Browse Source

refactor(appointment): 优化预约确认订单拒绝流程

- 添加EquipBoilerSchedulingMapper依赖注入用于调度数据管理
- 引入LambdaUpdateWrapper支持动态条件更新操作
- 使用@Lazy注解延迟加载装备调度映射器实例
- 实现设备状态恢复逻辑根据检查类型重置对应标识
- 添加调度记录清理功能当关联项目为空时删除调度数据
- 重构管道设备拒绝流程中的状态更新机制
- 移除过时的年度拒绝项目处理代码块
xuzhancheng 1 tuần trước cách đây
mục cha
commit
6bb4fbce74

+ 29 - 57
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/service/appointmentconfirmorder/AppointmentConfirmOrderServiceImpl.java

@@ -23,6 +23,7 @@ import cn.start.tz.module.member.api.templatesendlog.dto.TemplateSendLogDto;
 import cn.start.tz.module.member.api.templatesendlog.dto.TemplateSendLogRespDto;
 import cn.start.tz.module.pressure2.controller.admin.boilerorderexception.vo.BoilerOrderExceptionSaveReqVO;
 import cn.start.tz.module.pressure2.dal.dataobject.acceptorder.AcceptOrderDO;
+import cn.start.tz.module.pressure2.dal.mysql.equipboilerscheduling.EquipBoilerSchedulingMapper;
 import cn.start.tz.module.pressure2.enums.RedisKeyEnums;
 import cn.start.tz.module.pressure2.controller.admin.appointmentconfirmorder.vo.*;
 import cn.start.tz.module.pressure2.controller.app.appointmentconfirmorder.vo.AppAppointmentRefuseVO;
@@ -68,11 +69,13 @@ import cn.start.tz.module.system.api.dict.dto.DictDataRespDTO;
 import cn.start.tz.module.system.api.orgcontact.OrgContactApi;
 import cn.start.tz.module.system.api.user.AdminUserApi;
 import cn.start.tz.module.system.api.user.dto.AdminUserRespDTO;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
@@ -180,6 +183,10 @@ public class AppointmentConfirmOrderServiceImpl implements AppointmentConfirmOrd
     @Resource
     private OrderReportService orderReportService;
 
+    @Resource
+    @Lazy
+    private EquipBoilerSchedulingMapper equipBoilerSchedulingMapper;
+
     @Override
     public String create(AppointmentConfirmOrderDO appointmentConfirmOrderDO) {
 
@@ -577,6 +584,28 @@ public class AppointmentConfirmOrderServiceImpl implements AppointmentConfirmOrd
                     eq(EquipBoilerSchedulingItemDO::getSchedulingId, appointmentConfirmOrderDO.getSchedulingId()).
                     in(EquipBoilerSchedulingItemDO::getEquipId, appointmentRefuseVO.getEquipIds())
             );
+            Long count = equipBoilerSchedulingItemMapper.selectCount(EquipBoilerSchedulingItemDO::getSchedulingId, appointmentConfirmOrderDO.getSchedulingId());
+            if (count == null || count == 0) {
+                equipBoilerSchedulingMapper.deleteById(appointmentConfirmOrderDO.getSchedulingId());
+            }
+
+            // 恢复设备状态
+            if (appointmentConfirmOrderDO.getCheckType() == 100){
+                equipBoilerMapper.update(new LambdaUpdateWrapper<EquipBoilerDO>().
+                        in(EquipBoilerDO::getId, appointmentRefuseVO.getEquipIds()).
+                        set(EquipBoilerDO::getHasInternal, false)
+                );
+            }else if (appointmentConfirmOrderDO.getCheckType() == 200){
+                equipBoilerMapper.update(new LambdaUpdateWrapper<EquipBoilerDO>().
+                        in(EquipBoilerDO::getId, appointmentRefuseVO.getEquipIds()).
+                        set(EquipBoilerDO::getHasExternal, false)
+                );
+            }else if (appointmentConfirmOrderDO.getCheckType() == 300){
+                equipBoilerMapper.update(new LambdaUpdateWrapper<EquipBoilerDO>().
+                        in(EquipBoilerDO::getId, appointmentRefuseVO.getEquipIds()).
+                        set(EquipBoilerDO::getHasPressure, false)
+                );
+            }
 
         }
         if (300 == appointmentRefuseVO.getType()) {
@@ -602,63 +631,6 @@ public class AppointmentConfirmOrderServiceImpl implements AppointmentConfirmOrd
             return;
         }
         // 拒绝检验
