@@ -32,13 +32,10 @@ public class Question extends BaseEntity implements Serializable { | |||
public Question(int type){ | |||
if(type== UpdateOrCreateEnum.CREATE.getCode()){ | |||
setCreateUser(ShiroUtils.getUserId()); | |||
setCreateTime(new Date()); | |||
setMark(MarkTypeEnum.VALID.getCode()); | |||
} | |||
setUpdateUser(ShiroUtils.getUserId()); | |||
setUpdateTime(new Date()); | |||
setTenantId(ShiroUtils.getTenantId()); | |||
} | |||
/** |
@@ -28,11 +28,9 @@ public class ThInspection extends BaseEntity implements Serializable { | |||
public ThInspection(int type){ | |||
if(type== UpdateOrCreateEnum.CREATE.getCode()){ | |||
setCreateUser(ShiroUtils.getUserId()); | |||
setCreateTime(new Date()); | |||
setMark(MarkTypeEnum.VALID.getCode()); | |||
} | |||
setUpdateUser(ShiroUtils.getUserId()); | |||
setUpdateTime(new Date()); | |||
} | |||
@@ -55,7 +53,7 @@ public class ThInspection extends BaseEntity implements Serializable { | |||
/** | |||
* 地面站标识 | |||
*/ | |||
private Integer hostIp; | |||
private String hostIp; | |||
/** | |||
@@ -77,8 +75,6 @@ public class ThInspection extends BaseEntity implements Serializable { | |||
/** | |||
* 飞行时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private String timestamp; | |||
private Long flyTime; | |||
} |
@@ -32,11 +32,9 @@ public class ThMission extends BaseEntity implements Serializable { | |||
public ThMission(int type){ | |||
if(type== UpdateOrCreateEnum.CREATE.getCode()){ | |||
setCreateUser(ShiroUtils.getUserId()); | |||
setCreateTime(new Date()); | |||
setMark(MarkTypeEnum.VALID.getCode()); | |||
} | |||
setUpdateUser(ShiroUtils.getUserId()); | |||
setUpdateTime(new Date()); | |||
} | |||
@@ -38,10 +38,8 @@ public class InspectionRequest implements Serializable { | |||
private String hostIp; | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@ApiModelProperty(value = "飞行时间") | |||
@NotNull(message = "飞行时间不能为空!") | |||
private String timestamp; | |||
private Long flyTime; | |||
} |
@@ -30,8 +30,6 @@ public class InspectionVO implements Serializable { | |||
@ApiModelProperty(value = "纬度") | |||
private String lat; | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
@ApiModelProperty(value = "飞行时间") | |||
private String timestamp; | |||
private Long flyTime; | |||
} |
@@ -7,9 +7,4 @@ import org.apache.ibatis.annotations.Param; | |||
import java.util.List; | |||
public interface ThMissionMapper extends BaseMapper<ThMission> { | |||
/** | |||
* 批量删除巡检任务 | |||
* | |||
*/ | |||
int deleteBatch(@Param("idList") List<Integer> idList, @Param("updateUser") Integer updateUser, @Param("tenantId") Integer tenantId); | |||
} |
@@ -20,7 +20,7 @@ public interface IThInspectionService extends IBaseService<ThInspection> { | |||
List<InspectionVO> track(Integer id); | |||
Integer track(InspectionRequest inspectionRequest); | |||
Integer track(InspectionRequest inspectionRequest) throws ServiceException; | |||
List<AirPortVO> airport() throws ServiceException; | |||
@@ -72,6 +72,8 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi | |||
public Integer addMission(MissionRequest addThMissionRequest) throws ServiceException { | |||
ThMission tm=new ThMission(UpdateOrCreateEnum.CREATE.getCode()); | |||
tm.setCreateUser(ShiroUtils.getUserId()); | |||
tm.setUpdateUser(ShiroUtils.getUserId()); | |||
BeanUtils.copyProperties(addThMissionRequest,tm); | |||
//任务名称不能重复 |
@@ -206,7 +206,7 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
return inspectionMapper.selectList(new LambdaQueryWrapper<ThInspection>() | |||
.eq(ThInspection::getMissionId, mission.getId()) | |||
.eq(ThInspection::getMark, MarkTypeEnum.VALID.getCode()) | |||
.orderByDesc(ThInspection::getTimestamp)); | |||
.orderByDesc(ThInspection::getUpdateTime)); | |||
} | |||
private List<Question> getQuestionList(ThMission mission, List<CallbackRequest.QuestionFilesDTO> questionFiles, List<ThInspection> flightDataList) { | |||
@@ -249,14 +249,10 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!"); | |||
} | |||
List<ThInspection> inspectionData =new ArrayList<>(); | |||
try { | |||
for (ThInspection thInspection : inspectionList) { | |||
if(dateformat.parse(thInspection.getTimestamp()).getTime() <= time){ | |||
inspectionData.add(thInspection); | |||
} | |||
for (ThInspection thInspection : inspectionList) { | |||
if(thInspection.getUpdateTime().getTime() <= time){ | |||
inspectionData.add(thInspection); | |||
} | |||
} catch (ParseException e) { | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"巡检时间格式错误!"); | |||
} | |||
if (CollectionUtils.isEmpty(inspectionData)) { | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!"); |
@@ -8,6 +8,8 @@ import com.tuoheng.admin.entity.domain.ThInspection; | |||
import com.tuoheng.admin.entity.domain.ThMission; | |||
import com.tuoheng.admin.entity.request.InspectionRequest; | |||
import com.tuoheng.admin.entity.vo.*; | |||
import com.tuoheng.admin.enums.MarkTypeEnum; | |||
import com.tuoheng.admin.enums.TaskStatusEnum; | |||
import com.tuoheng.admin.enums.UpdateOrCreateEnum; | |||
import com.tuoheng.admin.mapper.ThInspectionMapper; | |||
import com.tuoheng.admin.mapper.ThMissionMapper; | |||
@@ -52,7 +54,7 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
public List<InspectionVO> track(Integer id) { | |||
LambdaQueryWrapper<ThInspection> lambdaQueryWrapper=new LambdaQueryWrapper<>(); | |||
lambdaQueryWrapper.eq(ThInspection::getMissionId,id).orderByDesc(ThInspection::getTimestamp); | |||
lambdaQueryWrapper.eq(ThInspection::getMissionId,id).orderByDesc(ThInspection::getUpdateTime); | |||
//lambdaQueryWrapper.eq(ThInspection::getTenantId, ShiroUtils.getTenantId()); | |||
List<InspectionVO> result=new ArrayList<>(); | |||
List<ThInspection> thInspections = inspectionMapper.selectList(lambdaQueryWrapper); | |||
@@ -66,9 +68,20 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
} | |||
@Override | |||
public Integer track(InspectionRequest inspectionRequest) { | |||
public Integer track(InspectionRequest inspectionRequest) throws ServiceException { | |||
ThInspection inspection=new ThInspection(UpdateOrCreateEnum.CREATE.getCode()); | |||
BeanUtils.copyProperties(inspectionRequest,inspection); | |||
//获取当前巡检正在执行的任务 | |||
List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>() | |||
.eq(ThMission::getInspectionLine, inspectionRequest.getInspectionId()) | |||
.eq(ThMission::getStatus, TaskStatusEnum.FLIGHT.getCode()) | |||
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(ThMission::getExecutionStartTime)); | |||
if(ObjectUtil.isEmpty(thMissions) || thMissions.size()==0){ | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"没有正在飞行的任务!"); | |||
} | |||
ThMission mission = thMissions.get(0); | |||
inspection.setMissionId(mission.getId()); | |||
inspection.setTenantId(mission.getTenantId()); | |||
inspectionMapper.insert(inspection); | |||
return inspection.getId(); | |||
} | |||
@@ -90,8 +103,8 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
public List<AirLineVO> airLine(Integer droneId) throws ServiceException { | |||
//这边需要配置到yml文件里面 | |||
String url = CommonConfig.airportUrl +"/api/airportInterface/airportList"; | |||
String param="page=1&limit=10&droneId="+droneId; | |||
String url = CommonConfig.airportUrl +"/api/airportInterface/taskByDroneId"; | |||
String param="page=1&limit=100&droneId="+droneId; | |||
String airPortStr = HttpUtils.sendGet(url, param); | |||
JsonResult<AirLineVO> jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
if(ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0)) { |
@@ -1,16 +1,4 @@ | |||
<?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.ThMissionMapper"> | |||
<!-- 批量删除 --> | |||
<update id="deleteBatch"> | |||
update th_mission | |||
set mark = 0, | |||
update_user = #{updateUser} | |||
where id in | |||
<foreach collection="idList" item="id" open="(" close=")" separator=","> | |||
#{id} | |||
</foreach> | |||
and tenant_id = #{tenantId} | |||
</update> | |||
</mapper> |