liujie
2026-04-02 8ed8ea0817c0c62b31f24e27c57135aa252e1389
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
package com.estate.expert.admin.controller.admin.option;
 
import com.estate.expert.admin.domain.business.device.DeviceType;
import com.estate.expert.admin.domain.common.option.SelectOptionVo;
import com.estate.expert.admin.domain.common.request.BatchReq;
import com.estate.expert.admin.domain.report.ReportTemplateType;
import com.estate.expert.admin.service.*;
import com.estate.expert.admin.service.expert.DeviceExpertService;
import com.estate.expert.admin.service.expert.SysExpertService;
import com.estate.expert.admin.service.model.DeviceModelService;
import com.estate.expert.admin.service.model.SystemModelService;
import com.estate.expert.common.rpc.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.stream.Collectors;
 
@Api(tags = "管理后台/选项/实体选项")
@Slf4j
@RequestMapping("/admin/entity")
@CrossOrigin
@RestController
@Validated
public class OptionEntityController {
 
    @Resource
    private RoleService roleService;
 
    @Resource
    private DeviceModelService deviceModelService;
 
    @Resource
    private SystemModelService systemModelService;
 
    @Resource
    private DeviceService deviceService;
 
    @Resource
    private UserService userService;
 
    @Resource
    private CheckTaskService checkTaskService;
 
    @Resource
    private PlanService planService;
 
    @Resource
    private ClientService clientService;
 
    @Resource
    private ProjectService projectService;
 
    @Resource
    private CarService carService;
 
    @Resource
    private SysExpertService sysExpertService;
 
    @Resource
    private DeviceExpertService deviceExpertService;
 
    @Resource
    private ReportTemplateService reportTemplateService;
 
    @ApiOperation(value = "岗位下拉框")
    @RequestMapping("/roles")
    public Result roles(@RequestParam(value = "title", required = false) String title) {
        return Result.success(SelectOptionVo.buildOptions(title, roleService.findAll()));
    }
 
    @ApiOperation(value = "委托方下拉框")
    @RequestMapping("/clients")
    public Result clients(@RequestParam(value = "title", required = false) String title,
                         @RequestParam(value = "keyword", required = false) String keyword) {
        return Result.success(SelectOptionVo.buildOptions(title, clientService.list(keyword)));
    }
 
    @ApiOperation(value = "项目下拉框")
    @RequestMapping("/projects")
    public Result projects(@RequestParam(value = "title", required = false) String title,
                           @RequestParam(value = "clientId", required = false) Integer clientId) {
        return Result.success(SelectOptionVo.buildOptions(title, projectService.listByClient(clientId)));
    }
 
    @ApiOperation(value = "项目下拉框-进入大屏")
    @RequestMapping("/projectsSelect")
    public Result projectsSelect(@RequestParam(value = "name", required = false) String name) {
        return Result.success( projectService.listByTitle(name));
    }
 
    //////////  综合体系  //////////
 
    @ApiOperation(value = "综合模型")
    @GetMapping("/systemModels")
    public Result systemModels(@RequestParam(value = "title", required = false) String title) {
        return Result.success(SelectOptionVo.buildOptions(title, systemModelService.findAll()));
    }
 
    @ApiOperation(value = "综合打分专家")
    @GetMapping("/system/scoreExperts")
    public Result sysExperts(@RequestParam(value = "title", required = false) String title,
                             @RequestParam("modelId") Integer modelId) {
        return Result.success(SelectOptionVo.buildOptions(title, sysExpertService.listScoreExperts(modelId)));
    }
 
    @ApiOperation(value = "综合模糊专家")
    @GetMapping("/system/fuzzyExperts")
    public Result sysFuzzyExperts(@RequestParam(value = "title", required = false) String title,
                                  @RequestParam("modelId") Integer modelId) {
        return Result.success(SelectOptionVo.buildOptions(title, sysExpertService.listFuzzyExperts(modelId)));
    }
 
    //////////  设备体系  //////////
    @ApiOperation(value = "设备模型")
    @GetMapping("/deviceModels")
    public Result deviceModels(@RequestParam(value = "title",required = false) String title) {
        return Result.success(SelectOptionVo.buildOptions(title, deviceModelService.findActiveModels()));
    }
 
