zhangherong
2025-04-10 2894c312ad787d1c22d4a4a9c5cc061d87d759ec
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java
@@ -14,7 +14,7 @@
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.constant.MaintenanceStatusEnum;
import org.jeecg.modules.eam.constant.WeekMaintenanceStatusEnum;
import org.jeecg.modules.eam.constant.OrderCreationMethodEnum;
import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder;
import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail;
@@ -66,7 +66,7 @@
        order.setOperator(request.getOperator());
        order.setRemark(request.getRemark());
        //状态初始化
        order.setMaintenanceStatus(MaintenanceStatusEnum.WAIT_MAINTENANCE.name());
        order.setMaintenanceStatus(WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name());
        order.setCreationMethod(OrderCreationMethodEnum.MANUAL.name());
        //删除标记
        order.setDelFlag(CommonConstant.DEL_FLAG_0);
@@ -80,7 +80,33 @@
            eamWeekMaintenanceOrderDetailService.saveBatch(request.getTableDetailList());
        }
        //判断是否存在保养人 如果存在则启动流程
        //TODO
        if(StringUtils.isNotBlank(order.getOperator())) {
            //启动流程
            flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";开始进行设备周保",
                    order.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
            Map<String, Object> variables = new HashMap<>();
            variables.put("dataId", order.getId());
            if (StrUtil.isEmpty(order.getRemark())) {
                variables.put("organization", "新增周保工单默认启动流程");
                variables.put("comment", "新增周保工单默认启动流程");
            } else {
                variables.put("organization", order.getRemark());
                variables.put("comment", order.getRemark());
            }
            variables.put("proofreading", true);
            List<String> usernames = new ArrayList<>();
            usernames.add(order.getOperator());
            variables.put("NextAssignee", usernames);
            Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables);
            if(result != null){
                //更新周保状态
                order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
                order.setActualStartTime(new Date());
                eamWeekMaintenanceOrderMapper.updateById(order);
                return result.isSuccess();
            }
        }
        return true;
    }
@@ -142,7 +168,7 @@
        if(entity == null){
            throw new JeecgBootException("编辑的数据已删除,请刷新重试!");
        }
        if(!MaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())){
        if(!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())){
            throw new JeecgBootException("只有待保养状态的数据才可编辑!");
        }
        entity.setMaintenanceDate(request.getMaintenanceDate());
@@ -174,7 +200,32 @@
            eamWeekMaintenanceOrderDetailService.removeBatchByIds(ids);
        }
        //判断是否存在保养人 如果存在则启动流程
        //TODO
        if(StringUtils.isNotBlank(entity.getOperator())) {
            //启动流程
            flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";开始进行设备周保",
                    entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
            Map<String, Object> variables = new HashMap<>();
            variables.put("dataId", entity.getId());
            if (StrUtil.isEmpty(entity.getRemark())) {
                variables.put("organization", "新增周保工单默认启动流程");
                variables.put("comment", "新增周保工单默认启动流程");
            } else {
                variables.put("organization", entity.getRemark());
                variables.put("comment", entity.getRemark());
            }
            variables.put("proofreading", true);
            List<String> usernames = new ArrayList<>();
            usernames.add(entity.getOperator());
            variables.put("NextAssignee", usernames);
            Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables);
            if(result != null){
                //更新周保状态
                entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
                entity.setActualStartTime(new Date());
                eamWeekMaintenanceOrderMapper.updateById(entity);
                return result.isSuccess();
            }
        }
        return true;
    }
@@ -185,12 +236,13 @@
        if(entity == null) {
            throw new JeecgBootException("要领取的工单不存在,请刷新重试!");
        }
        if(!MaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
        if(!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
            throw new JeecgBootException("该工单已进行过领取!");
        }
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        entity.setOperator(sysUser.getUsername());
        entity.setMaintenanceStatus(MaintenanceStatusEnum.UNDER_MAINTENANCE.name());
        entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
        entity.setActualStartTime(new Date());
        eamWeekMaintenanceOrderMapper.updateById(entity);
        //启动流程