tuqin
6 天以前 bc136ac1a5fa5b29dc4d06a5de9bc3332b2aea47
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
package cn.iocoder.yudao.module.mes.controller.admin.em.meter;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mes.controller.admin.em.meter.vo.MesEmMeterPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.em.meter.vo.MesEmMeterRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.em.meter.vo.MesEmMeterSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.em.meter.vo.MesEmOptionRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.em.meter.MesEmMeterDO;
import cn.iocoder.yudao.module.mes.service.em.meter.MesEmMeterService;
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.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.Collections;
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - MES 能耗计量点")
@RestController
@RequestMapping("/mes/em/meter")
@Validated
public class MesEmMeterController {
 
    @Resource
    private MesEmMeterService meterService;
 
    @PostMapping("/create")
    @Operation(summary = "创建能耗计量点")
    @PreAuthorize("@ss.hasPermission('mes:em-meter:create')")
    public CommonResult<Long> createMeter(@Valid @RequestBody MesEmMeterSaveReqVO createReqVO) {
        return success(meterService.createMeter(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新能耗计量点")
    @PreAuthorize("@ss.hasPermission('mes:em-meter:update')")
    public CommonResult<Boolean> updateMeter(@Valid @RequestBody MesEmMeterSaveReqVO updateReqVO) {
        meterService.updateMeter(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除能耗计量点")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:em-meter:delete')")
    public CommonResult<Boolean> deleteMeter(@RequestParam("id") Long id) {
        meterService.deleteMeter(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得能耗计量点")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<MesEmMeterRespVO> getMeter(@RequestParam("id") Long id) {
        MesEmMeterDO meter = meterService.getMeter(id);
        if (meter == null) {
            return success(null);
        }
        return success(meterService.getMeterRespVOList(Collections.singletonList(meter)).get(0));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得能耗计量点分页")
    public CommonResult<PageResult<MesEmMeterRespVO>> getMeterPage(@Valid MesEmMeterPageReqVO pageReqVO) {
        PageResult<MesEmMeterDO> pageResult = meterService.getMeterPage(pageReqVO);
        return success(new PageResult<>(meterService.getMeterRespVOList(pageResult.getList()),
                pageResult.getTotal()));
    }
 
    @GetMapping("/simple-list")
    @Operation(summary = "获得启用中的能耗计量点精简列表")
    public CommonResult<List<MesEmOptionRespVO>> getMeterSimpleList() {
        return success(meterService.getMeterSimpleList());
    }
 
    @GetMapping("/workshop-options")
    @Operation(summary = "获得车间下拉选项")
    public CommonResult<List<MesEmOptionRespVO>> getWorkshopOptions() {
        return success(meterService.getWorkshopOptions());
    }
 
    @GetMapping("/line-options")
    @Operation(summary = "获得产线下拉选项")
    public CommonResult<List<MesEmOptionRespVO>> getLineOptions() {
        return success(meterService.getLineOptions());
    }
 
    @GetMapping("/machinery-options")
    @Operation(summary = "获得设备下拉选项")
    public CommonResult<List<MesEmOptionRespVO>> getMachineryOptions() {
        return success(meterService.getMachineryOptions());
    }
 
}