Jelajahi Sumber

裂解炉炉管测压 - 现场照片上传(APP)

wangggziwen 11 bulan lalu
induk
melakukan
39f194d296

+ 64 - 8
master/src/main/java/com/ruoyi/project/production/controller/TFurnancePressureController.java

@@ -1,11 +1,17 @@
 package com.ruoyi.project.production.controller;
 
+import java.io.IOException;
 import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.common.utils.file.FileUtils;
+import com.ruoyi.framework.config.RuoYiConfig;
+import com.ruoyi.project.common.domain.TCommonfile;
+import com.ruoyi.project.common.service.ITCommonfileService;
 import com.ruoyi.project.production.controller.vo.FurnancePressureFvpVO;
 import com.ruoyi.project.production.controller.vo.FurnancePressureVO;
 import com.ruoyi.project.production.controller.vo.FvpAnalysisQueryVO;
@@ -13,14 +19,7 @@ import com.ruoyi.project.production.domain.TFurnanceTemperature;
 import com.ruoyi.project.production.mapper.TFurnancePressureMapper;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
 import com.ruoyi.project.production.domain.TFurnancePressure;
@@ -29,6 +28,7 @@ import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.web.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -47,6 +47,62 @@ public class TFurnancePressureController extends BaseController
     @Autowired
     private TFurnancePressureMapper tFurnancePressureMapper;
 
+    @Autowired
+    private ITCommonfileService tCommonfileService;
+
+    /**
+     * 现场照片上传(APP)
+     */
+    @PostMapping("/uploadFile")
+    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, String pType, String pId) throws IOException
+    {
+        if (!file.isEmpty())
+        {
+            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);
+
+            AjaxResult ajax = AjaxResult.success();
+            ajax.put("url", tCommonfile.getFileUrl());
+            ajax.put("fileName", tCommonfile.getFileName());
+            return ajax;
+        }
+        return AjaxResult.error("上传失败,请联系管理员");
+    }
+
+//    public AjaxResult getPressureSummary() {
+//        TFurnancePressure query = new TFurnancePressure();
+//        query.setRecordTime(new Date());
+//        List<TFurnancePressure> result = tFurnancePressureService.selectTFurnancePressureList(query);
+//        for (TFurnancePressure pressure : result) {
+//            String furnanceName = pressure.getFurnanceName();
+//            switch (furnanceName) {
+//                case "H109":
+//                    break;
+//                case "H110":
+//                case "H111":
+//                case "H112":
+//                case "H113":
+//                case "H114":
+//                case "H115":
+//                case "H116":
+//                case "H117":
+//                case "H118":
+//                    break;
+//                case "H130":
+//                    break;
+//            }
+//        }
+//        return AjaxResult.success();
+//    }
+
     /**
      * 获取裂解炉炉管测压fvp分析数据
      */