Ver código fonte

检定完善

xiongchao 3 anos atrás
pai
commit
3845009f43

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/mapper/check/CheckStandardMapper.java

@@ -38,5 +38,5 @@ public interface CheckStandardMapper extends MyMapper<CheckStandard> {
      */
     List<CheckStandardVO> selectProjectStandardList(String projectId);
 
-    void updataBatch(List<CheckStandard> updateStandardList);
+    void updateBatch(List<CheckStandard> updateStandardList);
 }

+ 86 - 5
platform-dao/src/main/java/com/platform/dao/util/CustomExcelImportUtil.java

@@ -10,9 +10,7 @@ import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.sb.SbModel;
 import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
 import com.platform.dao.entity.store.SpareStore;
-import com.platform.dao.enums.CheckStandardTypeEnum;
-import com.platform.dao.enums.SbInfoChildEnum;
-import com.platform.dao.enums.SbInfoShowEnum;
+import com.platform.dao.enums.*;
 import com.platform.dao.vo.export.sb.ExportSbInfoVO;
 import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
 import com.platform.dao.vo.sb.SbInfoVO;
@@ -459,13 +457,13 @@ public class CustomExcelImportUtil {
     public static void main(String[] args) throws IOException, InvalidFormatException {
         //String path = "C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson";
         //File dirFile = new File("C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson");
-        String[] files = {"C:\\Users\\cyz\\\\Downloads\\2021.8.3设备基础导入 修改设备等级 设备类型 自定义类型.xls"};
+        String[] files = {"C:\\Users\\cyz\\\\Downloads\\保养标准20210812160348862.xls"};
         for(String fileStr:files){
             System.out.println(fileStr);
             InputStream inputstream = new FileInputStream(fileStr);
             LocalDateTime now = LocalDateTime.now();
             //List<SbInfoVO> list = importSbInfoList(inputstream);
-            List<SbInfoVO> list = importListByUpdateALl(inputstream);
+            List<CheckStandard> list = importCheckStandardListByUpdate(inputstream);
            list.forEach(item -> {
                 System.out.println(item.toString());
             });
@@ -995,6 +993,89 @@ public class CustomExcelImportUtil {
         return result;
     }
 
+    /**
+     * 导入修改,导入的模板是导出的ExportCheckStandardVO
+     *
+     * @param inputstream
+     * @return
+     * @throws IOException
+     * @throws InvalidFormatException
+     */
+    public static List<CheckStandard> importCheckStandardListByUpdate(InputStream inputstream) throws IOException, InvalidFormatException {
+        if (inputstream == null) {
+            return Collections.emptyList();
+        }
+        Workbook book = null;
+        if (!(inputstream.markSupported())) {
+            inputstream = new PushbackInputStream(inputstream, 8);
+        }
+        if (POIFSFileSystem.hasPOIFSHeader(inputstream)) {
+            book = new HSSFWorkbook(inputstream);
+        } else if (POIXMLDocument.hasOOXMLHeader(inputstream)) {
+            book = new XSSFWorkbook(OPCPackage.open(inputstream));
+        }
+        Sheet sheet = book.getSheetAt(0);
+        int rowCounts = sheet.getLastRowNum();
+        List<CheckStandard> result = new ArrayList<>(rowCounts);
+        CheckStandard record = null;
+        StringBuffer error = new StringBuffer();
+        LOGGER.info("文件行数:" + rowCounts);
+        for (int i = 2; i <= rowCounts; i++) {
+            record = new CheckStandard();
+            Row row = sheet.getRow(i);
+            if(isRowEmpty(row)){
+                break;
+            }
+            try {
+                record.setId(row.getCell(0).getStringCellValue().trim());
+                record.setName(row.getCell(3).getStringCellValue().trim());
+                record.setNo(row.getCell(4).getStringCellValue().trim());
+                record.setRequirement(row.getCell(5).getStringCellValue().trim());
+                record.setRemark(row.getCell(6).getStringCellValue().trim());
+                String period = row.getCell(7).getStringCellValue();
+                record.setPeriod(Double.valueOf(period).intValue());
+                String periodType = row.getCell(8).getStringCellValue();
+                if(periodType.equals("天")){
+                    record.setPeriodType(CheckPlanPeriodTypeEnum.DAY.getValue());
+                }else  if(periodType.equals("周")){
+                    record.setPeriodType(CheckPlanPeriodTypeEnum.WEEK.getValue());
+                }else  if(periodType.equals("月")){
+                    record.setPeriodType(CheckPlanPeriodTypeEnum.MONTH.getValue());
+                }else  if(periodType.equals("季度")){
+                    record.setPeriodType(CheckPlanPeriodTypeEnum.SEASON.getValue());
+                }else  if(periodType.equals("年")){
+                    record.setPeriodType(CheckPlanPeriodTypeEnum.YEAR.getValue());
+                }else  if(periodType.equals("公里")){
+                    record.setPeriodType(CheckPlanPeriodTypeEnum.MILES.getValue());
+                }else  if(periodType.equals("台时")){
+                    record.setPeriodType(CheckPlanPeriodTypeEnum.TAISHI.getValue());
+                }
+                String lastDate = row.getCell(9).getStringCellValue().trim();
+                String nextDate = row.getCell(10).getStringCellValue().trim();
+                if(StringUtils.isNotBlank(lastDate)){
+                    record.setLastDate(DateUtils.strToLocalDate(lastDate, DateUtils.PATTERN_YMD));
+                }
+                if(StringUtils.isNotBlank(nextDate)){
+                    record.setNextDate(DateUtils.strToLocalDate(nextDate, DateUtils.PATTERN_YMD));
+                }
+                String checkUserType = row.getCell(11).getStringCellValue().trim();
+                if(StringUtils.isBlank(checkUserType)){
+                    if(record.getPeriodType()>1){
+                        record.setCheckUserType(CheckUserTypeEnum.REPAIR_USER.getValue());
+                    }else{
+                        record.setCheckUserType(CheckUserTypeEnum.USE_USER.getValue());
+                    }
+                }else{
+                    record.setCheckUserType(Integer.valueOf(checkUserType));
+                }
+            } catch (Exception e) {
+                throw new BusinessException("导入异常,行号:"+ i + ", 错误信息" + e.getMessage() +  ", 错误原因" + e.getCause());
+            }
+            result.add(record);
+        }
+        return result;
+    }
+
     /**
      * 导入老版本的点检标准
      *

+ 35 - 50
platform-dao/src/main/java/com/platform/dao/vo/export/check/ExportCheckStandardVO.java

@@ -18,34 +18,31 @@ import java.time.LocalDateTime;
 public class ExportCheckStandardVO implements Serializable {
 
     /**
-   * 主键
+   * id
    */
-  @Excel(name = "主键", orderNum = "1")
+  @Excel(name = "id", orderNum = "1")
   private String id;
-
+    /**
+     * 标准名称
+     */
+    @Excel(name = "设备编号", orderNum = "2")
+    private String sbNo;
+    /**
+     * 标准名称
+     */
+    @Excel(name = "设备名称", orderNum = "3")
+    private String sbName;
     /**
    * 标准名称
    */
-  @Excel(name = "标准名称", orderNum = "2")
-  private LocalDate checkDate;//检定日期(新增字段)
+  @Excel(name = "标准名称", orderNum = "4")
+  private String name;
     /**
    * 编码
    */
-  @Excel(name = "编码", orderNum = "3")
+  @Excel(name = "编码", orderNum = "5")
   private String no;
 
-    /**
-   * 检查类型: 1-点检 2-巡检
-   */
-  @Excel(name = "检查类型: 1-点检 2-巡检", orderNum = "4")
-  private Integer type;
-
-    /**
-   * 是否启用: 0-否 1-是
-   */
-  @Excel(name = "是否启用: 0-否 1-是", orderNum = "5")
-  private Integer enable;
-
     /**
    * 要求
    */
@@ -57,42 +54,30 @@ public class ExportCheckStandardVO implements Serializable {
    */
   @Excel(name = "备注", orderNum = "7")
   private String remark;
-
     /**
-   * 创建人
-   */
-  @Excel(name = "创建人", orderNum = "8")
-  private String createdUserId;
-
+     * 计划周期
+     */
+    @Excel(name = "计划周期", orderNum = "8")
+    private Integer period;
     /**
-   * 更新人
-   */
-  @Excel(name = "更新人", orderNum = "9")
-  private String updateUserId;
-
+     * 周期类型
+     */
+    @Excel(name = "周期类型", orderNum = "9", dicCode="CHECK_PLAN_PERIOD_TYPE")
+    private Integer periodType;
     /**
-   * 创建人名称
-   */
-  @Excel(name = "创建人名称", orderNum = "10")
-  private String createdUserName;
-
+     * 上次实际执行日期
+     */
+    @Excel(name = "上次实际执行日期", orderNum = "10")
+    private LocalDate lastDate;
     /**
-   * 更新人名称
-   */
-  @Excel(name = "更新人名称", orderNum = "11")
-  private String updateUserName;
-
+     * 下次预计执行日期
+     */
+    @Excel(name = "下次预计执行日期", orderNum = "11")
+    private LocalDate nextDate;
     /**
-   * 创建时间
-   */
-  @Excel(name = "创建时间", orderNum = "12")
-  private LocalDateTime createdTime;
-
-    /**
-   * 更新时间
-   */
-  @Excel(name = "更新时间", orderNum = "13")
-  private LocalDateTime updateTime;
-
+     * 执行人方式(1使用人、2维修人、3指定人)
+     */
+    @Excel(name = "执行人方式", orderNum = "12")
+    private Integer checkUserType;
 
 }

+ 37 - 1
platform-dao/src/main/resources/mapper/check/CheckStandardMapper.xml

@@ -23,6 +23,8 @@ checkstandard.sort,
                                      checkstandard.update_user_id,
                                      checkstandard.created_user_name,
                                      checkstandard.update_user_name,
+checkstandard.last_date,
+                                     checkstandard.next_date,
                                      checkstandard.created_time,
                                      checkstandard.update_time
                         </sql>
@@ -34,6 +36,8 @@ checkstandard.sort,
                                      checkstandard.name,
 checkstandard.sort,
                                      checkstandard.no,
+checkstandard.last_date,
+                                     checkstandard.next_date,
                                      checkstandard.type,
                                      checkstandard.period,
                                      checkstandard.part,
@@ -66,6 +70,12 @@ checkstandard.sort,
         <if test="type != null">
             and checkstandard.type = #{type}
         </if>
+        <if test="lastDate != null">
+            and checkstandard.last_date = #{lastDate}
+        </if>
+        <if test="nextDate != null">
+            and checkstandard.next_date = #{nextDate}
+        </if>
         <if test="period != null">
             and checkstandard.period = #{period}
         </if>
@@ -149,7 +159,33 @@ checkstandard.sort,
         <foreach collection="list" item="item" index="index" open="" close="" separator=";">
             update t_check_standard
             <set>
-                check_user_type=#{item.checkUserType}
+                <if test="item.requirement != null and item.requirement != ''">
+                    requirement = #{item.requirement},
+                </if>
+                <if test="item.remark != null and item.remark != ''">
+                     remark = #{item.remark},
+                </if>
+                <if test="item.no != null and item.no != ''">
+                    remark = #{item.no},
+                </if>
+                <if test="item.name != null and item.name != ''">
+                    remark = #{item.name},
+                </if>
+                <if test="item.period != null">
+                     period = #{item.period},
+                </if>
+                <if test="item.periodType != null">
+                     period_type = #{item.periodType},
+                </if>
+                <if test="item.checkUserType != null">
+                     check_user_type = #{item.checkUserType},
+                </if>
+                <if test="item.lastDate != null">
+                     last_date = #{item.lastDate},
+                </if>
+                <if test="item.nextDate != null">
+                     next_date = #{item.nextDate}
+                </if>
             </set>
             where id = #{item.id}
         </foreach>

+ 34 - 17
platform-rest/src/main/java/com/platform/rest/controller/check/CheckStandardController.java

@@ -5,6 +5,7 @@ import com.platform.common.util.R;
 import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.check.CheckStandardDTO;
 import com.platform.dao.entity.check.CheckStandard;
+import com.platform.dao.vo.query.check.CheckStandardVO;
 import com.platform.service.check.CheckStandardService;
 import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.vo.export.check.ExportCheckStandardVO;
@@ -26,7 +27,7 @@ import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
 /**
- * @Description 点检标准 控制器
+ * @Description 保养标准 控制器
  * @Author liuyu
  * @Date 2020-05-28 17:23:30
  * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
@@ -63,10 +64,10 @@ public class CheckStandardController {
   /**
    * 新增记录
    *
-   * @param checkStandardDTO 点检标准DTO
+   * @param checkStandardDTO 保养标准DTO
    * @return R
    */
-  @SysLog("新增点检标准")
+  @SysLog("新增保养标准")
   @PostMapping
   @PreAuthorize("@pms.hasPermission('check-spot-standards-add') or @pms.hasPermission('check-spot-standards-add')")
   public R save(@Validated({AddGroup.class}) @RequestBody CheckStandardDTO checkStandardDTO) {
@@ -76,10 +77,10 @@ public class CheckStandardController {
   /**
    * 修改记录
    *
-   * @param checkStandardDTO 点检标准DTO
+   * @param checkStandardDTO 保养标准DTO
    * @return R
    */
-  @SysLog("修改点检标准")
+  @SysLog("修改保养标准")
   @PutMapping("/{id}")
   @PreAuthorize("@pms.hasPermission('check-spot-standards-edit')")
   public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody CheckStandardDTO checkStandardDTO) {
@@ -102,7 +103,7 @@ public class CheckStandardController {
     /**
      * 通过标准直接生成任务
      *
-     * @param checkJobDTO 点检标准DTO
+     * @param checkJobDTO 保养标准DTO
      * @return R
      */
     @SysLog("插入check任务")
@@ -115,7 +116,7 @@ public class CheckStandardController {
     /**
      * 任务数量
      *
-     * @param checkStandardDTO 点检任务DTO
+     * @param checkStandardDTO 保养任务DTO
      * @return R
      */
     @GetMapping("/num")
@@ -129,7 +130,7 @@ public class CheckStandardController {
    * @param id 主键
    * @return R
    */
-  @SysLog("删除点检标准")
+  @SysLog("删除保养标准")
   @DeleteMapping("/{id}")
   @PreAuthorize("@pms.hasPermission('check-spot-standards-del') or @pms.hasPermission('check-spot-standards-del')")
   public R removeById(@PathVariable String id){
@@ -143,7 +144,7 @@ public class CheckStandardController {
      * @param ids 主键
      * @return R
      */
-    @SysLog("批量删除点检标准")
+    @SysLog("批量删除保养标准")
     @DeleteMapping("")
     @PreAuthorize("@pms.hasPermission('check-spot-standards-del')")
     public R removeIds(@RequestBody List<String> ids){
@@ -156,7 +157,7 @@ public class CheckStandardController {
    *
    * @param pageNum 当前页码
    * @param pageSize 每页条数
-   * @param checkStandardDTO 点检标准DTO
+   * @param checkStandardDTO 保养标准DTO
    * @return R
    */
   @GetMapping("/page")
@@ -167,7 +168,7 @@ public class CheckStandardController {
   /**
    * 获取列表
    *
-   * @param checkStandardDTO 点检标准DTO
+   * @param checkStandardDTO 保养标准DTO
    * @return R
    */
   @GetMapping("")
@@ -176,17 +177,16 @@ public class CheckStandardController {
   }
 
   /**
-     * 点检标准导出
+     * 保养标准导出
      *
-     * @param checkStandardDTO 点检标准DTO
+     * @param checkStandardDTO 保养标准DTO
      * @return R
      */
   @GetMapping("/export")
-  @SysLog("点检标准导出")
-  @PreAuthorize("@pms.hasPermission('check-spot-standards-export') or @pms.hasPermission('check-spot-standards-export')")
+  @SysLog("保养标准导出")
   public void export(HttpServletResponse response, CheckStandardDTO checkStandardDTO) {
-    List<CheckStandard> list = checkStandardService.getModelListByDTO(checkStandardDTO);
-    ExcelUtil.exportResponseDict(response, ExportCheckStandardVO.class, BeanConverterUtil.copyListProperties(list, ExportCheckStandardVO.class), "点检标准");
+    List<CheckStandardVO> list = checkStandardService.selectList(checkStandardDTO);
+    ExcelUtil.exportResponseDict(response, ExportCheckStandardVO.class, BeanConverterUtil.copyListProperties(list, ExportCheckStandardVO.class), "保养标准");
   }
 
     /**
@@ -222,4 +222,21 @@ public class CheckStandardController {
         }
         return new R<>(result);
     }
+
+    /**
+     * 导入保养标准
+     *
+     * @param files bom excel文件
+     *
+     * @return R
+     */
+    @SysLog("修改导入设备的保养标准执行时间")
+    @PostMapping(value="/import/update",headers = "content-type=multipart/form-data")
+    public R importListByUpdate( @RequestParam("files") MultipartFile[] files) throws Exception {
+        String result ="";
+        for(MultipartFile file: files){
+            result = result + checkStandardService.importListByUpdate(file);
+        }
+        return new R<>(result);
+    }
 }

+ 2 - 0
platform-service/src/main/java/com/platform/service/check/CheckStandardService.java

@@ -55,6 +55,8 @@ public interface CheckStandardService extends IBaseService<CheckStandard, CheckS
 
     String importListByAdd(MultipartFile file);
 
+    String importListByUpdate(MultipartFile file);
+
     String importListByAddOldVersion(MultipartFile file);
 
     void genSpareWarnTask(int month, int type);

+ 2 - 2
platform-service/src/main/java/com/platform/service/check/impl/CheckJobServiceImpl.java

@@ -395,7 +395,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         }
 
         if (!CollectionUtils.isEmpty(updateStandardList)) {
-            standardMapper.updataBatch(updateStandardList);
+            standardMapper.updateBatch(updateStandardList);
         }
     }
 
@@ -693,7 +693,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
             mapper.insert(nextCheckJob);
         }
 
-        // 更新标准的上次执行时间和下次执行时间
+        // 更新标准的上次执行时间和下次预计执行时间
         checkStandard.setLastDate(now.toLocalDate());
         checkStandard.setNextDate(nextCheckJob.getStartTime());
         standardMapper.updateByPrimaryKey(checkStandard);

+ 20 - 0
platform-service/src/main/java/com/platform/service/check/impl/CheckStandardServiceImpl.java

@@ -463,6 +463,26 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
         }
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public String importListByUpdate(MultipartFile file) {
+        int addNum = 0;
+        List<String> modelError = new ArrayList<String>();
+        try {
+            List<CheckStandard> items = CustomExcelImportUtil.importCheckStandardListByUpdate(file.getInputStream());
+            if (!CollectionUtils.isEmpty(items)) {
+                if(!CollectionUtils.isEmpty(items)){
+                    mapper.updateBatch(items);
+                }
+            }
+            return "成功: "  +  file.getOriginalFilename()+ ";";
+        } catch (Exception e) {
+            System.out.println("file.getOriginalFilename():" + file.getOriginalFilename() );
+            return ("失败:" +  file.getOriginalFilename() + ":"+ e.getMessage()+ ";");
+
+        }
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String importListByAddOldVersion(MultipartFile file) {