Browse Source

Merge branch 'develop' of http://192.168.11.14:51037/gitadmin/tuoheng_freeway into feature_v1.0

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
d4a63314e1
15 changed files with 523 additions and 142 deletions
  1. +10
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java
  2. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java
  3. +13
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java
  4. +35
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java
  5. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardPageListRequest.java
  6. +14
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java
  7. +10
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java
  8. +1
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java
  9. +0
    -14
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentByIdService.java
  10. +153
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java
  11. +208
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java
  12. +11
    -112
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java
  13. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java
  14. +26
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java
  15. +33
    -3
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml

+ 10
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java View File

@@ -24,11 +24,20 @@ public class AccidentController {
* 查询事故卡片分页列表
*/
@GetMapping("/card/page/list")
public JsonResult getAccidentCardPageList(QueryAccidentPageListRequest request) {
public JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request) {
// log.info("进入查询事故分页列表接口");
return accidentService.getAccidentCardPageList(request);
}

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

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

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java View File

@@ -163,6 +163,13 @@ public class Accident extends BaseEntity {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date reportTime;

/**
* 忽略时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date ignoreTime;

/**
* 结束时间
*/

+ 13
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java View File

@@ -4,9 +4,12 @@ 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.QueryAccidentPageListRequest;
import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest;
import com.tuoheng.admin.request.accident.QueryAccidentCardPageListRequest;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @Author ChengWang
* @Date 2023/3/2
@@ -19,6 +22,14 @@ public interface AccidentMapper extends BaseMapper<Accident> {
* @param request 事故查询实体
* @return 事故集合
*/
Page<Accident> selectPageList(@Param("page") IPage page, @Param("request") QueryAccidentPageListRequest request);
Page<Accident> selectPageList(@Param("page") IPage page, @Param("request") QueryAccidentCardPageListRequest request);

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

}

+ 35
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java View File

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

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
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;

}

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentPageListRequest.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardPageListRequest.java View File

@@ -9,14 +9,14 @@ import java.util.Date;
import java.util.List;

/**
* 查询巡检任务请求实体
* 查询事故卡片分页请求实体
*
* @author wanjing
* @team tuoheng
* @date 2022-11-17
*/
@Data
public class QueryAccidentPageListRequest extends BaseQuery {
public class QueryAccidentCardPageListRequest extends BaseQuery {

/**
* 公路名称

+ 14
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java View File

@@ -5,9 +5,7 @@ import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.*;
import com.tuoheng.admin.service.accident.ignore.AccidentIgnoreService;
import com.tuoheng.admin.service.accident.query.QueryAccidentByIdService;
import com.tuoheng.admin.service.accident.query.QueryAccidentDetailsService;
import com.tuoheng.admin.service.accident.query.QueryAccidentPageListService;
import com.tuoheng.admin.service.accident.query.*;
import com.tuoheng.admin.service.accident.reoprt.ReportAccidentService;
import com.tuoheng.admin.service.accident.reoprt.ReportNoAccidentService;
import com.tuoheng.admin.service.accident.verify.AccidentVerifyCompletedService;
@@ -26,6 +24,12 @@ import org.springframework.stereotype.Service;
@Slf4j
public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Accident> implements IAccidentService {

@Autowired
private QueryAccidentCardPageListService queryAccidentCardPageListService;

@Autowired
private QueryAccidentCardListService queryAccidentCardListService;

@Autowired
private QueryAccidentPageListService queryAccidentPageListService;

@@ -60,8 +64,13 @@ public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Acciden
private AccidentIgnoreService accidentIgnoreService;

@Override
public JsonResult getAccidentCardPageList(QueryAccidentPageListRequest request) {
return queryAccidentPageListService.getPageList(request);
public JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request) {
return queryAccidentCardPageListService.getPageList(request);
}

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

@Override

+ 10
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java View File

@@ -15,10 +15,18 @@ public interface IAccidentService extends IBaseService<Accident> {
/**
* 查询事故列表(分页)
*
* @param request 事故分页查询实体
* @param request 事故分页列表查询实体
* @return 巡检任务集合
*/
JsonResult getAccidentCardPageList(QueryAccidentPageListRequest request);
JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request);

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

/**
* 查询事故信息

+ 1
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java View File

@@ -84,6 +84,7 @@ public class AccidentIgnoreService {
accidentUpdate.setStatus(AccidentStatusEnum.IGNORED.getCode());
accidentUpdate.setUpdateUser(userId);
accidentUpdate.setUpdateTime(DateUtils.now());
accidentUpdate.setIgnoreTime(DateUtils.now());
Integer count = accidentMapper.updateById(accidentUpdate);
if (count <= 0) {
log.info("事故忽略,修改预警信息失败");

+ 0
- 14
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentByIdService.java View File

@@ -1,20 +1,11 @@
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.enums.MarkEnum;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.accident.AccidentVo;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
@@ -22,11 +13,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
* 根据ID查询事件业务层处理
*

+ 153
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java View File

@@ -0,0 +1,153 @@
package com.tuoheng.admin.service.accident.query;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.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.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.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;

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

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 accidentList
* @return
*/
private List<AccidentVo> buildAccidentVoList(List<Accident> accidentList) {
Map<String, String> deptNameMap = this.getDeptMap(accidentList);
Map<String, User> userMap = this.getUserMap(deptNameMap);
Map<String, InspectionFile> inspectionFileMap = this.getInspectionFileMap(accidentList);
List<AccidentVo> accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList);
String deptName;
User user;
InspectionFile inspectionFile;
for (AccidentVo accidentVo : accidentVoList) {
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());
}
}
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());
}
}
}
return accidentVoList;
}

