xiaoyi
4 天以前 abf1c0a35d85d38239ff5d2ed746a4e4b797c9d1
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
package cn.iocoder.yudao.module.mes.controller.admin.pd.basedata;
 
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.mes.controller.admin.pd.basedata.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.pd.basedata.MesPdElectricityTypeDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pd.basedata.MesPdServicePackageDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pd.basedata.MesPdVoltageLevelDO;
import cn.iocoder.yudao.module.mes.service.pd.basedata.MesPdDiscountPolicyService;
import cn.iocoder.yudao.module.mes.service.pd.basedata.MesPdElectricityTypeService;
import cn.iocoder.yudao.module.mes.service.pd.basedata.MesPdPriceStandardService;
import cn.iocoder.yudao.module.mes.service.pd.basedata.MesPdServicePackageService;
import cn.iocoder.yudao.module.mes.service.pd.basedata.MesPdTieredPriceService;
import cn.iocoder.yudao.module.mes.service.pd.basedata.MesPdVoltageLevelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.io.IOException;
import java.util.List;
 
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - MES 产品基础数据")
@RestController
@RequestMapping("/mes/pd")
@Validated
public class MesPdBaseDataController {
 
    @Resource
    private MesPdElectricityTypeService electricityTypeService;
    @Resource
    private MesPdVoltageLevelService voltageLevelService;
    @Resource
    private MesPdServicePackageService servicePackageService;
    @Resource
    private MesPdPriceStandardService priceStandardService;
    @Resource
    private MesPdDiscountPolicyService discountPolicyService;
    @Resource
    private MesPdTieredPriceService tieredPriceService;
 
    // ==================== 用电类型 ====================
 
    @PostMapping("/electricity-type/create")
    @Operation(summary = "创建用电类型")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:create')")
    public CommonResult<Long> createElectricityType(@Valid @RequestBody MesPdElectricityTypeSaveReqVO createReqVO) {
        return success(electricityTypeService.createElectricityType(createReqVO));
    }
 
