From 097a230fea54afc1f0a21a16e5e9f38d45d0573e Mon Sep 17 00:00:00 2001 From: hongjli <3117313295@qq.com> Date: 星期三, 14 五月 2025 10:29:48 +0800 Subject: [PATCH] 钣金计划(管理&大表)接口字段变更,管路、气柜产能负载按月统计工厂拆分,气柜管路产能规划增加工厂查询字段 --- aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml | 4 aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java | 289 +++++++++++++++++++++++++++++++++++++++++ aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java | 3 aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml | 2 aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopPlanStat.java | 56 ++++++++ aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlan.java | 10 + aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsResourceDateStat.java | 9 + 7 files changed, 369 insertions(+), 4 deletions(-) diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java index 36b831d..a803376 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java @@ -123,6 +123,9 @@ @Excel(name = "鎵规鍙�") private String batchNumber; + /** 宸ュ巶 */ + private String plant; + @Transient private String searchStartDate; diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlan.java b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlan.java index 087713f..1f6ffea 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlan.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlan.java @@ -198,6 +198,16 @@ @Excel(name = "鐢熶骇鍩哄湴") private String productionBase; + /** 宸ュ崟瀹℃牳鏃堕棿 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "宸ュ崟瀹℃牳鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date approveOn; + + /** 宸ュ崟寮�宸ユ椂闂� */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "宸ュ崟寮�宸ユ椂闂�", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date startWorkDate; + /** 鏈尮閰嶇殑鐢熶骇鏁伴噺*/ private BigDecimal unmatchedQuantity; /** 涓撲笟褰掑睘*/ diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopPlanStat.java b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopPlanStat.java index c172b1d..bd68f2a 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopPlanStat.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateProcessShopPlanStat.java @@ -8,6 +8,7 @@ import java.io.Serial; import java.io.Serializable; import java.math.BigDecimal; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -27,10 +28,25 @@ @Excel(name = "涓讳欢鏂欏彿") private String mainPartNumber; + /** 涓讳欢瀹㈡埛 */ + @Schema(description = "涓讳欢瀹㈡埛锛屾潵鑷狤RP", type = "String") + @Excel(name = "涓讳欢瀹㈡埛") + private String customer; + + /** 涓讳欢璁㈠崟浜ゆ湡 */ + @Schema(description = "涓讳欢璁㈠崟浜ゆ湡锛屾潵鑷狤RP", type = "String") + @Excel(name = "涓讳欢璁㈠崟浜ゆ湡") + private BigInteger mainOrderDelivery; + /** 涓氬姟绫诲瀷 */ @Schema(description = "涓氬姟绫诲瀷", type = "String") @Excel(name = "涓氬姟绫诲瀷") private String businessType; + + /** 鐣彿 */ + @Schema(description = "闇�姹傝拷婧彿锛岀敱APS浜х敓", type = "String") + @Excel(name = "鐣彿") + private String designation; /** 鍗曟嵁鍙� */ @Schema(description = "鍗曟嵁鍙�", type = "String") @@ -73,12 +89,52 @@ @Excel(name = "鐢熶骇鏁伴噺") private BigDecimal productionQuantity; + /** 宸ュ崟鍒涘缓鏃堕棿 */ + @Schema(description = "宸ュ崟鍒涘缓鏃堕棿锛屾潵鑷狤RP", type = "String") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "宸ュ崟鍒涘缓鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date orderCreateTime; + + /** 宸ュ崟瀹℃牳鏃堕棿 */ + @Schema(description = "宸ュ崟瀹℃牳鏃堕棿锛屾潵鑷狤RP", type = "String") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "宸ュ崟瀹℃牳鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date approveOn; + + /** 宸ュ崟寮�宸ユ椂闂� */ + @Schema(description = "宸ュ崟寮�宸ユ椂闂达紝鏉ヨ嚜ERP", type = "String") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "宸ュ崟寮�宸ユ椂闂�", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date startWorkDate; + + /** 鍐嶆纭瀹屽伐鏃堕棿 */ + @Schema(description = "鍐嶆纭瀹屽伐鏃堕棿锛屾潵鑷狝PS", type = "String") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "鍐嶆纭瀹屽伐鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date workOrderConfirmTime; + /** 璁″垝瀹屽伐鏃� */ @Schema(description = "璁″垝瀹屽伐鏃�", type = "String") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "璁″垝瀹屽伐鏃�", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date planEndDay; + /** 鐗堟湰鍙� */ + @Schema(description = "鐢熶骇宸ュ巶锛屾潵鑷狤RP", type = "String") + @Excel(name = "鐢熶骇宸ュ巶") + private String productionBase; + + /** 鐗堟湰鍙� */ + @Schema(description = "榻愬鐘跺喌锛屾潵鑷狤RP", type = "String") + @Excel(name = "榻愬鐘跺喌") + private String kittingCondition; + + /** 璁″垝榻愬鏃堕棿 */ + @Schema(description = "璁″垝榻愬鏃堕棿锛屾潵鑷狤RP", type = "String") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "璁″垝榻愬鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date planKittingTime; + /** 宸ュ簭鍙� */ @Excel(name = "宸ュ簭鍙�") private String processNumber; diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsResourceDateStat.java b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsResourceDateStat.java index b2c00e9..c5fda2d 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsResourceDateStat.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsResourceDateStat.java @@ -57,10 +57,19 @@ this.resourceGroupName = resourceGroupName; } + public String getPlant() { + return plant; + } + + public void setPlant(String plant) { + this.plant = plant; + } + private LocalDate planDay; private String resourceName; private BigDecimal requireTimes; private BigDecimal designTimes; private BigDecimal capacityLoad; private String resourceGroupName; + private String plant; } diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java index 3a71bcf..571b44a 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java @@ -32,6 +32,7 @@ import java.time.*; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.stream.Collectors; import static java.util.stream.Collectors.groupingBy; @@ -251,8 +252,7 @@ return true; } - @Override - public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) { + public JSONObject getCapacityPlanDataBackup(ApsGasPipingRouteStat apsGasPipingRouteStat) { JSONObject result = new JSONObject(); YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate()); int daysInMonth = yearMonth.lengthOfMonth(); @@ -422,6 +422,291 @@ } @Override + public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) { + JSONObject result = new JSONObject(); + YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate()); + int daysInMonth = yearMonth.lengthOfMonth(); + LinkedHashSet<String> startPlanTimeSet = new LinkedHashSet<>(); + //宸ュ簭鍒嗙粍缁熻 + LinkedHashMap<String, List<ApsResourceDateStat>> processMap = new LinkedHashMap<>(); + List<HashMap<String, List<ApsResourceDateStat>>> processList = new ArrayList<>(); + try { + //鑾峰彇鏍囧噯宸ュ簭鍚嶇О + ApsStandardProcess apsStandardProcess = new ApsStandardProcess(); + apsStandardProcess.setMajor(apsGasPipingRouteStat.getMajor().equals("gas")?"姘旀煖":"绠¤矾"); + List<ApsStandardProcess> apsStandardProcessList = apsStandardProcessService.selectApsStandardProcessList(apsStandardProcess); + apsStandardProcessList.sort((a, b)->a.getProcessName().compareTo(b.getProcessName())); + for(ApsStandardProcess temp:apsStandardProcessList){ + processMap.put(temp.getProcessName(), new ArrayList<ApsResourceDateStat>()); + } + //鑾峰彇宸ュ簭璁″垝浜ц兘鏁版嵁 + HashMap<String, ApsGasPipelineCapacityPlan> apsGasPipingPlanMap = new HashMap<>(); + ApsGasPipelineCapacityPlan searchCapacityPlan = new ApsGasPipelineCapacityPlan(); + searchCapacityPlan.setMajor(apsGasPipingRouteStat.getMajor().equals("gas")?"姘旀煖":"绠¤矾"); + if("day".equals(apsGasPipingRouteStat.getSearchType())){ + searchCapacityPlan.setYear(yearMonth.getYear()+""); + searchCapacityPlan.setMonth(yearMonth.getMonthValue()+""); + for(int i=1;i<=daysInMonth;i++){ + startPlanTimeSet.add(yearMonth +"-"+ (i<10?"0"+i:i)); + } + }else if("month".equals(apsGasPipingRouteStat.getSearchType())){ + searchCapacityPlan.setYear(yearMonth.getYear()+""); + YearMonth start = YearMonth.of(Integer.parseInt(apsGasPipingRouteStat.getSearchStartDate().split("-")[0]), Integer.parseInt(apsGasPipingRouteStat.getSearchStartDate().split("-")[1])); + YearMonth end = YearMonth.of(Integer.parseInt(apsGasPipingRouteStat.getSearchEndDate().split("-")[0]), Integer.parseInt(apsGasPipingRouteStat.getSearchEndDate().split("-")[1])); + List<String> yearMonths = getYearMonthsInRange(start, end); + startPlanTimeSet.addAll(yearMonths); + } + List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(searchCapacityPlan); + apsGasPipelineCapacityPlanList.forEach(apsGasPipelineCapacityPlan -> { + String key = apsGasPipelineCapacityPlan.getProcessName() + "-" + apsGasPipelineCapacityPlan.getOrgCode() + "-" + apsGasPipelineCapacityPlan.getYear() + "-" + (Integer.parseInt(apsGasPipelineCapacityPlan.getMonth())<10?"0"+apsGasPipelineCapacityPlan.getMonth():apsGasPipelineCapacityPlan.getMonth()); + apsGasPipingPlanMap.put(key, apsGasPipelineCapacityPlan); + }); + //璁$畻鏃ヤ骇鑳芥暟鎹� + DateTimeFormatter formatter = null; + List<ApsGasPipingRouteStat> apsGasPipingRouteStats; + SimpleDateFormat simpleDateFormat = null; + apsGasPipingRouteStat.setSearchStartDate(apsGasPipingRouteStat.getSearchStartDate()+"-01 00:00:00"); + apsGasPipingRouteStat.setSearchEndDate(apsGasPipingRouteStat.getSearchEndDate()+"-"+ daysInMonth +" 23:59:59"); + if("day".equals(apsGasPipingRouteStat.getSearchType())){ + formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + }else if("month".equals(apsGasPipingRouteStat.getSearchType())){ + formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + } + ApsGasPipingRouteStat queryStatParam = new ApsGasPipingRouteStat(); + BeanUtils.copyProperties(apsGasPipingRouteStat,queryStatParam); + queryStatParam.setMajor(""); + apsGasPipingRouteStats = apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(queryStatParam); + //鏍规嵁寮�宸ユ棩杩涜鍗囧簭鎺掑簭 + apsGasPipingRouteStats.sort((a, b)->a.getProcessPlanStartDay().compareTo(b.getProcessPlanStartDay())); + //宸ュ簭寮�宸ユ棩鏈� + String planStartDate = ""; + //缁熻鎵�鏈夊伐搴忓搴旂殑寮�宸ユ椂闂� + for (ApsGasPipingRouteStat apsGasPipingRouteStatTemp : apsGasPipingRouteStats) { + if(processMap.containsKey(apsGasPipingRouteStatTemp.getProcessName())){ + planStartDate = simpleDateFormat.format(apsGasPipingRouteStatTemp.getProcessPlanStartDay()); + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + planStartDate = planStartDate+"-01"; + } + ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat(); + apsResourceDateStat.setPlanDay(LocalDate.parse(planStartDate, formatter)); + apsResourceDateStat.setResourceName(apsGasPipingRouteStatTemp.getProcessName()); + apsResourceDateStat.setPlant(apsGasPipingRouteStatTemp.getPlant()); + //鏌ヨ姘旀煖绠¤矾浜ц兘瑙勫垝琛� + String capacityKey = apsGasPipingRouteStatTemp.getProcessName() + "-" + apsGasPipingRouteStatTemp.getPlant() + "-" + planStartDate.substring(0, 7); + apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(capacityKey)!=null?apsGasPipingPlanMap.get(capacityKey).getDayProduceAllNum():new BigDecimal(0)); + //鏌ヨ鏂欏彿宸ュ簭浜ц兘琛� + apsResourceDateStat.setRequireTimes(apsGasPipingRouteStatTemp.getProcessTotalTime()); + if(apsResourceDateStat.getDesignTimes().compareTo(BigDecimal.ZERO)>0){ + apsResourceDateStat.setCapacityLoad(apsResourceDateStat.getRequireTimes() + .divide(apsResourceDateStat.getDesignTimes(), 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100))); + }else{ + apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(0)); + } + + List<ApsResourceDateStat> apsResourceDateStatList = processMap.get(apsGasPipingRouteStatTemp.getProcessName()); + apsResourceDateStatList.add(apsResourceDateStat); + processMap.put(apsGasPipingRouteStatTemp.getProcessName(), apsResourceDateStatList); + } + } + //鑱氬悎姣忛亾宸ュ簭鐨勫紑宸ユ椂闂村拰浜ц兘 + for (Map.Entry<String, List<ApsResourceDateStat>> entry : processMap.entrySet()) { + String processName = entry.getKey(); + List<ApsResourceDateStat> apsResourceDateStatList = entry.getValue(); + + if("day".equals(apsGasPipingRouteStat.getSearchType())) { + // 鎸夊ぉ缁熻鏃朵繚鎸佸師鏈夐�昏緫锛屼笉鎸夊伐鍘傚垎缁� + LinkedHashMap<String, ApsResourceDateStat> dayMap = new LinkedHashMap<>(); + + // 棣栧厛锛屼负鎵�鏈夋棩鏈熷垱寤哄垵濮嬭褰� + for(String date : startPlanTimeSet) { + ApsResourceDateStat initStat = new ApsResourceDateStat(); + initStat.setPlanDay(LocalDate.parse(date, formatter)); + initStat.setResourceName(processName); + initStat.setResourceGroupName(processName); + initStat.setRequireTimes(new BigDecimal(0)); + String capacityKey = processName + "-" + date.substring(0,7); + initStat.setDesignTimes(apsGasPipingPlanMap.get(capacityKey)!=null?apsGasPipingPlanMap.get(capacityKey).getDayProduceAllNum():new BigDecimal(0)); + initStat.setCapacityLoad(new BigDecimal(0)); + dayMap.put(date, initStat); + } + + // 鐒跺悗澶勭悊瀹為檯鏁版嵁 + for (ApsResourceDateStat apsResourceDateStat : apsResourceDateStatList) { + String dateKey = apsResourceDateStat.getPlanDay().toString(); + if(dayMap.containsKey(dateKey)){ + ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(dateKey); + String capacityKey = processName + "-" + dateKey.substring(0,7); + apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(capacityKey)!=null?apsGasPipingPlanMap.get(capacityKey).getDayProduceAllNum():new BigDecimal(0)); + apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes().add(apsResourceDateStat.getRequireTimes())); + if(apsResourceDateStatTemp.getDesignTimes().compareTo(BigDecimal.ZERO) > 0){ + apsResourceDateStatTemp.setCapacityLoad(apsResourceDateStatTemp.getRequireTimes() + .divide(apsResourceDateStatTemp.getDesignTimes(), 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100))); + }else{ + apsResourceDateStatTemp.setCapacityLoad(new BigDecimal(0)); + } + apsResourceDateStatTemp.setResourceGroupName(processName); + apsResourceDateStatTemp.setPlanDay(apsResourceDateStat.getPlanDay()); + dayMap.put(dateKey, apsResourceDateStatTemp); + } + } + + List<ApsResourceDateStat> tempList = new ArrayList<>(dayMap.values()); + HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>(); + temp.put(processName, tempList); + processList.add(temp); + } else { + // 鎸夋湀缁熻鏃舵墠鎸夊伐鍘傚垎缁� + if (apsResourceDateStatList.isEmpty()) { + // 浠庝骇鑳借鍒掓暟鎹腑鑾峰彇鎵�鏈夌殑宸ュ巶 + Set<String> plants = apsGasPipelineCapacityPlanList.stream() + .filter(plan -> plan.getProcessName().equals(processName)) + .map(ApsGasPipelineCapacityPlan::getOrgCode) + .filter(orgCode -> orgCode != null && !orgCode.trim().isEmpty()) + .collect(Collectors.toSet()); + + // 濡傛灉娌℃湁鎵惧埌浠讳綍鏈夋晥宸ュ巶锛岃烦杩囪繖涓伐搴� + if (plants.isEmpty()) { + continue; + } + + // 涓烘瘡涓伐鍘傚垱寤虹┖璁板綍 + for (String plant : plants) { + LinkedHashMap<String, ApsResourceDateStat> dayMap = new LinkedHashMap<>(); + // 涓烘瘡涓湀浠藉垱寤鸿褰� + for(String monthDate : startPlanTimeSet) { + String tempTime = monthDate + "-01"; + ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat(); + apsResourceDateStat.setPlanDay(LocalDate.parse(tempTime, formatter)); + apsResourceDateStat.setResourceName(processName); + apsResourceDateStat.setResourceGroupName(processName + "-" + plant); + apsResourceDateStat.setPlant(plant); + apsResourceDateStat.setRequireTimes(new BigDecimal(0)); + String capacityKey = processName + "-" + plant + "-" + monthDate; + apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(capacityKey)!=null?apsGasPipingPlanMap.get(capacityKey).getMonthProduceAllNum():new BigDecimal(0)); + apsResourceDateStat.setCapacityLoad(new BigDecimal(0)); + dayMap.put(monthDate, apsResourceDateStat); + } + List<ApsResourceDateStat> tempList = new ArrayList<>(dayMap.values()); + HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>(); + temp.put(processName + "-" + plant, tempList); + processList.add(temp); + } + } else { + // 鎸夊伐鍘傚垎缁勶紝骞惰繃婊ゆ帀plant涓簄ull鎴栫┖瀛楃涓茬殑璁板綍 + Map<String, List<ApsResourceDateStat>> plantGroups = apsResourceDateStatList.stream() + .filter(stat -> stat.getPlant() != null && !stat.getPlant().trim().isEmpty()) + .collect(groupingBy(ApsResourceDateStat::getPlant)); + + // 濡傛灉杩囨护鍚庢病鏈夋湁鏁堢殑宸ュ巶鏁版嵁锛岃烦杩囪繖涓伐搴� + if (plantGroups.isEmpty()) { + continue; + } + + // 瀵规瘡涓伐鍘傜殑鏁版嵁杩涜澶勭悊 + for (Map.Entry<String, List<ApsResourceDateStat>> plantEntry : plantGroups.entrySet()) { + String plant = plantEntry.getKey(); + // 鍐嶆纭plant涓嶄负绌� + if (plant == null || plant.trim().isEmpty()) { + continue; + } + List<ApsResourceDateStat> plantStats = plantEntry.getValue(); + LinkedHashMap<String, ApsResourceDateStat> dayMap = new LinkedHashMap<>(); + + // 棣栧厛涓烘墍鏈夋湀浠藉垱寤哄垵濮嬭褰� + for(String monthDate : startPlanTimeSet) { + String tempTime = monthDate + "-01"; + ApsResourceDateStat initStat = new ApsResourceDateStat(); + initStat.setPlanDay(LocalDate.parse(tempTime, formatter)); + initStat.setResourceName(processName); + initStat.setResourceGroupName(processName + "-" + plant); + initStat.setPlant(plant); + initStat.setRequireTimes(new BigDecimal(0)); + String capacityKey = processName + "-" + plant + "-" + monthDate; + initStat.setDesignTimes(apsGasPipingPlanMap.get(capacityKey)!=null?apsGasPipingPlanMap.get(capacityKey).getMonthProduceAllNum():new BigDecimal(0)); + initStat.setCapacityLoad(new BigDecimal(0)); + dayMap.put(monthDate, initStat); + } + + // 鐒跺悗澶勭悊瀹為檯鏁版嵁 + for (ApsResourceDateStat stat : plantStats) { + String monthKey = stat.getPlanDay().toString().substring(0, 7); + if (dayMap.containsKey(monthKey)) { + ApsResourceDateStat existingStat = dayMap.get(monthKey); + String capacityKey = processName + "-" + plant + "-" + monthKey; + existingStat.setDesignTimes(apsGasPipingPlanMap.get(capacityKey)!=null?apsGasPipingPlanMap.get(capacityKey).getMonthProduceAllNum():new BigDecimal(0)); + existingStat.setRequireTimes(existingStat.getRequireTimes().add(stat.getRequireTimes())); + if(existingStat.getDesignTimes().compareTo(BigDecimal.ZERO) > 0){ + existingStat.setCapacityLoad(existingStat.getRequireTimes() + .divide(existingStat.getDesignTimes(), 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100))); + } + } + } + + List<ApsResourceDateStat> tempList = new ArrayList<>(dayMap.values()); + HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>(); + temp.put(processName + "-" + plant, tempList); + processList.add(temp); + } + } + } + } + //鎺掑簭鏃堕棿鏍囬 + List<String> sortedStartPlanTimeList = new ArrayList<>(startPlanTimeSet); + Collections.sort(sortedStartPlanTimeList); + for (int i=0;i<processList.size();i++){ + HashMap<String, List<ApsResourceDateStat>> temp = processList.get(i); + for (Map.Entry<String, List<ApsResourceDateStat>> entry : temp.entrySet()){ + List<ApsResourceDateStat> apsResourceDateStatList = entry.getValue(); + String key = entry.getKey(); + List<ApsResourceDateStat> crtList = new ArrayList<>(); + for(String tempTime:sortedStartPlanTimeList) { + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + tempTime += "-01"; + } + LocalDate crtDate = LocalDate.parse(tempTime, formatter); + Optional<ApsResourceDateStat> first = apsResourceDateStatList.stream().filter(x -> x.getPlanDay().equals(crtDate)).findFirst(); + if (first.isPresent()) { + ApsResourceDateStat apsResourceDateStat = first.get(); + crtList.add(apsResourceDateStat); + } else { + ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat(); + apsResourceDateStat.setPlanDay(LocalDate.parse(tempTime, formatter)); + String[] keyParts = key.split("-"); + String processNamePart = keyParts[0]; + String plantPart = keyParts[1]; + String capacityKey = processNamePart + "-" + plantPart + "-" + tempTime.substring(0,7); + if ("month".equals(apsGasPipingRouteStat.getSearchType())) { + apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(capacityKey) != null ? apsGasPipingPlanMap.get(capacityKey).getMonthProduceAllNum() : new BigDecimal(0)); + } else { + apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(capacityKey) != null ? apsGasPipingPlanMap.get(capacityKey).getDayProduceAllNum() : new BigDecimal(0)); + } + apsResourceDateStat.setRequireTimes(new BigDecimal(0)); + apsResourceDateStat.setCapacityLoad(new BigDecimal(0)); + apsResourceDateStat.setResourceName(processNamePart); + apsResourceDateStat.setResourceGroupName(key); + apsResourceDateStat.setPlant(plantPart); + apsResourceDateStatList.add(apsResourceDateStat); + crtList.add(apsResourceDateStat); + } + temp.put(entry.getKey(), crtList); + processList.set(i, temp); + } + } + } + result.put("planTable", processList); + result.put("planTitle", sortedStartPlanTimeList); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + @Override public void exportExcel(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat) { SXSSFWorkbook wb = new SXSSFWorkbook(500); wb.createSheet(); diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml index 16fac43..55a6efc 100644 --- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml @@ -38,7 +38,7 @@ process_plan_start_day, design_times, del_flag, create_by, process_name, create_time, item_number, standard_dosage, process_total_dosage, design_capacity, major, plan_start_year, - plan_start_month, plan_start_day , warning + plan_start_month, plan_start_day , warning, plant from aps_gas_piping_route_stat </sql> diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml index 30ad4ac..9cb4122 100644 --- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml @@ -49,6 +49,8 @@ <result property="professionalAffiliation" column="professional_affiliation" /> <result property="requireId" column="require_id" /> <result property="version" column="version" /> + <result property="approveOn" column="approve_on" /> + <result property="startWorkDate" column="start_work_date" /> </resultMap> <sql id="selectApsPlatePlanVo"> @@ -59,7 +61,7 @@ standby_stock, next_process_deparment, is_suspended, is_outsourcing, account, advanced_materials, advanced_document_number, advanced_requirement_day, is_plan_complete, is_stock_complete, has_turnback, has_risk, std_op, op_status, next_op_name ,unmatched_quantity,professional_affiliation, - require_id, version,production_base, order_create_time + require_id, version,production_base, order_create_time, approve_on, start_work_date from aps_plate_plan </sql> -- Gitblit v1.9.3