From 6b9957f24372bedf76d9cc1c9ea426a98359500e Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 22 一月 2026 13:46:53 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectReportVo.java           |   33 ++
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DeviceUsageServiceImpl.java |   58 ++++
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/EntrustProjectController.java |  254 ++++++++++++++++++
 ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustListQuery.java              |   31 ++
 ruoyi-system/src/main/java/com/ruoyi/system/mapper/DeviceUsageMapper.java            |   14 
 ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml                  |  217 ++++++++++++++-
 ruoyi-system/src/main/java/com/ruoyi/system/query/ErrorListQuery.java                |   26 +
 ruoyi-system/src/main/java/com/ruoyi/system/service/DeviceUsageService.java          |   15 
 ruoyi-system/src/main/java/com/ruoyi/system/query/ProjectReportListQuery.java        |   16 +
 ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectVo.java                 |   51 +++
 ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustDeviceListQuery.java        |   30 ++
 ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustDeviceListVo.java              |   28 ++
 ruoyi-system/src/main/java/com/ruoyi/system/vo/ErrorListVo.java                      |   43 +++
 13 files changed, 789 insertions(+), 27 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/EntrustProjectController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/EntrustProjectController.java
new file mode 100644
index 0000000..e49ed9c
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/EntrustProjectController.java
@@ -0,0 +1,254 @@
+package com.ruoyi.web.controller.api;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.system.dto.EditHiddenDangerResponsiblePersonDto;
+import com.ruoyi.system.model.*;
+import com.ruoyi.system.model.Record;
+import com.ruoyi.system.query.*;
+import com.ruoyi.system.service.*;
+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.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@RestController
+@RequestMapping("/projectEntrust")
+@Api(tags = "委托方端")
+public class EntrustProjectController {
+
+
+    @Autowired
+    private ProjectService projectService;
+    @Autowired
+    private ClientService clientService;
+    @Autowired
+    private ClientParamService clientParamService;
+
+    @Autowired
+    private DeviceUsageService deviceUsageService;
+
+    @Autowired
+    private ReportTemplateService reportTemplateService;
+    @Autowired
+    private ProjectInfoService projectInfoService;
+    @Autowired
+    private ScreenAccountService screenAccountService;
+
+    @Autowired
+    private TaskService taskService;
+
+    @Autowired
+    private RecordService recordService;
+    @Autowired
+    private RecordImageService recordImageService;
+    @Autowired
+    private UserFileService userFileService;
+
+    @ApiOperation(value = "项目列表", response = EntrustProjectVo.class)
+    @PostMapping("/projectList")
+    public R<Page<EntrustProjectVo>> projectList(@RequestBody EntrustListQuery query) {
+        Page<EntrustProjectVo> page = new Page<>(query.getPageNum(), query.getPageSize());
+        List<EntrustProjectVo> list = deviceUsageService.projectList(page, query);
+        page.setRecords(list);
+        return R.ok(page);
+    }
+
+    @ApiOperation(value = "项目列表-报告模板列表", response = ReportTemplate.class)
+    @GetMapping("/projectReport")
+    public R<List<ReportTemplate>> projectReport(Integer id, Integer type) {
+        Client client = clientService.getById(id);
+        ClientParam clientParam = clientParamService.lambdaQuery().eq(ClientParam::getClientId, client.getId())
+                .last("limit 1")
+                .one();
+        List<Integer> templateIds = new ArrayList<>();
+        Integer safetyId = clientParam.getSafetyId();
+        if (safetyId != null) templateIds.add(safetyId);
+        Integer deviceTemplateId = clientParam.getDeviceTemplateId();
+        if (deviceTemplateId != null) templateIds.add(deviceTemplateId);
+
+        if (templateIds.isEmpty()) {
+            return R.ok(new ArrayList<>());
+        }
+        List<ReportTemplate> list = reportTemplateService.lambdaQuery()
+                .in(ReportTemplate::getId, templateIds).list();
+        return R.ok(list);
+    }
+
+    @ApiOperation(value = "项目列表-报告列表", response = EntrustProjectReportVo.class)
+    @PostMapping("/projectReport")
+    public R<Page<EntrustProjectReportVo>> projectReport(@RequestBody ProjectReportListQuery query) {
+        Page<EntrustProjectReportVo> page = new Page<>(query.getPageNum(), query.getPageSize());
+        List<EntrustProjectReportVo> list = deviceUsageService.projectReport(page, query);
+        page.setRecords(list);
+        return R.ok(page);
+    }
+
+    @ApiOperation(value = "获取设备列表", response = EntrustDeviceListVo.class)
+    @PostMapping("/deviceList")
+    public R<Page<EntrustDeviceListVo>> deviceList(@RequestBody @Valid EntrustDeviceListQuery query) {
+        Page<EntrustDeviceListVo> page = new Page<>(query.getPageNum(), query.getPageSize());
+        List<EntrustDeviceListVo> list = deviceUsageService.deviceList(page, query);
+        page.setRecords(list);
+        return R.ok(page);
+    }
+
+    @ApiOperation(value = "获取重大隐患列表", response = DeviceListVo.class)
+    @PostMapping("/errorList")
+    public R<Page<ErrorListVo>> errorList(@RequestBody @Valid ErrorListQuery query) {
+        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()
+                    .stream().map(RecordImage::getUserFileId).collect(Collectors.toList());
+            if (!recordFileIds.isEmpty()) {
+                List<UserFile> pictures = userFileService.lambdaQuery()
+                        .in(UserFile::getId, recordFileIds).list();
+                errorListVo.setPictures(pictures);
+            }
+        }
+        page.setRecords(list);
+        return R.ok(page);
+    }
+    @ApiOperation(value = "获取安全隐患列表", response = ErrorListVo.class)
+    @PostMapping("/safetyErrorList")
+    public R<Page<ErrorListVo>> safetyErrorList(@RequestBody @Valid ErrorListQuery query) {
+        Page<ErrorListVo> page = new Page<>(query.getPageNum(), query.getPageSize());
+        List<ErrorListVo> list = deviceUsageService.safetyErrorList(page, query);
+        for (ErrorListVo errorListVo : list) {
+            List<Integer> recordFileIds = recordImageService.lambdaQuery()
+                    .eq(RecordImage::getRecordId, errorListVo.getId()).list()
+                    .stream().map(RecordImage::getUserFileId).collect(Collectors.toList());
+            if (!recordFileIds.isEmpty()) {
+                List<UserFile> pictures = userFileService.lambdaQuery()
+                        .in(UserFile::getId, recordFileIds).list();
+                errorListVo.setPictures(pictures);
+            }
+        }
+        page.setRecords(list);
+        return R.ok(page);
+    }
+    @ApiOperation(value = "获取设备隐患列表", response = ErrorListVo.class)
+    @PostMapping("/deviceErrorList")
+    public R<Page<ErrorListVo>> deviceList(@RequestBody @Valid ErrorListQuery query) {
+        Page<ErrorListVo> page = new Page<>(query.getPageNum(), query.getPageSize());
+        List<ErrorListVo> list = deviceUsageService.deviceErrorList(page, query);
+        for (ErrorListVo errorListVo : list) {
+            List<Integer> recordFileIds = recordImageService.lambdaQuery()
+                    .eq(RecordImage::getRecordId, errorListVo.getId()).list()
+                    .stream().map(RecordImage::getUserFileId).collect(Collectors.toList());
+            if (!recordFileIds.isEmpty()) {
+                List<UserFile> pictures = userFileService.lambdaQuery()
+                        .in(UserFile::getId, recordFileIds).list();
+                errorListVo.setPictures(pictures);
+            }
+        }
+        page.setRecords(list);
+        return R.ok(page);
+    }
+    @ApiOperation(value = "设置负责人")
+    @GetMapping("/setResponsiblePerson")
+    public R setResponsiblePerson(Integer id , String responsiblePerson) {
+        Record record = recordService.getById(id);
+        record.setResponsiblePerson(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);
+    }
+
+
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DeviceUsageMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DeviceUsageMapper.java
index 2393b8a..2ee54fe 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DeviceUsageMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DeviceUsageMapper.java
@@ -5,8 +5,8 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.system.model.DeviceUsage;
 import com.ruoyi.system.model.Record;