    @PutMapping("/electricity-type/update")
    @Operation(summary = "更新用电类型")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:update')")
    public CommonResult<Boolean> updateElectricityType(@Valid @RequestBody MesPdElectricityTypeSaveReqVO updateReqVO) {
        electricityTypeService.updateElectricityType(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/electricity-type/delete")
    @Operation(summary = "删除用电类型")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:delete')")
    public CommonResult<Boolean> deleteElectricityType(@RequestParam("id") Long id) {
        electricityTypeService.deleteElectricityType(id);
        return success(true);
    }
 
    @GetMapping("/electricity-type/get")
    @Operation(summary = "获得用电类型")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<MesPdElectricityTypeRespVO> getElectricityType(@RequestParam("id") Long id) {
        return success(electricityTypeService.getElectricityType(id));
    }
 
    @GetMapping("/electricity-type/page")
    @Operation(summary = "获得用电类型分页")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<PageResult<MesPdElectricityTypeRespVO>> getElectricityTypePage(@Valid MesPdElectricityTypePageReqVO pageReqVO) {
        return success(electricityTypeService.getElectricityTypePage(pageReqVO));
    }
 
    @GetMapping("/electricity-type/list")
    @Operation(summary = "获得用电类型列表")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<List<MesPdElectricityTypeDO>> getElectricityTypeList() {
        return success(electricityTypeService.getElectricityTypeList());
    }
 
    @GetMapping("/electricity-type/export-excel")
    @Operation(summary = "导出用电类型 Excel")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportElectricityTypeExcel(@Valid MesPdElectricityTypePageReqVO pageReqVO,
                                           HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        ExcelUtils.write(response, "用电类型.xls", "数据", MesPdElectricityTypeRespVO.class,
                electricityTypeService.getElectricityTypePage(pageReqVO).getList());
    }
 
    // ==================== 电压等级 ====================
 
    @PostMapping("/voltage-level/create")
    @Operation(summary = "创建电压等级")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:create')")
    public CommonResult<Long> createVoltageLevel(@Valid @RequestBody MesPdVoltageLevelSaveReqVO createReqVO) {
        return success(voltageLevelService.createVoltageLevel(createReqVO));
    }
 
    @PutMapping("/voltage-level/update")
    @Operation(summary = "更新电压等级")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:update')")
    public CommonResult<Boolean> updateVoltageLevel(@Valid @RequestBody MesPdVoltageLevelSaveReqVO updateReqVO) {
        voltageLevelService.updateVoltageLevel(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/voltage-level/delete")
    @Operation(summary = "删除电压等级")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:delete')")
    public CommonResult<Boolean> deleteVoltageLevel(@RequestParam("id") Long id) {
        voltageLevelService.deleteVoltageLevel(id);
        return success(true);
    }
 
    @GetMapping("/voltage-level/get")
    @Operation(summary = "获得电压等级")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<MesPdVoltageLevelRespVO> getVoltageLevel(@RequestParam("id") Long id) {
        return success(voltageLevelService.getVoltageLevel(id));
    }
 
    @GetMapping("/voltage-level/page")
    @Operation(summary = "获得电压等级分页")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<PageResult<MesPdVoltageLevelRespVO>> getVoltageLevelPage(@Valid MesPdVoltageLevelPageReqVO pageReqVO) {
        return success(voltageLevelService.getVoltageLevelPage(pageReqVO));
    }
 
    @GetMapping("/voltage-level/list")
    @Operation(summary = "获得电压等级列表")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<List<MesPdVoltageLevelDO>> getVoltageLevelList() {
        return success(voltageLevelService.getVoltageLevelList());
    }
 
    @GetMapping("/voltage-level/export-excel")
    @Operation(summary = "导出电压等级 Excel")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportVoltageLevelExcel(@Valid MesPdVoltageLevelPageReqVO pageReqVO,
                                        HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        ExcelUtils.write(response, "电压等级.xls", "数据", MesPdVoltageLevelRespVO.class,
                voltageLevelService.getVoltageLevelPage(pageReqVO).getList());
    }
 
    // ==================== 服务套餐 ====================
 
    @PostMapping("/service-package/create")
    @Operation(summary = "创建服务套餐")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:create')")
    public CommonResult<Long> createServicePackage(@Valid @RequestBody MesPdServicePackageSaveReqVO createReqVO) {
        return success(servicePackageService.createServicePackage(createReqVO));
    }
 
    @PutMapping("/service-package/update")
    @Operation(summary = "更新服务套餐")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:update')")
    public CommonResult<Boolean> updateServicePackage(@Valid @RequestBody MesPdServicePackageSaveReqVO updateReqVO) {
        servicePackageService.updateServicePackage(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/service-package/delete")
    @Operation(summary = "删除服务套餐")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:delete')")
    public CommonResult<Boolean> deleteServicePackage(@RequestParam("id") Long id) {
        servicePackageService.deleteServicePackage(id);
        return success(true);
    }
 
    @GetMapping("/service-package/get")
    @Operation(summary = "获得服务套餐")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<MesPdServicePackageRespVO> getServicePackage(@RequestParam("id") Long id) {
        return success(servicePackageService.getServicePackage(id));
    }
 
    @GetMapping("/service-package/page")
    @Operation(summary = "获得服务套餐分页")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<PageResult<MesPdServicePackageRespVO>> getServicePackagePage(@Valid MesPdServicePackagePageReqVO pageReqVO) {
        return success(servicePackageService.getServicePackagePage(pageReqVO));
    }
 
    @GetMapping("/service-package/list")
    @Operation(summary = "获得服务套餐列表")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<List<MesPdServicePackageDO>> getServicePackageList() {
        return success(servicePackageService.getServicePackageList());
    }
 
    @GetMapping("/service-package/export-excel")
    @Operation(summary = "导出服务套餐 Excel")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportServicePackageExcel(@Valid MesPdServicePackagePageReqVO pageReqVO,
                                          HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        ExcelUtils.write(response, "服务套餐.xls", "数据", MesPdServicePackageRespVO.class,
                servicePackageService.getServicePackagePage(pageReqVO).getList());
    }
 
    // ==================== 定价标准 ====================
 
    @PostMapping("/price-standard/create")
    @Operation(summary = "创建定价标准")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:create')")
    public CommonResult<Long> createPriceStandard(@Valid @RequestBody MesPdPriceStandardSaveReqVO createReqVO) {
        return success(priceStandardService.createPriceStandard(createReqVO));
    }
 
    @PutMapping("/price-standard/update")
    @Operation(summary = "更新定价标准")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:update')")
    public CommonResult<Boolean> updatePriceStandard(@Valid @RequestBody MesPdPriceStandardSaveReqVO updateReqVO) {
        priceStandardService.updatePriceStandard(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/price-standard/delete")
    @Operation(summary = "删除定价标准")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:delete')")
    public CommonResult<Boolean> deletePriceStandard(@RequestParam("id") Long id) {
        priceStandardService.deletePriceStandard(id);
        return success(true);
    }
 
    @GetMapping("/price-standard/get")
    @Operation(summary = "获得定价标准")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<MesPdPriceStandardRespVO> getPriceStandard(@RequestParam("id") Long id) {
        return success(priceStandardService.getPriceStandard(id));
    }
 
    @GetMapping("/price-standard/page")
    @Operation(summary = "获得定价标准分页")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<PageResult<MesPdPriceStandardRespVO>> getPriceStandardPage(@Valid MesPdPriceStandardPageReqVO pageReqVO) {
        return success(priceStandardService.getPriceStandardPage(pageReqVO));
    }
 
    @GetMapping("/price-standard/export-excel")
    @Operation(summary = "导出定价标准 Excel")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportPriceStandardExcel(@Valid MesPdPriceStandardPageReqVO pageReqVO,
                                         HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        ExcelUtils.write(response, "定价标准.xls", "数据", MesPdPriceStandardRespVO.class,
                priceStandardService.getPriceStandardPage(pageReqVO).getList());
    }
 
    // ==================== 优惠策略 ====================
 
    @PostMapping("/discount-policy/create")
    @Operation(summary = "创建优惠策略")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:create')")
    public CommonResult<Long> createDiscountPolicy(@Valid @RequestBody MesPdDiscountPolicySaveReqVO createReqVO) {
        return success(discountPolicyService.createDiscountPolicy(createReqVO));
    }
 
    @PutMapping("/discount-policy/update")
    @Operation(summary = "更新优惠策略")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:update')")
    public CommonResult<Boolean> updateDiscountPolicy(@Valid @RequestBody MesPdDiscountPolicySaveReqVO updateReqVO) {
        discountPolicyService.updateDiscountPolicy(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/discount-policy/delete")
    @Operation(summary = "删除优惠策略")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:delete')")
    public CommonResult<Boolean> deleteDiscountPolicy(@RequestParam("id") Long id) {
        discountPolicyService.deleteDiscountPolicy(id);
        return success(true);
    }
 
    @GetMapping("/discount-policy/get")
    @Operation(summary = "获得优惠策略")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<MesPdDiscountPolicyRespVO> getDiscountPolicy(@RequestParam("id") Long id) {
        return success(discountPolicyService.getDiscountPolicy(id));
    }
 
    @GetMapping("/discount-policy/page")
    @Operation(summary = "获得优惠策略分页")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<PageResult<MesPdDiscountPolicyRespVO>> getDiscountPolicyPage(@Valid MesPdDiscountPolicyPageReqVO pageReqVO) {
        return success(discountPolicyService.getDiscountPolicyPage(pageReqVO));
    }
 
    @GetMapping("/discount-policy/export-excel")
    @Operation(summary = "导出优惠策略 Excel")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportDiscountPolicyExcel(@Valid MesPdDiscountPolicyPageReqVO pageReqVO,
                                          HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        ExcelUtils.write(response, "优惠策略.xls", "数据", MesPdDiscountPolicyRespVO.class,
                discountPolicyService.getDiscountPolicyPage(pageReqVO).getList());
    }
 
    // ==================== 阶梯电价 ====================
 
    @PostMapping("/tiered-price/create")
    @Operation(summary = "创建阶梯电价")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:create')")
    public CommonResult<Long> createTieredPrice(@Valid @RequestBody MesPdTieredPriceSaveReqVO createReqVO) {
        return success(tieredPriceService.createTieredPrice(createReqVO));
    }
 
    @PutMapping("/tiered-price/update")
    @Operation(summary = "更新阶梯电价")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:update')")
    public CommonResult<Boolean> updateTieredPrice(@Valid @RequestBody MesPdTieredPriceSaveReqVO updateReqVO) {
        tieredPriceService.updateTieredPrice(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/tiered-price/delete")
    @Operation(summary = "删除阶梯电价")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:delete')")
    public CommonResult<Boolean> deleteTieredPrice(@RequestParam("id") Long id) {
        tieredPriceService.deleteTieredPrice(id);
        return success(true);
    }
 
    @GetMapping("/tiered-price/get")
    @Operation(summary = "获得阶梯电价")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<MesPdTieredPriceRespVO> getTieredPrice(@RequestParam("id") Long id) {
        return success(tieredPriceService.getTieredPrice(id));
    }
 
    @GetMapping("/tiered-price/page")
    @Operation(summary = "获得阶梯电价分页")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:query')")
    public CommonResult<PageResult<MesPdTieredPriceRespVO>> getTieredPricePage(@Valid MesPdTieredPricePageReqVO pageReqVO) {
        return success(tieredPriceService.getTieredPricePage(pageReqVO));
    }
 
    @GetMapping("/tiered-price/export-excel")
    @Operation(summary = "导出阶梯电价 Excel")
    @PreAuthorize("@ss.hasPermission('mes:pd-basedata:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportTieredPriceExcel(@Valid MesPdTieredPricePageReqVO pageReqVO,
                                       HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        ExcelUtils.write(response, "阶梯电价.xls", "数据", MesPdTieredPriceRespVO.class,
                tieredPriceService.getTieredPricePage(pageReqVO).getList());
    }
 
}