From 664c33a8a82fc7ba9189078037469e2efd7023f6 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期二, 08 七月 2025 09:37:36 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/DateUtils.java | 63 ++++++++++++--- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamInspectionOrderRequest.java | 11 -- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekInspectionDetailController.java | 8 +- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java | 105 +++++++++++++------------- 4 files changed, 105 insertions(+), 82 deletions(-) diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/DateUtils.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/DateUtils.java index efed637..de64074 100644 --- a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/DateUtils.java +++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/DateUtils.java @@ -1092,27 +1092,62 @@ * 鑾峰彇鏈懆鐨勭涓�澶╂棩鏈燂紝 鏍煎紡涓猴細yyyy-MM-dd * @return */ - public static Date getFirstDayOfWeek() { - // 鑾峰彇鏈懆绗竴澶╋紙鍛ㄤ竴锛夌殑 LocalDate - LocalDate today = LocalDate.now(); - LocalDate firstDayOfWeek = today.with(DayOfWeek.MONDAY); + public static Date getFirstDayOfWeek(String date) { + // 灏� java.util.Date 杞崲涓� LocalDate + LocalDate localDate = LocalDate.parse(date); - // 濡傛灉闇�瑕佽浆鎹负浼犵粺鐨� Date 绫诲瀷锛堝彲閫夛級 - java.sql.Date sqlDate = java.sql.Date.valueOf(firstDayOfWeek); - return new Date(sqlDate.getTime()); + // 鑾峰彇鏈懆绗竴澶╋紙鍛ㄤ竴锛� + LocalDate firstDayOfWeek = localDate.with(DayOfWeek.MONDAY); + + // 杞崲鍥� java.sql.Date 绫诲瀷 + return java.sql.Date.valueOf(firstDayOfWeek); + } + + /** + * 鑾峰彇鏈懆鐨勭涓�澶╂棩鏈燂紝 鏍煎紡涓猴細yyyy-MM-dd + * @return + */ + public static Date getFirstDayOfWeek(Date date) { + // 灏� java.util.Date 杞崲涓� LocalDate + LocalDate localDate = date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + + // 鑾峰彇鏈懆绗竴澶╋紙鍛ㄤ竴锛� + LocalDate firstDayOfWeek = localDate.with(DayOfWeek.MONDAY); + + // 杞崲鍥� java.sql.Date 绫诲瀷 + return java.sql.Date.valueOf(firstDayOfWeek); } /** * 鑾峰彇鏈懆鐨勬渶鍚庝竴澶╂棩鏈燂紝 鏍煎紡涓猴細yyyy-MM-dd * @return */ - public static Date getLastDayOfWeek() { - // 鑾峰彇鏈懆绗竴澶╋紙鍛ㄤ竴锛夌殑 LocalDate - LocalDate today = LocalDate.now(); - LocalDate firstDayOfWeek = today.with(DayOfWeek.SUNDAY); + public static Date getLastDayOfWeek(String date) { + // 灏� java.util.Date 杞崲涓� LocalDate + LocalDate localDate = LocalDate.parse(date); - // 濡傛灉闇�瑕佽浆鎹负浼犵粺鐨� Date 绫诲瀷锛堝彲閫夛級 - java.sql.Date sqlDate = java.sql.Date.valueOf(firstDayOfWeek); - return new Date(sqlDate.getTime()); + // 鑾峰彇鏈懆绗竴澶╋紙鍛ㄤ竴锛� + LocalDate firstDayOfWeek = localDate.with(DayOfWeek.SUNDAY); + + // 杞崲鍥� java.sql.Date 绫诲瀷 + return java.sql.Date.valueOf(firstDayOfWeek); + } + + /** + * 鑾峰彇鏈懆鐨勬渶鍚庝竴澶╂棩鏈燂紝 鏍煎紡涓猴細yyyy-MM-dd + * @return + */ + public static Date getLastDayOfWeek(Date date) { + // 灏� java.util.Date 杞崲涓� LocalDate + LocalDate localDate = date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + // 鑾峰彇鏈懆绗竴澶╋紙鍛ㄤ竴锛� + LocalDate firstDayOfWeek = localDate.with(DayOfWeek.SUNDAY); + + // 杞崲鍥� java.sql.Date 绫诲瀷 + return java.sql.Date.valueOf(firstDayOfWeek); } } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekInspectionDetailController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekInspectionDetailController.java index 688836a..0b54f4e 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekInspectionDetailController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekInspectionDetailController.java @@ -6,14 +6,14 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.base.controller.JeecgController; -import org.jeecg.modules.eam.constant.InspectionItemCategroyEnum; -import org.jeecg.modules.eam.entity.EamMaintenanceStandardDetail; import org.jeecg.modules.eam.entity.EamWeekInspectionDetail; import org.jeecg.modules.eam.service.IEamWeekInspectionDetailService; import org.jeecg.modules.eam.util.DateUtils; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.Date; import java.util.List; /** @@ -39,10 +39,10 @@ */ @ApiOperation(value = "鍛ㄧ偣妫�宸ュ崟鏄庣粏-鏃ョ偣妫�瑙勮寖鍒楄〃鏌ヨ", notes = "鍛ㄧ偣妫�宸ュ崟鏄庣粏-鏃ョ偣妫�瑙勮寖鍒楄〃鏌ヨ") @GetMapping(value = "/queryStandardList") - public Result<?> queryStandardList(@RequestParam("standardId") String standardId) { + public Result<?> queryStandardList(@RequestParam("standardId") String standardId, @RequestParam("inspectionDate") String inspectionDate) { LambdaQueryWrapper<EamWeekInspectionDetail> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(EamWeekInspectionDetail::getStandardId, standardId); - queryWrapper.between(EamWeekInspectionDetail::getPlanInspectionDate, DateUtils.getFirstDayOfWeek(), DateUtils.getLastDayOfWeek()); + queryWrapper.between(EamWeekInspectionDetail::getPlanInspectionDate, DateUtils.getFirstDayOfWeek(inspectionDate), DateUtils.getLastDayOfWeek(inspectionDate)); queryWrapper.orderByAsc(EamWeekInspectionDetail::getItemCode); List<EamWeekInspectionDetail> list = eamWeekInspectionDetailService.list(queryWrapper); return Result.OK(list); diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamInspectionOrderRequest.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamInspectionOrderRequest.java index 3a71c69..4f035ea 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamInspectionOrderRequest.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamInspectionOrderRequest.java @@ -1,19 +1,15 @@ package org.jeecg.modules.eam.request; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -import org.jeecg.common.api.vo.FileUploadResult; import org.jeecg.common.aspect.annotation.Dict; import org.jeecg.modules.eam.entity.EamInspectionOrderDetail; import org.jeecg.modules.eam.entity.EamWeekInspectionDetail; import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; -import org.jeecgframework.poi.excel.annotation.Excel; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; @@ -98,13 +94,6 @@ /**澶囨敞*/ @ApiModelProperty(value = "澶囨敞-鐐规宸ュ崟鍒涘缓澶囨敞") private String remark; - /**鐓х墖鏂囦欢ids;id浠ラ�楀彿鍒嗛殧*/ - @ApiModelProperty(value = "鐓х墖鏂囦欢ids;id浠ラ�楀彿鍒嗛殧") - private String imageFiles; - - /**涓婁紶鏂囦欢瀵圭郴*/ - @ApiModelProperty(value = "涓婁紶鏂囦欢瀵硅薄") - private List<FileUploadResult> fileList; /**鍒楄〃 淇濆吇椤规槑缁�*/ @ApiModelProperty(value = "鍒楄〃 淇濆吇椤规槑缁�") 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 df387bf..78f13f7 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 @@ -99,11 +99,11 @@ queryWrapper.in("e.equipment_code", equipArr); } else { //娌℃湁閫夋嫨璁惧锛屾牴鎹腑蹇冭繃婊よ澶� - List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService. - list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId())); - if(!CollectionUtils.isEmpty(baseFactoryUserList)){ + 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()); + List<String> factoryCode = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); queryWrapper.in("e.factory_code", factoryCode); } } @@ -167,21 +167,42 @@ } eamInspectionOrder.setDelFlag(CommonConstant.DEL_FLAG_0); save(eamInspectionOrder); - //澶勭悊鏄庣粏鏁版嵁 - if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableDetailList())) { - eamInspectionOrderRequest.getTableDetailList().forEach(tableDetail -> { - tableDetail.setOrderId(eamInspectionOrder.getId()); - tableDetail.setId(null); - }); - eamInspectionOrderDetailService.saveBatch(eamInspectionOrderRequest.getTableDetailList()); + //澶勭悊鏃ョ偣妫�鏄庣粏鏁版嵁 + if (StrUtil.isNotBlank(eamInspectionOrderRequest.getStandardId())) { + List<EamMaintenanceStandardDetail> maintenanceStandardDetailList = eamMaintenanceStandardDetailService.list(new LambdaQueryWrapper<EamMaintenanceStandardDetail>().eq(EamMaintenanceStandardDetail::getStandardId, eamInspectionOrderRequest.getStandardId()).eq(EamMaintenanceStandardDetail::getItemCategory, InspectionItemCategroyEnum.DAY_INSPECTION.name())); + if (CollectionUtils.isNotEmpty(maintenanceStandardDetailList)) { + List<EamInspectionOrderDetail> inspectionOrderList = maintenanceStandardDetailList.stream().map(EamInspectionOrderDetail::new).collect(Collectors.toList()); + inspectionOrderList.forEach(tableDetail -> { + tableDetail.setOrderId(eamInspectionOrder.getId()); + tableDetail.setId(null); + }); + eamInspectionOrderDetailService.saveBatch(inspectionOrderList); + } } //澶勭悊鍛ㄧ偣妫�鏄庣粏鏁版嵁 - if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableWeekDetailList())) { - eamWeekInspectionDetailService.saveOrUpdateBatch(eamInspectionOrderRequest.getTableWeekDetailList()); + if (StrUtil.isNotBlank(eamInspectionOrderRequest.getStandardId()) && eamInspectionOrderRequest.getInspectionDate() != null) { + LambdaQueryWrapper<EamWeekInspectionDetail> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(EamWeekInspectionDetail::getStandardId, eamInspectionOrderRequest.getStandardId()); + queryWrapper.between(EamWeekInspectionDetail::getPlanInspectionDate, DateUtils.getFirstDayOfWeek(eamInspectionOrderRequest.getInspectionDate()), DateUtils.getLastDayOfWeek(eamInspectionOrderRequest.getInspectionDate())); + queryWrapper.orderByAsc(EamWeekInspectionDetail::getItemCode); + List<EamWeekInspectionDetail> eamWeekInspectionDetailList = eamWeekInspectionDetailService.list(queryWrapper); + if (CollectionUtil.isEmpty(eamWeekInspectionDetailList)) { + List<EamMaintenanceStandardDetail> maintenanceStandardDetailList = eamMaintenanceStandardDetailService.list(new LambdaQueryWrapper<EamMaintenanceStandardDetail>().eq(EamMaintenanceStandardDetail::getStandardId, eamInspectionOrderRequest.getStandardId()).eq(EamMaintenanceStandardDetail::getItemCategory, InspectionItemCategroyEnum.WEEK_INSPECTION.name())); + if (CollectionUtils.isNotEmpty(maintenanceStandardDetailList)) { + List<EamWeekInspectionDetail> weekInspectionDetailList = maintenanceStandardDetailList.stream().map(EamWeekInspectionDetail::new).collect(Collectors.toList()); + weekInspectionDetailList.forEach(weekInspectionDetail -> { + weekInspectionDetail.setStandardId(eamInspectionOrderRequest.getStandardId()); + // TODO 鍛ㄧ偣妫�鏃ユ湡 + weekInspectionDetail.setPlanInspectionDate(eamInspectionOrderRequest.getInspectionDate()); + }); + eamWeekInspectionDetailService.saveBatch(weekInspectionDetailList); + } + } } - if (StrUtil.isNotBlank(eamInspectionOrderRequest.getOperator())) { - triggerProcess(eamInspectionOrder); - } + +// if (StrUtil.isNotBlank(eamInspectionOrderRequest.getOperator())) { +// triggerProcess(eamInspectionOrder); +// } return true; } @@ -196,9 +217,9 @@ if (equipment == null) { return false; } else { - eamInspectionOrder.setEquipmentId(equipment.getEquipmentCode()); + eamInspectionOrder.setEquipmentId(equipment.getId()); } - flowCommonService.initActBusiness("宸ュ崟鍙�: " + eamInspectionOrder.getOrderNum() + ";璁惧缂栧彿: " + eamInspectionOrder.getEquipmentId() + ";瀹夎浣嶇疆: " + equipment.getInstallationPosition(), + flowCommonService.initActBusiness("宸ュ崟鍙�: " + eamInspectionOrder.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + (equipment.getInstallationPosition() == null ? "" : ";瀹夎浣嶇疆: " + equipment.getInstallationPosition()), eamInspectionOrder.getId(), "IEamInspectionOrderService", "eam_inspection", null); Map<String, Object> variables = new HashMap<>(); variables.put("dataId", eamInspectionOrder.getId()); @@ -226,16 +247,6 @@ eamInspectionOrder.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); } super.updateById(eamInspectionOrder); -// //澶勭悊鏄庣粏鏁版嵁 -// if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableDetailList())) { -// eamInspectionOrderRequest.getTableDetailList().forEach(tableDetail -> { -// tableDetail.setOrderId(eamInspectionOrder.getId()); -// tableDetail.setCreateTime(new Date()); -// }); -// //鍒犻櫎鏄庣粏 -// eamInspectionOrderDetailService.remove(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", eamInspectionOrder.getId())); -// eamInspectionOrderDetailService.saveBatch(eamInspectionOrderRequest.getTableDetailList()); -// } return true; } @@ -249,7 +260,7 @@ @Transactional(rollbackFor = Exception.class) public boolean takeInspectionOrder(String id) { LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - if(user == null || !BusinessCodeConst.PCR0001.equals(user.getPost())) { + if (user == null || !BusinessCodeConst.PCR0001.equals(user.getPost())) { throw new JeecgBootException("涓嶆槸鎿嶄綔宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒"); } EamInspectionOrder eamInspectionOrder = this.getById(id); @@ -394,27 +405,19 @@ Map<String, Object> values = new HashMap<>(); if (InspectionStatus.UNDER_INSPECTION.name().equals(order.getInspectionStatus()) && user.getUsername().equals(order.getOperator())) { // 鐐规浜虹偣妫�缁撴潫 -// String manager = Optional.ofNullable(iEamEquipmentService.getById(order.getEquipmentId())) -// .map(EamEquipment::getEquipmentManager) -// .orElse(null); -// if (manager == null) { -// throw new IllegalArgumentException("璁惧绠$悊鍛樻湭閰嶇疆"); -// } -// List<String> usernameList = Collections.singletonList(manager); values.put("dataId", order.getId()); values.put("organization", "鐐规浜虹偣妫�缁撴潫"); values.put("comment", "鐐规浜虹偣妫�缁撴潫"); -// values.put("NextAssignee", usernameList); request.setComment("鐐规浜虹偣妫�缁撴潫"); } else { - // 鐝粍闀跨‘璁� + // 缁翠慨宸ョ‘璁� values.put("dataId", order.getId()); values.put("organization", request.getConfirmComment()); values.put("comment", request.getConfirmComment()); values.put("confirmation", request.getConfirmDealType()); request.setComment(request.getConfirmComment()); if ("2".equals(request.getConfirmDealType())) { - // 鐝粍闀块┏鍥� + // 缁翠慨宸ラ┏鍥� List<String> usernames = new ArrayList<>(); usernames.add(order.getOperator()); order.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); @@ -430,18 +433,14 @@ // 鐐规瀹屾垚 order.setInspectionStatus(InspectionStatus.WAIT_CONFIRM.name()); order.setOperateTime(new Date()); -// if (CollectionUtil.isNotEmpty(request.getFileList())) { -// List<FileUploadResult> fileUploadResultList = request.getFileList(); -// ObjectMapper mapper = new ObjectMapper(); -// try { -// String referenceFile = mapper.writeValueAsString(fileUploadResultList); -// order.setImageFiles(referenceFile); -// } catch (JsonProcessingException e) { -// log.error("JSON杞崲澶辫触锛�" + e.getMessage(), e); -// } -// } 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()); + } } else if (InspectionStatus.WAIT_CONFIRM.name().equals(order.getInspectionStatus()) && StrUtil.isNotEmpty(request.getConfirmDealType())) { // 鐝粍闀跨‘璁や换鍔� order.setInspectionStatus(InspectionStatus.COMPLETE.name()); @@ -545,13 +544,13 @@ } @Override - public List<InspectionVo> findInspectionResult(String equipmentId,String itemDemand,String yearMonth) { - return this.baseMapper.findInspectionResult(equipmentId,itemDemand,yearMonth); + 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); + public List<InspectionVo> findInspectionUser(String equipmentId, String yearMonth) { + return this.baseMapper.findInspectionUser(equipmentId, yearMonth); } @Override -- Gitblit v1.9.3