|
@@ -426,11 +426,110 @@ public class MesProductRecordController extends BaseController {
|
|
|
|
|
|
|
|
mesProductRecordService.update(mesProductRecord);
|
|
mesProductRecordService.update(mesProductRecord);
|
|
|
|
|
|
|
|
|
|
+ // 保存上传的图片和附件
|
|
|
|
|
+ FileUploadUtils.saveFileUpload(mesProductRecord, mesProductRecord.getId(), "mesProductRecord_image");
|
|
|
|
|
+ FileUploadUtils.saveFileUpload(mesProductRecord, mesProductRecord.getId(), "mesProductRecord_file");
|
|
|
|
|
|
|
|
return renderResult(Global.TRUE, text("保存生产记录成功!"));
|
|
return renderResult(Global.TRUE, text("保存生产记录成功!"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 查询某条记录关联的附件列表(用于详情页"查看"按钮)
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductRecord:view")
|
|
|
|
|
+ @RequestMapping(value = "fileList")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public List<Map<String, Object>> fileList(String bizKey, String bizType) {
|
|
|
|
|
+ List<Map<String, Object>> result = ListUtils.newArrayList();
|
|
|
|
|
+ if (StringUtils.isBlank(bizKey) || StringUtils.isBlank(bizType)) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ FileUpload fu = new FileUpload();
|
|
|
|
|
+ fu.setBizKey(bizKey);
|
|
|
|
|
+ fu.setBizType(bizType);
|
|
|
|
|
+ List<FileUpload> list = fileUploadService.findList(fu);
|
|
|
|
|
+ if (ListUtils.isEmpty(list)) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (FileUpload fi : list) {
|
|
|
|
|
+ Map<String, Object> map = MapUtils.newHashMap();
|
|
|
|
|
+ map.put("fileName", fi.getFileName());
|
|
|
|
|
+ map.put("fileUrl", fi.getFileUrl());
|
|
|
|
|
+ if (fi.getFileEntity() != null) {
|
|
|
|
|
+ map.put("fileId", fi.getFileEntity().getFileId());
|
|
|
|
|
+ }
|
|
|
|
|
+ result.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 内联预览附件(在线查看)。
|
|
|
|
|
+ * 根据 bizKey + bizType + fileUrl 找到对应文件,从磁盘读取文件流输出,
|
|
|
|
|
+ * Content-Disposition 设为 inline 让浏览器尽量预览而不是下载。
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductRecord:view")
|
|
|
|
|
+ @RequestMapping(value = "viewFile")
|
|
|
|
|
+ public void viewFile(String bizKey, String bizType, String fileUrl,
|
|
|
|
|
+ javax.servlet.http.HttpServletResponse response) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (StringUtils.isBlank(bizKey) || StringUtils.isBlank(bizType) || StringUtils.isBlank(fileUrl)) {
|
|
|
|
|
+ response.sendError(404, "params missing");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ FileUpload q = new FileUpload();
|
|
|
|
|
+ q.setBizKey(bizKey);
|
|
|
|
|
+ q.setBizType(bizType);
|
|
|
|
|
+ List<FileUpload> list = fileUploadService.findList(q);
|
|
|
|
|
+ if (ListUtils.isEmpty(list)) {
|
|
|
|
|
+ response.sendError(404, "file not found");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ FileUpload fu = null;
|
|
|
|
|
+ for (FileUpload f : list) {
|
|
|
|
|
+ if (fileUrl.equals(f.getFileUrl())) {
|
|
|
|
|
+ fu = f;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fu == null) {
|
|
|
|
|
+ response.sendError(404, "file not found");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String url = fu.getFileUrl();
|
|
|
|
|
+ String baseDir = Global.getConfig("file.baseDir");
|
|
|
|
|
+ if (StringUtils.isBlank(baseDir)) {
|
|
|
|
|
+ baseDir = System.getProperty("user.home");
|
|
|
|
|
+ }
|
|
|
|
|
+ java.io.File file = new java.io.File(baseDir, url);
|
|
|
|
|
+ if (!file.exists() || !file.isFile()) {
|
|
|
|
|
+ response.sendError(404, "file not exist on disk: " + file.getAbsolutePath());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String contentType = java.net.URLConnection.guessContentTypeFromName(file.getName());
|
|
|
|
|
+ if (StringUtils.isBlank(contentType)) {
|
|
|
|
|
+ contentType = "application/octet-stream";
|
|
|
|
|
+ }
|
|
|
|
|
+ response.setContentType(contentType);
|
|
|
|
|
+ response.setContentLengthLong(file.length());
|
|
|
|
|
+ String encodedName = java.net.URLEncoder.encode(fu.getFileName(), "UTF-8").replace("+", "%20");
|
|
|
|
|
+ response.setHeader("Content-Disposition", "inline; filename*=UTF-8''" + encodedName);
|
|
|
|
|
+
|
|
|
|
|
+ try (java.io.InputStream in = new java.io.FileInputStream(file);
|
|
|
|
|
+ java.io.OutputStream out = response.getOutputStream()) {
|
|
|
|
|
+ byte[] buf = new byte[8192];
|
|
|
|
|
+ int len;
|
|
|
|
|
+ while ((len = in.read(buf)) != -1) {
|
|
|
|
|
+ out.write(buf, 0, len);
|
|
|
|
|
+ }
|
|
|
|
|
+ out.flush();
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("内联预览文件失败", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 保存数据 创建生产订单,都可以创建----
|
|
* 保存数据 创建生产订单,都可以创建----
|
|
|
*/
|
|
*/
|
|
|
// @RequiresPermissions("mes:mesProductRecord:edit")
|
|
// @RequiresPermissions("mes:mesProductRecord:edit")
|