From d6372da6f37778e90a4bae02865e8ec77e980b6e Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期四, 17 七月 2025 17:14:26 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java | 400 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 369 insertions(+), 31 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java index ab31904..c91a37c 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java @@ -3,6 +3,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -18,35 +19,38 @@ 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.*; +import org.jeecg.modules.eam.request.*; 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.eam.constant.BusinessCodeConst; -import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum; -import org.jeecg.modules.eam.constant.InspectionItemCategroyEnum; -import org.jeecg.modules.eam.constant.InspectionStatus; import org.jeecg.modules.eam.entity.*; import org.jeecg.modules.eam.mapper.EamInspectionOrderMapper; -import org.jeecg.modules.eam.request.EamInspectionOrderQuery; -import org.jeecg.modules.eam.request.EamInspectionOrderRequest; import org.jeecg.modules.eam.service.*; import org.jeecg.modules.eam.util.DateUtils; -import org.jeecg.modules.eam.vo.InspectionVo; import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; 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; +import org.jeecg.modules.system.service.ISysDictService; +import org.jeecg.modules.system.service.ISysUserService; +import org.jeecg.modules.system.vo.UserSelector; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -84,6 +88,12 @@ private IEamReportRepairService eamReportRepairService; @Resource private IEamMaintenanceStandardDetailService eamMaintenanceStandardDetailService; + @Resource + private ISysDictService sysDictService; + @Resource + private ISysUserService sysUserService; + @Resource + private IEamBaseHFCodeService eamBaseHFCodeService; @Override public IPage<EamInspectionOrder> queryPageList(Page<EamInspectionOrder> page, EamInspectionOrderQuery query) { @@ -102,9 +112,11 @@ List<BaseFactoryUser> baseFactoryUserList = baseFactoryUserService. list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId, sysUser.getId())); if (!CollectionUtils.isEmpty(baseFactoryUserList)) { - List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); - List<String> factoryCode = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); - queryWrapper.in("e.factory_code", factoryCode); + 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; } } //鏌ヨ鏉′欢杩囨护 @@ -154,6 +166,305 @@ return eamInspectionOrderMapper.selectList(queryWrapper); } + /** + * 瀵煎嚭鑾峰彇鍩烘湰淇℃伅 + * @param equipmentCode 璁惧缂栫爜 + * @param inspectionDate 鐐规鏃ユ湡 + * @return + */ + @Override + public JSONObject exportInspectionOrderBaseInfo(String equipmentCode, String inspectionDate) { + if (StrUtils.isEmpty(inspectionDate)) { + // 鑾峰彇褰撳墠鏃ユ湡 + LocalDate currentDate = LocalDate.now(); + // 瀹氫箟鏃ユ湡鏍煎紡 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + // 鏍煎紡鍖栧綋鍓嶆湀浠� + inspectionDate = currentDate.format(formatter); + } + // 鍒涘缓缁撴灉瀵硅薄 + JSONObject result = new JSONObject(); + EamInspectionOrderBaseResponse eamInspectionOrderBaseResponse = eamInspectionOrderMapper.findInsOrderBaseInfo(equipmentCode, inspectionDate); + // 澶勭悊鍗曚綅 + String factoryOrgCode = eamInspectionOrderBaseResponse.getFactoryName(); + BaseFactory baseFactory = baseFactoryService.getOne(new LambdaQueryWrapper<BaseFactory>().eq(BaseFactory::getOrgCode, factoryOrgCode.substring(0, 6))); + eamInspectionOrderBaseResponse.setFactoryName(baseFactory.getFactoryName()); + result.put("data",Collections.singletonList(eamInspectionOrderBaseResponse)); + return result; + } + + /** + * 鏃ョ偣妫�椤瑰垪琛� + * @param equipmentCode 璁惧缂栫爜 + * @param inspectionDate 鐐规鏃ユ湡 + * @return + */ + @Override + public JSONObject exportInspectionOrderDetailList(String equipmentCode, String inspectionDate) { + if (StrUtils.isEmpty(inspectionDate)) { + // 鑾峰彇褰撳墠鏃ユ湡 + LocalDate currentDate = LocalDate.now(); + // 瀹氫箟鏃ユ湡鏍煎紡 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + // 鏍煎紡鍖栧綋鍓嶆湀浠� + inspectionDate = currentDate.format(formatter); + } + // 鍒涘缓缁撴灉瀵硅薄 + JSONObject result = new JSONObject(); + List<EamInsOrderDetailResultResponse> eamInsOrderDetailResultResponseList = eamInspectionOrderMapper.findInsOrderDetailList(equipmentCode, inspectionDate); + if (eamInsOrderDetailResultResponseList == null || eamInsOrderDetailResultResponseList.isEmpty()) { + return result; + } + Map<EamInsOrderDetailResultResponse, List<EamInsOrderDetailResultResponse>> groupMap = eamInsOrderDetailResultResponseList + .stream().collect(Collectors.groupingBy( + // 鍒嗙粍閿細鍖呭惈 itemCode銆乮temName銆乮temDemand 鐨勫璞� + item -> new EamInsOrderDetailResultResponse( + item.getItemCode(), + item.getItemName(), + item.getItemDemand() + ), + // 鐢� TreeMap 浣滀负瀹瑰櫒锛屽苟鎸囧畾鎸� itemCode 鎺掑簭鐨勬瘮杈冨櫒 + () -> new TreeMap<>(Comparator.comparingInt(EamInsOrderDetailResultResponse::getItemCode)), + // 鏀堕泦姣忕粍鐨勫厓绱犱负 List + Collectors.toList() + )); + List<Map<String, Object>> resultList = new ArrayList<>(); + groupMap.forEach((insOrderDetailResultResponse, insOrderDetailResultResponseList) -> { + Map<String, Object> resultMap = new LinkedHashMap<>(); + resultMap.put("itemCode", insOrderDetailResultResponse.getItemCode()); + resultMap.put("itemName", insOrderDetailResultResponse.getItemName()); + resultMap.put("itemDemand", insOrderDetailResultResponse.getItemDemand()); + Map<Integer, EamInsOrderDetailResultResponse> collect = insOrderDetailResultResponseList + .stream().collect(Collectors.toMap( + // 鍒嗙粍閿細鎻愬彇鏃ユ湡涓殑鈥滃ぉ鈥� + item -> { + Date date = item.getInspectionDate(); + LocalDate localDate = date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + return localDate.getDayOfMonth(); // 閿负鈥滃ぉ鈥濓紙1-31锛� + }, + // 鍊硷細鐩存帴浣跨敤褰撳墠瀵硅薄锛堜綔涓哄垵濮嬪�硷級 + item -> item, + // 鍚堝苟鍑芥暟锛氬綋鍚屼竴鈥滃ぉ鈥濇湁澶氫釜瀵硅薄鏃讹紝濡備綍澶勭悊锛堣繖閲岀ず渚嬪彇绗竴涓級 + (existing, replacement) -> existing // 鑻ユ湁閲嶅閿紝淇濈暀宸插瓨鍦ㄧ殑瀵硅薄 + )); + for (int i = 1; i <= 31; i++) { + if (collect.containsKey(i)) { + String inspectionResult = ""; + if (!StrUtils.isEmpty(collect.get(i).getInspectionResult())) { + switch (collect.get(i).getInspectionResult()) { + case "NORMAL": + inspectionResult = "鈭�"; + break; + case "ANOMALY": + inspectionResult = "脳"; + break; + case "FAULT": + inspectionResult = "鈻�"; + break; + case "CLOSE": + inspectionResult = "T"; + break; + } + } + resultMap.put("inspectionResult" + i, inspectionResult); + } else { + resultMap.put("inspectionResult" + i, ""); + } + } + resultList.add(resultMap); + }); + result.put("data", resultList); + return result; + } + + /** + * 鏃ョ偣妫�璐d换浜哄垪琛� + * @param equipmentCode 璁惧缂栫爜 + * @param inspectionDate 鐐规鏃ユ湡 + * @return + */ + @Override + public JSONObject exportInspectionOrderDetailUserList(String equipmentCode, String inspectionDate) { + if (StrUtils.isEmpty(inspectionDate)) { + // 鑾峰彇褰撳墠鏃ユ湡 + LocalDate currentDate = LocalDate.now(); + // 瀹氫箟鏃ユ湡鏍煎紡 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + // 鏍煎紡鍖栧綋鍓嶆湀浠� + inspectionDate = currentDate.format(formatter); + } + // 鍒涘缓缁撴灉瀵硅薄 + JSONObject result = new JSONObject(); + List<EamInsOrderDetailUserResponse> eamInsOrderDetailUserResponseList = eamInspectionOrderMapper.findInspectionOrderDetailUserList(equipmentCode, inspectionDate); + if (eamInsOrderDetailUserResponseList == null || eamInsOrderDetailUserResponseList.isEmpty()) { + return result; + } + Map<Integer, EamInsOrderDetailUserResponse> groupMap = eamInsOrderDetailUserResponseList.stream().collect(Collectors.toMap( + // 鍒嗙粍閿細鎻愬彇鏃ユ湡涓殑鈥滃ぉ鈥� + item -> { + Date date = item.getInspectionDate(); + LocalDate localDate = date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + return localDate.getDayOfMonth(); // 閿负鈥滃ぉ鈥濓紙1-31锛� + }, + // 鍊硷細鐩存帴浣跨敤褰撳墠瀵硅薄锛堜綔涓哄垵濮嬪�硷級 + item -> item, + // 鍚堝苟鍑芥暟锛氬綋鍚屼竴鈥滃ぉ鈥濇湁澶氫釜瀵硅薄鏃讹紝濡備綍澶勭悊锛堣繖閲岀ず渚嬪彇绗竴涓級 + (existing, replacement) -> existing // 鑻ユ湁閲嶅閿紝淇濈暀宸插瓨鍦ㄧ殑瀵硅薄 + )); + Map<String, Object> resultMap = new LinkedHashMap<>(); + for (int i = 1; i <= 31; i++) { + if (groupMap.containsKey(i)) { + EamInsOrderDetailUserResponse eamInsOrderDetailUserResponse = groupMap.get(i); + resultMap.put("operator" + i, sysDictService.queryTableDictTextByKey("sys_user", "realname", "username", eamInsOrderDetailUserResponse.getOperator())); + resultMap.put("confirmUser" + i, sysDictService.queryTableDictTextByKey("sys_user", "realname", "username", eamInsOrderDetailUserResponse.getConfirmUser())); + } else { + resultMap.put("operator" + i, ""); + resultMap.put("confirmUser" + i, ""); + } + } + result.put("data", Collections.singletonList(resultMap)); + return result; + } + + /** + * 鍛ㄧ偣妫�椤瑰垪琛� + * @param equipmentCode 璁惧缂栫爜 + * @param inspectionDate 鐐规鏃ユ湡 + * @return + */ + @Override + public JSONObject exportWeekInsDetailList(String equipmentCode, String inspectionDate) { + if (StrUtils.isEmpty(inspectionDate)) { + // 鑾峰彇褰撳墠鏃ユ湡 + LocalDate currentDate = LocalDate.now(); + // 瀹氫箟鏃ユ湡鏍煎紡 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + // 鏍煎紡鍖栧綋鍓嶆湀浠� + inspectionDate = currentDate.format(formatter); + } + // 鍒涘缓缁撴灉瀵硅薄 + JSONObject result = new JSONObject(); + List<EamWeekInsDetailResultResponse> eamWeekInsDetailResultResponseList = eamInspectionOrderMapper.findWeekInsDetailList(equipmentCode, inspectionDate); + if (eamWeekInsDetailResultResponseList == null || eamWeekInsDetailResultResponseList.isEmpty()) { + return result; + } + Map<EamWeekInsDetailResultResponse, List<EamWeekInsDetailResultResponse>> groupMap = eamWeekInsDetailResultResponseList + .stream().collect(Collectors.groupingBy( + // 鍒嗙粍閿細鍖呭惈 itemCode銆乮temName銆乮temDemand 鐨勫璞� + item -> new EamWeekInsDetailResultResponse( + item.getItemCode(), + item.getItemName(), + item.getItemDemand() + ), + // 鐢� TreeMap 浣滀负瀹瑰櫒锛屽苟鎸囧畾鎸� itemCode 鎺掑簭鐨勬瘮杈冨櫒 + () -> new TreeMap<>(Comparator.comparingInt(EamWeekInsDetailResultResponse::getItemCode)), + // 鏀堕泦姣忕粍鐨勫厓绱犱负 List + Collectors.toList() + )); + List<Map<String, Object>> resultList = new ArrayList<>(); + groupMap.forEach((weekInsDetailResultResponse, weekInsDetailResultResponseList) -> { + Map<String, Object> resultMap = new LinkedHashMap<>(); + resultMap.put("itemCode", weekInsDetailResultResponse.getItemCode()); + resultMap.put("itemName", weekInsDetailResultResponse.getItemName()); + resultMap.put("itemDemand", weekInsDetailResultResponse.getItemDemand()); + // 浣跨敤AtomicInteger浣滀负璁℃暟鍣紝浠�1寮�濮� + AtomicInteger counter = new AtomicInteger(1); + Map<Integer, EamWeekInsDetailResultResponse> collect = weekInsDetailResultResponseList + .stream() + .collect(Collectors.toMap( + // 鍒嗙粍閿細浣跨敤鑷搴忓彿锛堜粠1寮�濮嬶級 + item -> counter.getAndIncrement(), + // 鍊硷細鐩存帴浣跨敤褰撳墠瀵硅薄 + item -> item, + // 鍚堝苟鍑芥暟锛氬綋鍚屼竴搴忓彿鏈夊涓璞℃椂锛堢悊璁轰笂涓嶄細鍙戠敓锛夛紝濡備綍澶勭悊 + (existing, replacement) -> existing, // 鑻ユ湁閲嶅閿紝淇濈暀宸插瓨鍦ㄧ殑瀵硅薄 + // 鎸囧畾Map鐨勫叿浣撳疄鐜帮紙鍙�夛級 + LinkedHashMap::new // 淇濇寔鎻掑叆椤哄簭 + )); + for (int i = 1; i <= 5; i++) { + if (collect.containsKey(i)) { + String inspectionResult = ""; + if (!StrUtils.isEmpty(collect.get(i).getInspectionResult())) { + switch (collect.get(i).getInspectionResult()) { + case "NORMAL": + inspectionResult = "鈭�"; + break; + case "ANOMALY": + inspectionResult = "脳"; + break; + case "FAULT": + inspectionResult = "鈻�"; + break; + case "CLOSE": + inspectionResult = "T"; + break; + } + } + resultMap.put("inspectionResult" + i, inspectionResult); + } else { + resultMap.put("inspectionResult" + i, ""); + } + } + resultList.add(resultMap); + }); + result.put("data", resultList); + return result; + } + + /** + * 鍛ㄧ偣妫�璐d换浜哄垪琛� + * @param equipmentCode 璁惧缂栫爜 + * @param inspectionDate 鐐规鏃ユ湡 + * @return + */ + @Override + public JSONObject exportWeekInsOrderDetailUserList(String equipmentCode, String inspectionDate) { + if (StrUtils.isEmpty(inspectionDate)) { + // 鑾峰彇褰撳墠鏃ユ湡 + LocalDate currentDate = LocalDate.now(); + // 瀹氫箟鏃ユ湡鏍煎紡 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + // 鏍煎紡鍖栧綋鍓嶆湀浠� + inspectionDate = currentDate.format(formatter); + } + // 鍒涘缓缁撴灉瀵硅薄 + JSONObject result = new JSONObject(); + List<EamWeekInsDetailUserResponse> eamWeekInsDetailUserResponseList = eamInspectionOrderMapper.findWeekInsOrderDetailUserList(equipmentCode, inspectionDate); + if (eamWeekInsDetailUserResponseList == null || eamWeekInsDetailUserResponseList.isEmpty()) { + return result; + } + // 浣跨敤AtomicInteger浣滀负璁℃暟鍣紝浠�1寮�濮� + AtomicInteger counter = new AtomicInteger(1); + Map<Integer, EamWeekInsDetailUserResponse> groupMap = eamWeekInsDetailUserResponseList + .stream() + .collect(Collectors.toMap( + // 鍒嗙粍閿細浣跨敤鑷搴忓彿锛堜粠1寮�濮嬶級 + item -> counter.getAndIncrement(), + // 鍊硷細鐩存帴浣跨敤褰撳墠瀵硅薄锛堜綔涓哄垵濮嬪�硷級 + item -> item, + // 鍚堝苟鍑芥暟锛氬綋鍚屼竴鈥滃ぉ鈥濇湁澶氫釜瀵硅薄鏃讹紝濡備綍澶勭悊锛堣繖閲岀ず渚嬪彇绗竴涓級 + (existing, replacement) -> existing // 鑻ユ湁閲嶅閿紝淇濈暀宸插瓨鍦ㄧ殑瀵硅薄 + )); + Map<String, Object> resultMap = new LinkedHashMap<>(); + for (int i = 1; i <= 5; i++) { + if (groupMap.containsKey(i)) { + EamWeekInsDetailUserResponse eamWeekInsDetailUserResponse = groupMap.get(i); + resultMap.put("operator" + i, sysDictService.queryTableDictTextByKey("sys_user", "realname", "username", eamWeekInsDetailUserResponse.getInspector())); + resultMap.put("confirmUser" + i, sysDictService.queryTableDictTextByKey("sys_user", "realname", "username", eamWeekInsDetailUserResponse.getConfirmUser())); + } else { + resultMap.put("operator" + i, ""); + resultMap.put("confirmUser" + i, ""); + } + } + result.put("data", Collections.singletonList(resultMap)); + + return result; + } + @Override @Transactional(rollbackFor = Exception.class) public Result<String> addInspectionOrder(EamInspectionOrderRequest eamInspectionOrderRequest) { @@ -166,6 +477,12 @@ //淇敼鐘舵�� eamInspectionOrder.setInspectionStatus(InspectionStatus.WAIT_INSPECTION.name()); eamInspectionOrder.setDelFlag(CommonConstant.DEL_FLAG_0); + //HF鐮佸鐞� + EamBaseHFCode eamBaseHFCode = eamBaseHFCodeService.selectByCategory(HfTemplateCategoryEnum.INSPECTION.name()); + if (eamBaseHFCode == null) { + return Result.error("娣诲姞澶辫触,鏈厤缃偣妫�HF缂栫爜锛�"); + } + eamInspectionOrder.setHfCode(eamBaseHFCode.getHfCode()); save(eamInspectionOrder); //澶勭悊鏃ョ偣妫�鏄庣粏鏁版嵁 if (StrUtil.isNotBlank(eamInspectionOrderRequest.getStandardId())) { @@ -191,6 +508,7 @@ if (CollectionUtils.isNotEmpty(maintenanceStandardDetailList)) { List<EamWeekInspectionDetail> weekInspectionDetailList = maintenanceStandardDetailList.stream().map(EamWeekInspectionDetail::new).collect(Collectors.toList()); weekInspectionDetailList.forEach(weekInspectionDetail -> { + weekInspectionDetail.setEquipmentId(eamInspectionOrderRequest.getEquipmentId()); weekInspectionDetail.setStandardId(eamInspectionOrderRequest.getStandardId()); // TODO 鍛ㄧ偣妫�鏃ユ湡 weekInspectionDetail.setPlanInspectionDate(eamInspectionOrderRequest.getInspectionDate()); @@ -334,8 +652,26 @@ throw new JeecgBootException("浠诲姟涓嶅瓨鍦ㄣ�佸凡瀹屾垚鎴栧凡琚粬浜鸿棰�"); } + EamEquipment equipment = eamEquipmentService.getById(eamInspectionOrder.getEquipmentId()); + if (equipment == null) { + throw new JeecgBootException("璁惧涓嶅瓨鍦紝璇锋鏌ワ紒"); + } + + // 妫�鏌ュ懆淇濊繃鏈熸椂闂� + if (eamInspectionOrderRequest.getTableWeekDetailList() == null || eamInspectionOrderRequest.getTableWeekDetailList().isEmpty()) { + List<EamWeekInspectionDetail> weekInspectionDetailList = eamWeekInspectionDetailService.list(new LambdaQueryWrapper<EamWeekInspectionDetail>().eq(EamWeekInspectionDetail::getStandardId, eamInspectionOrderRequest.getStandardId()).between(EamWeekInspectionDetail::getPlanInspectionDate, DateUtils.getFirstDayOfWeek(eamInspectionOrderRequest.getInspectionDate()), DateUtils.getLastDayOfWeek(eamInspectionOrderRequest.getInspectionDate()))); + if (weekInspectionDetailList != null && !weekInspectionDetailList.isEmpty()) { + if (StrUtil.isEmpty(eamInspectionOrderRequest.getOperator())) { + Date lastDate = DateUtils.getLastDayOfWeek(eamInspectionOrderRequest.getInspectionDate()); + if (DateUtils.isSameDay(lastDate, new Date())) { + throw new JeecgBootException("鏈懆鐐规鏈畬鎴愶紝璇疯繘琛屽~鎶ワ紒"); + } + } + } + } + // 璁剧疆娴佺▼鍙橀噺 - setupProcessVariables(eamInspectionOrderRequest, eamInspectionOrder, user); + setupProcessVariables(eamInspectionOrderRequest, eamInspectionOrder, user, equipment); // 瀹屾垚娴佺▼浠诲姟 Result result = flowTaskService.complete(eamInspectionOrderRequest); @@ -397,13 +733,20 @@ return true; } - private void setupProcessVariables(EamInspectionOrderRequest request, EamInspectionOrder order, LoginUser user) { + private void setupProcessVariables(EamInspectionOrderRequest request, EamInspectionOrder order, LoginUser user, EamEquipment equipment) { Map<String, Object> values = new HashMap<>(); if (InspectionStatus.UNDER_INSPECTION.name().equals(order.getInspectionStatus()) && user.getUsername().equals(order.getOperator())) { // 鐐规浜虹偣妫�缁撴潫 values.put("dataId", order.getId()); values.put("organization", "鐐规浜虹偣妫�缁撴潫"); values.put("comment", "鐐规浜虹偣妫�缁撴潫"); + // 鑾峰彇涓嬩竴姝ユ墽琛屼汉 + List<UserSelector> userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨宸ワ紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + } + List<String> userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("NextAssignee", userApprovalList); request.setComment("鐐规浜虹偣妫�缁撴潫"); } else { // 缁翠慨宸ョ‘璁� @@ -432,10 +775,17 @@ eamInspectionOrderDetailService.remove(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", order.getId())); eamInspectionOrderDetailService.saveBatch(request.getTableDetailList()); + //璁剧疆鍛ㄧ偣妫� if (request.getTableWeekDetailList() != null && !request.getTableWeekDetailList().isEmpty()) { - // 璁剧疆鍛ㄧ偣妫� -// eamWeekInspectionDetailService.remove(new QueryWrapper<EamWeekInspectionDetail>().eq("order_id", order.getId())); - eamWeekInspectionDetailService.saveOrUpdateBatch(request.getTableWeekDetailList()); + List<EamWeekInspectionDetail> tableWeekDetailList = request.getTableWeekDetailList(); + for (EamWeekInspectionDetail eamWeekInspectionDetail : tableWeekDetailList) { + if (StringUtils.isEmpty(eamWeekInspectionDetail.getInspectionResult())) { + break; + } + eamWeekInspectionDetail.setInspector(user.getUsername()); + eamWeekInspectionDetail.setInspectTime(new Date()); + } + eamWeekInspectionDetailService.saveOrUpdateBatch(tableWeekDetailList); } } else if (InspectionStatus.WAIT_CONFIRM.name().equals(order.getInspectionStatus()) && StrUtil.isNotEmpty(request.getConfirmDealType())) { // 鐝粍闀跨‘璁や换鍔� @@ -459,8 +809,10 @@ */ private void updateEamInspectionOrderDetail(EamInspectionOrder eamInspectionOrder) { List<EamInspectionOrderDetail> eamInspectionOrderDetails = eamInspectionOrderDetailService - .list(new QueryWrapper<EamInspectionOrderDetail>() - .eq("order_id", eamInspectionOrder.getId()).eq("report_flag", "1").eq("inspection_result", "2")); + .list(new LambdaQueryWrapper<EamInspectionOrderDetail>() + .eq(EamInspectionOrderDetail::getOrderId, eamInspectionOrder.getId()).eq(EamInspectionOrderDetail::getReportFlag, "1")); + + // TODO 鐐规瀹屾垚鍚庤嚜鍔ㄤ繚淇� eamReportRepairService.reportRepairFromInspection(eamInspectionOrder.getEquipmentId(), eamInspectionOrder.getOperator(), eamInspectionOrderDetails); } @@ -539,18 +891,4 @@ return (List<String>) object; } - @Override - public List<InspectionVo> findInspectionResult(String equipmentId, String itemDemand, String yearMonth) { - return this.baseMapper.findInspectionResult(equipmentId, itemDemand, yearMonth); - } - - @Override - public List<InspectionVo> findInspectionUser(String equipmentId, String yearMonth) { - return this.baseMapper.findInspectionUser(equipmentId, yearMonth); - } - - @Override - public List<Map<String, Object>> findInspectionStandard(String equipmentId) { - return this.baseMapper.findInspectionStandard(equipmentId); - } } -- Gitblit v1.9.3