lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java
@@ -9,6 +9,7 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.flowable.engine.TaskService;
@@ -18,6 +19,7 @@
import org.jeecg.common.constant.DataBaseConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog;
import org.jeecg.modules.eam.constant.*;
@@ -50,6 +52,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -61,12 +64,12 @@
 * @Version: V1.0
 */
@Service("IEamSecondMaintenanceOrderService")
@Slf4j
public class EamSecondMaintenanceOrderServiceImpl extends ServiceImpl<EamSecondMaintenanceOrderMapper, EamSecondMaintenanceOrder> implements IEamSecondMaintenanceOrderService, FlowCallBackServiceI {
    @Resource
    private EamSecondMaintenanceOrderMapper eamSecondMaintenanceOrderMapper;
    @Autowired
    private IEamSecondMaintenanceOrderDetailService secondMaintenanceOrderDetailService;
    @Autowired
    private FlowCommonService flowCommonService;
    @Autowired
@@ -97,6 +100,10 @@
    private BaseFactoryMapper baseFactoryMapper;
    @Autowired
    private IEamSecondMaintenanceOrderDetailService eamSecondMaintenanceOrderDetailService;
    @Autowired
    private EamSecondMaintenanceOrderAsyncService eamSecondMaintenanceOrderAsyncService;
    @Autowired
    private IEamFactorySecondMaintPlanService factorySecondMaintPlanService;
    @Override
    public IPage<EamSecondMaintenanceOrder> queryPageList(Page<EamSecondMaintenanceOrder> page, EamSecondMaintenanceQuery query) {
@@ -340,6 +347,11 @@
            });
            secondMaintenanceOrderDetailService.saveBatch(requestTableDetailList);
        }
        // 插入首页二保养计划
        // 使用 SimpleDateFormat 直接格式化为“yyyy年MM月”格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
        String formattedDate = sdf.format(order.getMaintenanceDate());
        factorySecondMaintPlanService.add(order.getEquipmentId(), formattedDate);
        return true;
    }
@@ -357,9 +369,14 @@
        if (!SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
            throw new JeecgBootException("只有待保养状态的数据才可编辑!");
        }
        // 编辑首页二保养计划
        // 使用 SimpleDateFormat 直接格式化为“yyyy年MM月”格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
        String oldFormattedDate = sdf.format(entity.getMaintenanceDate());
        String newFormattedDate = sdf.format(request.getMaintenanceDate());
        factorySecondMaintPlanService.dateChange(entity.getEquipmentId(), oldFormattedDate,newFormattedDate);
        entity.setMaintenanceDate(request.getMaintenanceDate());
        entity.setRemark(request.getRemark());
        eamSecondMaintenanceOrderMapper.updateById(entity);
        //判断是否存在保养人 如果存在则启动流程
        if (StringUtils.isNotBlank(entity.getOperator())) {
@@ -389,7 +406,6 @@
                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name());
                return result.isSuccess();
            }
        }
        return true;
    }
@@ -665,6 +681,15 @@
        }
        //保存工单
        eamSecondMaintenanceOrderMapper.updateById(entity);
        //异步生成下次二保工单
        if (SecondMaintenanceStatusEnum.COMPLETE.name().equals(entity.getMaintenanceStatus())) {
            try {
                eamSecondMaintenanceOrderAsyncService.asyncGenerateNextMaintenanceOrder(entity.getId());
            } catch (Exception e) {
                log.error("触发异步生成下次工单失败,工单ID: {}", entity.getId(), e);
            }
        }
        return entity;
    }