@@ -19,6 +19,7 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils { | |||
public static String YYYY_MM_DD = "yyyy-MM-dd"; | |||
public static String YYYYMMDD = "yyyyMMdd"; | |||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; | |||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; | |||
@@ -160,6 +161,16 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils { | |||
return prefix + formatter.format(date); | |||
} | |||
/** | |||
* 根据时间生成code | |||
*/ | |||
public static String generateCode(String prefix, String format, String random) { | |||
// 根据当前时间,生成任务编码 | |||
Date date = new Date(); | |||
SimpleDateFormat formatter = new SimpleDateFormat(format); | |||
return prefix + formatter.format(date) + random; | |||
} | |||
/** | |||
* 生成图片编号,P+年月日时分秒+随机三位数 | |||
* |
@@ -0,0 +1,38 @@ | |||
-- 2023-11-25 10:30 | |||
-- v1.3.3 | |||
use tuoheng_freeway; | |||
-- 新建周期任务表 | |||
create table th_inspection_cycle | |||
( | |||
id varchar(36) default '' not null comment 'ID' primary key, | |||
tenant_id varchar(36) default '' not null comment '租户ID', | |||
dept_id varchar(36) default '' not null comment '部门ID', | |||
code varchar(255) default '' null comment '任务编号', | |||
name varchar(255) default '' null comment '任务名称', | |||
road_id varchar(36) default '0' null comment '巡检公路ID', | |||
section_id varchar(36) default '0' null comment '巡检路段ID', | |||
airport_task_id int unsigned default '0' not null comment '机场任务ID', | |||
airport_id int unsigned default '0' null comment '巡检机场id', | |||
airport_line_id int unsigned default '0' null comment '巡检线路id', | |||
drone_id int unsigned default '0' not null comment '执飞无人机ID', | |||
type tinyint null comment '执行类型:1,单次;2,每天;5,每周;6,每月', | |||
single_time datetime null comment '单次执行时间', | |||
everyday_time time null comment '每天执行时间', | |||
cycle_time datetime null comment '循环执行时间', | |||
cycle_next_time datetime null comment '循环下次执行时间', | |||
cycle_frequency varchar(255) null comment '循环频率:1~7,每周;1~31,每月', | |||
cycle_start_time datetime null comment '循环开始时间', | |||
cycle_end_time datetime null comment '循环结束时间', | |||
is_enable tinyint(1) default 1 null comment '是否启用: 0:禁用; 1:启用(默认);', | |||
note varchar(255) default '' null comment '备注', | |||
create_user varchar(36) default '0' null comment '创建人', | |||
create_time datetime default CURRENT_TIMESTAMP null comment '创建时间', | |||
update_user varchar(36) default '0' null comment '更新人', | |||
update_time datetime null on update CURRENT_TIMESTAMP comment '更新时间', | |||
mark tinyint unsigned default '1' null comment '有效标记:0删除 1启用 2禁用' | |||
) comment '周期任务表' collate = utf8mb4_bin; | |||
-- 任务表中新增周期任务ID | |||
alter table tuoheng_freeway.th_inspection add inspection_cycle_id varchar(36) default '' not null comment '周期性任务ID' after inspection_type; |
@@ -75,4 +75,14 @@ public interface SystemConstant { | |||
*/ | |||
String ADD_PILOTTASK = "apiTask/add"; | |||
/** | |||
* 机场平台:获取机场路线列表接口 | |||
*/ | |||
String API_AIRPORT_LINE_FILE_LIST = "/airportInterface/getAirlineFileListForThird"; | |||
/** | |||
* 机场平台:根据id获取机场信息 | |||
*/ | |||
String API_AIRPORT_MSG_BY_AIRPORT_ID = "/airportInterface/queryAirportList"; | |||
} |
@@ -0,0 +1,84 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.request.cycle.AddInspectionCycleRequest; | |||
import com.tuoheng.admin.request.cycle.EditInspectionCycleRequest; | |||
import com.tuoheng.admin.request.cycle.QueryInspectionCyclePageListRequest; | |||
import com.tuoheng.admin.service.cycle.InspectionCycleService; | |||
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 java.util.List; | |||
/** | |||
* 周期任务前端控制器 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-23 | |||
*/ | |||
@Slf4j | |||
@RestController | |||
@RequestMapping("/inspection/cycle") | |||
public class InspectionCycleController { | |||
@Autowired | |||
private InspectionCycleService inspectionCycleService; | |||
/** | |||
* 查询周期任务分页列表 | |||
*/ | |||
@GetMapping("/page/list") | |||
public JsonResult getPagelist(QueryInspectionCyclePageListRequest request) { | |||
// log.info("进入查询巡检任务分页列表接口"); | |||
return inspectionCycleService.selectPageList(request); | |||
} | |||
/** | |||
* 根据周期任务id获取周期任务详情 | |||
* @param id | |||
* @return | |||
*/ | |||
@GetMapping("/info/{id}") | |||
public JsonResult getOne(@PathVariable("id") String id){ | |||
return inspectionCycleService.getInfo(id); | |||
} | |||
/** | |||
* 新增周期任务 | |||
*/ | |||
@PostMapping("/add") | |||
public JsonResult add(@RequestBody AddInspectionCycleRequest request) { | |||
// log.info("进入添加周期任务接口"); | |||
return inspectionCycleService.insert(request); | |||
} | |||
/** | |||
* 修改周期任务 | |||
*/ | |||
@PutMapping("/edit") | |||
public JsonResult edit(@RequestBody EditInspectionCycleRequest request) { | |||
// log.info("进入修改周期任务接口, id={}", request.getId()); | |||
return inspectionCycleService.update(request); | |||
} | |||
/** | |||
* 删除周期任务 | |||
*/ | |||
@DeleteMapping("/{ids}") | |||
public JsonResult delete(@PathVariable("ids") List<String> idList) { | |||
// log.info("进入删除周期任务接口, idList={}", idList); | |||
return inspectionCycleService.deleteByIdList(idList); | |||
} | |||
/** | |||
* 周期任务启用/禁用 | |||
*/ | |||
@PutMapping("/{id}/{isEnable}") | |||
public JsonResult update(@PathVariable("id") String id, @PathVariable("isEnable") Integer isEnable) { | |||
log.info("进入周期任务启用/禁用, id={},isEnable={}", id, isEnable); | |||
return inspectionCycleService.updateEnable(id, isEnable); | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
package com.tuoheng.admin.conver; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.vo.cycle.InspectionCycleVo; | |||
import org.mapstruct.Mapper; | |||
import org.mapstruct.factory.Mappers; | |||
import java.util.List; | |||
@Mapper | |||
public interface InspectionCycleConverMapper { | |||
InspectionCycleConverMapper INSTANCE = Mappers.getMapper(InspectionCycleConverMapper.class); | |||
InspectionCycleVo fromInspectionCycleToInspectionCycleVo(InspectionCycle inspectionCycle); | |||
List<InspectionCycleVo> fromInspectionCycleListToInspectionCycleVoList(List<InspectionCycle> inspectionCycleList); | |||
} |
@@ -78,6 +78,11 @@ public class Inspection extends BaseEntity { | |||
*/ | |||
private Integer inspectionType; | |||
/** | |||
* 周期任务ID | |||
*/ | |||
private String inspectionCycleId; | |||
/** | |||
* 巡检机场id | |||
*/ |
@@ -0,0 +1,155 @@ | |||
package com.tuoheng.admin.entity; | |||
import com.baomidou.mybatisplus.annotation.FieldStrategy; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* 周期任务表 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-23 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("th_inspection_cycle") | |||
public class InspectionCycle extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 部门ID | |||
*/ | |||
private String deptId; | |||
/** | |||
* 任务编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 巡检公路id | |||
*/ | |||
private String roadId; | |||
/** | |||
* 巡检路段id | |||
*/ | |||
private String sectionId; | |||
/** | |||
* 巡检机场id | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 航线id | |||
*/ | |||
private Integer airportLineId; | |||
/** | |||
* 航线长度 | |||
*/ | |||
private Double airportLineLength; | |||
/** | |||
* 巡检无人机id | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 执行类型:1,单次;2,每天; 5,每周;6,每月 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 单次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) // 添加忽略判断,该字段值不论是什么,都进行更新 | |||
private Date singleTime; | |||
/** | |||
* 每天执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) // 添加忽略判断,该字段值不论是什么,都进行更新 | |||
private Date everydayTime; | |||
/** | |||
* 循环执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "HH:mm:ss") | |||
@JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) // 添加忽略判断,该字段值不论是什么,都进行更新 | |||
private Date cycleTime; | |||
/** | |||
* 循环下次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) // 添加忽略判断,该字段值不论是什么,都进行更新 | |||
private Date cycleNextTime; | |||
/** | |||
* 循环频率:1~7,每周;1~31,每月;多个以引文逗号分隔 | |||
*/ | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) // 添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleFrequency; | |||
/** | |||
* 循环开始时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) // 添加忽略判断,该字段值不论是什么,都进行更新 | |||
private Date cycleStartTime; | |||
/** | |||
* 循环结束时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) // 添加忽略判断,该字段值不论是什么,都进行更新 | |||
private Date cycleEndTime; | |||
/** | |||
* 是否启用: 0:禁用; 1:启用(默认); | |||
*/ | |||
private Integer isEnable; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 创建人名称 | |||
*/ | |||
@TableField(exist = false) | |||
private String createUserName; | |||
} |
@@ -0,0 +1,31 @@ | |||
package com.tuoheng.admin.enums; | |||
import lombok.Getter; | |||
/** | |||
* @Author: 吴彬 | |||
* @CreateTime: 2023-06-14 15:24 | |||
* @Description: 机场任务类型枚举 | |||
* @Version: 1.0 | |||
*/ | |||
public enum InspectionCycleTypeEnum { | |||
ONCE(1, "单次"), | |||
EVERYDAY(2, "每天"), | |||
EVERYWEEK(5, "每周"), | |||
EVERYMONTH(6, "每月"), | |||
; | |||
InspectionCycleTypeEnum(int code, String description) { | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -0,0 +1,40 @@ | |||
package com.tuoheng.admin.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.request.cycle.QueryInspectionCyclePageListRequest; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.springframework.stereotype.Repository; | |||
/** | |||
* <p> | |||
* 周期任务表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-10-15 | |||
*/ | |||
@Repository | |||
public interface InspectionCycleMapper extends BaseMapper<InspectionCycle> { | |||
/** | |||
* 查询周期任务分页列表 | |||
* | |||
* @param page | |||
* @param request | |||
* @return | |||
*/ | |||
Page<InspectionCycle> selectPageList(@Param("page") IPage page, @Param("request") QueryInspectionCyclePageListRequest request); | |||
/** | |||
* 修改周期任务状态 | |||
* | |||
* @param inspectionCycle 巡检任务 | |||
* @return 结果 | |||
*/ | |||
int updateEnable(InspectionCycle inspectionCycle); | |||
} |
@@ -0,0 +1,128 @@ | |||
package com.tuoheng.admin.request.cycle; | |||
import com.baomidou.mybatisplus.annotation.FieldStrategy; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
/** | |||
* 添加周期任务 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-23 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
public class AddInspectionCycleRequest { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 任务描述 | |||
*/ | |||
private String note; | |||
/** | |||
* 巡检公路id | |||
*/ | |||
private String roadId; | |||
/** | |||
* 巡检路段id | |||
*/ | |||
private String sectionId; | |||
/** | |||
* 机场任务ID | |||
*/ | |||
private Integer airportTaskId; | |||
/** | |||
* 巡检机场id | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 航线id | |||
*/ | |||
private Integer airportLineId; | |||
/** | |||
* 航线长度 | |||
*/ | |||
private Double airportLineLength; | |||
/** | |||
* 巡检无人机id | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 执行类型:1,单次;2,每天; 5,每周;6,每月 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 单次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String singleTime; | |||
/** | |||
* 每天执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String everydayTime; | |||
/** | |||
* 循环执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "HH:mm:ss") | |||
@JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleTime; | |||
/** | |||
* 循环下次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleNextTime; | |||
/** | |||
* 循环频率:1~7,每周;1~31,每月;多个以引文逗号分隔 | |||
*/ | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleFrequency; | |||
/** | |||
* 循环开始时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleStartTime; | |||
/** | |||
* 循环结束时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleEndTime; | |||
} |
@@ -0,0 +1,137 @@ | |||
package com.tuoheng.admin.request.cycle; | |||
import com.baomidou.mybatisplus.annotation.FieldStrategy; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
/** | |||
* 添加周期任务 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-23 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
public class EditInspectionCycleRequest { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 周期任务 id | |||
*/ | |||
private String id; | |||
/** | |||
* 任务编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 巡检公路id | |||
*/ | |||
private String roadId; | |||
/** | |||
* 巡检路段id | |||
*/ | |||
private String sectionId; | |||
/** | |||
* 机场任务ID | |||
*/ | |||
private Integer airportTaskId; | |||
/** | |||
* 巡检机场id | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 航线id | |||
*/ | |||
private Integer airportLineId; | |||
/** | |||
* 航线长度 | |||
*/ | |||
private Double airportLineLength; | |||
/** | |||
* 巡检无人机id | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 执行类型:1,单次;2,每天; 5,每周;6,每月 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 单次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String singleTime; | |||
/** | |||
* 每天执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String everydayTime; | |||
/** | |||
* 循环执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "HH:mm:ss") | |||
@JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleTime; | |||
/** | |||
* 循环下次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleNextTime; | |||
/** | |||
* 循环频率:1~7,每周;1~31,每月;多个以引文逗号分隔 | |||
*/ | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleFrequency; | |||
/** | |||
* 循环开始时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleStartTime; | |||
/** | |||
* 循环结束时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
@TableField(updateStrategy = FieldStrategy.IGNORED)//添加忽略判断,该字段值不论是什么,都进行更新 | |||
private String cycleEndTime; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
} |
@@ -0,0 +1,58 @@ | |||
package com.tuoheng.admin.request.cycle; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* 查询周期任务请求实体 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-17 | |||
*/ | |||
@Data | |||
public class QueryInspectionCyclePageListRequest extends BaseQuery { | |||
/** | |||
* 任务编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 巡检机场id | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 巡检线路Id | |||
*/ | |||
private Integer airportLineId; | |||
/** | |||
* 周期任务启用状态 | |||
*/ | |||
private Integer isEnable; | |||
/** | |||
* 周期任务状态:0未开始 1进行中 2已完成 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 租户Id | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 部门ID列表 | |||
*/ | |||
private List<String> deptIdList; | |||
} |
@@ -0,0 +1,68 @@ | |||
package com.tuoheng.admin.service.cycle; | |||
import com.tuoheng.admin.request.cycle.AddInspectionCycleRequest; | |||
import com.tuoheng.admin.request.cycle.EditInspectionCycleRequest; | |||
import com.tuoheng.admin.request.cycle.QueryInspectionCyclePageListRequest; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import java.util.List; | |||
/** | |||
* 周期任务Service接口 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-23 | |||
*/ | |||
public interface InspectionCycleService { | |||
/** | |||
* 查询周期任务列表(分页) | |||
* | |||
* @param request 周期任务查询实体 | |||
* @return 周期任务集合 | |||
*/ | |||
JsonResult selectPageList(QueryInspectionCyclePageListRequest request); | |||
/** | |||
* 查询周期任务信息 | |||
* | |||
* @param id 周期任务Id | |||
* @return 周期任务 | |||
*/ | |||
JsonResult getInfo(String id); | |||
/** | |||
* 新增巡检任务 | |||
* | |||
* @param request 新增周期任务请求参数 | |||
* @return 结果 | |||
*/ | |||
JsonResult insert(AddInspectionCycleRequest request); | |||
/** | |||
* 修改周期任务 | |||
* | |||
* @param request 修改任务请求参数 | |||
* @return 结果 | |||
*/ | |||
JsonResult update(EditInspectionCycleRequest request); | |||
/** | |||
* 删除周期任务信息 | |||
* | |||
* @param idList 周期任务主键集合 | |||
* @return 结果 | |||
*/ | |||
JsonResult deleteByIdList(List<String> idList) ; | |||
/** | |||
* 周期任务启用,禁用 | |||
* | |||
* @param id 周期任务主键 | |||
* @param id 是否启用 | |||
* @return 结果 | |||
*/ | |||
JsonResult updateEnable(String id, Integer isEnable); | |||
} |
@@ -0,0 +1,71 @@ | |||
package com.tuoheng.admin.service.cycle; | |||
import com.tuoheng.admin.request.cycle.AddInspectionCycleRequest; | |||
import com.tuoheng.admin.request.cycle.EditInspectionCycleRequest; | |||
import com.tuoheng.admin.request.cycle.QueryInspectionCyclePageListRequest; | |||
import com.tuoheng.admin.service.cycle.add.AddInspectionCycleService; | |||
import com.tuoheng.admin.service.cycle.delete.DeleteInspectionCycleService; | |||
import com.tuoheng.admin.service.cycle.query.list.QueryInspectionCyclePageListService; | |||
import com.tuoheng.admin.service.cycle.query.one.QueryInspectionCycleService; | |||
import com.tuoheng.admin.service.cycle.update.UpdateInspectionCycleEnableService; | |||
import com.tuoheng.admin.service.cycle.update.UpdateInspectionCycleService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
@Slf4j | |||
@Service | |||
public class InspectionCycleServiceImpl implements InspectionCycleService { | |||
@Autowired | |||
private QueryInspectionCyclePageListService queryInspectionCyclePageListService; | |||
@Autowired | |||
private QueryInspectionCycleService queryInspectionCycleService; | |||
@Autowired | |||
private AddInspectionCycleService addInspectionCycleService; | |||
@Autowired | |||
private UpdateInspectionCycleService updateInspectionCycleService; | |||
@Autowired | |||
private DeleteInspectionCycleService deleteInspectionCycleService; | |||
@Autowired | |||
private UpdateInspectionCycleEnableService updateInspectionCycleEnableService; | |||
@Override | |||
public JsonResult selectPageList(QueryInspectionCyclePageListRequest request) { | |||
return queryInspectionCyclePageListService.getPageList(request); | |||
} | |||
@Override | |||
public JsonResult getInfo(String id) { | |||
return queryInspectionCycleService.get(id); | |||
} | |||
@Override | |||
public JsonResult insert(AddInspectionCycleRequest request) { | |||
return addInspectionCycleService.add(request); | |||
} | |||
@Override | |||
public JsonResult update(EditInspectionCycleRequest request) { | |||
return updateInspectionCycleService.edit(request); | |||
} | |||
@Override | |||
public JsonResult deleteByIdList(List<String> idList) { | |||
return deleteInspectionCycleService.deleteByIdList(idList); | |||
} | |||
@Override | |||
public JsonResult updateEnable(String id, Integer isEnable) { | |||
return updateInspectionCycleEnableService.updateEnable(id, isEnable); | |||
} | |||
} |
@@ -0,0 +1,85 @@ | |||
package com.tuoheng.admin.service.cycle.add; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.enums.InspectionCycleTypeEnum; | |||
import com.tuoheng.admin.request.cycle.AddInspectionCycleRequest; | |||
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.stereotype.Component; | |||
import java.text.ParseException; | |||
import java.util.Date; | |||
@Slf4j | |||
@Component | |||
public class AddInspectionCycleCheckParamService { | |||
public JsonResult check(AddInspectionCycleRequest request) { | |||
if(StringUtils.isEmpty(request.getName())){ | |||
return JsonResult.error("任务名称为空"); | |||
} | |||
if(null == request.getRoadId()){ | |||
return JsonResult.error("巡检公路id为空"); | |||
} | |||
if(null == request.getSectionId()){ | |||
return JsonResult.error("巡检路段id为空"); | |||
} | |||
if(null == request.getAirportId()){ | |||
return JsonResult.error("巡检机场id为空"); | |||
} | |||
if(null == request.getAirportLineId()){ | |||
return JsonResult.error("航线id为空"); | |||
} | |||
if ((ObjectUtil.isNotNull(request.getCycleStartTime()) && ObjectUtil.isNull(request.getCycleEndTime())) | |||
|| (ObjectUtil.isNull(request.getCycleStartTime()) && ObjectUtil.isNotNull(request.getCycleEndTime()))) { | |||
return JsonResult.error("周期性任务循环开始时间和循环结束时间要么都存在要么都不存在!"); | |||
} | |||
if(ObjectUtil.isNull(request.getCycleTime())){ | |||
return JsonResult.error("循环执行时间为空"); | |||
} | |||
if(null == request.getType()){ | |||
return JsonResult.error("执行频次为空"); | |||
} | |||
if (InspectionCycleTypeEnum.EVERYWEEK.getCode() == request.getType()) { | |||
if (StringUtils.isEmpty(request.getCycleFrequency())) { | |||
return JsonResult.error("循环周期类型为周,循环日期不能为空!"); | |||
} | |||
for (String item : request.getCycleFrequency().split(",")) { | |||
if ((Integer.valueOf(item) < 0 || Integer.valueOf(item) > 7)) { | |||
return JsonResult.error("循环周期类型为周,循环日期只能在1~7范围内!"); | |||
} | |||
} | |||
} else if (InspectionCycleTypeEnum.EVERYMONTH.getCode() == request.getType()) { | |||
if (StringUtils.isEmpty(request.getCycleFrequency())) { | |||
return JsonResult.error("循环周期类型为月,循环日期不能为空!"); | |||
} | |||
for (String item : request.getCycleFrequency().split(",")) { | |||
if ((Integer.valueOf(item) < 0 || Integer.valueOf(item) > 31)) { | |||
return JsonResult.error("循环周期类型为月,循环日期只能在1~31范围内!"); | |||
} | |||
} | |||
} | |||
Date dateBegin = null; | |||
try { | |||
dateBegin = DateUtils.parseDate(DateUtils.getDate(), DateUtils.YYYY_MM_DD); | |||
} catch (ParseException e) { | |||
log.error("获取开始时间异常:{}", e); | |||
throw new RuntimeException(e); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,93 @@ | |||
package com.tuoheng.admin.service.cycle.add; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.RandomUtil; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.mapper.InspectionCycleMapper; | |||
import com.tuoheng.admin.request.cycle.AddInspectionCycleRequest; | |||
import com.tuoheng.admin.service.third.airport.GetAirportListByAirportIds; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
@Slf4j | |||
@Component | |||
public class AddInspectionCycleService { | |||
private final static String CAPITAL_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |||
@Autowired | |||
private InspectionCycleMapper inspectionCycleMapper; | |||
@Autowired | |||
private AddInspectionCycleCheckParamService addInspectionCycleCheckParamService; | |||
@Autowired | |||
private GetAirportListByAirportIds getAirportListByAirportIds; | |||
public JsonResult add(AddInspectionCycleRequest request) { | |||
JsonResult result = addInspectionCycleCheckParamService.check(request); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
User user = CurrentUserUtil.getUserInfo(); | |||
String tenantId = user.getTenantId(); | |||
//新增周期性任务 | |||
InspectionCycle inspectionCycle = new InspectionCycle(); | |||
BeanUtils.copyProperties(request, inspectionCycle); | |||
//无人机id | |||
getDroneId(request.getAirportId(), inspectionCycle); | |||
//任务code | |||
String code = DateUtils.generateCode("GSZQ", DateUtils.YYYYMMDD, RandomUtil.randomString(CAPITAL_CHAR, 3)); | |||
inspectionCycle.setCode(code); | |||
inspectionCycle.setCycleTime(DateUtils.dateTime("HH:mm:ss", request.getCycleTime())); | |||
//inspectionCycle.setCycleNextTime(DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",request.getCycleNextTime())); | |||
inspectionCycle.setCycleStartTime(DateUtils.dateTime("yyyy-MM-dd", request.getCycleStartTime())); | |||
inspectionCycle.setCycleEndTime(DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", request.getCycleEndTime()+" 23:59:59")); | |||
inspectionCycle.setTenantId(tenantId); | |||
inspectionCycle.setDeptId(user.getDeptId()); | |||
inspectionCycle.setIsEnable(1); | |||
inspectionCycle.setCreateTime(DateUtils.now()); | |||
inspectionCycle.setCreateUser(user.getId()); | |||
int count = inspectionCycleMapper.insert(inspectionCycle); | |||
if (count <= 0) { | |||
return JsonResult.error("新增失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 根据机场id获取无人机id | |||
* | |||
* @param airportId | |||
* @return | |||
*/ | |||
private void getDroneId(Integer airportId, InspectionCycle inspectionCycle) { | |||
List<Integer> airportIdList = new ArrayList<>(1); | |||
airportIdList.add(airportId); | |||
String airportIds = airportIdList.stream().map(x -> String.valueOf(x)).collect(Collectors.joining(",", "", "")); | |||
List<AirportInfoVo> airportInfoVos = getAirportListByAirportIds.getAirportInfo(airportIds); | |||
if (CollectionUtil.isEmpty(airportInfoVos) && airportInfoVos.size() == 0) { | |||
log.info("机场对应的无人机id为空,airportInfoVos:{}", airportInfoVos); | |||
return; | |||
} | |||
if (airportInfoVos.get(0).getDroneId() != null) { | |||
inspectionCycle.setDroneId(airportInfoVos.get(0).getDroneId()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,59 @@ | |||
package com.tuoheng.admin.service.cycle.delete; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.mapper.InspectionCycleMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import java.util.List; | |||
@Component | |||
public class DeleteInspectionCycleService { | |||
@Autowired | |||
private InspectionCycleMapper inspectionCycleMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
public JsonResult deleteByIdList(List<String> idList) { | |||
List<Inspection> inspectionList; | |||
for (String id : idList) { | |||
InspectionCycle inspectionCycle = inspectionCycleMapper.selectById(id); | |||
if (ObjectUtil.isNull(inspectionCycle)) { | |||
return JsonResult.error("周期任务不存在!"); | |||
} | |||
inspectionCycle.setMark(MarkEnum.NOTVALID.getCode()); | |||
int deleteById = inspectionCycleMapper.updateById(inspectionCycle); | |||
if (deleteById <= 0) { | |||
return JsonResult.error("删除周期任务失败!"); | |||
} | |||
inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery() | |||
.eq(Inspection::getTenantId, inspectionCycle.getTenantId()) | |||
.eq(Inspection::getInspectionCycleId, inspectionCycle.getId()) | |||
.eq(Inspection::getStatus, InspectionStatusEnum.WAIT_FLIGHT.getCode()) | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode()) | |||
.orderByDesc(Inspection::getCreateTime)); | |||
if (CollectionUtil.isNotEmpty(inspectionList)) { | |||
for (Inspection inspection : inspectionList) { | |||
inspection.setMark(MarkEnum.NOTVALID.getCode()); | |||
inspection.setUpdateUser(CurrentUserUtil.getUserId()); | |||
inspection.setUpdateTime(DateUtils.now()); | |||
inspectionMapper.update(inspection); | |||
} | |||
} | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,227 @@ | |||
package com.tuoheng.admin.service.cycle.query.list; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.admin.conver.InspectionCycleConverMapper; | |||
import com.tuoheng.admin.entity.Dept; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.InspectionCycleMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.request.cycle.QueryInspectionCyclePageListRequest; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.admin.vo.AirportLineVo; | |||
import com.tuoheng.admin.vo.cycle.InspectionCycleVo; | |||
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.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Function; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 查询周期任务分页列表业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-25 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryInspectionCyclePageListService { | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Autowired | |||
private UserMapper userMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private InspectionCycleMapper inspectionCycleMapper; | |||
@Autowired | |||
private AirportService airportService; | |||
public JsonResult getPageList(QueryInspectionCyclePageListRequest request) { | |||
// log.info("进入查询周期任务分页列表业务"); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
String tenantId = user.getTenantId(); | |||
JsonResult result = this.check(tenantId, request); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询周期任务分页列表业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
List<String> deptIdList = new ArrayList<>(); | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList.add(user.getDeptId()); | |||
} | |||
request.setTenantId(tenantId); | |||
request.setDeptIdList(deptIdList); | |||
// 设置分页参数 | |||
IPage<Inspection> page = new Page<>(request.getPage(), request.getLimit()); | |||
// 查询结果 | |||
IPage<InspectionCycle> pageData = inspectionCycleMapper.selectPageList(page, request); | |||
// 构造返回结果对象 | |||
List<InspectionCycleVo> inspectionCycleVoList = this.buildInspectionCycleVoList(pageData.getRecords()); | |||
// 重写返回结果对象 | |||
IPage<InspectionCycleVo> inspectionCycleVoPageData = new Page<>(); | |||
inspectionCycleVoPageData.setPages(pageData.getPages()); | |||
inspectionCycleVoPageData.setCurrent(pageData.getCurrent()); | |||
inspectionCycleVoPageData.setSize(pageData.getSize()); | |||
inspectionCycleVoPageData.setTotal(pageData.getTotal()); | |||
inspectionCycleVoPageData.setRecords(inspectionCycleVoList); | |||
return JsonResult.success(inspectionCycleVoPageData); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param tenantId | |||
* @param request | |||
* @return | |||
*/ | |||
private JsonResult check(String tenantId, QueryInspectionCyclePageListRequest request) { | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* @param inspectionCycleList | |||
* @return | |||
*/ | |||
private List<InspectionCycleVo> buildInspectionCycleVoList(List<InspectionCycle> inspectionCycleList) { | |||
Map<String, String> deptMap = this.getDeptMap(inspectionCycleList); | |||
Map<String, String> updateUsernameMap = this.getUpdateUsernameMap(inspectionCycleList); | |||
Map<String, AirportInfoVo> airportMap = this.getAirportMap(inspectionCycleList); | |||
Map<Integer, AirportLineVo> airportLineMap = this.getAirportLineMap(inspectionCycleList); | |||
List<InspectionCycleVo> inspectionCycleVoList = InspectionCycleConverMapper.INSTANCE.fromInspectionCycleListToInspectionCycleVoList(inspectionCycleList); | |||
String deptName; | |||
String updateUsername; | |||
Integer executCount; | |||
AirportInfoVo airportInfoVo; | |||
AirportLineVo airportLineVo; | |||
for (InspectionCycleVo inspectionCycleVo : inspectionCycleVoList) { | |||
if (ObjectUtil.isNotEmpty(deptMap)) { | |||
deptName = deptMap.get(inspectionCycleVo.getDeptId()); | |||
if (StringUtils.isNotEmpty(deptName)) { | |||
inspectionCycleVo.setDeptName(deptName); | |||
} | |||
} | |||
if (ObjectUtil.isNotEmpty(updateUsernameMap)) { | |||
updateUsername = updateUsernameMap.get(inspectionCycleVo.getUpdateUser()); | |||
if (StringUtils.isNotEmpty(updateUsername)) { | |||
inspectionCycleVo.setUpdateUsername(updateUsername); | |||
} | |||
} | |||
if (ObjectUtil.isNotEmpty(airportMap)) { | |||
airportInfoVo = airportMap.get(String.valueOf(inspectionCycleVo.getAirportId())); | |||
if (ObjectUtil.isNotEmpty(airportInfoVo)) { | |||
inspectionCycleVo.setAirportName(airportInfoVo.getName()); | |||
} | |||
} | |||
if (ObjectUtil.isNotEmpty(airportLineMap)) { | |||
airportLineVo = airportLineMap.get(inspectionCycleVo.getAirportLineId()); | |||
if (ObjectUtil.isNotEmpty(airportLineVo)) { | |||
inspectionCycleVo.setAirportLineName(airportLineVo.getFileName()); | |||
inspectionCycleVo.setAirportLineFileUrl(airportLineVo.getFileUrl()); | |||
} | |||
} | |||
executCount = inspectionMapper.selectCount(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getInspectionCycleId, inspectionCycleVo.getId()) | |||
.ne(Inspection::getStatus, InspectionStatusEnum.WAIT_FLIGHT.getCode()) | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode())); | |||
inspectionCycleVo.setExecutCount(executCount); | |||
} | |||
return inspectionCycleVoList; | |||
} | |||
/** | |||
* 设置任务列表中每一个任务的部门名称 | |||
* 查询到的任务列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 | |||
* | |||
* @param inspectionCycleList | |||
* @return | |||
*/ | |||
private Map<String, String> getDeptMap(List<InspectionCycle> inspectionCycleList) { | |||
if (CollectionUtil.isEmpty(inspectionCycleList)) { | |||
return null; | |||
} | |||
Map<String, String> map = new HashMap<>(); | |||
List<String> deptIdList = inspectionCycleList.stream().map(o -> o.getDeptId()).collect(Collectors.toList()); | |||
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList); | |||
for (Dept dept : deptList) { | |||
map.put(dept.getId(), dept.getName()); | |||
} | |||
return map; | |||
} | |||
private Map<String, String> getUpdateUsernameMap(List<InspectionCycle> inspectionCycleList) { | |||
if (CollectionUtil.isEmpty(inspectionCycleList)) { | |||
return null; | |||
} | |||
Map<String, String> map = new HashMap<>(); | |||
List<String> updateUserList = inspectionCycleList.stream().map(o -> o.getUpdateUser()).collect(Collectors.toList()); | |||
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() | |||
.in(User::getId, updateUserList) | |||
.eq(User::getMark, MarkEnum.VALID.getCode())); | |||
for (User user : userList) { | |||
map.put(user.getId(), user.getRealname()); | |||
} | |||
return map; | |||
} | |||
private Map<String, AirportInfoVo> getAirportMap(List<InspectionCycle> inspectionCycleList) { | |||
if (CollectionUtil.isEmpty(inspectionCycleList)) { | |||
return null; | |||
} | |||
List<Integer> airportIdList = inspectionCycleList.stream().map(o -> o.getAirportId()).collect(Collectors.toList()); | |||
String airportIds = airportIdList.stream().map(x -> String.valueOf(x)).collect(Collectors.joining(",", "", "")); | |||
List<AirportInfoVo> airportInfoVoList = airportService.getAirportInfoList(airportIds); | |||
if (CollectionUtil.isEmpty(airportInfoVoList)) { | |||
return null; | |||
} | |||
Map<String, AirportInfoVo> airportMap = airportInfoVoList.stream().collect(Collectors.toMap(AirportInfoVo::getId, Function.identity())); | |||
return airportMap; | |||
} | |||
private Map<Integer, AirportLineVo> getAirportLineMap(List<InspectionCycle> inspectionCycleList) { | |||
if (CollectionUtil.isEmpty(inspectionCycleList)) { | |||
return null; | |||
} | |||
List<Integer> airportLineIdList = inspectionCycleList.stream().map(o -> o.getAirportLineId()).collect(Collectors.toList()); | |||
List<AirportLineVo> airportLineVoList = airportService.getAirportLineListByAirportIdAndLineIdList(null, airportLineIdList); | |||
if (CollectionUtil.isEmpty(airportLineVoList)) { | |||
return null; | |||
} | |||
Map<Integer, AirportLineVo> airportLineMap = airportLineVoList.stream().collect(Collectors.toMap(AirportLineVo::getId, Function.identity())); | |||
return airportLineMap; | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
package com.tuoheng.admin.service.cycle.query.one; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.conver.InspectionCycleConverMapper; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.InspectionCycleMapper; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.admin.vo.cycle.InspectionCycleVo; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 查询周期任务业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-25 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryInspectionCycleService { | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Autowired | |||
private InspectionCycleMapper inspectionCycleMapper; | |||
@Autowired | |||
private AirportService airportService; | |||
public JsonResult get(String id) { | |||
// log.info("进入查询周期任务业务"); | |||
// User user = CurrentUserUtil.getUserInfo(); | |||
JsonResult result = this.check(id); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询周期任务分页列表业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
InspectionCycle inspectionCycle = (InspectionCycle) result.getData(); | |||
InspectionCycleVo inspectionCycleVo = InspectionCycleConverMapper.INSTANCE.fromInspectionCycleToInspectionCycleVo(inspectionCycle); | |||
return JsonResult.success(inspectionCycleVo); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
if (StringUtils.isEmpty(id)) { | |||
throw new ServiceException("周期任务ID为空"); | |||
} | |||
InspectionCycle inspectionCycle = inspectionCycleMapper.selectById(id); | |||
if (ObjectUtil.isEmpty(inspectionCycle)) { | |||
throw new ServiceException("周期任务不存在"); | |||
} | |||
return JsonResult.success(inspectionCycle); | |||
} | |||
} |
@@ -0,0 +1,91 @@ | |||
package com.tuoheng.admin.service.cycle.update; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.enums.InspectionCycleTypeEnum; | |||
import com.tuoheng.admin.request.cycle.EditInspectionCycleRequest; | |||
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.stereotype.Component; | |||
import java.text.ParseException; | |||
import java.util.Date; | |||
@Slf4j | |||
@Component | |||
public class EditInspectionCycleCheckParamService { | |||
public JsonResult check(EditInspectionCycleRequest request) { | |||
if(StringUtils.isEmpty(request.getId())){ | |||
return JsonResult.error("周期性任务id为空"); | |||
} | |||
if(null == request.getRoadId()){ | |||
return JsonResult.error("巡检公路id为空"); | |||
} | |||
if(null == request.getSectionId()) { | |||
return JsonResult.error("巡检路段id为空"); | |||
} | |||
if(StringUtils.isEmpty(request.getName())){ | |||
return JsonResult.error("任务名称为空"); | |||
} | |||
if(null == request.getAirportId()){ | |||
return JsonResult.error("巡检机场id为空"); | |||
} | |||
if(null == request.getAirportLineId()){ | |||
return JsonResult.error("航线id为空"); | |||
} | |||
/** | |||
* 周期性计划需要判断是否在循环开始时间和结束时间内 | |||
*/ | |||
if ((ObjectUtil.isNotNull(request.getCycleStartTime()) && ObjectUtil.isNull(request.getCycleEndTime())) | |||
|| (ObjectUtil.isNull(request.getCycleStartTime()) && ObjectUtil.isNotNull(request.getCycleEndTime()))) { | |||
return JsonResult.error("周期性任务循环开始时间和循环结束时间要么都存在要么都不存在!"); | |||
} | |||
if(ObjectUtil.isNull(request.getCycleTime())){ | |||
return JsonResult.error("循环执行时间为空"); | |||
} | |||
if(null == request.getType()){ | |||
return JsonResult.error("执行频次为空"); | |||
} | |||
if (InspectionCycleTypeEnum.EVERYWEEK.getCode() == request.getType()) { | |||
if (StringUtils.isEmpty(request.getCycleFrequency())) { | |||
return JsonResult.error("循环周期类型为周,循环日期不能为空!"); | |||
} | |||
for (String item : request.getCycleFrequency().split(",")) { | |||
if ((Integer.valueOf(item) < 0 || Integer.valueOf(item) > 7)) { | |||
return JsonResult.error("循环周期类型为周,循环日期只能在1~7范围内!"); | |||
} | |||
} | |||
} else if (InspectionCycleTypeEnum.EVERYMONTH.getCode() == request.getType()) { | |||
if (StringUtils.isEmpty(request.getCycleFrequency())) { | |||
return JsonResult.error("循环周期类型为月,循环日期不能为空!"); | |||
} | |||
for (String item : request.getCycleFrequency().split(",")) { | |||
if ((Integer.valueOf(item) < 0 || Integer.valueOf(item) > 31)) { | |||
return JsonResult.error("循环周期类型为月,循环日期只能在1~31范围内!"); | |||
} | |||
} | |||
} | |||
Date dateBegin = null; | |||
try { | |||
dateBegin = DateUtils.parseDate(DateUtils.getDate(), DateUtils.YYYY_MM_DD); | |||
} catch (ParseException e) { | |||
log.error("获取开始时间异常:{}", e); | |||
throw new RuntimeException(e); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,77 @@ | |||
package com.tuoheng.admin.service.cycle.update; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.mapper.InspectionCycleMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
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 org.springframework.stereotype.Component; | |||
import java.util.List; | |||
@Component | |||
public class UpdateInspectionCycleEnableService { | |||
private final InspectionCycleMapper inspectionCycleMapper; | |||
private final InspectionMapper inspectionMapper; | |||
public UpdateInspectionCycleEnableService(InspectionCycleMapper inspectionCycleMapper, | |||
InspectionMapper inspectionMapper) { | |||
this.inspectionCycleMapper = inspectionCycleMapper; | |||
this.inspectionMapper = inspectionMapper; | |||
} | |||
public JsonResult updateEnable(String id, Integer isEnable) { | |||
JsonResult result = this.check(id, isEnable); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
InspectionCycle inspectionCycle = (InspectionCycle) result.getData(); | |||
inspectionCycle.setIsEnable(isEnable); | |||
inspectionCycle.setUpdateUser(CurrentUserUtil.getUserId()); | |||
inspectionCycle.setUpdateTime(DateUtils.now()); | |||
inspectionCycleMapper.updateEnable(inspectionCycle); | |||
// 禁用 | |||
if (0 == isEnable) { | |||
// 将其下子任务都删除 | |||
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery() | |||
.eq(Inspection::getTenantId, inspectionCycle.getTenantId()) | |||
.eq(Inspection::getInspectionCycleId, inspectionCycle.getId()) | |||
.eq(Inspection::getStatus, InspectionStatusEnum.WAIT_FLIGHT.getCode()) | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode()) | |||
.orderByDesc(Inspection::getCreateTime)); | |||
if (CollectionUtil.isNotEmpty(inspectionList)) { | |||
for (Inspection inspection : inspectionList) { | |||
inspection.setMark(MarkEnum.NOTVALID.getCode()); | |||
inspection.setUpdateUser(CurrentUserUtil.getUserId()); | |||
inspection.setUpdateTime(DateUtils.now()); | |||
inspectionMapper.update(inspection); | |||
} | |||
} | |||
} | |||
return JsonResult.success(); | |||
} | |||
private JsonResult check(String id, Integer isEnable) { | |||
if (StringUtils.isEmpty(id)) { | |||
throw new ServiceException("周期任务ID为空"); | |||
} | |||
InspectionCycle inspectionCycle = inspectionCycleMapper.selectById(id); | |||
if (ObjectUtil.isEmpty(inspectionCycle)) { | |||
throw new ServiceException("周期任务不存在"); | |||
} | |||
return JsonResult.success(inspectionCycle); | |||
} | |||
} |
@@ -0,0 +1,81 @@ | |||
package com.tuoheng.admin.service.cycle.update; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import com.tuoheng.admin.entity.InspectionCycle; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.mapper.InspectionCycleMapper; | |||
import com.tuoheng.admin.request.cycle.EditInspectionCycleRequest; | |||
import com.tuoheng.admin.service.third.airport.GetAirportListByAirportIds; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
@Component | |||
@Slf4j | |||
public class UpdateInspectionCycleService { | |||
@Autowired | |||
private InspectionCycleMapper inspectionCycleMapper; | |||
@Autowired | |||
private EditInspectionCycleCheckParamService editInspectionCycleCheckParamService; | |||
@Autowired | |||
private GetAirportListByAirportIds getAirportListByAirportIds; | |||
public JsonResult edit(EditInspectionCycleRequest request) { | |||
JsonResult result = editInspectionCycleCheckParamService.check(request); | |||
if (0 != result.getCode()) { | |||
return result; | |||
} | |||
User user = CurrentUserUtil.getUserInfo(); | |||
//编辑周期性任务 | |||
InspectionCycle inspectionCycle = inspectionCycleMapper.selectById(request.getId()); | |||
BeanUtils.copyProperties(request,inspectionCycle); | |||
//无人机id | |||
getDroneId(request.getAirportId(),inspectionCycle); | |||
//任务code | |||
inspectionCycle.setCycleTime(DateUtils.dateTime("HH:mm:ss",request.getCycleTime())); | |||
//inspectionCycle.setCycleNextTime(DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",request.getCycleNextTime())); | |||
inspectionCycle.setCycleStartTime(DateUtils.dateTime("yyyy-MM-dd",request.getCycleStartTime())); | |||
inspectionCycle.setCycleEndTime(DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",request.getCycleEndTime()+" 23:59:59")); | |||
inspectionCycle.setUpdateTime(DateUtils.now()); | |||
inspectionCycle.setUpdateUser(user.getId()); | |||
int count = inspectionCycleMapper.updateById(inspectionCycle); | |||
if(count <= 0){ | |||
return JsonResult.error("任务编辑失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 根据机场id获取无人机id | |||
* @param airportId | |||
* @return | |||
*/ | |||
private void getDroneId(Integer airportId,InspectionCycle inspectionCycle) { | |||
List<Integer> airportIdList = new ArrayList<>(1); | |||
airportIdList.add(airportId); | |||
String airportIds = airportIdList.stream().map(x -> String.valueOf(x)).collect(Collectors.joining(",", "", "")); | |||
List<AirportInfoVo> airportInfoVos = getAirportListByAirportIds.getAirportInfo(airportIds); | |||
if(CollectionUtil.isEmpty(airportInfoVos) && airportInfoVos.size() == 0){ | |||
log.info("机场对应的无人机id为空,airportInfoVos:{}",airportInfoVos); | |||
return; | |||
} | |||
if(airportInfoVos.get(0).getDroneId() != null){ | |||
inspectionCycle.setDroneId(airportInfoVos.get(0).getDroneId()); | |||
} | |||
} | |||
} |
@@ -3,10 +3,18 @@ package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.request.accident.AccidentFlightRequest; | |||
import com.tuoheng.admin.request.accident.ReversalFlightRequest; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.admin.vo.AirportLineVo; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import java.util.List; | |||
public interface AirportService { | |||
List<AirportInfoVo> getAirportInfoList(String airportIds); | |||
List<AirportLineVo> getAirportLineListByAirportIdAndLineIdList(String airportId, List<Integer> airportLineIdList); | |||
JsonResult getAirportList(); | |||
JsonResult getAirportDetail(Integer airportId,String airportCode); |
@@ -3,10 +3,14 @@ package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.request.accident.AccidentFlightRequest; | |||
import com.tuoheng.admin.request.accident.ReversalFlightRequest; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.admin.vo.AirportLineVo; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
@Service | |||
public class AirportServiceImpl implements AirportService { | |||
@@ -31,6 +35,19 @@ public class AirportServiceImpl implements AirportService { | |||
@Autowired | |||
private ReversalFlightService reversalFlightService; | |||
@Autowired | |||
private GetAirportListByAirportIds getAirportListByAirportIds; | |||
@Override | |||
public List<AirportInfoVo> getAirportInfoList(String airportIds) { | |||
return getAirportListByAirportIds.getAirportInfo(airportIds); | |||
} | |||
@Override | |||
public List<AirportLineVo> getAirportLineListByAirportIdAndLineIdList(String airportId, List<Integer> airportLineIdList) { | |||
return getAirLineListService.getList(airportId, airportLineIdList); | |||
} | |||
@Override | |||
public JsonResult getAirportList() { | |||
return getAirportListService.getAirportList(); |
@@ -1,21 +1,26 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.Tenant; | |||
import com.tuoheng.admin.enums.code.AriportCodeEnum; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.AirportLineVo; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Qualifier; | |||
import org.springframework.http.*; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.client.RestTemplate; | |||
import org.springframework.web.util.UriComponentsBuilder; | |||
import java.util.List; | |||
import java.util.Objects; | |||
@Slf4j | |||
@@ -54,4 +59,49 @@ public class GetAirLineListService { | |||
return jsonResult; | |||
} | |||
public List<AirportLineVo> getList(String airportId, List<Integer> airportLineIdList) { | |||
//读取不同租户的机场平台url | |||
Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId()); | |||
if (ObjectUtil.isEmpty(tenant)) { | |||
return null; | |||
} | |||
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LINE_FILE_LIST; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("tenantCode", tenant.getCode()); | |||
jsonObject.put("airportId", airportId); | |||
jsonObject.put("airlineFileIds", airportLineIdList); | |||
log.info("调用机场平台,获取航线列表,url:{}", url); | |||
log.info("调用机场平台,获取航线列表,jsonObject:{}", jsonObject); | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.setContentType(MediaType.APPLICATION_JSON); | |||
HttpEntity httpEntity = new HttpEntity(jsonObject, headers); | |||
ResponseEntity<JsonResult> response; | |||
try { | |||
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); | |||
} catch (Exception e) { | |||
log.info("调用机场平台,获取航线列表接口异常,url:{}", url); | |||
log.info("调用机场平台,获取航线列表接口异常,jsonObject:{}", jsonObject); | |||
return null; | |||
} | |||
if (ObjectUtil.isEmpty(response)) { | |||
log.info("调用机场平台,获取航线列表接口返回为空,url:{}", url); | |||
log.info("调用机场平台,获取航线列表接口返回为空,jsonObject:{}", jsonObject); | |||
return null; | |||
} | |||
JsonResult jsonResult = response.getBody(); | |||
if (0 != jsonResult.getCode()) { | |||
log.info("调用机场平台,获取航线列表,失败,url:{}", url); | |||
log.info("调用机场平台,获取航线列表,失败,jsonObject:{}", jsonObject); | |||
log.info("调用机场平台,获取航线列表,失败,jsonResult:{}", jsonResult.getMsg()); | |||
return null; | |||
} | |||
List<AirportLineVo> airportLineVoList = JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirportLineVo.class); | |||
if (CollectionUtil.isEmpty(airportLineVoList)) { | |||
log.info("调用机场平台,获取航线列表,数据为空"); | |||
} | |||
return airportLineVoList; | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.Tenant; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.AirportInfoVo; | |||
import com.tuoheng.admin.vo.airport.AirPortStatusVo; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Qualifier; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.client.RestTemplate; | |||
import org.springframework.web.util.UriComponentsBuilder; | |||
import java.util.List; | |||
@Slf4j | |||
@Service | |||
public class GetAirportListByAirportIds { | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@Autowired | |||
@Qualifier("restTemplate") | |||
private RestTemplate restTemplate; | |||
public List<AirPortStatusVo> getList(String airportIds) { | |||
String url = UriComponentsBuilder.fromHttpUrl(CommonConfig.airportURL + SystemConstant.API_AIRPORT_STATUS_BY_AIRPORT_ID) | |||
.queryParam("airportIds", airportIds) | |||
.toUriString(); | |||
JsonResult jsonResult; | |||
try { | |||
jsonResult = restTemplate.getForObject(url, JsonResult.class); | |||
} catch (Exception e) { | |||
log.info("调用机场平台,查询飞行状态异常, url:{}", url); | |||
return null; | |||
} | |||
List<AirPortStatusVo> airPortStatusVOList = JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirPortStatusVo.class); | |||
return airPortStatusVOList; | |||
} | |||
public List<AirportInfoVo> getAirportInfo(String airportIds) { | |||
//读取不同租户的机场平台url | |||
Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId()); | |||
if (ObjectUtil.isEmpty(tenant) && StringUtils.isEmpty(tenant.getCode())) { | |||
return null; | |||
} | |||
String tenantCode = tenant.getCode(); | |||
String url = UriComponentsBuilder.fromHttpUrl(CommonConfig.airportURL + SystemConstant.API_AIRPORT_MSG_BY_AIRPORT_ID) | |||
.queryParam("airportIds", airportIds) | |||
.queryParam("tenantCode", tenantCode) | |||
.toUriString(); | |||
JsonResult jsonResult; | |||
try { | |||
jsonResult = restTemplate.getForObject(url, JsonResult.class); | |||
} catch (Exception e) { | |||
log.info("调用机场平台,查询机场信息异常,url:{}", url); | |||
return null; | |||
} | |||
if (jsonResult.getCode() != 0) { | |||
log.info("调用机场平台,查询机场信息,失败,jsonResult:{}", jsonResult.getMsg()); | |||
return null; | |||
} | |||
List<AirportInfoVo> airPortStatusVOList = JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirportInfoVo.class); | |||
return airPortStatusVOList; | |||
} | |||
} |
@@ -0,0 +1,108 @@ | |||
package com.tuoheng.admin.vo; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/7/27 | |||
*/ | |||
@Data | |||
@NoArgsConstructor | |||
public class AirportInfoVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 机场id | |||
*/ | |||
private String id; | |||
/** | |||
* 机场代码 | |||
*/ | |||
private String code; | |||
/** | |||
* 机场名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 机场图片 | |||
*/ | |||
private String image; | |||
/** | |||
* 机场外部监控地址 | |||
*/ | |||
private String externalMonitorUrl; | |||
/** | |||
* 机场外部监控FLV地址 | |||
*/ | |||
private String flvExternalMonitorUrl; | |||
/** | |||
* 机场内部监控地址 | |||
*/ | |||
private String internalMonitorUrl; | |||
/** | |||
* 覆盖范围(km) | |||
*/ | |||
private String coverage; | |||
/** | |||
* 排序 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 无人机id | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 无人机名称 | |||
*/ | |||
private String groundStationUrl; | |||
/** | |||
* 创建人 | |||
*/ | |||
private String createUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private String createTime; | |||
/** | |||
* 修改人 | |||
*/ | |||
private String updateUser; | |||
/** | |||
* 修改时间 | |||
*/ | |||
private String updateTime; | |||
} |
@@ -0,0 +1,56 @@ | |||
package com.tuoheng.admin.vo; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* 机场线路视图Vo | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-23 | |||
*/ | |||
@Data | |||
@NoArgsConstructor | |||
public class AirportLineVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 航线id | |||
*/ | |||
private Integer id; | |||
/** | |||
* 航线名称 | |||
*/ | |||
private String fileName; | |||
/** | |||
* 航线地址 | |||
*/ | |||
private String fileUrl; | |||
/** | |||
* 机场ID | |||
*/ | |||
private String airportId; | |||
/** | |||
* 机场名称 | |||
*/ | |||
private String airportName; | |||
/** | |||
* 航线类型:1,航点航线;2,指点航线;3,指面航线 | |||
*/ | |||
private String type; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
} |
@@ -0,0 +1,81 @@ | |||
package com.tuoheng.admin.vo.airport; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* 机场平台创建任务视图Vo | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-07-27 | |||
*/ | |||
@NoArgsConstructor | |||
@Data | |||
public class AirPortCreateTaskVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 任务ID(执行任务时传此ID) | |||
*/ | |||
private Integer id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 任务编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 机场ID | |||
*/ | |||
private Integer aid; | |||
/** | |||
* 机场名称 | |||
*/ | |||
private String aname; | |||
/** | |||
* 执飞无人机ID | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 航线文件ID | |||
*/ | |||
private Integer airlineFileId; | |||
/** | |||
* 任务状态:1,待执行;2,执行中;3,执行完成 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 任务来源 | |||
*/ | |||
private String taskSource; | |||
/** | |||
* 任务来源名称 | |||
*/ | |||
private String taskSourceName; | |||
/** | |||
* 执行类型:1,单次;2,每天; 5,每周;6,每月 | |||
*/ | |||
private Integer type; | |||
} |
@@ -0,0 +1,32 @@ | |||
package com.tuoheng.admin.vo.airport; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* 航线坐标视图Vo | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-02-07 | |||
*/ | |||
@NoArgsConstructor | |||
@Data | |||
public class AirPortLineLocationVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 经度 | |||
*/ | |||
private String lon; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String lat; | |||
} |
@@ -0,0 +1,28 @@ | |||
package com.tuoheng.admin.vo.airport; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* 机场状态视图Vo | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-02-07 | |||
*/ | |||
@NoArgsConstructor | |||
@Data | |||
public class AirPortStatusVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
private Integer airportId; | |||
private String airportName; | |||
private String msg; | |||
} |
@@ -0,0 +1,158 @@ | |||
package com.tuoheng.admin.vo.cycle; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* 周期任务 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-08-25 | |||
*/ | |||
@Data | |||
public class InspectionCycleVo extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 部门ID | |||
*/ | |||
private String deptId; | |||
/** | |||
* 部门名称 | |||
*/ | |||
private String deptName; | |||
/** | |||
* 任务编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 任务名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 巡检机场id | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 巡检机场名称 | |||
*/ | |||
private String airportName; | |||
/** | |||
* 航线id | |||
*/ | |||
private Integer airportLineId; | |||
/** | |||
* 航线id | |||
*/ | |||
private String airportLineName; | |||
/** | |||
* 航线长度 | |||
*/ | |||
private Double airportLineLength; | |||
/** | |||
* 航线url | |||
*/ | |||
private String airportLineFileUrl; | |||
/** | |||
* 巡检无人机id | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 执行类型:1,单次;2,每天; 5,每周;6,每月 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 单次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date singleTime; | |||
/** | |||
* 每天执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date everydayTime; | |||
/** | |||
* 循环执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "HH:mm:ss") | |||
@JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") | |||
private Date cycleTime; | |||
/** | |||
* 循环下次执行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date cycleNextTime; | |||
/** | |||
* 循环频率:1~7,每周;1~31,每月;多个以引文逗号分隔 | |||
*/ | |||
private String cycleFrequency; | |||
/** | |||
* 循环开始时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
private Date cycleStartTime; | |||
/** | |||
* 循环结束时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
private Date cycleEndTime; | |||
/** | |||
* 是否启用: 1:禁用; 1:启用(默认); | |||
*/ | |||
private Integer isEnable; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 执行次数 | |||
*/ | |||
private Integer executCount; | |||
/** | |||
* 创建人名称 | |||
*/ | |||
private String createUserName; | |||
/** | |||
* 更新人名称 | |||
*/ | |||
private String updateUsername; | |||
} |
@@ -0,0 +1,79 @@ | |||
<?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.InspectionCycleMapper"> | |||
<resultMap id="InspectionCycleResult" type="com.tuoheng.admin.entity.InspectionCycle" > | |||
<result property="id" column="id" /> | |||
<result property="tenantId" column="tenant_id" /> | |||
<result property="deptId" column="dept_id" /> | |||
<result property="code" column="code" /> | |||
<result property="name" column="name" /> | |||
<result property="type" column="type" /> | |||
<result property="airportId" column="airport_id" /> | |||
<result property="droneId" column="drone_id" /> | |||
<result property="airportLineId" column="airport_line_id" /> | |||
<result property="airportLineLength" column="airport_line_length" /> | |||
<result property="singleTime" column="single_time" /> | |||
<result property="everydayTime" column="everyday_time" /> | |||
<result property="cycleTime" column="cycle_time" /> | |||
<result property="cycleNextTime" column="cycle_next_time" /> | |||
<result property="cycleFrequency" column="cycle_frequency" /> | |||
<result property="cycleStartTime" column="cycle_start_time" /> | |||
<result property="cycleEndTime" column="cycle_end_time" /> | |||
<result property="isEnable" column="is_enable" /> | |||
<result property="note" column="note" /> | |||
<result property="createUser" column="create_user" /> | |||
<result property="createTime" column="create_time" /> | |||
<result property="updateUser" column="update_user" /> | |||
<result property="updateTime" column="update_time" /> | |||
<result property="mark" column="mark" /> | |||
</resultMap> | |||
<resultMap id="ForeignResult" type="com.tuoheng.admin.entity.InspectionCycle" extends="InspectionCycleResult"> | |||
<result property="createUserName" column="create_user_name" /> | |||
</resultMap> | |||
<sql id="Base_Column_List"> | |||
t.id, t.tenant_id, t.dept_id, t.code, t.name, t.airport_id, t.airport_line_id, t.airport_line_length, t.drone_id, t.type, | |||
t.single_time, t.everyday_time, t.cycle_time, t.cycle_next_time, t.cycle_frequency, t.cycle_start_time, t.cycle_end_time, | |||
t.is_enable, t.note, t.create_user, t.create_time, t.update_user, t.update_time, t.mark | |||
</sql> | |||
<select id="selectPageList" parameterType="com.tuoheng.admin.request.cycle.QueryInspectionCyclePageListRequest" resultMap="ForeignResult"> | |||
select <include refid="Base_Column_List"/>, u.realname as create_user_name | |||
from th_inspection_cycle t | |||
left join th_user u on u.id = t.create_user | |||
<where> | |||
<if test="1 == 1"> and t.mark = 1 </if> | |||
<if test="request.code != null and request.code != ''"> and t.code like concat('%', #{request.code}, '%') </if> | |||
<if test="request.name != null and request.name != ''"> and t.name like concat('%', #{request.name}, '%') </if> | |||
<if test="request.tenantId != null and request.tenantId != ''"> and t.tenant_id = #{request.tenantId} </if> | |||
<if test="request.airportId != null and request.airportId != 0"> and t.airport_id = #{request.airportId} </if> | |||
<if test="request.airportLineId != null and request.airportLineId != 0"> and t.airport_line_id = #{request.airportLineId} </if> | |||
<if test="request.isEnable != null"> and t.is_enable = #{request.isEnable} </if> | |||
<if test="request.status != null and request.status == 0">and now() < t.cycle_start_time</if> | |||
<if test="request.status != null and request.status == 1">and now() >= t.cycle_start_time and now() <= t.cycle_end_time</if> | |||
<if test="request.status != null and request.status == 2">and now() > t.cycle_end_time</if> | |||
<if test="request.deptIdList != null and request.deptIdList.size() > 0"> | |||
and t.dept_id in | |||
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")"> | |||
#{deptId} | |||
</foreach> | |||
</if> | |||
</where> | |||
order by t.create_time desc | |||
</select> | |||
<update id="updateEnable" parameterType="com.tuoheng.admin.entity.InspectionCycle"> | |||
update th_inspection_cycle | |||
<trim prefix="SET" suffixOverrides=","> | |||
<if test="isEnable != null"> is_enable = #{isEnable}, </if> | |||
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser},</if> | |||
<if test="updateTime != null"> update_time = #{updateTime},</if> | |||
</trim> | |||
where id = #{id} | |||
</update> | |||
</mapper> |