zhangherong
2025-05-20 bb957f15fa76b5eac4de84bbef2b5d95c900df38
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java
@@ -1,6 +1,7 @@
package org.jeecg.modules.eam.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -8,12 +9,14 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.flowable.engine.TaskService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.DataBaseConstant;
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.BusinessCodeConst;
import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
import org.jeecg.modules.eam.constant.SecondMaintenanceStatusEnum;
import org.jeecg.modules.eam.entity.EamEquipment;
import org.jeecg.modules.eam.entity.EamSecondMaintenanceOrder;
@@ -22,7 +25,9 @@
import org.jeecg.modules.eam.request.EamSecondMaintenanceQuery;
import org.jeecg.modules.eam.request.EamSecondMaintenanceRequest;
import org.jeecg.modules.eam.service.*;
import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService;
import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI;
import org.jeecg.modules.flowable.apithird.service.FlowCommonService;
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
import org.jeecg.modules.flowable.service.IFlowTaskService;
@@ -32,10 +37,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -44,8 +46,8 @@
 * @Date:   2025-04-29
 * @Version: V1.0
 */
@Service
public class EamSecondMaintenanceOrderServiceImpl extends ServiceImpl<EamSecondMaintenanceOrderMapper, EamSecondMaintenanceOrder> implements IEamSecondMaintenanceOrderService {
@Service("IEamSecondMaintenanceOrderService")
public class EamSecondMaintenanceOrderServiceImpl extends ServiceImpl<EamSecondMaintenanceOrderMapper, EamSecondMaintenanceOrder> implements IEamSecondMaintenanceOrderService, FlowCallBackServiceI {
    @Resource
    private EamSecondMaintenanceOrderMapper eamSecondMaintenanceOrderMapper;
    @Autowired
@@ -152,32 +154,32 @@
        }
        //判断是否存在保养人 如果存在则启动流程
        if (StringUtils.isNotBlank(order.getOperator())) {
            //启动流程 TODO
//            flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备二保",
//                    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);
//                //更新设备保养状态
//                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
//                return result.isSuccess();
//            }
            //启动流程
            flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备二保",
                    order.getId(), "IEamSecondMaintenanceOrderService", "second_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("second_maintenance_process", variables);
            if (result != null) {
                //更新周保状态
                order.setMaintenanceStatus(SecondMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
                order.setActualStartTime(new Date());
                eamSecondMaintenanceOrderMapper.updateById(order);
                //更新设备保养状态
                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name());
                return result.isSuccess();
            }
        }
        return true;
@@ -227,32 +229,32 @@
        }
        //判断是否存在保养人 如果存在则启动流程
        if (StringUtils.isNotBlank(entity.getOperator())) {
            //启动流程 TODO
//            flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备周保",
//                    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);
//                //更新设备保养状态
//                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
//                return result.isSuccess();
//            }
            //启动流程
            flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备二保",
                    entity.getId(), "IEamSecondMaintenanceOrderService", "second_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("second_maintenance_process", variables);
            if (result != null) {
                //更新周保状态
                entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
                entity.setActualStartTime(new Date());
                eamSecondMaintenanceOrderMapper.updateById(entity);
                //更新设备保养状态
                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name());
                return result.isSuccess();
            }
        }
        return true;
@@ -281,28 +283,53 @@
        entity.setActualStartTime(new Date());
        eamSecondMaintenanceOrderMapper.updateById(entity);
//        //启动流程
//        flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备周保",
//                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) {
//            //更新设备保养状态
//            eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
//            return result.isSuccess();
//        }
        //启动流程
        flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备二保",
                entity.getId(), "IEamSecondMaintenanceOrderService", "second_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("second_maintenance_process", variables);
        if (result != null) {
            //更新设备保养状态
            eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name());
            return result.isSuccess();
        }
        return true;
    }
    @Override
    public void afterFlowHandle(FlowMyBusiness business) {
        business.getTaskNameId();//接下来审批的节点
        business.getValues();//前端传进来的参数
        business.getActStatus();
    }
    @Override
    public Object getBusinessDataById(String dataId) {
        return this.getById(dataId);
    }
    @Override
    public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) {
        return null;
    }
    @Override
    public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) {
        //业务是否干预流程,业务干预,流程干预,指定人员进行处理
        //获取下一步处理人
        Object object = values.get("NextAssignee");
        return (List<String>) object;
    }
}