|
|
@@ -3,17 +3,13 @@ package com.tuoheng.admin.service.accident.query; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.tuoheng.admin.conver.AccidentConverMapper; |
|
|
|
import com.tuoheng.admin.entity.Accident; |
|
|
|
import com.tuoheng.admin.entity.Dept; |
|
|
|
import com.tuoheng.admin.entity.InspectionFile; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.entity.*; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.enums.RoleEnum; |
|
|
|
import com.tuoheng.admin.mapper.AccidentMapper; |
|
|
|
import com.tuoheng.admin.mapper.DeptMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionFileMapper; |
|
|
|
import com.tuoheng.admin.mapper.UserMapper; |
|
|
|
import com.tuoheng.admin.mapper.*; |
|
|
|
import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.accident.AccidentVo; |
|
|
@@ -51,6 +47,9 @@ public class QueryAccidentCardListService { |
|
|
|
@Autowired |
|
|
|
private AccidentMapper accidentMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InspectionMapper inspectionMapper; |
|
|
|
|
|
|
|
public JsonResult getList(QueryAccidentCardListRequest request) { |
|
|
|
// log.info("进入查询事件列表业务"); |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
@@ -88,10 +87,12 @@ public class QueryAccidentCardListService { |
|
|
|
Map<String, String> deptNameMap = this.getDeptMap(accidentList); |
|
|
|
Map<String, User> userMap = this.getUserMap(deptNameMap); |
|
|
|
Map<String, InspectionFile> inspectionFileMap = this.getInspectionFileMap(accidentList); |
|
|
|
Map<String, Inspection> inspectionMap = this.getInspectionMap(accidentList); |
|
|
|
List<AccidentVo> accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); |
|
|
|
String deptName; |
|
|
|
User user; |
|
|
|
InspectionFile inspectionFile; |
|
|
|
Inspection inspection; |
|
|
|
for (AccidentVo accidentVo : accidentVoList) { |
|
|
|
if (ObjectUtil.isNotNull(deptNameMap)) { |
|
|
|
deptName = deptNameMap.get(accidentVo.getDeptId()); |
|
|
@@ -113,10 +114,29 @@ public class QueryAccidentCardListService { |
|
|
|
accidentVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(ObjectUtil.isNotNull(inspectionMap)){ |
|
|
|
inspection = inspectionMap.get(accidentVo.getInspectionId()); |
|
|
|
if(ObjectUtil.isNotNull(inspection)){ |
|
|
|
accidentVo.setInspectionStatus(inspection.getStatus()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return accidentVoList; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String, Inspection> getInspectionMap(List<Accident> accidentList) { |
|
|
|
if (CollectionUtil.isEmpty(accidentList)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<String> inspectionIdList = accidentList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList()); |
|
|
|
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery() |
|
|
|
.eq(Inspection::getMark, MarkEnum.VALID.getCode()) |
|
|
|
.in(Inspection::getId, inspectionIdList)); |
|
|
|
Map<String, Inspection> inspectionMap = inspectionList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v), HashMap::putAll); |
|
|
|
|
|
|
|
return inspectionMap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置列表中每一个的部门名称 |
|
|
|
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 |