소스 검색

feat(repairs): 新增维修单转派审批功能并优化代码格式

- 添加转派审批通过和驳回接口,支持权限控制
- 新增transferApprove和transferReject服务方法
- 重构RepairApplicationFormServiceImpl类结构和代码格式
- 优化ExcelUtil工具类方法参数换行格式
- 更新备件信息导出VO字段命名和注释清理
- 完善维修单转派业务逻辑和状态管理
- 优化多处代码换行和空格格式问题
dazhaxie 2 주 전
부모
커밋
b4af30575d

+ 5 - 1
platform-dao/src/main/java/com/platform/dao/enums/RepairApplicationFormStatusEnum.java

@@ -36,6 +36,10 @@ public enum RepairApplicationFormStatusEnum {
      * 	已完成
      */
     FINISHED(6),
-    REFUSED(7);
+    REFUSED(7),
+    /**
+     * 转派审批中
+     */
+    TRANSFER_APPROVAL(8);
     private final Integer value;
 }

+ 12 - 7
platform-dao/src/main/java/com/platform/dao/util/ExcelUtil.java

@@ -28,7 +28,8 @@ public class ExcelUtil {
      * @param dataSet   :
      * @param <T>       :
      */
-    public static <T> void exportResponseDict(HttpServletResponse response, Class<T> pojoClass, Collection<?> dataSet, String name) {
+    public static <T> void exportResponseDict(HttpServletResponse response, Class<T> pojoClass, Collection<?> dataSet,
+            String name) {
         PoiExcelUtil.exportResponse(response, new MyDictHandle(), pojoClass, dataSet, name);
     }
 
@@ -41,12 +42,11 @@ public class ExcelUtil {
      */
     public static <T> List<T> importExcel(InputStream inputStream, Class<? extends T> pojoClass, int titleRows) {
         ImportParams params = new ImportParams();
-        //标题行数
+        // 标题行数
         params.setTitleRows(titleRows);
         return ExcelImportUtil.importExcel(new MyDictHandle(), inputStream, pojoClass, params);
     }
 
-
     /**
      * 导出包含数据词典
      *
@@ -55,7 +55,8 @@ public class ExcelUtil {
      * @param dataSet    :
      * @param <T>        :
      */
-    public static <T> void exportResponseDict(HttpServletResponse response, List<ExcelExportEntity> entityList, Collection<? extends ExcelData> dataSet, String name) {
+    public static <T> void exportResponseDict(HttpServletResponse response, List<ExcelExportEntity> entityList,
+            Collection<? extends ExcelData> dataSet, String name) {
         PoiExcelUtil.exportResponse(response, new MyDictHandle(), entityList, dataSet, name);
     }
 
@@ -68,7 +69,8 @@ public class ExcelUtil {
      * @param dataSet   :
      * @param <T>       :
      */
-    public static <T> void exportCustomTitleResponseDict(HttpServletResponse response, List<ExcelData> customTitleList, Class<? extends T> pojoClass, Collection<? extends ExcelData> dataSet, String name) {
+    public static <T> void exportCustomTitleResponseDict(HttpServletResponse response, List<ExcelData> customTitleList,
+            Class<? extends T> pojoClass, Collection<? extends ExcelData> dataSet, String name) {
         PoiExcelUtil.exportCustomTitleResponse(response, new MyDictHandle(), customTitleList, pojoClass, dataSet, name);
     }
 
@@ -81,8 +83,11 @@ public class ExcelUtil {
      * @param dataSet   :
      * @param <T>       :
      */
-    public static <T> void exportCustomTitleMergeRowResponseDict(HttpServletResponse response, List<ExcelData> customTitleList, Class<? extends T> pojoClass, Collection<? extends ExcelData> dataSet, String name) {
-        PoiExcelUtil.exportCustomTitleMergeRowResponse(response, new MyDictHandle(), customTitleList, pojoClass, dataSet, name);
+    public static <T> void exportCustomTitleMergeRowResponseDict(HttpServletResponse response,
+            List<ExcelData> customTitleList, Class<? extends T> pojoClass, Collection<? extends ExcelData> dataSet,
+            String name) {
+        PoiExcelUtil.exportCustomTitleMergeRowResponse(response, new MyDictHandle(), customTitleList, pojoClass,
+                dataSet, name);
     }
 
 }

+ 22 - 34
platform-dao/src/main/java/com/platform/dao/vo/export/sqarepartmanage/ExportSparePartInfoVO.java

@@ -47,8 +47,6 @@ public class ExportSparePartInfoVO implements Serializable {
     @Excel(name = "规格型号", orderNum = "5")
     private String ggxh;
 
-
-
     /**
      * 计量单位: 1-件;2-台;3-条; 4-个
      */
@@ -88,57 +86,47 @@ public class ExportSparePartInfoVO implements Serializable {
     @Excel(name = "备件价值", orderNum = "12")
     private Double initialValue;
 
-
     /**
-     * 大类编码名称
+     * 大类编码
      */
-    @Excel(name = "备件类别", orderNum = "13")
+    @Excel(name = "备件类别编码", orderNum = "13")
     private String typeName;
 
-
-
-
-
-
-
-
-
-//    /**
-//     * 寿命周期:月
-//     */
-//    @Excel(name = "寿命周期(月)", orderNum = "11")
-//    private BigDecimal agePeriod;
-
+    // /**
+    // * 寿命周期:月
+    // */
+    // @Excel(name = "寿命周期(月)", orderNum = "11")
+    // private BigDecimal agePeriod;
 
     /**
      * 使用周期:月
      */
-//    @Excel(name = "使用周期(月)", orderNum = "10")
-//    private BigDecimal usePeriod;
-
-//    /**
-//     * 采购到货周期:天
-//     */
-//    @Excel(name = "采购到货周期(天)", orderNum = "12")
-//    private BigDecimal purchasePeriod;
+    // @Excel(name = "使用周期(月)", orderNum = "10")
+    // private BigDecimal usePeriod;
+
+    // /**
+    // * 采购到货周期:天
+    // */
+    // @Excel(name = "采购到货周期(天)", orderNum = "12")
+    // private BigDecimal purchasePeriod;
     /**
      * 生产商
      */
     @Excel(name = "生产商", orderNum = "14")
     private String producerName;
 
-    @Excel(name = "用途", orderNum = "15",dicCode = "SPARE_USE_TYPE")
+    @Excel(name = "用途", orderNum = "15", dicCode = "SPARE_USE_TYPE")
     private Integer yt;
 
-/*    @Excel(name = "关联设备号", orderNum = "16")
-    private String sbNo;*/
+    /*
+     * @Excel(name = "关联设备号", orderNum = "16")
+     * private String sbNo;
+     */
 
     @Excel(name = "备注", orderNum = "16")
     private String remark;
 
-//    @Excel(name = "创建时间", orderNum = "16")
-//    private LocalDateTime createdTime;
-
-
+    // @Excel(name = "创建时间", orderNum = "16")
+    // private LocalDateTime createdTime;
 
 }

+ 2 - 3
platform-rest/src/main/java/com/platform/rest/RestApplication.java

@@ -6,7 +6,6 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.scheduling.annotation.EnableAsync;
-
 import java.util.TimeZone;
 
 /**
@@ -15,8 +14,8 @@ import java.util.TimeZone;
  * @Date 2019/7/22
  * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
  */
-@SpringBootApplication(scanBasePackages = {"com.platform", "org.activiti"}, exclude = {
-        DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class})
+@SpringBootApplication(scanBasePackages = { "com.platform", "org.activiti" }, exclude = {
+        DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class })
 @QmEnableResourceServer
 @EnableAsync
 public class RestApplication {

+ 29 - 0
platform-rest/src/main/java/com/platform/rest/controller/repair/RepairApplicationFormController.java

@@ -386,9 +386,38 @@ public class RepairApplicationFormController {
      */
     @SysLog("转派")
     @PutMapping("/transfer/{id}")
+    @PreAuthorize("@pms.hasPermission('repair-application-forms-transfer')")
     public R transfer(@PathVariable("id") String id, @RequestBody RepairApplicationFormDTO record) {
         record.setId(id);
         repairApplicationFormService.transfer(record);
         return new R<>();
     }
+
+    /**
+     * 转派审批通过
+     * @param record 保修单DTO
+     * @return R
+     */
+    @SysLog("转派审批通过")
+    @PutMapping("/transfer-approve/{id}")
+    @PreAuthorize("@pms.hasPermission('repair-application-forms-transfer-approve')")
+    public R transferApprove(@PathVariable("id") String id, @RequestBody RepairApplicationFormDTO record) {
+        record.setId(id);
+        repairApplicationFormService.transferApprove(record);
+        return new R<>();
+    }
+
+    /**
+     * 转派审批驳回
+     * @param record 保修单DTO
+     * @return R
+     */
+    @SysLog("转派审批驳回")
+    @PutMapping("/transfer-reject/{id}")
+    @PreAuthorize("@pms.hasPermission('repair-application-forms-transfer-approve')")
+    public R transferReject(@PathVariable("id") String id, @RequestBody RepairApplicationFormDTO record) {
+        record.setId(id);
+        repairApplicationFormService.transferReject(record);
+        return new R<>();
+    }
 }

+ 20 - 15
platform-service/src/main/java/com/platform/service/bean/ScheduleUtils.java

@@ -4,6 +4,7 @@ import com.platform.common.enums.ScheduleStatus;
 import com.platform.common.exception.BusinessException;
 import com.platform.dao.entity.upms.ScheduleJob;
 import com.google.gson.Gson;
+import lombok.extern.slf4j.Slf4j;
 import org.quartz.*;
 
 /**
@@ -13,6 +14,7 @@ import org.quartz.*;
  * @Date 2019/8/13
  * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
  */
+@Slf4j
 public class ScheduleUtils {
     private final static String JOB_NAME = "TASK_";
 
@@ -47,29 +49,32 @@ public class ScheduleUtils {
     public static void createScheduleJob(Scheduler scheduler, ScheduleJob scheduleJob) {
 
         try {
-            //构建job信息
-            JobDetail jobDetail = JobBuilder.newJob(ScheduleJobBean.class).withIdentity(getJobKey(scheduleJob.getJobId())).build();
+            // 构建job信息
+            JobDetail jobDetail = JobBuilder.newJob(ScheduleJobBean.class)
+                    .withIdentity(getJobKey(scheduleJob.getJobId())).build();
 
-            //表达式调度构建器
+            // 表达式调度构建器
             CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
                     .withMisfireHandlingInstructionDoNothing();
 
-            //按新的cronExpression表达式构建一个新的trigger
-            CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getJobId())).withSchedule(scheduleBuilder).build();
+            // 按新的cronExpression表达式构建一个新的trigger
+            CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getJobId()))
+                    .withSchedule(scheduleBuilder).build();
 
-            //放入参数,运行时的方法可以获取
+            // 放入参数,运行时的方法可以获取
             jobDetail.getJobDataMap().put(ScheduleJob.JOB_PARAM_KEY, new Gson().toJson(scheduleJob));
 
             scheduler.scheduleJob(jobDetail, trigger);
 
-            //暂停任务
+            // 暂停任务
             if (scheduleJob.getStatus() == ScheduleStatus.PAUSE.getValue()) {
                 pauseJob(scheduler, scheduleJob.getJobId());
             }
         } catch (SchedulerException e) {
-            e.printStackTrace();
-            System.err.println("=============" + scheduleJob.getJobId());
-            throw new BusinessException("创建定时任务失败");
+            log.error("创建定时任务失败, jobId={}, cronExpression={}, 原因: {}", scheduleJob.getJobId(),
+                    scheduleJob.getCronExpression(), e.getMessage(), e);
+            throw new BusinessException("创建定时任务失败, jobId=" + scheduleJob.getJobId() + ", cronExpression="
+                    + scheduleJob.getCronExpression() + ", 原因: " + e.getMessage());
         }
     }
 
@@ -80,21 +85,21 @@ public class ScheduleUtils {
         try {
             TriggerKey triggerKey = getTriggerKey(scheduleJob.getJobId());
 
-            //表达式调度构建器
+            // 表达式调度构建器
             CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
                     .withMisfireHandlingInstructionDoNothing();
 
             CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getJobId());
 
-            //按新的cronExpression表达式重新构建trigger
+            // 按新的cronExpression表达式重新构建trigger
             trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
 
-            //参数
+            // 参数
             trigger.getJobDataMap().put(ScheduleJob.JOB_PARAM_KEY, new Gson().toJson(scheduleJob));
 
             scheduler.rescheduleJob(triggerKey, trigger);
 
-            //暂停任务
+            // 暂停任务
             if (scheduleJob.getStatus() == ScheduleStatus.PAUSE.getValue()) {
                 pauseJob(scheduler, scheduleJob.getJobId());
             }
@@ -109,7 +114,7 @@ public class ScheduleUtils {
      */
     public static void run(Scheduler scheduler, ScheduleJob scheduleJob) {
         try {
-            //参数
+            // 参数
             JobDataMap dataMap = new JobDataMap();
             dataMap.put(ScheduleJob.JOB_PARAM_KEY, new Gson().toJson(scheduleJob));
 

+ 12 - 0
platform-service/src/main/java/com/platform/service/repair/RepairApplicationFormService.java

@@ -125,4 +125,16 @@ public interface RepairApplicationFormService extends IBaseService<RepairApplica
      * @param record
      */
     void transfer(RepairApplicationFormDTO record);
+
+    /**
+     * 转派审批通过
+     * @param record
+     */
+    void transferApprove(RepairApplicationFormDTO record);
+
+    /**
+     * 转派审批驳回
+     * @param record
+     */
+    void transferReject(RepairApplicationFormDTO record);
 }

+ 368 - 125
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -73,7 +73,9 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 @Service("repairApplicationFormService")
 @Slf4j
-public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairApplicationFormMapper, RepairApplicationForm, RepairApplicationFormDTO> implements RepairApplicationFormService {
+public class RepairApplicationFormServiceImpl
+        extends BaseServiceImpl<RepairApplicationFormMapper, RepairApplicationForm, RepairApplicationFormDTO>
+        implements RepairApplicationFormService {
 
     private RepairReasonMapper repairReasonMapper;
     private final SysUserService sysUserService;
@@ -86,7 +88,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     public void refuseOrder(RepairApplicationFormDTO repairApplicationFormDTO) {
         repairApplicationFormDTO.setStatus(RepairApplicationFormStatusEnum.REFUSED.getValue());
-        mapper.updateByPrimaryKeySelective(BeanConverterUtil.copyObjectProperties(repairApplicationFormDTO, RepairApplicationForm.class));
+        mapper.updateByPrimaryKeySelective(
+                BeanConverterUtil.copyObjectProperties(repairApplicationFormDTO, RepairApplicationForm.class));
 
         // 通知机台
         List<String> openIds = new ArrayList<>();
@@ -116,7 +119,6 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             }
         }
 
-
         String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
         if (StringUtils.isBlank(domain)) {
             throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
@@ -127,7 +129,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         String repairUrl = domain + "repair/form?no=" + repairApplicationFormDTO.getNo();
 
         // 发送邮件给机台人员
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
                 repairApplicationFormDTO.getId(),
                 MessageTemplateUtil.getFreemarkerHtmlContentRefuse(repairUrl, repairApplicationFormDTO, sbInfo),
                 repairApplicationFormDTO.getId(), userIds, mails));
@@ -141,7 +144,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             if (!mobileDomain.endsWith("/")) {
                 mobileDomain = mobileDomain + "/";
             }
-            String mobileRepairUrl = mobileDomain + "pages/repair-detail/repair-detail?detailId=" + repairApplicationFormDTO.getId();
+            String mobileRepairUrl = mobileDomain + "pages/repair-detail/repair-detail?detailId="
+                    + repairApplicationFormDTO.getId();
             for (String openId : openIds) {
                 WeChatMessageUtil.repairRefuseMessage(openId, mobileRepairUrl, repairApplicationFormDTO, sbInfo);
             }
@@ -152,7 +156,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     public void sendMessage() {
         Weekend<RepairApplicationForm> weekend = new Weekend(RepairApplicationForm.class);
-        weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
+        weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getStatus,
+                RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
         LocalDateTime time = LocalDateTime.now().minusHours(1);
         weekend.weekendCriteria().andLessThan(RepairApplicationForm::getCreatedTime, time);
         List<RepairApplicationForm> list = mapper.selectAll();
@@ -210,14 +215,20 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     public int batchDelete(List<String> ids) {
         // 判断是否允许删除
-  /*      Weekend<RepairApplicationForm> weekendSelect = new Weekend<>(RepairApplicationForm.class);
-        WeekendCriteria<RepairApplicationForm, Object> weekendCriteriaSelect = weekendSelect.weekendCriteria();
-        weekendCriteriaSelect.andIn(RepairApplicationForm::getId, ids);
-        weekendCriteriaSelect.andNotEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED);
-        List<RepairApplicationForm> repairApplicationForms = mapper.selectByExample(weekendSelect);
-        if (CollectionUtil.isNotEmpty(repairApplicationForms)) {
-            throw new BusinessException("部分状态不允许删除");
-        }*/
+        /*
+         * Weekend<RepairApplicationForm> weekendSelect = new
+         * Weekend<>(RepairApplicationForm.class);
+         * WeekendCriteria<RepairApplicationForm, Object> weekendCriteriaSelect =
+         * weekendSelect.weekendCriteria();
+         * weekendCriteriaSelect.andIn(RepairApplicationForm::getId, ids);
+         * weekendCriteriaSelect.andNotEqualTo(RepairApplicationForm::getStatus,
+         * RepairApplicationFormStatusEnum.NOT_ALLOCATED);
+         * List<RepairApplicationForm> repairApplicationForms =
+         * mapper.selectByExample(weekendSelect);
+         * if (CollectionUtil.isNotEmpty(repairApplicationForms)) {
+         * throw new BusinessException("部分状态不允许删除");
+         * }
+         */
         Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
         WeekendCriteria<RepairApplicationForm, Object> weekendCriteria = weekend.weekendCriteria();
         weekendCriteria.andIn(RepairApplicationForm::getId, ids);
@@ -234,7 +245,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
      * @return
      */
     @Override
-    public MyVOPage<RepairApplicationFormVO> selectPageInfoVO(RepairApplicationFormDTO record, int pageNum, int pageSize) {
+    public MyVOPage<RepairApplicationFormVO> selectPageInfoVO(RepairApplicationFormDTO record, int pageNum,
+            int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
 
         if (record.getSearchType() != null) {
@@ -256,9 +268,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             if (record.getSearchType() == 3) {
                 if (record.getFilter() != null && DataFilterTypeEnum.SELF.getValue() == record.getFilter().intValue()) {
                     record.setStatus(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
-                    String verifyUser = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.VERIFY_REPAIR_USER_LIST.name());
+                    String verifyUser = ConfigCache
+                            .getLabelByValueAllowNull(SysConfigEnum.VERIFY_REPAIR_USER_LIST.name());
                     UserInfo userInfo = SecurityUtils.getUserInfo();
-                    if(StringUtils.isNotBlank(verifyUser) && !verifyUser.contains(userInfo.getUsername())){
+                    if (StringUtils.isNotBlank(verifyUser) && !verifyUser.contains(userInfo.getUsername())) {
                         record.setCheckUserId(userInfo.getUserId());
                     }
                 }
@@ -304,9 +317,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     @Transactional(rollbackFor = Exception.class)
     public RepairApplicationForm saveModelByDTO(RepairApplicationFormDTO model) {
-/*        if (model.getCategory() == null) {
-            throw new BusinessException("未获取到工单类别!");
-        }*/
+        /*
+         * if (model.getCategory() == null) {
+         * throw new BusinessException("未获取到工单类别!");
+         * }
+         */
         if (StringUtils.isBlank(model.getSbId())) {
             throw new BusinessException("请填写报修设备");
         }
@@ -316,7 +331,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             model.setType(type);
         }
         Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
-        weekend.weekendCriteria().andIsNotNull(RepairApplicationForm::getId).andEqualTo(RepairApplicationForm::getType, model.getType());
+        weekend.weekendCriteria().andIsNotNull(RepairApplicationForm::getId).andEqualTo(RepairApplicationForm::getType,
+                model.getType());
         int count = mapper.selectCountByExample(weekend);
         // 查询对应的维修人,保存维修单
         String sbId = model.getSbId();
@@ -366,7 +382,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             updateSb = true;
         }
         // 如果选择了设备停机,则要修改设备状态,记录设备状态变更变
-        if (model.getNeedStop() != null && model.getNeedStop().intValue() == RepairApplicationFormStopEnum.STOP.getValue()) {
+        if (model.getNeedStop() != null
+                && model.getNeedStop().intValue() == RepairApplicationFormStopEnum.STOP.getValue()) {
             info.setStatus(SbInfoStatusEnum.IN_STOP.getValue());
             updateSb = true;
         }
@@ -450,7 +467,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         String repairUrl = domain + "repair/form?no=" + model.getNo();
 
         // 通过给当天值班维修人员
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
                 model.getId(),
                 MessageTemplateUtil.getFreemarkerHtmlContent(repairUrl, model, sb),
                 model.getId(), userIds, mails));
@@ -494,12 +512,13 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                         RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, "1", 24, TimeUnit.HOURS);
                     } else if (Integer.valueOf(numStr) < 5) {
                         isSend = true;
-                        RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
+                        RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver,
+                                String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
                     }
                     if (isSend) {
                         System.out.println("templateParas_repair: " + templateParas_repair);
                         String template = "[\"369751\"]";
-                        //SendSms.sendCodeSms(receiver, template);
+                        // SendSms.sendCodeSms(receiver, template);
                         SendSms.sendRepairSms(receiver, templateParas_repair);
                     }
                 } catch (Exception e) {
@@ -514,9 +533,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         if (StringUtils.isNotBlank(minuteStr)) {
             minute = Integer.valueOf(minuteStr);
         }
-        RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_STEP_FIRST + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), minute, TimeUnit.MINUTES);
+        RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_STEP_FIRST
+                + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), minute, TimeUnit.MINUTES);
 
-        // 启动维修超时监控,维修时间升级流程:超过3个小时没修好,升级给牛工,超过8个小时没修好,升级给相工,超过24 没修好,升级给田总,现在把三阶段的人员位置留好,可以先暂时升级给我,后期再改为具体的人。
+        // 启动维修超时监控,维修时间升级流程:超过3个小时没修好,升级给牛工,超过8个小时没修好,升级给相工,超过24
+        // 没修好,升级给田总,现在把三阶段的人员位置留好,可以先暂时升级给我,后期再改为具体的人。
         String hourFirstStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_OVERTIME_MINUTE_FIRST.name());
         int hourFirst = 3;// 默认3小时
         if (StringUtils.isNotBlank(hourFirstStr)) {
@@ -532,9 +553,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         if (StringUtils.isNotBlank(hourThirdStr)) {
             hourThird = Integer.valueOf(hourThirdStr);
         }
-        RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_FIRST + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourFirst, TimeUnit.HOURS);
-        RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_SECOND + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourSecond, TimeUnit.HOURS);
-        RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_THIRD + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourThird, TimeUnit.HOURS);
+        RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_FIRST
+                + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourFirst, TimeUnit.HOURS);
+        RedisUtils.setString(
+                RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_SECOND
+                        + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(),
+                model.getId(), hourSecond, TimeUnit.HOURS);
+        RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_THIRD
+                + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourThird, TimeUnit.HOURS);
 
         return form;
     }
@@ -579,9 +605,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     private void saveFile(RepairApplicationFormDTO model) {
         if (CollectionUtil.isNotEmpty(model.getApplicationFileList())) {
             Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
-            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
+            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue())
+                    .andEqualTo(SysFile::getTargetId, model.getId());
             sysFileMapper.deleteByExample(weekend);
-            List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(), SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue());
+            List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(),
+                    SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue());
             if (CollectionUtil.isNotEmpty(list)) {
                 sysFileMapper.insertListforComplex(list);
             }
@@ -596,9 +624,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     private void saveRepairFile(RepairApplicationFormDTO model) {
         if (CollectionUtil.isNotEmpty(model.getRepairFileList())) {
             Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
-            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
+            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue())
+                    .andEqualTo(SysFile::getTargetId, model.getId());
             sysFileMapper.deleteByExample(weekend);
-            List<SysFile> list = SysFileUtils.changeFileList(model.getRepairFileList(), model.getId(), SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue());
+            List<SysFile> list = SysFileUtils.changeFileList(model.getRepairFileList(), model.getId(),
+                    SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue());
             if (CollectionUtil.isNotEmpty(list)) {
                 sysFileMapper.insertListforComplex(list);
             }
@@ -613,9 +643,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     private void saveCheckFile(RepairApplicationFormDTO model) {
         if (CollectionUtil.isNotEmpty(model.getCheckFileList())) {
             Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
-            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
+            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue())
+                    .andEqualTo(SysFile::getTargetId, model.getId());
             sysFileMapper.deleteByExample(weekend);
-            List<SysFile> list = SysFileUtils.changeFileList(model.getCheckFileList(), model.getId(), SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue());
+            List<SysFile> list = SysFileUtils.changeFileList(model.getCheckFileList(), model.getId(),
+                    SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue());
             if (CollectionUtil.isNotEmpty(list)) {
                 sysFileMapper.insertListforComplex(list);
             }
@@ -630,7 +662,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     public void receive(String id) {
         RepairApplicationForm applicationForm = mapper.selectById(id);
-        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
+        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus())
+                && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
             throw new BusinessException("该状态不允许接收任务");
         }
         UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
@@ -644,19 +677,24 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         if (sbInfo.getRepairUserSecond() == null) {
             throw new BusinessException("设备的第二维修人未设置,无法接受任务");
         }
-        if (!SecurityUtils.isRole(SysRoleCodeEnum.MM.name()) && !SecurityUtils.isRole(SysRoleCodeEnum.Maintenance.name())) {
+        if (!SecurityUtils.isRole(SysRoleCodeEnum.MM.name())
+                && !SecurityUtils.isRole(SysRoleCodeEnum.Maintenance.name())) {
             throw new BusinessException("您不是维修人或维修主管,无法接受任务");
         }
 
-       /* if (!sbInfo.getRepairUser().equals(userInfo.getUserId()) && !sbInfo.getRepairUserSecond().equals(userInfo.getUserId())) {
-            throw new BusinessException("您不是该设备的第一维修人或第二维修人,无法接受任务");
-        }*/
+        /*
+         * if (!sbInfo.getRepairUser().equals(userInfo.getUserId()) &&
+         * !sbInfo.getRepairUserSecond().equals(userInfo.getUserId())) {
+         * throw new BusinessException("您不是该设备的第一维修人或第二维修人,无法接受任务");
+         * }
+         */
         applicationForm.setRepairUserId(userInfo.getUserId());
         applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
         if (applicationForm.getRepairStartTime() == null) {
             applicationForm.setRepairStartTime(LocalDateTime.now());
         }
-        applicationForm.setReceiveMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairStartTime()));
+        applicationForm.setReceiveMinutes(
+                DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairStartTime()));
 
         // 根据配置判断维修是否超时
         String minuteStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_WARN_MINUTE.name());
