Pārlūkot izejas kodu

提交查询事件卡片列表

develop
wanjing pirms 9 mēnešiem
vecāks
revīzija
b21c468410
7 mainītis faili ar 271 papildinājumiem un 0 dzēšanām
  1. +9
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java
  2. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java
  3. +32
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java
  4. +9
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java
  5. +8
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java
  6. +180
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java
  7. +23
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml

+ 9
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java Parādīt failu

@@ -69,6 +69,15 @@ public class AccidentController {
return accidentService.getAccidentPageList(request);
}

/**
* 查询事故卡片列表
*/
@GetMapping("/card/list")
public JsonResult getAccidentCardList(QueryAccidentCardListRequest request) {
// log.info("进入查询事故分页列表接口");
return accidentService.getAccidentCardList(request);
}

/**
* 获取巡检任务信息信息
*/

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java Parādīt failu

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest;
import com.tuoheng.admin.request.accident.QueryAccidentRealtimeInfoListRequest;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.request.accident.QueryHistoryPageListRequest;
@@ -41,4 +42,13 @@ public interface AccidentMapper extends BaseMapper<Accident> {
*/
Page<Accident> getHistoryPageList(@Param("page") IPage page, @Param("request") QueryHistoryPageListRequest request);


/**
* 查询事故分页列表
*
* @param request 事故查询实体
* @return 事故集合
*/
List<Accident> selectAccidentCardList(@Param("request") QueryAccidentCardListRequest request);

}

+ 32
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java Parādīt failu

@@ -0,0 +1,32 @@
package com.tuoheng.admin.request.accident;

import lombok.Data;

import java.util.List;

/**
* 查询事故卡片请求实体
*
* @author wanjing
* @team tuoheng
* @date 2023-03-20
*/
@Data
public class QueryAccidentCardListRequest {

/**
* 任务状态
*/
private List<Integer> statusList;

/**
* 租户Id
*/
private String tenantId;

/**
* 部门Id list
*/
private List<String> deptIdList;

}

+ 9
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java Parādīt failu

@@ -37,6 +37,9 @@ public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Acciden
@Autowired
private QueryAccidentHistoryListService queryAccidentHistoryListService;

@Autowired
private QueryAccidentCardListService queryAccidentCardListService;

@Autowired
private QueryAccidentPageListService queryAccidentPageListService;

@@ -83,6 +86,12 @@ public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Acciden
return queryAccidentHistoryListService.getPageList(request);
}

@Override
public JsonResult getAccidentCardList(QueryAccidentCardListRequest request) {
return queryAccidentCardListService.getList(request);
}


/**
* 新增应急事件
*

+ 8
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java Parādīt failu

@@ -30,6 +30,14 @@ public interface IAccidentService extends IBaseService<Accident> {
*/
JsonResult getHistoryPageList(QueryHistoryPageListRequest request);

/**
* 查询事故列表
*
* @param request 事故列表查询实体
* @return 巡检任务集合
*/
JsonResult getAccidentCardList(QueryAccidentCardListRequest request);

/**
* 新增应急事件
*

+ 180
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java Parādīt failu

@@ -0,0 +1,180 @@
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.Wrappers;
import com.tuoheng.admin.conver.AccidentConverMapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.DataPermissionEnum;
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;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 查询事故卡片列表业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-03-03
*/
@Slf4j
@Service
public class QueryAccidentCardListService {

@Autowired
private DeptMapper deptMapper;

@Autowired
private UserMapper userMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private AccidentMapper accidentMapper;

@Autowired
private InspectionMapper inspectionMapper;

public JsonResult getList(QueryAccidentCardListRequest request) {
// log.info("进入查询事件列表业务");
User user = CurrentUserUtil.getUserInfo();
String tenantId = user.getTenantId();

JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
log.info("进入查询事故卡片列表业务:校验失败:{}", result.getMsg());
return result;
}

List<String> deptIdList = this.getDeptIdList(user);
request.setDeptIdList(deptIdList);
request.setTenantId(tenantId);
List<Accident> accidentList = accidentMapper.selectAccidentCardList(request);

// 构造返回结果对象
List<AccidentVo> accidentVoList = this.buildAccidentVoList(accidentList);

return JsonResult.success(accidentVoList);
}

/**
* 检查参数
*
* @param tenantId
* @param request
* @return
*/
private JsonResult check(String tenantId, QueryAccidentCardListRequest request) {
return JsonResult.success();
}

/**
* 根据用户自己的数据权限,查询对应部门的数据
*
* @param user
* @return
*/
private List<String> getDeptIdList(User user) {
List<String> deptIdList = new ArrayList<>();
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null;
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
deptIdList.add(user.getDeptId());
}
return deptIdList;
}

/**
* @param accidentList
* @return
*/
private List<AccidentVo> buildAccidentVoList(List<Accident> accidentList) {
Map<String, String> deptNameMap = this.getDeptMap(accidentList);
Map<String, InspectionFile> inspectionFileMap = this.getInspectionFileMap(accidentList);
Map<String, Inspection> inspectionMap = this.getInspectionMap(accidentList);
List<AccidentVo> accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList);
String deptName;
InspectionFile inspectionFile;
Inspection inspection;
for (AccidentVo accidentVo : accidentVoList) {
if (ObjectUtil.isNotNull(deptNameMap)) {
deptName = deptNameMap.get(accidentVo.getDeptId());
accidentVo.setDeptName(deptName);
}
if (ObjectUtil.isNotNull(inspectionFileMap)) {
inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId());
if (ObjectUtil.isNotNull(inspectionFile)) {
accidentVo.setFileName(inspectionFile.getFileName());
accidentVo.setFileImage(CommonConfig.imageURL + inspectionFile.getFileImage());
accidentVo.setFileOriginal(CommonConfig.imageURL + inspectionFile.getFileOriginal());
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中
*
* @param accidentList
* @return
*/
private Map<String, String> getDeptMap(List<Accident> accidentList) {
if (CollectionUtil.isEmpty(accidentList)) {
return null;
}
List<String> deptIdList = accidentList.stream().map(o -> o.getDeptId()).collect(Collectors.toList());
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList);
Map<String, String> deptNameMap = deptList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getName()), HashMap::putAll);
return deptNameMap;
}

private Map<String, InspectionFile> getInspectionFileMap(List<Accident> accidentList) {
if (CollectionUtil.isEmpty(accidentList)) {
return null;
}
List<String> inspectionFileIdList = accidentList.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList());
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper<InspectionFile>()
.in(InspectionFile::getId, inspectionFileIdList));
Map<String, InspectionFile> inspectionFileMap = inspectionFileList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v), HashMap::putAll);
return inspectionFileMap;
}
}

+ 23
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml Parādīt failu

@@ -130,4 +130,27 @@
</where>
order by create_time desc
</select>

<select id="selectAccidentCardList" parameterType="com.tuoheng.admin.request.accident.QueryAccidentCardListRequest" resultMap="AccidentResult">
select <include refid="Base_Column_List"/>
from th_accident
<where>
<if test="1 == 1"> and mark = 1 </if>
<if test="1 == 1"> and flag = 0 </if>
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if>
<if test="request.statusList != null and request.statusList.size() > 0">
and status in
<foreach item="status" collection="request.statusList" open="(" separator="," close=")">
#{status}
</foreach>
</if>
<if test="request.deptIdList != null and request.deptIdList.size() > 0">
and dept_id in
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
</where>
order by create_time desc
</select>
</mapper>

Notiek ielāde…
Atcelt
Saglabāt