|
|
@@ -5,17 +5,21 @@ import com.tuoheng.admin.conver.InspectionFileConverMapper; |
|
|
|
import com.tuoheng.admin.conver.ReportConverMapper; |
|
|
|
import com.tuoheng.admin.entity.*; |
|
|
|
import com.tuoheng.admin.enums.code.report.QueryInspectionReportCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.DeptMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionFileMapper; |
|
|
|
import com.tuoheng.admin.mapper.QuestionTypeMapper; |
|
|
|
import com.tuoheng.admin.mapper.ReportMapper; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.inspection.InspectionFileReportVo; |
|
|
|
import com.tuoheng.admin.vo.inspection.InspectionReportVo; |
|
|
|
import com.tuoheng.admin.vo.inspection.InspectionResultVo; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@@ -35,6 +39,12 @@ public class QueryInspectionReportService { |
|
|
|
@Autowired |
|
|
|
private ReportMapper reportMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DeptMapper deptMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QuestionTypeMapper questionTypeMapper; |
|
|
|
|
|
|
|
public JsonResult getInspectionReport(String id) { |
|
|
|
log.info("进入查看巡检报告业务"); |
|
|
|
|
|
|
@@ -89,9 +99,53 @@ public class QueryInspectionReportService { |
|
|
|
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper<InspectionFile>() |
|
|
|
.eq(InspectionFile::getInspectionId, report.getInspectionId()) |
|
|
|
.eq(InspectionFile::getMark, 1)); |
|
|
|
|
|
|
|
String deptName = this.getDeptName(report.getDeptId()); |
|
|
|
List<InspectionResultVo> inspectionResultVoList = this.buildInspectionResult(report); |
|
|
|
List<InspectionFileReportVo> inspectionFileHandleVoList = InspectionFileConverMapper.INSTANCE.fromInspectionFileListToInspectionFileHandleVoList(inspectionFileList); |
|
|
|
inspectionReportVo.setDeptName(deptName); |
|
|
|
inspectionReportVo.setInspectionResultVoList(inspectionResultVoList); |
|
|
|
inspectionReportVo.setInspectionFileReportVoList(inspectionFileHandleVoList); |
|
|
|
return inspectionReportVo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取部门路名称 |
|
|
|
*/ |
|
|
|
private String getDeptName(String deptId) { |
|
|
|
if (StringUtils.isEmpty(deptId)) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() |
|
|
|
.eq(Dept::getId, deptId) |
|
|
|
.eq(Dept::getMark, 1)); |
|
|
|
if (null != dept) { |
|
|
|
return dept.getName(); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
private List<InspectionResultVo> buildInspectionResult(Report report) { |
|
|
|
List<InspectionResultVo> inspectionResultVoList = new ArrayList<>(); |
|
|
|
List<QuestionType> questionTypeList = questionTypeMapper.selectList(new LambdaQueryWrapper<QuestionType>() |
|
|
|
.eq(QuestionType::getMark, 1)); |
|
|
|
QuestionType questionType; |
|
|
|
InspectionResultVo inspectionResultVo; |
|
|
|
for (int i = 0; i < questionTypeList.size(); i++) { |
|
|
|
inspectionResultVo = new InspectionResultVo(); |
|
|
|
questionType = questionTypeList.get(i); |
|
|
|
Integer count = this.getCount(report.getInspectionId(), questionType.getId()); |
|
|
|
inspectionResultVo.setQuestionTypeContent(questionType.getContent()); |
|
|
|
inspectionResultVo.setCount(count); |
|
|
|
inspectionResultVoList.add(inspectionResultVo); |
|
|
|
} |
|
|
|
return inspectionResultVoList; |
|
|
|
} |
|
|
|
|
|
|
|
private Integer getCount(String inspectionId, String questionTypeId) { |
|
|
|
Integer count = inspectionFileMapper.selectCount(new LambdaQueryWrapper<InspectionFile>() |
|
|
|
.eq(InspectionFile::getInspectionId, inspectionId) |
|
|
|
.eq(InspectionFile::getQuestionId, questionTypeId) |
|
|
|
.eq(InspectionFile::getMark, 1)); |
|
|
|
return count; |
|
|
|
} |
|
|
|
} |