@@ -670,7 +708,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         applicationForm.setUpdateTime(LocalDateTime.now());
         super.modModelByPrimaryKey(applicationForm);
 
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.RECEIVE.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_RECEIVE.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.RECEIVE.getValue(),
+                WorkplaceBacklogDetailTypeEnum.REPAIR_RECEIVE.getValue(),
                 applicationForm.getId(), MessageTemplateUtil.getReceive(applicationForm.getNo()),
                 applicationForm.getId(), ListUtils.newArrayList(applicationForm.getUserId())));
 
@@ -684,26 +723,40 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     public void dispatchModelByDTO(RepairApplicationFormDTO model) {
         RepairApplicationForm applicationForm = mapper.selectById(model.getId());
-        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
-            throw new BusinessException("该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
+        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus())
+                && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
+            throw new BusinessException(
+                    "该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
+        }
+
+        // 查询原维修人姓名(selectById 返回的是实体,repairUserName 为 @Transient 不会被填充)
+        String oldRepairUserName = null;
+        if (StringUtils.isNotBlank(applicationForm.getRepairUserId())) {
+            SysUser oldRepairUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
+            if (oldRepairUser != null) {
+                oldRepairUserName = oldRepairUser.getRealName();
+            }
         }
+        // 查询操作人(当前登录用户)姓名,用于记录是谁派的工
+        UserInfo currentUser = SecurityUtils.getUserInfo();
+        String operatorName = currentUser != null ? currentUser.getRealName() : null;
+        String operatorId = currentUser != null ? currentUser.getUserId() : null;
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("userId", applicationForm.getRepairUserId());
+        jsonObject.put("username", oldRepairUserName);
+        jsonObject.put("remark", model.getRepairDispatchRemark());
+        jsonObject.put("time", LocalDateTime.now());
+        jsonObject.put("type", "dispatch");
+        jsonObject.put("operatorId", operatorId);
+        jsonObject.put("operatorName", operatorName);
 
         if (StringUtils.isBlank(applicationForm.getRepairDispatchList())) {
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("userId", applicationForm.getRepairUserId());
-            jsonObject.put("username", applicationForm.getRepairUserName());
-            jsonObject.put("remark", model.getRepairDispatchRemark());
-            jsonObject.put("time", LocalDateTime.now());
             JSONArray jsonArray = new JSONArray();
             jsonArray.add(jsonObject);
             applicationForm.setRepairDispatchList(jsonArray.toJSONString());
         } else {
             JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("userId", applicationForm.getRepairUserId());
-            jsonObject.put("username", applicationForm.getRepairUserName());
-            jsonObject.put("remark", applicationForm.getRepairDispatchRemark());
-            jsonObject.put("time", LocalDateTime.now());
             jsonArray.add(jsonObject);
             applicationForm.setRepairDispatchList(jsonArray.toJSONString());
         }
@@ -716,9 +769,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         super.modModelByPrimaryKey(applicationForm);
 
         SysUser repairUser = userMapper.selectByPrimaryKey(model.getRepairUserId());
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
                 applicationForm.getId(), MessageTemplateUtil.getRepairDispatch(applicationForm.getNo()),
-                applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()), ListUtils.newArrayList(repairUser.getEmail())));
+                applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()),
+                ListUtils.newArrayList(repairUser.getEmail())));
     }
 
     /**
@@ -747,8 +802,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             applicationForm.setRepairEndTime(dto.getRepairEndTime());
         }
 
-        applicationForm.setRepairMinutes(DateUtils.getDurationHours(applicationForm.getRepairStartTime(), applicationForm.getRepairEndTime()));
-        applicationForm.setDealMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairEndTime()));
+        applicationForm.setRepairMinutes(
+                DateUtils.getDurationHours(applicationForm.getRepairStartTime(), applicationForm.getRepairEndTime()));
+        applicationForm.setDealMinutes(
+                DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairEndTime()));
 
         // 根据配置判断维修是否超时
         String hourFirstStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_OVERTIME_MINUTE_FIRST.name());
@@ -763,11 +820,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         }
         applicationForm.setRepairContent(dto.getRepairContent());
         applicationForm.setNeedStop(dto.getNeedStop());
-        //applicationForm.setLevel(dto.getLevel());
+        // applicationForm.setLevel(dto.getLevel());
         applicationForm.setRepairContent(dto.getRepairContent());
-        //applicationForm.setRepairErrorTypeId(dto.getRepairErrorTypeId());
+        // applicationForm.setRepairErrorTypeId(dto.getRepairErrorTypeId());
         applicationForm.setUpdateTime(LocalDateTime.now());
-        //applicationForm.setContent(dto.getContent());
+        // applicationForm.setContent(dto.getContent());
         applicationForm.setOutType(dto.getOutType());
         applicationForm.setCategory(dto.getCategory());
 
@@ -805,10 +862,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         String checkUserId = null;
 
         // // 有可能维修人不是本设备绑定的维修人,则统一给牛工
-      /*  if(applicationForm.getRepairUserId().equals(sbInfoVO.getRepairUser())){
-            applicationForm.setCheckUserId(sbInfoVO.getRepairUserSecond());
-            userVO = BeanConverterUtil.copyObjectProperties(userMapper.selectByPrimaryKey(sbInfoVO.getRepairUserSecond()), SysUserVO.class);
-        }else{*/
+        /*
+         * if(applicationForm.getRepairUserId().equals(sbInfoVO.getRepairUser())){
+         * applicationForm.setCheckUserId(sbInfoVO.getRepairUserSecond());
+         * userVO =
+         * BeanConverterUtil.copyObjectProperties(userMapper.selectByPrimaryKey(sbInfoVO
+         * .getRepairUserSecond()), SysUserVO.class);
+         * }else{
+         */
         SysUserDTO query = new SysUserDTO();
         query.setRoleCode(SysRoleCodeEnum.REPAIR_EXAMINE.name());
         List<SysUserVO> users = userMapper.selectDeptRoleUser(query);