/**
* 设置列表中每一个的部门名称
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
*
* @param accidentList
* @return
*/
private Map<String, String> getDeptMap(List<Accident> accidentList) {
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, User> getUserMap(Map<String, String> deptMap) {
if (ObjectUtil.isNull(deptMap)) {
return null;
}
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;
}

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

+ 208
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java View File

@@ -0,0 +1,208 @@
package com.tuoheng.admin.service.accident.query;

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.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.QueryAccidentCardPageListRequest;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.accident.AccidentVo;
import com.tuoheng.admin.vo.accident.QueryAccidentPageVO;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
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 QueryAccidentCardPageListService {

@Autowired
private DeptMapper deptMapper;

@Autowired
private UserMapper userMapper;

@Autowired
private AccidentMapper accidentMapper;

public JsonResult getPageList(QueryAccidentCardPageListRequest request) {
// log.info("进入查询事件分页列表业务");
String tenantId = CurrentUserUtil.getTenantId();
request.setTenantId(tenantId);
JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
log.info("进入查询事故卡片分页列表业务:校验失败:{}", result.getMsg());
return result;
}

// 设置分页参数
IPage<Accident> page = new Page<>(request.getPage(), request.getLimit());
IPage<Accident> pageData = accidentMapper.selectPageList(page, request);

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

// 重写返回结果对象
IPage<AccidentVo> accidentVoPageData = new Page<>();
accidentVoPageData.setPages(pageData.getPages());
accidentVoPageData.setCurrent(pageData.getCurrent());
accidentVoPageData.setSize(pageData.getSize());
accidentVoPageData.setTotal(pageData.getTotal());
accidentVoPageData.setRecords(accidentVoList);
return JsonResult.success(accidentVoPageData);
}

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

/**
* @param accidentList
* @return
*/
private List<AccidentVo> buildAccidentVoList(List<Accident> 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(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;
}

/**
* 设置列表中每一个的部门名称
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
*
* @param accidentList
* @return
*/
private Map<String, String> getDeptMap(List<Accident> accidentList) {
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, User> getUserMap(Map<String, String> deptMap) {
if (ObjectUtil.isNull(deptMap)) {
return null;
}
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) {
//校验
if(query.getLimit() == null && query.getPage() == null){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}

//当前租户下
String tenantId = CurrentUserUtil.getTenantId();
if(tenantId == null){
return JsonResult.error(AccidentEnum.TENANT_ID_IS_NULL.getCode(),AccidentEnum.TENANT_ID_IS_NULL.getMsg());
}
query.setTenantId(tenantId);
IPage<Accident> page = new Page<>(query.getPage(),query.getLimit());
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(),query.getLimit());
//搜索时间
Date startTime = null;
Date endTime = null;
if(StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())){
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getStartTime()+" 00:00:00");
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getEndTime()+" 23:59:59");
}
query.setAccidentStartTime(startTime);
query.setAccidentEndTime(endTime);
//获取分页数据
IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery()
.eq(null != query.getCode(),Accident::getRoadCode,query.getCode())
.eq(null != query.getDeptId(),Accident::getDeptId,query.getDeptId())
.between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(),
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime())
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode())
.eq(Accident::getMark, MarkEnum.VALID.getCode())
.orderByDesc(Accident::getCreateTime));
//属性复制
List<QueryAccidentPageVO> result = accidentPageData.getRecords().stream().map(x -> {
QueryAccidentPageVO vo = new QueryAccidentPageVO();
BeanUtils.copyProperties(x, vo);
//公路代号
if (StringUtils.isNotEmpty(x.getRoadCode())) {
vo.setCode(x.getRoadCode());
}
//监管部门
if (StringUtils.isNotEmpty(x.getDeptId())) {
//根据当前部门id查询对应的部门名称
Dept dept = deptMapper.selectById(x.getDeptId());
vo.setName(dept.getName() !=null?dept.getName():"");
}

return vo;
}).collect(Collectors.toList());
pageData.setPages(accidentPageData.getPages());
pageData.setRecords(result);
pageData.setTotal(accidentPageData.getTotal());
pageData.setCurrent(accidentPageData.getCurrent());

