@@ -0,0 +1,111 @@ | |||
package com.tuoheng.common.core.constant; | |||
/** | |||
* 系统公共常量 | |||
*/ | |||
public class CommonConstants { | |||
/** | |||
* UTF-8 字符集 | |||
*/ | |||
public static final String UTF8 = "UTF-8"; | |||
/** | |||
* GBK 字符集 | |||
*/ | |||
public static final String GBK = "GBK"; | |||
/** | |||
* http请求 | |||
*/ | |||
public static final String HTTP = "http://"; | |||
/** | |||
* https请求 | |||
*/ | |||
public static final String HTTPS = "https://"; | |||
/** | |||
* 成功标记 | |||
*/ | |||
public static final Integer SUCCESS = 200; | |||
/** | |||
* 失败标记 | |||
*/ | |||
public static final Integer FAIL = 500; | |||
/** | |||
* 登录成功 | |||
*/ | |||
public static final String LOGIN_SUCCESS = "Success"; | |||
/** | |||
* 注销 | |||
*/ | |||
public static final String LOGOUT = "Logout"; | |||
/** | |||
* 注册 | |||
*/ | |||
public static final String REGISTER = "Register"; | |||
/** | |||
* 登录失败 | |||
*/ | |||
public static final String LOGIN_FAIL = "Error"; | |||
/** | |||
* 当前记录起始索引 | |||
*/ | |||
public static final String PAGE_NUM = "pageNum"; | |||
/** | |||
* 每页显示记录数 | |||
*/ | |||
public static final String PAGE_SIZE = "pageSize"; | |||
/** | |||
* 排序列 | |||
*/ | |||
public static final String ORDER_BY_COLUMN = "orderByColumn"; | |||
/** | |||
* 排序的方向 "desc" 或者 "asc". | |||
*/ | |||
public static final String IS_ASC = "isAsc"; | |||
/** | |||
* 验证码 redis key | |||
*/ | |||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; | |||
/** | |||
* 验证码有效期(分钟) | |||
*/ | |||
public static final Integer CAPTCHA_EXPIRATION = 2; | |||
/** | |||
* 参数管理 cache key | |||
*/ | |||
public static final String SYS_CONFIG_KEY = "sys_config:"; | |||
/** | |||
* 字典管理 cache key | |||
*/ | |||
public static final String SYS_DICT_KEY = "sys_dict:"; | |||
/** | |||
* 资源映射路径 前缀 | |||
*/ | |||
public static final String RESOURCE_PREFIX = "/profile"; | |||
/** | |||
* 类型:1巡检任务 | |||
*/ | |||
public static final int INSPECTION_TASK_TYPE = 1; | |||
//常用数值 | |||
public static final int ONE = 1; | |||
} |
@@ -117,6 +117,15 @@ | |||
<scope>system</scope> | |||
<systemPath>${project.basedir}/src/main/resources/lib/aliyun-java-vod-upload-1.4.14.jar</systemPath> | |||
</dependency> | |||
<dependency> | |||
<groupId>net.coobird</groupId> | |||
<artifactId>thumbnailator</artifactId> | |||
<version>[0.4, 0.5)</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring-test</artifactId> | |||
</dependency> | |||
</dependencies> | |||
@@ -15,7 +15,7 @@ public class THAdminApplication { | |||
public static void main(String[] args) { | |||
SpringApplication.run(THAdminApplication.class, args); | |||
System.out.println("(♥◠‿◠)ノ゙ 微服务【水环境监测业务服务】启动成功 ლ(´ڡ`ლ)゙"); | |||
System.out.println("(♥◠‿◠)ノ゙ 微服务【周界警戒业务服务】启动成功 ლ(´ڡ`ლ)゙"); | |||
} | |||
} |
@@ -1,10 +1,15 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.request.*; | |||
import com.tuoheng.admin.service.InspectionService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.validation.Valid; | |||
/** | |||
* @Description 飞行巡检任务模块 | |||
* @Author douzhenjun | |||
@@ -12,6 +17,7 @@ import org.springframework.web.bind.annotation.*; | |||
**/ | |||
@RestController | |||
@RequestMapping("/inspection") | |||
@Slf4j | |||
public class InspectionController { | |||
@Autowired | |||
@@ -48,4 +54,44 @@ public class InspectionController { | |||
public JsonResult execute(@PathVariable String eventId) { | |||
return inspectionService.execute(eventId, null); | |||
} | |||
/** | |||
* 被硬件调用,存任务状态 | |||
*/ | |||
@PutMapping("/status") | |||
public JsonResult track(@RequestBody @Valid MissionStatusRequest missionStatusRequest) { | |||
log.info("被硬件调用,存任务状态:{}", JSONObject.toJSONString(missionStatusRequest)); | |||
return inspectionService.updateStatus(missionStatusRequest); | |||
} | |||
/** | |||
* 被硬件调用,存飞行轨迹 | |||
*/ | |||
@PostMapping("/track") | |||
public JsonResult track(@RequestBody @Valid InspectionRequest inspectionRequest) { | |||
log.info("被硬件调用,存飞行轨迹:{}", JSONObject.toJSONString(inspectionRequest)); | |||
return inspectionService.track(inspectionRequest); | |||
} | |||
/** | |||
* 被硬件调用,执行任务后,回调执行状态 | |||
*/ | |||
@PostMapping("/executeTaskStatus") | |||
public JsonResult updateExecuteTaskStatus(@RequestBody @Valid ExecuteTaskStatusRequest executeTaskStatusRequest) { | |||
log.info("被硬件调用,执行任务后,回调执行状态:{}", JSONObject.toJSONString(executeTaskStatusRequest)); | |||
return inspectionService.updateExecuteTaskStatus(executeTaskStatusRequest); | |||
} | |||
/** | |||
* 上传离线视频 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/uploadFlightUrl") | |||
public JsonResult uploadFlightUrl(@RequestBody UploadFlightUrlRequest request) { | |||
log.info("被第三方调用,上传离线视频:{}", JSONObject.toJSONString(request)); | |||
return inspectionService.uploadFlightUrl(request); | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.tuoheng.admin.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("alert_business") | |||
public class Business extends BaseEntity { | |||
/** | |||
* 消息id | |||
*/ | |||
private String msgId; | |||
/** | |||
* 类型:1巡检任务 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 类型ID(type对应类型对应的业务ID) | |||
*/ | |||
private String typeId; | |||
/** | |||
* 租户id | |||
*/ | |||
private String tenantId; | |||
} |
@@ -0,0 +1,143 @@ | |||
package com.tuoheng.admin.entity; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import java.util.Date; | |||
/** | |||
* | |||
* @TableName alert_inspection_file | |||
*/ | |||
@TableName(value ="alert_inspection_file") | |||
@Data | |||
public class InspectionFile extends BaseEntity { | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 图片编号 | |||
*/ | |||
private String fileCode; | |||
/** | |||
* 巡检任务ID | |||
*/ | |||
private String inspectionId; | |||
/** | |||
* 附件类型:1图片 2视频 | |||
*/ | |||
private Integer fileType; | |||
/** | |||
* 文件名称 | |||
*/ | |||
private String fileName; | |||
/** | |||
* 缩略图 | |||
*/ | |||
private String fileThumbnail; | |||
/** | |||
* 原图 | |||
*/ | |||
private String fileOriginal; | |||
/** | |||
* 标记图 | |||
*/ | |||
private String fileImage; | |||
/** | |||
* 文件大小 | |||
*/ | |||
private Double fileSize; | |||
/** | |||
* 纬度(原始图片纬度) | |||
*/ | |||
private String latitude; | |||
/** | |||
* 经度(原始图片经度) | |||
*/ | |||
private String longitude; | |||
/** | |||
* 位置信息 | |||
*/ | |||
private String location; | |||
/** | |||
* 高德地图经度 | |||
*/ | |||
private String gaodeLongitude; | |||
/** | |||
* 高德地图纬度 | |||
*/ | |||
private String gaodeLatitude; | |||
/** | |||
* 高德地图地址 | |||
*/ | |||
private String gaodeAddress; | |||
/** | |||
* 问题类型二级分类ID | |||
*/ | |||
private String questionId; | |||
/** | |||
* 图片来源:1AI 2后台 3视频 | |||
*/ | |||
private Integer source; | |||
/** | |||
* 问题名称 | |||
*/ | |||
private String questionName; | |||
/** | |||
* 巡检内容 | |||
*/ | |||
private String content; | |||
/** | |||
* 详细描述 | |||
*/ | |||
private String questionDesc; | |||
/** | |||
* 审核状态:0待审核 1已审核 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 审核人 | |||
*/ | |||
private String checkUser; | |||
/** | |||
* 审核时间 | |||
*/ | |||
private Date checkTime; | |||
/** | |||
* 后台上传图片的拍摄时间 | |||
*/ | |||
@TableField(exist = false) | |||
private Long shootTime; | |||
/* | |||
是否经过确认,0没有1有 | |||
*/ | |||
private Integer isChecked; | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.tuoheng.admin.enums; | |||
import lombok.Getter; | |||
/** | |||
* Ai分析状态 | |||
*/ | |||
public enum AiAnalyseStatusEnum { | |||
UPLOADED(1,"uploaded"), | |||
WAITING(2,"waiting"), | |||
RUNNING(3,"running"), | |||
SUCCESS(4,"success"), | |||
SUCCESS_TIMEOUT(5,"success_timeout"), | |||
FAILED(6,"failed"), | |||
DEFAULT(0,"default"); | |||
AiAnalyseStatusEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
public static AiAnalyseStatusEnum getByDesc(String description){ | |||
for (AiAnalyseStatusEnum analyseStatusEnum : values()) { | |||
if(analyseStatusEnum.getDescription().equals(description)){ | |||
return analyseStatusEnum; | |||
} | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.admin.enums; | |||
import lombok.Getter; | |||
/** | |||
* Ai分析状态 | |||
* @author chenyukun | |||
*/ | |||
public enum AiAnalyseTypeEnum { | |||
ONLINE(1,"在线"), | |||
OFFLINE(2,"离线"), | |||
DEFAULT(0,"default"); | |||
AiAnalyseTypeEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -0,0 +1,27 @@ | |||
package com.tuoheng.admin.enums; | |||
import lombok.Getter; | |||
/** | |||
* 请求状态 | |||
* | |||
* @author chenyukun | |||
* @date 2022/06/14 | |||
*/ | |||
public enum HttpStatusEnum { | |||
NO_RESOURCES(600,"暂无可用的服务资源, 请稍后再试!"), | |||
; | |||
HttpStatusEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.tuoheng.admin.enums.inspection; | |||
import lombok.Getter; | |||
/** | |||
* 任务状态枚举 | |||
*/ | |||
public enum AirPortTaskStatusEnum { | |||
//任务状态1待执行 2执行中 | |||
WAIT(1,"待执行"), | |||
FLIGHT(2,"执行中"); | |||
AirPortTaskStatusEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.admin.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.admin.entity.Business; | |||
/** | |||
* kafka对应发送消息消息与任务id绑定 | |||
* | |||
* @author 拓恒 | |||
* @since 2022-03-09 | |||
*/ | |||
public interface BusinessMapper extends BaseMapper<Business> { | |||
} |
@@ -0,0 +1,56 @@ | |||
package com.tuoheng.admin.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.tuoheng.admin.entity.InspectionFile; | |||
import com.tuoheng.admin.query.WorkorderQuery; | |||
import com.tuoheng.admin.query.workOrderFileQuery; | |||
import com.tuoheng.admin.request.inspectionFile.QueryQuestionPictureRequest; | |||
import com.tuoheng.admin.request.inspectionFile.QuestionRequest; | |||
import com.tuoheng.admin.vo.QuestionDetailVo; | |||
import com.tuoheng.admin.vo.QuestionFileVo; | |||
import com.tuoheng.admin.vo.QuestionInventoryVo; | |||
import com.tuoheng.admin.vo.QuestionTypeCountVo; | |||
import com.tuoheng.admin.vo.inspetionFile.ThInspectionQuestionPictureVo; | |||
import com.tuoheng.admin.vo.inspetionFile.ThInspectionQuestionVo; | |||
import org.apache.ibatis.annotations.Param; | |||
import java.util.List; | |||
/** | |||
* @author 小影 | |||
* @description 针对表【weptsp_inspection_file】的数据库操作Mapper | |||
* @createDate 2023-05-17 10:07:30 | |||
* @Entity com.tuoheng.admin.entity.InspectionFile | |||
*/ | |||
public interface InspectionFileMapper extends BaseMapper<InspectionFile> { | |||
List<ThInspectionQuestionVo> selectQuestionList(@Param("request") QuestionRequest request, @Param("tenantId") String tenantId, @Param("deptIdList") List<String> deptIdList); | |||
List<ThInspectionQuestionPictureVo> selectPictureList(@Param("request") QueryQuestionPictureRequest request, @Param("tenantId") String tenantId); | |||
List<InspectionFile> selectReviewPictureList(@Param("inspectionId") String inspectionId, @Param("tenantId") String tenantId); | |||
IPage<QuestionInventoryVo> queryQuestionInventory(@Param("page") IPage<QuestionInventoryVo> page, @Param("param") WorkorderQuery param, @Param("tenantId") String tenantId); | |||
List<QuestionTypeCountVo> selectQuestionTypeCount(@Param("id") String id, @Param("tenantId") String tenantId); | |||
IPage<QuestionFileVo> queryQuestionFileList(@Param("page") IPage<QuestionFileVo> page, @Param("param") workOrderFileQuery query, @Param("tenantId") String tenantId); | |||
QuestionDetailVo queryQuestionDetail(@Param("fileId") String fileId, @Param("tenantId") String tenantId); | |||
ThInspectionQuestionPictureVo selectPicture(@Param("id") String sourceFileId, @Param("tenantId") String tenantId); | |||
Integer selectFileCount(@Param("param") InspectionFile file); | |||
void deleteByInspectionId(@Param("inspectionId") String inspectionId, @Param("tenantId") String tenantId); | |||
void batchadd(@Param("list") List<InspectionFile> x); | |||
Integer selectCount(@Param("parm") InspectionFile parm); | |||
} | |||
@@ -3,6 +3,8 @@ package com.tuoheng.admin.mapper; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import java.util.List; | |||
/** | |||
* @author 小影 | |||
* @description 针对表【alert_inspection(巡检任务表)】的数据库操作Mapper | |||
@@ -11,6 +13,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
*/ | |||
public interface InspectionMapper extends BaseMapper<Inspection> { | |||
int updateByPrimaryKeySelective(Inspection request); | |||
List<Inspection> getListByBox(String boxSn); | |||
} | |||
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.admin.query; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* @Author xiaoying | |||
* @Date 2023/5/20 9:13 | |||
*/ | |||
@Data | |||
public class WorkorderQuery extends BaseQuery { | |||
/** | |||
* 巡检河道id | |||
*/ | |||
private String streamId; | |||
/** | |||
* 处理状态:1问题待指派 2问题待处理 3问题处理中 4问题已处理 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 任务编码/名称集合 | |||
*/ | |||
private String keyWords; | |||
} |
@@ -0,0 +1,30 @@ | |||
package com.tuoheng.admin.query; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* @Author xiaoying | |||
* @Date 2023/5/20 9:33 | |||
*/ | |||
@Data | |||
public class workOrderFileQuery extends BaseQuery { | |||
/** | |||
* 项目名称:1河湖水面 2河湖岸线 3河湖感观水质4入河、湖异常排口 | |||
*/ | |||
private Integer questionName; | |||
/** | |||
* 巡检ID | |||
*/ | |||
private String inspectionId; | |||
/** | |||
* 图片ID | |||
*/ | |||
private String fileId; | |||
/** | |||
* 图片编码 | |||
*/ | |||
private String fileCode; | |||
} |
@@ -0,0 +1,35 @@ | |||
package com.tuoheng.admin.request; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
/** | |||
* 修改任务请求参数 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-01-10 | |||
*/ | |||
@Data | |||
public class ExecuteTaskStatusRequest implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 0:成功,500:失败 | |||
*/ | |||
private String code; | |||
/** | |||
* 业务平台任务id | |||
*/ | |||
private String requestId; | |||
/** | |||
* 执行结果 | |||
*/ | |||
private String msg; | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.admin.request; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 飞行轨迹坐标查询条件 | |||
*/ | |||
@Data | |||
public class FlightDataQuery extends BaseQuery { | |||
/** | |||
* 巡检任务ID | |||
*/ | |||
String inspectionId; | |||
} |
@@ -0,0 +1,55 @@ | |||
package com.tuoheng.admin.request; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
import java.io.Serializable; | |||
/** | |||
* @User qiujinyang | |||
* @Description | |||
* @Date Created by 2022/7/28 9:51 | |||
*/ | |||
@Data | |||
public class InspectionRequest implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
private String requestId; | |||
/** | |||
* 巡检的ID,跟硬件对接的时候,硬件的巡检ID,对应th_inspection表inspection_line字段 | |||
*/ | |||
@NotNull(message = "巡检的ID不能为空!") | |||
private Integer inspectionId; | |||
/** | |||
* 飞行高度 | |||
*/ | |||
@NotNull(message = "飞行高度不能为空!") | |||
private String altitude; | |||
/** | |||
* 经度 | |||
*/ | |||
@NotNull(message = "经度不能为空!") | |||
private String lng; | |||
/** | |||
* 纬度 | |||
*/ | |||
@NotNull(message = "纬度不能为空!") | |||
private String lat; | |||
/** | |||
* 地面基站 | |||
*/ | |||
private String hostIp; | |||
/** | |||
* 时间戳 | |||
*/ | |||
@NotNull(message = "时间戳不能为空!") | |||
private String timestamp; | |||
} |
@@ -0,0 +1,54 @@ | |||
package com.tuoheng.admin.request; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
import java.io.Serializable; | |||
/** | |||
* 巡检任务 新增或修改请求参数 | |||
* @author: qiujinyang | |||
* @date: 2021/9/7 | |||
*/ | |||
@Data | |||
public class MissionStatusRequest implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 巡检任务ID | |||
*/ | |||
@NotNull(message = "巡检任务ID不能为空!") | |||
private Integer id; | |||
/** | |||
* 视频推流地址 | |||
*/ | |||
private String pushUrl; | |||
/** | |||
* 视频拉流地址 | |||
*/ | |||
private String pullUrl; | |||
/** | |||
* 视频拉流播放地址 | |||
*/ | |||
private String playUrl; | |||
/** | |||
* 任务状态1待执行 2执行中 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 任务里程 | |||
*/ | |||
private String mileage; | |||
/** | |||
* 请求ID | |||
*/ | |||
private String requestId; | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.tuoheng.admin.request.inspectionFile; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* 查询巡检问题图片请求参数 | |||
* | |||
* @author: zhu_zishuang | |||
* @date: 2021/9/26 | |||
*/ | |||
@Data | |||
public class QueryQuestionPictureRequest extends BaseQuery { | |||
/** | |||
* 巡检ID | |||
*/ | |||
@NotBlank(message = "巡检ID不能为空!") | |||
private String inspectionId; | |||
/** | |||
* 问题类型 | |||
*/ | |||
private Integer questionName; | |||
/** | |||
* 图片审核状态:0待审核 1已审核 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.admin.request.inspectionFile; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* @Author xiaoying | |||
* @Date 2023/5/19 15:56 | |||
*/ | |||
@Data | |||
public class QuestionRequest extends BaseQuery { | |||
/** | |||
* 巡检河道id | |||
*/ | |||
private String streamId; | |||
/** | |||
* 审核状态:0待审核 1已审核 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 任务编码/名称集合 | |||
*/ | |||
private String keyWords; | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.tuoheng.admin.request.inspectionFile; | |||
import lombok.Data; | |||
@Data | |||
public class UploadHandleImageRequest { | |||
/** | |||
* 巡检问题文件ID | |||
*/ | |||
private String fileId; | |||
/** | |||
* 处理结果 | |||
*/ | |||
private String handlerResult; | |||
/** | |||
* 处理后图片(多个图片逗号“,”分隔) | |||
*/ | |||
private String handlerImage; | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.admin.service; | |||
import java.util.List; | |||
/** | |||
* 异步任务接口 | |||
*/ | |||
public interface AsyncService { | |||
/** | |||
* 飞行数据批量入库 | |||
* @param list | |||
*/ | |||
void flightDataSaveBatch(List list); | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.admin.service; | |||
import com.tuoheng.admin.entity.FlightData; | |||
import com.tuoheng.admin.request.FlightDataQuery; | |||
import com.tuoheng.common.core.common.IBaseService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/1 | |||
*/ | |||
public interface IFlightDataService extends IBaseService<FlightData> { | |||
/** | |||
* 获取飞机巡检坐标列表 | |||
* @param flightDataQuery | |||
* @return | |||
*/ | |||
JsonResult getFlightDataList(FlightDataQuery flightDataQuery); | |||
/** | |||
* 飞行遥测数据入库 | |||
* @param entity | |||
*/ | |||
void addCallback(FlightData entity); | |||
} |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.service; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.admin.request.PushAndPullURLRequest; | |||
import com.tuoheng.admin.request.*; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
/** | |||
@@ -17,5 +17,14 @@ public interface InspectionService extends IService<Inspection> { | |||
JsonResult findFlightData(String id); | |||
JsonResult execute(String eventId, PushAndPullURLRequest pushAndPull);; | |||
JsonResult execute(String eventId, PushAndPullURLRequest pushAndPull); | |||
JsonResult updateStatus(MissionStatusRequest missionStatusRequest); | |||
JsonResult track(InspectionRequest inspectionRequest); | |||
JsonResult updateExecuteTaskStatus(ExecuteTaskStatusRequest executeTaskStatusRequest); | |||
JsonResult uploadFlightUrl(UploadFlightUrlRequest request); | |||
} |
@@ -0,0 +1,105 @@ | |||
package com.tuoheng.admin.service.business; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.entity.Business; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.mapper.BusinessMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
import com.tuoheng.common.core.constant.CommonConstants; | |||
import com.tuoheng.common.core.enums.MarkEnum; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JacksonUtil; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 业务处理表 服务实现类 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-03-11 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class BusinessServiceImpl extends BaseServiceImpl<BusinessMapper, Business> implements IBusinessService { | |||
@Autowired | |||
private BusinessMapper businessMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Override | |||
public void insertBusiness(String msgId, String typeId) { | |||
// 将消息任务和kafka任务id消息存入数据库,用于监听获取任务信息 | |||
Business business = new Business(); | |||
business.setMsgId(msgId); | |||
business.setType(CommonConstants.INSPECTION_TASK_TYPE); | |||
business.setTypeId(typeId); | |||
business.setCreateUser(CurrentUserUtil.getUserId()); | |||
business.setCreateTime(DateUtils.now()); | |||
business.setUpdateUser(CurrentUserUtil.getUserId()); | |||
business.setUpdateTime(DateUtils.now()); | |||
business.setTenantId(CurrentUserUtil.getTenantId()); | |||
business.setMark(MarkEnum.VALID.getCode()); | |||
log.info("thbusiness:{}", JacksonUtil.obj2StringPretty(business)); | |||
// 查询任务是否存在 | |||
int result = businessMapper.selectCount(new LambdaQueryWrapper<Business>() | |||
.eq(Business::getMsgId, msgId) | |||
.eq(Business::getTenantId, CurrentUserUtil.getTenantId()) | |||
.eq(Business::getMark, MarkEnum.VALID.getCode())); | |||
if (result > 0) { | |||
log.info("更新"); | |||
businessMapper.update(business, new LambdaQueryWrapper<Business>() | |||
.eq(Business::getMsgId, msgId) | |||
.eq(Business::getTenantId, CurrentUserUtil.getTenantId()) | |||
.eq(Business::getMark, MarkEnum.VALID.getCode())); | |||
} else { | |||
log.info("插入"); | |||
businessMapper.insert(business); | |||
} | |||
} | |||
/** | |||
* 针对于上传时的操作 | |||
* | |||
* @param msgId | |||
* @param typeId | |||
*/ | |||
@Override | |||
public void insertBusinessUploadUrl(String msgId, String typeId) { | |||
Inspection inspection = inspectionMapper.selectById(typeId); | |||
// 将消息任务和kafka任务id消息存入数据库,用于监听获取任务信息 | |||
Business business = new Business(); | |||
business.setMsgId(msgId); | |||
business.setType(CommonConstants.INSPECTION_TASK_TYPE); | |||
business.setTypeId(typeId); | |||
business.setCreateUser(inspection.getCreateUser()); | |||
business.setCreateTime(DateUtils.now()); | |||
business.setUpdateUser(inspection.getUpdateUser()); | |||
business.setUpdateTime(DateUtils.now()); | |||
business.setTenantId(inspection.getTenantId()); | |||
business.setMark(MarkEnum.VALID.getCode()); | |||
log.info("thbusiness:{}", JacksonUtil.obj2StringPretty(business)); | |||
// 查询任务是否存在 | |||
int result = businessMapper.selectCount(new LambdaQueryWrapper<Business>() | |||
.eq(Business::getMsgId, msgId) | |||
.eq(Business::getTenantId, inspection.getTenantId()) | |||
.eq(Business::getMark, MarkEnum.VALID.getCode())); | |||
if (result > 0) { | |||
log.info("更新"); | |||
businessMapper.update(business, new LambdaQueryWrapper<Business>() | |||
.eq(Business::getMsgId, msgId) | |||
.eq(Business::getTenantId, inspection.getTenantId()) | |||
.eq(Business::getMark, MarkEnum.VALID.getCode())); | |||
} else { | |||
log.info("插入"); | |||
businessMapper.insert(business); | |||
} | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.tuoheng.admin.service.business; | |||
import com.tuoheng.admin.entity.Business; | |||
import com.tuoheng.common.core.common.IBaseService; | |||
/** | |||
* 业务处理表 服务类 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-03-11 | |||
*/ | |||
public interface IBusinessService extends IBaseService<Business> { | |||
/** | |||
* @param msgId kafka消息id | |||
* @param typeId 类型ID(type对应类型对应的业务ID) | |||
*/ | |||
void insertBusiness(String msgId, String typeId); | |||
void insertBusinessUploadUrl(String msgId, String typeId); | |||
} |
@@ -0,0 +1,28 @@ | |||
package com.tuoheng.admin.service.impl; | |||
import com.tuoheng.admin.service.AsyncService; | |||
import com.tuoheng.admin.service.IFlightDataService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.scheduling.annotation.Async; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* 异步任务接口实现 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class AsyncServiceImpl implements AsyncService { | |||
@Autowired | |||
private IFlightDataService flightDataService; | |||
@Async("asyncServiceExecutor") | |||
public void flightDataSaveBatch(List list){ | |||
log.info("线程-" + Thread.currentThread().getId() + "在执行写入"); | |||
flightDataService.saveBatch(list); | |||
} | |||
} |
@@ -0,0 +1,89 @@ | |||
package com.tuoheng.admin.service.impl; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.admin.entity.FlightData; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.mapper.FlightDataMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.request.FlightDataQuery; | |||
import com.tuoheng.admin.service.IFlightDataService; | |||
import com.tuoheng.admin.utils.RedisUtils; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
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.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/1 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class FlightDataServiceImpl extends BaseServiceImpl<FlightDataMapper, FlightData> implements IFlightDataService { | |||
@Autowired | |||
private FlightDataMapper flightDataMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private RedisUtils redisUtils; | |||
/** | |||
* 获取巡检任务飞行轨迹坐标列表 | |||
* | |||
* @param flightDataQuery | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getFlightDataList(FlightDataQuery flightDataQuery) { | |||
if (StringUtils.isEmpty(flightDataQuery.getInspectionId())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
QueryWrapper<FlightData> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("inspection_id", flightDataQuery.getInspectionId()); | |||
queryWrapper.eq("mark", 1); | |||
//飞机坐标不关联租户id | |||
//queryWrapper.eq("tenant_id", ShiroUtils.getTenantId()) | |||
queryWrapper.orderByDesc("id"); | |||
//查询分页数据 | |||
IPage<FlightData> page = new Page<>(flightDataQuery.getPage(), flightDataQuery.getLimit()); | |||
IPage<FlightData> pageData = flightDataMapper.selectPage(page, queryWrapper); | |||
return JsonResult.success(pageData); | |||
} | |||
@Override | |||
public void addCallback(FlightData entity) { | |||
log.info("云盒遥测回调,入参:{}", entity); | |||
if (ObjectUtil.isNull(entity)) { | |||
log.info("传入参数entity为空"); | |||
return; | |||
} | |||
if (StringUtils.isEmpty(entity.getBoxSn())) { | |||
log.info("云盒SN号为空"); | |||
return; | |||
} | |||
//查询正在执行的云盒所对应的任务 | |||
List<Inspection> inspectionList = inspectionMapper.getListByBox(entity.getBoxSn()); | |||
if (StringUtils.isNotEmpty(inspectionList)) { | |||
entity.setTenantId(inspectionList.get(0).getTenantId()); | |||
entity.setInspectionId(inspectionList.get(0).getId()); | |||
//将最新一条数据存放入缓存,并设置过期时间 | |||
redisUtils.set(inspectionList.get(0).getId(), entity, 10); | |||
} | |||
entity.setCreateTime(DateUtils.now()); | |||
flightDataMapper.insert(entity); | |||
log.info("addCallback接口入库成功:" + entity.getId()); | |||
} | |||
} |
@@ -1,47 +1,46 @@ | |||
package com.tuoheng.admin.service.impl; | |||
import cn.hutool.core.date.DateUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONArray; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.admin.config.CommonConfig; | |||
import com.tuoheng.admin.constant.DspInspection.DspInspectionCallback; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.dto.TemplateConfigDto; | |||
import com.tuoheng.admin.entity.Event; | |||
import com.tuoheng.admin.entity.FlightData; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.LiveChannel; | |||
import com.tuoheng.admin.enums.DspInspection.AirportRequestEnum; | |||
import com.tuoheng.admin.enums.DspInspection.PilotRequestEnum; | |||
import com.tuoheng.admin.enums.inspection.QueryInspectionInfoByIdCodeEnum; | |||
import com.tuoheng.admin.enums.inspection.QueryVideoServiceEnum; | |||
import com.tuoheng.admin.mapper.EventMapper; | |||
import com.tuoheng.admin.mapper.FlightDataMapper; | |||
import com.tuoheng.admin.mapper.LiveChannelMapper; | |||
import com.tuoheng.admin.request.DspInspection.TemplateTaskRequest; | |||
import com.tuoheng.admin.request.PushAndPullURLRequest; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.AiAnalyseStatusEnum; | |||
import com.tuoheng.admin.enums.AiAnalyseTypeEnum; | |||
import com.tuoheng.admin.enums.HttpStatusEnum; | |||
import com.tuoheng.admin.enums.inspection.*; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.request.*; | |||
import com.tuoheng.admin.service.AsyncService; | |||
import com.tuoheng.admin.service.InspectionService; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.service.business.IBusinessService; | |||
import com.tuoheng.admin.synthesize.entity.Tenant; | |||
import com.tuoheng.admin.synthesize.mapper.TenantMapper; | |||
import com.tuoheng.admin.third.DspInspection.DspInspectionService; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.DspInspection.TemplateConfigListVo; | |||
import com.tuoheng.admin.vo.DspInspection.TemplateConfigVo; | |||
import com.tuoheng.admin.vo.DspInspection.TemplateTaskVo; | |||
import com.tuoheng.admin.vo.DspInspection.TemplateVo; | |||
import com.tuoheng.admin.third.dsp.IDspService; | |||
import com.tuoheng.admin.utils.*; | |||
import com.tuoheng.admin.vo.AirWeatherVO; | |||
import com.tuoheng.admin.vo.DspCallbackVo; | |||
import com.tuoheng.admin.vo.LiveChannelVo; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import com.tuoheng.common.core.enums.MarkEnum; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.*; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.http.HttpStatus; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
import javax.annotation.Resource; | |||
import java.util.*; | |||
/** | |||
* @author 小影 | |||
@@ -70,7 +69,34 @@ public class InspectionServiceImpl extends ServiceImpl<InspectionMapper, Inspect | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@Autowired | |||
private TargetDataMapper targetDataMapper; | |||
@Autowired | |||
private BusinessMapper businessMapper; | |||
@Autowired | |||
private IDspService dspService; | |||
@Autowired | |||
private RedisUtils redisUtils; | |||
@Autowired | |||
private InspectionFileMapper inspectionFileMapper; | |||
@Autowired | |||
private IBusinessService businessService; | |||
@Resource | |||
private AsyncService asyncService; | |||
/** | |||
* DSP服务回调接口域名 | |||
*/ | |||
@Value("${tuoheng.dsp-callback-url:}") | |||
private String dspCallbackUrl; | |||
@Override | |||
public JsonResult getVideoById(String id) { | |||
if (com.tuoheng.common.core.utils.StringUtils.isEmpty(id)) { | |||
@@ -108,6 +134,9 @@ public class InspectionServiceImpl extends ServiceImpl<InspectionMapper, Inspect | |||
return JsonResult.success(liveChannelVo); | |||
} | |||
/** | |||
* 获取机场数据 | |||
*/ | |||
@Override | |||
public JsonResult findFlightData(String id) { | |||
if (StringUtils.isEmpty(id)) { | |||
@@ -119,6 +148,9 @@ public class InspectionServiceImpl extends ServiceImpl<InspectionMapper, Inspect | |||
return JsonResult.success(listData); | |||
} | |||
/** | |||
* 立即执行指点飞行任务,新增巡检任务数据 | |||
*/ | |||
@Override | |||
public JsonResult execute(String eventId, PushAndPullURLRequest pushAndPull) { | |||
/* | |||
@@ -143,239 +175,479 @@ public class InspectionServiceImpl extends ServiceImpl<InspectionMapper, Inspect | |||
String code = DateUtils.generateCode("XJRW"); | |||
inspection.setCode(code); | |||
inspectionMapper.insert(inspection); | |||
//机场写死(暂时) | |||
inspection.setAirportName("2号机场"); | |||
inspection.setAirportId(9); | |||
//绑定任务id | |||
Event eventUpdate = new Event(); | |||
eventUpdate.setId(eventId); | |||
eventUpdate.setInspectionId(inspection.getId()); | |||
eventMapper.updateById(eventUpdate); | |||
//调取巡检云去创建机场任务 | |||
inspection.setInspectionType(0); | |||
sendDsp(inspection); | |||
log.info("绑定任务id"); | |||
Event event = new Event(); | |||
event.setId(eventId); | |||
event.setInspectionId(inspection.getId()); | |||
eventMapper.updateById(event); | |||
//执行指点飞行任务 | |||
log.info("executeTask准备就绪"); | |||
//调取巡检云完成机场执行 | |||
dspInspectionService.executeAirport(inspection.getRequestId()); | |||
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("taskId", inspection.getId()); | |||
jsonObject.put("airportId", inspection.getAirportId()); | |||
jsonObject.put("zalt", "100"); | |||
Event eventResult = eventMapper.selectById(eventId); | |||
TargetData targetData = targetDataMapper.selectOne(new LambdaQueryWrapper<TargetData>() | |||
.eq(TargetData::getAlarmId, eventResult.getAlarmId()) | |||
.orderByDesc(TargetData::getCreateTime) | |||
.last("limit 1")); | |||
if(ObjectUtil.isNotNull(targetData)){ | |||
jsonObject.put("zlon", targetData.getLongitude()); | |||
jsonObject.put("zlat", targetData.getLatitude()); | |||
} | |||
log.info("调用机场平台,无人机执行定点飞行: url:{}", url); | |||
log.info("调用机场平台,无人机执行定点飞行: jsonObject:{}", jsonObject); | |||
//将任务执行状态修改为已执行 | |||
inspection.setExecutionStatus(2); | |||
inspection.setExecutionStartTime(DateUtil.date()); | |||
inspectionMapper.updateById(inspection); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
log.info("调用机场平台,无人机执行定点飞行:返回数据为空,飞行失败,jsonObject:{}", jsonObject); | |||
throw new ServiceException("机场平台返回数据为空,飞行失败"); | |||
} | |||
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
if (0 != jsonResult.getCode()) { | |||
log.info("调用机场平台,无人机执行定点飞行:飞行失败,jsonResult:{}", jsonResult.getMsg()); | |||
throw new ServiceException("机场平台返回,飞行失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 调取巡检云抽取相关方法 | |||
* | |||
* @param inspection | |||
* 被硬件调用, 存任务状态 | |||
*/ | |||
private void sendDsp(Inspection inspection) { | |||
//1.获取模板 | |||
TemplateVo templateVo = dspInspectionService.getServiceInstance(inspection.getInspectionType()); | |||
//2.获取模板配置 | |||
TemplateConfigListVo templateConfig = dspInspectionService.getTemplateConfig(templateVo.getId()); | |||
//3.巡检云构建任务发送 | |||
TemplateTaskRequest request = buildTemplateTaskRequest(templateConfig, inspection, templateVo.getType()); | |||
TemplateTaskVo templateTaskVo = dspInspectionService.addInspectionTemplateTask(request); | |||
inspection.setRequestId(templateTaskVo.getRequestId()); | |||
inspection.setWeather(templateTaskVo.getWeather()); | |||
if (0 == inspection.getInspectionType()) { | |||
inspection.setInspectionType(2); | |||
@Override | |||
public JsonResult updateStatus(MissionStatusRequest missionStatusRequest) { | |||
//查询出对应的巡检任务 | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode()) | |||
.eq(Inspection::getId, missionStatusRequest.getRequestId()) | |||
.eq(Inspection::getInspectionLine, missionStatusRequest.getId())); | |||
if (ObjectUtil.isEmpty(inspection)) { | |||
throw new ServiceException(ServiceExceptionEnum.TASK_DOES_NOT_EXIST); | |||
} | |||
inspectionMapper.updateById(inspection); | |||
} | |||
//查询业务对应的租户信息 | |||
Tenant tenant = tenantMapper.selectById(inspection.getTenantId()); | |||
/** | |||
* 构建 TemplateTaskRequest | |||
* | |||
* @param templateConfig | |||
* @return | |||
*/ | |||
private TemplateTaskRequest buildTemplateTaskRequest(TemplateConfigListVo templateConfig, Inspection | |||
inspection, Integer type) { | |||
Inspection inspectionUpdate = new Inspection(); | |||
inspectionUpdate.setId(inspection.getId()); | |||
//如果发送过来的状态是执行中,那么就说明之前是待执行,开始飞行 | |||
if (AirPortTaskStatusEnum.FLIGHT.getCode() == missionStatusRequest.getStatus()) { | |||
JSONObject jsonObject = null; | |||
try { | |||
jsonObject = startAI(missionStatusRequest); | |||
} catch (Exception e) { | |||
//如果调用DSP失败就直接失败! | |||
log.error("调用DSP数据失败:{}", e.getMessage()); | |||
inspectionUpdate.setStatus(TaskStatusEnum.FAIL.getCode()); | |||
inspectionMapper.updateById(inspectionUpdate); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "任务分析失败!"); | |||
} | |||
DspCallbackVo dspCallbackVo = JSON.toJavaObject(jsonObject.getJSONObject("data"), DspCallbackVo.class); | |||
log.info("dsp响应体:{}", JacksonUtil.obj2StringPretty(dspCallbackVo)); | |||
inspectionUpdate.setStatus(TaskStatusEnum.INFLIGHT.getCode()); | |||
inspectionMapper.updateById(inspectionUpdate); | |||
//通道表新增 | |||
LiveChannel liveChannel = new LiveChannel(); | |||
liveChannel.setTenantId(inspection.getTenantId()); | |||
liveChannel.setInspectionId(inspection.getId()); | |||
liveChannel.setChannelCode("0"); | |||
liveChannel.setPushUrl(dspCallbackVo.getPushUrl()); | |||
liveChannel.setPullUrl(missionStatusRequest.getPlayUrl()); | |||
liveChannel.setAipushUrl(dspCallbackVo.getAipushUrl()); | |||
liveChannel.setAipullUrl(dspCallbackVo.getAiplayUrl()); | |||
// 查验是否存在 | |||
LiveChannel liveChannelQuery = liveChannelMapper.selectOne(new LambdaQueryWrapper<LiveChannel>() | |||
.eq(LiveChannel::getInspectionId, inspection.getId()) | |||
.eq(LiveChannel::getMark, MarkEnum.VALID.getCode())); | |||
if (liveChannelQuery == null) { | |||
// 添加通道使用记录 | |||
liveChannel.setCreateTime(DateUtils.now()); | |||
liveChannelMapper.insert(liveChannel); | |||
} else { | |||
// 更新通道使用记录 | |||
liveChannel.setId(liveChannelQuery.getId()); | |||
liveChannelMapper.updateById(liveChannel); | |||
} | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
Tenant tenant = tenantMapper.selectById(tenantId); | |||
TemplateTaskRequest request = new TemplateTaskRequest(); | |||
List<TemplateConfigDto> dtos = new ArrayList<>(); | |||
List<TemplateConfigDto> configUrlDtos = new ArrayList<>(); | |||
TemplateConfigDto dto = null; | |||
List<TemplateConfigVo> templateInstReqList = templateConfig.getTemplateInstReqList(); | |||
List<TemplateConfigVo> templateInstConfigList = templateConfig.getTemplateInstConfigList(); | |||
if (1 == type) { | |||
//飞手 | |||
buildDtosByPilot(inspection, tenant, dtos, dto, templateInstReqList); | |||
} else if (0 == type) { | |||
//机场 | |||
buildDtosByAirport(inspection, tenant, dtos, dto, templateInstReqList); | |||
// 将请求id和业务id消息存入数据库,用于监听获取任务信息 | |||
Business thbusiness = new Business(); | |||
thbusiness.setTenantId(inspection.getTenantId()); | |||
thbusiness.setMsgId(dspCallbackVo.getRequestId()); | |||
thbusiness.setType(1); | |||
thbusiness.setTypeId(inspection.getId()); | |||
thbusiness.setCreateTime(DateUtils.now()); | |||
businessMapper.insert(thbusiness);//todo | |||
} else if (AirPortTaskStatusEnum.WAIT.getCode() == missionStatusRequest.getStatus()) { | |||
inspectionUpdate.setStatus(TaskStatusEnum.COMPLETE.getCode()); | |||
List<Business> thbusinessList = businessMapper.selectList(new LambdaQueryWrapper<Business>() | |||
.eq(Business::getTypeId, inspection.getId()) | |||
.eq(Business::getMark, MarkEnum.VALID.getCode()) | |||
.orderByDesc(Business::getCreateTime)); | |||
if (StringUtils.isNotEmpty(thbusinessList)) { | |||
//硬件停止后,停止AI分析 | |||
stopAI(thbusinessList.get(0).getMsgId(), inspection.getId()); | |||
//获取天气信息 | |||
try { | |||
AirWeatherVO weather = getWeather(CommonConfig.airportURL, inspection.getAirportId()); | |||
String weatherStr = AirWeatherUtil.getWeather(weather); | |||
inspectionUpdate.setWeather(weatherStr); | |||
Integer flightDataCount = flightDataMapper.selectCount(new LambdaQueryWrapper<FlightData>() | |||
.eq(FlightData::getInspectionId, inspection.getId()) | |||
.eq(FlightData::getTenantId, inspection.getTenantId()) | |||
.eq(FlightData::getMark, MarkEnum.VALID.getCode())); | |||
if (flightDataCount > 0) { | |||
int index = (int) Math.ceil((double) flightDataCount / 2); | |||
FlightData flightData = flightDataMapper.selectOne(new LambdaQueryWrapper<FlightData>() | |||
.eq(FlightData::getInspectionId, inspection.getId()) | |||
.eq(FlightData::getTenantId, inspection.getTenantId()) | |||
.eq(FlightData::getMark, MarkEnum.VALID.getCode()) | |||
.orderByDesc(FlightData::getTimestamp) | |||
.last("limit " + index + ",1")); | |||
if (ObjectUtil.isNotNull(flightData)) { | |||
inspectionUpdate.setFlyHeight(flightData.getUltrasonic()); | |||
} | |||
} | |||
} catch (Exception e) { | |||
inspectionUpdate.setWeather(""); | |||
log.info("获取天气信息失败,请重试"); | |||
} | |||
} | |||
inspectionMapper.updateById(inspectionUpdate); | |||
} else { | |||
throw new ServiceException(ServiceExceptionEnum.TASK_NOT_STATUS); | |||
} | |||
request.setTemplateInstReqList(dtos); | |||
//填充配置地址 | |||
buildconfigUrlDtos(configUrlDtos, type, templateInstConfigList); | |||
request.setTemplateInstConfigList(configUrlDtos); | |||
//此集合中的模板id都一样直接填充 | |||
request.setTemplateInstId(templateInstReqList.get(0).getTemplateInstId()); | |||
return request; | |||
return JsonResult.success(OperationEnum.OPERATION_SUCCESS); | |||
} | |||
/** | |||
* 飞手情况 | |||
* | |||
* @param inspection | |||
* @param tenant | |||
* @param dtos | |||
* @param dto | |||
* @param templateInstReqList | |||
* 被硬件调用, 存飞行轨迹 | |||
*/ | |||
private void buildDtosByPilot(Inspection inspection, Tenant | |||
tenant, List<TemplateConfigDto> dtos, TemplateConfigDto dto, List<TemplateConfigVo> templateInstReqList) { | |||
for (TemplateConfigVo configVo : templateInstReqList) { | |||
if (PilotRequestEnum.ISLIVE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), 2); | |||
} | |||
if (PilotRequestEnum.DSPSERVICEINSTID.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getDspServiceInstId()); | |||
} | |||
if (PilotRequestEnum.ENDLATITUDE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getEndLatitude()); | |||
} | |||
if (PilotRequestEnum.ENDLONGITUDE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getEndLongitude()); | |||
} | |||
if (PilotRequestEnum.PATROLLOCATION.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getPatrolLocation()); | |||
} | |||
if (PilotRequestEnum.TASKNAME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getName()); | |||
} | |||
if (PilotRequestEnum.STARTLATITUDE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getStartLatitude()); | |||
} | |||
if (PilotRequestEnum.STARTLONGITUDE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getStartLongitude()); | |||
} | |||
if (PilotRequestEnum.TASKSTARTTIME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), DateUtil.formatDateTime(inspection.getInspectionTime())); | |||
} | |||
if (PilotRequestEnum.TENANTUSERNAME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), tenant.getUsername()); | |||
} | |||
if (PilotRequestEnum.TENANTNAME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), tenant.getName()); | |||
} | |||
if (PilotRequestEnum.TASKCODE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getCode()); | |||
} | |||
if (PilotRequestEnum.SPONSORNAME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CurrentUserUtil.getUserInfo().getRealname()); | |||
@Override | |||
public JsonResult track(InspectionRequest inspectionRequest) { | |||
Inspection inspection = inspectionMapper.selectById(inspectionRequest.getRequestId()); | |||
if (ObjectUtil.isEmpty(inspection)) { | |||
throw new ServiceException(ServiceExceptionEnum.TASK_DOES_NOT_EXIST); | |||
} | |||
FlightData flightData = new FlightData(); | |||
BeanUtils.copyProperties(inspectionRequest, flightData); | |||
flightData.setTenantId(inspection.getTenantId()); | |||
flightData.setInspectionId(inspection.getId()); | |||
flightData.setAltitude(null); | |||
//机场传过来的高度是相对高度 | |||
flightData.setUltrasonic(inspectionRequest.getAltitude()); | |||
//将最新一条数据放入缓存,并设置过期时间 | |||
redisUtils.set(String.valueOf(inspection.getId()), flightData, 10); | |||
flightDataMapper.insert(flightData); | |||
return JsonResult.success(OperationEnum.OPERATION_SUCCESS); | |||
} | |||
private AirWeatherVO getWeather(String airportUrl, Integer airportId) { | |||
String url = airportUrl + "/api/airportInterface/getWeather"; | |||
String param = "airportId=" + airportId; | |||
String weatherStr = HttpUtils.sendGet(url, param); | |||
JsonResult jsonResult; | |||
try { | |||
jsonResult = JacksonUtil.json2pojo(weatherStr, JsonResult.class); | |||
if (ObjectUtil.isEmpty(jsonResult) || Objects.requireNonNull(jsonResult).getCode() != 0) { | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试"); | |||
} | |||
if (PilotRequestEnum.PLATFORMCODE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), SystemConstant.PLATFORM_CODE); | |||
if (ObjectUtil.isEmpty(jsonResult.getData())) { | |||
return new AirWeatherVO(); | |||
} | |||
if (PilotRequestEnum.SPONSORPHONE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), StringUtils.isEmpty(CurrentUserUtil.getUserInfo().getMobile()) ? "" : CurrentUserUtil.getUserInfo().getMobile()); | |||
return JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()), AirWeatherVO.class); | |||
} catch (Exception e) { | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试"); | |||
} | |||
} | |||
private OperationEnum stopAI(String msgId, String inspectionId) { | |||
//任务调用完成之后,调用发送通道,请求DSP关闭请求 | |||
//调用DSP接口 | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("requestId", msgId); | |||
JSONObject responseJson = new JSONObject(); | |||
Inspection inspectionUpdate = new Inspection(); | |||
inspectionUpdate.setId(inspectionId); | |||
try { | |||
responseJson = dspService.serviceStopApplication(jsonObject); | |||
if (responseJson.getIntValue("code") == 0) { | |||
if (responseJson.containsKey("data") && ObjectUtil.isNotEmpty(responseJson.get("data"))) { | |||
String requestId = responseJson.getJSONObject("data").getString("requestId"); | |||
log.info("dsp实时调用响应requestId:{}", requestId); | |||
} else { | |||
log.info("dsp实时调用响应:{}", responseJson); | |||
} | |||
return OperationEnum.OPERATION_SUCCESS; | |||
} else { | |||
log.error("dsp实时调用失败:{}", responseJson); | |||
inspectionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.FAILED.getCode()); | |||
} | |||
dtos.add(dto); | |||
inspectionMapper.updateById(inspectionUpdate); | |||
} catch (Exception e) { | |||
log.error("dsp实时调用失败:{}", responseJson); | |||
inspectionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.FAILED.getCode()); | |||
inspectionMapper.updateById(inspectionUpdate); | |||
} | |||
return OperationEnum.OPERATION_SUCCESS; | |||
} | |||
private JSONObject startAI(MissionStatusRequest missionStatusRequest) { | |||
//调用DSP接口 | |||
JSONObject request = new JSONObject(); | |||
JSONArray configList = new JSONArray(); | |||
JSONObject instConfigMode = new JSONObject(); | |||
instConfigMode.put("ename", "service_mode"); | |||
instConfigMode.put("evalue", "1"); | |||
configList.add(instConfigMode); | |||
JSONObject instConfigUrl = new JSONObject(); | |||
instConfigUrl.put("ename", "callback_url"); | |||
instConfigUrl.put("evalue", dspCallbackUrl); | |||
configList.add(instConfigUrl); | |||
request.put("serviceInstConfigList", configList); | |||
JSONArray reqList = new JSONArray(); | |||
JSONObject instReqUrlPush = new JSONObject(); | |||
instReqUrlPush.put("ename", "push_url"); | |||
instReqUrlPush.put("evalue", missionStatusRequest.getPushUrl()); | |||
reqList.add(instReqUrlPush); | |||
JSONObject instReqUrlPull = new JSONObject(); | |||
instReqUrlPull.put("ename", "pull_url"); | |||
instReqUrlPull.put("evalue", missionStatusRequest.getPullUrl()); | |||
reqList.add(instReqUrlPull); | |||
request.put("serviceInstReqList", reqList); | |||
JSONObject responseJson = dspService.serviceInstApplication(request); | |||
if (responseJson.getIntValue("code") == 0) { | |||
String requestId = responseJson.getJSONObject("data").getString("requestId"); | |||
log.info("dsp实时调用响应requestId:{}", requestId); | |||
} else { | |||
log.error("dsp实时调用失败:{}", responseJson); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "任务失败!"); | |||
} | |||
return responseJson; | |||
} | |||
@Override | |||
public JsonResult updateExecuteTaskStatus(ExecuteTaskStatusRequest executeTaskStatusRequest) { | |||
JsonResult result = this.check(executeTaskStatusRequest); | |||
if (0 != result.getCode()) { | |||
log.info("被硬件调用,执行任务后,回调执行状态业务:校验失败:{}", result.getMsg()); | |||
return JsonResult.error(OperationEnum.OPERATION_ERROR); | |||
} | |||
Inspection inspection = (Inspection) result.getData(); | |||
if (!"0".equals(executeTaskStatusRequest.getCode())) { | |||
log.info("被硬件调用,执行任务后,回调执行状态业务, 机场接口返回结果:失败:{}", executeTaskStatusRequest.getMsg()); | |||
inspection.setStatus(TaskStatusEnum.FAIL.getCode()); | |||
this.updateInspection(null, inspection); | |||
} else { | |||
inspection.setStatus(TaskStatusEnum.INFLIGHT.getCode()); | |||
this.updateInspection(null, inspection); | |||
} | |||
log.info("被硬件调用,任务执行后,回调执行状态业务成功"); | |||
return JsonResult.success(OperationEnum.OPERATION_SUCCESS); | |||
} | |||
/** | |||
* 机场 | |||
* 检查参数 | |||
* | |||
* @param executeTaskStatusRequest | |||
* @return | |||
*/ | |||
private JsonResult check(ExecuteTaskStatusRequest executeTaskStatusRequest) { | |||
//查询出对应的巡检任务 | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode()) | |||
.eq(Inspection::getId, executeTaskStatusRequest.getRequestId())); | |||
if (ObjectUtil.isEmpty(inspection)) { | |||
log.info("任务不存在, inspectionId:{}", executeTaskStatusRequest.getRequestId()); | |||
return JsonResult.error(500, "任务不存在" + executeTaskStatusRequest.getRequestId()); | |||
} | |||
return JsonResult.success(inspection); | |||
} | |||
/** | |||
* 修改任务执行时数据 | |||
* | |||
* @param userId | |||
* @param inspection | |||
* @param tenant | |||
* @param dtos | |||
* @param dto | |||
* @param templateInstReqList | |||
*/ | |||
private void buildDtosByAirport(Inspection inspection, Tenant | |||
tenant, List<TemplateConfigDto> dtos, TemplateConfigDto dto, List<TemplateConfigVo> templateInstReqList) { | |||
for (TemplateConfigVo configVo : templateInstReqList) { | |||
if (AirportRequestEnum.AIRPORTNAME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), StringUtils.isEmpty(inspection.getAirportName()) ? "" : inspection.getAirportName()); | |||
} | |||
if (AirportRequestEnum.AIRPORTID.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getAirportId()); | |||
} | |||
if (AirportRequestEnum.INSPECTIONLINENAME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), StringUtils.isEmpty(inspection.getInspectionLineName()) ? "" : inspection.getInspectionLineName()); | |||
} | |||
if (AirportRequestEnum.TASKSTARTTIME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), DateUtil.formatDateTime(inspection.getInspectionTime())); | |||
} | |||
if (AirportRequestEnum.TENANTCODE.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), tenant.getCode()); | |||
} | |||
if (AirportRequestEnum.DSPSERVICEINSTID.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getDspServiceInstId()); | |||
private void updateInspection(String userId, Inspection inspection) { | |||
inspection.setStatus(inspection.getStatus()); | |||
inspection.setUpdateUser(userId); | |||
inspection.setUpdateTime(DateUtils.now()); | |||
inspection.setExecutionStartTime(DateUtils.now()); | |||
inspectionMapper.updateById(inspection); | |||
} | |||
@Override | |||
@Transactional(rollbackFor = Exception.class) | |||
public JsonResult uploadFlightUrl(UploadFlightUrlRequest request) { | |||
if (StringUtils.isEmpty(request.getVideoUrl()) || StringUtils.isEmpty(request.getSrtUrl()) | |||
|| StringUtils.isEmpty(request.getTaskCode())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getCode, request.getTaskCode()) | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode())); | |||
Optional.ofNullable(inspection).orElseThrow(() -> new ServiceException(ServiceExceptionEnum.TASK_DOES_NOT_EXIST)); | |||
//修改用户直播完也可以进行分析 | |||
if (1 == inspection.getIsLive() && inspection.getAnalyseStatus() != 1) { | |||
inspection.setAnalyseStatus(1); | |||
inspectionMapper.updateById(inspection); | |||
} | |||
if (TaskStatusEnum.COMPLETE.getCode() != inspection.getStatus()) { | |||
throw new ServiceException(ServiceExceptionEnum.TASK_NOT_OPERATION); | |||
} | |||
// 如果任务处于待分析中,响应前端,任务待分析中,不能上传视频 | |||
if (AiAnalyseStatusEnum.WAITING.getCode() == inspection.getAnalyseStatus() | |||
|| AiAnalyseStatusEnum.RUNNING.getCode() == inspection.getAnalyseStatus()) { | |||
throw new ServiceException(ServiceExceptionEnum.VIDEO_ANALYSIS_IN_PROGRESS); | |||
} | |||
if (AiAnalyseStatusEnum.SUCCESS.getCode() == inspection.getAnalyseStatus() | |||
|| AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode() == inspection.getAnalyseStatus()) { | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "视频分析已完成"); | |||
} | |||
Inspection thInspection = new Inspection(); | |||
thInspection.setId(inspection.getId()); | |||
thInspection.setAnalyseStatus(AiAnalyseStatusEnum.WAITING.getCode()); | |||
thInspection.setAiVideoUrl(""); | |||
thInspection.setIsLive(AiAnalyseTypeEnum.OFFLINE.getCode()); | |||
thInspection.setProgressbar(0.0000D); | |||
thInspection.setHeartbeatTime(System.currentTimeMillis()); | |||
thInspection.setTenantId(inspection.getTenantId()); | |||
// 如果任务处于分析完成,响应前端,任务已完成,不能上传视频 | |||
updateSrtUrl(request.getSrtUrl(), inspection.getId(), request.getType(), inspection.getTenantId()); | |||
// 上传离线视频,更新任务状态为分析中 | |||
thInspection.setSrtName(request.getSrtUrl().substring(request.getSrtUrl().lastIndexOf("/") + 1)); | |||
thInspection.setVideoUrl(StringUtils.removeHost(request.getVideoUrl(), CommonConfig.videoURL)); | |||
inspectionMapper.updateByPrimaryKeySelective(thInspection); | |||
// 每次上传或重试,清除上次的数据 | |||
InspectionFile thInspectionFile = new InspectionFile(); | |||
thInspectionFile.setInspectionId(inspection.getId()); | |||
thInspectionFile.setTenantId(inspection.getTenantId()); | |||
int num = inspectionFileMapper.selectCount(thInspectionFile); | |||
if (num > 0) { | |||
inspectionFileMapper.deleteByInspectionId(inspection.getId(), null); | |||
} | |||
//调用DSP接口 | |||
JSONObject requestDsp = new JSONObject(); | |||
JSONArray configList = new JSONArray(); | |||
JSONObject instConfigMode = new JSONObject(); | |||
instConfigMode.put("ename", "service_mode"); | |||
instConfigMode.put("evalue", "2"); | |||
configList.add(instConfigMode); | |||
JSONObject instConfigUrl = new JSONObject(); | |||
instConfigUrl.put("ename", "callback_url"); | |||
instConfigUrl.put("evalue", dspCallbackUrl); | |||
configList.add(instConfigUrl); | |||
requestDsp.put("serviceInstConfigList", configList); | |||
JSONArray reqList = new JSONArray(); | |||
JSONObject instReqUrl = new JSONObject(); | |||
instReqUrl.put("ename", "original_url"); | |||
instReqUrl.put("evalue", request.getVideoUrl()); | |||
reqList.add(instReqUrl); | |||
requestDsp.put("serviceInstReqList", reqList); | |||
JSONObject responseJson = dspService.serviceInstApplication(requestDsp); | |||
if (responseJson.getIntValue("code") == 0) { | |||
String requestId = responseJson.getJSONObject("data").getString("requestId"); | |||
log.info("dsp离线调用响应requestId:", requestId); | |||
businessService.insertBusinessUploadUrl(requestId, inspection.getId()); | |||
} else if (responseJson.getIntValue("code") == HttpStatusEnum.NO_RESOURCES.getCode()) { | |||
log.warn("dsp离线调用响应失败,暂时无资源可用"); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), HttpStatusEnum.NO_RESOURCES.getDescription()); | |||
} else { | |||
log.error("dsp离线调用失败:", responseJson); | |||
} | |||
return JsonResult.success(OperationEnum.OPERATION_SUCCESS); | |||
} | |||
private void updateSrtUrl(String fileUrl, String inspectionId, Integer type, String tenantId) { | |||
List<FlightData> flightDataList = new ArrayList<>(); | |||
try { | |||
String txtContent = FileUtils.txtToString(fileUrl); | |||
//type为1时,机型为M300 | |||
if (type == 1) { | |||
//解析srt文件经纬度和时间戳 | |||
flightDataList = SrtDataUtil.getByM300(txtContent, inspectionId, tenantId); | |||
} else if(type == 2){ | |||
flightDataList = SrtDataUtil.getByYu2(txtContent, inspectionId, tenantId); | |||
} else if(type == 3){ | |||
flightDataList = SrtDataUtil.getByYu3e(txtContent, inspectionId, tenantId); | |||
} else { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
if (AirportRequestEnum.TASKNAME.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getName()); | |||
if (ObjectUtils.isEmpty(flightDataList)) { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_IS_ERROR); | |||
} | |||
if (AirportRequestEnum.INSPECTIONLINEID.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), inspection.getInspectionLine()); | |||
flightDataMapper.delete(new LambdaQueryWrapper<FlightData>() | |||
.eq(FlightData::getInspectionId, inspectionId) | |||
.eq(FlightData::getTenantId, tenantId) | |||
.eq(FlightData::getMark, MarkEnum.VALID.getCode())); | |||
List<List> lists = splitList(flightDataList, 100); | |||
//线程池使用多线程插入数据 | |||
for (List list : lists) { | |||
asyncService.flightDataSaveBatch(list); | |||
} | |||
dtos.add(dto); | |||
} catch (Exception e) { | |||
log.error("srt文件上传异常", e); | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_IS_ERROR); | |||
} | |||
} | |||
} | |||
/** | |||
* 配置模板配置相关url-人工 | |||
* 切分list | |||
* | |||
* @param configUrlDtos | |||
* @param type 1 飞手 0机场 | |||
* @param templateInstConfigList | |||
* @param sourceList | |||
* @param groupSize 每组定长 | |||
* @return | |||
*/ | |||
private void buildconfigUrlDtos(List<TemplateConfigDto> configUrlDtos, Integer | |||
type, List<TemplateConfigVo> templateInstConfigList) { | |||
TemplateConfigDto dto = null; | |||
if (1 == type) { | |||
for (TemplateConfigVo configVo : templateInstConfigList) { | |||
if (PilotRequestEnum.UPLOADFLIGHTDATA_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.PILOT_UPLOAD_URL); | |||
} | |||
if (PilotRequestEnum.TASKSTATUS_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.PILOT_UPDATE_STATUS); | |||
} | |||
if (PilotRequestEnum.CLOUDBOXTRACK_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.FLIGHTDATA_CALLBACK); | |||
} | |||
if (PilotRequestEnum.ALGQUESTION_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.DSP_CALLBACK); | |||
} | |||
if (PilotRequestEnum.DSPSERVICEINSTID.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.DSP_VIDEO_CALLBACK); | |||
} | |||
configUrlDtos.add(dto); | |||
} | |||
} | |||
if (0 == type) { | |||
//机场填充配置回调url | |||
for (TemplateConfigVo configVo : templateInstConfigList) { | |||
if (AirportRequestEnum.DSP_ALGSTATUS_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.DSP_VIDEO_CALLBACK); | |||
} | |||
if (AirportRequestEnum.DSP_ALGQUESTION_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.DSP_CALLBACK); | |||
} | |||
if (AirportRequestEnum.AIRPORT_EXECUTETASKSTATUS_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.AIRPORT_EXECUTETASKSTATUS_CALLBACK); | |||
} | |||
if (AirportRequestEnum.AIRPORT_TRACK_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.AIRPORT_TRACK_CALLBACK); | |||
} | |||
if (AirportRequestEnum.AIRPORT_TASKSTATUS_CALLBACK.getDescription().equals(configVo.getCname())) { | |||
dto = new TemplateConfigDto(configVo.getEname(), CommonConfig.alertUrl + DspInspectionCallback.DSP_ALGSTATUS_CALLBACK); | |||
} | |||
configUrlDtos.add(dto); | |||
} | |||
public static List<List> splitList(List sourceList, int groupSize) { | |||
int length = sourceList.size(); | |||
// 计算可以分成多少组 | |||
int num = (length + groupSize - 1) / groupSize; | |||
List<List> newList = new ArrayList<>(num); | |||
for (int i = 0; i < num; i++) { | |||
// 开始位置 | |||
int fromIndex = i * groupSize; | |||
// 结束位置 | |||
int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; | |||
newList.add(sourceList.subList(fromIndex, toIndex)); | |||
} | |||
return newList; | |||
} | |||
} | |||
@@ -0,0 +1,19 @@ | |||
package com.tuoheng.admin.utils; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.vo.AirWeatherVO; | |||
import java.math.BigDecimal; | |||
public class AirWeatherUtil { | |||
public static String getWeather(AirWeatherVO airWeather) { | |||
if(ObjectUtil.isEmpty(airWeather) ||ObjectUtil.isEmpty(airWeather.getWth())){ | |||
return ""; | |||
} | |||
return "气温:" + new BigDecimal(airWeather.getWth().getParm().getTmp()).divide(new BigDecimal(10))+"℃" | |||
+ ";湿度:" + new BigDecimal(airWeather.getWth().getParm().getHum()).divide(new BigDecimal(10))+"RH" | |||
+ ";风速:" + new BigDecimal(airWeather.getWth().getParm().getWspd()).divide(new BigDecimal(10))+"M/S" | |||
+ ";风向:" + airWeather.getWth().getParm().getWdir() + "°"; | |||
} | |||
} |
@@ -0,0 +1,233 @@ | |||
package com.tuoheng.admin.utils; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import org.springframework.mock.web.MockMultipartFile; | |||
import org.springframework.web.multipart.MultipartFile; | |||
import javax.servlet.http.HttpServletRequest; | |||
import java.io.*; | |||
import java.net.HttpURLConnection; | |||
import java.net.URL; | |||
import java.net.URLConnection; | |||
import java.net.URLEncoder; | |||
/** | |||
* 文件处理工具类 | |||
*/ | |||
public class FileUtils { | |||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; | |||
/** | |||
* 验证文件名是否含有特殊字符 | |||
* | |||
* @param filename | |||
* @return | |||
*/ | |||
public static boolean isValidFilename(String filename) { | |||
return filename.matches(FILENAME_PATTERN); | |||
} | |||
/** | |||
* 下载文件并重新编码 | |||
* | |||
* @param request 网络请求 | |||
* @param fileName 文件名 | |||
* @return | |||
* @throws UnsupportedEncodingException | |||
*/ | |||
public static String setFileDownloadHeader(HttpServletRequest request, String fileName) | |||
throws UnsupportedEncodingException { | |||
final String agent = request.getHeader("USER-AGENT"); | |||
String filename = fileName; | |||
if (agent.contains("MSIE")) { | |||
// IE浏览器 | |||
filename = URLEncoder.encode(filename, "utf-8"); | |||
filename = filename.replace("+", " "); | |||
} else if (agent.contains("Firefox")) { | |||
// 火狐浏览器 | |||
filename = new String(fileName.getBytes(), "ISO8859-1"); | |||
} else if (agent.contains("Chrome")) { | |||
// google浏览器 | |||
filename = URLEncoder.encode(filename, "utf-8"); | |||
} else { | |||
// 其它浏览器 | |||
filename = URLEncoder.encode(filename, "utf-8"); | |||
} | |||
return filename; | |||
} | |||
/** | |||
* 输出指定文件的Byte数组 | |||
* | |||
* @param filePath | |||
* @param os | |||
* @throws IOException | |||
*/ | |||
public static void writeBytes(String filePath, OutputStream os) throws IOException { | |||
FileInputStream fis = null; | |||
try { | |||
File file = new File(filePath); | |||
if (!file.exists()) { | |||
throw new FileNotFoundException(filePath); | |||
} | |||
fis = new FileInputStream(file); | |||
byte[] b = new byte[1024]; | |||
int length; | |||
while ((length = fis.read(b)) > 0) { | |||
os.write(b, 0, length); | |||
} | |||
} catch (IOException e) { | |||
throw e; | |||
} finally { | |||
if (os != null) { | |||
try { | |||
os.close(); | |||
} catch (IOException e1) { | |||
e1.printStackTrace(); | |||
} | |||
} | |||
if (fis != null) { | |||
try { | |||
fis.close(); | |||
} catch (IOException e1) { | |||
e1.printStackTrace(); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* 删除文件 | |||
* | |||
* @param filePath 文件路径 | |||
* @return | |||
*/ | |||
public static boolean deleteFile(String filePath) { | |||
boolean flag = false; | |||
File file = new File(filePath); | |||
// 路径为文件且不为空则进行删除 | |||
if (file.isFile() && file.exists()) { | |||
file.delete(); | |||
flag = true; | |||
} | |||
return flag; | |||
} | |||
/** | |||
* MultipartFile 转 File | |||
* | |||
* @param mFile | |||
* @param filePathName | |||
*/ | |||
public static File multipartFileToFile(MultipartFile mFile, String filePathName) { | |||
File file = null; | |||
if (ObjectUtil.isNull(mFile)) { | |||
throw new RuntimeException("图片不能为空!"); | |||
} else { | |||
InputStream ins = null; | |||
try { | |||
ins = mFile.getInputStream(); | |||
file = new File(filePathName); | |||
inputStreamToFile(ins, file); | |||
ins.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
ThumbnailUtil.cenerateCompression(filePathName,filePathName,300,0.8); | |||
return file; | |||
} | |||
} | |||
/** | |||
* File 转 MultipartFile | |||
* | |||
* @param file | |||
* @throws Exception | |||
*/ | |||
public static void fileToMultipartFile(File file) throws Exception { | |||
FileInputStream fileInput = new FileInputStream(file); | |||
MultipartFile toMultipartFile = new MockMultipartFile("file", file.getName(), "text/plain", getBytesByFile(fileInput)); | |||
toMultipartFile.getInputStream(); | |||
} | |||
public static String txtToString(String fileUrl) throws Exception { | |||
StringBuilder sb = new StringBuilder(); | |||
int HttpResult; // 服务器返回的状态 | |||
try { | |||
URL url =new URL(fileUrl); // 创建URL | |||
URLConnection urlconn = url.openConnection(); // 试图连接并取得返回状态码 | |||
urlconn.connect(); | |||
HttpURLConnection httpconn =(HttpURLConnection)urlconn; | |||
HttpResult = httpconn.getResponseCode(); | |||
if(HttpResult != HttpURLConnection.HTTP_OK) { | |||
throw new RuntimeException("无法连接"); | |||
} else { | |||
InputStreamReader isReader = new InputStreamReader(urlconn.getInputStream(),"UTF-8"); | |||
BufferedReader reader = new BufferedReader(isReader); | |||
String line; // 用来保存每行读取的内容 | |||
line = reader.readLine(); // 读取第一行 | |||
while (line != null) { // 如果 line 为空说明读完了 | |||
sb.append(line); // 将读到的内容添加到 buffer 中 | |||
sb.append(" "); // 添加换行符 | |||
line = reader.readLine(); // 读取下一行 | |||
} | |||
} | |||
} | |||
catch (FileNotFoundException e) { | |||
e.printStackTrace(); | |||
} | |||
catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
return sb.toString(); | |||
} | |||
public static void inputStreamToFile(InputStream ins, File file) { | |||
try { | |||
OutputStream os = new FileOutputStream(file); | |||
int bytesRead = 0; | |||
byte[] buffer = new byte[8192]; | |||
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { | |||
os.write(buffer, 0, bytesRead); | |||
} | |||
os.close(); | |||
ins.close(); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
/** | |||
* 将 File 转换成 Byte数组 | |||
* | |||
* @param fis | |||
* @return | |||
*/ | |||
public static byte[] getBytesByFile(FileInputStream fis) { | |||
try { | |||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |||
byte[] b = new byte[1024 * 1024 * 10]; | |||
int n; | |||
while ((n = fis.read(b)) != -1) { | |||
bos.write(b, 0, n); | |||
} | |||
fis.close(); | |||
byte[] data = bos.toByteArray(); | |||
bos.close(); | |||
return data; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,610 @@ | |||
package com.tuoheng.admin.utils; | |||
import org.springframework.data.redis.core.RedisTemplate; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Propagation; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import org.springframework.util.CollectionUtils; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.concurrent.TimeUnit; | |||
@Component | |||
public class RedisUtils { | |||
private RedisTemplate<String, Object> redisTemplate; | |||
public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) { | |||
this.redisTemplate = redisTemplate; | |||
} | |||
// =============================common============================ | |||
/** | |||
* 普通缓存获取 | |||
* | |||
* @param | |||
* @return 值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Set<String> keys(String pattern) { | |||
return redisTemplate.keys(pattern); | |||
} | |||
/** | |||
* 指定缓存失效时间 | |||
* | |||
* @param key 键 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean expire(String key, long time) { | |||
try { | |||
if (time > 0) { | |||
redisTemplate.expire(key, time, TimeUnit.SECONDS); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 根据key 获取过期时间 | |||
* | |||
* @param key 键 不能为null | |||
* @return 时间(秒) 返回0代表为永久有效 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public long getExpire(String key) { | |||
return redisTemplate.getExpire(key, TimeUnit.SECONDS); | |||
} | |||
/** | |||
* 判断key是否存在 | |||
* | |||
* @param key 键 | |||
* @return true 存在 false不存在 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public boolean hasKey(String key) { | |||
try { | |||
return redisTemplate.hasKey(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 删除缓存 | |||
* | |||
* @param key 可以传一个值 或多个 | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public void del(String... key) { | |||
if (key != null && key.length > 0) { | |||
if (key.length == 1) { | |||
redisTemplate.delete(key[0]); | |||
} else { | |||
redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key)); | |||
} | |||
} | |||
} | |||
// ============================String============================= | |||
/** | |||
* 普通缓存获取 | |||
* | |||
* @param key 键 | |||
* @return 值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Object get(String key) { | |||
return key == null ? null : redisTemplate.opsForValue().get(key); | |||
} | |||
/** | |||
* 普通缓存放入 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @return true成功 false失败 | |||
*/ | |||
public boolean set(String key, Object value) { | |||
try { | |||
redisTemplate.opsForValue().set(key, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 普通缓存放入并设置时间 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 | |||
* @return true成功 false 失败 | |||
*/ | |||
public boolean set(String key, Object value, long time) { | |||
try { | |||
if (time > 0) { | |||
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); | |||
} else { | |||
set(key, value); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 递增 | |||
* | |||
* @param key 键 | |||
* @param delta 要增加几(大于0) | |||
* @return | |||
*/ | |||
public long incr(String key, long delta) { | |||
if (delta < 0) { | |||
throw new RuntimeException("递增因子必须大于0"); | |||
} | |||
return redisTemplate.opsForValue().increment(key, delta); | |||
} | |||
/** | |||
* 递减 | |||
* | |||
* @param key 键 | |||
* @param delta 要减少几(小于0) | |||
* @return | |||
*/ | |||
public long decr(String key, long delta) { | |||
if (delta < 0) { | |||
throw new RuntimeException("递减因子必须大于0"); | |||
} | |||
return redisTemplate.opsForValue().increment(key, -delta); | |||
} | |||
// ================================Map================================= | |||
/** | |||
* HashGet | |||
* | |||
* @param key 键 不能为null | |||
* @param item 项 不能为null | |||
* @return 值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Object hget(String key, String item) { | |||
return redisTemplate.opsForHash().get(key, item); | |||
} | |||
/** | |||
* 获取hashKey对应的所有键值 | |||
* | |||
* @param key 键 | |||
* @return 对应的多个键值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Map<Object, Object> hmget(String key) { | |||
return redisTemplate.opsForHash().entries(key); | |||
} | |||
/** | |||
* HashSet | |||
* | |||
* @param key 键 | |||
* @param map 对应多个键值 | |||
* @return true 成功 false 失败 | |||
*/ | |||
public boolean hmset(String key, Map<String, Object> map) { | |||
try { | |||
redisTemplate.opsForHash().putAll(key, map); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* HashSet 并设置时间 | |||
* | |||
* @param key 键 | |||
* @param map 对应多个键值 | |||
* @param time 时间(秒) | |||
* @return true成功 false失败 | |||
*/ | |||
public boolean hmset(String key, Map<String, Object> map, long time) { | |||
try { | |||
redisTemplate.opsForHash().putAll(key, map); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 向一张hash表中放入数据,如果不存在将创建 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param value 值 | |||
* @return true 成功 false失败 | |||
*/ | |||
public boolean hset(String key, String item, Object value) { | |||
try { | |||
redisTemplate.opsForHash().put(key, item, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 向一张hash表中放入数据,如果不存在将创建 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param value 值 | |||
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 | |||
* @return true 成功 false失败 | |||
*/ | |||
public boolean hset(String key, String item, Object value, long time) { | |||
try { | |||
redisTemplate.opsForHash().put(key, item, value); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 删除hash表中的值 | |||
* | |||
* @param key 键 不能为null | |||
* @param item 项 可以使多个 不能为null | |||
*/ | |||
public void hdel(String key, Object... item) { | |||
redisTemplate.opsForHash().delete(key, item); | |||
} | |||
/** | |||
* 判断hash表中是否有该项的值 | |||
* | |||
* @param key 键 不能为null | |||
* @param item 项 不能为null | |||
* @return true 存在 false不存在 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public boolean hHasKey(String key, String item) { | |||
return redisTemplate.opsForHash().hasKey(key, item); | |||
} | |||
/** | |||
* hash递增 如果不存在,就会创建一个 并把新增后的值返回 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param by 要增加几(大于0) | |||
* @return | |||
*/ | |||
public double hincr(String key, String item, double by) { | |||
return redisTemplate.opsForHash().increment(key, item, by); | |||
} | |||
/** | |||
* hash递减 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param by 要减少记(小于0) | |||
* @return | |||
*/ | |||
public double hdecr(String key, String item, double by) { | |||
return redisTemplate.opsForHash().increment(key, item, -by); | |||
} | |||
// ============================set============================= | |||
/** | |||
* 根据key获取Set中的所有值 | |||
* | |||
* @param key 键 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Set<Object> sGet(String key) { | |||
try { | |||
return redisTemplate.opsForSet().members(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 根据value从一个set中查询,是否存在 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @return true 存在 false不存在 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public boolean sHasKey(String key, Object value) { | |||
try { | |||
return redisTemplate.opsForSet().isMember(key, value); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将数据放入set缓存 | |||
* | |||
* @param key 键 | |||
* @param values 值 可以是多个 | |||
* @return 成功个数 | |||
*/ | |||
public long sSet(String key, Object... values) { | |||
try { | |||
return redisTemplate.opsForSet().add(key, values); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 将set数据放入缓存 | |||
* | |||
* @param key 键 | |||
* @param time 时间(秒) | |||
* @param values 值 可以是多个 | |||
* @return 成功个数 | |||
*/ | |||
public long sSetAndTime(String key, long time, Object... values) { | |||
try { | |||
Long count = redisTemplate.opsForSet().add(key, values); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return count; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 获取set缓存的长度 | |||
* | |||
* @param key 键 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public long sGetSetSize(String key) { | |||
try { | |||
return redisTemplate.opsForSet().size(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 移除值为value的 | |||
* | |||
* @param key 键 | |||
* @param values 值 可以是多个 | |||
* @return 移除的个数 | |||
*/ | |||
public long setRemove(String key, Object... values) { | |||
try { | |||
Long count = redisTemplate.opsForSet().remove(key, values); | |||
return count; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
// ===============================list================================= | |||
/** | |||
* 获取list缓存的内容 | |||
* | |||
* @param key 键 | |||
* @param start 开始 | |||
* @param end 结束 0 到 -1代表所有值 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public List<Object> lGet(String key, long start, long end) { | |||
try { | |||
return redisTemplate.opsForList().range(key, start, end); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 获取list缓存的长度 | |||
* | |||
* @param key 键 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public long lGetListSize(String key) { | |||
try { | |||
return redisTemplate.opsForList().size(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 通过索引 获取list中的值 | |||
* | |||
* @param key 键 | |||
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Object lGetIndex(String key, long index) { | |||
try { | |||
return redisTemplate.opsForList().index(key, index); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, Object value) { | |||
try { | |||
redisTemplate.opsForList().rightPush(key, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, Object value, long time) { | |||
try { | |||
redisTemplate.opsForList().rightPush(key, value); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, List<Object> value) { | |||
try { | |||
redisTemplate.opsForList().rightPushAll(key, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, List<Object> value, long time) { | |||
try { | |||
redisTemplate.opsForList().rightPushAll(key, value); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 根据索引修改list中的某条数据 | |||
* | |||
* @param key 键 | |||
* @param index 索引 | |||
* @param value 值 | |||
* @return | |||
*/ | |||
public boolean lUpdateIndex(String key, long index, Object value) { | |||
try { | |||
redisTemplate.opsForList().set(key, index, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 移除N个值为value | |||
* | |||
* @param key 键 | |||
* @param count 移除多少个 | |||
* @param value 值 | |||
* @return 移除的个数 | |||
*/ | |||
public long lRemove(String key, long count, Object value) { | |||
try { | |||
Long remove = redisTemplate.opsForList().remove(key, count, value); | |||
return remove; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 按键的排序获取对应的值 | |||
* | |||
* @param keys 多个键 | |||
* @return List<Object> | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public List<Object> mget(Collection<String> keys) { | |||
return redisTemplate.opsForValue().multiGet(keys); | |||
} | |||
} |
@@ -0,0 +1,244 @@ | |||
package com.tuoheng.admin.utils; | |||
import com.tuoheng.admin.entity.FlightData; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import lombok.extern.slf4j.Slf4j; | |||
import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.regex.Matcher; | |||
import java.util.regex.Pattern; | |||
/** | |||
* SRT文件经纬度解析工具 | |||
* | |||
* @author WangHaoran | |||
* @since 2021-12-21 | |||
*/ | |||
@Slf4j | |||
public class SrtDataUtil { | |||
// public static void main(String[] args) throws Exception { | |||
// String txtContent = FileUtils.txtToString("https://ta-tech-file.oss-cn-shanghai.aliyuncs.com/DJI_0826.SRT"); | |||
// List<FlightData> byYu3e = getByYu3e(txtContent, 1,1); | |||
// System.out.println(byYu3e); | |||
// } | |||
/** | |||
* 机型为御3E拍摄的SRT文件 | |||
*/ | |||
public static List<FlightData> getByYu3e(String srtMsg, String inspectionId, String tenantId) throws Exception { | |||
List<FlightData> flightDataList = new ArrayList<>(); | |||
//将全部字符串按照每个font分割 | |||
List<String> msgList = new ArrayList<>(); | |||
Matcher msg = Pattern.compile( | |||
Pattern.quote("HOME(") | |||
+ "(.*?)" | |||
+ Pattern.quote("ISO:") | |||
).matcher(srtMsg); | |||
while(msg.find()){ | |||
String match = msg.group(1); | |||
msgList.add(match); | |||
} | |||
//解析每组数据 | |||
for (String str : msgList) { | |||
FlightData flightData = new FlightData(); | |||
flightData.setIsSrt(1); | |||
flightData.setInspectionId(inspectionId); | |||
flightData.setTenantId(tenantId); | |||
//找出时间,格式为2023.02.27 15:32:19 | |||
Matcher time = Pattern.compile(Pattern.quote(") ") | |||
+ "(.*?)" | |||
+ Pattern.quote("GPS(") | |||
).matcher(str); | |||
if(time.find()){ | |||
String match = time.group(1); | |||
//截取时间,转为时间戳 | |||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); | |||
Date date = simpleDateFormat.parse(match); | |||
String timeStamp = String.valueOf(date.getTime()); | |||
flightData.setTimestamp(timeStamp); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); | |||
} | |||
//找出经度 | |||
Matcher longitude = Pattern.compile( | |||
Pattern.quote("GPS(") | |||
+ "(.*?)" | |||
+ Pattern.quote(",") | |||
).matcher(str); | |||
if(longitude.find()){ | |||
String match = longitude.group(1); | |||
flightData.setLng(match); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); | |||
} | |||
//找出数据 格式为 GPS(120.909168,32.596070,141.100000) | |||
Matcher latitude = Pattern.compile( | |||
Pattern.quote("GPS(") | |||
+ "(.*?)" | |||
+ Pattern.quote(")") | |||
).matcher(str); | |||
if(latitude.find()){ | |||
String match = latitude.group(1); | |||
//找出纬度 | |||
String lat = match.split(",")[1]; | |||
flightData.setLat(lat); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR); | |||
} | |||
flightDataList.add(flightData); | |||
} | |||
return flightDataList; | |||
} | |||
/** | |||
* 机型为御二拍摄的SRT文件 | |||
*/ | |||
public static List<FlightData> getByYu2(String srtMsg, String inspectionId, String tenantId) throws Exception { | |||
List<FlightData> flightDataList = new ArrayList<>(); | |||
//将全部字符串按照每个font分割 | |||
List<String> msgList = new ArrayList<>(); | |||
Matcher msg = Pattern.compile( | |||
Pattern.quote("<font") | |||
+ "(.*?)" | |||
+ Pattern.quote("</font>") | |||
).matcher(srtMsg); | |||
while(msg.find()){ | |||
String match = msg.group(1); | |||
msgList.add(match); | |||
} | |||
//解析每组数据 | |||
for (String str : msgList) { | |||
FlightData flightData = new FlightData(); | |||
flightData.setIsSrt(1); | |||
flightData.setInspectionId(inspectionId); | |||
flightData.setTenantId(tenantId); | |||
//找出时间,格式为2021-08-24 09:33:15,848,518 | |||
Matcher time = Pattern.compile(Pattern.quote("ms") | |||
+ "(.*?)" | |||
+ Pattern.quote("[iso :") | |||
).matcher(str); | |||
if(time.find()){ | |||
String match = time.group(1); | |||
//截取时间到毫秒,转为时间戳 | |||
int endIndex = match.lastIndexOf(","); | |||
String timeSubStr = match.substring(0, endIndex); | |||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); | |||
Date date = simpleDateFormat.parse(timeSubStr); | |||
String timeStamp = String.valueOf(date.getTime()); | |||
flightData.setTimestamp(timeStamp); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); | |||
} | |||
//找出经度 | |||
Matcher longitude = Pattern.compile( | |||
Pattern.quote("[longtitude : ") | |||
+ "(.*?)" | |||
+ Pattern.quote("] [altitude:") | |||
).matcher(str); | |||
if(longitude.find()){ | |||
String match = longitude.group(1); | |||
flightData.setLng(match); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); | |||
} | |||
//找出纬度 | |||
Matcher latitude = Pattern.compile( | |||
Pattern.quote("[latitude : ") | |||
+ "(.*?)" | |||
+ Pattern.quote("] [longtitude") | |||
).matcher(str); | |||
if(latitude.find()){ | |||
String match = latitude.group(1); | |||
flightData.setLat(match); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR); | |||
} | |||
flightDataList.add(flightData); | |||
} | |||
return flightDataList; | |||
} | |||
/** | |||
* 机型为M300拍摄的SRT文件 | |||
*/ | |||
public static List<FlightData> getByM300(String srtMsg, String inspectionId, String tenantId) throws Exception { | |||
List<FlightData> flightDataList = new ArrayList<>(); | |||
//将全部字符串按照每个font分割 | |||
List<String> msgList = new ArrayList<>(); | |||
Matcher msg = Pattern.compile( | |||
Pattern.quote("<font") | |||
+ "(.*?)" | |||
+ Pattern.quote("</font>") | |||
).matcher(srtMsg); | |||
while(msg.find()){ | |||
String match = msg.group(1); | |||
msgList.add(match); | |||
} | |||
//解析每组数据 | |||
for (String str : msgList) { | |||
FlightData flightData = new FlightData(); | |||
flightData.setIsSrt(1); | |||
flightData.setInspectionId(inspectionId); | |||
flightData.setTenantId(tenantId); | |||
//找出时间,格式为2021-12-21 09:41:40.463 | |||
Matcher time = Pattern.compile(Pattern.quote("ms") | |||
+ "(.*?)" | |||
+ Pattern.quote("[") | |||
).matcher(str); | |||
if(time.find()){ | |||
String match = time.group(1); | |||
//截取时间到毫秒,转为时间戳 | |||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |||
Date date = null; | |||
try { | |||
date = simpleDateFormat.parse(match); | |||
} catch (ParseException e) { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); | |||
} | |||
String timeStamp = String.valueOf(date.getTime()); | |||
flightData.setTimestamp(timeStamp); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR); | |||
} | |||
//找出经度 | |||
Matcher longitude = Pattern.compile( | |||
Pattern.quote("[longitude: ") | |||
+ "(.*?)" | |||
+ Pattern.quote("] [rel_alt:") | |||
).matcher(str); | |||
if(longitude.find()){ | |||
String match = longitude.group(1); | |||
flightData.setLng(match); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR); | |||
} | |||
//找出纬度 | |||
Matcher latitude = Pattern.compile( | |||
Pattern.quote("[latitude: ") | |||
+ "(.*?)" | |||
+ Pattern.quote("] [longitude: ") | |||
).matcher(str); | |||
if(latitude.find()){ | |||
String match = latitude.group(1); | |||
flightData.setLat(match); | |||
}else { | |||
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR); | |||
} | |||
flightDataList.add(flightData); | |||
} | |||
return flightDataList; | |||
} | |||
} |
@@ -0,0 +1,112 @@ | |||
package com.tuoheng.admin.utils; | |||
import net.coobird.thumbnailator.Thumbnails; | |||
import javax.imageio.ImageIO; | |||
import java.awt.image.BufferedImage; | |||
import java.io.*; | |||
import java.math.BigDecimal; | |||
public class ThumbnailUtil { | |||
/** | |||
* 生成压缩图 | |||
* @param url 原图地址 | |||
* @param desFileSize 指定图片大小,单位kb | |||
* @param accuracy 精度,递归压缩的比率,建议小于0.9 | |||
* @return | |||
*/ | |||
public static String cenerateCompression(String url,String urlThumbnail,long desFileSize , double accuracy){ | |||
//String urlThumbnail= UploadFileConfig.uploadFolder +"Thumbnail"+ imgUrl; | |||
String root= urlThumbnail.substring(0,urlThumbnail.lastIndexOf("/")); | |||
//如果指定的文件夹不存在 则创建 | |||
File filedir=new File(root); | |||
if (!filedir.exists()) { | |||
filedir.mkdirs();//创建文件夹 | |||
} | |||
//图片文件 | |||
File fileThumbnail = new File(urlThumbnail); | |||
if (fileThumbnail.exists()&&fileThumbnail.length() <= desFileSize * 1024) { | |||
System.out.println("已存在压缩文件!"); | |||
return urlThumbnail; | |||
} | |||
//原图 | |||
File file = new File(url); | |||
if (!file.exists() || !file.isFile()) { | |||
System.out.println("文件不存在"); | |||
} | |||
try { | |||
if(!fileThumbnail.exists()) { | |||
copyFileUsingFileStreams(file, new File(urlThumbnail)); | |||
} | |||
}catch (IOException e){ | |||
e.printStackTrace(); | |||
} | |||
urlThumbnail = commpressPicForScale(url, urlThumbnail, desFileSize, accuracy); | |||
return urlThumbnail; | |||
} | |||
/** | |||
* | |||
* @param srcPath 原图片地址 | |||
* @param desPath 目标图片地址 | |||
* @param desFileSize 指定图片大小,单位kb | |||
* @param accuracy 精度,递归压缩的比率,建议小于0.9 | |||
* @return | |||
*/ | |||
public static String commpressPicForScale(String srcPath,String desPath, | |||
long desFileSize , double accuracy){ | |||
try { | |||
File srcFile = new File(srcPath); | |||
long srcFilesize = srcFile.length(); | |||
System.out.println("原图片:"+srcPath + ",大小:" + srcFilesize/1024 + "kb"); | |||
//递归压缩,直到目标文件大小小于desFileSize | |||
commpressPicCycle(desPath, desFileSize, accuracy); | |||
File desFile = new File(desPath); | |||
System.out.println("目标图片:" + desPath + ",大小" + desFile.length()/1024 + "kb"); | |||
System.out.println("图片压缩完成!"); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
return desPath; | |||
} | |||
public static void commpressPicCycle(String desPath , long desFileSize, | |||
double accuracy) throws IOException{ | |||
File imgFile = new File(desPath); | |||
long fileSize = imgFile.length(); | |||
//判断大小,如果小于desFileSizek,不压缩,如果大于等于desFileSizek,压缩 | |||
if(fileSize <= desFileSize * 1024){ | |||
return; | |||
} | |||
//计算宽高 | |||
BufferedImage bim = ImageIO.read(imgFile); | |||
int imgWidth = bim.getWidth(); | |||
int imgHeight = bim.getHeight(); | |||
int desWidth = new BigDecimal(imgWidth).multiply( | |||
new BigDecimal(accuracy)).intValue(); | |||
int desHeight = new BigDecimal(imgHeight).multiply( | |||
new BigDecimal(accuracy)).intValue(); | |||
Thumbnails.of(desPath).size(desWidth, desHeight).outputQuality(accuracy).toFile(desPath); | |||
//如果不满足要求,递归直至满足小于1M的要求 | |||
commpressPicCycle(desPath, desFileSize, accuracy); | |||
} | |||
private static void copyFileUsingFileStreams(File source, File dest) | |||
throws IOException { | |||
InputStream input = null; | |||
OutputStream output = null; | |||
try { | |||
input = new FileInputStream(source); | |||
output = new FileOutputStream(dest); | |||
byte[] buf = new byte[1024]; | |||
int bytesRead; | |||
while ((bytesRead = input.read(buf)) > 0) { | |||
output.write(buf, 0, bytesRead); | |||
} | |||
} finally { | |||
input.close(); | |||
output.close(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,87 @@ | |||
package com.tuoheng.admin.vo; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* @User qiujinyang | |||
* @Description | |||
* @Date Created by 2022/7/28 13:31 | |||
*/ | |||
@NoArgsConstructor | |||
@Data | |||
public class AirWeatherVO implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
private ACDDTO acd; | |||
private WTHDTO wth; | |||
private TAHDTO tah; | |||
@NoArgsConstructor | |||
@Data | |||
public static class ACDDTO { | |||
private ParmDTO parm; | |||
private Integer mid; | |||
private String deviceid; | |||
private Integer timestamp; | |||
@NoArgsConstructor | |||
@Data | |||
public static class ParmDTO { | |||
private Integer tmp; | |||
} | |||
} | |||
@NoArgsConstructor | |||
@Data | |||
public static class WTHDTO { | |||
private ParmDTO parm; | |||
private Integer mid; | |||
private String deviceid; | |||
private Integer timestamp; | |||
@NoArgsConstructor | |||
@Data | |||
public static class ParmDTO { | |||
private Integer hum; | |||
private Integer rainfull; | |||
private Integer noise; | |||
private Integer co2; | |||
private Integer lux; | |||
private Integer rainType; | |||
private Integer tmp; | |||
private Integer _$Pm25111;// FIXME check this code | |||
private Integer dew; | |||
private Integer hpa; | |||
private Integer wspd; | |||
private Integer pm10; | |||
private Integer wdir; | |||
} | |||
} | |||
@NoArgsConstructor | |||
@Data | |||
public static class TAHDTO { | |||
private ParmDTO parm; | |||
private Integer mid; | |||
private String deviceid; | |||
private Integer timestamp; | |||
@NoArgsConstructor | |||
@Data | |||
public static class ParmDTO { | |||
/** | |||
* 湿度 | |||
*/ | |||
private Integer hum; | |||
/** | |||
* 温度 | |||
*/ | |||
private Integer tmp; | |||
} | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
package com.tuoheng.admin.vo; | |||
import lombok.Data; | |||
@Data | |||
public class DspCallbackVo { | |||
/** | |||
* 请求ID | |||
*/ | |||
private String requestId; | |||
/** | |||
* 推流地址 | |||
*/ | |||
private String pushUrl; | |||
/** | |||
* 拉流地址 | |||
*/ | |||
private String pullUrl; | |||
/** | |||
* 播放地址(m3u8格式) | |||
*/ | |||
private String playUrl; | |||
/** | |||
* AI推流地址 | |||
*/ | |||
private String aipushUrl; | |||
/** | |||
* AI拉流地址 | |||
*/ | |||
private String aipullUrl; | |||
/** | |||
* AI播放地址 | |||
*/ | |||
private String aiplayUrl; | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.tuoheng.admin.vo; | |||
import com.tuoheng.admin.entity.InspectionFile; | |||
import lombok.Data; | |||
/** | |||
* @Description | |||
* @Author douzhenjun | |||
* @DATE 2023/6/14 | |||
**/ | |||
@Data | |||
public class InspectionFileVo extends InspectionFile { | |||
/** | |||
* 断面id | |||
*/ | |||
private String sectionId; | |||
/** | |||
* 图片trl (无域名) | |||
*/ | |||
private String image; | |||
} |
@@ -0,0 +1,82 @@ | |||
package com.tuoheng.admin.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
@Data | |||
public class QuestionDetailVo { | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 位置信息 | |||
*/ | |||
private String location; | |||
/** | |||
* 标记图 | |||
*/ | |||
private String fileImage; | |||
/** | |||
* 缩略图 | |||
*/ | |||
private String fileThumbnail; | |||
/** | |||
* 原图 | |||
*/ | |||
private String fileOriginal; | |||
/** | |||
* 项目名称:1水面 2岸线 3水质 4排口 | |||
*/ | |||
private Integer name; | |||
/** | |||
* 项目类型:1日常监测 2重点核查 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 巡检内容 | |||
*/ | |||
private String content; | |||
/** | |||
* 处理后图片(多个图片逗号“,”分隔) | |||
*/ | |||
private String handlerImage; | |||
/** | |||
* 处理结果 | |||
*/ | |||
private String handlerResult; | |||
/** | |||
* 处理完成时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private String handlerTime; | |||
/** | |||
* 处理人名称 | |||
*/ | |||
private String userName; | |||
/** | |||
* 处理状态:0待处理 1已处理 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,57 @@ | |||
package com.tuoheng.admin.vo; | |||
import lombok.Data; | |||
@Data | |||
public class QuestionFileVo { | |||
/** | |||
* weptsp_inspection_file表ID | |||
*/ | |||
private String id; | |||
/** | |||
* 图片编码 | |||
*/ | |||
private String fileCode; | |||
/** | |||
* 标记图地址 | |||
*/ | |||
private String fileImage; | |||
/** | |||
* 缩略图地址 | |||
*/ | |||
private String fileThumbnail; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 位置 | |||
*/ | |||
private String location; | |||
/** | |||
* 项目名称:1水面 2岸线 3水质 4排口 | |||
*/ | |||
private Integer name; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String content; | |||
/** | |||
* 处理状态:0待处理 1已处理 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,81 @@ | |||
package com.tuoheng.admin.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
import java.util.List; | |||
@Data | |||
public class QuestionInventoryVo { | |||
/** | |||
* weptse_workorder表ID | |||
*/ | |||
private String id; | |||
/** | |||
* 巡检ID | |||
*/ | |||
private String inspectionId; | |||
/** | |||
* 清单编码(工单编码) | |||
*/ | |||
private String code; | |||
/** | |||
* 巡检河道 | |||
*/ | |||
private String streamName; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String inspectionName; | |||
/** | |||
* 巡检编码 | |||
*/ | |||
private String inspectionCode; | |||
/** | |||
* 巡检时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private String inspectionTime; | |||
/** | |||
* 发现问题数量 | |||
*/ | |||
private Integer totalCount; | |||
/** | |||
* 未处理问题数量 | |||
*/ | |||
private Integer todoCount; | |||
/** | |||
* 处理状态:1问题待处理 2问题已处理 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 问题类型统计 | |||
*/ | |||
private List<QuestionTypeCountVo> typeCount; | |||
/** | |||
* 工单生成时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date workGenerateTime; | |||
/** | |||
* 工单完成时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date workCompleteTime; | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.admin.vo; | |||
import lombok.Data; | |||
@Data | |||
public class QuestionTypeCountVo { | |||
/** | |||
* 项目名称:1水面 2岸线 3水质 4排口 | |||
*/ | |||
private Integer name; | |||
/** | |||
* 数量 | |||
*/ | |||
private Integer totalCount; | |||
} |
@@ -0,0 +1,128 @@ | |||
package com.tuoheng.admin.vo.inspetionFile; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* 巡检问题图片 响应实体 | |||
* | |||
* @author zhuzishuang | |||
* @date 2021/9/27 | |||
*/ | |||
@Data | |||
public class ThInspectionQuestionPictureVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 问题ID | |||
*/ | |||
private String id; | |||
/** | |||
* 图片编码 | |||
*/ | |||
private String fileCode; | |||
/** | |||
* 巡检任务ID | |||
*/ | |||
private String inspectionId; | |||
/** | |||
* 问题 二级分类ID | |||
*/ | |||
private String questionId; | |||
/** | |||
* 问题类型:1水面 2岸线 3水质 4排口 | |||
*/ | |||
private Integer questionName; | |||
/** | |||
* 巡检内容(问题二级分类名称) | |||
*/ | |||
private String content; | |||
/** | |||
* 图片缩略图 | |||
*/ | |||
private String fileThumbnail; | |||
/** | |||
* 原图 | |||
*/ | |||
private String fileOriginal; | |||
/** | |||
* 标记图 | |||
*/ | |||
private String fileImage; | |||
/** | |||
* 位置信息 | |||
*/ | |||
private String location; | |||
/** | |||
* 纬度(原始图片纬度) | |||
*/ | |||
private String latitude; | |||
/** | |||
* 纬度(原始图片纬度) | |||
*/ | |||
private String longitude; | |||
/** | |||
* 高德地图经度 | |||
*/ | |||
private String gaodeLongitude; | |||
/** | |||
* 高德地图纬度 | |||
*/ | |||
private String gaodeLatitude; | |||
/** | |||
* 图片来源:1AI 2后台 3视频 | |||
*/ | |||
private Integer source; | |||
/** | |||
* 图片审核状态:0待审核 1已审核 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 审核人ID | |||
*/ | |||
private String checkUser; | |||
/** | |||
* 审核人 | |||
*/ | |||
private String checkUserName; | |||
/** | |||
* 详细描述 | |||
*/ | |||
private String questionDesc; | |||
/** | |||
* 审核时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date checkTime; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date createTime; | |||
} |
@@ -0,0 +1,64 @@ | |||
package com.tuoheng.admin.vo.inspetionFile; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* 巡检问题工单 映射实体 | |||
* 巡检问题 响应实体 | |||
*/ | |||
@Data | |||
public class ThInspectionQuestionVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 巡检ID | |||
*/ | |||
private String inspectionId; | |||
/** | |||
* 巡检编码 | |||
*/ | |||
private String inspectionCode; | |||
/** | |||
* 巡检名称 | |||
*/ | |||
private String inspectionName; | |||
/** | |||
* 河流名称 | |||
*/ | |||
private String streamName; | |||
/** | |||
* 计划巡检日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date inspectionTime; | |||
/** | |||
* 已审核图片数量 | |||
*/ | |||
private Integer reviewedPictureNum; | |||
/** | |||
* 未审核图片数量 | |||
*/ | |||
private Integer unreviewedPictureNum; | |||
/** | |||
* 图片总数量 | |||
*/ | |||
private Integer totalPictureNum; | |||
/** | |||
* 任务状态:15 任务飞行完成(图片待审核);25 图片已审核(问题待分派) | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,341 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE mapper | |||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.tuoheng.admin.mapper.InspectionFileMapper"> | |||
<resultMap id="BaseResultMap" type="com.tuoheng.admin.entity.InspectionFile"> | |||
<id property="id" column="id" jdbcType="VARCHAR"/> | |||
<result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/> | |||
<result property="fileCode" column="file_code" jdbcType="VARCHAR"/> | |||
<result property="inspectionId" column="inspection_id" jdbcType="VARCHAR"/> | |||
<result property="fileType" column="file_type" jdbcType="TINYINT"/> | |||
<result property="fileName" column="file_name" jdbcType="VARCHAR"/> | |||
<result property="fileThumbnail" column="file_thumbnail" jdbcType="VARCHAR"/> | |||
<result property="fileOriginal" column="file_original" jdbcType="VARCHAR"/> | |||
<result property="fileImage" column="file_image" jdbcType="VARCHAR"/> | |||
<result property="fileSize" column="file_size" jdbcType="DOUBLE"/> | |||
<result property="latitude" column="latitude" jdbcType="VARCHAR"/> | |||
<result property="longitude" column="longitude" jdbcType="VARCHAR"/> | |||
<result property="location" column="location" jdbcType="VARCHAR"/> | |||
<result property="gaodeLongitude" column="gaode_longitude" jdbcType="VARCHAR"/> | |||
<result property="gaodeLatitude" column="gaode_latitude" jdbcType="VARCHAR"/> | |||
<result property="gaodeAddress" column="gaode_address" jdbcType="VARCHAR"/> | |||
<result property="questionId" column="question_id" jdbcType="VARCHAR"/> | |||
<result property="source" column="source" jdbcType="TINYINT"/> | |||
<result property="questionName" column="question_name" jdbcType="VARCHAR"/> | |||
<result property="content" column="content" jdbcType="VARCHAR"/> | |||
<result property="questionDesc" column="question_desc" jdbcType="VARCHAR"/> | |||
<result property="status" column="status" jdbcType="TINYINT"/> | |||
<result property="checkUser" column="check_user" jdbcType="VARCHAR"/> | |||
<result property="checkTime" column="check_time" jdbcType="TIMESTAMP"/> | |||
<result property="createUser" column="create_user" jdbcType="VARCHAR"/> | |||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> | |||
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/> | |||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> | |||
<result property="mark" column="mark" jdbcType="TINYINT"/> | |||
</resultMap> | |||
<sql id="Base_Column_List"> | |||
id,tenant_id,file_code, | |||
inspection_id,file_type,file_name, | |||
file_thumbnail,file_original,file_image, | |||
file_size,latitude,longitude, | |||
location,gaode_longitude,gaode_latitude, | |||
gaode_address,question_id,source, | |||
question_name,content,question_desc, | |||
status,check_user,check_time, | |||
create_user,create_time,update_user, | |||
update_time,mark | |||
</sql> | |||
<insert id="batchadd"> | |||
insert into weptsp_inspection_file (id,file_code, inspection_id, file_type, file_name, | |||
file_thumbnail, file_original, file_image, | |||
file_size, latitude, longitude, | |||
`location`, gaode_longitude, gaode_latitude, | |||
gaode_address, `source`, question_id, question_name, content, | |||
question_desc, `status`, check_user, | |||
check_time, create_user, tenant_id) | |||
values | |||
<foreach collection="list" item="item" separator=","> | |||
( | |||
#{item.id,jdbcType=VARCHAR}, | |||
#{item.fileCode,jdbcType=VARCHAR}, | |||
#{item.inspectionId,jdbcType=VARCHAR}, | |||
#{item.fileType,jdbcType=BOOLEAN}, | |||
#{item.fileName,jdbcType=VARCHAR}, | |||
#{item.fileThumbnail,jdbcType=VARCHAR}, | |||
#{item.fileOriginal,jdbcType=VARCHAR}, | |||
#{item.fileImage,jdbcType=VARCHAR}, | |||
#{item.fileSize}, | |||
#{item.latitude,jdbcType=VARCHAR}, | |||
#{item.longitude,jdbcType=VARCHAR}, | |||
#{item.location,jdbcType=VARCHAR}, | |||
#{item.gaodeLongitude,jdbcType=VARCHAR}, | |||
#{item.gaodeLatitude,jdbcType=VARCHAR}, | |||
#{item.gaodeAddress,jdbcType=VARCHAR}, | |||
#{item.source,jdbcType=BOOLEAN}, | |||
#{item.questionId,jdbcType=VARCHAR}, | |||
#{item.questionName,jdbcType=VARCHAR}, | |||
#{item.content,jdbcType=VARCHAR}, | |||
#{item.questionDesc,jdbcType=VARCHAR}, | |||
#{item.status,jdbcType=TINYINT}, | |||
#{item.checkUser,jdbcType=VARCHAR}, | |||
#{item.checkTime,jdbcType=TIMESTAMP}, | |||
#{item.createUser,jdbcType=VARCHAR}, | |||
#{item.tenantId,jdbcType=VARCHAR} | |||
) | |||
</foreach> | |||
</insert> | |||
<delete id="deleteByInspectionId"> | |||
delete | |||
from weptsp_inspection_file | |||
where inspection_id = #{inspectionId} | |||
<if test="tenantId != null and tenantId != ''"> | |||
AND tenant_id = #{tenantId} | |||
</if> | |||
and mark = 1 | |||
</delete> | |||
<select id="selectQuestionList" resultType="com.tuoheng.admin.vo.inspetionFile.ThInspectionQuestionVo"> | |||
SELECT | |||
i.id AS inspectionId, | |||
i.CODE AS inspectionCode, | |||
i.NAME AS inspectionName, | |||
s.NAME AS streamName, | |||
i.inspection_time AS inspectionTime, | |||
(SELECT count(1) FROM weptsp_inspection_file fi | |||
WHERE fi.inspection_id = i.id AND fi.`status` = 1 AND fi.mark = 1 AND fi.tenant_id=#{tenantId}) AS | |||
reviewedPictureNum, | |||
(SELECT count(1) FROM weptsp_inspection_file fi | |||
WHERE fi.inspection_id = i.id AND fi.`status` = 0 AND fi.mark = 1 AND fi.tenant_id=#{tenantId}) AS | |||
unreviewedPictureNum, | |||
(SELECT count(1) FROM weptsp_inspection_file fi | |||
WHERE fi.inspection_id = i.id AND fi.mark = 1 AND fi.tenant_id=#{tenantId}) AS totalPictureNum | |||
FROM | |||
weptsp_inspection i | |||
LEFT JOIN weptsp_inspection_file f ON i.id = f.inspection_id | |||
LEFT JOIN weptsp_stream s ON i.stream_id = s.id | |||
WHERE | |||
i.mark = 1 and i.tenant_id=#{tenantId} AND s.tenant_id=#{tenantId} | |||
AND ( i.STATUS = 10 OR i.STATUS = 15 ) | |||
AND i.dept_id IN | |||
<foreach collection="deptIdList" item="deptId" separator="," open="(" close=")"> | |||
#{deptId} | |||
</foreach> | |||
<if test="request.keyWords != '' and request.keyWords != null"> | |||
AND concat(i.name,i.code) LIKE concat('%',#{request.keyWords},'%') | |||
</if> | |||
<if test="request.streamId != null and request.streamId != ''"> | |||
AND s.id = #{request.streamId} | |||
</if> | |||
GROUP BY | |||
i.id | |||
ORDER BY | |||
i.inspection_time DESC | |||
</select> | |||
<select id="selectPictureList" | |||
resultType="com.tuoheng.admin.vo.inspetionFile.ThInspectionQuestionPictureVo"> | |||
SELECT | |||
f.id, | |||
f.file_code, | |||
f.inspection_id, | |||
f.question_id, | |||
q.name questionName, | |||
q.content, | |||
f.question_desc, | |||
f.file_thumbnail, | |||
f.file_image, | |||
f.file_original, | |||
f.location, | |||
f.latitude, | |||
f.longitude, | |||
f.gaode_longitude, | |||
f.gaode_latitude, | |||
f.create_time, | |||
f.source, | |||
f.`status`, | |||
f.check_user, | |||
u.realname checkUserName, | |||
f.check_time | |||
FROM weptsp_inspection_file f | |||
LEFT JOIN weptsp_question_type q ON f.question_id = q.code | |||
LEFT JOIN weptsp_oauth_user u on u.id = f.check_user and u.tenant_id=#{tenantId} | |||
WHERE f.mark = 1 and f.tenant_id=#{tenantId} | |||
<if test="request.inspectionId != null and request.inspectionId != '' "> | |||
AND f.inspection_id = #{request.inspectionId} | |||
</if> | |||
<if test="request.questionName != null"> | |||
AND q.name = #{request.questionName} | |||
</if> | |||
<if test="request.status != null "> | |||
AND f.status = #{request.status} | |||
</if> | |||
ORDER BY f.create_time DESC | |||
</select> | |||
<select id="selectReviewPictureList" resultType="com.tuoheng.admin.entity.InspectionFile"> | |||
select f.* | |||
from weptsp_inspection_file f | |||
LEFT JOIN weptsp_question_type q ON f.question_id = q.`code` | |||
where f.mark = 1 | |||
and f.status = 1 | |||
and f.inspection_id = #{inspectionId} | |||
and f.tenant_id = #{tenantId} | |||
AND q.`code` is not null | |||
</select> | |||
<select id="queryQuestionInventory" resultType="com.tuoheng.admin.vo.QuestionInventoryVo"> | |||
SELECT | |||
w.id, | |||
w.inspection_id AS inspectionId, | |||
w.code, | |||
w.`status`, | |||
i.`name` AS inspectionName, | |||
i.`code` AS inspectionCode, | |||
i.inspection_time AS inspectionTime, | |||
s.`name` AS streamName, | |||
w.create_time as workGenerateTime, | |||
w.work_complete_time as workCompleteTime, | |||
(SELECT count(1) FROM weptsp_workorder_item wi | |||
WHERE wi.workorder_id = w.id AND wi.mark = 1 and wi.tenant_id=#{tenantId}) AS totalCount, | |||
(SELECT count(1) FROM weptsp_workorder_item wi | |||
WHERE wi.workorder_id = w.id AND wi.`status` = 0 AND wi.mark = 1 and wi.tenant_id=#{tenantId}) AS | |||
todoCount | |||
FROM | |||
weptsp_workorder w | |||
LEFT JOIN weptsp_inspection i ON w.inspection_id = i.id and w.tenant_id=#{tenantId} | |||
LEFT JOIN weptsp_stream s ON i.stream_id = s.id and s.tenant_id=#{tenantId} | |||
WHERE w.mark = 1 AND i.mark = 1 AND s.mark = 1 and i.tenant_id=#{tenantId} | |||
<if test="param.streamId != null and param.streamId != ''"> | |||
AND s.id = #{param.streamId} | |||
</if> | |||
<if test="param.status != null"> | |||
AND w.`status` = #{param.status} | |||
</if> | |||
<if test="param.keyWords != null and param.keyWords != ''"> | |||
and CONCAT(i.name,i.code) like concat('%',#{param.keyWords},'%') | |||
</if> | |||
ORDER BY w.create_time desc | |||
</select> | |||
<select id="selectQuestionTypeCount" resultType="com.tuoheng.admin.vo.QuestionTypeCountVo"> | |||
SELECT wq.NAME, | |||
count(wq.NAME) AS totalCount | |||
FROM weptsp_workorder_item wi | |||
LEFT JOIN weptsp_inspection_file f ON wi.feedback_id = f.id | |||
LEFT JOIN weptsp_question_type wq ON f.question_id = wq.code | |||
WHERE wi.workorder_id = #{id} | |||
and wi.tenant_id = #{tenantId} | |||
and f.tenant_id = #{tenantId} | |||
GROUP BY wq.NAME | |||
</select> | |||
<select id="queryQuestionFileList" resultType="com.tuoheng.admin.vo.QuestionFileVo"> | |||
SELECT | |||
f.id, | |||
f.file_code AS fileCode, | |||
f.file_image AS fileImage, | |||
f.file_thumbnail AS fileThumbnail, | |||
f.latitude, | |||
f.longitude, | |||
f.location location, | |||
q.name, | |||
q.content, | |||
IFNULL(wi.`status`, 0) AS `status` | |||
FROM weptsp_inspection_file f | |||
LEFT JOIN weptsp_question_type q ON f.question_id = q.code | |||
LEFT JOIN weptsp_workorder_item wi ON f.id = wi.feedback_id and wi.tenant_id=#{tenantId} | |||
WHERE f.mark = 1 AND q.mark = 1 | |||
AND f.inspection_id = #{param.inspectionId} | |||
AND f.gaode_longitude is not null | |||
AND f.tenant_id=#{tenantId} | |||
<if test="param.questionName != null"> | |||
AND q.`name` = #{param.questionName} | |||
</if> | |||
<if test="param.fileCode != null and param.fileCode != ''"> | |||
and f.file_code like concat('%',#{param.fileCode},'%') | |||
</if> | |||
GROUP BY | |||
f.id | |||
</select> | |||
<select id="queryQuestionDetail" resultType="com.tuoheng.admin.vo.QuestionDetailVo"> | |||
SELECT f.gaode_longitude AS longitude, | |||
f.gaode_latitude AS latitude, | |||
f.gaode_address AS location, | |||
f.file_image AS fileImage, | |||
f.file_thumbnail AS fileThumbnail, | |||
f.file_original AS fileOriginal, | |||
q.`name`, | |||
q.type, | |||
q.content, | |||
wi.status, | |||
wi.handler_image AS handlerImage, | |||
wi.handler_result AS handlerResult, | |||
wi.handler_time AS handlerTime, | |||
u.realname AS userName | |||
FROM weptsp_inspection_file f | |||
LEFT JOIN weptsp_question_type q ON f.question_id = q.code | |||
LEFT JOIN weptsp_workorder_item wi ON f.id = wi.feedback_id and wi.tenant_id = #{tenantId} | |||
LEFT JOIN weptsp_oauth_user u ON wi.handler_user = u.id and u.tenant_id = #{tenantId} | |||
WHERE f.mark = 1 | |||
AND q.mark = 1 | |||
AND f.tenant_id = #{tenantId} | |||
AND f.id = #{fileId} | |||
LIMIT 1 | |||
</select> | |||
<select id="selectPicture" resultType="com.tuoheng.admin.vo.inspetionFile.ThInspectionQuestionPictureVo"> | |||
SELECT f.id, | |||
f.inspection_id, | |||
f.question_id, | |||
q.name question_name, | |||
q.content, | |||
f.question_desc, | |||
f.file_thumbnail, | |||
f.file_original, | |||
f.file_image, | |||
f.location, | |||
f.latitude, | |||
f.longitude, | |||
f.gaode_longitude, | |||
f.gaode_latitude, | |||
f.source, | |||
f.`status`, | |||
f.check_user, | |||
u.realname check_user_name, | |||
f.check_time | |||
FROM weptsp_inspection_file f | |||
LEFT JOIN weptsp_question_type q ON f.question_id = q.code | |||
LEFT JOIN weptsp_oauth_user u on u.id = f.check_user and u.tenant_id = #{tenantId} | |||
WHERE f.mark = 1 | |||
and f.tenant_id = #{tenantId} | |||
AND f.id = #{id} | |||
</select> | |||
<select id="selectFileCount" resultType="java.lang.Integer"> | |||
SELECT | |||
count(*) | |||
FROM weptsp_inspection_file f | |||
where | |||
<if test="param.inspectionId != null "> | |||
f.inspection_id = #{param.inspectionId} | |||
AND f.mark = 1 | |||
</if> | |||
<if test="param.tenantId != null "> | |||
AND f.tenant_id = #{param.tenantId} | |||
</if> | |||
</select> | |||
<!-- 查询巡检任务问题图片列表 --> | |||
<select id="selectCount" parameterType="com.tuoheng.admin.entity.InspectionFile" resultType="integer"> | |||
SELECT | |||
count(*) | |||
FROM th_inspection_file f | |||
where | |||
<if test="parm.inspectionId != null "> | |||
f.inspection_id = #{parm.inspectionId} | |||
AND f.mark = 1 | |||
</if> | |||
<if test="parm.tenantId != null "> | |||
AND f.tenant_id = #{parm.tenantId} | |||
</if> | |||
</select> | |||
</mapper> |
@@ -84,4 +84,189 @@ | |||
box_sn,section_id,weptsp_type, | |||
dsp_service_inst_id,request_id | |||
</sql> | |||
<update id="updateByPrimaryKeySelective" parameterType="com.tuoheng.admin.entity.Inspection"> | |||
update th_inspection | |||
<set> | |||
<if test="code != null"> | |||
code = #{code,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="name != null"> | |||
`name` = #{name,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="streamId != null"> | |||
stream_id = #{streamId,jdbcType=INTEGER}, | |||
</if> | |||
<if test="equipmentId != null"> | |||
equipment_id = #{equipmentId,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="equipmentMountId != null"> | |||
equipment_mount_id = #{equipmentMountId,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="equipmentMountName != null"> | |||
equipment_mount_name = #{equipmentMountName,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="cloudBoxId != null"> | |||
cloud_box_id = #{cloudBoxId,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="flightHand != null"> | |||
flight_hand = #{flightHand,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="flightHandName != null"> | |||
flight_hand_name = #{flightHandName,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="inspectionTime != null"> | |||
inspection_time = #{inspectionTime}, | |||
</if> | |||
<if test="executionStartTime != null"> | |||
execution_start_time = #{executionStartTime}, | |||
</if> | |||
<if test="executionEndTime != null"> | |||
execution_end_time = #{executionEndTime}, | |||
</if> | |||
<if test="isLive != null"> | |||
is_live = #{isLive}, | |||
</if> | |||
<if test="isTaken != null"> | |||
is_taken = #{isTaken}, | |||
</if> | |||
<if test="isTilt != null"> | |||
is_tilt = #{isTilt}, | |||
</if> | |||
<if test="videoUrl != null"> | |||
video_url = #{videoUrl,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="aiVideoUrl != null"> | |||
ai_video_url = #{aiVideoUrl,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="reportUrl != null"> | |||
report_url = #{reportUrl,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="status != null"> | |||
`status` = #{status,jdbcType=TINYINT}, | |||
</if> | |||
<if test="analyseStatus != null"> | |||
analyse_status = #{analyseStatus,jdbcType=TINYINT}, | |||
</if> | |||
<if test="note != null"> | |||
note = #{note,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="weather != null"> | |||
weather = #{weather}, | |||
</if> | |||
<if test="flyHeight != null"> | |||
fly_height = #{flyHeight}, | |||
</if> | |||
<if test="srtName != null"> | |||
srt_name = #{srtName}, | |||
</if> | |||
<if test="airportId != null"> | |||
airport_id = #{airportId}, | |||
</if> | |||
<if test="airportName != null"> | |||
airport_name = #{airportName}, | |||
</if> | |||
<if test="inspectionLine != null"> | |||
inspection_line = #{inspectionLine}, | |||
</if> | |||
<if test="inspectionLineName != null"> | |||
inspection_line_name = #{inspectionLineName}, | |||
</if> | |||
<if test="progressbar != null"> | |||
progressbar = #{progressbar}, | |||
</if> | |||
<if test="updateTime != null"> | |||
update_time = #{updateTime}, | |||
</if> | |||
<if test="heartbeatTime != null"> | |||
heartbeat_time = #{heartbeatTime}, | |||
</if> | |||
<if test="startLatitude != null"> | |||
start_latitude = #{startLatitude,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="startLongitude != null"> | |||
start_longitude = #{startLongitude,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="endLongitude != null"> | |||
end_longitude = #{endLongitude,jdbcType=VARCHAR}, | |||
</if> | |||
<if test="inspectionType != null"> | |||
inspection_type = #{inspectionType,jdbcType=INTEGER}, | |||
</if> | |||
<if test="endLatitude != null"> | |||
end_latitude = #{endLatitude,jdbcType=VARCHAR}, | |||
</if> | |||
</set> | |||
where id = #{id,jdbcType=INTEGER} and mark = 1 and tenant_id = #{tenantId,jdbcType=INTEGER} | |||
</update> | |||
<sql id="selectInspectionVo"> | |||
select id, | |||
tenant_id, | |||
dept_id, | |||
code, | |||
name, | |||
type, | |||
channel_id, | |||
channel_name, | |||
leg_id, | |||
leg_name, | |||
inspection_type, | |||
airport_id, | |||
airport_name, | |||
drone_id, | |||
inspection_line, | |||
inspection_line_name, | |||
equipment_id, | |||
equipment_name, | |||
equipment_mount_id, | |||
equipment_mount_name, | |||
cloud_box_id, | |||
cloud_box_name, | |||
box_sn, | |||
flight_hand, | |||
flight_hand_name, | |||
inspection_time, | |||
execution_start_time, | |||
execution_end_time, | |||
is_live, | |||
is_taken, | |||
is_tilt, | |||
video_url, | |||
ai_video_url, | |||
report_url, | |||
srt_url, | |||
status, | |||
analyse_status, | |||
progressbar, | |||
note, | |||
weather, | |||
fly_height, | |||
srt_name, | |||
heartbeat_time, | |||
execution_status, | |||
start_longitude, | |||
start_latitude, | |||
end_longitude, | |||
end_latitude, | |||
mobile, | |||
patrol_location, | |||
dsp_service_inst_id, | |||
emergency_data_inspection_id, | |||
create_user, | |||
create_time, | |||
update_user, | |||
update_time, | |||
mark, | |||
dept_id | |||
from weptsp_inspection | |||
</sql> | |||
<!-- 根据云盒ID查询执行中的巡检任务--> | |||
<select id="getListByBox" resultType="com.tuoheng.admin.entity.Inspection"> | |||
<include refid="selectInspectionVo"/> | |||
where box_sn = #{boxSn, jdbcType=VARCHAR} | |||
and status = 10 | |||
and mark = 1 | |||
order by update_time desc | |||
</select> | |||
</mapper> |