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 = "计划可用项目下拉框")
|
@RequestMapping("/availableProjects")
|
public Result availableProjects(@RequestParam(value = "title", required = false) String title,
|
@RequestParam("planId") Integer planId) {
|
return Result.success(SelectOptionVo.buildOptions(title, projectService.listAvailableByPlan(planId)));
|
}
|
|
////////// 综合体系 //////////
|
|
@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));
|
}
|
}
|