From 6da289fff756eaecc600422d77c4afff1ddebab0 Mon Sep 17 00:00:00 2001
From: zhanghl <253316343@qq.com>
Date: 星期五, 23 五月 2025 15:23:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsGasPipelineCapacityPlanController.java |  115 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 85 insertions(+), 30 deletions(-)

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 db7b77d..0b08b15 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
@@ -1,5 +1,6 @@
 package com.aps.core.controller.basicData;
 
+import com.aps.common.core.utils.DateUtils;
 import com.aps.common.core.utils.poi.ExcelUtil;
 import com.aps.common.core.web.controller.BaseController;
 import com.aps.common.core.web.domain.AjaxResult;
@@ -7,9 +8,12 @@
 import com.aps.common.log.annotation.Log;
 import com.aps.common.log.enums.BusinessType;
 import com.aps.common.security.annotation.RequiresPermissions;
+import com.aps.common.security.utils.SecurityUtils;
 import com.aps.core.domain.ApsGasPipelineCapacityPlan;
+import com.aps.core.domain.ApsShop;
 import com.aps.core.domain.ApsStandardProcess;
 import com.aps.core.service.IApsGasPipelineCapacityPlanService;
+import com.aps.core.service.IApsShopService;
 import com.aps.core.service.IApsStandardProcessService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -18,11 +22,13 @@
 import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 姘斾綋绠¤矾浜ц兘瑙勫垝Controller
- * 
+ *
  * @author hjy
  * @date 2025-04-24
  */
@@ -30,54 +36,83 @@
 @Tag(name = "姘斾綋绠¤矾浜ц兘瑙勫垝", description = "姘斾綋绠¤矾浜ц兘瑙勫垝鎺ュ彛")
 @RestController
 @RequestMapping("/gasPipelineCapacityPlan")
