|
@@ -1,16 +1,26 @@
|
|
|
package com.ruoyi.project.monitor.controller;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
+import com.ruoyi.project.production.domain.TSaiApply;
|
|
|
+import com.ruoyi.project.system.domain.SysDept;
|
|
|
+import com.ruoyi.project.system.domain.SysDictData;
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.service.ISysDictTypeService;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
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.monitor.domain.TPfd;
|
|
@@ -19,6 +29,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;
|
|
|
|
|
|
/**
|
|
|
* PFD管理Controller
|
|
@@ -58,6 +69,202 @@ public class TPfdController extends BaseController
|
|
|
return util.exportExcel(list, "pfdmgr");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入PFD管理列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('production:apply:add')")
|
|
|
+ @PostMapping("/importData")
|
|
|
+ public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException
|
|
|
+ {
|
|
|
+ //获取操作人员ID
|
|
|
+ Long userId = getUserId();
|
|
|
+ //报错行数统计
|
|
|
+ List<Integer> failRow =new ArrayList<Integer>();
|
|
|
+ Workbook workbook = ExcelUtils.getWorkBook(file);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ List<TPfd> list = new ArrayList<TPfd>();
|
|
|
+ int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
+ int failNumber = 0;
|
|
|
+ for (int i = 1; i <= rowNum; i++) {
|
|
|
+ try {
|
|
|
+ logger.info("读取行数:" + i);
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ int cellNum = row.getPhysicalNumberOfCells();
|
|
|
+ TPfd entity = new TPfd();
|
|
|
+ entity.setCreateTime(new Date());
|
|
|
+ entity.setCreateBy(userId.toString());
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
+ String cellValue = ExcelUtils.getCellValue(cell);
|
|
|
+ logger.info("cellValue:" + cellValue);
|
|
|
+ if (j == 0) {
|
|
|
+ entity.setCode(cellValue);
|
|
|
+ } else if (j == 1) {
|
|
|
+ entity.setDescription(cellValue);
|
|
|
+ } else if (j == 2) {
|
|
|
+ entity.setH2o(cellValue);
|
|
|
+ } else if (j == 3) {
|
|
|
+ entity.setHydrogen(cellValue);
|
|
|
+ } else if (j == 4) {
|
|
|
+ entity.setCo(cellValue);
|
|
|
+ } else if (j == 5) {
|
|
|
+ entity.setMethane(cellValue);
|
|
|
+ } else if (j == 6) {
|
|
|
+ entity.setAcetyln(cellValue);
|
|
|
+ } else if (j == 7) {
|
|
|
+ entity.setEthylene(cellValue);
|
|
|
+ } else if (j == 8) {
|
|
|
+ entity.setEthane(cellValue);
|
|
|
+ } else if (j == 9) {
|
|
|
+ entity.setMacetyln(cellValue);
|
|
|
+ } else if (j == 10) {
|
|
|
+ entity.setPropdien(cellValue);
|
|
|
+ } else if (j == 11) {
|
|
|
+ entity.setPropylen(cellValue);
|
|
|
+ } else if (j == 12) {
|
|
|
+ entity.setPropane(cellValue);
|
|
|
+ } else if (j == 13) {
|
|
|
+ entity.setButd13(cellValue);
|
|
|
+ } else if (j == 14) {
|
|
|
+ entity.setButene1(cellValue);
|
|
|
+ } else if (j == 15) {
|
|
|
+ entity.setIbte(cellValue);
|
|
|
+ } else if (j == 16) {
|
|
|
+ entity.setC2butene(cellValue);
|
|
|
+ } else if (j == 17) {
|
|
|
+ entity.setT2butene(cellValue);
|
|
|
+ } else if (j == 18) {
|
|
|
+ entity.setIbutane(cellValue);
|
|
|
+ } else if (j == 19) {
|
|
|
+ entity.setButane(cellValue);
|
|
|
+ } else if (j == 20) {
|
|
|
+ entity.setCpd13(cellValue);
|
|
|
+ } else if (j == 21) {
|
|
|
+ entity.setIsoprene(cellValue);
|
|
|
+ } else if (j == 22) {
|
|
|
+ entity.setC13pnd(cellValue);
|
|
|
+ } else if (j == 23) {
|
|
|
+ entity.setPentene1(cellValue);
|
|
|
+ } else if (j == 24) {
|
|
|
+ entity.setIpentane(cellValue);
|
|
|
+ } else if (j == 25) {
|
|
|
+ entity.setPentane(cellValue);
|
|
|
+ } else if (j == 26) {
|
|
|
+ entity.setHexene1(cellValue);
|
|
|
+ } else if (j == 27) {
|
|
|
+ entity.setBenzene(cellValue);
|
|
|
+ } else if (j == 28) {
|
|
|
+ entity.setToluene(cellValue);
|
|
|
+ } else if (j == 29) {
|
|
|
+ entity.setOxylene(cellValue);
|
|
|
+ } else if (j == 30) {
|
|
|
+ entity.setC9200c(cellValue);
|
|
|
+ } else if (j == 31) {
|
|
|
+ entity.setFuelOil(cellValue);
|
|
|
+ } else if (j == 32) {
|
|
|
+ entity.setCo2(cellValue);
|
|
|
+ } else if (j == 33) {
|
|
|
+ entity.setH2s(cellValue);
|
|
|
+ } else if (j == 34) {
|
|
|
+ entity.setNbp25(cellValue);
|
|
|
+ } else if (j == 35) {
|
|
|
+ entity.setNbp58(cellValue);
|
|
|
+ } else if (j == 36) {
|
|
|
+ entity.setNbp72(cellValue);
|
|
|
+ } else if (j == 37) {
|
|
|
+ entity.setNbp86(cellValue);
|
|
|
+ } else if (j == 38) {
|
|
|
+ entity.setNbp100(cellValue);
|
|
|
+ } else if (j == 39) {
|
|
|
+ entity.setNbp114(cellValue);
|
|
|
+ } else if (j == 40) {
|
|
|
+ entity.setNbp128(cellValue);
|
|
|
+ } else if (j == 41) {
|
|
|
+ entity.setNbp141(cellValue);
|
|
|
+ } else if (j == 42) {
|
|
|
+ entity.setNbp155(cellValue);
|
|
|
+ } else if (j == 43) {
|
|
|
+ entity.setNbp169(cellValue);
|
|
|
+ } else if (j == 44) {
|
|
|
+ entity.setNbp183(cellValue);
|
|
|
+ } else if (j == 45) {
|
|
|
+ entity.setNbp199(cellValue);
|
|
|
+ } else if (j == 46) {
|
|
|
+ entity.setNbp207(cellValue);
|
|
|
+ } else if (j == 47) {
|
|
|
+ entity.setNbp222(cellValue);
|
|
|
+ } else if (j == 48) {
|
|
|
+ entity.setNbp236(cellValue);
|
|
|
+ } else if (j == 49) {
|
|
|
+ entity.setNbp249(cellValue);
|
|
|
+ } else if (j == 50) {
|
|
|
+ entity.setTotalMolarFlowrate(cellValue);
|
|
|
+ } else if (j == 51) {
|
|
|
+ entity.setTotalMassFlowrate(cellValue);
|
|
|
+ } else if (j == 52) {
|
|
|
+ entity.setTotalMolecularWeight(cellValue);
|
|
|
+ } else if (j == 53) {
|
|
|
+ entity.setTemperature(cellValue);
|
|
|
+ } else if (j == 54) {
|
|
|
+ entity.setPressure(cellValue);
|
|
|
+ } else if (j == 55) {
|
|
|
+ entity.setVaporMassFlowrate(cellValue);
|
|
|
+ } else if (j == 56) {
|
|
|
+ entity.setVaporMolecularWeight(cellValue);
|
|
|
+ } else if (j == 57) {
|
|
|
+ entity.setVaporDensityAct(cellValue);
|
|
|
+ } else if (j == 58) {
|
|
|
+ entity.setVaporZ(cellValue);
|
|
|
+ } else if (j == 59) {
|
|
|
+ entity.setVaporActVolFlow(cellValue);
|
|
|
+ } else if (j == 60) {
|
|
|
+ entity.setVaporHtCapacity(cellValue);
|
|
|
+ } else if (j == 61) {
|
|
|
+ entity.setVaporViscosity(cellValue);
|
|
|
+ } else if (j == 62) {
|
|
|
+ entity.setLiquidMassFlowrate(cellValue);
|
|
|
+ } else if (j == 63) {
|
|
|
+ entity.setLiquidMolecularWeight(cellValue);
|
|
|
+ } else if (j == 64) {
|
|
|
+ entity.setLiquidDensityAct(cellValue);
|
|
|
+ } else if (j == 65) {
|
|
|
+ entity.setLiquidActVolFlow(cellValue);
|
|
|
+ } else if (j == 66) {
|
|
|
+ entity.setLiquidHtCapacity(cellValue);
|
|
|
+ } else if (j == 67) {
|
|
|
+ entity.setLiquidViscosity(cellValue);
|
|
|
+ } else if (j == 68) {
|
|
|
+ entity.setLiquidSurfTension(cellValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("entity:" + entity);
|
|
|
+ list.add(entity);
|
|
|
+ }catch (Exception e){
|
|
|
+ failNumber++;
|
|
|
+ failRow.add(i+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int successNumber = 0;
|
|
|
+ int failNum = 0;
|
|
|
+ for (TPfd t : list
|
|
|
+ ) {
|
|
|
+ failNum++;
|
|
|
+ try {
|
|
|
+ tPfdService.insertTPfd(t);
|
|
|
+ successNumber++;
|
|
|
+ }catch (Exception e){
|
|
|
+ failNumber++;
|
|
|
+ logger.info("e:" + e);
|
|
|
+ failRow.add(failNum+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("list:" + JSON.toJSONString(list));
|
|
|
+ logger.info("successNumber:" +String.valueOf(successNumber));
|
|
|
+ logger.info("failNumber:" +String.valueOf(failNumber));
|
|
|
+ logger.info("failRow:" +String.valueOf(failRow));
|
|
|
+ return AjaxResult.success(String.valueOf(successNumber), failRow);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取PFD管理详细信息
|
|
|
*/
|