Forráskód Böngészése

Merge branch 'master' of http://47.114.101.16:7070/ssy/newcpms

dengliying 11 hónapja
szülő
commit
c07cfad3b1

+ 22 - 1
master/src/main/java/com/ruoyi/project/production/controller/TFurnancePressureController.java

@@ -79,7 +79,9 @@ public class TFurnancePressureController extends BaseController
     public AjaxResult scan(@RequestParam("file") MultipartFile file,
                            @RequestParam("furnanceName") String furnanceName,
                            @RequestParam("pass") int pass,
-                           @RequestParam("isInlet") boolean isInlet) throws IOException {
+                           @RequestParam("isInlet") boolean isInlet,
+                           @RequestParam("pType") String pType,
+                           @RequestParam("pId") String pId) throws IOException {
         // 判断图片中的压力仪表数量
         int num = 0;
         switch (furnanceName) {
@@ -225,9 +227,28 @@ public class TFurnancePressureController extends BaseController
             case "H130":
                 break;
         }
+
+        // 上传图片
+        if (file.isEmpty())
+        {
+            return AjaxResult.error("上传失败,文件为空!");
+        }
+        String url = FileUploadUtils.upload(RuoYiConfig.getFilePath("/"+ pType), file);
+        long size = file.getSize()/1024;
+        TCommonfile tCommonfile = new TCommonfile();
+        tCommonfile.setFileUrl(url);
+        tCommonfile.setFileName(file.getOriginalFilename());
+        tCommonfile.setCreaterCode(String.valueOf(getUserId()));
+        tCommonfile.setpId(Long.parseLong(pId));
+        tCommonfile.setpType(pType);
+        tCommonfile.setFileSize(String.valueOf(size));
+        tCommonfileService.insertTCommonfile(tCommonfile);
+
         //组装返回
         JSONObject returnObj = new JSONObject();
         returnObj.put("readings", newArray);
+        returnObj.put("fileName", tCommonfile.getFileName());
+        returnObj.put("url", tCommonfile.getFileUrl());
         return AjaxResult.success(returnObj);
     }