zhanghl
2025-05-06 d66be8ca5ce1e89dcd6a12a6648c6a9d759dd4f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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;
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.common.security.utils.SecurityUtils;
import com.aps.core.domain.ApsGasPipelineCapacityPlan;
import com.aps.core.domain.ApsStandardProcess;
import com.aps.core.service.IApsGasPipelineCapacityPlanService;
import com.aps.core.service.IApsStandardProcessService;
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.ArrayList;
import java.util.List;
 
/**
 * 气体管路产能规划Controller
 * 
 * @author hjy
 * @date 2025-04-24
 */
 
@Tag(name = "气体管路产能规划", description = "气体管路产能规划接口")
@RestController
@RequestMapping("/gasPipelineCapacityPlan")
public class ApsGasPipelineCapacityPlanController extends BaseController
{
    @Autowired
    private IApsGasPipelineCapacityPlanService apsGasPipelineCapacityPlanService;
 
    @Autowired
    private IApsStandardProcessService apsStandardProcessService;
 
    /**
     * 查询气体管路产能规划列表
     */
    @Operation(summary = "查询气体管路产能规划列表", description = "分页查询")
    @RequiresPermissions("aps:gasPipelineCapacityPlan:list")
    @GetMapping("/list")
    public TableDataInfo list(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
    {
//        startPage();
        List<ApsGasPipelineCapacityPlan> list = apsGasPipelineCapacityPlanService.selectApsGasPipelineCapacityPlanList(apsGasPipelineCapacityPlan);
        ApsStandardProcess apsStandardProcess = new ApsStandardProcess();
        apsStandardProcess.setMajor(apsGasPipelineCapacityPlan.getMajor());
        List<ApsStandardProcess> processList = apsStandardProcessService.selectApsStandardProcessListAll(apsStandardProcess);
        if(list.isEmpty()){
            for(ApsStandardProcess apsStandardProcessTemp : processList){
                ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlanTemp = new ApsGasPipelineCapacityPlan();
                apsGasPipelineCapacityPlanTemp.setProcessName(apsStandardProcessTemp.getProcessName());
                list.add(apsGasPipelineCapacityPlanTemp);
            }
        }
        if(processList.size()>list.size()){
            List<String> newProcess = new ArrayList<>();
            for(ApsStandardProcess apsStandardProcessTemp : processList){
                boolean flag = true;
                for(ApsGasPipelineCapacityPlan temp : list){
                    if(apsStandardProcessTemp.getProcessName().equals(temp.getProcessName())){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    newProcess.add(apsStandardProcessTemp.getProcessName());
                }
            }
            for(String processName : newProcess){
                ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlanTemp = new ApsGasPipelineCapacityPlan();
                apsGasPipelineCapacityPlanTemp.setProcessName(processName);
                list.add(apsGasPipelineCapacityPlanTemp);
            }
        }
        list.sort((a, b)->a.getProcessName().compareTo(b.getProcessName()));
        return getDataTable(list);
    }
 
    /**
     * 导出气体管路产能规划列表
     */
    @Operation(summary = "导出气体管路产能规划列表", description = "导出")
    @RequiresPermissions("aps:gasPipelineCapacityPlan:export")
    @Log(title = "气体管路产能规划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    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 = "根据id获取")
    @RequiresPermissions("aps:gasPipelineCapacityPlan:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(apsGasPipelineCapacityPlanService.selectApsGasPipelineCapacityPlanById(id));
    }
 
    /**
     * 新增气体管路产能规划
     */
    @Operation(summary = "新增气体管路产能规划", description = "单个新增")
    @RequiresPermissions("aps:gasPipelineCapacityPlan:add")
    @Log(title = "气体管路产能规划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlan)
    {
        apsGasPipelineCapacityPlan.forEach(apsGasPipelineCapacityPlanTemp -> {
            if(apsGasPipelineCapacityPlanTemp.getId()==null){
                apsGasPipelineCapacityPlanTemp.setCreateBy(SecurityUtils.getUsername());
                apsGasPipelineCapacityPlanTemp.setCreateTime(DateUtils.getNowDate());
                apsGasPipelineCapacityPlanService.insertApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp);
            }else{
                apsGasPipelineCapacityPlanTemp.setUpdateBy(SecurityUtils.getUsername());
                apsGasPipelineCapacityPlanTemp.setUpdateTime(DateUtils.getNowDate());
                apsGasPipelineCapacityPlanService.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlanTemp);
            }
        });
        return AjaxResult.success();
    }
 
    /**
     * 修改气体管路产能规划
     */
    @Operation(summary = "修改气体管路产能规划", description = "单个修改")
    @RequiresPermissions("aps:gasPipelineCapacityPlan:edit")
    @Log(title = "气体管路产能规划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan)
    {
        return toAjax(apsGasPipelineCapacityPlanService.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan));
    }
 
    /**
     * 删除气体管路产能规划
     */
    @Operation(summary = "删除气体管路产能规划", description = "批量删除")
    @RequiresPermissions("aps:gasPipelineCapacityPlan:remove")
    @Log(title = "气体管路产能规划", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(apsGasPipelineCapacityPlanService.deleteApsGasPipelineCapacityPlanByIds(ids));
    }
}