@@ -818,7 +879,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             throw new BusinessException("审核角色:REPAIR_EXAMINE未绑定用户,REPAIR_EXAMINE为维修单最终验收人,请设置用户");
         }
         applicationForm.setCheckUserId(userVO.getUserId());
-        /*}*/
+        /* } */
 
         super.modModelByPrimaryKey(applicationForm);
 
@@ -831,9 +892,17 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             domain = domain + "/";
         }
         String repairUrl = domain + "repair/application/form/check?no=" + applicationForm.getNo();
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_EXAMINE.getValue(),
-                applicationForm.getId(), MessageTemplateUtil.getFreemarkerHtmlContentCheck(repairUrl, BeanConverterUtil.copyObjectProperties(applicationForm, RepairApplicationFormDTO.class), sbInfoVO),
-                applicationForm.getId(), ListUtils.newArrayList(userVO.getUserId()), ListUtils.newArrayList(userVO.getEmail())));
+        SpringContextHolder
+                .publishEvent(
+                        new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                                WorkplaceBacklogDetailTypeEnum.REPAIR_EXAMINE.getValue(),
+                                applicationForm.getId(),
+                                MessageTemplateUtil.getFreemarkerHtmlContentCheck(repairUrl,
+                                        BeanConverterUtil.copyObjectProperties(applicationForm,
+                                                RepairApplicationFormDTO.class),
+                                        sbInfoVO),
+                                applicationForm.getId(), ListUtils.newArrayList(userVO.getUserId()),
+                                ListUtils.newArrayList(userVO.getEmail())));
     }
 
     /**
@@ -847,7 +916,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
      * @return
      */
     @Override
