zhangherong
10 天以前 b463880866cb946b824e989667ff3f0c0faf22f6
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java
@@ -20,10 +20,8 @@
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog;
import org.jeecg.modules.eam.constant.BusinessCodeConst;
import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum;
import org.jeecg.modules.eam.constant.ThirdMaintenanceStatusEnum;
import org.jeecg.modules.eam.constant.*;
import org.jeecg.modules.eam.entity.EamBaseHFCode;
import org.jeecg.modules.eam.entity.EamEquipment;
import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrder;
import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrderDetail;
@@ -87,6 +85,9 @@
    @Resource
    private IBaseFactoryService baseFactoryService;
    @Resource
    private IEamBaseHFCodeService eamBaseHFCodeService;
    @Override
    public IPage<EamThirdMaintenanceOrder> queryPageList(Page<EamThirdMaintenanceOrder> page, EamThirdMaintenanceQuery query) {
        QueryWrapper<EamThirdMaintenanceOrder> queryWrapper = new QueryWrapper<>();
@@ -148,60 +149,51 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addMaintenance(EamThirdMaintenanceRequest request) {
    public Result<String> addMaintenance(EamThirdMaintenanceRequest request) {
        if (request == null) {
            return Result.error("添加的对象不能为空!");
        }
        if (CollectionUtil.isEmpty(request.getTableDetailList())) {
            return Result.error("保养项不能为空!");
        }
        EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId());
        if (equipment == null) {
            throw new JeecgBootException("设备不存在,添加失败!");
            return Result.error("设备不存在,添加失败!");
        }
        EamThirdMaintenanceOrder order = new EamThirdMaintenanceOrder();
        order.setOrderNum(request.getOrderNum());
        order.setEquipmentId(request.getEquipmentId());
        order.setStandardId(request.getStandardId());
        order.setMaintenanceDate(request.getMaintenanceDate());
        order.setOperator(request.getOperator());
        order.setRemark(request.getRemark());
        //状态初始化
        order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name());
        order.setCreationMethod(request.getCreationMethod());
        //删除标记
        order.setDelFlag(CommonConstant.DEL_FLAG_0);
        //HF码处理  三保移交单HF编码
        EamBaseHFCode hFCodeA = eamBaseHFCodeService.selectByCategory(HfTemplateCategoryEnum.THIRD_MAINTENANCE_HANDOVER.name());
        if (hFCodeA == null) {
            return Result.error("添加失败,未配置三保移交单HF编码!");
        }
        order.setHfCodeA(hFCodeA.getHfCode());
        // 三保验收单HF编码
        EamBaseHFCode hFCodeB = eamBaseHFCodeService.selectByCategory(HfTemplateCategoryEnum.THIRD_MAINTENANCE_ACCEPTANCE.name());
        if (hFCodeB == null) {
            return Result.error("添加失败,未配置三保验收单HF编码!");
        }
        order.setHfCodeB(hFCodeB.getHfCode());
        eamThirdMaintenanceOrderMapper.insert(order);
        //处理明细数据
        if (CollectionUtil.isNotEmpty(request.getTableDetailList())) {
            request.getTableDetailList().forEach(tableDetail -> {
//                tableDetail.setId(null);
                tableDetail.setId(null);
                tableDetail.setOrderId(order.getId());
            });
            thirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList());
        }
        //判断是否存在保养人 如果存在则启动流程
//        if (StringUtils.isNotBlank(order.getOperator())) {
//            //启动流程
//            flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";安装位置" + equipment.getInstallationPosition(),
//                    order.getId(), "IEamThirdMaintenanceOrderService", "third_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);
//            //并行任务会签
//            variables.put("maintenance_execution", Collections.singletonList(request.getOperator()));
////            variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager()));
//            Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables);
//            if (result != null) {
//                //更新设备保养状态
//                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name());
//                return result.isSuccess();
//            }
//        }
        return true;
        return Result.OK("添加成功!");
    }
    @Override
@@ -219,7 +211,6 @@
            throw new JeecgBootException("只有待保养状态的数据才可编辑!");
        }
        entity.setMaintenanceDate(request.getMaintenanceDate());
        entity.setOperator(request.getOperator());
        entity.setRemark(request.getRemark());
        eamThirdMaintenanceOrderMapper.updateById(entity);
@@ -246,32 +237,6 @@
            List<String> ids = request.getRemoveDetailList().stream().map(EamThirdMaintenanceOrderDetail::getId).collect(Collectors.toList());
            thirdMaintenanceOrderDetailService.removeBatchByIds(ids);
        }
        //判断是否存在保养人 如果存在则启动流程
        if (StringUtils.isNotBlank(entity.getOperator())) {
            //启动流程
            flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";安装位置" + equipment.getInstallationPosition(),
                    entity.getId(), "IEamThirdMaintenanceOrderService", "third_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);
            //并行任务会签
            variables.put("maintenance_execution", Collections.singletonList(request.getOperator()));
//            variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager()));
            Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables);
            if (result != null) {
                //更新设备保养状态
                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name());
                return result.isSuccess();
            }
        }
        return true;
    }
@@ -296,7 +261,7 @@
        if (sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) {
            throw new JeecgBootException("不是操作工,无法领取此工单!");
        }
        entity.setOperator(sysUser.getUsername());
        entity.setRepairman(sysUser.getUsername());
        entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
        entity.setActualStartTime(new Date());
        eamThirdMaintenanceOrderMapper.updateById(entity);