yangys
2024-10-30 25db770e621f1259b8d5b7fd514207f7481c2d0f
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
package com.qianwen.smartman.modules.cps.controller;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import javax.validation.Valid;
import com.qianwen.smartman.common.enums.DynamicCalculationWcsDataType;
import com.qianwen.core.boot.ctrl.BladeController;
import com.qianwen.core.scanner.modular.annotation.DeleteResource;
import com.qianwen.core.scanner.modular.annotation.GetResource;
import com.qianwen.core.scanner.modular.annotation.PostResource;
import com.qianwen.core.scanner.modular.annotation.PutResource;
import com.qianwen.core.scanner.modular.stereotype.ApiResource;
import com.qianwen.core.secure.annotation.PreAuth;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.cps.service.IWorkstationWcsUsageService;
import com.qianwen.smartman.modules.cps.vo.WorkstationDataTypeExecParamVO;
import com.qianwen.smartman.modules.cps.vo.WorkstationWcsUsageVO;
import com.qianwen.smartman.modules.system.vo.ChartSelect;
import com.qianwen.smartman.modules.visual.vo.VisualUsagePolicyEnum;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
 
@Api(value = "获取数据数据标签", tags = {"获取数据数据标签"})
@RestController
@ApiResource({"smis/workstation-wcs-usage"})
@Validated
public class WorkstationWcsUsageController extends BladeController {
    private final IWorkstationWcsUsageService workstationWcsUsageService;
 
    public WorkstationWcsUsageController(final IWorkstationWcsUsageService workstationWcsUsageService) {
        this.workstationWcsUsageService = workstationWcsUsageService;
    }
 
    @PreAuth
    @GetResource({"/list"})
    @ApiOperation("获取所有数据数据标签数据")
    public R<List<WorkstationWcsUsageVO>> list() {
        return R.data(this.workstationWcsUsageService.listVO());
    }
 
    @PreAuth
    @PutResource
    @ApiOperation(value = "保存数据标签", notes = "插入数据数据标签,数据数据标签的名称不能重复")
    public R<Boolean> save(@Valid @RequestBody WorkstationWcsUsageVO workstationWcsVO) {
        return R.data(this.workstationWcsUsageService.save(workstationWcsVO));
    }
 
    @PreAuth
    @PostResource
    @ApiOperation("更新数据标签")
    public R<Boolean> update(@Valid @RequestBody WorkstationWcsUsageVO workstationWcsVO) {
        return R.data(this.workstationWcsUsageService.update(workstationWcsVO));
    }
 
    @PreAuth
    @DeleteResource
    @ApiOperation("删除数据标签")
    public R<Boolean> remove(@RequestBody String id) {
        return R.data(this.workstationWcsUsageService.remove(Long.valueOf(Func.toLong(id))));
    }
 
    @PreAuth
    @GetResource({"/params-config/{collectType}"})
    @ApiOperation("获取计算方式的参数配置")
    public R<List<WorkstationDataTypeExecParamVO>> paramsConfig(@PathVariable Integer collectType) {
        return R.data(DynamicCalculationWcsDataType.getParamsByCode(collectType.intValue()));
    }
 
    @GetMapping({"/visual-usage-code"})
    @ApiOperation(value = "获取大屏接口参数", notes = "数据数据标签下拉")
    public R<List<ChartSelect>> visualUsageCode() {
        List<ChartSelect> chartSelects = (List) this.workstationWcsUsageService.listVO().stream().filter(it -> {
            return DynamicCalculationWcsDataType.of(it.getCollectType().intValue()) != null;
        }).map(it2 -> {
            return new ChartSelect() { // from class: org.springblade.modules.cps.controller.WorkstationWcsUsageController.1
                @Override // org.springblade.modules.system.vo.ChartSelect
                public String getLabel() {
                    return it2.getUsageName();
                }
 
                @Override // org.springblade.modules.system.vo.ChartSelect
                public String getValue() {
                    return Func.toStr(it2.getUsageCode());
                }
            };
        }).collect(Collectors.toList());
        return R.data(chartSelects);
    }
 
    @GetMapping({"/visual-usage-policy"})
    @ApiOperation(value = "获取大屏接口参数", notes = "数据标签策略下拉")
    public R<List<ChartSelect>> visualUsagePolicy() {
        List<ChartSelect> chartSelects = (List) Arrays.stream(VisualUsagePolicyEnum.values()).map(it -> {
            return new ChartSelect() { // from class: org.springblade.modules.cps.controller.WorkstationWcsUsageController.2
                @Override // org.springblade.modules.system.vo.ChartSelect
                public String getLabel() {
                    return it.getLabel();
                }
 
                @Override // org.springblade.modules.system.vo.ChartSelect
                public String getValue() {
                    return it.name();
                }
            };
        }).collect(Collectors.toList());
        return R.data(chartSelects);
    }
}