-    public List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
+    public List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO,
+            Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
         List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
         LocalDateTime searchStartTime = null;
         LocalDateTime searchEndTime = null;
@@ -892,7 +962,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                         continue;
                     }
                 }
-                if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
+                if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth"))
+                        && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
                     i++;
                     detailList.add(repairApplicationForm);
                 }
@@ -919,7 +990,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
      * @return
      */
     @Override
-    public List<RepairReport24VO> getMonthReportTime(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
+    public List<RepairReport24VO> getMonthReportTime(RepairApplicationFormDTO repairApplicationFormDTO,
+            Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
 
         // 只能一个月一个月的查询
         int monthNum = DateUtils.monthDiff(startMonth, endMonth);
@@ -955,7 +1027,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         List<RepairApplicationFormVO> list = mapper.selectPageList(repairApplicationFormDTO);
 
         // 按照人员分组
-        Map<String, List<RepairApplicationFormVO>> mapList = list.stream().collect(Collectors.groupingBy(RepairApplicationFormVO::getRepairUser));
+        Map<String, List<RepairApplicationFormVO>> mapList = list.stream()
+                .collect(Collectors.groupingBy(RepairApplicationFormVO::getRepairUser));
 
         List<RepairReport24VO> result = new ArrayList<RepairReport24VO>();
         int i = 0;
@@ -976,7 +1049,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                     }
                     double minutes = repairApplicationForm.getDealMinutes();
                     time = time + minutes;
-                    if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
+                    if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth"))
+                            && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
                         i++;
                         detailList.add(repairApplicationForm);
                     }
@@ -995,22 +1069,171 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void transfer(RepairApplicationFormDTO record) {
-        if(StringUtils.isBlank(record.getSecondRepairUser()) && StringUtils.isBlank(record.getThreeRepairUser()) && StringUtils.isBlank(record.getFourRepairUser())) {
+        RepairApplicationForm applicationForm = mapper.selectById(record.getId());
+        if (applicationForm == null) {
+            throw new BusinessException("维修单不存在,id:" + record.getId());
+        }
+        // 只有维修中状态可以发起转派
+        if (!RepairApplicationFormStatusEnum.PROCESSING.getValue().equals(applicationForm.getStatus())) {
+            throw new BusinessException(
+                    "该状态不允许转派, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
+        }
+        // 转派目标维修人不能为空
+        if (StringUtils.isBlank(record.getRepairUserId())) {
             throw new BusinessException("转派的维修人不可为空");
         }
-        RepairApplicationForm form = new RepairApplicationForm();
-        form.setId(record.getId());
-        if(StringUtils.isNotBlank(record.getSecondRepairUser())){
-            form.setSecondRepairUser(record.getSecondRepairUser());
+
+        // 查询原维修人姓名
+        String oldRepairUserName = null;
+        if (StringUtils.isNotBlank(applicationForm.getRepairUserId())) {
+            SysUser oldRepairUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
+            if (oldRepairUser != null) {
+                oldRepairUserName = oldRepairUser.getRealName();
+            }
         }
-        if(StringUtils.isNotBlank(record.getThreeRepairUser())){
-            form.setThreeRepairUser(record.getThreeRepairUser());
+        // 查询新维修人姓名
+        SysUser newRepairUser = userMapper.selectByPrimaryKey(record.getRepairUserId());
+        String newRepairUserName = newRepairUser != null ? newRepairUser.getRealName() : null;
+        // 查询操作人(当前登录用户)
+        UserInfo currentUser = SecurityUtils.getUserInfo();
+        String operatorName = currentUser != null ? currentUser.getRealName() : null;
+        String operatorId = currentUser != null ? currentUser.getUserId() : null;
+
+        // 追加转派记录到 repairDispatchList
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("userId", record.getRepairUserId());
+        jsonObject.put("username", newRepairUserName);
+        jsonObject.put("remark", record.getRepairDispatchRemark());
+        jsonObject.put("time", LocalDateTime.now());
+        jsonObject.put("type", "transfer");
+        jsonObject.put("operatorId", operatorId);
+        jsonObject.put("operatorName", operatorName);
+        jsonObject.put("fromUserId", applicationForm.getRepairUserId());
+        jsonObject.put("fromUsername", oldRepairUserName);
+        jsonObject.put("status", "pending"); // pending / approved / rejected
+
+        if (StringUtils.isBlank(applicationForm.getRepairDispatchList())) {
+            JSONArray jsonArray = new JSONArray();
+            jsonArray.add(jsonObject);
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        } else {
+            JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
+            jsonArray.add(jsonObject);
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        }
+
+        // 保存转派备注,暂不更新 repairUserId(审批通过后才更新)
+        applicationForm.setRepairDispatchRemark(record.getRepairDispatchRemark());
+        // 将待转派维修人暂存到 secondRepairUser 字段(审批通过后赋值给 repairUserId)
+        applicationForm.setSecondRepairUser(record.getRepairUserId());
+        // 状态变更为转派审批中
+        applicationForm.setStatus(RepairApplicationFormStatusEnum.TRANSFER_APPROVAL.getValue());
+        applicationForm.setUpdateTime(LocalDateTime.now());
+        super.modModelByPrimaryKey(applicationForm);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void transferApprove(RepairApplicationFormDTO record) {
+        RepairApplicationForm applicationForm = mapper.selectById(record.getId());
+        if (applicationForm == null) {
+            throw new BusinessException("维修单不存在,id:" + record.getId());
         }
-        if(StringUtils.isNotBlank(record.getFourRepairUser())){
-            form.setFourRepairUser(record.getFourRepairUser());
+        if (!RepairApplicationFormStatusEnum.TRANSFER_APPROVAL.getValue().equals(applicationForm.getStatus())) {
+            throw new BusinessException(
+                    "该状态不允许审批转派, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
         }
-        mapper.updateByPrimaryKeySelective(form);
+
+        // 查询审批人(当前登录用户)
+        UserInfo currentUser = SecurityUtils.getUserInfo();
+        String approverName = currentUser != null ? currentUser.getRealName() : null;
+        String approverId = currentUser != null ? currentUser.getUserId() : null;
+
+        // 更新 repairDispatchList 中最后一条转派记录的状态为 approved
+        if (StringUtils.isNotBlank(applicationForm.getRepairDispatchList())) {
+            JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
+            // 从后往前找最后一条 type=transfer 且 status=pending 的记录
+            for (int i = jsonArray.size() - 1; i >= 0; i--) {
+                JSONObject obj = jsonArray.getJSONObject(i);
+                if ("transfer".equals(obj.getString("type")) && "pending".equals(obj.getString("status"))) {
+                    obj.put("status", "approved");
+                    obj.put("approverId", approverId);
+                    obj.put("approverName", approverName);
+                    obj.put("approveTime", LocalDateTime.now());
+                    obj.put("approveRemark", record.getRepairDispatchRemark());
+                    break;
+                }
+            }
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        }
+
+        // 审批通过:将暂存在 secondRepairUser 中的待转派维修人赋值给 repairUserId
+        if (StringUtils.isNotBlank(applicationForm.getSecondRepairUser())) {
+            applicationForm.setRepairUserId(applicationForm.getSecondRepairUser());
+            applicationForm.setSecondRepairUser(null);
+        }
+        // 状态恢复为维修中
+        applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
+        applicationForm.setRepairDispatchRemark(record.getRepairDispatchRemark());
+        applicationForm.setUpdateTime(LocalDateTime.now());
+        super.modModelByPrimaryKey(applicationForm);
+
+        // 通知新维修人
+        if (StringUtils.isNotBlank(applicationForm.getRepairUserId())) {
+            SysUser repairUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
+            if (repairUser != null) {
+                SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                        WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
+                        applicationForm.getId(), MessageTemplateUtil.getRepairDispatch(applicationForm.getNo()),
+                        applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()),
+                        ListUtils.newArrayList(repairUser.getEmail())));
+            }
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void transferReject(RepairApplicationFormDTO record) {
+        RepairApplicationForm applicationForm = mapper.selectById(record.getId());
+        if (applicationForm == null) {
+            throw new BusinessException("维修单不存在,id:" + record.getId());
+        }
+        if (!RepairApplicationFormStatusEnum.TRANSFER_APPROVAL.getValue().equals(applicationForm.getStatus())) {
+            throw new BusinessException(
+                    "该状态不允许审批转派, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
+        }
+
+        // 查询审批人(当前登录用户)
+        UserInfo currentUser = SecurityUtils.getUserInfo();
+        String approverName = currentUser != null ? currentUser.getRealName() : null;
+        String approverId = currentUser != null ? currentUser.getUserId() : null;
+
+        // 更新 repairDispatchList 中最后一条转派记录的状态为 rejected
+        if (StringUtils.isNotBlank(applicationForm.getRepairDispatchList())) {
+            JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
+            for (int i = jsonArray.size() - 1; i >= 0; i--) {
+                JSONObject obj = jsonArray.getJSONObject(i);
+                if ("transfer".equals(obj.getString("type")) && "pending".equals(obj.getString("status"))) {
+                    obj.put("status", "rejected");
+                    obj.put("approverId", approverId);
+                    obj.put("approverName", approverName);
+                    obj.put("approveTime", LocalDateTime.now());
+                    obj.put("approveRemark", record.getRepairDispatchRemark());
+                    break;
+                }
+            }
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        }
+
+        // 审批驳回:清除暂存的待转派维修人,保持原 repairUserId 不变
+        applicationForm.setSecondRepairUser(null);
+        // 状态恢复为维修中
+        applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
+        applicationForm.setRepairDispatchRemark(record.getRepairDispatchRemark());
+        applicationForm.setUpdateTime(LocalDateTime.now());
+        super.modModelByPrimaryKey(applicationForm);
     }
 
     /**
@@ -1061,8 +1284,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                     vo.setYear(map.get("searchStartTime").getYear());
                     double workYear = sbWorkYear - (map.get("searchStartTime").getYear() - sbStartYear);
                     for (RepairApplicationFormVO repairApplicationForm : list) {
-                        if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTime")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTime"))) {
-                            if (repairApplicationForm.getCategory() != null && dictVO.getValue().equals(repairApplicationForm.getCategory())) {
+                        if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTime"))
+                                && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTime"))) {
+                            if (repairApplicationForm.getCategory() != null
+                                    && dictVO.getValue().equals(repairApplicationForm.getCategory())) {
                                 num++;
                                 detailList.add(repairApplicationForm);
                             }
@@ -1089,7 +1314,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
      * @return
      */
     @Override
-    public List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
+    public List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO,
+            Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
 
         List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
         LocalDateTime searchStartTime = null;
@@ -1132,7 +1358,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                 if (repairApplicationForm.getDealMinutes() == null || (repairApplicationForm.getDealMinutes() > 24.0)) {
                     continue;
                 }
-                if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
+                if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth"))
+                        && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
                     i++;
                     detailList.add(repairApplicationForm);
                     totalMinuties = totalMinuties + repairApplicationForm.getDealMinutes();
@@ -1174,11 +1401,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         applicationForm.setCategory(dto.getCategory());
         if (dto.getRepairStartTime() != null) {
             applicationForm.setRepairStartTime(dto.getRepairStartTime());
-            applicationForm.setReceiveMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairStartTime()));
+            applicationForm.setReceiveMinutes(
+                    DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairStartTime()));
             if (dto.getRepairEndTime() != null) {
                 applicationForm.setRepairEndTime(dto.getRepairEndTime());
-                applicationForm.setRepairMinutes(DateUtils.getDurationHours(dto.getRepairStartTime(), dto.getRepairEndTime()));
-                applicationForm.setDealMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairEndTime()));
+                applicationForm
+                        .setRepairMinutes(DateUtils.getDurationHours(dto.getRepairStartTime(), dto.getRepairEndTime()));
+                applicationForm.setDealMinutes(
+                        DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairEndTime()));
             }
         }
         applicationForm.setCategory(dto.getCategory());
@@ -1230,15 +1460,15 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                 }
             }
             // 发送微信
