|
@@ -7,15 +7,25 @@ import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.document.ChartUtil;
|
|
|
import com.ruoyi.common.utils.document.DocumentHandler;
|
|
|
import com.ruoyi.common.utils.document.PDFTemplateUtil;
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
import com.ruoyi.framework.config.RuoYiConfig;
|
|
|
import com.ruoyi.project.sems.domain.TMeasureRecord;
|
|
|
+import com.ruoyi.project.sems.domain.TSpecdevCc;
|
|
|
import com.ruoyi.project.sems.service.ITMeasureRecordService;
|
|
|
+import com.ruoyi.project.system.domain.SysDept;
|
|
|
+import com.ruoyi.project.system.domain.SysDictData;
|
|
|
import freemarker.template.Template;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+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.jfree.data.category.DefaultCategoryDataset;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -62,16 +72,16 @@ public class TMeasureThicknessController extends BaseController
|
|
|
if (measureRecords.size() > 0) {
|
|
|
m.setFirstMeasureDate(measureRecords.get(measureRecords.size() - 1).getMeasureDate());
|
|
|
m.setNewMeasureDate(measureRecords.get(0).getMeasureDate());
|
|
|
- BigDecimal measureCycle = new BigDecimal(m.getMeasureCycle());
|
|
|
- BigDecimal yearNum = new BigDecimal("31536000000");
|
|
|
- Long cycle = measureCycle.multiply(yearNum).longValue();
|
|
|
- Long newTime = measureRecords.get(0).getMeasureDate().getTime();
|
|
|
- Long nextTime = newTime + cycle;
|
|
|
- Date dat = new Date(nextTime);
|
|
|
- GregorianCalendar nextMeasureDate = new GregorianCalendar();
|
|
|
- nextMeasureDate.setTime(dat);
|
|
|
- java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
|
|
- m.setNextMeasureDate(format.format(nextMeasureDate.getTime()));
|
|
|
+// BigDecimal measureCycle = new BigDecimal(m.getMeasureCycle());
|
|
|
+// BigDecimal yearNum = new BigDecimal("31536000000");
|
|
|
+// Long cycle = measureCycle.multiply(yearNum).longValue();
|
|
|
+// Long newTime = measureRecords.get(0).getMeasureDate().getTime();
|
|
|
+// Long nextTime = newTime;
|
|
|
+// Date dat = new Date(nextTime);
|
|
|
+// GregorianCalendar nextMeasureDate = new GregorianCalendar();
|
|
|
+// nextMeasureDate.setTime(dat);
|
|
|
+// java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
|
|
+// m.setNextMeasureDate(format.format(nextMeasureDate.getTime()));
|
|
|
}else {
|
|
|
m.setFirstMeasureDate(null);
|
|
|
m.setNewMeasureDate(null);
|
|
@@ -82,7 +92,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
int day = this.formatDate(m.getNextWarnDate(),new Date());
|
|
|
BigDecimal remain = new BigDecimal(m.getEstRemain()).multiply(new BigDecimal("365")).setScale(4,BigDecimal.ROUND_HALF_DOWN);
|
|
|
logger.info(day +"::::" + remain);
|
|
|
- if (remain.compareTo(new BigDecimal(day)) == 1) {
|
|
|
+ if (remain.compareTo(new BigDecimal(day)) == -1) {
|
|
|
m.setWarnFlag(1);
|
|
|
}else {
|
|
|
m.setWarnFlag(0);
|
|
@@ -94,6 +104,140 @@ public class TMeasureThicknessController extends BaseController
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量导入
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('sems:thickness:add')")
|
|
|
+ @Log(title = "侧厚批量导入", businessType = BusinessType.INSERT)
|
|
|
+ @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<TMeasureThickness> list = new ArrayList<TMeasureThickness>();
|
|
|
+ //字典查询
|
|
|
+
|
|
|
+ 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.getLastCellNum();
|
|
|
+ TMeasureThickness entity = new TMeasureThickness();
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
+ if (cell == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String cellValue = ExcelUtils.getCellValue(cell);
|
|
|
+ logger.info("cellValue:" + cellValue);
|
|
|
+ if (j == 0) {
|
|
|
+ //序号
|
|
|
+ } else if (j == 1) {
|
|
|
+ entity.setPlantCode(cellValue);//装置名称
|
|
|
+ } else if (j == 2) {
|
|
|
+ entity.setUnitCode(cellValue);//单元名称
|
|
|
+ } else if (j == 3) {
|
|
|
+ entity.setTagno(cellValue);//单位内编号
|
|
|
+ } else if (j == 4) {
|
|
|
+ entity.setPosition(cellValue);//测厚部位CML
|
|
|
+ } else if (j == 5) {
|
|
|
+ entity.setMeasureNo(cellValue);//检测编号
|
|
|
+ } else if (j == 6) {
|
|
|
+ entity.setEquipmentName(cellValue);//设备/管线名称
|
|
|
+ } else if (j == 7) {
|
|
|
+ entity.setMaterial(cellValue);//材质
|
|
|
+ } else if (j == 8) {
|
|
|
+ entity.setNominalTickness(cellValue);//公称壁厚(mm)
|
|
|
+ } else if (j == 9) {
|
|
|
+ entity.setThicknessMin(cellValue);//最小允许壁厚(mm)
|
|
|
+ } else if (j == 10) {
|
|
|
+ entity.setStCorrosion(cellValue);//短期腐蚀速率(mm/year)
|
|
|
+ } else if (j == 11) {
|
|
|
+ entity.setLtCorrosion(cellValue);//长期腐蚀速率(mm/year)
|
|
|
+ } else if (j == 12) {
|
|
|
+ if (cellValue.length() > 3) {//下次测厚日期
|
|
|
+ entity.setNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 13) {
|
|
|
+ entity.setInspectionMethod(cellValue);//检测方法
|
|
|
+ } else if (j == 14) {
|
|
|
+ entity.setCorAllowance(cellValue);//腐蚀裕度(mm)
|
|
|
+ } else if (j == 15) {
|
|
|
+ entity.setOriginalThickness(cellValue);//原始壁厚(mm)
|
|
|
+ } else if (j == 16) {
|
|
|
+ entity.setMedium(cellValue);//介质
|
|
|
+ } else if (j == 17) {
|
|
|
+ entity.setPressure(cellValue);//压力(MPa)
|
|
|
+ } else if (j == 18) {
|
|
|
+ entity.setSpecification(cellValue); //规格
|
|
|
+ } else if (j == 19) {
|
|
|
+ entity.setFlowRate(cellValue);//流速(m/s)
|
|
|
+ } else if (j == 20) {
|
|
|
+ //温度(℃)
|
|
|
+ entity.setTemperature(cellValue);
|
|
|
+ } else if (j == 21) {
|
|
|
+ //腐蚀类型
|
|
|
+ entity.setCorrosionType(cellValue);
|
|
|
+ } else if (j == 22) {
|
|
|
+ entity.setAnalysis(cellValue);//原因分析
|
|
|
+ }else if (j == 23) {
|
|
|
+ entity.setMethodCause(cellValue);//治理方法及依据
|
|
|
+ } else if (j == 24) {
|
|
|
+ entity.setEffectTracing(cellValue); //效果跟踪
|
|
|
+ }else if (j == 25) {
|
|
|
+ entity.setRaiser(cellValue);//提出人
|
|
|
+ }else if (j == 26) {
|
|
|
+ if (cellValue.length() > 3) {//提出时间
|
|
|
+ entity.setRaiserDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ }else if (j == 27) {
|
|
|
+ entity.setOtherContent(cellValue);//其他检测方法内容
|
|
|
+ }else if (j == 28) {
|
|
|
+ entity.setRecorder(cellValue);//记录人
|
|
|
+ }else if (j == 29) {
|
|
|
+ if (cellValue.length() > 3) {//记录时间
|
|
|
+ entity.setRecorderDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ }else if (j == 30) {
|
|
|
+ entity.setRemarks(cellValue);//备注
|
|
|
+ }
|
|
|
+ }
|
|
|
+ entity.setCreateBy(userId.toString());
|
|
|
+ logger.info("entity:" + entity);
|
|
|
+ list.add(entity);
|
|
|
+ }catch (Exception e){
|
|
|
+ failNumber++;
|
|
|
+ logger.info("e:" + JSON.toJSONString(e));
|
|
|
+ failRow.add(i + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int successNumber = 0;
|
|
|
+ int failNum = 0;
|
|
|
+ for (TMeasureThickness t : list
|
|
|
+ ) {
|
|
|
+ failNum++;
|
|
|
+ try {
|
|
|
+ tMeasureThicknessService.insertTMeasureThickness(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);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出定点测厚列表
|
|
|
*/
|