From 0a19d4923b0a048aee0cda91c37f25bc6e140d54 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期三, 16 七月 2025 21:01:24 +0800 Subject: [PATCH] 修改接收字段 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java | 499 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 318 insertions(+), 181 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java index 6121b18..f7f3eaf 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java @@ -3,32 +3,31 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.flowable.engine.TaskService; import org.flowable.task.api.Task; -import org.jeecg.common.api.vo.FileUploadResult; 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.StrUtils; 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; import org.jeecg.modules.eam.mapper.EamThirdMaintenanceOrderMapper; +import org.jeecg.modules.eam.request.EamInspectionOrderRequest; import org.jeecg.modules.eam.request.EamThirdMaintenanceQuery; import org.jeecg.modules.eam.request.EamThirdMaintenanceRequest; import org.jeecg.modules.eam.service.*; @@ -38,8 +37,13 @@ import org.jeecg.modules.flowable.apithird.service.FlowCommonService; import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; +import org.jeecg.modules.system.entity.BaseFactory; +import org.jeecg.modules.system.entity.BaseFactoryUser; +import org.jeecg.modules.system.service.IBaseFactoryService; +import org.jeecg.modules.system.service.IBaseFactoryUserService; import org.jeecg.modules.system.service.ISysUserService; import org.jeecg.modules.system.vo.UserSelector; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -76,11 +80,17 @@ @Autowired private IEamEquipmentService eamEquipmentService; @Autowired - private IEamReportRepairService eamReportRepairService; - @Autowired private IEamEquipmentExtendService eamEquipmentExtendService; - @Autowired - private IEamPrecisionCheckDetailService precisionCheckDetailService; + + @Resource + private IBaseFactoryUserService baseFactoryUserService; + @Resource + private IBaseFactoryService baseFactoryService; + + @Resource + private IEamBaseHFCodeService eamBaseHFCodeService; + @Resource + private IEamThirdMaintenanceOrderDetailService eamThirdMaintenanceOrderDetailService; @Override public IPage<EamThirdMaintenanceOrder> queryPageList(Page<EamThirdMaintenanceOrder> page, EamThirdMaintenanceQuery query) { @@ -95,8 +105,16 @@ List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); queryWrapper.in("e.equipment_code", equipArr); } else { - //娌℃湁閫夋嫨璁惧锛屾牴鎹溅闂磋繃婊よ澶� - queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); + //娌℃湁閫夋嫨璁惧锛屾牴鎹腑蹇冭繃婊よ澶� + List<BaseFactoryUser> baseFactoryUserList = baseFactoryUserService. + list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId, sysUser.getId())); + if (!CollectionUtils.isEmpty(baseFactoryUserList)) { + Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet()); + Set<String> factoryCode = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet()); + queryWrapper.in("e.factory_org_code", factoryCode); + } else { + return page; + } } //鏌ヨ鏉′欢杩囨护 if (query != null) { @@ -135,23 +153,40 @@ @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鐮佸鐞� 涓変繚绉讳氦鍗旽F缂栫爜 + EamBaseHFCode hFCodeA = eamBaseHFCodeService.selectByCategory(HfTemplateCategoryEnum.THIRD_MAINTENANCE_HANDOVER.name()); + if (hFCodeA == null) { + return Result.error("娣诲姞澶辫触,鏈厤缃笁淇濈Щ浜ゅ崟HF缂栫爜锛�"); + } + order.setHfCodeA(hFCodeA.getHfCode()); + // 涓変繚楠屾敹鍗旽F缂栫爜 + 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())) { @@ -161,41 +196,8 @@ }); thirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); } - //澶勭悊绮惧害鍙傛暟 - if (CollectionUtil.isNotEmpty(request.getPrecisionDetailList())) { - request.getPrecisionDetailList().forEach(tableDetail -> { - tableDetail.setId(null); - tableDetail.setOrderId(order.getId()); - }); - precisionCheckDetailService.saveBatch(request.getPrecisionDetailList()); - } - //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋� - 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 @@ -213,7 +215,6 @@ throw new JeecgBootException("鍙湁寰呬繚鍏荤姸鎬佺殑鏁版嵁鎵嶅彲缂栬緫锛�"); } entity.setMaintenanceDate(request.getMaintenanceDate()); - entity.setOperator(request.getOperator()); entity.setRemark(request.getRemark()); eamThirdMaintenanceOrderMapper.updateById(entity); @@ -240,32 +241,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; } @@ -283,24 +258,19 @@ if (equipment == null) { throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�"); } - if (StringUtils.isBlank(equipment.getEquipmentManager())) { - throw new JeecgBootException("璁惧鏈垎閰嶈澶囩鐞嗗憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); - } LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - if (sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { - throw new JeecgBootException("涓嶆槸鎿嶄綔宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒"); + if (sysUser == null || !BusinessCodeConst.PCR0002.equals(sysUser.getPost())) { + throw new JeecgBootException("涓嶆槸缁翠慨宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒"); } - entity.setOperator(sysUser.getUsername()); - entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); + entity.setRepairman(sysUser.getUsername()); + entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_CHECK.name()); entity.setActualStartTime(new Date()); eamThirdMaintenanceOrderMapper.updateById(entity); //鍚姩娴佺▼ - flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆" + equipment.getInstallationPosition(), + flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + (equipment.getInstallationPosition() == null ? "" : ";瀹夎浣嶇疆: " + equipment.getInstallationPosition()), entity.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); Map<String, Object> variables = new HashMap<>(); - boolean equipmentPrecisionFlag = precisionCheckDetailService.hasPrecisionCheckDetail(entity.getId()); - variables.put("equipmentPrecisionFlag", equipmentPrecisionFlag); variables.put("dataId", entity.getId()); if (StrUtil.isEmpty(entity.getRemark())) { variables.put("organization", "鏂板涓変繚宸ュ崟榛樿鍚姩娴佺▼"); @@ -310,9 +280,10 @@ variables.put("comment", entity.getRemark()); } variables.put("proofreading", true); - //骞惰浠诲姟浼氱 - variables.put("maintenance_execution", Collections.singletonList(sysUser.getUsername())); - variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); + // 璁剧疆涓嬩竴姝ュ鐞嗕汉 + List<String> usernames = new ArrayList<>(); + usernames.add(entity.getRepairman()); + variables.put("NextAssignee", usernames); Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); if (result != null) { //鏇存柊璁惧淇濆吇鐘舵�� @@ -325,25 +296,24 @@ @Override @Transactional(rollbackFor = Exception.class) @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.THIRD_MAINTENANCE, businessTable = "eam_third_maintenance_order") - public EamThirdMaintenanceOrder approval(EamThirdMaintenanceRequest request) { - EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderMapper.selectById(request.getId()); - if (entity == null) { - throw new JeecgBootException("瀹℃壒鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�"); + public EamThirdMaintenanceOrder approval(EamThirdMaintenanceRequest eamThirdMaintenanceRequest) { + EamThirdMaintenanceOrder eamThirdMaintenanceOrder = eamThirdMaintenanceOrderMapper.selectById(eamThirdMaintenanceRequest.getId()); + if (eamThirdMaintenanceOrder == null) { + throw new JeecgBootException("寰呭鐞嗙殑鏁版嵁宸插垹闄わ紝璇峰埛鏂伴噸璇曪紒"); } // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛 LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); if (user == null || StrUtil.isBlank(user.getId())) { throw new JeecgBootException("鏈幏鍙栧埌鐧诲綍鐢ㄦ埛锛岃閲嶆柊鐧诲綍鍚庡啀璇曪紒"); } - request.setAssignee(user.getUsername()); + eamThirdMaintenanceRequest.setAssignee(user.getUsername()); // 鑾峰彇娴佺▼涓氬姟璁板綍 - FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId(), request.getTaskId()); + FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(eamThirdMaintenanceRequest.getInstanceId(), eamThirdMaintenanceRequest.getTaskId()); if (flowMyBusiness == null) { throw new JeecgBootException("娴佺▼瀹炰緥涓嶅瓨鍦紝璇峰埛鏂板悗閲嶈瘯锛�"); } - boolean userAuthorized = isUserAuthorized(flowMyBusiness, user); - if (!userAuthorized) { + if (!isUserAuthorized(flowMyBusiness, user)) { throw new JeecgBootException("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔★紝璇峰埛鏂板悗閲嶈瘯锛�"); } // 璁ら浠诲姟 @@ -351,118 +321,285 @@ throw new JeecgBootException("浠诲姟涓嶅瓨鍦ㄣ�佸凡瀹屾垚鎴栧凡琚粬浜鸿棰嗭紒"); } - EamEquipment equipment = eamEquipmentService.getById(entity.getEquipmentId()); + EamEquipment equipment = eamEquipmentService.getById(eamThirdMaintenanceOrder.getEquipmentId()); if (equipment == null) { throw new JeecgBootException("璁惧涓嶅瓨鍦紝璇锋鏌ワ紒"); } - ThirdMaintenanceStatusEnum status = ThirdMaintenanceStatusEnum.getInstance(entity.getMaintenanceStatus()); - if (status == null) { - return null; - } + // 璁剧疆娴佺▼鍙橀噺 + setupProcessVariables(eamThirdMaintenanceRequest, eamThirdMaintenanceOrder, user, equipment); + + // 瀹屾垚娴佺▼浠诲姟 + Result result = flowTaskService.complete(eamThirdMaintenanceRequest); + + // 鏍规嵁浠诲姟瀹屾垚缁撴灉鏇存柊宸ュ崟鐘舵�� + updateOrderStatus(result, eamThirdMaintenanceRequest, eamThirdMaintenanceOrder, user); + + //鏇存柊宸ュ崟淇℃伅 + eamThirdMaintenanceOrderMapper.updateById(eamThirdMaintenanceOrder); + return eamThirdMaintenanceOrder; + } + + /** + * 鏌ヨ涓変繚宸ュ崟鍩烘湰淇℃伅 + * @param id + * @return + */ + @Override + public Result<?> selectVoById(String id) { + List<EamThirdMaintenanceOrder> eamThirdMaintenanceOrders = this.list(new QueryWrapper<EamThirdMaintenanceOrder>().eq("id", id)); + List<EamThirdMaintenanceRequest> eamThirdMaintenanceRequestList = new ArrayList<>(); + eamThirdMaintenanceOrders.forEach(eamThirdMaintenanceOrder -> { + EamThirdMaintenanceRequest eamThirdMaintenanceRequest = new EamThirdMaintenanceRequest(); + BeanUtils.copyProperties(eamThirdMaintenanceOrder, eamThirdMaintenanceRequest); + List<EamThirdMaintenanceOrderDetail> eamThirdMaintenanceOrderDetails = eamThirdMaintenanceOrderDetailService + .list(new QueryWrapper<EamThirdMaintenanceOrderDetail>().eq("order_id", eamThirdMaintenanceOrder.getId())); + eamThirdMaintenanceRequest.setTableDetailList(eamThirdMaintenanceOrderDetails); + eamThirdMaintenanceRequestList.add(eamThirdMaintenanceRequest); + }); + return Result.ok(eamThirdMaintenanceRequestList); + } + + /** + * 璁剧疆娴佺▼鍙橀噺 + */ + private void setupProcessVariables(EamThirdMaintenanceRequest request, EamThirdMaintenanceOrder order, LoginUser user, EamEquipment equipment) { //娴佺▼鍙橀噺 Map<String, Object> values = new HashMap<>(); List<String> userApprovalList; List<UserSelector> userSelectors; + ThirdMaintenanceStatusEnum status = ThirdMaintenanceStatusEnum.getInstance(order.getMaintenanceStatus()); switch (status) { + case WAIT_CHECK: + // 鎶�鏈姸鎬侀壌瀹氱粨鏉� + values.put("dataId", order.getId()); + values.put("organization", "鎶�鏈姸鎬侀壌瀹氱粨鏉�"); + values.put("comment", "鎶�鏈姸鎬侀壌瀹氱粨鏉�"); + if (CommonConstant.YN_1.equals(request.getFullyFunctional()) && CommonConstant.YN_1.equals(request.getRunningNormally())) { + values.put("confirmation", "1"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨宸ワ紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + } + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("NextAssignee", userApprovalList); + //鏇存柊璁惧淇濆吇鐘舵�� + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name()); + } else { + values.put("confirmation", "2"); + } + request.setComment("妫�鏌ヤ汉妫�鏌ョ粨鏉�"); + break; case UNDER_MAINTENANCE: - boolean parallelCompletion = flowTaskService.checkParallelCompletion(flowMyBusiness.getTaskId()); - //鎵ц瀹屾垚 - userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0006); + // 淇濆吇缁撴潫 + values.put("dataId", order.getId()); + values.put("organization", "淇濆吇浜轰繚鍏荤粨鏉�"); + values.put("comment", "淇濆吇浜轰繚鍏荤粨鏉�"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); if (CollectionUtil.isEmpty(userSelectors)) { - throw new JeecgBootException("璁惧鏈垎閰嶇粰杞﹂棿鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨宸ワ紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); } userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); - values.put("dataId", entity.getId()); - values.put("organization", "涓変繚鎵ц缁撴潫"); - values.put("comment", "涓変繚鎵ц缁撴潫"); - if (parallelCompletion) { - values.put("NextAssignee", userApprovalList); - } - request.setComment("涓変繚鎵ц缁撴潫"); - //璁剧疆entity - if (parallelCompletion) { - entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_CONFIRM.name()); - entity.setActualEndTime(new Date()); - } - if ("maintenance_execution".equals(flowMyBusiness.getTaskNameId())) { - //鎵ц淇濆吇 - //澶勭悊闄勪欢 - if (CollectionUtil.isNotEmpty(request.getImageFilesResult())) { - List<FileUploadResult> fileUploadResultList = request.getImageFilesResult(); - ObjectMapper mapper = new ObjectMapper(); - try { - String referenceFile = mapper.writeValueAsString(fileUploadResultList); - entity.setImageFiles(referenceFile); - } catch (JsonProcessingException e) { - log.error("JSON杞崲澶辫触锛�" + e.getMessage(), e); + values.put("NextAssignee", userApprovalList); + request.setComment("淇濆吇浜轰繚鍏荤粨鏉�"); + //鏇存柊璁惧淇濆吇鐘舵�� + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name()); + break; + case UNDER_FIRST_ACCEPTANCE: + // 绗竴娆¢獙鏀剁粨鏉� + values.put("dataId", order.getId()); + values.put("organization", "绗竴娆¢獙鏀剁粨鏉�"); + values.put("comment", "绗竴娆¢獙鏀剁粨鏉�"); + boolean flag = false; + if (!CollectionUtil.isEmpty(request.getTableDetailList())) { + for (EamThirdMaintenanceOrderDetail eamThirdMaintenanceOrderDetail : request.getTableDetailList()) { + if ("2".equals(eamThirdMaintenanceOrderDetail.getFirstInspectResult())) { + flag = true; + break; } } - //澶勭悊璇︽儏 - if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { - thirdMaintenanceOrderDetailService.updateBatchById(request.getTableDetailList()); - } - } else if ("precision_check".equals(flowMyBusiness.getTaskNameId())) { - entity.setPrecisionChecker(user.getUsername()); - entity.setPrecisionCheckTime(new Date()); - //澶勭悊绮惧害妫�楠� - if (CollectionUtil.isNotEmpty(request.getPrecisionDetailList())) { - precisionCheckDetailService.updateBatchById(request.getPrecisionDetailList()); - } } - if (parallelCompletion) { - //鏇存柊璁惧淇濆吇鐘舵�� - eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name()); + if (flag) { + // 寮�鍚浜屾楠屾敹 + values.put("confirmation", "2"); + List<String> usernames = new ArrayList<>(); + usernames.add(user.getUsername()); + values.put("NextAssignee", usernames); + } else { + // 娴佺▼娴佽浆鍒版搷浣滀汉绛惧瓧 + values.put("confirmation", "1"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0001); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰鎿嶄綔宸ワ紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + } + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("NextAssignee", userApprovalList); } + request.setComment("绗竴娆¢獙鏀剁粨鏉�"); break; - case WAIT_CONFIRM: - userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0003); + case UNDER_SECOND_ACCEPTANCE: + // 绗簩娆¢獙鏀剁粨鏉� + values.put("dataId", order.getId()); + values.put("organization", "绗簩娆¢獙鏀剁粨鏉�"); + values.put("comment", "绗簩娆¢獙鏀剁粨鏉�"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0001); if (CollectionUtil.isEmpty(userSelectors)) { - throw new JeecgBootException("璁惧鏈垎閰嶇粰杞﹂棿鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + throw new JeecgBootException("璁惧鏈垎閰嶇粰鎿嶄綔宸ワ紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); } - //鐝粍闀跨‘璁� userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); - values.put("dataId", entity.getId()); - values.put("organization", request.getConfirmComment()); - values.put("comment", request.getConfirmComment()); values.put("NextAssignee", userApprovalList); - values.put("confirmation", request.getConfirmDealType()); - request.setComment(request.getConfirmComment()); - //璁剧疆entity - entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_LEADER_CONFIRM.name()); - entity.setConfirmUser(user.getUsername()); - entity.setConfirmComment(request.getConfirmComment()); - entity.setConfirmTime(new Date()); - //澶勭悊鎶ヤ慨 - List<EamThirdMaintenanceOrderDetail> collect = request.getTableDetailList().stream().filter((detail) -> CommonConstant.DEFAULT_1.equals(detail.getReportFlag())).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(collect)) { - eamReportRepairService.reportRepairFromThirdMaintenance(equipment.getId(), entity.getOperator(), collect); - } + request.setComment("绗簩娆¢獙鏀剁粨鏉�"); break; - case WAIT_LEADER_CONFIRM: - values.put("dataId", entity.getId()); - values.put("organization", request.getLeaderConfirmComment()); - values.put("comment", request.getLeaderConfirmComment()); - request.setComment(request.getLeaderConfirmComment()); - //璁剧疆entity - entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.COMPLETE.name()); - entity.setConfirmLeader(user.getUsername()); - entity.setLeaderConfirmComment(request.getLeaderConfirmComment()); - entity.setLeaderConfirmTime(new Date()); + case OPERATOR_SIGNATURE: + // 鎿嶄綔浜虹瀛楃粨鏉� + values.put("dataId", order.getId()); + values.put("organization", "鎿嶄綔浜虹瀛楃粨鏉�"); + values.put("comment", "鎿嶄綔浜虹瀛楃粨鏉�"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨宸ワ紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + } + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("NextAssignee", userApprovalList); + request.setComment("鎿嶄綔浜虹瀛楃粨鏉�"); + break; + case REPAIRMAN_SIGNATURE: + // 缁翠慨浜虹瀛楃粨鏉� + values.put("dataId", order.getId()); + values.put("organization", "缁翠慨浜虹瀛楃粨鏉�"); + values.put("comment", "缁翠慨浜虹瀛楃粨鏉�"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0008); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨瀹や富浠伙紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + } + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("NextAssignee", userApprovalList); + request.setComment("缁翠慨浜虹瀛楃粨鏉�"); + break; + case REPAIR_MANAGER_SIGNATURE: + // 缁翠慨瀹や富浠荤瀛楃粨鏉� + values.put("dataId", order.getId()); + values.put("organization", "缁翠慨瀹や富浠荤瀛楃粨鏉�"); + values.put("comment", "缁翠慨瀹や富浠荤瀛楃粨鏉�"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0003); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰璁惧妫�楠屽憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); + } + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("NextAssignee", userApprovalList); + request.setComment("缁翠慨瀹や富浠荤瀛楃粨鏉�"); + break; + case INSPECTOR_SIGNATURE: + // 璁惧妫�鏌ヤ汉绛惧瓧缁撴潫 + values.put("dataId", order.getId()); + values.put("organization", "缁翠慨瀹や富浠荤瀛楃粨鏉�"); + values.put("comment", "缁翠慨瀹や富浠荤瀛楃粨鏉�"); + request.setComment("缁翠慨瀹や富浠荤瀛楃粨鏉�"); //鏇存柊璁惧淇濆吇鐘舵�� - eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); break; } request.setValues(values); + } - // 瀹屾垚娴佺▼浠诲姟 - Result result = flowTaskService.complete(request); - if (!result.isSuccess()) { - throw new JeecgBootException("瀹℃壒澶辫触锛岃鍒锋柊鏌ョ湅锛�"); + /** + * 鏇存柊宸ュ崟鐘舵�� + */ + private void updateOrderStatus(Result result, EamThirdMaintenanceRequest request, EamThirdMaintenanceOrder order, LoginUser user) { + if (result.isSuccess()) { + ThirdMaintenanceStatusEnum status = ThirdMaintenanceStatusEnum.getInstance(order.getMaintenanceStatus()); + switch (status) { + case WAIT_CHECK: + // 鎶�鏈姸鎬侀壌瀹氱粨鏉� + order.setInspector(user.getUsername()); + order.setFullyFunctional(request.getFullyFunctional()); + order.setRunningNormally(request.getRunningNormally()); + order.setInspectTime(new Date()); + if (CommonConstant.YN_1.equals(request.getFullyFunctional()) && CommonConstant.YN_1.equals(request.getRunningNormally())) { + // 閴村畾閫氳繃 + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); + } else { + // 閴村畾鏈�氳繃 + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.CANCEL.name()); + order.setProblemDescription(request.getProblemDescription()); + order.setActualEndTime(new Date()); + } + break; + case UNDER_MAINTENANCE: + // 淇濆吇缁撴潫 + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_FIRST_ACCEPTANCE.name()); + order.setRepairman(user.getUsername()); + order.setActualEndTime(new Date()); + // 涓変繚鏄庣粏澶勭悊 + eamThirdMaintenanceOrderDetailService.remove(new LambdaQueryWrapper<EamThirdMaintenanceOrderDetail>().eq(EamThirdMaintenanceOrderDetail::getOrderId, order.getId())); + eamThirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); + break; + case UNDER_FIRST_ACCEPTANCE: + // 绗竴娆¢獙鏀剁粨鏉� + boolean flag = false; + if (!CollectionUtil.isEmpty(request.getTableDetailList())) { + for (EamThirdMaintenanceOrderDetail eamThirdMaintenanceOrderDetail : request.getTableDetailList()) { + if ("2".equals(eamThirdMaintenanceOrderDetail.getFirstInspectResult())) { + flag = true; + break; + } + } + } + if (flag) { + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_SECOND_ACCEPTANCE.name()); + } else { + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.OPERATOR_SIGNATURE.name()); + } + // 涓変繚鏄庣粏澶勭悊 + eamThirdMaintenanceOrderDetailService.remove(new LambdaQueryWrapper<EamThirdMaintenanceOrderDetail>().eq(EamThirdMaintenanceOrderDetail::getOrderId, order.getId())); + eamThirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); + break; + case UNDER_SECOND_ACCEPTANCE: + // 绗簩娆¢獙鏀剁粨鏉� + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.OPERATOR_SIGNATURE.name()); + // 涓変繚鏄庣粏澶勭悊 + eamThirdMaintenanceOrderDetailService.remove(new LambdaQueryWrapper<EamThirdMaintenanceOrderDetail>().eq(EamThirdMaintenanceOrderDetail::getOrderId, order.getId())); + eamThirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); + break; + case OPERATOR_SIGNATURE: + // 鎿嶄綔浜虹瀛楃粨鏉� + if (!StrUtils.isEmpty(request.getAssistantOperator())) { + order.setAssistantOperator(request.getAssistantOperator()); + } + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.REPAIRMAN_SIGNATURE.name()); + order.setOperatorSignature(user.getUsername()); + order.setOperatorSignatureTime(new Date()); + break; + case REPAIRMAN_SIGNATURE: + // 缁翠慨浜虹瀛楃粨鏉� + if (!StrUtils.isEmpty(request.getAssistantRepairman())) { + order.setAssistantRepairman(request.getAssistantRepairman()); + } + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.REPAIR_MANAGER_SIGNATURE.name()); + order.setRepairmanSignature(user.getUsername()); + order.setRepairmanSignatureTime(new Date()); + break; + case REPAIR_MANAGER_SIGNATURE: + // 缁翠慨瀹や富浠荤瀛楃粨鏉� + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.INSPECTOR_SIGNATURE.name()); + order.setRepairManagerSignature(user.getUsername()); + order.setRepairManagerSignatureTime(new Date()); + break; + case INSPECTOR_SIGNATURE: + // 璁惧妫�鏌ヤ汉绛惧瓧缁撴潫 + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.COMPLETE.name()); + order.setInspectorSignature(user.getUsername()); + order.setInspectorSignatureTime(new Date()); + break; + } } - //淇濆瓨宸ュ崟 - eamThirdMaintenanceOrderMapper.updateById(entity); - return entity; } private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { -- Gitblit v1.9.3