|
|
@ -154,12 +154,7 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
@Override |
|
|
|
public Boolean add( DeviceQrtzDTO deviceQrtzDTO) { |
|
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(deviceQrtzDTO.getDeviceQrtzDates())){ |
|
|
|
deviceQrtzDTO.getDeviceQrtzDates().forEach(e->{ |
|
|
|
e.setQrtzId(deviceQrtzDTO.getId()); |
|
|
|
deviceQrtzDateMapper.insert(e); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
DeviceQrtzEntity entity = new DeviceQrtzEntity(); |
|
|
|
entity.setDeviceSn(deviceQrtzDTO.getDeviceSn()); |
|
|
|
entity.setName(deviceQrtzDTO.getName()); |
|
|
@ -169,7 +164,14 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
entity.setNickName(loginUser.getNickname()); |
|
|
|
entity.setCreateDept(loginUser.getDeptId()); |
|
|
|
entity.setDeptName(loginUser.getDeptName()); |
|
|
|
return deviceQrtzMapper.insert(entity)>0; |
|
|
|
int insert = deviceQrtzMapper.insert(entity); |
|
|
|
if(!CollectionUtils.isEmpty(deviceQrtzDTO.getDeviceQrtzDates())){ |
|
|
|
deviceQrtzDTO.getDeviceQrtzDates().forEach(e->{ |
|
|
|
e.setQrtzId(entity.getId()); |
|
|
|
deviceQrtzDateMapper.insert(e); |
|
|
|
}); |
|
|
|
} |
|
|
|
return insert>0; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -190,7 +192,7 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
int sort=1; |
|
|
|
Long qrtzId = Convert.toLong(map.get("qrtzId")); |
|
|
|
String deviceSn = Convert.toStr(map.get("deviceSn")); |
|
|
|
Date execDate = Convert.toDate(map.get("execDate")); |
|
|
|
Date execDate = Convert.toDate(map.get("execDate"),new Date()); |
|
|
|
String waylineIdStr = Convert.toStr(map.get("waylineIdStr")); |
|
|
|
List<DeviceQrtzFileEntity> selectList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>() |
|
|
|
.eq("qrtz_id", qrtzId).eq("exec_date",execDate).orderByDesc("sort")); |
|
|
@ -282,7 +284,6 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
if (RedisOpsUtils.checkExist(device.getDeviceSn())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
RedisOpsUtils.setWithExpire(device.getDeviceSn(), device, 180); |
|
|
|
List<DeviceQrtzEntity> qrtzEntityList = deviceQrtzMapper.selectList(new LambdaQueryWrapper<DeviceQrtzEntity>().eq(DeviceQrtzEntity::getDeviceSn, device.getDeviceSn()).eq(DeviceQrtzEntity::getStatus, DeviceQrtzConstants.QRTZ_STATUS_1)); |
|
|
|
if(!qrtzEntityList.isEmpty()){ |
|
|
|
// 获取当前日期
|
|
|
@ -292,14 +293,17 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
DateTimeFormatter formatterS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
// 格式化当前日期
|
|
|
|
String formattedDate = currentDate.format(formatter); |
|
|
|
List<DeviceQrtzFileEntity> qrtzFileEntityList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>().eq("device_sn", qrtzEntityList.get(0).getDeviceSn()).eq("exec_date", formattedDate).eq("qrtz_id",qrtzEntityList.get(0).getId()).eq("status", DeviceQrtzConstants.QRTZ_FILE_STATUS_1).orderByAsc("sort")); |
|
|
|
if (!qrtzFileEntityList.isEmpty()) { |
|
|
|
DeviceQrtzFileEntity deviceQrtzFileEntity = qrtzFileEntityList.get(0); |
|
|
|
List<DeviceQrtzDateEntity> qrtzDateEntityList = deviceQrtzDateMapper.listDeviceQrtzDateByQrtzAndDate(deviceQrtzFileEntity.getQrtzId()); |
|
|
|
for (DeviceQrtzEntity deviceQrtzEntity : qrtzEntityList) { |
|
|
|
List<DeviceQrtzDateEntity> qrtzDateEntityList = deviceQrtzDateMapper.listDeviceQrtzDateByQrtzAndDate(deviceQrtzEntity.getId()); |
|
|
|
//判断下是否有时间
|
|
|
|
if(!qrtzDateEntityList.isEmpty()){ |
|
|
|
// 获取当前日期和时间
|
|
|
|
//遍历,当前时间是否在范围内
|
|
|
|
for (DeviceQrtzDateEntity qrtzDate : qrtzDateEntityList) { |
|
|
|
//在里面执行航线,进行无人机飞行
|
|
|
|
if (!currentDate.isBefore(Convert.toLocalDateTime(qrtzDate.getStartDate())) && !currentDate.isAfter(Convert.toLocalDateTime(qrtzDate.getEndDate()))) { |
|
|
|
List<DeviceQrtzFileEntity> qrtzFileEntityList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>().eq("device_sn",deviceQrtzEntity.getDeviceSn()).eq("exec_date", formattedDate).eq("qrtz_id",deviceQrtzEntity.getId()).eq("status", DeviceQrtzConstants.QRTZ_FILE_STATUS_1).orderByAsc("sort")); |
|
|
|
if(!qrtzFileEntityList.isEmpty()){ |
|
|
|
DeviceQrtzFileEntity deviceQrtzFileEntity = qrtzFileEntityList.get(0); |
|
|
|
//获取航线数据发送之类
|
|
|
|
WaylineFileEntity waylineFileEntity = waylineFileMapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>().eq(WaylineFileEntity::getWaylineId, deviceQrtzFileEntity.getWaylineId())); |
|
|
|
if (waylineFileEntity == null) { |
|
|
@ -334,6 +338,8 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
} |
|
|
|
deviceQrtzFileEntity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_0); |
|
|
|
deviceQrtzFileMapper.updateById(deviceQrtzFileEntity); |
|
|
|
RedisOpsUtils.setWithExpire(device.getDeviceSn(), device, 180); |
|
|
|
return; |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
@ -345,6 +351,8 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|