-/*        if(200 == appointmentRefuseVO.getType()){
-
-            List<AppointmentConfirmRefuseYearItemDO> list = equipContainerDOS.stream().map(item -> {
-                AppointmentConfirmRefuseYearItemDO appointmentConfirmOrderRefuseItemDO = new AppointmentConfirmRefuseYearItemDO();
-                appointmentConfirmOrderRefuseItemDO.setOrderId(appointmentRefuseVO.getOrderId());
-                appointmentConfirmOrderRefuseItemDO.setEquipId(item.getId());
-                if (appointmentRefuseVO.getCheckType() == 100 && item.getNextInCheckDate() != null) {
-                    appointmentConfirmOrderRefuseItemDO.setNextCheckDate(LocalDate.from(item.getNextInCheckDate()));
-                }
-                if (appointmentRefuseVO.getCheckType() == 200 && item.getNextOutCheckDate() != null) {
-                    appointmentConfirmOrderRefuseItemDO.setNextCheckDate(LocalDate.from(item.getNextOutCheckDate()));
-                }
-                if (appointmentRefuseVO.getCheckType() == 300 && item.getNextPressureCheckDate() != null) {
-                    appointmentConfirmOrderRefuseItemDO.setNextCheckDate(LocalDate.from(item.getNextPressureCheckDate()));
-                }
-                appointmentConfirmOrderRefuseItemDO.setUnitCode(item.getUnitCode());
-                appointmentConfirmOrderRefuseItemDO.setUnitName(item.getUnitName());
-                appointmentConfirmOrderRefuseItemDO.setCheckType(appointmentRefuseVO.getCheckType());
-                appointmentConfirmOrderRefuseItemDO.setOrderNo(appointmentRefuseVO.getOrderNo());
-                appointmentConfirmOrderRefuseItemDO.setSubmitId(getLoginUserId());
-                appointmentConfirmOrderRefuseItemDO.setSubmitTime(LocalDateTime.now());
-                appointmentConfirmOrderRefuseItemDO.setReasonDict(appointmentRefuseVO.getReasonDict());
-                //appointmentConfirmOrderRefuseItemDO.setBeDistrict(item.getBeDistrict());
-                //appointmentConfirmOrderRefuseItemDO.setEquipType(item.getEquipType());
-
-                if (appointmentConfirmOrderDO != null) {
-                    appointmentConfirmOrderRefuseItemDO.setCheckDate(appointmentConfirmOrderDO.getAppointmentDate());
-                    appointmentConfirmOrderRefuseItemDO.setOrderNo(appointmentConfirmOrderDO.getAppointmentNo());
-                }
-
-                appointmentConfirmOrderRefuseItemDO.setReason(appointmentRefuseVO.getReason());
-                return appointmentConfirmOrderRefuseItemDO;
-            }).toList();
-
-            appointmentConfirmRefuseYearItemMapper.insert(list);
-
-            appointmentConfirmOrderItemMapper.delete(new LambdaQueryWrapperX<BoilerAppointmentConfirmOrderItemDO>().
-                    eq(BoilerAppointmentConfirmOrderItemDO::getOrderId, appointmentRefuseVO.getOrderId()).
-                    in(BoilerAppointmentConfirmOrderItemDO::getEquipId, appointmentRefuseVO.getEquipIds())
-            );
-
-            if (StringUtils.isNotBlank(appointmentRefuseVO.getOrderId())) {
-                Long count = appointmentConfirmOrderItemMapper.selectCount(BoilerAppointmentConfirmOrderItemDO::getOrderId, appointmentRefuseVO.getOrderId());
-                AppointmentConfirmOrderDO updateOrder = new AppointmentConfirmOrderDO();
-                updateOrder.setId(appointmentRefuseVO.getOrderId());
-                if (count == null || count == 0) {
-                    updateOrder.setStatus(500);
-                    updateOrder.setEquipNumBoiler(0);
-                }
-                if (count != null){
-                    updateOrder.setEquipNumBoiler(Math.toIntExact(count));
-                }
-                appointmentConfirmOrderMapper.updateById(updateOrder);
-            }
-
-            return ;
-        }*/
 
         Map<String, Object> processInstanceVariables = new HashMap<>();
 

+ 13 - 0
tz-module-pressure2/tz-module-pressure2-biz/src/main/java/cn/start/tz/module/pressure2/service/appointmentconfirmorder/PipeAppointmentConfirmOrderServiceImpl.java

@@ -90,6 +90,7 @@ import cn.start.tz.module.system.api.orgcontact.OrgContactApi;
 import cn.start.tz.module.system.api.orgcontact.dto.OrgContactDTO;
 import cn.start.tz.module.system.api.user.AdminUserApi;
 import cn.start.tz.module.system.api.user.dto.AdminUserRespDTO;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -633,6 +634,18 @@ public class PipeAppointmentConfirmOrderServiceImpl implements PipeAppointmentCo
                 equipPipeSchedulingMapper.deleteById(appointmentConfirmOrderDO.getSchedulingId());
             }
 
+            if (appointmentConfirmOrderDO.getCheckType() == 100) {
+                equipPipeDetailMapper.update(new LambdaUpdateWrapper<EquipPipeDetailDO>().
+                        in(EquipPipeDetailDO::getId, equipDetailIds).
+                        set(EquipPipeDetailDO::getHasLegalScheduling, false)
+                );
+            } else if (appointmentConfirmOrderDO.getCheckType() == 200) {
+                equipPipeDetailMapper.update(new LambdaUpdateWrapper<EquipPipeDetailDO>().
+                        in(EquipPipeDetailDO::getId, equipDetailIds).
+                        set(EquipPipeDetailDO::getHasYearScheduling, false)
+                );
+            }
+
         }
 
         if (300 == appointmentRefuseVO.getType()) {