From 98acd3249e64f5366f0dc145f0b896a8f9a0183a Mon Sep 17 00:00:00 2001 From: “linengliang” <vanSuperEnergy@163.com> Date: 星期三, 13 十二月 2023 11:05:48 +0800 Subject: [PATCH] ABC评分系统修改 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/StreamController.java | 99 +++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 91 insertions(+), 8 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/StreamController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/StreamController.java index f97ca3c..e329163 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/StreamController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/StreamController.java @@ -13,8 +13,8 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.api.vo.Result; -import org.jeecg.modules.eam.entity.Equipment; -import org.jeecg.modules.eam.service.IEamEquipmentService; +import org.jeecg.modules.eam.entity.*; +import org.jeecg.modules.eam.service.*; import org.jeecg.modules.eam.vo.ButtonVo; import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.service.*; @@ -28,15 +28,11 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.ModelAndView; +import java.time.LocalDate; +import java.time.ZoneId; import java.util.*; import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.eam.entity.StreamOperation; -import org.jeecg.modules.eam.entity.ABCAssessment; -import org.jeecg.modules.eam.entity.Stream; -import org.jeecg.modules.eam.service.IStreamService; -import org.jeecg.modules.eam.service.IStreamOperationService; -import org.jeecg.modules.eam.service.IABCAssessmentService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.aspect.annotation.AutoLog; @@ -93,6 +89,23 @@ @Autowired private IEamEquipmentService equipmentService; + + @Autowired + private IdentityService sysIdentityService; + + @Autowired + private IEquipmentMaintenancePlanDetailService planDetailService; + + @Autowired + private IEquipmentMaintenancePlanService planService; + + @Autowired + private IMaintenanceStandardService maintenanceStandardService; + @Autowired + private IEquipmentUpdateInfoService updateInfoService; + + + @@ -583,12 +596,82 @@ List<SysDictItem> nodes = sysDictItemService.selectItemsByMainId(streamNode.getId()); if(buttonVo.getNodeSort()+1==nodes.size()){ List<ABCAssessment> abcAssessments = aBCAssessmentService.selectByMainId(buttonVo.getStreamId()); + EquipmentMaintenancePlan plan = new EquipmentMaintenancePlan(); + UUID uuid = UUID.randomUUID(); + long mostSignificantBits = uuid.getMostSignificantBits(); + long leastSignificantBits = uuid.getLeastSignificantBits(); + + // 灏嗘渶楂樹綅鍜屾渶浣庝綅鍙栧嚭锛岀劧鍚庡悎骞朵负涓�涓猯ong绫诲瀷鐨勫�� + long combinedBits = mostSignificantBits ^ leastSignificantBits; + + // 灏嗗悎骞跺悗鐨刲ong鍊艰浆鎹负16杩涘埗瀛楃涓� + String hexString = Long.toHexString(combinedBits); + String planNum = sysIdentityService.getNumByTypeAndLength("",4); + plan.setId(hexString); + plan.setNum(planNum); + plan.setType("3"); + plan.setStatus("created"); + plan.setCreateReason("鍥燗BC鏍囪瘑浠嶣鎴朇鍙樻洿涓篈鑰屽鑷翠笅娆′笁淇濇椂闂磋繃鏈燂紝灏辫繖浜涜澶囩敓鎴愮殑涓存椂淇濆吇璁″垝"); + List<EquipmentMaintenancePlanDetail> details = new ArrayList<>(); for(ABCAssessment abcAssessment:abcAssessments){ Equipment equipment = equipmentService.getById(abcAssessment.getEquipmentId()); + String oldStandard = equipment.getEquipmentImportanceId(); + String newStandard = abcAssessment.getFinalStandard(); + LocalDate currentDate = LocalDate.now(); + + // 灏嗗綋鍓嶆棩鏈熷姞涓�澶� + LocalDate nextDay = currentDate.plusDays(1); + LocalDate nextMonth = currentDate.plusMonths(1); + + // 灏哃ocalDate杞崲涓篋ate + Date currentDateAsDate = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); + Date nextDayAsDate =Date.from(nextDay.atStartOfDay(ZoneId.systemDefault()).toInstant()); + Date nextMonthAsDate = Date.from(nextMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()); + Date needingDate = equipment.getNextThirdMaintenanceTime(); + Boolean a = StringUtils.isNotBlank(oldStandard); + Boolean b = oldStandard.equals("B")||oldStandard.equals("C"); + Boolean c = newStandard.equals("A"); + Boolean d = ObjectUtils.isNotNull(needingDate)&&needingDate.compareTo(currentDateAsDate)<0; + if(a&&b&&c&&d){ + EquipmentMaintenancePlanDetail equipmentMaintenancePlanDetail = new EquipmentMaintenancePlanDetail(); + equipmentMaintenancePlanDetail.setPlanId(hexString); + equipmentMaintenancePlanDetail.setEquipmentId(equipment.getId()); + equipmentMaintenancePlanDetail.setPlanStartTime(nextDayAsDate); + equipmentMaintenancePlanDetail.setPlanEndTime(nextMonthAsDate); + MaintenanceStandard maintenanceStandard = maintenanceStandardService.getOne(new QueryWrapper<MaintenanceStandard>() + .eq("equipment_id",equipment.getId()) + .eq("maintenance_type","3") + .eq("version_status","2") + .eq("del_flag",0),false); + if(ObjectUtils.isNotNull(maintenanceStandard)){ + equipmentMaintenancePlanDetail.setStandardId(maintenanceStandard.getId()); + details.add(equipmentMaintenancePlanDetail); + } + } equipment.setEquipmentImportanceId(abcAssessment.getFinalStandard()); + equipment.setStandardA(abcAssessment.getStandardA()); + equipment.setStandardB(abcAssessment.getStandardB()); + equipment.setStandardC(abcAssessment.getStandardC()); + equipment.setStandardD(abcAssessment.getStandardD()); + equipment.setStandardE(abcAssessment.getStandardE()); + equipment.setStandardF(abcAssessment.getStandardF()); equipmentService.updateById(equipment); + EquipmentUpdateInfo equipmentUpdateInfo = new EquipmentUpdateInfo(); + equipmentUpdateInfo.setOldAbcTag(oldStandard); + equipmentUpdateInfo.setNewAbcTag(newStandard); + equipmentUpdateInfo.setEquipmentId(equipment.getId()); + equipmentUpdateInfo.setUpdatePerson(user.getId()); + equipmentUpdateInfo.setUpdateType("ABC"); + equipmentUpdateInfo.setUpdateDate(currentDateAsDate); + updateInfoService.save(equipmentUpdateInfo); + + } + if(details.size()>0){ + planService.save(plan); + planDetailService.saveBatch(details); } } + SysDictItem nextStreamNodeItem = sysDictItemService.getOne(new QueryWrapper<SysDictItem>().eq("dict_id",streamNode.getId()).eq("sort_order",buttonVo.getNodeSort()+1),false); return getResult(buttonVo, user, streamOperations, nextStreamNodeItem); } -- Gitblit v1.9.3