@@ -1,10 +1,17 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | |||
import com.tuoheng.admin.service.accident.IAccidentService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.PathVariable; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 事故表 前端控制器 | |||
* 事故前端控制器 | |||
* | |||
* @Author ChengWang | |||
* @Date 2023/3/2 | |||
*/ | |||
@@ -12,5 +19,25 @@ import org.springframework.web.bind.annotation.RestController; | |||
@RequestMapping("/accident") | |||
public class AccidentController { | |||
@Autowired | |||
private IAccidentService accidentService; | |||
/** | |||
* 查询巡检任务分页列表 | |||
*/ | |||
@GetMapping("/page/list") | |||
public JsonResult list(QueryAccidentPageListRequest request) { | |||
// log.info("进入查询事故分页列表接口"); | |||
return accidentService.getPageList(request); | |||
} | |||
/** | |||
* 获取巡检任务信息信息 | |||
*/ | |||
@GetMapping(value = "/info/{id}") | |||
public JsonResult getInfo(@PathVariable("id") String id) { | |||
// log.info("进入查询事故详情接口, id={}", id); | |||
return accidentService.getAccidentInfo(id); | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.admin.conver; | |||
import com.tuoheng.admin.entity.Accident; | |||
import com.tuoheng.admin.entity.Dept; | |||
import com.tuoheng.admin.vo.accident.AccidentVo; | |||
import com.tuoheng.admin.vo.dept.DeptInfoVo; | |||
import com.tuoheng.admin.vo.dept.DeptTreeVo; | |||
import org.mapstruct.Mapper; | |||
import org.mapstruct.factory.Mappers; | |||
import java.util.List; | |||
@Mapper | |||
public interface AccidentConverMapper { | |||
AccidentConverMapper INSTANCE = Mappers.getMapper(AccidentConverMapper.class); | |||
/** | |||
* deptList 转化为 deptVoList | |||
* @param accidentList | |||
* | |||
* @return | |||
*/ | |||
List<AccidentVo> accidentListToAccidentVoList(List<Accident> accidentList); | |||
} |
@@ -1,11 +1,24 @@ | |||
package com.tuoheng.admin.mapper; | |||
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 org.apache.ibatis.annotations.Param; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/3/2 | |||
*/ | |||
public interface AccidentMapper extends BaseMapper<Accident> { | |||
/** | |||
* 查询事故分页列表 | |||
* | |||
* @param request 事故查询实体 | |||
* @return 事故集合 | |||
*/ | |||
Page<Accident> selectPageList(@Param("page") IPage page, @Param("request") QueryAccidentPageListRequest request); | |||
} |
@@ -0,0 +1,65 @@ | |||
package com.tuoheng.admin.request.accident; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
import java.util.List; | |||
/** | |||
* 查询巡检任务请求实体 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-17 | |||
*/ | |||
@Data | |||
public class QueryAccidentPageListRequest extends BaseQuery { | |||
/** | |||
* 公路名称 | |||
*/ | |||
private String roadName; | |||
/** | |||
* 路段名称 | |||
*/ | |||
private String sectionName; | |||
/** | |||
* 部门名称 | |||
*/ | |||
private String deptName; | |||
/** | |||
* 任务状态 | |||
*/ | |||
private List<Integer> statusList; | |||
/** | |||
* 开始时间 | |||
*/ | |||
@JsonFormat(pattern = "yyyy-MM-dd") | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
private Date beginTime; | |||
/** | |||
* 结束时间 | |||
*/ | |||
@JsonFormat(pattern = "yyyy-MM-dd") | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
private Date endTime; | |||
/** | |||
* 租户Id | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 部门Id list | |||
*/ | |||
private List<String> deptIdList; | |||
} |
@@ -1,9 +1,11 @@ | |||
package com.tuoheng.admin.service.accident; | |||
import com.tuoheng.admin.entity.Accident; | |||
import com.tuoheng.admin.mapper.AccidentMapper; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | |||
import com.tuoheng.admin.service.accident.query.QueryAccidentByIdService; | |||
import com.tuoheng.admin.service.accident.query.QueryAccidentPageListService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
@@ -12,6 +14,21 @@ import org.springframework.stereotype.Service; | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Accident> implements IAccidentService{ | |||
public class AccidentServiceImpl implements IAccidentService { | |||
@Autowired | |||
private QueryAccidentPageListService queryAccidentPageListService; | |||
@Autowired | |||
private QueryAccidentByIdService queryAccidentByIdService; | |||
@Override | |||
public JsonResult getPageList(QueryAccidentPageListRequest request) { | |||
return queryAccidentPageListService.getPageList(request); | |||
} | |||
@Override | |||
public JsonResult getAccidentInfo(String id) { | |||
return queryAccidentByIdService.getInfoById(id); | |||
} | |||
} |
@@ -3,6 +3,8 @@ package com.tuoheng.admin.service.accident; | |||
import com.tuoheng.admin.entity.Accident; | |||
import com.tuoheng.admin.entity.Section; | |||
import com.tuoheng.admin.query.SectionQuery; | |||
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | |||
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
import com.tuoheng.common.core.common.IBaseService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
@@ -10,6 +12,22 @@ import com.tuoheng.common.core.utils.JsonResult; | |||
* @Author ChengWang | |||
* @Date 2022/11/17 | |||
*/ | |||
public interface IAccidentService extends IBaseService<Accident> { | |||
public interface IAccidentService { | |||
/** | |||
* 查询事故列表(分页) | |||
* | |||
* @param request 事故分页查询实体 | |||
* @return 巡检任务集合 | |||
*/ | |||
JsonResult getPageList(QueryAccidentPageListRequest request); | |||
/** | |||
* 查询事故信息 | |||
* | |||
* @param id 事故Id | |||
* @return 事故 | |||
*/ | |||
JsonResult getAccidentInfo(String id); | |||
} |
@@ -0,0 +1,80 @@ | |||
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.vo.accident.AccidentVo; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
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.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 根据ID查询事件业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-03-03 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryAccidentByIdService { | |||
@Autowired | |||
private AccidentMapper accidentMapper; | |||
public JsonResult getInfoById(String id) { | |||
// log.info("进入根据ID查询事件业务"); | |||
// String tenantId = CurrentUserUtil.getTenantId(); | |||
String tenantId = "1"; | |||
JsonResult result = this.check(tenantId, id); | |||
if (0 != result.getCode()) { | |||
log.info("进入根据ID查询事件业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
Accident accident = (Accident) result.getData(); | |||
return JsonResult.success(accident); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param tenantId | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String tenantId, String id) { | |||
if (StringUtils.isEmpty(id)) { | |||
throw new ServiceException("事故ID为空"); | |||
} | |||
Accident accident = accidentMapper.selectOne(new LambdaQueryWrapper<Accident>() | |||
.eq(Accident::getId, id) | |||
.eq(Accident::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(accident)) { | |||
throw new ServiceException("事故不存在"); | |||
} | |||
return JsonResult.success(accident); | |||
} | |||
} |
@@ -0,0 +1,143 @@ | |||
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.conver.InspectionConverMapper; | |||
import com.tuoheng.admin.entity.Accident; | |||
import com.tuoheng.admin.entity.Dept; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.RoleEnum; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; | |||
import com.tuoheng.admin.mapper.AccidentMapper; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | |||
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
import com.tuoheng.admin.service.inspection.query.handle.GenerateInspectionFieldHander; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.accident.AccidentVo; | |||
import com.tuoheng.admin.vo.inspection.InspectionVo; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
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.beans.factory.annotation.Qualifier; | |||
import org.springframework.stereotype.Service; | |||
import javax.annotation.PostConstruct; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Function; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 查询事件分页列表业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-03-03 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryAccidentPageListService { | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Autowired | |||
private AccidentMapper accidentMapper; | |||
public JsonResult getPageList(QueryAccidentPageListRequest request) { | |||
// log.info("进入查询事件分页列表业务"); | |||
// String tenantId = CurrentUserUtil.getTenantId(); | |||
String tenantId = "1"; | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(tenantId, request); | |||
if (0 != result.getCode()) { | |||
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); | |||
// 构造返回结果对象 | |||
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> deptMap = this.getDeptMap(accidentList); | |||
List<AccidentVo> accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); | |||
String deptName; | |||
for (AccidentVo accidentVo : accidentVoList) { | |||
if (ObjectUtil.isNotNull(deptMap)) { | |||
deptName = deptMap.get(accidentVo.getDeptId()); | |||
accidentVo.setDeptName(deptName); | |||
} | |||
} | |||
return accidentVoList; | |||
} | |||
/** | |||
* 设置列表中每一个的部门名称 | |||
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 | |||
* | |||
* @param accidentList | |||
* @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()); | |||
} | |||
return map; | |||
} | |||
} |
@@ -0,0 +1,142 @@ | |||
package com.tuoheng.admin.vo.accident; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.math.BigDecimal; | |||
import java.util.Date; | |||
/** | |||
* 事件对象 | |||
* | |||
* @team tuoheng | |||
* @author wanjing | |||
* @date 2023-03-03 | |||
*/ | |||
@Data | |||
public class AccidentVo extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 部门id | |||
*/ | |||
private String deptId; | |||
/** | |||
* 部门名称 | |||
*/ | |||
private String deptName; | |||
/** | |||
* 巡检任务id | |||
*/ | |||
private String inspectionId; | |||
/** | |||
* 巡检任务问题ID | |||
*/ | |||
private String inspectionFileId; | |||
/** | |||
* 应急任务ID | |||
*/ | |||
private String accidentInspectionId; | |||
/** | |||
* 公路id | |||
*/ | |||
private String roadId; | |||
/** | |||
* 公路名称 | |||
*/ | |||
private String roadName; | |||
/** | |||
* 路段ID | |||
*/ | |||
private String sectionId; | |||
/** | |||
* 路段名称 | |||
*/ | |||
private String sectionName; | |||
/** | |||
* 问题ID | |||
*/ | |||
private String questionId; | |||
/** | |||
* 问题编码 | |||
*/ | |||
private String questionCode; | |||
/** | |||
* 问题名称 | |||
*/ | |||
private String questionName; | |||
/** | |||
* 是否有伤亡:0:无;1:有 | |||
*/ | |||
private Integer isCasualties; | |||
/** | |||
* 是否影响驾驶安全:0:无;1:有 | |||
*/ | |||
private Integer isDrivingSafety; | |||
/** | |||
* 是否有明火:0:无;1:有 | |||
*/ | |||
private Integer isFire; | |||
/** | |||
* 事故现场描述 | |||
*/ | |||
private String record; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 无人机回仓:0未回仓;1:已回仓 | |||
*/ | |||
private Integer uavReturn; | |||
/** | |||
* 事故状态:1未处理 2处理中 3已忽略 4已处理 | |||
*/ | |||
private Integer status; | |||
/** | |||
*处理人 | |||
*/ | |||
private String checkUser; | |||
/** | |||
* 处理时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date checkTime; | |||
/** | |||
* 处理结果 | |||
*/ | |||
private String checkResult; | |||
} |
@@ -2,5 +2,75 @@ | |||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.tuoheng.admin.mapper.AccidentMapper"> | |||
<resultMap type="com.tuoheng.admin.entity.Accident" id="AccidentResult"> | |||
<result property="id" column="id" /> | |||
<result property="tenantId" column="tenant_id" /> | |||
<result property="deptId" column="dept_id" /> | |||
<result property="inspectionId" column="inspection_id" /> | |||
<result property="inspectionFileId" column="inspection_file_id" /> | |||
<result property="accidentInspectionId" column="accident_inspection_id" /> | |||
<result property="roadId" column="road_id" /> | |||
<result property="sectionId" column="section_id" /> | |||
<result property="questionId" column="question_id" /> | |||
<result property="questionCode" column="question_code" /> | |||
<result property="questionName" column="question_name" /> | |||
<result property="isCasualties" column="is_casualties" /> | |||
<result property="isDrivingSafety" column="is_driving_safety" /> | |||
<result property="isFire" column="is_fire" /> | |||
<result property="record" column="record" /> | |||
<result property="longitude" column="longitude" /> | |||
<result property="latitude" column="latitude" /> | |||
<result property="uavReturn" column="uav_return" /> | |||
<result property="status" column="status" /> | |||
<result property="createUser" column="create_user" /> | |||
<result property="createTime" column="create_time" /> | |||
<result property="updateUser" column="update_user" /> | |||
<result property="updateTime" column="update_time" /> | |||
<result property="checkUser" column="check_user" /> | |||
<result property="checkTime" column="check_time" /> | |||
<result property="checkResult" column="check_result" /> | |||
<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 | |||
</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 | |||
</sql> | |||
<select id="selectPageList" parameterType="com.tuoheng.admin.request.accident.QueryAccidentPageListRequest" 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.sectionName != null and request.sectionName != ''"> and section_name = #{request.sectionName} </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> | |||
<if test="request.beginTime != null"> | |||
and create_time >= #{request.beginTime} | |||
</if> | |||
<if test="request.endTime != null"> | |||
and create_time <= #{request.endTime} | |||
</if> | |||
</where> | |||
order by create_time desc | |||
</select> | |||
</mapper> |