-            sendCompleteWechat(openIds,applicationForm,info);
+            sendCompleteWechat(openIds, applicationForm, info);
             // 发送邮件
-            sendCompleteEmail(userIds,applicationForm,info,mails);
+            sendCompleteEmail(userIds, applicationForm, info, mails);
             // 发送短信
-            sendCompleteSms(receiverList,info,applicationForm);
+            sendCompleteSms(receiverList, info, applicationForm);
         }
     }
 
-    private void sendCompleteWechat(List<String> openIds,RepairApplicationForm form,SbInfo info) {
+    private void sendCompleteWechat(List<String> openIds, RepairApplicationForm form, SbInfo info) {
         // 发送微信通知给设备使用人员
         if (CollectionUtil.isNotEmpty(openIds) && BeanUtils.isProd()) {
             String mobileDomain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN_MOBILE.name());
@@ -1252,24 +1482,24 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
 
             for (String openId : openIds) {
                 // 封装请求参数
-                WechatTemplateRequest request = WechatTemplateRequestBuilder.
-                        getRepairSynergism(mobileRepairUrl,
-                                WeChatMessageUtil.template_id_send_repair,
-                                openId,
-                                new String[]{
-                                        "维修工单已验收请知悉",
-                                        info.getNo(),
-                                        "已完成",
-                                        DateUtils.dateToString(LocalDateTime.now()),
-                                        info.getName()
-                                }, new String[]{"#000000",
-                                        "#000000", "#000000", "#000000", "#000000" });
-                WeChatMessageUtil.sendRepairMessage(openId,request);
+                WechatTemplateRequest request = WechatTemplateRequestBuilder.getRepairSynergism(mobileRepairUrl,
+                        WeChatMessageUtil.template_id_send_repair,
+                        openId,
+                        new String[] {
+                                "维修工单已验收请知悉",
+                                info.getNo(),
+                                "已完成",
+                                DateUtils.dateToString(LocalDateTime.now()),
+                                info.getName()
+                        },
+                        new String[] { "#000000",
+                                "#000000", "#000000", "#000000", "#000000" });
+                WeChatMessageUtil.sendRepairMessage(openId, request);
             }
         }
     }
 
-    private void sendCompleteEmail(List<String> userIds,RepairApplicationForm form,SbInfo info,List<String> mails){
+    private void sendCompleteEmail(List<String> userIds, RepairApplicationForm form, SbInfo info, List<String> mails) {
         String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
         if (StringUtils.isBlank(domain)) {
             throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
@@ -1284,13 +1514,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         model.setSbCph(form.getSbCph());
         model.setContent(form.getContent());
         model.setActualUser(form.getActualUser());
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue(),
                 form.getId(),
                 MessageTemplateUtil.getFreemarkerHtmlContent(repairUrl, model, info),
                 form.getId(), userIds, mails));
     }
 
-    private void sendCompleteSms(List<String> receiverList,SbInfo sb,RepairApplicationForm model){
+    private void sendCompleteSms(List<String> receiverList, SbInfo sb, RepairApplicationForm model) {
         if (CollectionUtil.isNotEmpty(receiverList) && BeanUtils.isProd()) {
             String no = sb.getNo();
             if (StringUtils.isNotBlank(no)) {
@@ -1314,7 +1545,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                         RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, "1", 24, TimeUnit.HOURS);
                     } else if (Integer.valueOf(numStr) < 5) {
                         isSend = true;
-                        RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
+                        RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver,
+                                String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
                     }
                     if (isSend) {
                         System.out.println("templateParas_repair: " + templateParas_repair);
@@ -1343,9 +1575,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         super.modModelByPrimaryKey(applicationForm);
 
         SysUser noticeUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_BACK.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                WorkplaceBacklogDetailTypeEnum.REPAIR_BACK.getValue(),
                 dto.getId(), MessageTemplateUtil.getRepairBack(applicationForm.getNo()),
-                applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()), ListUtils.newArrayList(noticeUser.getEmail())));
+                applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()),
+                ListUtils.newArrayList(noticeUser.getEmail())));
     }
 
     @Override
@@ -1378,7 +1612,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     public void autoAssignTaskForTimer() {
         LocalDateTime minutesAgo = DateUtils.minus(LocalDateTime.now(), 10, ChronoUnit.MINUTES);
         Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
-        weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue())
+        weekend.weekendCriteria()
+                .andEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue())
                 .andLessThan(RepairApplicationForm::getCreatedTime, minutesAgo);
         List<RepairApplicationForm> tasks = mapper.selectByExample(weekend);
         List<SysUser> users = userMapper.select(new SysUser().setIdentityType(SysUserIdentityType.WXZG.getValue()));
@@ -1395,9 +1630,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                 update.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
                 mapper.updateByPrimaryKeySelective(update);
 
-                SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
+                SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
+                        WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
                         item.getId(), MessageTemplateUtil.getRepairApplicationForReceive(item.getNo()),
-                        item.getId(), Arrays.asList(repairManager.getUserId()), Arrays.asList(repairManager.getEmail())));
+                        item.getId(), Arrays.asList(repairManager.getUserId()),
+                        Arrays.asList(repairManager.getEmail())));
             });
         }
     }
@@ -1406,15 +1643,16 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     public void unFinishNoticeForTimer() {
         // 3小时通知
         List<RepairApplicationForm> tasks = getOverTimeTask(3);
-        List<SysUser> users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.WXJL.getValue(), SysUserIdentityType.SCJL.getValue()}));
+        List<SysUser> users = getUsersByIdentity(Arrays
+                .asList(new Integer[] { SysUserIdentityType.WXJL.getValue(), SysUserIdentityType.SCJL.getValue() }));
         sendOverTimeNotice(users, tasks);
         // 8小时通知
         tasks = getOverTimeTask(8);
-        users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.YYJL.getValue()}));
+        users = getUsersByIdentity(Arrays.asList(new Integer[] { SysUserIdentityType.YYJL.getValue() }));
         sendOverTimeNotice(users, tasks);
         // 24小时通知
         tasks = getOverTimeTask(24);
-        users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.ZJL.getValue()}));
+        users = getUsersByIdentity(Arrays.asList(new Integer[] { SysUserIdentityType.ZJL.getValue() }));
         sendOverTimeNotice(users, tasks);
     }
 
@@ -1427,7 +1665,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     private List<RepairApplicationForm> getOverTimeTask(int hour) {
         LocalDateTime threeHourAgo = DateUtils.minus(LocalDateTime.now(), hour, ChronoUnit.HOURS);
         Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
-        weekend.weekendCriteria().andNotIn(RepairApplicationForm::getStatus, Arrays.asList(new Integer[]{RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue(), RepairApplicationFormStatusEnum.FINISHED.getValue()}))
+        weekend.weekendCriteria()
+                .andNotIn(RepairApplicationForm::getStatus,
+                        Arrays.asList(new Integer[] { RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue(),
+                                RepairApplicationFormStatusEnum.FINISHED.getValue() }))
                 .andLessThan(RepairApplicationForm::getCreatedTime, threeHourAgo);
         return mapper.selectByExample(weekend);
     }
