From b079a1727af6eeb2ebcfc44190a9b72a454d4f12 Mon Sep 17 00:00:00 2001 From: huangjiayang <5265313@qq.com> Date: 星期五, 25 四月 2025 22:56:52 +0800 Subject: [PATCH] 【ADD】增加气体管路产能统计相关代码 --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java | 472 +++++++++++++++++++++++ aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java | 150 +++++++ aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsGasPipingRouteStatController.java | 130 ++++++ aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java | 11 aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingPlanMapper.xml | 47 ++ aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingPlanMapper.java | 10 aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingPlan.java | 12 aps-modules/aps-core/src/main/resources/mapper/core/ApsProcessRouteMapper.xml | 1 aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java | 77 +++ aps-modules/aps-core/src/main/java/com/aps/core/service/IApsGasPipingRouteStatService.java | 85 ++++ aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml | 173 ++++++++ aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsProcessRouteMapper.java | 1 aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineCapacityPlanServiceImpl.java | 3 13 files changed, 1,166 insertions(+), 6 deletions(-) diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsGasPipingRouteStatController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsGasPipingRouteStatController.java new file mode 100644 index 0000000..8935b4d --- /dev/null +++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsGasPipingRouteStatController.java @@ -0,0 +1,130 @@ +package com.aps.core.controller; + +import com.aps.common.core.utils.poi.ExcelUtil; +import com.aps.common.core.web.controller.BaseController; +import com.aps.common.core.web.domain.AjaxResult; +import com.aps.common.core.web.page.TableDataInfo; +import com.aps.common.log.annotation.Log; +import com.aps.common.log.enums.BusinessType; +import com.aps.common.security.annotation.RequiresPermissions; +import com.aps.core.domain.ApsGasPipingRouteStat; +import com.aps.core.service.IApsGasPipingRouteStatService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 姘斾綋绠¤矾浜ц兘璐熻浇缁熻Controller + * + * @author hjy + * @date 2025-04-24 + */ + +@Tag(name = "姘斾綋绠¤矾浜ц兘璐熻浇缁熻", description = "姘斾綋绠¤矾浜ц兘璐熻浇缁熻鎺ュ彛") +@RestController +@RequestMapping("/apsGasPipingRouteStat") +public class ApsGasPipingRouteStatController extends BaseController +{ + @Autowired + private IApsGasPipingRouteStatService apsGasPipingRouteStatService; + + /** + * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃 + */ + @Operation(summary = "鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃", description = "鍒嗛〉鏌ヨ") + @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:list") + @GetMapping("/list") + public TableDataInfo list(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat) + { + startPage(); + List<ApsGasPipingRouteStat> list = apsGasPipingRouteStatService.selectApsGasPipingRouteStatList(apsGasPipingRouteStat); + return getDataTable(list); + } + + /** + * 瀵煎嚭姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃 + */ + @Operation(summary = "瀵煎嚭姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃", description = "瀵煎嚭") + @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:export") + @Log(title = "姘斾綋绠¤矾浜ц兘璐熻浇缁熻", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat) + { + List<ApsGasPipingRouteStat> list = apsGasPipingRouteStatService.selectApsGasPipingRouteStatList(apsGasPipingRouteStat); + ExcelUtil<ApsGasPipingRouteStat> util = new ExcelUtil<ApsGasPipingRouteStat>(ApsGasPipingRouteStat.class); + util.exportExcel(response, list, "姘斾綋绠¤矾浜ц兘璐熻浇缁熻鏁版嵁"); + } + + /** + * 鑾峰彇姘斾綋绠¤矾浜ц兘璐熻浇缁熻璇︾粏淇℃伅 + */ + @Operation(summary = "鑾峰彇姘斾綋绠¤矾浜ц兘璐熻浇缁熻璇︾粏淇℃伅", description = "鏍规嵁id鑾峰彇") + @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(apsGasPipingRouteStatService.selectApsGasPipingRouteStatById(id)); + } + + /** + * 鏂板姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + */ + @Operation(summary = "鏂板姘斾綋绠¤矾浜ц兘璐熻浇缁熻", description = "鍗曚釜鏂板") + @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:add") + @Log(title = "姘斾綋绠¤矾浜ц兘璐熻浇缁熻", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat) + { + return toAjax(apsGasPipingRouteStatService.insertApsGasPipingRouteStat(apsGasPipingRouteStat)); + } + + /** + * 淇敼姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + */ + @Operation(summary = "淇敼姘斾綋绠¤矾浜ц兘璐熻浇缁熻", description = "鍗曚釜淇敼") + @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:edit") + @Log(title = "姘斾綋绠¤矾浜ц兘璐熻浇缁熻", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat) + { + return toAjax(apsGasPipingRouteStatService.updateApsGasPipingRouteStat(apsGasPipingRouteStat)); + } + + /** + * 鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + */ + @Operation(summary = "鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻", description = "鎵归噺鍒犻櫎") + @RequiresPermissions("apsGasPipingRouteStat:apsGasPipingRouteStat:remove") + @Log(title = "姘斾綋绠¤矾浜ц兘璐熻浇缁熻", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(apsGasPipingRouteStatService.deleteApsGasPipingRouteStatByIds(ids)); + } + + @Operation(summary = "璁$畻姘斾綋绠¤矾浜ц兘璐熻浇缁熻", description = "璁$畻") + @PostMapping("/computeCapacity") + public void computeCapacity() + { + apsGasPipingRouteStatService.computeCapacity(); + } + + @Operation(summary = "鑾峰彇姘斾綋绠¤矾浜ц兘璐熻浇缁熻", description = "璁$畻") + @PostMapping("/getCapacityPlanData") + public AjaxResult getCapacityPlanData(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat) + { + return AjaxResult.success(apsGasPipingRouteStatService.getCapacityPlanData(apsGasPipingRouteStat)); + } + + @Operation(summary = "瀵煎嚭姘斾綋绠¤矾浜ц兘璐熻浇缁熻Excel琛�", description = "瀵煎嚭") + @GetMapping("/exportExcel") + public void exportExcel(@RequestBody ApsGasPipingRouteStat apsGasPipingRouteStat, HttpServletResponse response) + { + apsGasPipingRouteStatService.exportExcel(response, apsGasPipingRouteStat); + } + +} diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java index ece0314..f4ca43d 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java @@ -42,7 +42,7 @@ * 鏌ヨ姘斾綋绠¤矾浜ц兘瑙勫垝鍒楄〃 */ @Operation(summary = "鏌ヨ姘斾綋绠¤矾浜ц兘瑙勫垝鍒楄〃", description = "鍒嗛〉鏌ヨ") -// @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:list") + @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:list") @GetMapping("/list") public TableDataInfo list(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) { @@ -57,12 +57,13 @@ apsGasPipelineCapacityPlanTemp.setProcessName(apsStandardProcessTemp.getProcessName()); list.add(apsGasPipelineCapacityPlanTemp); } - }else if(processList.size()>list.size()){ + } + if(processList.size()>list.size()){ List<String> newProcess = new ArrayList<>(); for(ApsStandardProcess apsStandardProcessTemp : processList){ boolean flag = true; for(ApsGasPipelineCapacityPlan temp : list){ - if(apsStandardProcessTemp.getMajor().equals(temp.getMajor())){ + if(apsStandardProcessTemp.getProcessName().equals(temp.getProcessName())){ flag = false; break; } @@ -109,13 +110,13 @@ * 鏂板姘斾綋绠¤矾浜ц兘瑙勫垝 */ @Operation(summary = "鏂板姘斾綋绠¤矾浜ц兘瑙勫垝", description = "鍗曚釜鏂板") - @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:add") +// @RequiresPermissions("gasPipelineCapacityPlan:gasPipelineCapacityPlan:add") @Log(title = "姘斾綋绠¤矾浜ц兘瑙勫垝", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlan) { apsGasPipelineCapacityPlan.forEach(apsGasPipelineCapacityPlanTemp -> { - if(apsGasPipelineCapacityPlanTemp.getId()!=null){ + if(apsGasPipelineCapacityPlanTemp.getId()==null){ apsGasPipelineCapacityPlanService.insertApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp); }else{ apsGasPipelineCapacityPlanService.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp); diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingPlan.java b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingPlan.java index cb82baa..2138c12 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingPlan.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingPlan.java @@ -8,6 +8,7 @@ import java.math.BigDecimal; import java.util.Date; +import java.util.List; /** * 姘斾綋绠¤矾璁″垝绠$悊瀵硅薄 aps_gas_piping_plan @@ -171,6 +172,17 @@ private String planType; + /** 宸ュ簭鍒楄〃 */ + private List<ApsProcessRoute> apsProcessRoutes; + + public List<ApsProcessRoute> getApsProcessRoutes() { + return apsProcessRoutes; + } + + public void setApsProcessRoutes(List<ApsProcessRoute> apsProcessRoutes) { + this.apsProcessRoutes = apsProcessRoutes; + } + public void setId(String id) { this.id = id; 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 new file mode 100644 index 0000000..b3f47f1 --- /dev/null +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsGasPipingRouteStat.java @@ -0,0 +1,150 @@ +package com.aps.core.domain; + +import com.aps.common.core.annotation.Excel; +import com.aps.common.core.web.domain.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.springframework.data.annotation.Transient; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 姘斾綋绠¤矾浜ц兘璐熻浇缁熻瀵硅薄 aps_gas_piping_route_stat + * + * @author hjy + * @date 2025-04-24 + */ +@Schema(description = "姘斾綋绠¤矾浜ц兘璐熻浇缁熻瀹炰綋绫�") +@Data +public class ApsGasPipingRouteStat extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 涓婚敭id */ + @Schema(description = "涓婚敭id", type = "Long") + private String id; + + /** 宸ュ崟鍙� */ + @Excel(name = "宸ュ崟鍙�") + @Schema(description = "宸ュ崟鍙�", type = "String") + private String workOrderNo; + + /** 宸ュ簭鍙� */ + @Excel(name = "宸ュ簭鍙�") + @Schema(description = "宸ュ簭鍙�", type = "String") + private String roadProcessNumber; + + /** 褰撳墠宸ュ簭鍙� */ + @Excel(name = "褰撳墠宸ュ簭鍙�") + @Schema(description = "褰撳墠宸ュ簭鍙�", type = "String") + private String currentProcessNumber; + + /** 鐢熶骇鏁伴噺 */ + @Excel(name = "鐢熶骇鏁伴噺") + @Schema(description = "鐢熶骇鏁伴噺", type = "BigDecimal") + private BigDecimal productionQuantity; + + /** 鏍囧噯宸ユ椂 */ + @Excel(name = "鏍囧噯宸ユ椂") + @Schema(description = "鏍囧噯宸ユ椂", type = "BigDecimal") + private BigDecimal standardTime; + + /** 宸ュ簭鎬诲伐鏃� */ + @Excel(name = "宸ュ簭鎬诲伐鏃�") + @Schema(description = "宸ュ簭鎬诲伐鏃�", type = "BigDecimal") + private BigDecimal processTotalTime; + + /** 璁″垝寮�宸ユ棩 */ + @Excel(name = "璁″垝寮�宸ユ棩") + @Schema(description = "璁″垝寮�宸ユ棩", type = "Date") + private Date processPlanStartDay; + + /** 璁捐宸ユ椂 */ + @Excel(name = "璁捐宸ユ椂") + @Schema(description = "璁捐宸ユ椂", type = "Long") + private Long designTimes; + + /** 鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛� */ + @Schema(description = "鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�", type = "String") + private String delFlag; + + /** 宸ュ簭鍚嶇О */ + @Excel(name = "宸ュ簭鍚嶇О") + @Schema(description = "宸ュ簭鍚嶇О", type = "String") + private String processName; + + /** 鏂欏彿 */ + @Excel(name = "鏂欏彿") + @Schema(description = "鏂欏彿", type = "String") + private String itemNumber; + + /** 鏍囧噯鐢ㄩ噺 */ + @Excel(name = "鏍囧噯鐢ㄩ噺") + @Schema(description = "鏍囧噯鐢ㄩ噺", type = "BigDecimal") + private BigDecimal standardDosage; + + /** 宸ュ簭鎬荤敤閲� */ + @Excel(name = "宸ュ簭鎬荤敤閲�") + @Schema(description = "宸ュ簭鎬荤敤閲�", type = "BigDecimal") + private BigDecimal processTotalDosage; + + /** 璁捐浜ц兘 */ + @Excel(name = "璁捐浜ц兘") + @Schema(description = "璁捐浜ц兘", type = "BigDecimal") + private BigDecimal designCapacity; + + /** 璁捐浜ц兘 */ + @Excel(name = "涓撲笟") + @Schema(description = "涓撲笟", type = "String") + private String major; + + /** 骞� */ + @Excel(name = "骞�") + @Schema(description = "骞�", type = "String") + private String planStartYear; + + /** 鏈� */ + @Excel(name = "鏈�") + @Schema(description = "鏈�", type = "String") + private String planStartMonth; + + /** 鏃� */ + @Excel(name = "鏃�") + @Schema(description = "鏃�", type = "String") + private String planStartDay; + + /** 鎵规鍙� */ + @Excel(name = "鎵规鍙�") + private String batchNumber; + + @Transient + private String searchStartDate; + + @Transient + private String searchEndDate; + + @Transient + private String searchType; + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("workOrderNo", getWorkOrderNo()) + .append("roadProcessNumber", getRoadProcessNumber()) + .append("currentProcessNumber", getCurrentProcessNumber()) + .append("productionQuantity", getProductionQuantity()) + .append("standardTime", getStandardTime()) + .append("processTotalTime", getProcessTotalTime()) + .append("processPlanStartDay", getProcessPlanStartDay()) + .append("designTimes", getDesignTimes()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("processName", getProcessName()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingPlanMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingPlanMapper.java index f8abec7..3de94b4 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingPlanMapper.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingPlanMapper.java @@ -1,8 +1,9 @@ package com.aps.core.mapper; -import java.util.List; import com.aps.core.domain.ApsGasPipingPlan; import org.apache.ibatis.annotations.Mapper; + +import java.util.List; /** * 姘斾綋绠¤矾璁″垝绠$悊Mapper鎺ュ彛 @@ -65,4 +66,11 @@ * @return 缁撴灉 */ int removeAllPlans(); + + /** + * 鑾峰彇姘斾綋绠¤矾宸ュ崟鍏宠仈宸ュ簭鏁版嵁 + * @param apsGasPipingPlan + * @return + */ + public List<ApsGasPipingPlan> selectApsGasPipingPlanWithProcess(ApsGasPipingPlan apsGasPipingPlan); } diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java new file mode 100644 index 0000000..992ecaf --- /dev/null +++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java @@ -0,0 +1,77 @@ +package com.aps.core.mapper; + +import com.aps.core.domain.ApsGasPipingRouteStat; + +import java.util.List; + +/** + * 姘斾綋绠¤矾浜ц兘璐熻浇缁熻Mapper鎺ュ彛 + * + * @author hjy + * @date 2025-04-24 + */ +public interface ApsGasPipingRouteStatMapper +{ + /** + * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭 + * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + */ + public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id); + + /** + * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻闆嗗悎 + */ + public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat); + + /** + * 鏂板姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 缁撴灉 + */ + public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat); + + /** + * 淇敼姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 缁撴灉 + */ + public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat); + + /** + * 鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭 + * @return 缁撴灉 + */ + public int deleteApsGasPipingRouteStatById(String id); + + /** + * 鎵归噺鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteApsGasPipingRouteStatByIds(String[] ids); + + /** + * 鏍规嵁鎵规鍙峰垹闄ゆ暟鎹� + * @param batchNumber + * @return + */ + public int deleteApsGasPipingRouteStatByBatchNum(String batchNumber); + + + /** + * 鎵归噺鎻掑叆绠¤矾姘旀煖浜ц兘鏁版嵁 + * @param apsGasPipingRouteStatList + * @return + */ + public int insertApsGasPipingRouteStatBatch(List<ApsGasPipingRouteStat> apsGasPipingRouteStatList); +} diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsProcessRouteMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsProcessRouteMapper.java index 252ee63..6f5031d 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsProcessRouteMapper.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsProcessRouteMapper.java @@ -67,4 +67,5 @@ * @return */ public List<ApsProcessRoute> selectProcessNameList(String orgCode); + } diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsGasPipingRouteStatService.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsGasPipingRouteStatService.java new file mode 100644 index 0000000..664fac3 --- /dev/null +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsGasPipingRouteStatService.java @@ -0,0 +1,85 @@ +package com.aps.core.service; + +import com.alibaba.fastjson2.JSONObject; +import com.aps.core.domain.ApsGasPipingRouteStat; +import jakarta.servlet.http.HttpServletResponse; + +import java.util.List; + +/** + * 姘斾綋绠¤矾浜ц兘璐熻浇缁熻Service鎺ュ彛 + * + * @author hjy + * @date 2025-04-24 + */ +public interface IApsGasPipingRouteStatService +{ + /** + * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭 + * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + */ + public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id); + + /** + * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻闆嗗悎 + */ + public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat); + + /** + * 鏂板姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 缁撴灉 + */ + public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat); + + /** + * 淇敼姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 缁撴灉 + */ + public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat); + + /** + * 鎵归噺鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param ids 闇�瑕佸垹闄ょ殑姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteApsGasPipingRouteStatByIds(String[] ids); + + /** + * 鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻淇℃伅 + * + * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭 + * @return 缁撴灉 + */ + public int deleteApsGasPipingRouteStatById(String id); + + /** + * 璁$畻浜ц兘鏁版嵁鍒板簳琛� + * @param yearMonth + * @return + */ + boolean computeCapacity(); + + /** + * 鑾峰彇浜ц兘璁″垝鏁版嵁 + * @param year + * @param month + * @return + */ + public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat); + + /** + * 瀵煎嚭鏁版嵁 + * @param response + */ + public void exportExcel(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat); +} diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineCapacityPlanServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineCapacityPlanServiceImpl.java index d11bd09..f175d09 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineCapacityPlanServiceImpl.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipelineCapacityPlanServiceImpl.java @@ -1,6 +1,7 @@ package com.aps.core.service.impl; import com.aps.common.core.utils.DateUtils; +import com.aps.common.security.utils.SecurityUtils; import com.aps.core.domain.ApsGasPipelineCapacityPlan; import com.aps.core.mapper.ApsGasPipelineCapacityPlanMapper; import com.aps.core.service.IApsGasPipelineCapacityPlanService; @@ -55,6 +56,7 @@ public int insertApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) { apsGasPipelineCapacityPlan.setCreateTime(DateUtils.getNowDate()); + apsGasPipelineCapacityPlan.setCreateBy(SecurityUtils.getUsername()); return apsGasPipelineCapacityPlanMapper.insertApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan); } @@ -68,6 +70,7 @@ public int updateApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) { apsGasPipelineCapacityPlan.setUpdateTime(DateUtils.getNowDate()); + apsGasPipelineCapacityPlan.setUpdateBy(SecurityUtils.getUsername()); return apsGasPipelineCapacityPlanMapper.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan); } 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 new file mode 100644 index 0000000..0522a73 --- /dev/null +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java @@ -0,0 +1,472 @@ +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; +import com.aps.common.security.utils.SecurityUtils; +import com.aps.core.domain.*; +import com.aps.core.mapper.ApsGasPipelineCapacityPlanMapper; +import com.aps.core.mapper.ApsGasPipingPlanMapper; +import com.aps.core.mapper.ApsGasPipingRouteStatMapper; +import com.aps.core.service.IApsGasMaterialUsageService; +import com.aps.core.service.IApsGasPipingRouteStatService; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.streaming.SXSSFCell; +import org.apache.poi.xssf.streaming.SXSSFRow; +import org.apache.poi.xssf.streaming.SXSSFSheet; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.YearMonth; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * 姘斾綋绠¤矾浜ц兘璐熻浇缁熻Service涓氬姟灞傚鐞� + * + * @author hjy + * @date 2025-04-24 + */ +@Slf4j +@Service +public class ApsGasPipingRouteStatServiceImpl implements IApsGasPipingRouteStatService +{ + @Autowired + private ApsGasPipingRouteStatMapper apsGasPipingRouteStatMapper; + + @Autowired + private ApsGasPipingPlanMapper apsGasPipingPlanMapper; + + @Autowired + private ApsGasPipelineCapacityPlanMapper apsGasPipelineCapacityPlanMapper; + + @Autowired + private IApsGasMaterialUsageService apsGasMaterialUsageService; + + /** + * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭 + * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + */ + @Override + public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id) + { + return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatById(id); + } + + /** + * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + */ + @Override + public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat) + { + return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat); + } + + /** + * 鏂板姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 缁撴灉 + */ + @Override + public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat) + { + apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate()); + apsGasPipingRouteStat.setCreateBy(SecurityUtils.getUsername()); + return apsGasPipingRouteStatMapper.insertApsGasPipingRouteStat(apsGasPipingRouteStat); + } + + /** + * 淇敼姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * @return 缁撴灉 + */ + @Override + public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat) + { + apsGasPipingRouteStat.setUpdateBy(SecurityUtils.getUsername()); + apsGasPipingRouteStat.setUpdateTime(DateUtils.getNowDate()); + return apsGasPipingRouteStatMapper.updateApsGasPipingRouteStat(apsGasPipingRouteStat); + } + + /** + * 鎵归噺鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻 + * + * @param ids 闇�瑕佸垹闄ょ殑姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭 + * @return 缁撴灉 + */ + @Override + public int deleteApsGasPipingRouteStatByIds(String[] ids) + { + return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByIds(ids); + } + + /** + * 鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻淇℃伅 + * + * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭 + * @return 缁撴灉 + */ + @Override + public int deleteApsGasPipingRouteStatById(String id) + { + return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatById(id); + } + + @Override + public boolean computeCapacity() { +// PageHelper.startPage(1, 500); + List<ApsGasPipingPlan> apsGasPipingPlans = apsGasPipingPlanMapper.selectApsGasPipingPlanWithProcess(new ApsGasPipingPlan()); + List<ApsGasPipingRouteStat> apsGasPipingRouteStatList = new ArrayList<>(); + /*鏈璁$畻鎵规鍙�*/ + String batchNum = IdUtils.fastSimpleUUID(); + try { + apsGasPipingPlans.forEach(apsGasPipingPlan -> { + List<ApsProcessRoute> apsProcessRoutes = apsGasPipingPlan.getApsProcessRoutes(); + //鎸夌収宸ュ簭搴忓彿鍗囧簭鎺掑簭 + apsProcessRoutes.sort((a, b)->a.getProcessNumber().compareTo(b.getProcessNumber())); + //鏄惁鎵惧埌褰撳墠宸ュ簭 + boolean isFind = false; + for (int i=0;i<apsProcessRoutes.size();i++){ + ApsProcessRoute apsProcessRoute = apsProcessRoutes.get(i); + ApsGasPipingRouteStat apsGasPipingRouteStat = new ApsGasPipingRouteStat(); + //宸ュ崟鍙� + apsGasPipingRouteStat.setWorkOrderNo(apsGasPipingPlan.getDocumentNumber()); + //鏂欏彿 + apsGasPipingRouteStat.setItemNumber(apsGasPipingPlan.getItemNumber()); + //褰撳墠宸ュ簭鍙� + apsGasPipingRouteStat.setCurrentProcessNumber(apsGasPipingPlan.getProcessNumber()); + //鐢熶骇鏁伴噺 + apsGasPipingRouteStat.setProductionQuantity(apsGasPipingPlan.getProductionQuantity()); + //宸ュ簭鍚嶇О + apsGasPipingRouteStat.setProcessName(apsProcessRoute.getProcessName()); + //宸ュ簭鍙� + apsGasPipingRouteStat.setRoadProcessNumber(apsProcessRoute.getProcessNumber()); + //鏍囧噯宸ユ椂 + apsGasPipingRouteStat.setStandardTime(apsProcessRoute.getStandardTime()); + //涓撲笟 + apsGasPipingRouteStat.setMajor(apsGasPipingPlan.getPlanType()); + //宸ュ簭鎬诲伐鏃� 绛変簬 鏍囧噯宸ユ椂*鐢熶骇鏁伴噺 + apsGasPipingRouteStat.setProcessTotalTime(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity())); + //璁″垝寮�宸ユ棩 + if(apsGasPipingRouteStat.getCurrentProcessNumber().equals(apsGasPipingRouteStat.getRoadProcessNumber())) { + /* 瀵� stat.getProcessPlanStartDay() 鍜屽綋鍓嶆棩鏈� 杩涜瀵规瘮锛屽彧瀵规瘮鍒版棩锛屼笉鐢ㄧ鍗佸垎绉�*/ + LocalDate startLocalDate = LocalDate.ofInstant(apsProcessRoute.getProcessPlanStartDay().toInstant(), ZoneId.systemDefault()); + LocalDate nowLocalDate = LocalDate.now(); + if (startLocalDate.isBefore(nowLocalDate)) { + apsGasPipingRouteStat.setProcessPlanStartDay(new Date()); + }else{ + apsGasPipingRouteStat.setProcessPlanStartDay(apsProcessRoute.getProcessPlanStartDay()); + } + isFind = true; + } + if(!isFind){ + continue; + } + // 涓婁竴閬撳伐搴忕殑缁撴潫鏃堕棿 = 涓婁竴閬撳伐搴忕殑寮�濮嬫椂闂� + 涓婁竴閬撳伐搴忕殑鎬诲伐鏃� + if(apsGasPipingRouteStat.getProcessPlanStartDay()==null){ + LocalDateTime previousProcessPlanStartDay = apsProcessRoutes.get(i - 1).getProcessPlanStartDay().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + long previousProcessTotalTime = apsGasPipingRouteStatList.get(i - 1).getProcessTotalTime().longValue(); + LocalDateTime currentProcessPlanStartDay = previousProcessPlanStartDay.plusHours(previousProcessTotalTime); + apsGasPipingRouteStat.setProcessPlanStartDay(Date.from(Timestamp.valueOf(currentProcessPlanStartDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).toInstant())); + } + //鎻掑叆 骞� 鏈� 鏃� + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String formattedDate = sdf.format(apsGasPipingRouteStat.getProcessPlanStartDay()); + String[] dateParts = formattedDate.split("-"); + apsGasPipingRouteStat.setPlanStartYear(String.valueOf(Integer.parseInt(dateParts[0]))); + apsGasPipingRouteStat.setPlanStartMonth(String.valueOf(Integer.parseInt(dateParts[1]))); + apsGasPipingRouteStat.setPlanStartDay(String.valueOf(Integer.parseInt(dateParts[2]))); + //鏍囧噯鐢ㄩ噺 鏌ヨ鐗╂枡鐢ㄩ噺琛� +// ApsGasMaterialUsage apsGasMaterialUsage = new ApsGasMaterialUsage(); +// apsGasMaterialUsage.setItemNumber(apsGasPipingPlan.getItemNumber()); +// apsGasMaterialUsage.setProcessName(apsProcessRoute.getProcessName()); +// List<ApsGasMaterialUsage> apsGasMaterialUsageList = apsGasMaterialUsageService.selectApsGasMaterialUsageList(apsGasMaterialUsage); + apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity())); + //宸ュ簭鎬荤敤閲� = 鏍囧噯鐢ㄩ噺*鐢熶骇鏁伴噺 + apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity())); + apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate()); + apsGasPipingRouteStat.setCreateBy("auto"); + apsGasPipingRouteStat.setBatchNumber(batchNum); + apsGasPipingRouteStat.setId(IdUtils.fastSimpleUUID()); + apsGasPipingRouteStatList.add(apsGasPipingRouteStat); + } + }); + List<ApsGasPipingRouteStat> tempInsertList = new ArrayList<>(); + for (int i = 0; i < apsGasPipingRouteStatList.size(); i++) { + tempInsertList.add(apsGasPipingRouteStatList.get(i)); + if(tempInsertList.size()==500){ + apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList); + tempInsertList = new ArrayList<>(); + }else if(i==apsGasPipingRouteStatList.size()-1){ + apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList); + } + } + apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByBatchNum(batchNum); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + @Override + public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) { + JSONObject result = new JSONObject(); + HashSet<String> startPlanTimeSet = new HashSet<>(); + JSONArray processData = new JSONArray(); + try { + //鑾峰彇宸ュ簭璁″垝浜ц兘鏁版嵁 + HashMap<String, ApsGasPipelineCapacityPlan> apsGasPipingPlanMap = new HashMap<>(); + List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(new ApsGasPipelineCapacityPlan()); + apsGasPipelineCapacityPlanList.forEach(apsGasPipelineCapacityPlan -> { + apsGasPipingPlanMap.put(apsGasPipelineCapacityPlan.getProcessName(),apsGasPipelineCapacityPlan); + }); + //璁$畻鏃ヤ骇鑳芥暟鎹� + 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())){ + 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"); + } + apsGasPipingRouteStats = apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat); + //鏍规嵁寮�宸ユ棩杩涜鍗囧簭鎺掑簭 + apsGasPipingRouteStats.sort((a, b)->a.getPlanStartDay().compareTo(b.getPlanStartDay())); + //宸ュ簭鍒嗙粍缁熻 + HashMap<String, List<ApsResourceDateStat>> processMap = new HashMap<>(); + List<HashMap<String, List<ApsResourceDateStat>>> processList = new ArrayList<>(); + HashMap<String, List<ApsResourceDateStat>> processMapMonth = new HashMap<>(); + List<HashMap<String, List<ApsResourceDateStat>>> processListMonth = new ArrayList<>(); + //宸ュ簭寮�宸ユ棩鏈� + String planStartDate = ""; + for (ApsGasPipingRouteStat apsGasPipingRouteStatTemp : apsGasPipingRouteStats) { + 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.setDesignTimes(apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName())!=null?apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName()).getDayProduceAllNum().intValue():0); + //鏌ヨ鏂欏彿宸ュ簭浜ц兘琛� + apsResourceDateStat.setRequireTimes(apsGasPipingRouteStatTemp.getProcessTotalTime().intValue()); + if(apsResourceDateStat.getDesignTimes()!=0){ + apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStat.getRequireTimes()/apsResourceDateStat.getDesignTimes()* 100L)); + }else{ + apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(0)); + } + List<ApsResourceDateStat> apsResourceDateStatList = new ArrayList<>(); + if(processMap.containsKey(apsGasPipingRouteStatTemp.getProcessName())){ + apsResourceDateStatList = processMap.get(apsGasPipingRouteStatTemp.getProcessName()); + } + apsResourceDateStatList.add(apsResourceDateStat); + processMap.put(apsGasPipingRouteStatTemp.getProcessName(), apsResourceDateStatList); + } + processMap.forEach((processName, apsResourceDateStatList) -> { + HashMap<String, ApsResourceDateStat> dayMap = new HashMap<>(); + apsResourceDateStatList.forEach(apsResourceDateStat -> { + startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString()); + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){ + ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString()); + apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum().intValue():0); + apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes()+apsResourceDateStat.getRequireTimes()); + if(apsResourceDateStatTemp.getDesignTimes()!=0){ + apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStatTemp.getRequireTimes()/apsResourceDateStatTemp.getDesignTimes()* 100L)); + }else{ + apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(0)); + } + apsResourceDateStatTemp.setResourceGroupName(processName); + apsResourceDateStatTemp.setPlanDay(apsResourceDateStat.getPlanDay()); + dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStatTemp); + }else{ + dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStat); + } + } + }); + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + List<ApsResourceDateStat> tempList = new ArrayList<>(); + dayMap.forEach((key, value) -> { + tempList.add(value); + }); + processMapMonth.put(processName, tempList); + } + }); + List<String> sortedStartPlanTimeList = new ArrayList<>(startPlanTimeSet); + Collections.sort(sortedStartPlanTimeList); +// processMap.forEach((processName, apsResourceDateStatList) -> { +// HashMap<String, ApsResourceDateStat> dayMap = new HashMap<>(); +// apsResourceDateStatList.forEach(apsResourceDateStat -> { +// startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString()); +// if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){ +// ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString()); +// if("day".equals(apsGasPipingRouteStat.getSearchType())){ +// apsResourceDateStatTemp.setDesignTimes(apsResourceDateStatTemp.getDesignTimes()+apsResourceDateStat.getDesignTimes()); +// }else if("month".equals(apsGasPipingRouteStat.getSearchType())){ +// apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum().intValue():0); +// } +// apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes()+apsResourceDateStat.getRequireTimes()); +// if(apsResourceDateStatTemp.getDesignTimes()!=0){ +// apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStatTemp.getRequireTimes()/apsResourceDateStatTemp.getDesignTimes()* 100L)); +// } +// apsResourceDateStatTemp.setResourceGroupName(processName); +// dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStatTemp); +// }else{ +// dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStat); +// } +// }); +// JSONArray tempList = new JSONArray(); +// dayMap.forEach((key, value) -> { +// JSONObject temp = new JSONObject(); +// temp.put("planDay", key); +// temp.put("designTimes", value.getDesignTimes()); +// temp.put("requireTimes", value.getRequireTimes()); +// temp.put("capacityLoad", value.getCapacityLoad()); +// temp.put("resourceGroupName", value.getResourceGroupName()); +// tempList.add(temp); +// }); +// processData.add(new JSONObject().put(processName, tempList)); +// }); + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + for (String key : processMapMonth.keySet()) { + HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>(); + temp.put(key, processMapMonth.get(key)); + processListMonth.add(temp); + } + result.put("planTable", processListMonth); + }else{ + for (String key : processMap.keySet()) { + HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>(); + temp.put(key, processMap.get(key)); + processList.add(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(); + wb.setSheetName(0, "姘旀煖绠¤矾浜ц兘璐熻浇缁熻琛�"); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + + Map<String, CellStyle> styles = createStyles(wb); + CellStyle title = styles.get("title"); + try + { + JSONObject stat = getCapacityPlanData(apsGasPipingRouteStat); + List<String> days = (List<String>) stat.get("planTitle"); + List<HashMap<String, List<ApsResourceDateStat>>> table= (List<HashMap<String, List<ApsResourceDateStat>>>) stat.get("planTable"); + SXSSFSheet sheet = wb.getSheetAt(0); + /*濉啓鏃ユ湡鍒� 鍜� 宸ユ椂鍒�*/ + SXSSFRow rowDay = sheet.createRow(0); + SXSSFRow rowTitle = sheet.createRow(1); + + SXSSFCell daytitle = rowDay.createCell(0); + daytitle.setCellValue("鏃ユ湡"); + daytitle.setCellStyle(title); + SXSSFCell titleCell = rowTitle.createCell(0); + titleCell.setCellValue("宸ュ簭"); + titleCell.setCellStyle(title); + + for (int i = 0; i < days.size(); i++) { + SXSSFCell dateCell = rowDay.createCell(i * 3 + 1); + SXSSFCell designHoursCell = rowTitle.createCell(i * 3 + 1); + SXSSFCell requireHoursCell = rowTitle.createCell(i * 3 + 2); + SXSSFCell loadCell = rowTitle.createCell(i * 3 + 3); + dateCell.setCellValue(days.get(i)); + designHoursCell.setCellValue("璁捐宸ユ椂"); + requireHoursCell.setCellValue("闇�姹傚伐鏃�"); + loadCell.setCellValue("浜ц兘璐熻嵎"); + /*set cell style*/ + dateCell.setCellStyle(title); + designHoursCell.setCellStyle(title); + requireHoursCell.setCellStyle(title); + loadCell.setCellStyle(title); + + /*鍚堝苟鏃ユ湡鍗曞厓鏍�*/ + sheet.addMergedRegion( new CellRangeAddress(0, 0, i*3+1, i*3+3)); + } + for (int i = 0; i < table.size(); i++) { + Map<String, List<ApsResourceDateStat>> resourceList = table.get(i); + /*鍒涘缓鏁版嵁琛�*/ + SXSSFRow dataRow = sheet.createRow(i+2); + for( Map.Entry<String, List<ApsResourceDateStat>> entry : resourceList.entrySet()){ + String resourceName = entry.getKey(); + List<ApsResourceDateStat> resourceDateStats = entry.getValue(); + dataRow.createCell(0).setCellValue(resourceName); + for (int j = 0; j < resourceDateStats.size(); j++) { + ApsResourceDateStat apsResourceDateStat = resourceDateStats.get(j); + dataRow.createCell(j*3+1).setCellValue(apsResourceDateStat.getDesignTimes()); + dataRow.createCell(j*3+2).setCellValue(apsResourceDateStat.getRequireTimes()); + if(apsResourceDateStat.getCapacityLoad()!=null){ + dataRow.createCell(j*3+3).setCellValue(apsResourceDateStat.getCapacityLoad().doubleValue()+"%"); + }else{ + dataRow.createCell(j*3+3).setCellValue("%"); + } + } + } + + } + wb.write(response.getOutputStream()); + } + catch (Exception e) + { + log.error("瀵煎嚭Excel寮傚父{}", e.getMessage()); + } + finally + { + IOUtils.closeQuietly(wb); + } + } + private Map<String,CellStyle> createStyles(SXSSFWorkbook wb) + { + Map<String,CellStyle> styles=new HashMap<>(); + CellStyle style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + Font titleFont = wb.createFont(); + titleFont.setFontName("Arial"); + titleFont.setFontHeightInPoints((short) 12); + titleFont.setBold(true); + style.setFont(titleFont); + DataFormat dataFormat = wb.createDataFormat(); + style.setDataFormat(dataFormat.getFormat("@")); + styles.put("title", style); + return styles; + } +} diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingPlanMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingPlanMapper.xml index 0955f47..6273868 100644 --- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingPlanMapper.xml +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingPlanMapper.xml @@ -41,6 +41,46 @@ <result property="hasTurnback" column="has_turnback" /> <result property="hasRisk" column="has_risk" /> <result property="planType" column="plan_type" /> +<!-- <collection property="apsProcessRoutes" javaType="java.util.ArrayList" ofType="com.aps.core.domain.ApsProcessRoute">--> +<!-- <result property="id" column="id" />--> +<!-- <result property="itemNo" column="item_no" />--> +<!-- <result property="workOrderNo" column="work_order_no" />--> +<!-- <result property="processNumber" column="process_number_sub" />--> +<!-- <result property="processName" column="process_name" />--> +<!-- <result property="processPlanStartDay" column="process_plan_start_day" />--> +<!-- <result property="processPlanEndDay" column="process_plan_end_day" />--> +<!-- <result property="notStartWorkCount" column="not_start_work_count" />--> +<!-- <result property="completedCount" column="completed_count" />--> +<!-- <result property="discardCount" column="discard_count" />--> +<!-- <result property="integrationDay" column="integration_day" />--> +<!-- <result property="plant" column="plant" />--> +<!-- <result property="delFlag" column="del_flag" />--> +<!-- <result property="createBy" column="create_by" />--> +<!-- <result property="createTime" column="create_time" />--> +<!-- <result property="updateBy" column="update_by" />--> +<!-- <result property="updateTime" column="update_time" />--> +<!-- <result property="standardTime" column="standard_time" />--> +<!-- <result property="processOrder" column="process_order" />--> +<!-- <result property="workCenter" column="work_center" />--> +<!-- <result property="processQty" column="process_qty" />--> +<!-- <result property="opStatus" column="op_status" />--> +<!-- <result property="opStatus" column="op_status" />--> +<!-- <result property="orgCode" column="org_code" />--> +<!-- </collection>--> + </resultMap> + + <resultMap type="ApsGasPipingPlan" id="ApsGasPipingPlanResultWithProcess"> + <result property="documentNumber" column="document_number" /> + <result property="itemNumber" column="item_number" /> + <result property="productionQuantity" column="production_quantity" /> + <result property="processNumber" column="process_number" /> + <result property="planType" column="plan_type" /> + <collection property="apsProcessRoutes" javaType="java.util.ArrayList" ofType="com.aps.core.domain.ApsProcessRoute"> + <result property="processNumber" column="process_number_sub" /> + <result property="processName" column="process_name" /> + <result property="processPlanStartDay" column="process_plan_start_day" /> + <result property="standardTime" column="standard_time" /> + </collection> </resultMap> <sql id="selectApsGasPipingPlanVo"> @@ -233,4 +273,11 @@ <update id="removeAllPlans" > update aps_gas_piping_plan set del_flag='1' where del_flag ='0' </update> + + <select id="selectApsGasPipingPlanWithProcess" parameterType="ApsGasPipingPlan" resultMap="ApsGasPipingPlanResultWithProcess"> + select c.* from (select a.document_number,a.item_number,a.process_number,a.production_quantity,a.plan_type,b.process_name,b.process_number as process_number_sub,b.standard_time,b.process_plan_start_day from aps_gas_piping_plan a + left join aps_process_route b on a.document_number = b.work_order_no + where a.document_status in ('0','1','2','4') and b.process_plan_start_day is not null ORDER BY a.document_number,b.process_number) c GROUP BY c.document_number,c.item_number,c.process_number,c.production_quantity,c.process_name,c.process_number_sub,c.standard_time,c.process_plan_start_day,c.plan_type + </select> + </mapper> \ No newline at end of file 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 new file mode 100644 index 0000000..fae7c5f --- /dev/null +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.aps.core.mapper.ApsGasPipingRouteStatMapper"> + + <resultMap type="ApsGasPipingRouteStat" id="ApsGasPipingRouteStatResult"> + <result property="id" column="id" /> + <result property="workOrderNo" column="work_order_no" /> + <result property="roadProcessNumber" column="road_process_number" /> + <result property="currentProcessNumber" column="current_process_number" /> + <result property="productionQuantity" column="production_quantity" /> + <result property="standardTime" column="standard_time" /> + <result property="processTotalTime" column="process_total_time" /> + <result property="processPlanStartDay" column="process_plan_start_day" /> + <result property="designTimes" column="design_times" /> + <result property="delFlag" column="del_flag" /> + <result property="createBy" column="create_by" /> + <result property="processName" column="process_name" /> + <result property="createTime" column="create_time" /> + <result property="itemNumber" column="item_number" /> + <result property="standardDosage" column="standard_dosage" /> + <result property="processTotalDosage" column="process_total_dosage" /> + <result property="designCapacity" column="design_capacity" /> + <result property="major" column="major" /> + <result property="planStartYear" column="plan_start_year" /> + <result property="planStartMonth" column="plan_start_month" /> + <result property="planStartDay" column="plan_start_day" /> + </resultMap> + + <sql id="selectApsGasPipingRouteStatVo"> + select id, work_order_no, road_process_number, current_process_number, production_quantity, standard_time, process_total_time, 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 from aps_gas_piping_route_stat + </sql> + + <select id="selectApsGasPipingRouteStatList" parameterType="ApsGasPipingRouteStat" resultMap="ApsGasPipingRouteStatResult"> + <include refid="selectApsGasPipingRouteStatVo"/> + <where> + <if test="workOrderNo != null and workOrderNo != ''"> and work_order_no = #{workOrderNo}</if> + <if test="roadProcessNumber != null and roadProcessNumber != ''"> and road_process_number = #{roadProcessNumber}</if> + <if test="currentProcessNumber != null and currentProcessNumber != ''"> and current_process_number = #{currentProcessNumber}</if> + <if test="productionQuantity != null and productionQuantity != ''"> and production_quantity = #{productionQuantity}</if> + <if test="standardTime != null and standardTime != ''"> and standard_time = #{standardTime}</if> + <if test="processTotalTime != null and processTotalTime != ''"> and process_total_time = #{processTotalTime}</if> + <if test="processPlanStartDay != null and processPlanStartDay != ''"> and process_plan_start_day = #{processPlanStartDay}</if> + <if test="designTimes != null "> and design_times = #{designTimes}</if> + <if test="processName != null and processName != ''"> and process_name like '%' || #{processName} || '%')</if> + <if test="major != null and major != ''"> and major = #{major} </if> + <if test="planStartYear != null and planStartYear != ''"> and plan_start_year = #{planStartYear} </if> + <if test="planStartMonth != null and planStartMonth != ''"> and plan_start_month = #{planStartMonth} </if> + <if test="planStartDay != null and planStartDay != ''"> and plan_start_day = #{planStartDay} </if> + <if test="searchStartDate != null and searchStartDate != '' and searchEndDate != null and searchEndDate != ''"> and (process_plan_start_day >= #{searchStartDate} and process_plan_start_day <= #{searchEndDate}) </if> + </where> + </select> + + <select id="selectApsGasPipingRouteStatById" parameterType="String" resultMap="ApsGasPipingRouteStatResult"> + <include refid="selectApsGasPipingRouteStatVo"/> + where id = #{id} + </select> + + <insert id="insertApsGasPipingRouteStat" parameterType="ApsGasPipingRouteStat"> + insert into aps_gas_piping_route_stat + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">id,</if> + <if test="workOrderNo != null">work_order_no,</if> + <if test="roadProcessNumber != null and roadProcessNumber != ''">road_process_number,</if> + <if test="currentProcessNumber != null">current_process_number,</if> + <if test="productionQuantity != null">production_quantity,</if> + <if test="standardTime != null">standard_time,</if> + <if test="processTotalTime != null">process_total_time,</if> + <if test="processPlanStartDay != null and processPlanStartDay != ''">process_plan_start_day,</if> + <if test="designTimes != null">design_times,</if> + <if test="delFlag != null">del_flag,</if> + <if test="createBy != null">create_by,</if> + <if test="processName != null">process_name,</if> + <if test="createTime != null">create_time,</if> + <if test="itemNumber != null">item_number,</if> + <if test="standardDosage != null">standard_dosage,</if> + <if test="processTotalDosage != null">process_total_dosage,</if> + <if test="designCapacity != null">design_capacity,</if> + <if test="major != null">major,</if> + <if test="planStartYear != null">plan_start_year,</if> + <if test="planStartMonth != null">plan_start_month,</if> + <if test="planStartDay != null">plan_start_day,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null">#{id},</if> + <if test="workOrderNo != null">#{workOrderNo},</if> + <if test="roadProcessNumber != null and roadProcessNumber != ''">#{roadProcessNumber},</if> + <if test="currentProcessNumber != null">#{currentProcessNumber},</if> + <if test="productionQuantity != null">#{productionQuantity},</if> + <if test="standardTime != null">#{standardTime},</if> + <if test="processTotalTime != null">#{processTotalTime},</if> + <if test="processPlanStartDay != null and processPlanStartDay != ''">#{processPlanStartDay},</if> + <if test="designTimes != null">#{designTimes},</if> + <if test="delFlag != null">#{delFlag},</if> + <if test="createBy != null">#{createBy},</if> + <if test="processName != null">#{processName},</if> + <if test="createTime != null">#{createTime},</if> + <if test="itemNumber != null">#{itemNumber},</if> + <if test="standardDosage != null">#{standardDosage},</if> + <if test="processTotalDosage != null">#{processTotalDosage},</if> + <if test="designCapacity != null">#{designCapacity},</if> + <if test="major != null">#{major},</if> + <if test="planStartYear != null">#{planStartYear},</if> + <if test="planStartMonth != null">#{planStartMonth},</if> + <if test="planStartDay != null">#{planStartDay},</if> + </trim> + </insert> + + <update id="updateApsGasPipingRouteStat" parameterType="ApsGasPipingRouteStat"> + update aps_gas_piping_route_stat + <trim prefix="SET" suffixOverrides=","> + <if test="workOrderNo != null">work_order_no = #{workOrderNo},</if> + <if test="roadProcessNumber != null and roadProcessNumber != ''">road_process_number = #{roadProcessNumber},</if> + <if test="currentProcessNumber != null">current_process_number = #{currentProcessNumber},</if> + <if test="productionQuantity != null">production_quantity = #{productionQuantity},</if> + <if test="standardTime != null">standard_time = #{standardTime},</if> + <if test="processTotalTime != null">process_total_time = #{processTotalTime},</if> + <if test="processPlanStartDay != null and processPlanStartDay != ''">process_plan_start_day = #{processPlanStartDay},</if> + <if test="designTimes != null">design_times = #{designTimes},</if> + <if test="delFlag != null">del_flag = #{delFlag},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="processName != null">process_name = #{processName},</if> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="itemNumber != null">item_number = #{itemNumber},</if> + <if test="standardDosage != null">standard_dosage = #{standardDosage},</if> + <if test="processTotalDosage != null">process_total_dosage = #{processTotalDosage},</if> + <if test="designCapacity != null">design_capacity = #{designCapacity},</if> + <if test="major != null">major = #{major},</if> + <if test="planStartYear != null">plan_start_year = #{planStartYear},</if> + <if test="planStartMonth != null">plan_start_month = #{planStartMonth},</if> + <if test="planStartDay != null">plan_start_day = #{planStartDay},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteApsGasPipingRouteStatById" parameterType="String"> + delete from aps_gas_piping_route_stat where id = #{id} + </delete> + + <delete id="deleteApsGasPipingRouteStatByIds" parameterType="String"> + delete from aps_gas_piping_route_stat where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> + + <delete id="deleteApsGasPipingRouteStatByBatchNum" parameterType="String"> + delete from aps_gas_piping_route_stat where batch_number != #{batchNumber} + </delete> + + <insert id="insertApsGasPipingRouteStatBatch"> + INSERT INTO aps_gas_piping_route_stat + ( + id,work_order_no, road_process_number, current_process_number, production_quantity, standard_time, + process_total_time, 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,batch_number + ) + VALUES + <foreach collection="apsGasPipingRouteStatList" item="stat" separator=","> + ( + #{stat.id},#{stat.workOrderNo}, #{stat.roadProcessNumber}, #{stat.currentProcessNumber}, #{stat.productionQuantity}, + #{stat.standardTime}, #{stat.processTotalTime}, #{stat.processPlanStartDay}, #{stat.designTimes}, #{stat.delFlag}, + #{stat.createBy}, #{stat.processName}, #{stat.createTime}, #{stat.itemNumber}, #{stat.standardDosage}, + #{stat.processTotalDosage}, #{stat.designCapacity}, #{stat.major}, #{stat.planStartYear}, + #{stat.planStartMonth}, #{stat.planStartDay}, #{stat.batchNumber} + ) + </foreach> + + </insert> + +</mapper> \ No newline at end of file diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsProcessRouteMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsProcessRouteMapper.xml index b277710..dfc842a 100644 --- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsProcessRouteMapper.xml +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsProcessRouteMapper.xml @@ -145,4 +145,5 @@ <select id="selectProcessNameList" parameterType="String" resultMap="ApsProcessRouteResult"> select DISTINCT process_name from aps_process_route where org_code = #{orgCode} </select> + </mapper> \ No newline at end of file -- Gitblit v1.9.3