-import com.ruoyi.system.query.DeviceListQuery;
-import com.ruoyi.system.vo.DeviceListVo;
+import com.ruoyi.system.query.*;
+import com.ruoyi.system.vo.*;
 import org.apache.ibatis.annotations.Param;
 
 import java.time.LocalDateTime;
@@ -27,5 +27,15 @@
     List<DeviceListVo> getDeviceList(@Param("page") Page<DeviceListVo> page, @Param("query") DeviceListQuery query);
 
 
+    List<EntrustProjectVo> projectList(@Param("page")Page<EntrustProjectVo> page,@Param("query")EntrustListQuery query);
 
+    List<EntrustProjectReportVo> projectReport(@Param("page")Page<EntrustProjectReportVo> page, @Param("query")ProjectReportListQuery query);
+
+    List<EntrustDeviceListVo> deviceList(@Param("page")Page<EntrustDeviceListVo> page, @Param("query")EntrustDeviceListQuery query);
+
+    List<ErrorListVo> errorList(@Param("page")Page<ErrorListVo> page, @Param("query")ErrorListQuery query);
+
+    List<ErrorListVo> deviceErrorList(@Param("page")Page<ErrorListVo> page, @Param("query")ErrorListQuery query);
+
+    List<ErrorListVo> safetyErrorList(@Param("page")Page<ErrorListVo> page, @Param("query")ErrorListQuery query);
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustDeviceListQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustDeviceListQuery.java
new file mode 100644
index 0000000..b8ac3e6
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustDeviceListQuery.java
@@ -0,0 +1,30 @@
+package com.ruoyi.system.query;
+
+import com.ruoyi.common.core.domain.BasePage;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel("委托方端设备信息列表查询query")
+public class EntrustDeviceListQuery extends BasePage {
+
+    @ApiModelProperty("项目id")
+    @NotNull(message = "项目id不能为空")
+    private Integer projectId;
+    @ApiModelProperty("整改情况 true已整改 false未整改")
+    private Boolean reformed;
+    @ApiModelProperty("设备类型")
+    private Integer type;
+
+    @ApiModelProperty("开始时间")
+    private String startTime;
+
+    @ApiModelProperty("结束时间")
+    private String endTime;
+
+    @ApiModelProperty("内容")
+    private String content;
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustListQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustListQuery.java
new file mode 100644
index 0000000..d7e42e6
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/EntrustListQuery.java
@@ -0,0 +1,31 @@
+package com.ruoyi.system.query;
+
+import com.ruoyi.common.core.domain.BasePage;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel("委托方端项目列表查询query")
+public class EntrustListQuery extends BasePage {
+
+    @ApiModelProperty("项目id")
+    private Integer projectId;
+
+    @ApiModelProperty("项目类型:1-房建 2-市政 3-建筑工程等")
+    private Integer type;
+
+    @ApiModelProperty("开始时间")
+    private String startTime;
+
+    @ApiModelProperty("结束时间")
+    private String endTime;
+
+    @ApiModelProperty("风险评级")
+    private String riskLevel;
+
+    @ApiModelProperty("项目名称")
+    private String name;
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/ErrorListQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/ErrorListQuery.java
new file mode 100644
index 0000000..313e6b7
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/ErrorListQuery.java
@@ -0,0 +1,26 @@
+package com.ruoyi.system.query;
+
+import com.ruoyi.common.core.domain.BasePage;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel("委托方端隐患列表查询query")
+public class ErrorListQuery extends BasePage {
+
+    @ApiModelProperty("项目id")
+    private Integer projectId;
+    @ApiModelProperty("整改情况 true已整改 false未整改")
+    private Boolean reformed;
+    @ApiModelProperty("隐患类型 1安全 2设备")
+    private Integer type;
+    @ApiModelProperty("开始时间")
+    private String startTime;
+    @ApiModelProperty("结束时间")
+    private String endTime;
+    @ApiModelProperty("内容")
+    private String content;
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/ProjectReportListQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/ProjectReportListQuery.java
new file mode 100644
index 0000000..1202a0e
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/ProjectReportListQuery.java
@@ -0,0 +1,16 @@
+package com.ruoyi.system.query;
+
+import com.ruoyi.common.core.domain.BasePage;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel("委托方端项目报告列表查询query")
+public class ProjectReportListQuery extends BasePage {
+
+    @ApiModelProperty("项目id")
+    private Integer projectId;
+
+
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/DeviceUsageService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/DeviceUsageService.java
index 0e0f7e0..e800ac5 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/DeviceUsageService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/DeviceUsageService.java
@@ -4,8 +4,8 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.system.model.DeviceUsage;
-import com.ruoyi.system.query.DeviceListQuery;
-import com.ruoyi.system.vo.DeviceListVo;
+import com.ruoyi.system.query.*;
+import com.ruoyi.system.vo.*;
 
 import javax.validation.Valid;
 import java.util.List;
@@ -24,4 +24,15 @@
 
     List<DeviceListVo> getDeviceList(Page<DeviceListVo> page, @Valid DeviceListQuery query);
 
+    List<EntrustProjectVo> projectList(Page<EntrustProjectVo> page, EntrustListQuery query);
+
+    List<EntrustProjectReportVo> projectReport(Page<EntrustProjectReportVo> page, ProjectReportListQuery query);
+
+    List<EntrustDeviceListVo> deviceList(Page<EntrustDeviceListVo> page, EntrustDeviceListQuery query);
+
+    List<ErrorListVo> errorList(Page<ErrorListVo> page, ErrorListQuery query);
+
+    List<ErrorListVo> deviceErrorList(Page<ErrorListVo> page, ErrorListQuery query);
+
+    List<ErrorListVo> safetyErrorList(Page<ErrorListVo> page, ErrorListQuery query);
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DeviceUsageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DeviceUsageServiceImpl.java
index dafccf6..753773b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DeviceUsageServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DeviceUsageServiceImpl.java
@@ -6,9 +6,9 @@
 import com.ruoyi.system.mapper.DeviceUsageMapper;
 import com.ruoyi.system.model.DeviceUsage;
 import com.ruoyi.system.model.Record;
-import com.ruoyi.system.query.DeviceListQuery;
+import com.ruoyi.system.query.*;
 import com.ruoyi.system.service.DeviceUsageService;
-import com.ruoyi.system.vo.DeviceListVo;
+import com.ruoyi.system.vo.*;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -49,5 +49,59 @@
         return deviceList;
     }
 
+    @Override
+    public List<EntrustProjectVo> projectList( Page<EntrustProjectVo> page,EntrustListQuery query) {
+        Integer pageNum = query.getPageNum();
+        Integer pageSize = query.getPageSize();
+        List<EntrustProjectVo> deviceList = this.baseMapper.projectList(page,query);
+        for (EntrustProjectVo deviceListVo : deviceList) {
+            LocalDateTime checkTime = deviceListVo.getCheckTime();
+            // 判断checkTime是否是本月的时间
+            if (checkTime != null && YearMonth.from(checkTime).equals(YearMonth.now())) {
+                deviceListVo.setCheckResult("已检查");
+            }else {
+                deviceListVo.setCheckResult("未检查");
+            }
+        }
+        return deviceList;
+    }
+
+    @Override
+    public List<EntrustProjectReportVo> projectReport(Page<EntrustProjectReportVo> page, ProjectReportListQuery query) {
+        List<EntrustProjectReportVo> entrustProjectReportVoList = this.baseMapper.projectReport(page,query);
+        return entrustProjectReportVoList;
+    }
+
+    @Override
+    public List<EntrustDeviceListVo> deviceList(Page<EntrustDeviceListVo> page, EntrustDeviceListQuery query) {
+        List<EntrustDeviceListVo> deviceList = this.baseMapper.deviceList(page, query);
+        for (EntrustDeviceListVo deviceListVo : deviceList) {
+            LocalDateTime checkTime = deviceListVo.getCheckTime();
+            // 判断checkTime是否是本月的时间
+            if (checkTime != null && YearMonth.from(checkTime).equals(YearMonth.now())) {
+                deviceListVo.setCheckResult("已检查");
+            }else {
+                deviceListVo.setCheckResult("未检查");
+            }
+        }
+        return deviceList;
+    }
+
+    @Override
+    public List<ErrorListVo> errorList(Page<ErrorListVo> page, ErrorListQuery query) {
+        List<ErrorListVo> errorList = this.baseMapper.errorList(page, query);
+        return errorList;
+    }
+
+    @Override
+    public List<ErrorListVo> deviceErrorList(Page<ErrorListVo> page, ErrorListQuery query) {
+        List<ErrorListVo> errorList = this.baseMapper.deviceErrorList(page, query);
+        return errorList;    }
+
+    @Override
+    public List<ErrorListVo> safetyErrorList(Page<ErrorListVo> page, ErrorListQuery query) {
+        List<ErrorListVo> errorList = this.baseMapper.safetyErrorList(page, query);
+        return errorList;    }
+
 
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustDeviceListVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustDeviceListVo.java
new file mode 100644
index 0000000..4818c1c
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustDeviceListVo.java
@@ -0,0 +1,28 @@
+package com.ruoyi.system.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("大屏设备列表信息Vo")
+public class EntrustDeviceListVo {
+
+    private Integer id;
+    @ApiModelProperty("项目名称")
+    private String projectName;
+    @ApiModelProperty("设备类型:1-塔式起重机 2-施工升降机 3-物料提升机 4-桥式起重机 5-附着式升降脚手架 6-流动式起重机 7-高处作业吊篮 8-门式起重机 9-架桥机 10-其他")
+    private Integer type;
+    @ApiModelProperty("设备编号")
+    private String name;
+    @ApiModelProperty("设备信息 例:{\"使用单位\": \"使用单位1\", \"初装高度\": \"1001\", \"备案机构\": \"备案机构1\", \"报废年限\": \"66\", \"设备型号\": \"设备型号1\", \"使用登记日期\": \"2021-01-01\", \"使用登记机构\": \"使用登记机构1\", \"最大安装高度\": \"2001\", \"最终安装高度\": \"3001\", \"设备出厂日期\": \"2023-07-20\", \"安拆人员证件号\": \"安拆证号1\", \"设备使用登记证号\": \"使用证号1\", \"设备备案登记日期\": \"2021-01-01\", \"设备备案登记有效期\": \"2021-01-01\", \"工程起重机械安拆单位\": \"安拆单位1\", \"工程起重机械生产单位\": \"生产单位1\", \"工程起重机械租赁单位\": \"租赁单位1\", \"工程起重机械维保单位\": \"维保单位1\", \"使用登记有效期截止日期\": \"2021-01-01\", \"工程起重机械设备备案登记证号\": \"备案证号1\"}")
+    private String properties;
+    @ApiModelProperty("检查情况")
+    private String checkResult;
+    @ApiModelProperty("检查时间")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDateTime checkTime;
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectReportVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectReportVo.java
new file mode 100644
index 0000000..14bb363
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectReportVo.java
@@ -0,0 +1,33 @@
+package com.ruoyi.system.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("项目信息-报告清单")
+public class EntrustProjectReportVo {
+
+    @ApiModelProperty("计划类型:1-安全检查 2-质量检查 3-综合检查 4-设备检查 5-运营检查")
+    private Integer type;
+    @ApiModelProperty("检查计划")
+    private String name;
+    @ApiModelProperty("分数")
+    private Integer score;
+    @ApiModelProperty("风险类型")
+    private Integer riskLevel;
+    @ApiModelProperty("检查时间")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDateTime checkTime;
+
+    private Integer id;
+
+
+
+
+
+
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectVo.java
new file mode 100644
index 0000000..dc628c4
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/EntrustProjectVo.java
@@ -0,0 +1,51 @@
+package com.ruoyi.system.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@ApiModel("项目信息")
+public class EntrustProjectVo {
+
+    @ApiModelProperty("项目类型")
+    private Integer type;
+
+    @ApiModelProperty("项目名称")
+    private String name;
+
+    @ApiModelProperty("项目地址")
+    private String addressInfo;
+
+    @ApiModelProperty("施工单位信息")
+    private String constructionCompanyInfo;
+
+    @ApiModelProperty("监理单位信息")
+    private String supervisorCompanyInfo;
+
+    @ApiModelProperty("建设单位信息")
+    private String developmentCompanyInfo;
+
+    @ApiModelProperty("本月检查情况")
+    private String checkResult;
+    @ApiModelProperty("本月检查风险")
+    private String risk;
+//    @ApiModelProperty("风险等级:0-拒绝接受风险 1-不可接受风险 2-重大风险 3-中等风险 4-可接受风险")
+//    private Integer riskLevel;
+
+    @ApiModelProperty("最近检查时间")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDateTime checkTime;
+
+    private Integer id;
+
+
+
+
+
+
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/ErrorListVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/ErrorListVo.java
new file mode 100644
index 0000000..f8af8eb
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/ErrorListVo.java
@@ -0,0 +1,43 @@
+package com.ruoyi.system.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.system.model.UserFile;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@ApiModel("重大安全隐患列表信息Vo")
+public class ErrorListVo {
+
+    private Integer id;
+    @ApiModelProperty("项目名称")
+    private String projectName;
+    @ApiModelProperty("计划名称")
+    private String planName;
+    @ApiModelProperty("检查内容")
+    private String hierarchyName;
+    @ApiModelProperty("问题描述")
+    private String problemName;
+    @ApiModelProperty("问题部位")
+    private String problemPart;
+    @ApiModelProperty("问题备注")
+    private String remark;
+    @ApiModelProperty("隐患等级:1-一级隐患 2-二级隐患 3-三级隐患 4-四级隐患")
+    private Integer level;
+    @ApiModelProperty("隐患类型 1安全 2设备")
+    private Integer type;
+    @ApiModelProperty("图片")
+    private List<UserFile> pictures;
+    @ApiModelProperty("检查时间")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDateTime checkTime;
+    @ApiModelProperty("整改情况 true已整改 false未整改")
+    private Boolean reformed;
+    @ApiModelProperty("责任人")
+    private String responsiblePerson;
+
+}
diff --git a/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml b/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml
index 33c49a1..8a4ace5 100644
--- a/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml
@@ -4,32 +4,33 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.ruoyi.system.model.DeviceUsage">
-        <id column="id" property="id" />
-        <result column="create_time" property="createTime" />
-        <result column="deleted" property="deleted" />
-        <result column="name" property="name" />
-        <result column="update_time" property="updateTime" />
-        <result column="properties" property="properties" />
-        <result column="creator_id" property="creatorId" />
-        <result column="device_id" property="deviceId" />
-        <result column="project_id" property="projectId" />
-        <result column="disabled" property="disabled" />
+        <id column="id" property="id"/>
+        <result column="create_time" property="createTime"/>
+        <result column="deleted" property="deleted"/>
+        <result column="name" property="name"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="properties" property="properties"/>
+        <result column="creator_id" property="creatorId"/>
+        <result column="device_id" property="deviceId"/>
+        <result column="project_id" property="projectId"/>
+        <result column="disabled" property="disabled"/>
     </resultMap>
     <select id="getDeviceUsageList" resultType="java.lang.String">
-        select t3.properties from device_usage t1
-        left join device t2 on t1.device_id = t2.id
-        where t1.project_id =#{id}
+        select t3.properties
+        from device_usage t1
+                 left join device t2 on t1.device_id = t2.id
+        where t1.project_id = #{id}
     </select>
     <select id="getDeviceList" resultType="com.ruoyi.system.vo.DeviceListVo">
 
-        select t1.id, t1.name, t1.create_time, t1.properties,   t1.type, latest.record_time as checkTime
+        select t1.id, t1.name, t1.create_time, t1.properties, t1.type, latest.record_time as checkTime
         from device t1
-                 left join device_usage t2 on t1.id = t2.device_id
-                 left join (
-                     select device_id, max(create_time) as record_time
-                     from record
-                     group by device_id
-                 ) latest on t1.id = latest.device_id
+        left join device_usage t2 on t1.id = t2.device_id
+        left join (
+        select device_id, max(create_time) as record_time
+        from record
+        group by device_id
+        ) latest on t1.id = latest.device_id
         where t2.project_id = #{query.projectId} and t2.deleted = 0
         <if test="query.type != null">
             and t1.type = #{query.type}
@@ -41,9 +42,183 @@
             and latest.record_time >= #{query.startTime}
         </if>
         <if test="query.endTime != null and query.endTime != ''">
-            and   #{query.endTime} >=latest.record_time
+            and #{query.endTime} >=latest.record_time
         </if>
         order by latest.record_time desc
     </select>
+    <select id="deviceList" resultType="com.ruoyi.system.vo.EntrustDeviceListVo">
+        select t2.id, t2.name, t2.create_time, t2.properties, t2.type, latest.record_time as checkTime,t3.name as projectName
+        from device_usage t1
+        left join device t2 on t2.id = t1.device_id
+        left join (
+        select device_id, max(create_time) as record_time
+        from record
+        group by device_id
+        ) latest on t2.id = latest.device_id
+        left join project t3 on t1.project_id = t3.id
+        where t1.project_id = #{query.projectId} and t1.deleted = 0 and t1.disabled = 0
+        <if test="query.type != null">
+            and t2.type = #{query.type}
+        </if>
+        <if test="query.content!= null and query.content!=''">
+            and t2.name like CONCAT('%', #{query.content}, '%')
+        </if>
+        <if test="query.startTime != null and query.startTime != ''">
+            and latest.record_time >= #{query.startTime}
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            and #{query.endTime} >=latest.record_time
+        </if>
+        order by latest.record_time desc
+    </select>
+    <select id="projectList" resultType="com.ruoyi.system.vo.EntrustProjectVo">
+        select
+        t1.*, latest.record_time as checkTime,result.risk_level
+        from project t1
+        left join device_usage t2 on t1.id = t2.project_id
+        left join (
+        select device_id, max(create_time) as record_time
+        from record
+        group by device_id
+        ) latest on t2.device_id = latest.device_id
+        left join (
+        select score,project_id,risk_level
+        from eval_result
+        group by project_id
+        order by create_time desc
+        ) result on t1.id = result.project_id
+        where t1.deleted = 0 and t2.deleted = 0
+
+        <if test="query.projectId != null">
+            and t1.id = #{query.projectId}
+        </if>
+        <if test="query.type != null">
+            and t1.type = #{query.type}
+        </if>
+        <if test="query.riskLevel != null">
+            and result.risk_level = #{query.riskLevel}
+        </if>
+        <if test="query.name!= null and query.name!=''">
+            and t1.name like CONCAT('%', #{query.content}, '%')
+        </if>
+        <if test="query.startTime != null and query.startTime != ''">
+            and latest.record_time >= #{query.startTime}
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            and #{query.endTime} >=latest.record_time
+        </if>
+        GROUP BY t1.id
+        order by latest.record_time desc
+    </select>
+    <select id="projectReport" resultType="com.ruoyi.system.vo.EntrustProjectReportVo">
+        select t1.name,t1.type,t2.score,t2.risk_level,t3.time as checkTime
+        from plan t1
+        left join eval_result t2 on t1.id = t2.plan_id and t2.project_id = #{query.projectId}
+        left join check t3 on t1.id = t3.plan_id and t3.project_id = #{query.projectId}
+        where t1.deleted = 0 and t2.deleted = 0 and t2.deleted = 0
+
+    </select>
+    <select id="errorList" resultType="com.ruoyi.system.vo.ErrorListVo">
+        select t1.*,t2.project_id,t2.plan_id,t3.`name` as  projectName,t4.`name` as planName
+             ,t5.`name` as problemName,IF(t1.device_id is null ,1,2) as type,t1.create_time as checkTime
+        from record t1
+                 LEFT JOIN task t2 on t1.check_task_id = t2.id
+                 LEFT JOIN project t3 on t2.project_id = t3.id
+                 LEFT JOIN plan t4 on t2.plan_id = t4.id
+                 LEFT JOIN problem t5 ON t1.problem_id = t5.id
+        where t1.deleted = 0 and t2.deleted = 0  and t1.`level` =1
+          <if test="query.projectId != null">
+            and t2.project_id = #{query.projectId}
+        </if>
+        <if test="query.reformed != null">
+            and t1.reformed = #{query.reformed}
+        </if>
+        <if test="query.type != null and query.type == 1">
+            and t1.device_id is null
+        </if>
+        <if test="query.type != null and query.type == 2">
+            and t1.device_id is not null
+        </if>
+        <if test="query.startTime != null and query.startTime != ''">
+            and t1.create_time >= #{query.startTime}
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            and #{query.endTime} >=t1.create_time
+        </if>
+        <if test="query.content!= null and query.content!=''">
+            and (t3.name like CONCAT('%', #{query.content}, '%')
+                or
+            t5.name like CONCAT('%', #{query.content}, '%')
+                or
+            t1.remark like CONCAT('%', #{query.content}, '%')
+                )
+        </if>
+        order by t1.create_time desc
+    </select>
+    <select id="deviceErrorList" resultType="com.ruoyi.system.vo.ErrorListVo">
+        select t1.*,t2.project_id,t2.plan_id,t3.`name` as  projectName,t4.`name` as planName
+        ,t5.`name` as problemName,IF(t1.device_id is null ,1,2) as type,t1.create_time as checkTime
+        from record t1
+        LEFT JOIN task t2 on t1.check_task_id = t2.id
+        LEFT JOIN project t3 on t2.project_id = t3.id
+        LEFT JOIN plan t4 on t2.plan_id = t4.id
+        LEFT JOIN problem t5 ON t1.problem_id = t5.id
+        where t1.deleted = 0 and t2.deleted = 0  and t1.device_id is not null
+        <if test="query.projectId != null">
+            and t2.project_id = #{query.projectId}
+        </if>
+        <if test="query.reformed != null">
+            and t1.reformed = #{query.reformed}
+        </if>
+
+        <if test="query.startTime != null and query.startTime != ''">
+            and t1.create_time >= #{query.startTime}
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            and #{query.endTime} >=t1.create_time
+        </if>
+        <if test="query.content!= null and query.content!=''">
+            and (t3.name like CONCAT('%', #{query.content}, '%')
+            or
+            t5.name like CONCAT('%', #{query.content}, '%')
+            or
+            t1.remark like CONCAT('%', #{query.content}, '%')
+            )
+        </if>
+        order by t1.create_time desc
+    </select>
+    <select id="safetyErrorList" resultType="com.ruoyi.system.vo.ErrorListVo">
+        select t1.*,t2.project_id,t2.plan_id,t3.`name` as  projectName,t4.`name` as planName
+        ,t5.`name` as problemName,IF(t1.device_id is null ,1,2) as type,t1.create_time as checkTime
+        from record t1
+        LEFT JOIN task t2 on t1.check_task_id = t2.id
+        LEFT JOIN project t3 on t2.project_id = t3.id
+        LEFT JOIN plan t4 on t2.plan_id = t4.id
+        LEFT JOIN problem t5 ON t1.problem_id = t5.id
+        where t1.deleted = 0 and t2.deleted = 0  and t1.device_id is null
+        <if test="query.projectId != null">
+            and t2.project_id = #{query.projectId}
+        </if>
+        <if test="query.reformed != null">
+            and t1.reformed = #{query.reformed}
+        </if>
+
+        <if test="query.startTime != null and query.startTime != ''">
+            and t1.create_time >= #{query.startTime}
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            and #{query.endTime} >=t1.create_time
+        </if>
+        <if test="query.content!= null and query.content!=''">
+            and (t3.name like CONCAT('%', #{query.content}, '%')
+            or
+            t5.name like CONCAT('%', #{query.content}, '%')
+            or
+            t1.remark like CONCAT('%', #{query.content}, '%')
+            )
+        </if>
+        order by t1.create_time desc
+    </select>
+
 
 </mapper>

--
Gitblit v1.7.1