@@ -1442,9 +1683,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         if (CollectionUtil.isNotEmpty(users) && CollectionUtil.isNotEmpty(tasks)) {
             List<String> userIds = users.stream().map(item -> item.getUserId()).collect(Collectors.toList());
             List<String> mails = users.stream().map(item -> item.getEmail()).collect(Collectors.toList());
-            tasks.forEach(item -> SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR_NOT_FINISH.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
-                    item.getId(), MessageTemplateUtil.getRepairApplicationForNotFinishNotic(item.getNo(), 3),
-                    item.getId(), userIds, mails)));
+            tasks.forEach(item -> SpringContextHolder
+                    .publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR_NOT_FINISH.getValue(),
+                            WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
+                            item.getId(), MessageTemplateUtil.getRepairApplicationForNotFinishNotic(item.getNo(), 3),
+                            item.getId(), userIds, mails)));
         }
     }
 

+ 182 - 144
platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartInfoServiceImpl.java

@@ -84,7 +84,8 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 @Service("sparePartInfoService")
 @Slf4j
-public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMapper, SparePartInfo, SparePartInfoDTO> implements SparePartInfoService {
+public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMapper, SparePartInfo, SparePartInfoDTO>
+        implements SparePartInfoService {
 
     private final SbInfoMapper sbInfoMapper;
     private final SpareTypeMapper spareTypeMapper;
@@ -100,15 +101,13 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
     private CheckJobMapper checkJobMapper;
     private CheckStandardSpareMapper checkStandardSpareMapper;
 
-
     @Override
     public AbstractPageResultBean<SparePartInfoVO> getInOrOut(SparePartInfoDTO dto, Integer pageNum, Integer pageSize) {
         List<StoreVO> stores = storeMapper.selectList(null);
         Map<String, String> map = new HashMap<>();
         for (StoreVO vo : stores) {
             if (vo.getLevel() == 3) {
-                first:
-                for (StoreVO vo1 : stores) {
+                first: for (StoreVO vo1 : stores) {
                     System.out.println("11111111111");
                     if (vo.getParentId().equals(vo1.getId())) {
                         for (StoreVO vo2 : stores) {
@@ -130,7 +129,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
             SbModelSpareBomDTO sbModelDTO = new SbModelSpareBomDTO();
             sbModelDTO.setKeyword(dto.getModel());
             List<SbModelSpareBomVO> modelList = sbModelSpareBomMapper.selectVOList(sbModelDTO);
-            List<String> spareList = modelList.stream().map(item -> item.getSpareId()).distinct().collect(Collectors.toList());
+            List<String> spareList = modelList.stream().map(item -> item.getSpareId()).distinct()
+                    .collect(Collectors.toList());
             dto.setSpareIdList(spareList);
         }
         PageHelper.startPage(pageNum, pageSize);
@@ -178,7 +178,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
     }
 
     @Override
-    public AbstractPageResultBean<SparePartInfoVO> selectSpareInfoPageListBySbId(String sbId, int pageNum, int pageSize) {
+    public AbstractPageResultBean<SparePartInfoVO> selectSpareInfoPageListBySbId(String sbId, int pageNum,
+            int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
         return new MyPage(mapper.selectSpareInfoListBySbId(sbId));
     }
@@ -215,7 +216,9 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
             String url = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.URL_SPARE_MIN_STOCK_WARN.name());
             if (StringUtils.isNotBlank(email)) {
                 // 通过给邮件人员
-                SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(), WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
+                SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(
+                        WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(),
+                        WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
                         null, MessageTemplateUtil.getSpareMinStockWarnNotice(domain + url, sparePartInfos.size()),
                         null, null, Arrays.asList(email)));
             }
@@ -270,7 +273,9 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     String url = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.URL_SPARE_CHECK_STOCK_WARN.name());
                     if (StringUtils.isNotBlank(email)) {
                         // 通过给邮件人员
-                        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(), WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
+                        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(
+                                WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(),
+                                WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
                                 null, MessageTemplateUtil.getSpareCheckStockWarnNotice(domain + url, voList.size()),
                                 null, null, Arrays.asList(email)));
                     }
@@ -324,7 +329,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         for (SparePartInfo vo : list) {
             if (StringUtils.isBlank(vo.getQrCode())) {
                 // 保存二维码
-                String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/" + IdGeneratorUtils.getObjectId() + "/";
+                String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/"
+                        + IdGeneratorUtils.getObjectId() + "/";
                 String rootPath = environment.getProperty("upload.root-dir");
                 String filePath = rootPath + path;
                 String codePath = path + vo.getId() + ".png";
@@ -426,8 +432,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         Map<String, String> map = new HashMap<>();
         for (StoreVO vo : stores) {
             if (vo.getLevel() == 3) {
-                first:
-                for (StoreVO vo1 : stores) {
+                first: for (StoreVO vo1 : stores) {
                     System.out.println("11111111111");
                     if (vo.getParentId().equals(vo1.getId())) {
                         for (StoreVO vo2 : stores) {
@@ -461,13 +466,13 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         // 查询备件关联的设备型号信息
         List<SbModelSpareBomVO> bomList = sbModelSpareBomMapper.selectExportList2(sparePartInfoDTO);
         for (SparePartInfoVO sparePartInfo : list) {
-//                if (sparePartInfo.getYt()==1){
-//                    sparePartInfo.setYtStr("设备配件");
-//                }else if (sparePartInfo.getYt()==2){
-//                    sparePartInfo.setYtStr("工程物资");
-//                }else {
-//                    sparePartInfo.setYtStr("设备配件");
-//                }
+            // if (sparePartInfo.getYt()==1){
+            // sparePartInfo.setYtStr("设备配件");
+            // }else if (sparePartInfo.getYt()==2){
+            // sparePartInfo.setYtStr("工程物资");
+            // }else {
+            // sparePartInfo.setYtStr("设备配件");
+            // }
             StringBuffer sb = new StringBuffer();
             for (SbModelSpareBomVO sbModelSpareBomVO : bomList) {
                 if (sparePartInfo.getId().equals(sbModelSpareBomVO.getSpareId())) {
@@ -476,9 +481,9 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     sbInfo.setId(sbModelSpareBomVO.getSbId());
                     sbInfo = sbInfoMapper.selectOne(sbInfo);
                     sb = sb.append(sbInfo.getNo()).append(';');
-//                    sparePartInfo.setModelName(sbModelSpareBomVO.getName());
-//                    sparePartInfo.setModelModel(sbModelSpareBomVO.getModel());
-//                        sparePartInfo.setSbNo(sb.append(sbInfo.getNo())+";");
+                    // sparePartInfo.setModelName(sbModelSpareBomVO.getName());
+                    // sparePartInfo.setModelModel(sbModelSpareBomVO.getModel());
+                    // sparePartInfo.setSbNo(sb.append(sbInfo.getNo())+";");
                 }
             }
             sparePartInfo.setSbNo(sb.toString());
@@ -518,14 +523,14 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         return names;
     }
 
-
     @Override
     public AbstractPageResultBean<SparePartInfoVO> selectPageInfo2(SparePartInfoDTO record, int pageNum, int pageSize) {
         if (StringUtils.isNotEmpty(record.getModel())) {
             SbModelSpareBomDTO sbModelDTO = new SbModelSpareBomDTO();
             sbModelDTO.setKeyword(record.getModel());
             List<SbModelSpareBomVO> modelList = sbModelSpareBomMapper.selectVOList(sbModelDTO);
-            List<String> spareList = modelList.stream().map(item -> item.getSpareId()).distinct().collect(Collectors.toList());
+            List<String> spareList = modelList.stream().map(item -> item.getSpareId()).distinct()
+                    .collect(Collectors.toList());
             record.setSpareIdList(spareList);
         }
         // 选择设备对应的备件bom列表
@@ -625,17 +630,20 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                 model.setChildNo(type.getNo());
             }
         }
-       /* Weekend<SysFile> weekendFile = new Weekend<>(SysFile.class);
-        weekendFile.weekendCriteria().andEqualTo(SysFile::getTargetId, model.getId());
-        List<SysFile> sysFiles = sysFileMapper.selectByExample(weekendFile);
-        List<SysFile> s = ListUtils.newArrayList();
-        List<SysFile> applicationFileList = ListUtils.newArrayList();
-        sysFiles.forEach(item -> {
-            if (item.getType().equals(SysFileTypeEnum.SPARE_IMGS.getValue())) {
-                applicationFileList.add(item);
-            }
-        });
-        model.setApplicationFileList(applicationFileList);*/
+        /*
+         * Weekend<SysFile> weekendFile = new Weekend<>(SysFile.class);
+         * weekendFile.weekendCriteria().andEqualTo(SysFile::getTargetId,
+         * model.getId());
+         * List<SysFile> sysFiles = sysFileMapper.selectByExample(weekendFile);
+         * List<SysFile> s = ListUtils.newArrayList();
+         * List<SysFile> applicationFileList = ListUtils.newArrayList();
+         * sysFiles.forEach(item -> {
+         * if (item.getType().equals(SysFileTypeEnum.SPARE_IMGS.getValue())) {
+         * applicationFileList.add(item);
+         * }
+         * });
+         * model.setApplicationFileList(applicationFileList);
+         */
 
         return model;
     }
@@ -688,7 +696,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         }
 
         Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
-        weekend.weekendCriteria().andEqualTo(SparePartInfo::getName, model.getName()).andEqualTo(SparePartInfo::getGgxh, model.getGgxh());
+        weekend.weekendCriteria().andEqualTo(SparePartInfo::getName, model.getName()).andEqualTo(SparePartInfo::getGgxh,
+                model.getGgxh());
         int checkInfo = mapper.selectCountByExample(weekend);
         if (checkInfo > 0) {
             throw new BusinessException("同名称同规格的备件已存在,请重新设置");
@@ -699,7 +708,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         setSpareNo(model);
 
         // 保存二维码
-        String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/" + IdGeneratorUtils.getObjectId() + "/";
+        String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/"
+                + IdGeneratorUtils.getObjectId() + "/";
         String rootPath = environment.getProperty("upload.root-dir");
         String filePath = rootPath + path;
         String codePath = path + model.getId() + ".png";
@@ -723,7 +733,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
             bom.setUpdateUserId(userInfo.getUserId());
             sbModelSpareBomMapper.insert(bom);
         }
-        //this.saveFile(model);
+        // this.saveFile(model);
 
         // 如果初始化数量有了,就需要更新库存
         if (model.getInitStock() == null) {
@@ -733,9 +743,9 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
             SpareStore spareStore = new SpareStore();
             spareStore.setSpareId(model.getId());
             spareStore.setId(IdGeneratorUtils.getObjectId());
-//            if (StringUtils.isBlank(model.getStoreId())) {
-//                throw new BusinessException("请设置库位信息");
-//            }
+            // if (StringUtils.isBlank(model.getStoreId())) {
+            // throw new BusinessException("请设置库位信息");
+            // }
             if (StringUtils.isNotBlank(model.getStoreId())) {
                 Store store = storeMapper.selectByPrimaryKey(model.getStoreId());
                 if (store == null) {
@@ -762,10 +772,10 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         // 插入设备关联
         List<SbModelSpareBomDTO> detailList = model.getDetailList();
         if (!CollectionUtils.isEmpty(detailList)) {
-//            for (SbModelSpareBomDTO detail : detailList) {
-//                detail.setSpareId(model.getId());
-//                detail.setId(IdGeneratorUtils.getObjectId());
-//            }
+            // for (SbModelSpareBomDTO detail : detailList) {
+            // detail.setSpareId(model.getId());
+            // detail.setId(IdGeneratorUtils.getObjectId());
+            // }
             for (int i = 0; i < detailList.size(); i++) {
                 if (detailList.get(i).getSbId().equals(model.getSbId())) {
                     detailList.remove(i);
@@ -778,7 +788,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
 
             }
             if (detailList.size() > 0) {
-                sbModelSpareBomMapper.insertListforComplex(BeanConverterUtil.copyListProperties(detailList, SbModelSpareBom.class));
+                sbModelSpareBomMapper
+                        .insertListforComplex(BeanConverterUtil.copyListProperties(detailList, SbModelSpareBom.class));
             }
         }
         return super.saveModelHaveCreateInfo(model);
@@ -868,7 +879,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         }
 
         Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
-        weekend.weekendCriteria().andEqualTo(SparePartInfo::getName, model.getName()).andEqualTo(SparePartInfo::getGgxh, model.getGgxh());
+        weekend.weekendCriteria().andEqualTo(SparePartInfo::getName, model.getName()).andEqualTo(SparePartInfo::getGgxh,
+                model.getGgxh());
         int count = mapper.selectCountByExample(weekend);
         if (count > 1) {
             throw new BusinessException("同名称同规格的备件已存在,请重新设置名称或者规格");
@@ -884,7 +896,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         List<String> ids = detailList.stream().map(SbModelSpareBomDTO::getId).collect(Collectors.toList());
         ids = ids.stream().filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
         if (!CollectionUtils.isEmpty(ids) && ids.size() > 0) {
-            detailWeekend.weekendCriteria().andNotIn(SbModelSpareBom::getId, ids).andEqualTo(SbModelSpareBom::getSpareId, model.getId());
+            detailWeekend.weekendCriteria().andNotIn(SbModelSpareBom::getId, ids)
+                    .andEqualTo(SbModelSpareBom::getSpareId, model.getId());
             sbModelSpareBomMapper.deleteByExample(detailWeekend);
         } else {
             // 全部刪除:说明id为空,全部删除了
@@ -903,34 +916,40 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                 }
             }
             if (!CollectionUtils.isEmpty(addList)) {
-                sbModelSpareBomMapper.insertListforComplex(BeanConverterUtil.copyListProperties(addList, SbModelSpareBom.class));
+                sbModelSpareBomMapper
+                        .insertListforComplex(BeanConverterUtil.copyListProperties(addList, SbModelSpareBom.class));
             }
             if (!CollectionUtils.isEmpty(updateList)) {
-                sbModelSpareBomMapper.updateBatchAll(BeanConverterUtil.copyListProperties(updateList, SbModelSpareBom.class));
+                sbModelSpareBomMapper
+                        .updateBatchAll(BeanConverterUtil.copyListProperties(updateList, SbModelSpareBom.class));
             }
         }
-        //修改关联仓库
-        /*if (model.getStoreId()!=null){
-            SpareStore spareStore = new SpareStore();
-            spareStore.setSpareId(model.getId());
-            spareStoreMapper.delete(spareStore);
-            spareStore.setStoreId(model.getStoreId());
-            spareStore.setPrice(model.getInitialValue());
-            setKey2(spareStore);
-            spareStore.setCreatedTime(LocalDateTime.now());
-            spareStore.setCreatedUserName(SecurityUtils.getUserInfo().getRealName());
-            spareStore.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
-            spareStoreMapper.insert(spareStore);
-        }*/
+        // 修改关联仓库
+        /*
+         * if (model.getStoreId()!=null){
+         * SpareStore spareStore = new SpareStore();
+         * spareStore.setSpareId(model.getId());
+         * spareStoreMapper.delete(spareStore);
+         * spareStore.setStoreId(model.getStoreId());
+         * spareStore.setPrice(model.getInitialValue());
+         * setKey2(spareStore);
+         * spareStore.setCreatedTime(LocalDateTime.now());
+         * spareStore.setCreatedUserName(SecurityUtils.getUserInfo().getRealName());
+         * spareStore.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
+         * spareStoreMapper.insert(spareStore);
+         * }
+         */
         super.modModelByDTO(model);
     }
 
     private void saveFile(SparePartInfoDTO model) {
         if (CollectionUtil.isNotEmpty(model.getApplicationFileList())) {
             Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
-            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.SPARE_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
+            weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.SPARE_IMGS.getValue())
+                    .andEqualTo(SysFile::getTargetId, model.getId());
             sysFileMapper.deleteByExample(weekend);
-            List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(), SysFileTypeEnum.SPARE_IMGS.getValue());
+            List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(),
+                    SysFileTypeEnum.SPARE_IMGS.getValue());
             if (CollectionUtil.isNotEmpty(list)) {
                 sysFileMapper.insertListforComplex(list);
             }
@@ -967,7 +986,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     System.out.println("正在处理:" + item.getName() + ",编号" + item.getNo());
                     boolean isExist = false;
                     for (SparePartInfo old : vos) {
-                        // System.out.println("正在对比:" + old.getName() + ", 规格" + old.getGgxh() + ", 原厂编号" + old.getInitNo());
+                        // System.out.println("正在对比:" + old.getName() + ", 规格" + old.getGgxh() + ",
+                        // 原厂编号" + old.getInitNo());
                         if (item.getGgxh() == null) {
                             if (old.getName().equals(item.getName()) && old.getGgxh() == null) {
                                 isExist = true;
@@ -1079,7 +1099,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                             model.setId(IdGeneratorUtils.getObjectId());
                             boolean withModelBoms = false;
                             for (SbModel modelIs : addSbModelItems) {
-                                if (modelIs.getName().equals(model.getName()) && modelIs.getModel().equals(model.getModel())) {
+                                if (modelIs.getName().equals(model.getName())
+                                        && modelIs.getModel().equals(model.getModel())) {
                                     withModelBoms = true;
                                     break;
                                 }
@@ -1137,7 +1158,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     spareStoreMapper.insertListforComplex(spareStoreList);
                 }
             }
-            return "总计新增导入:" + (addItems.size()) + "已存在未导入数量:" + modelExist.size() + ",找不到如下型号,已经添加:" + modelError.toString();
+            return "总计新增导入:" + (addItems.size()) + "已存在未导入数量:" + modelExist.size() + ",找不到如下型号,已经添加:"
+                    + modelError.toString();
         } catch (Exception e) {
             throw new BusinessException(e.getMessage());
         }
@@ -1196,7 +1218,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     }
                     // 判断等级
                     if (StringUtils.isNotBlank(item.getLevelString())) {
-                        Integer level = DictCache.getValueByLabel("SPARE_PART_INFO_LEVEL", item.getLevelString().trim());
+                        Integer level = DictCache.getValueByLabel("SPARE_PART_INFO_LEVEL",
+                                item.getLevelString().trim());
                         if (level == null) {
                             throw new BusinessException("第" + lineNum + "行的备件等级填写有误,请输入【一级】、【二级】、【三级】中的某一个");
                         }
@@ -1206,14 +1229,15 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     if (StringUtils.isNotBlank(item.getTypeId())) {
                         boolean isExist = false;
                         for (SpareType spareType : spareTypeList) {
-                            if (spareType.getName().equals(item.getTypeId().trim())) {
+                            if (spareType.getNo().equals(item.getTypeId().trim())) {
                                 isExist = true;
                                 sparePartInfo.setTypeId(spareType.getId());
                                 break;
                             }
                         }
                         if (!isExist) {
-                            throw new BusinessException("第" + lineNum + "行的备件类别【" + item.getTypeId() + "】,系统中不存在,请检查");
+                            throw new BusinessException(
+                                    "第" + lineNum + "行的备件类别编码【" + item.getTypeId() + "】,系统中不存在,请检查");
                         }
                     }
                     // 生产厂商
@@ -1227,7 +1251,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                             }
                         }
                         if (!isExist) {
-                            throw new BusinessException("第" + lineNum + "行的生产商【" + item.getProducerName() + "】,系统中不存在,请检查");
+                            throw new BusinessException(
+                                    "第" + lineNum + "行的生产商【" + item.getProducerName() + "】,系统中不存在,请检查");
                         }
                     }
                     // 备件用途 SPARE_USE_TYPE
@@ -1322,7 +1347,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     if (StringUtils.isBlank(updInfo.getId())) {
                         throw new DeniedException("第" + addNum + "行的主键不为空");
                     }
-                    //先删除当前备件的所有bom,再新增excel导入的bom
+                    // 先删除当前备件的所有bom,再新增excel导入的bom
                     SpareStore query = new SpareStore();
                     query.setSpareId(updInfo.getId());
                     List<SpareStore> deletelist = spareStoreMapper.select(query);
@@ -1349,7 +1374,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     }
                     // 判断等级
                     if (StringUtils.isNotBlank(item.getLevelString())) {
-                        Integer level = DictCache.getValueByLabel("SPARE_PART_INFO_LEVEL", item.getLevelString().trim());
+                        Integer level = DictCache.getValueByLabel("SPARE_PART_INFO_LEVEL",
+                                item.getLevelString().trim());
                         if (level == null) {
                             throw new BusinessException("第" + addNum + "行的备件等级填写有误,请输入【一级】、【二级】、【三级】中的某一个");
                         }
@@ -1359,14 +1385,14 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     if (StringUtils.isNotBlank(item.getTypeId())) {
                         boolean isExist = false;
                         for (SpareType spareType : spareTypeList) {
-                            if (spareType.getName().equals(item.getTypeId().trim())) {
+                            if (spareType.getNo().equals(item.getTypeId().trim())) {
                                 isExist = true;
                                 updInfo.setTypeId(spareType.getId());
                                 break;
                             }
                         }
                         if (!isExist) {
-                            throw new BusinessException("第" + addNum + "行的备件类别【" + item.getTypeId() + "】,系统中不存在,请检查");
+                            throw new BusinessException("第" + addNum + "行的备件类别编码【" + item.getTypeId() + "】,系统中不存在,请检查");
                         }
                     }
                     // 生产厂商
@@ -1380,7 +1406,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                             }
                         }
                         if (!isExist) {
-                            throw new BusinessException("第" + addNum + "行的生产商【" + item.getProducerName() + "】,系统中不存在,请检查");
+                            throw new BusinessException(
+                                    "第" + addNum + "行的生产商【" + item.getProducerName() + "】,系统中不存在,请检查");
                         }
                     }
                     // 备件用途 SPARE_USE_TYPE
@@ -1410,72 +1437,83 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         } catch (Exception e) {
             throw new BusinessException(e.getMessage());
         }
-        /*int addNum = 0;
-        List<SparePartInfoVO> addItems = new ArrayList<SparePartInfoVO>();
-        LocalDateTime now = LocalDateTime.now();
-        try {
-            List<SparePartInfoVO> items = CustomExcelImportUtil.importSparePartInfoListForUpdate(file.getInputStream());
-            if (!CollectionUtils.isEmpty(items)) {
-                List<SpareType> typeList = spareTypeMapper.selectAll();
-                for (SparePartInfoVO item : items) {
-                    //先删除当前备件的所有bom,再新增excel导入的bom
-                    SbModelSpareBom bom = new SbModelSpareBom();
-                    bom.setSpareId(item.getId());
-                    sbModelSpareBomMapper.delete(bom);
-                    List<String> sbNos = new ArrayList<>();
-                    if (item.getSbNo()!=null){
-                        sbNos = getSbNos(item.getSbNo());
-                    }
-                    if (sbNos.size()>0) {
-                        Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
-                        WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
-                        weekendCriteria.andIn(SbInfo::getNo, sbNos);
-                        List<SbInfo> sbinfos = sbInfoMapper.selectByExample(weekend);
-                        List<SbModelSpareBom> boms = new ArrayList<>();
-                        for (SbInfo info : sbinfos) {
-                            bom = new SbModelSpareBom();
-                            bom.setSpareId(item.getId());
-                            bom.setSbId(info.getId());
-                            setKey2(bom);
-                            bom.setCreatedTime(LocalDateTime.now());
-                            bom.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
-                            bom.setUpdateTime(LocalDateTime.now());
-                            bom.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
-                            bom.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
-                            bom.setUpdateUserName(SecurityUtils.getUserInfo().getUsername());
-                            boms.add(bom);
-                        }
-                        sbModelSpareBomMapper.insertListforComplex(boms);
-                    }
-                    // 设置类型转换
-                    for (SpareType type : typeList) {
-                        if (type.getName().equals(item.getTypeName())) {
-                            item.setParentTypeId(type.getId());
-                            item.setParentNo(type.getNo());
-                            item.setTypeId(type.getId());
-                        }
-                        *//*if (type.getName().equals(item.getMiddleName()) && StringUtils.isNotBlank(type.getParentId()) && type.getParentId().equals(item.getParentTypeId())) {
-                            item.setMiddleTypeId(type.getId());
-                            item.setMiddleNo(type.getNo());
-                            item.setTypeId(type.getId());
-                        }
-                        if (type.getName().equals(item.getChildName()) && StringUtils.isNotBlank(type.getParentId()) && type.getParentId().equals(item.getMiddleTypeId())) {
-                            item.setChildTypeId(type.getId());
-                            item.setChildNo(type.getNo());
-                            item.setTypeId(type.getId());
-                        }*//*
-                    }
-                    mapper.updateByPrimaryKeySelective(BeanConverterUtil.copyObjectProperties(item, SparePartInfo.class));
-                    addItems.add(item);
-                }
-            }
-            if (!CollectionUtils.isEmpty(addItems)) {
-                // mapper.updateBatch(addItems);
-            }
-            return "总计修改:" + addItems.size();
-        } catch (Exception e) {
-            throw new BusinessException(e.getMessage());
-        }*/
+        /*
+         * int addNum = 0;
+         * List<SparePartInfoVO> addItems = new ArrayList<SparePartInfoVO>();
+         * LocalDateTime now = LocalDateTime.now();
+         * try {
+         * List<SparePartInfoVO> items =
+         * CustomExcelImportUtil.importSparePartInfoListForUpdate(file.getInputStream())
+         * ;
+         * if (!CollectionUtils.isEmpty(items)) {
+         * List<SpareType> typeList = spareTypeMapper.selectAll();
+         * for (SparePartInfoVO item : items) {
+         * //先删除当前备件的所有bom,再新增excel导入的bom
+         * SbModelSpareBom bom = new SbModelSpareBom();
+         * bom.setSpareId(item.getId());
+         * sbModelSpareBomMapper.delete(bom);
+         * List<String> sbNos = new ArrayList<>();
+         * if (item.getSbNo()!=null){
+         * sbNos = getSbNos(item.getSbNo());
+         * }
+         * if (sbNos.size()>0) {
+         * Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
+         * WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
+         * weekendCriteria.andIn(SbInfo::getNo, sbNos);
+         * List<SbInfo> sbinfos = sbInfoMapper.selectByExample(weekend);
+         * List<SbModelSpareBom> boms = new ArrayList<>();
+         * for (SbInfo info : sbinfos) {
+         * bom = new SbModelSpareBom();
+         * bom.setSpareId(item.getId());
+         * bom.setSbId(info.getId());
+         * setKey2(bom);
+         * bom.setCreatedTime(LocalDateTime.now());
+         * bom.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
+         * bom.setUpdateTime(LocalDateTime.now());
+         * bom.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
+         * bom.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
+         * bom.setUpdateUserName(SecurityUtils.getUserInfo().getUsername());
+         * boms.add(bom);
+         * }
+         * sbModelSpareBomMapper.insertListforComplex(boms);
+         * }
+         * // 设置类型转换
+         * for (SpareType type : typeList) {
+         * if (type.getName().equals(item.getTypeName())) {
+         * item.setParentTypeId(type.getId());
+         * item.setParentNo(type.getNo());
+         * item.setTypeId(type.getId());
+         * }
+         *//*
+            * if (type.getName().equals(item.getMiddleName()) &&
+            * StringUtils.isNotBlank(type.getParentId()) &&
+            * type.getParentId().equals(item.getParentTypeId())) {
+            * item.setMiddleTypeId(type.getId());
+            * item.setMiddleNo(type.getNo());
+            * item.setTypeId(type.getId());
+            * }
+            * if (type.getName().equals(item.getChildName()) &&
+            * StringUtils.isNotBlank(type.getParentId()) &&
+            * type.getParentId().equals(item.getMiddleTypeId())) {
+            * item.setChildTypeId(type.getId());
+            * item.setChildNo(type.getNo());
+            * item.setTypeId(type.getId());
+            * }
+            *//*
+               * }
+               * mapper.updateByPrimaryKeySelective(BeanConverterUtil.copyObjectProperties(
+               * item, SparePartInfo.class));
+               * addItems.add(item);
+               * }
+               * }
+               * if (!CollectionUtils.isEmpty(addItems)) {
+               * // mapper.updateBatch(addItems);
+               * }
+               * return "总计修改:" + addItems.size();
+               * } catch (Exception e) {
+               * throw new BusinessException(e.getMessage());
+               * }
+               */
     }
 
     @Override
@@ -1537,8 +1575,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
     public void generateQrCodeAll() {
         List<SparePartInfo> list = mapper.selectAll();
         for (SparePartInfo vo : list) {
-            // 保存二维码
-            String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/" + vo.getId() + "/";
+            String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/" + vo.getId()
+                    + "/";
             String rootPath = environment.getProperty("upload.root-dir");
             String filePath = rootPath + path;
             String codePath = path + vo.getId() + ".png";

+ 17 - 9
platform-service/src/main/java/com/platform/service/upms/impl/ScheduleJobServiceImpl.java

@@ -1,8 +1,8 @@
 package com.platform.service.upms.impl;
 
-
 import cn.hutool.core.bean.BeanUtil;
 import com.platform.common.enums.ScheduleStatus;
+import com.platform.common.exception.BusinessException;
 import com.platform.dao.dto.upms.ScheduleJobDTO;
 import com.platform.dao.entity.upms.ScheduleJob;
 import com.platform.dao.mapper.upms.ScheduleJobMapper;
@@ -10,6 +10,7 @@ import com.platform.service.base.impl.BaseServiceImpl;
 import com.platform.service.bean.ScheduleUtils;
 import com.platform.service.upms.ScheduleJobService;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.quartz.CronTrigger;
 import org.quartz.Scheduler;
 import org.springframework.stereotype.Service;
@@ -27,9 +28,11 @@ import java.util.Map;
  * @Date 2019/8/13
  * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
  */
+@Slf4j
 @Service("scheduleJobService")
 @AllArgsConstructor
-public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobMapper, ScheduleJob, ScheduleJobDTO> implements ScheduleJobService {
+public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobMapper, ScheduleJob, ScheduleJobDTO>
+        implements ScheduleJobService {
 
     private final Scheduler scheduler;
 
@@ -40,12 +43,17 @@ public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobMapper, S
     public void init() {
         List<ScheduleJob> scheduleJobList = mapper.selectAll();
         for (ScheduleJob scheduleJob : scheduleJobList) {
-            CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getJobId());
-            //如果不存在,则创建
-            if (cronTrigger == null) {
-                ScheduleUtils.createScheduleJob(scheduler, scheduleJob);
-            } else {
-                ScheduleUtils.updateScheduleJob(scheduler, scheduleJob);
+            try {
+                CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getJobId());
+                if (cronTrigger == null) {
+                    ScheduleUtils.createScheduleJob(scheduler, scheduleJob);
+                } else {
+                    ScheduleUtils.updateScheduleJob(scheduler, scheduleJob);
+                }
+            } catch (Exception e) {
+                log.error("初始化定时任务失败, jobId={}, beanName={}, methodName={}, cronExpression={}, 原因: {}",
+                        scheduleJob.getJobId(), scheduleJob.getBeanName(), scheduleJob.getMethodName(),
+                        scheduleJob.getCronExpression(), e.getMessage(), e);
             }
         }
     }
@@ -89,7 +97,7 @@ public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobMapper, S
         for (Long jobId : jobIds) {
             ScheduleUtils.deleteScheduleJob(scheduler, jobId);
         }
-        //删除数据
+        // 删除数据
         mapper.deleteBatch(jobIds);
     }