return JsonResult.success(pageData);


}
}

+ 11
- 112
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java View File

@@ -1,27 +1,18 @@
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;
import com.tuoheng.admin.vo.accident.AccidentVo;
import com.tuoheng.admin.vo.accident.QueryAccidentPageVO;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException;
@@ -34,9 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
@@ -59,123 +48,33 @@ public class QueryAccidentPageListService {
@Autowired
private AccidentMapper accidentMapper;

public JsonResult getPageList(QueryAccidentPageListRequest request) {
// log.info("进入查询事件分页列表业务");
String tenantId = CurrentUserUtil.getTenantId();
request.setTenantId(tenantId);
JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) {
log.info("进入查询事故卡片分页列表业务:校验失败:{}", result.getMsg());
return result;
}

// 设置分页参数
IPage<Accident> page = new Page<>(request.getPage(), request.getLimit());
IPage<Accident> pageData = accidentMapper.selectPageList(page, request);

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

// 重写返回结果对象
IPage<AccidentVo> accidentVoPageData = new Page<>();
accidentVoPageData.setPages(pageData.getPages());
accidentVoPageData.setCurrent(pageData.getCurrent());
accidentVoPageData.setSize(pageData.getSize());
accidentVoPageData.setTotal(pageData.getTotal());
accidentVoPageData.setRecords(accidentVoList);
return JsonResult.success(accidentVoPageData);
}

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

