*/ | */ | ||||
private String sectionId; | private String sectionId; | ||||
/** | |||||
* 路段名称 | |||||
*/ | |||||
private String sectionName; | |||||
/** | /** | ||||
* 问题ID | * 问题ID | ||||
*/ | */ |
package com.tuoheng.admin.enums; | |||||
import lombok.Getter; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2023/3/10 | |||||
*/ | |||||
public enum AccidentStatusEnum { | |||||
UNTREATED(1,"未处理"), | |||||
PROCESSING(2,"处理中"), | |||||
IGNORED(3,"已忽略"), | |||||
PROCESSED(4,"已处理"); | |||||
AccidentStatusEnum(int code, String description){ | |||||
this.code = code; | |||||
this.description = description; | |||||
} | |||||
@Getter | |||||
private int code; | |||||
@Getter | |||||
private String description; | |||||
} |
package com.tuoheng.admin.enums; | |||||
import lombok.Getter; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2023/3/10 | |||||
*/ | |||||
public enum AccidentTaskEnum { | |||||
INSPECTION_ACCIDENT_TASK(1,"应急任务"), | |||||
INSPECTION_TASK(0,"巡检任务"); | |||||
AccidentTaskEnum(int code, String description){ | |||||
this.code = code; | |||||
this.description = description; | |||||
} | |||||
@Getter | |||||
private int code; | |||||
@Getter | |||||
private String description; | |||||
} |
package com.tuoheng.admin.enums; | |||||
import lombok.Getter; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2023/3/10 | |||||
*/ | |||||
public enum IsCasualtiesEnum { | |||||
CASUALTIES(1,"有"), | |||||
IS_NO_CASUALTIES(0,"否"); | |||||
IsCasualtiesEnum(int code, String description){ | |||||
this.code = code; | |||||
this.description = description; | |||||
} | |||||
@Getter | |||||
private int code; | |||||
@Getter | |||||
private String description; | |||||
} |
package com.tuoheng.admin.enums; | |||||
import lombok.Getter; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2023/3/10 | |||||
*/ | |||||
public enum IsDrivingSafetyEnum { | |||||
DRIVING_SAFETY(1,"有"), | |||||
IS_NO_DRIVING_SAFETY(0,"否"); | |||||
IsDrivingSafetyEnum(int code, String description){ | |||||
this.code = code; | |||||
this.description = description; | |||||
} | |||||
@Getter | |||||
private int code; | |||||
@Getter | |||||
private String description; | |||||
} |
package com.tuoheng.admin.enums; | |||||
import lombok.Getter; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2023/3/10 | |||||
*/ | |||||
public enum IsFireEnum { | |||||
IS_FIRE(1,"有"), | |||||
IS_NO_FIRE(0,"否"); | |||||
IsFireEnum(int code, String description){ | |||||
this.code = code; | |||||
this.description = description; | |||||
} | |||||
@Getter | |||||
private int code; | |||||
@Getter | |||||
private String description; | |||||
} |
package com.tuoheng.admin.enums; | |||||
import lombok.Getter; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2023/3/10 | |||||
*/ | |||||
public enum UavReturnEnum { | |||||
UAV_RETURN(1,"已回仓"), | |||||
UAV_RETURN_IS_NOT(0,"未回仓"); | |||||
UavReturnEnum(int code, String description){ | |||||
this.code = code; | |||||
this.description = description; | |||||
} | |||||
@Getter | |||||
private int code; | |||||
@Getter | |||||
private String description; | |||||
} |
package com.tuoheng.admin.service.accident; | package com.tuoheng.admin.service.accident; | ||||
import com.tuoheng.admin.entity.Accident; | |||||
import com.tuoheng.admin.mapper.AccidentMapper; | |||||
import com.tuoheng.admin.query.AccidentQuery; | import com.tuoheng.admin.query.AccidentQuery; | ||||
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | ||||
import com.tuoheng.admin.service.accident.query.QueryAccidentByIdService; | import com.tuoheng.admin.service.accident.query.QueryAccidentByIdService; | ||||
import com.tuoheng.admin.service.accident.query.QueryAccidentDetailsService; | import com.tuoheng.admin.service.accident.query.QueryAccidentDetailsService; | ||||
import com.tuoheng.admin.service.accident.query.QueryAccidentPageListService; | import com.tuoheng.admin.service.accident.query.QueryAccidentPageListService; | ||||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
*/ | */ | ||||
@Service | @Service | ||||
@Slf4j | @Slf4j | ||||
public class AccidentServiceImpl implements IAccidentService { | |||||
public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Accident> implements IAccidentService { | |||||
@Autowired | @Autowired | ||||
private QueryAccidentPageListService queryAccidentPageListService; | private QueryAccidentPageListService queryAccidentPageListService; |
package com.tuoheng.admin.service.accident; | package com.tuoheng.admin.service.accident; | ||||
import com.tuoheng.admin.entity.Accident; | |||||
import com.tuoheng.admin.query.AccidentQuery; | import com.tuoheng.admin.query.AccidentQuery; | ||||
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; | ||||
import com.tuoheng.common.core.common.IBaseService; | |||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
/** | /** | ||||
* @Author ChengWang | * @Author ChengWang | ||||
* @Date 2022/11/17 | * @Date 2022/11/17 | ||||
*/ | */ | ||||
public interface IAccidentService { | |||||
public interface IAccidentService extends IBaseService<Accident> { | |||||
/** | /** | ||||
* 查询事故列表(分页) | * 查询事故列表(分页) |
* @param vo | * @param vo | ||||
*/ | */ | ||||
private void getInspectionById(Accident accident, AccidentDetailsVo vo) { | private void getInspectionById(Accident accident, AccidentDetailsVo vo) { | ||||
if(StringUtils.isNotEmpty(accident.getAccidentInspectionId())){ | |||||
Inspection inspection = inspectionMapper.selectById(accident.getAccidentInspectionId()); | |||||
if(StringUtils.isNotEmpty(accident.getInspectionId())){ | |||||
Inspection inspection = inspectionMapper.selectById(accident.getInspectionId()); | |||||
if(inspection.getAirportName() !=null){ | if(inspection.getAirportName() !=null){ | ||||
vo.setAirPortName(inspection.getAirportName()); | vo.setAirPortName(inspection.getAirportName()); | ||||
} | } |
} | } | ||||
public JsonResult index(AccidentQuery query) { | 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); | throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | ||||
} | } |
import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.tuoheng.admin.entity.*; | import com.tuoheng.admin.entity.*; | ||||
import com.tuoheng.admin.enums.AiAnalyseTypeEnum; | |||||
import com.tuoheng.admin.enums.FileTypeEnum; | |||||
import com.tuoheng.admin.enums.InspectionFileStatusEnum; | |||||
import com.tuoheng.admin.enums.SourceEnum; | |||||
import com.tuoheng.admin.enums.*; | |||||
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | |||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
import com.tuoheng.admin.request.third.DspCallbackRequest; | import com.tuoheng.admin.request.third.DspCallbackRequest; | ||||
import com.tuoheng.admin.request.third.QuestionFile; | import com.tuoheng.admin.request.third.QuestionFile; | ||||
import com.tuoheng.admin.service.accident.IAccidentService; | |||||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||||
import com.tuoheng.admin.utils.GaodeUtil; | import com.tuoheng.admin.utils.GaodeUtil; | ||||
import com.tuoheng.common.core.config.common.CommonConfig; | import com.tuoheng.common.core.config.common.CommonConfig; | ||||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||||
import com.tuoheng.common.core.exception.ServiceException; | import com.tuoheng.common.core.exception.ServiceException; | ||||
import com.tuoheng.common.core.utils.*; | import com.tuoheng.common.core.utils.*; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.util.CollectionUtils; | import org.springframework.util.CollectionUtils; | ||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
/** | /** | ||||
@Autowired | @Autowired | ||||
private QuestionTypeMapper questionTypeMapper; | private QuestionTypeMapper questionTypeMapper; | ||||
@Autowired | |||||
private RoadInformationMapper roadInformationMapper; | |||||
@Autowired | |||||
private IAccidentService accidentService; | |||||
/** | /** | ||||
* 保存DSP回调数据 | * 保存DSP回调数据 | ||||
* | * | ||||
log.info("批量插入问题图片数据"); | log.info("批量插入问题图片数据"); | ||||
CommonUtils.batchOperate((x) -> inspectionFileMapper.addBatch(x), thirstyQuestionFiles, 1000); | CommonUtils.batchOperate((x) -> inspectionFileMapper.addBatch(x), thirstyQuestionFiles, 1000); | ||||
//批量插入问题之后调用saveAccidentData方法保存应急记录数据入库 | |||||
Boolean flag = this.saveAccidentData(thirstyQuestionFiles); | |||||
log.info("预警数据入库结束,{}",flag); | |||||
} | } | ||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
/** | |||||
* 应急记录数据入库 | |||||
* @param inspectionFileList | |||||
* @return | |||||
*/ | |||||
private Boolean saveAccidentData(List<InspectionFile> inspectionFileList){ | |||||
log.info("应急数据入库开始...."); | |||||
//获取当前登录用户 | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
//部门 | |||||
String deptId = user.getDeptId(); | |||||
if(StringUtils.isEmpty(deptId)){ | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
List<Accident> accidentList = new ArrayList<>(); | |||||
List<QuestionType> questionTypeList = questionTypeMapper.selectList(Wrappers.<QuestionType>lambdaQuery() | |||||
.eq(QuestionType::getMark, MarkEnum.VALID.getCode())); | |||||
Map<String,QuestionType> typeMap = new HashMap<>(); | |||||
for (QuestionType type : questionTypeList) { | |||||
typeMap.put(type.getCode(),type); | |||||
} | |||||
//调用问题列表接口 | |||||
for (InspectionFile inspectionFile : inspectionFileList) { | |||||
Accident accident = new Accident(); | |||||
//问题类型为应急类型时添加数据 | |||||
if(inspectionFile.getQuestionCode().equals(QuestionTypeEnum.PON_DING_NAME.getCode())){ | |||||
accident.setTenantId(inspectionFile.getTenantId()); | |||||
accident.setDeptId(deptId); | |||||
accident.setInspectionId(inspectionFile.getInspectionId()); | |||||
accident.setInspectionFileId(inspectionFile.getId()); | |||||
accident.setAccidentInspectionId(inspectionFile.getInspectionId()); | |||||
//根据巡检任务查询对应的公路id | |||||
Inspection inspection = inspectionMapper.selectById(inspectionFile.getInspectionId()); | |||||
if(ObjectUtils.isNotEmpty(inspection)){ | |||||
accident.setRoadId(inspection.getRoadId()); | |||||
accident.setSectionId(inspection.getSectionId()); | |||||
accident.setSectionName(inspection.getSectionName()); | |||||
//根据巡检任务类型判断当前应急事故类型 | |||||
Integer accidentTaskType = inspection.getAccidentTask(); | |||||
if(AccidentTaskEnum.INSPECTION_ACCIDENT_TASK.getCode() == accidentTaskType){ | |||||
accident.setFlag(FlagEnum.ACCIDENT.getCode()); | |||||
}else { | |||||
accident.setFlag(FlagEnum.INSPECTION_ACCIDENT.getCode()); | |||||
} | |||||
} | |||||
//公路代号 | |||||
RoadInformation roadInformation = roadInformationMapper.selectById(inspection.getRoadId()); | |||||
if(ObjectUtils.isNotEmpty(roadInformation)){ | |||||
accident.setRoadCode(roadInformation.getCode()); | |||||
} | |||||
accident.setQuestionId(inspectionFile.getQuestionId()); | |||||
accident.setQuestionCode(inspectionFile.getQuestionCode()); | |||||
accident.setQuestionName(inspectionFile.getQuestionName()); | |||||
accident.setIsCasualties(IsCasualtiesEnum.IS_NO_CASUALTIES.getCode()); | |||||
accident.setIsDrivingSafety(IsDrivingSafetyEnum.IS_NO_DRIVING_SAFETY.getCode()); | |||||
accident.setIsFire(IsFireEnum.IS_NO_FIRE.getCode()); | |||||
accident.setLongitude(inspectionFile.getLongitude()); | |||||
accident.setLatitude(inspectionFile.getLatitude()); | |||||
accident.setUavReturn(UavReturnEnum.UAV_RETURN_IS_NOT.getCode()); | |||||
accident.setStatus(AccidentStatusEnum.UNTREATED.getCode()); | |||||
accident.setCreateUser(user.getUsername()); | |||||
accident.setCreateTime(inspectionFile.getCreateTime()); | |||||
accidentList.add(accident); | |||||
} | |||||
} | |||||
return accidentService.saveBatch(accidentList); | |||||
} | |||||
/** | /** | ||||
* 获取飞行坐标 | * 获取飞行坐标 | ||||
* | * |