|
|
@@ -2,17 +2,22 @@ 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.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.tuoheng.admin.conver.AccidentConverMapper; |
|
|
|
import com.tuoheng.admin.entity.Accident; |
|
|
|
import com.tuoheng.admin.entity.Dept; |
|
|
|
import com.tuoheng.admin.entity.InspectionFileHandle; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.enums.AccidentEnum; |
|
|
|
import com.tuoheng.admin.enums.FlagEnum; |
|
|
|
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.UserMapper; |
|
|
|
import com.tuoheng.admin.query.AccidentQuery; |
|
|
|
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
@@ -35,7 +40,7 @@ import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询事件分页列表业务层处理 |
|
|
|
* 查询事故卡片分页列表业务层处理 |
|
|
|
* |
|
|
|
* @author wanjing |
|
|
|
* @team tuoheng |
|
|
@@ -47,6 +52,10 @@ public class QueryAccidentPageListService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DeptMapper deptMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AccidentMapper accidentMapper; |
|
|
|
|
|
|
@@ -54,22 +63,12 @@ public class QueryAccidentPageListService { |
|
|
|
// log.info("进入查询事件分页列表业务"); |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
request.setTenantId(tenantId); |
|
|
|
|
|
|
|
JsonResult result = this.check(tenantId, request); |
|
|
|
if (0 != result.getCode()) { |
|
|
|
log.info("进入查询巡检任务分页列表业务:校验失败:{}", result.getMsg()); |
|
|
|
log.info("进入查询事故卡片分页列表业务:校验失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
List<String> deptIdList = null; |
|
|
|
List<Dept> deptList = deptMapper.selectList(Wrappers.<Dept>lambdaQuery() |
|
|
|
.like(Dept::getName, request.getDeptName()) |
|
|
|
.eq(Dept::getMark, 1)); |
|
|
|
if (CollectionUtil.isNotEmpty(deptList)) { |
|
|
|
deptIdList = deptList.stream().map(o -> o.getId()).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
request.setDeptIdList(deptIdList); |
|
|
|
|
|
|
|
// 设置分页参数 |
|
|
|
IPage<Accident> page = new Page<>(request.getPage(), request.getLimit()); |
|
|
|
IPage<Accident> pageData = accidentMapper.selectPageList(page, request); |
|
|
@@ -103,14 +102,23 @@ public class QueryAccidentPageListService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<AccidentVo> buildAccidentVoList(List<Accident> accidentList) { |
|
|
|
Map<String, String> deptMap = this.getDeptMap(accidentList); |
|
|
|
Map<String, String> deptNameMap = this.getDeptMap(accidentList); |
|
|
|
Map<String, User> userMap = this.getUserMap(deptNameMap); |
|
|
|
List<AccidentVo> accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); |
|
|
|
String deptName; |
|
|
|
User user; |
|
|
|
for (AccidentVo accidentVo : accidentVoList) { |
|
|
|
if (ObjectUtil.isNotNull(deptMap)) { |
|
|
|
deptName = deptMap.get(accidentVo.getDeptId()); |
|
|
|
if (ObjectUtil.isNotNull(deptNameMap)) { |
|
|
|
deptName = deptNameMap.get(accidentVo.getDeptId()); |
|
|
|
accidentVo.setDeptName(deptName); |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotNull(userMap)) { |
|
|
|
user = userMap.get(accidentVo.getDeptId()); |
|
|
|
if (ObjectUtil.isNotNull(user)) { |
|
|
|
accidentVo.setDepartmentHead(user.getRealname()); |
|
|
|
accidentVo.setDepartmentHeadTelephone(user.getMobile()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return accidentVoList; |
|
|
|
} |
|
|
@@ -123,13 +131,22 @@ public class QueryAccidentPageListService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, String> getDeptMap(List<Accident> accidentList) { |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
List<String> deptIdList = accidentList.stream().map(o -> o.getDeptId()).collect(Collectors.toList()); |
|
|
|
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList); |
|
|
|
for (Dept dept : deptList) { |
|
|
|
map.put(dept.getId(), dept.getName()); |
|
|
|
Map<String, String> deptNameMap = deptList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getName()), HashMap::putAll); |
|
|
|
return deptNameMap; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String, User> getUserMap(Map<String, String> deptMap) { |
|
|
|
if (ObjectUtil.isNull(deptMap)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return map; |
|
|
|
List<String> deptIdList = deptMap.keySet().stream().collect(Collectors.toList()); |
|
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() |
|
|
|
.in(User::getDeptId, deptIdList) |
|
|
|
.eq(User::getRoleId, RoleEnum.ADMIN.getCode())); |
|
|
|
Map<String, User> userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll); |
|
|
|
return userMap; |
|
|
|
} |
|
|
|
|
|
|
|
public JsonResult index(AccidentQuery query) { |