| | |
| | | import com.ruoyi.system.vo.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.var; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | @RestController |
| | | @RequestMapping("/projectEntrust") |
| | |
| | | @Autowired |
| | | private UserFileService userFileService; |
| | | |
| | | @ApiOperation(value = "项目不分页列表", response = Project.class) |
| | | @GetMapping("/projectListAll") |
| | | public R<List<Project>> projectListAll(Integer clientId,Integer category) { |
| | | LambdaQueryWrapper<Project> projectLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | projectLambdaQueryWrapper.eq(Project::getClientId, clientId) |
| | | .eq(Project::getDeleted, false); |
| | | if (category==1){ |
| | | projectLambdaQueryWrapper.eq(Project::getStatus, 1); |
| | | } |
| | | if (category==2){ |
| | | projectLambdaQueryWrapper.eq(Project::getType,2); |
| | | } |
| | | List<Project> list = projectService.list(projectLambdaQueryWrapper); |
| | | return R.ok(list); |
| | | } |
| | | @ApiOperation(value = "项目列表", response = EntrustProjectVo.class) |
| | | @PostMapping("/projectList") |
| | | public R<Page<EntrustProjectVo>> projectList(@RequestBody EntrustListQuery query) { |
| | |
| | | |
| | | @ApiOperation(value = "获取重大隐患列表", response = DeviceListVo.class) |
| | | @PostMapping("/errorList") |
| | | public R<Page<ErrorListVo>> errorList(@RequestBody @Valid ErrorListQuery query) { |
| | | public R<Page<ErrorListVo>> errorList(@RequestBody @Valid ErrorListQuery query) throws ParseException { |
| | | Page<ErrorListVo> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | List<ErrorListVo> list = deviceUsageService.errorList(page, query); |
| | | |
| | | for (ErrorListVo errorListVo : list) { |
| | | List<Integer> recordFileIds = recordImageService.lambdaQuery() |
| | | .eq(RecordImage::getRecordId, errorListVo.getId()).list() |
| | |
| | | page.setRecords(list); |
| | | return R.ok(page); |
| | | } |
| | | @ApiOperation(value = "委托方端隐患详情") |
| | | @GetMapping("/errorDetail") |
| | | public R<?> errorDetail(Integer id) { |
| | | Record record = recordService.getById(id); |
| | | Integer problemId = record.getProblemId(); |
| | | var res = recordService.getHiddenDangerDetail(problemId); |
| | | return R.ok(res); |
| | | } |
| | | @ApiOperation(value = "获取隐患详情") |
| | | @GetMapping("/getHiddenDangerDetail/{problemId}") |
| | | public R<?> getHiddenDangerDetail(@PathVariable Integer problemId) { |
| | | var record = recordService.getHiddenDangerDetail(problemId); |
| | | return R.ok(record); |
| | | } |
| | | |
| | | @ApiOperation(value = "设置负责人") |
| | | @GetMapping("/setResponsiblePerson") |
| | | public R setResponsiblePerson(Integer id , String responsiblePerson) { |
| | |
| | | recordService.updateById(record); |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "隐患详情") |
| | | @GetMapping("/errorDetail") |
| | | public R errorDetail(Integer id) { |
| | | Record record = recordService.getById(id); |
| | | |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "获取项目详情", response = Project.class) |
| | | @GetMapping("/getProjectDetail/{id}") |
| | | public R<ProjectVo> getStoryDetail(@PathVariable Integer id) { |
| | | ProjectVo projectVo = new ProjectVo(); |
| | | Project project = projectService.getById(id); |
| | | BeanUtils.copyProperties(project, projectVo); |
| | | |
| | | List<String> properties = deviceUsageService.getDeviceUsageList(id); |
| | | projectVo.setProperties(properties); |
| | | |
| | | ProjectInfo projectInfo = projectInfoService.getOne(new LambdaUpdateWrapper<ProjectInfo>().eq(ProjectInfo::getProjectId, id)); |
| | | if (projectInfo != null) { |
| | | projectVo.setProgress(projectInfo.getProgress()); |
| | | } |
| | | Task task = taskService.getOne(new LambdaUpdateWrapper<Task>().eq(Task::getProjectId, id).orderByDesc(Task::getUpdateTime).last("limit 1")); |
| | | |
| | | if (task != null) { |
| | | projectVo.setCheckTime(task.getUpdateTime()); |
| | | } |
| | | return R.ok(projectVo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取项目隐患数量", response = Project.class) |
| | | @GetMapping("/getProjectHiddenDangerCount/{id}") |
| | | public R<HiddenDangerVo> getProjectHiddenDangerCount(@PathVariable Integer id) { |
| | | HiddenDangerVo hiddenDangerVo = new HiddenDangerVo(); |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getProjectId, id)); |
| | | if (!list.isEmpty()) { |
| | | List<Integer> taskIds = list.stream().map(Task::getId).collect(Collectors.toList()); |
| | | // 0是一级隐患 |
| | | List<Record> records = recordService.list(new LambdaQueryWrapper<Record>().eq(Record::getLevel, 0).eq(Record::getDeleted, 0).in(Record::getCheckTaskId, taskIds)); |
| | | hiddenDangerVo.setSerious(records.size()); |
| | | int rectified = records.stream().filter(Record::getReformed).collect(Collectors.toList()).size(); |
| | | hiddenDangerVo.setRectified(rectified); |
| | | hiddenDangerVo.setUnRectified(records.size() - rectified); |
| | | } |
| | | return R.ok(hiddenDangerVo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取隐患列表", response = HiddenDangerListVo.class) |
| | | @PostMapping("/getHiddenDangerList") |
| | | public R<Page<HiddenDangerListVo>> getHiddenDangerList(@RequestBody @Valid HiddenDangerListQuery query) { |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getProjectId, query.getProjectId())); |
| | | if (tasks.isEmpty()) { |
| | | return R.ok(new Page<>()); |
| | | } |
| | | List<Integer> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | Page<HiddenDangerListVo> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | List<HiddenDangerListVo> list = recordService.getHiddenDangerList(page, query, taskIds); |
| | | page.setRecords(list); |
| | | return R.ok(page); |
| | | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "编辑隐患责任人") |
| | | @PostMapping("/editHiddenDangerResponsiblePerson") |
| | | public R<Void> editHiddenDangerResponsiblePerson(@RequestBody @Valid EditHiddenDangerResponsiblePersonDto dto) { |
| | | Record record = recordService.getById(dto.getId()); |
| | | if (record == null) { |
| | | return R.fail("隐患不存在"); |
| | | } |
| | | record.setResponsiblePerson(dto.getResponsiblePerson()); |
| | | recordService.updateById(record); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取隐患详情") |
| | | @GetMapping("/getHiddenDangerDetail/{problemId}") |
| | | public R<?> getHiddenDangerDetail(@PathVariable Integer problemId) { |
| | | var record = recordService.getHiddenDangerDetail(problemId); |
| | | return R.ok(record); |
| | | } |
| | | |
| | | |
| | | } |