| | |
| | | String PATROL_TASK_PREFIX = "RW"; |
| | | //线索事件编号前缀 |
| | | String EVENT_NUM_PREFIX = "XS"; |
| | | //线索事件编号前缀 |
| | | String SJ_EVENT_NUM_PREFIX = "SJ"; |
| | | // 机构前缀 |
| | | String ORG_PREFIX = "JG"; |
| | | |
| | |
| | | DEFAULT_SKIP_URL.add("/manager/check-upload"); |
| | | DEFAULT_SKIP_URL.add("/assets/**"); |
| | | DEFAULT_SKIP_URL.add("/workOrder/gdPatrolTask/get-share-cache-data"); |
| | | DEFAULT_SKIP_URL.add("/workOrder/gdPatrolTask/pendingAcceptanceTasks"); |
| | | DEFAULT_SKIP_URL.add("/workOrder/gdClueEvent/submitExternal"); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 事件表(线索事件) 新增或修改-对外接口 |
| | | */ |
| | | @PostMapping("/submitExternal") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入gdClueEvent") |
| | | public R submitExternal(@Valid @RequestBody GdClueEventEntity gdClueEvent) { |
| | | return R.status(gdClueEventService.saveOrUpdateExternal(gdClueEvent)); |
| | | } |
| | | |
| | | /** |
| | | * 事件表(线索事件) 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | |
| | | } |
| | | |
| | | /** |
| | | * 成果表批量新增并返回ID列表,不关联任务-对外接口 |
| | | */ |
| | | // @PostMapping("/batchSaveWithIds") |
| | | // @ApiOperationSupport(order = 8) |
| | | // @ApiOperation(value = "批量新增并返回ID", notes = "传入gdTaskResult") |
| | | // public R<List<Long>> batchSaveWithIds(@Valid @RequestBody List<GdTaskResultDTO> gdTaskResults) { |
| | | // log.info("批量新增并返回ID-对外接口{}", JSON.toJSONString(gdTaskResults)); |
| | | // return R.data(gdTaskResultService.batchSaveWithIds(gdTaskResults)); |
| | | // } |
| | | |
| | | /** |
| | | * 成果表 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | |
| | | package org.sxkj.gd.workorder.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 事件表(线索事件) 实体类 |
| | |
| | | */ |
| | | @ApiModelProperty(value = "事件编号") |
| | | private String eventNum; |
| | | /** |
| | | * 事件名称 |
| | | */ |
| | | @ApiModelProperty(value = "事件名称") |
| | | private String eventName; |
| | | |
| | | /** |
| | | * 附件类型:1媒体文件; 2ai文件; 3主视频 |
| | | */ |
| | | @ApiModelProperty(value = "附件类型:1媒体文件; 2ai文件; 3主视频 4视频文件mp4") |
| | | private Integer attachmentType; |
| | | /** |
| | | * 附件URL |
| | | */ |
| | | @ApiModelProperty(value = "附件URL") |
| | | private String attachUrl; |
| | | /** |
| | | * AI图片的画框数据 |
| | | */ |
| | | @ApiModelProperty(value = "AI图片的画框数据") |
| | | private String geojson; |
| | | |
| | | /** |
| | | * 拍摄时间 |
| | | */ |
| | | @ApiModelProperty(value = "拍摄时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date shootTime; |
| | | |
| | | } |
| | |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="geojson" property="geojson"/> |
| | | <result column="attachment_type" property="attachmentType"/> |
| | | <result column="event_name" property="eventName"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="gdClueEventCountVoResultMap" type="org.sxkj.gd.workorder.vo.GdClueEventCountVO"> |
| | |
| | | </select> |
| | | |
| | | <select id="selectGdClueEventSimpleList" resultMap="gdClueEventListVoResultMap"> |
| | | select ce.id as id, |
| | | tr.result_url as event_image_url, |
| | | tr.geojson as geojson, |
| | | tr.attachment_type, |
| | | ce.create_time as create_time |
| | | select |
| | | ce.id as id, |
| | | ce.event_name, |
| | | COALESCE(tr.result_url, ce.attach_url) as event_image_url, |
| | | COALESCE(tr.geojson, ce.geojson) as geojson, |
| | | COALESCE(tr.attachment_type, ce.attachment_type) as attachment_type, |
| | | ce.create_time as create_time |
| | | from ja_gd_clue_event ce |
| | | left join ja_gd_task_result tr on tr.id::VARCHAR = ce.result_id::VARCHAR and tr.is_deleted = 0 |
| | | <include refid="gdClueEventDeptWhere"/> |
| | |
| | | </select> |
| | | |
| | | <select id="selectGdClueEventDetailById" resultMap="gdClueEventVoResultMap"> |
| | | select ce.*, |
| | | select |
| | | ce.id, |
| | | ce.result_id, |
| | | ce.work_order_id, |
| | | ce.dispose_user, |
| | | ce.dispose_dept, |
| | | ce.longitude, |
| | | ce.latitude, |
| | | ce.event_status, |
| | | ce.area_code, |
| | | ce.event_num, |
| | | ce.event_name, |
| | | ce.create_user, |
| | | ce.create_dept, |
| | | ce.create_time, |
| | | ce.update_user, |
| | | ce.update_time, |
| | | ce.status, |
| | | ce.is_deleted, |
| | | COALESCE(bu.real_name, bu.name) as dispose_user_name, |
| | | bd.dept_name as dispose_dept_name, |
| | | COALESCE(cu.real_name, cu.name) as distribute_user_name, |
| | |
| | | ce.create_time as distribute_time, |
| | | concat(ce.longitude, ',', ce.latitude) as event_location, |
| | | ce.event_num as event_num, |
| | | tr.shoot_time as shoot_time, |
| | | tr.result_url as event_image_url, |
| | | tr.geojson as geojson, |
| | | tr.attachment_type |
| | | COALESCE(tr.shoot_time, ce.shoot_time) as shoot_time, |
| | | COALESCE(tr.result_url, ce.attach_url) as event_image_url, |
| | | COALESCE(tr.geojson, ce.geojson) as geojson, |
| | | COALESCE(tr.attachment_type, ce.attachment_type) as attachment_type, |
| | | tr.id as tr_id, |
| | | tr.attachment_type as tr_attachment_type_raw |
| | | from ja_gd_clue_event ce |
| | | left join blade_user bu on bu.id::VARCHAR = ce.dispose_user::VARCHAR and bu.is_deleted = 0 |
| | | left join blade_dept bd on bd.id::VARCHAR = ce.dispose_dept::VARCHAR and bd.is_deleted = 0 |
| | |
| | | */ |
| | | @ApiModelProperty(value = "区域编码") |
| | | private String areaCode; |
| | | |
| | | @ApiModelProperty(value = "事件名称", required = true) |
| | | private String eventName; |
| | | } |
| | |
| | | */ |
| | | List<GdClueEventExcel> exportGdClueEvent(Wrapper<GdClueEventEntity> queryWrapper); |
| | | |
| | | /** |
| | | * 对外接口新增或修改事件 |
| | | * <p> |
| | | * 生成事件编号并保存或更新事件信息 |
| | | * </p> |
| | | * |
| | | * @param gdClueEvent 事件实体 |
| | | * @return 是否操作成功 |
| | | */ |
| | | boolean saveOrUpdateExternal(GdClueEventEntity gdClueEvent); |
| | | |
| | | } |
| | |
| | | package org.sxkj.gd.workorder.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import org.sxkj.gd.workorder.dto.GdTaskResultDTO; |
| | | import org.sxkj.gd.workorder.entity.GdTaskResultEntity; |
| | | import org.sxkj.gd.workorder.vo.GdTaskResultVO; |
| | | import org.sxkj.gd.workorder.excel.GdTaskResultExcel; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.sxkj.gd.workorder.dto.GdTaskResultDTO; |
| | | import org.sxkj.gd.workorder.entity.GdTaskResultEntity; |
| | | import org.sxkj.gd.workorder.excel.GdTaskResultExcel; |
| | | import org.sxkj.gd.workorder.vo.GdTaskResultVO; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | |
| | | List<GdTaskResultExcel> exportGdTaskResult(Wrapper<GdTaskResultEntity> queryWrapper); |
| | | |
| | | /** |
| | | * 批量保存成果数据 |
| | | * |
| | | * @param gdTaskResults |
| | | * @return |
| | | * @param gdTaskResults 成果DTO列表 |
| | | * @return 保存成功后的成果ID列表 |
| | | */ |
| | | boolean saveBatchTaskResult(List<GdTaskResultDTO> gdTaskResults); |
| | | |
| | |
| | | * @param response HTTP响应 |
| | | */ |
| | | void downloadResultFiles(String ids, HttpServletResponse response); |
| | | |
| | | /** |
| | | * 批量保存成果数据(包含ID) |
| | | * |
| | | * @param gdTaskResults 成果DTO列表 |
| | | * @return 保存成功后的成果ID列表 |
| | | * @return |
| | | */ |
| | | List<Long> batchSaveWithIds(List<GdTaskResultDTO> gdTaskResults); |
| | | } |
| | |
| | | clueEvent.setCreateUser(AuthUtil.getUserId()); |
| | | clueEvent.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | clueEvent.setCreateTime(new Date()); |
| | | clueEvent.setEventName(distributeParam.getEventName()); |
| | | if (!save(clueEvent)) { |
| | | throw new RuntimeException("事件分发失败"); |
| | | } |
| | |
| | | return gdClueEventList; |
| | | } |
| | | |
| | | /** |
| | | * 对外接口新增或修改事件 |
| | | * <p> |
| | | * 步骤: |
| | | * 1. 生成事件编号(使用SJ前缀) |
| | | * 2. 设置事件编号到实体 |
| | | * 3. 保存或更新事件信息 |
| | | * </p> |
| | | * |
| | | * @param gdClueEvent 事件实体 |
| | | * @return 是否操作成功 |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateExternal(GdClueEventEntity gdClueEvent) { |
| | | // 1. 生成事件编号 |
| | | String times = OrderNumUtils.initOrderNum(WordOrderConstant.EVENT_NUM_KEY); |
| | | String eventNum = WordOrderConstant.SJ_EVENT_NUM_PREFIX + times; |
| | | // 2. 设置事件编号 |
| | | gdClueEvent.setEventNum(eventNum); |
| | | gdClueEvent.setCreateTime(new Date()); |
| | | gdClueEvent.setEventStatus(1); |
| | | // 3. 保存或更新 |
| | | return saveOrUpdate(gdClueEvent); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.sxkj.gd.workorder.dto.GdTaskResultDTO; |
| | | import org.sxkj.gd.workorder.entity.GdDeviceCallDetailEntity; |
| | | import org.sxkj.gd.workorder.entity.GdDeviceCallEntity; |
| | |
| | | * 保存普通成果数据(dateType != 4) |
| | | * |
| | | * @param gdTaskResults 成果DTO列表 |
| | | * @return 保存成功后的成果ID列表 |
| | | */ |
| | | @Override |
| | | public List<Long> batchSaveWithIds(List<GdTaskResultDTO> gdTaskResults) { |
| | | // 步骤1:转换DTO为实体 |
| | | List<GdTaskResultEntity> gdTaskResultEntities = GdTaskResultWrapper.build().listEntity(gdTaskResults); |
| | | |
| | | // 步骤2:处理每个实体的属性 |
| | | gdTaskResultEntities.forEach(gdTaskResult -> { |
| | | String processedAreaCode = HeaderUtils.processAreaCode(gdTaskResult.getAreaCode()); |
| | | gdTaskResult.setAreaCode(processedAreaCode); |
| | | // 如果resultCode为空,生成时间戳作为默认值 |
| | | if (StringUtil.isEmpty(gdTaskResult.getResultCode())) { |
| | | gdTaskResult.setResultCode(String.valueOf(System.currentTimeMillis())); |
| | | } |
| | | if (gdTaskResult.getShootTime() == null) { |
| | | gdTaskResult.setShootTime(new Date()); |
| | | } |
| | | gdTaskResult.setStatus(0); |
| | | gdTaskResult.setUpdateTime(new Date()); |
| | | gdTaskResult.setCreateTime(new Date()); |
| | | gdTaskResult.setIsDeleted(0); |
| | | gdTaskResult.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | gdTaskResult.setUpdateUser(AuthUtil.getUserId()); |
| | | gdTaskResult.setDistributeStatus(0); |
| | | }); |
| | | |
| | | // 步骤3:批量插入数据 |
| | | int insertCount = baseMapper.insertBatch(gdTaskResultEntities); |
| | | |
| | | // 步骤4:收集并返回保存后的ID列表 |
| | | return gdTaskResultEntities.stream() |
| | | .map(GdTaskResultEntity::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 保存普通成果数据(dateType != 4) |
| | | * |
| | | * @param gdTaskResults 成果DTO列表 |
| | | */ |
| | | private void saveNormalTaskResults(List<GdTaskResultDTO> gdTaskResults) { |
| | | List<GdTaskResultEntity> gdTaskResultEntities = GdTaskResultWrapper.build().listEntity(gdTaskResults); |
| | |
| | | |
| | | @ApiModelProperty(value = "事件附件类型") |
| | | private Integer attachmentType; |
| | | /** |
| | | * 事件名称 |
| | | */ |
| | | @ApiModelProperty(value = "事件名称") |
| | | private String eventName; |
| | | } |
| | |
| | | @ApiModelProperty(value = "事件附件类型") |
| | | private Integer attachmentType; |
| | | |
| | | /** |
| | | * 事件名称 |
| | | */ |
| | | @ApiModelProperty(value = "事件名称") |
| | | private String eventName; |
| | | |
| | | |
| | | } |
| | |
| | | * 将单个DTO转换为Entity |
| | | * 处理geojson字段:将字符串数组格式转换为正确的JSON对象数组格式 |
| | | * |
| | | * @param dto DTO对象 |
| | | * @param dto DTO对象,不能为null |
| | | * @return Entity对象 |
| | | * @throws IllegalArgumentException 当dto为null时抛出 |
| | | */ |
| | | private GdTaskResultEntity convertDtoToEntity(GdTaskResultDTO dto) { |
| | | GdTaskResultEntity entity = BeanUtil.copy(dto, GdTaskResultEntity.class); |
| | | |
| | | // 步骤1:设置附件类型 |
| | | if (dto.getAttachmentType() != null) { |
| | | entity.setAttachmentType(dto.getAttachmentType()); |
| | | } else if (dto.getDateType() != null) { |
| | | entity.setAttachmentType(dto.getDateType()); |
| | | // 步骤1:参数校验 |
| | | if (dto == null) { |
| | | throw new IllegalArgumentException("dto不能为null"); |
| | | } |
| | | |
| | | // 步骤2:处理geojson字段,将字符串数组转换为正确的JSON格式 |
| | | // 步骤2:基础属性拷贝 |
| | | GdTaskResultEntity entity = BeanUtil.copy(dto, GdTaskResultEntity.class); |
| | | |
| | | // 步骤3:设置附件类型 |
| | | Integer attachmentType = determineAttachmentType(dto); |
| | | entity.setAttachmentType(attachmentType); |
| | | |
| | | // 步骤4:处理geojson字段,将字符串数组转换为正确的JSON格式 |
| | | String processedGeojson = processGeojson(dto.getGeojson()); |
| | | entity.setGeojson(processedGeojson); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据DTO信息确定附件类型 |
| | | * 优先使用dateType判断,其次通过文件URL后缀判断 |
| | | * |
| | | * @param dto DTO对象 |
| | | * @return 附件类型:1-图片,3-视频 |
| | | */ |
| | | private Integer determineAttachmentType(GdTaskResultDTO dto) { |
| | | // 步骤1:优先使用dateType判断 |
| | | if (dto.getDateType() != null) { |
| | | // 录像的视频特殊处理 |
| | | if ("视频".equals(dto.getFileType())) { |
| | | return 3; |
| | | } |
| | | return dto.getDateType(); |
| | | } |
| | | |
| | | // 步骤2:通过URL后缀判断 |
| | | String resultUrl = dto.getResultUrl(); |
| | | if (StringUtil.isEmpty(resultUrl)) { |
| | | return 1; // 默认返回图片类型 |
| | | } |
| | | |
| | | // 步骤3:根据文件扩展名判断类型 |
| | | String lowerUrl = resultUrl.toLowerCase(); |
| | | if (lowerUrl.endsWith(".mp4") || lowerUrl.endsWith(".m3u8")) { |
| | | return 3; // 视频 |
| | | } |
| | | return 1; // 图片(包含jpg、png及其他格式) |
| | | } |
| | | |
| | | /** |
| | | * 处理geojson字段,将字符串数组格式转换为正确的JSON对象数组格式 |
| | | * 解决问题:["{\"score\":0.88}"] -> [{"score":0.88}] |
| | | * |