    @ApiOperation(value = "设备打分专家")
    @GetMapping("/device/scoreExperts")
    public Result deviceScoreExperts(@RequestParam(value = "title", required = false) String title,
                                    @RequestParam("modelId") Integer modelId) {
        return Result.success(SelectOptionVo.buildOptions(title, deviceExpertService.listScoreExperts(modelId)));
    }
 
    @ApiOperation(value = "设备模糊专家")
    @GetMapping("/device/fuzzyExperts")
    public Result deviceFuzzyExperts(@RequestParam(value = "title", required = false) String title,
                                    @RequestParam("modelId") Integer modelId) {
        return Result.success(SelectOptionVo.buildOptions(title, deviceExpertService.listFuzzyExperts(modelId)));
    }
 
    // 专家
    @ApiOperation(value = "可用设备列表")
    @GetMapping("/freeDevices")
    public Result deviceQueryOptions(@RequestParam(value = "title", required = false) String title,
                                     @RequestParam(value = "deviceType", required = false) DeviceType deviceType) {
        return Result.success(SelectOptionVo.buildOptions(title, deviceService.listFreeDevices(deviceType)));
    }
 
    @ApiOperation("计划下拉选项")
    @GetMapping("/plans")
    public Result plans(@RequestParam(value = "title", required = false) String title,
                        @RequestParam(value = "clientId", required = false) Integer clientId) {
        return Result.success(SelectOptionVo.buildOptions(title, planService.list(clientId)));
    }
 
    @ApiOperation("项目下拉选项")
    @GetMapping("/existTasks")
    public Result existTasks(@RequestParam(value = "title", required = false) String title,
                             @RequestParam("planId") Integer planId) {
        return Result.success(SelectOptionVo.buildOptions(title, checkTaskService.listExistTasks(planId)));
    }
 
    @ApiOperation(value = "已完成检查任务")
    @GetMapping("/closedTasks")
    public Result closedTasks(@RequestParam(value = "title", required = false) String title,
                              @RequestParam("planId") Integer planId) {
        return Result.success(SelectOptionVo.buildOptions(title, checkTaskService.listClosedTasks(planId)));
    }
 
    @ApiOperation(value = "已完成检查任务(多个计划)")
    @PostMapping("/closedTasksBatch")
    public Result closedTasks(@RequestParam(value = "title", required = false) String title,
                              @Validated @RequestBody BatchReq req) {
        return Result.success(SelectOptionVo.buildOptions(title, checkTaskService.listClosedTasks(req.getIds())));
    }
 
    @ApiOperation(value = "用户下拉选项")
    @GetMapping("/activeUsers")
    public Result activeUsers(@RequestParam(value = "title", required = false) String title,
                              @RequestParam(value = "keyword", required = false) String keyword){
        return Result.success(SelectOptionVo.buildOptions(title, userService.listActiveUsers(keyword)));
    }
 
    @ApiOperation(value = "司机下拉选项")
    @GetMapping("/drivers")
    public Result driverList(@RequestParam(value = "title", required = false) String title,
                             @RequestParam(value = "keyword", required = false) String keyword){
        return Result.success(SelectOptionVo.buildOptions(title, userService.listActiveUsers(keyword)));
    }
 
    @ApiOperation(value = "车辆下拉选项")
    @GetMapping("/cars")
    public Result carList(@RequestParam(value = "title", required = false) String title,
                          @RequestParam(value = "keyword", required = false) String keyword){
        return Result.success(SelectOptionVo.buildOptions(title, carService.listAll(keyword)));
    }
 
    @ApiOperation(value = "报告模版")
    @GetMapping("/reportTemplates")
    public Result reportTemplates(@RequestParam(value = "title", required = false) String title,
                                   @RequestParam(value = "type", required = false) ReportTemplateType type){
        var templates = reportTemplateService.findAll();
        if (type != null) {
            templates = templates.stream()
                    .filter(t -> t.getType() == type)
                    .collect(Collectors.toList());
        }
        return Result.success(SelectOptionVo.buildOptions(title, templates));
    }
}