From edc00f6fbafa9bb74f736e47cafd000fb33ef4f1 Mon Sep 17 00:00:00 2001 From: zhanghl <253316343@qq.com> Date: 星期一, 28 四月 2025 20:39:00 +0800 Subject: [PATCH] 气体管路 --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java | 77 +++++++++++++++++++++++++++++--------- 1 files changed, 58 insertions(+), 19 deletions(-) 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 bfc7309..c0cbf3a 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 @@ -1,6 +1,5 @@ package com.aps.core.service.impl; -import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.uuid.IdUtils; @@ -11,6 +10,7 @@ import com.aps.core.mapper.ApsGasPipingRouteStatMapper; import com.aps.core.service.IApsGasMaterialUsageService; import com.aps.core.service.IApsGasPipingRouteStatService; +import com.aps.core.service.IApsStandardProcessService; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.*; @@ -25,7 +25,6 @@ import java.math.BigDecimal; import java.math.RoundingMode; -import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -55,6 +54,9 @@ @Autowired private IApsGasMaterialUsageService apsGasMaterialUsageService; + + @Autowired + private IApsStandardProcessService apsStandardProcessService; /** * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻 @@ -187,7 +189,7 @@ LocalDateTime previousProcessPlanStartDay = apsProcessRoutes.get(i - 1).getProcessPlanStartDay().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); long seconds = apsGasPipingRouteStatList.get(i - 1).getProcessTotalTime().multiply(new BigDecimal(60)).multiply(new BigDecimal(60)).longValue(); LocalDateTime currentProcessPlanStartDay = previousProcessPlanStartDay.plusSeconds(seconds); - apsGasPipingRouteStat.setProcessPlanStartDay(Date.from(Timestamp.valueOf(currentProcessPlanStartDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).toInstant())); + apsGasPipingRouteStat.setProcessPlanStartDay(Date.from(currentProcessPlanStartDay.atZone(ZoneId.systemDefault()).toInstant())); } //鎻掑叆 骞� 鏈� 鏃� SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); @@ -201,9 +203,9 @@ // apsGasMaterialUsage.setItemNumber(apsGasPipingPlan.getItemNumber()); // apsGasMaterialUsage.setProcessName(apsProcessRoute.getProcessName()); // List<ApsGasMaterialUsage> apsGasMaterialUsageList = apsGasMaterialUsageService.selectApsGasMaterialUsageList(apsGasMaterialUsage); - apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity())); +// apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity())); //宸ュ簭鎬荤敤閲� = 鏍囧噯鐢ㄩ噺*鐢熶骇鏁伴噺 - apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity())); +// apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity())); apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate()); apsGasPipingRouteStat.setCreateBy("auto"); apsGasPipingRouteStat.setBatchNumber(batchNum); @@ -233,11 +235,31 @@ public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) { JSONObject result = new JSONObject(); HashSet<String> startPlanTimeSet = new HashSet<>(); - JSONArray processData = new JSONArray(); + YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate()); + int daysInMonth = yearMonth.lengthOfMonth(); + //宸ュ簭鍒嗙粍缁熻 + 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<>(); - List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(new ApsGasPipelineCapacityPlan()); + ApsGasPipelineCapacityPlan searchCapacityPlan = new ApsGasPipelineCapacityPlan(); + searchCapacityPlan.setMajor(apsGasPipingRouteStat.getMajor().equals("gas")?"姘旀煖":"绠¤矾"); + if("day".equals(apsGasPipingRouteStat.getSearchType())){ + searchCapacityPlan.setYear(yearMonth.getYear()+""); + searchCapacityPlan.setMonth(yearMonth.getMonthValue()+""); + }else if("month".equals(apsGasPipingRouteStat.getSearchType())){ + searchCapacityPlan.setYear(yearMonth.getYear()+""); + } + List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(searchCapacityPlan); apsGasPipelineCapacityPlanList.forEach(apsGasPipelineCapacityPlan -> { apsGasPipingPlanMap.put(apsGasPipelineCapacityPlan.getProcessName(),apsGasPipelineCapacityPlan); }); @@ -245,8 +267,6 @@ DateTimeFormatter formatter = null; List<ApsGasPipingRouteStat> apsGasPipingRouteStats; SimpleDateFormat simpleDateFormat = null; - YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate()); - int daysInMonth = yearMonth.lengthOfMonth(); apsGasPipingRouteStat.setSearchStartDate(apsGasPipingRouteStat.getSearchStartDate()+"-01 00:00:00"); apsGasPipingRouteStat.setSearchEndDate(apsGasPipingRouteStat.getSearchEndDate()+"-"+ daysInMonth +" 23:59:59"); if("day".equals(apsGasPipingRouteStat.getSearchType())){ @@ -259,9 +279,6 @@ apsGasPipingRouteStats = apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat); //鏍规嵁寮�宸ユ棩杩涜鍗囧簭鎺掑簭 apsGasPipingRouteStats.sort((a, b)->a.getProcessPlanStartDay().compareTo(b.getProcessPlanStartDay())); - //宸ュ簭鍒嗙粍缁熻 - HashMap<String, List<ApsResourceDateStat>> processMap = new HashMap<>(); - List<HashMap<String, List<ApsResourceDateStat>>> processList = new ArrayList<>(); //宸ュ簭寮�宸ユ棩鏈� String planStartDate = ""; //缁熻鎵�鏈夊伐搴忓搴旂殑寮�宸ユ椂闂� @@ -298,7 +315,11 @@ startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString()); if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){ ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString()); - apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum():new BigDecimal(0)); + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum():new BigDecimal(0)); + }else{ + apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getDayProduceAllNum():new BigDecimal(0)); + } apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes().add(apsResourceDateStat.getRequireTimes())); if(apsResourceDateStatTemp.getDesignTimes().compareTo(BigDecimal.ZERO) > 0){ apsResourceDateStat.setCapacityLoad(apsResourceDateStat.getRequireTimes() @@ -318,19 +339,37 @@ dayMap.forEach((key, value) -> { tempList.add(value); }); -// processMap.put(processName, tempList); HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>(); temp.put(processName, tempList); processList.add(temp); }); -// for (String key : processMap.keySet()) { -// HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>(); -// temp.put(key, processMap.get(key)); -// 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(); + if(apsResourceDateStatList.size()<=0){ + for(String tempTime:sortedStartPlanTimeList){ + ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat(); + apsResourceDateStat.setPlanDay(LocalDate.parse(tempTime, formatter)); + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(entry.getKey())!=null?apsGasPipingPlanMap.get(entry.getKey()).getMonthProduceAllNum():new BigDecimal(0)); + }else{ + apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(entry.getKey())!=null?apsGasPipingPlanMap.get(entry.getKey()).getDayProduceAllNum():new BigDecimal(0)); + } + apsResourceDateStat.setRequireTimes(new BigDecimal(0)); + apsResourceDateStat.setCapacityLoad(new BigDecimal(0)); + apsResourceDateStat.setResourceName(entry.getKey()); + apsResourceDateStat.setResourceGroupName(entry.getKey()); + apsResourceDateStatList.add(apsResourceDateStat); + } + temp.put(entry.getKey(), apsResourceDateStatList); + processList.set(i, temp); + } + } + } result.put("planTable", processList); result.put("planTitle", sortedStartPlanTimeList); } catch (Exception e) { -- Gitblit v1.9.3