/**
* @param accidentList
* @return
*/
private List<AccidentVo> buildAccidentVoList(List<Accident> 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(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;
}

/**
* 设置列表中每一个的部门名称
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
*
* @param accidentList
* @return
*/
private Map<String, String> getDeptMap(List<Accident> accidentList) {
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, User> getUserMap(Map<String, String> deptMap) {
if (ObjectUtil.isNull(deptMap)) {
return null;
}
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) {
//校验
if(query.getLimit() == null && query.getPage() == null){
if (query.getLimit() == null && query.getPage() == null) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}

//当前租户下
String tenantId = CurrentUserUtil.getTenantId();
if(tenantId == null){
return JsonResult.error(AccidentEnum.TENANT_ID_IS_NULL.getCode(),AccidentEnum.TENANT_ID_IS_NULL.getMsg());
if (tenantId == null) {
return JsonResult.error(AccidentEnum.TENANT_ID_IS_NULL.getCode(), AccidentEnum.TENANT_ID_IS_NULL.getMsg());
}
query.setTenantId(tenantId);
IPage<Accident> page = new Page<>(query.getPage(),query.getLimit());
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(),query.getLimit());
IPage<Accident> page = new Page<>(query.getPage(), query.getLimit());
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(), query.getLimit());
//搜索时间
Date startTime = null;
Date endTime = null;
if(StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())){
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getStartTime()+" 00:00:00");
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getEndTime()+" 23:59:59");
if (StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())) {
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getStartTime() + " 00:00:00");
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getEndTime() + " 23:59:59");
}
query.setAccidentStartTime(startTime);
query.setAccidentEndTime(endTime);
//获取分页数据
IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery()
.eq(null != query.getCode(),Accident::getRoadCode,query.getCode())
.eq(null != query.getDeptId(),Accident::getDeptId,query.getDeptId())
.eq(null != query.getCode(), Accident::getRoadCode, query.getCode())
.eq(null != query.getDeptId(), Accident::getDeptId, query.getDeptId())
.between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(),
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime())
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode())
@@ -193,7 +92,7 @@ public class QueryAccidentPageListService {
if (StringUtils.isNotEmpty(x.getDeptId())) {
//根据当前部门id查询对应的部门名称
Dept dept = deptMapper.selectById(x.getDeptId());
vo.setName(dept.getName() !=null?dept.getName():"");
vo.setName(dept.getName() != null ? dept.getName() : "");
}

return vo;

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java View File

@@ -3,7 +3,6 @@ package com.tuoheng.admin.service.dept;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.request.dept.EditDeptRequest;
import com.tuoheng.admin.service.accident.query.QueryAccidentPageListService;
import com.tuoheng.admin.service.dept.add.AddDeptService;
import com.tuoheng.admin.service.dept.delete.DeleteDeptService;
import com.tuoheng.admin.service.dept.query.*;

+ 26
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java View File

@@ -100,6 +100,32 @@ public class AccidentVo extends BaseEntity {
*/
private String latitude;

/**
* 位置信息
*/
private String location;

/**
* 文件名称
*/
private String fileName;

/**
* 标记图
*/
private String fileImage;

/**
* 缩略图
*/
private String fileThumbnail;

/**
* 原图
*/
private String fileOriginal;


/**
* 事故状态:1未处理 2处理中 3已忽略 4已处理
*/

+ 33
- 3
tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml View File

@@ -29,22 +29,30 @@
<result property="checkUser" column="check_user" />
<result property="checkTime" column="check_time" />
<result property="checkResult" column="check_result" />
<result property="verificationTime" column="verification_time" />
<result property="reportTime" column="report_time" />
<result property="noAccidentTime" column="no_accident_time" />
<result property="ignoreTime" column="ignore_time" />
<result property="endTime" column="end_time" />
<result property="flag" column="flag" />
<result property="mark" column="mark" />
</resultMap>


<sql id="Base_Column_List">
id, tenant_id, dept_id, inspection_id, inspection_file_id, accident_inspection_id, road_id, section_id, question_id, question_code, question_name,
is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time,
check_user, check_time, check_result, mark
check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark
</sql>

<sql id="selectThAccidentVo">
select id, tenant_id, dept_id, inspection_id, inspection_file_id, accident_inspection_id, road_id, section_id, question_id, question_code, question_name,
is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time,
check_user, check_time, check_result, mark from th_accident
check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark
from th_accident
</sql>

<select id="selectPageList" parameterType="com.tuoheng.admin.request.accident.QueryAccidentPageListRequest" resultMap="AccidentResult">
<select id="selectPageList" parameterType="com.tuoheng.admin.request.accident.QueryAccidentCardPageListRequest" resultMap="AccidentResult">
select <include refid="Base_Column_List"/>
from th_accident
<where>
@@ -73,4 +81,26 @@
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="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>

Loading…
Cancel
Save