ly hace 3 años
padre
commit
66f85d4e4f

+ 3 - 0
master/src/main/java/com/ruoyi/project/common/CommonController.java

@@ -287,6 +287,9 @@ public class CommonController extends BaseController
         }else if( type.equals("thickness") ) {
             downloadname = "定点测厚批量导入更新模板.xlsx";
             url = "static/template/sems/thickness.xlsx";
+        }else if( type.equals("thicknessData") ) {
+            downloadname = "定点测厚数据导入模板.xlsx";
+            url = "static/template/sems/thicknessData.xlsx";
         }
         InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(url);
 

+ 1 - 1
master/src/main/java/com/ruoyi/project/sems/controller/SpecHomeController.java

@@ -191,7 +191,7 @@ public class SpecHomeController extends BaseController
                 .eq("del_flag" , 0)
                 .in("plant_code",plantIds)
                 .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
-                .like("CHECK_STRATEGY","委托")
+                .notLike("CHECK_STRATEGY","强制")
                 .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
         );
 

+ 2 - 1
master/src/main/java/com/ruoyi/project/sems/controller/TMeasureRecordController.java

@@ -233,7 +233,8 @@ public class TMeasureRecordController extends BaseController {
                 String measureId = t.getMeasureId();
                 String[] split = measureId.split(",");
                 Long id = this.tMeasureThicknessService.selectByTagNo(split[0], split[1]);
-                t.setMeasureId(id + "");
+                logger.info(id.toString());
+                t.setMeasureId(id.toString());
                 this.tMeasureRecordService.insertTMeasureRecord(t);
                 this.updateMeasure(id + "");
                 successNumber++;

+ 155 - 11
master/src/main/java/com/ruoyi/project/sems/controller/TMeasureThicknessController.java

@@ -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);
+    }
+
     /**
      * 导出定点测厚列表
      */

+ 0 - 1
master/src/main/java/com/ruoyi/project/sems/controller/TSpecdevCcController.java

@@ -451,7 +451,6 @@ public class TSpecdevCcController extends BaseController
             }
             if (t.getNextWarnDate()!= null){
                 row.createCell(5).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextWarnDate()));
-
             }
             row.createCell(6).setCellValue(t.getReportNo());
             row.createCell(7).setCellValue(t.getPerTestConclusion());

+ 3 - 3
master/src/main/java/com/ruoyi/project/sems/controller/TSpecdevDzsbController.java