-public class ApsGasPipelineCapacityPlanController extends BaseController
-{
+public class ApsGasPipelineCapacityPlanController extends BaseController {
     @Autowired
     private IApsGasPipelineCapacityPlanService apsGasPipelineCapacityPlanService;
 
     @Autowired
     private IApsStandardProcessService apsStandardProcessService;
 
+    @Autowired
+    private IApsShopService apsShopService;
+
     /**
      * 鏌ヨ姘斾綋绠¤矾浜ц兘瑙勫垝鍒楄〃
      */
     @Operation(summary = "鏌ヨ姘斾綋绠¤矾浜ц兘瑙勫垝鍒楄〃", description = "鍒嗛〉鏌ヨ")
-    @RequiresPermissions("aps:gasPipelineCapacityPlan:list")
+//    @RequiresPermissions("aps:gasPipelineCapacityPlan:list")
     @GetMapping("/list")
-    public TableDataInfo list(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
-    {
+    public TableDataInfo list(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) {
 //        startPage();
         List<ApsGasPipelineCapacityPlan> list = apsGasPipelineCapacityPlanService.selectApsGasPipelineCapacityPlanList(apsGasPipelineCapacityPlan);
         ApsStandardProcess apsStandardProcess = new ApsStandardProcess();
         apsStandardProcess.setMajor(apsGasPipelineCapacityPlan.getMajor());
+        apsStandardProcess.setPlant(apsGasPipelineCapacityPlan.getOrgCode());
         List<ApsStandardProcess> processList = apsStandardProcessService.selectApsStandardProcessListAll(apsStandardProcess);
-        if(list.isEmpty()){
-            for(ApsStandardProcess apsStandardProcessTemp : processList){
+        List<ApsShop> apsShops = apsShopService.findShopByFactory(apsGasPipelineCapacityPlan.getOrgCode());
+        if (list.isEmpty()) {
+            for (ApsStandardProcess apsStandardProcessTemp : processList) {
                 ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlanTemp = new ApsGasPipelineCapacityPlan();
                 apsGasPipelineCapacityPlanTemp.setProcessName(apsStandardProcessTemp.getProcessName());
+                apsGasPipelineCapacityPlanTemp.setOrgCode(apsStandardProcessTemp.getPlant());
+                apsGasPipelineCapacityPlanTemp.setWorkshop(apsShops.stream()
+                        .filter(shop -> Objects.equals(shop.getShopName(), apsStandardProcessTemp.getWorkShop()))
+                        .map(ApsShop::getShopCode)
+                        .findFirst()
+                        .orElse(null));
                 list.add(apsGasPipelineCapacityPlanTemp);
             }
+        } else {
+            list.forEach(capacityPlan -> {
+                processList.stream().filter(p -> Objects.equals(p.getPlant(), capacityPlan.getOrgCode()))
+                        .filter(p -> Objects.equals(p.getMajor(), capacityPlan.getMajor()))
+                        .filter(p -> p.getWorkShop() != null)
+                        .findFirst().ifPresent(p -> {
+                            capacityPlan.setWorkshop(apsShops.stream()
+                                    .filter(shop -> Objects.equals(shop.getShopCode(), p.getWorkShop()))
+                                    .map(ApsShop::getShopName)
+                                    .findFirst()
+                                    .orElse(null));
+                        });
+            });
         }
-        if(processList.size()>list.size()){
-            List<String> newProcess = new ArrayList<>();
-            for(ApsStandardProcess apsStandardProcessTemp : processList){
+        if (processList.size() > list.size()) {
+            List<ApsStandardProcess> newProcess = new ArrayList<>();
+            for (ApsStandardProcess apsStandardProcessTemp : processList) {
                 boolean flag = true;
-                for(ApsGasPipelineCapacityPlan temp : list){
-                    if(apsStandardProcessTemp.getProcessName().equals(temp.getProcessName())){
+                for (ApsGasPipelineCapacityPlan temp : list) {
+                    if (apsStandardProcessTemp.getProcessName().equals(temp.getProcessName())) {
                         flag = false;
                         break;
                     }
                 }
-                if(flag){
-                    newProcess.add(apsStandardProcessTemp.getProcessName());
+                if (flag) {
+                    newProcess.add(apsStandardProcessTemp);
                 }
             }
-            for(String processName : newProcess){
+            for (ApsStandardProcess process : newProcess) {
                 ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlanTemp = new ApsGasPipelineCapacityPlan();
-                apsGasPipelineCapacityPlanTemp.setProcessName(processName);
+                apsGasPipelineCapacityPlanTemp.setProcessName(process.getProcessName());
+                apsGasPipelineCapacityPlanTemp.setOrgCode(process.getPlant());
+                apsGasPipelineCapacityPlanTemp.setWorkshop(apsShops.stream()
+                        .filter(shop -> Objects.equals(shop.getShopName(), process.getWorkShop()))
+                        .map(ApsShop::getShopCode)
+                        .findFirst()
+                        .orElse(null));
                 list.add(apsGasPipelineCapacityPlanTemp);
             }
         }
+        list.sort(Comparator.comparing(ApsGasPipelineCapacityPlan::getProcessName));
         return getDataTable(list);
     }
 
@@ -88,11 +123,31 @@
     @RequiresPermissions("aps:gasPipelineCapacityPlan:export")
     @Log(title = "姘斾綋绠¤矾浜ц兘瑙勫垝", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
-    {
+    public void export(HttpServletResponse response, ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) {
         List<ApsGasPipelineCapacityPlan> list = apsGasPipelineCapacityPlanService.selectApsGasPipelineCapacityPlanList(apsGasPipelineCapacityPlan);
         ExcelUtil<ApsGasPipelineCapacityPlan> util = new ExcelUtil<ApsGasPipelineCapacityPlan>(ApsGasPipelineCapacityPlan.class);
         util.exportExcel(response, list, "姘斾綋绠¤矾浜ц兘瑙勫垝鏁版嵁");
+    }
+
+
+    /**
+     * 澶嶅埗姘斾綋绠¤矾浜ц兘瑙勫垝
+     */
+    @Operation(summary = "澶嶅埗姘斾綋绠¤矾浜ц兘瑙勫垝", description = "澶嶅埗")
+//    @RequiresPermissions("aps:gasPipelineCapacityPlan:copy")
+    @Log(title = "澶嶅埗姘斾綋绠¤矾浜ц兘瑙勫垝", businessType = BusinessType.INSERT)
+    @PutMapping("/copy")
+    public AjaxResult copy(
+            // 鏍煎紡锛歽yyy-MM
+            @RequestParam String date,
+            @RequestParam String factory,
+            @RequestParam String major,
+            // 鏍煎紡锛歽yyy-MM
+            @RequestParam String toStart,
+            // 鏍煎紡锛歽yyy-MM
+            @RequestParam String toEnd) {
+        apsGasPipelineCapacityPlanService.copyPlan(date, factory, major, toStart, toEnd);
+        return success();
     }
 
     /**
@@ -101,8 +156,7 @@
     @Operation(summary = "鑾峰彇姘斾綋绠¤矾浜ц兘瑙勫垝璇︾粏淇℃伅", description = "鏍规嵁id鑾峰彇")
     @RequiresPermissions("aps:gasPipelineCapacityPlan:query")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(apsGasPipelineCapacityPlanService.selectApsGasPipelineCapacityPlanById(id));
     }
 
@@ -113,12 +167,15 @@
     @RequiresPermissions("aps:gasPipelineCapacityPlan:add")
     @Log(title = "姘斾綋绠¤矾浜ц兘瑙勫垝", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlan)
-    {
+    public AjaxResult add(@RequestBody List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlan) {
         apsGasPipelineCapacityPlan.forEach(apsGasPipelineCapacityPlanTemp -> {
-            if(apsGasPipelineCapacityPlanTemp.getId()==null){
+            if (apsGasPipelineCapacityPlanTemp.getId() == null) {
+                apsGasPipelineCapacityPlanTemp.setCreateBy(SecurityUtils.getUsername());
+                apsGasPipelineCapacityPlanTemp.setCreateTime(DateUtils.getNowDate());
                 apsGasPipelineCapacityPlanService.insertApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp);
-            }else{
+            } else {
+                apsGasPipelineCapacityPlanTemp.setUpdateBy(SecurityUtils.getUsername());
+                apsGasPipelineCapacityPlanTemp.setUpdateTime(DateUtils.getNowDate());
                 apsGasPipelineCapacityPlanService.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp);
             }
         });
@@ -132,8 +189,7 @@
     @RequiresPermissions("aps:gasPipelineCapacityPlan:edit")
     @Log(title = "姘斾綋绠¤矾浜ц兘瑙勫垝", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
-    {
+    public AjaxResult edit(@RequestBody ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) {
         return toAjax(apsGasPipelineCapacityPlanService.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan));
     }
 
@@ -143,9 +199,8 @@
     @Operation(summary = "鍒犻櫎姘斾綋绠¤矾浜ц兘瑙勫垝", description = "鎵归噺鍒犻櫎")
     @RequiresPermissions("aps:gasPipelineCapacityPlan:remove")
     @Log(title = "姘斾綋绠¤矾浜ц兘瑙勫垝", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(apsGasPipelineCapacityPlanService.deleteApsGasPipelineCapacityPlanByIds(ids));
     }
 }

--
Gitblit v1.9.3