@@ -310,11 +310,11 @@ public class TSpecdevDzsbController extends BaseController
                         entity.setId(s);
                     } else if (j == 1) {    //装置
                         entity.setPlantCode(cellValue);
-                    } else if (j == 3) {    //设备位号
+                    } else if (j == 2) {    //设备位号
                         entity.setDevno(cellValue);
-                    } else if (j == 4) {    //档案号
+                    } else if (j == 3) {    //档案号
                         entity.setDocno(cellValue);
-                    } else if (j == 2) {    //设备名称
+                    } else if (j == 4) {    //设备名称
                         entity.setDevname(cellValue);
                     } else if (j == 5) {    //检验单位
                         entity.setCheckUnit(cellValue);

+ 2 - 0
master/src/main/resources/mybatis/sems/TMeasureThicknessMapper.xml

@@ -108,9 +108,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectByTagNo" resultType="Long">
         select id from t_measure_thickness
             <where>
+                del_flag = 0
                 <if test="tagNo != null  and tagNo != ''"> and tagno = #{tagNo}</if>
                 <if test="position != null  and position != ''"> and position = #{position}</if>
             </where>
+
     </select>
 
     <insert id="insertTMeasureThickness" parameterType="TMeasureThickness">

BIN
master/src/main/resources/static/template/sems/thicknessData.xlsx


+ 3 - 0
ui/src/utils/ruoyi.js

@@ -79,6 +79,9 @@ export function selectDictLabel(datas, value) {
 
 // 回显数据字典(字符串数组)
 export function selectDictLabels(datas, value, separator) {
+  if (!value) {
+    return
+  }
 	var actions = [];
 	var currentSeparator = undefined === separator ? "," : separator;
 	var temp = value.split(currentSeparator);

+ 119 - 23
ui/src/views/sems/thickness/index.vue

@@ -182,6 +182,17 @@
         >{{ $t('删除') }}</el-button>
       </el-col>
 
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          icon="el-icon-upload2"
+          size="mini"
+          @click="handleImportData"
+          v-hasPermi="['sems:thickness:add']"
+        >{{$t('导入')}}
+        </el-button>
+      </el-col>
+
       <el-col :span="1.5">
         <el-button
           type="warning"
@@ -799,11 +810,44 @@
            </el-table>
          </template>
 
-
       <span slot="footer" class="dialog-footer">
       <el-button @click="visible = false">{{ $t('取消') }}</el-button>
     </span>
     </el-dialog>
+    <!-- 侧厚导入对话框 -->
+    <el-dialog :title="uploadThickness.title" :visible.sync="uploadThickness.open" width="400px" append-to-body>
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="uploadThickness.headers"
+        :action="uploadThickness.url + '?updateSupport=' + uploadThickness.updateSupport"
+        :disabled="uploadThickness.isUploading"
+        :on-progress="handleFileUploadProgress2"
+        :on-success="handleFileSuccess2"
+        :auto-upload="false"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          将文件拖到此处,或
+          <em>点击上传</em>
+        </div>
+        <div class="el-upload__tip" slot="tip">
+          <el-link type="info" style="font-size:12px" @click="importTemplateData">下载模板</el-link>
+        </div>
+        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm"
+                   v-loading.fullscreen.lock="fullscreenLoading">确 定</el-button>
+        <el-button @click="uploadThickness.open = false">取 消</el-button>
+      </div>
+      <form ref="downloadFileDataForm" :action="uploadThickness.downloadAction" target="FORMSUBMIT">
+        <input name="type" :value="uploadThickness.type" hidden/>
+      </form>
+    </el-dialog>
+
     <!-- 用户导入对话框 -->
     <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
       <el-upload
@@ -889,25 +933,44 @@ export default {
       inspectionMethodOptions: [],
       statusOptions:[],
       plantOptions: [],
-        // 用户导入参数
-        upload: {
-            //模板下载路由
-            downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
-            //模板下载区分
-            type: "thickness",
-            // 是否显示弹出层(用户导入)
-            open: false,
-            // 弹出层标题(用户导入)
-            title: "",
-            // 是否禁用上传
-            isUploading: false,
-            // 是否更新已经存在的用户数据
-            updateSupport: 0,
-            // 设置上传的请求头部
-            headers: { Authorization: "Bearer " + getToken() },
-            // 上传的地址
-            url: process.env.VUE_APP_BASE_API + "/sems/measure-record/importForUpdate"
-        },
+      // 用户导入参数
+      upload: {
+          //模板下载路由
+          downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
+          //模板下载区分
+          type: "thickness",
+          // 是否显示弹出层(用户导入)
+          open: false,
+          // 弹出层标题(用户导入)
+          title: "",
+          // 是否禁用上传
+          isUploading: false,
+          // 是否更新已经存在的用户数据
+          updateSupport: 0,
+          // 设置上传的请求头部
+          headers: { Authorization: "Bearer " + getToken() },
+          // 上传的地址
+          url: process.env.VUE_APP_BASE_API + "/sems/measure-record/importForUpdate"
+      },
+      // 用户导入参数
+      uploadThickness: {
+        //模板下载路由
+        downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
+        //模板下载区分
+        type: "thicknessData",
+        // 是否显示弹出层(用户导入)
+        open: false,
+        // 弹出层标题(用户导入)
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 设置上传的请求头部
+        headers: { Authorization: "Bearer " + getToken() },
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/sems/thickness/importData"
+      },
       downloadForm: {
         id: '',
         key: ''
@@ -1324,6 +1387,15 @@ export default {
           this.download(response.msg);
         })
     },
+      /** 导入按钮操作 */
+      handleImportData() {
+        this.uploadThickness.title = this.$t('导入数据');
+        this.uploadThickness.open = true;
+      },
+      /** 下载侧厚模板操作 */
+      importTemplateData() {
+        this.$refs['downloadFileDataForm'].submit()
+      },
       /** 导入按钮操作 */
       handleImport() {
           this.upload.title = this.$t('导入更新数据');
@@ -1359,6 +1431,32 @@ export default {
           this.$refs.upload.submit();
           this.fullscreenLoading = true;
       },
+    // 文件上传中处理
+    handleFileUploadProgress2(event, file, fileList) {
+      this.uploadThickness.isUploading = true;
+    },
+    // 文件上传成功处理
+    handleFileSuccess2(response, file, fileList) {
+      this.uploadThickness.open = false;
+      this.uploadThickness.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.fullscreenLoading = false;
+      if (response.data.length > 0) {
+        let failrow = ''
+        for (let i = 0; i < response.data.length; i++) {
+          failrow += response.data[i] + ','
+        }
+        this.$alert(this.$t('导入成功条数:') + response.msg + '<br>' + this.$t('失败行数:') + failrow, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      } else {
+        this.$alert(this.$t('导入成功条数:') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      }
+      this.getList();
+    },
+    // 提交上传文件
+    submitFileForm2() {
+      this.$refs.uploadThickness.submit();
+      this.fullscreenLoading = true;
+    },
       //下载报告
       downloadHandle (row) {
         this.downloadForm.id = row.id;
@@ -1427,10 +1525,8 @@ export default {
 
     //寿命颜色预警
     tableCellStyle({ row, column, rowIndex, columnIndex }) {
-     if (columnIndex == 18 && row.warnFlag == 1){
+     if (columnIndex == 15 && row.warnFlag == 1){
         return "color: rgba(255, 26, 26, 0.98) "
-      }else if (columnIndex == 17 && row.warnFlag == 1){
-       return "color: rgba(255, 26, 26, 0.98) "
       }
     },
 

+ 1 - 0
ui/src/views/sems/thickness/record.vue

@@ -248,6 +248,7 @@ export default {
       var that = this;
       that.loading = true;
       this.form = row;
+      this.form.measureId = this.queryParams.measureId
       if (row.isAdd == true) {
         addMeasurerecord(this.form).then(response => {
           this.msgSuccess(this.$t('新增成功'));