|
|
@ -4,13 +4,13 @@ import cn.hutool.core.convert.Convert; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import org.dromara.common.core.constant.DeviceQrtzConstants; |
|
|
|
import org.dromara.common.core.utils.MapstructUtils; |
|
|
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|
|
|
import org.dromara.common.satoken.utils.LoginHelper; |
|
|
|
import org.dromara.sample.manage.mapper.IDeviceMapper; |
|
|
|
|
|
|
|
import org.dromara.sample.manage.mapper.IDeviceQrtzDateMapper; |
|
|
|
import org.dromara.sample.manage.mapper.IDeviceQrtzFileMapper; |
|
|
|
import org.dromara.sample.manage.mapper.IDeviceQrtzMapper; |
|
|
@ -21,9 +21,9 @@ import org.dromara.sample.manage.model.entity.DeviceQrtzDateEntity; |
|
|
|
import org.dromara.sample.manage.model.entity.DeviceQrtzEntity; |
|
|
|
import org.dromara.sample.manage.model.entity.DeviceQrtzFileEntity; |
|
|
|
import org.dromara.sample.manage.service.IDeviceQrtzDateService; |
|
|
|
import org.dromara.sample.manage.service.IDeviceQrtzFileService; |
|
|
|
|
|
|
|
import org.dromara.sample.manage.service.IDeviceQrtzService; |
|
|
|
import org.dromara.sample.manage.service.IDeviceService; |
|
|
|
|
|
|
|
import org.dromara.sample.wayline.mapper.IWaylineFileMapper; |
|
|
|
import org.dromara.sample.wayline.model.entity.WaylineFileEntity; |
|
|
|
import org.dromara.system.api.model.LoginUser; |
|
|
@ -32,6 +32,10 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
@ -174,29 +178,37 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean addFileList(DeviceQrtzFileDTO deviceQrtzFileDTO) { |
|
|
|
public Boolean addFileList(Map<String,Object>map) { |
|
|
|
int sort=1; |
|
|
|
Long qrtzId = Convert.toLong(map.get("qrtzId")); |
|
|
|
Date execDate = Convert.toDate(map.get("execDate")); |
|
|
|
String waylineIdStr = Convert.toStr(map.get("waylineIdStr")); |
|
|
|
List<DeviceQrtzFileEntity> selectList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>() |
|
|
|
.eq("qrtz_id", deviceQrtzFileDTO.getQrtzId()).eq("exec_date",deviceQrtzFileDTO.getExecDate()) |
|
|
|
.orderByDesc("sort")); |
|
|
|
.eq("qrtz_id", qrtzId).eq("exec_date",execDate).orderByDesc("sort")); |
|
|
|
if(!CollectionUtils.isEmpty(selectList)){ |
|
|
|
Integer number =selectList.get(0).getSort(); |
|
|
|
if(ObjectUtil.isNotEmpty(number)){ |
|
|
|
sort=number+1; |
|
|
|
} |
|
|
|
} |
|
|
|
for (String waylineId : deviceQrtzFileDTO.getWaylineIdStr().split(",")) { |
|
|
|
for (String waylineId : waylineIdStr.split(",")) { |
|
|
|
DeviceQrtzFileEntity entity = new DeviceQrtzFileEntity(); |
|
|
|
QueryWrapper<WaylineFileEntity> queryWrapper = new QueryWrapper<WaylineFileEntity>().eq("wayline_id", waylineId); |
|
|
|
WaylineFileEntity fileEntity = waylineFileMapper.selectOne(queryWrapper); |
|
|
|
entity.setQrtzId(deviceQrtzFileDTO.getQrtzId()); |
|
|
|
entity.setDeviceSn(fileEntity.getDeviceSn()); |
|
|
|
entity.setQrtzId(qrtzId); |
|
|
|
entity.setWaylineId(waylineId); |
|
|
|
entity.setWaylineName(fileEntity.getName()); |
|
|
|
try { |
|
|
|
entity.setSort(sort); |
|
|
|
entity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_1); |
|
|
|
entity.setExecDate(deviceQrtzFileDTO.getExecDate()); |
|
|
|
|
|
|
|
entity.setExecDate(execDate); |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
entity.setCreateBy(loginUser.getUserId()); |
|
|
|
entity.setCreateTime(new Date()); |
|
|
|
entity.setNickName(loginUser.getNickname()); |
|
|
|
entity.setCreateDept(loginUser.getDeptId()); |
|
|
|
entity.setDeptName(loginUser.getDeptName()); |
|
|
|
sort=sort+1; |
|
|
|
deviceQrtzFileMapper.insert(entity); |
|
|
|
}catch (Exception e){ |
|
|
@ -220,6 +232,12 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
entity.setSort(e.getSort()); |
|
|
|
entity.setStatus(DeviceQrtzConstants.QRTZ_FILE_STATUS_1); |
|
|
|
entity.setExecDate(Convert.toDate(endDate)); |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
entity.setCreateBy(loginUser.getUserId()); |
|
|
|
entity.setCreateTime(new Date()); |
|
|
|
entity.setNickName(loginUser.getNickname()); |
|
|
|
entity.setCreateDept(loginUser.getDeptId()); |
|
|
|
entity.setDeptName(loginUser.getDeptName()); |
|
|
|
return entity; |
|
|
|
}).toList(); |
|
|
|
return deviceQrtzFileMapper.insert(entityList).size()>0; |
|
|
@ -236,4 +254,40 @@ public class DeviceQrtzServiceImpl implements IDeviceQrtzService { |
|
|
|
entity.setId(id); |
|
|
|
return deviceQrtzFileMapper.updateById(entity)>0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public DeviceQrtzFileEntity getDeviceQrtzFileEntity(String deviceSn) { |
|
|
|
if(StrUtil.isNotEmpty(deviceSn)){ |
|
|
|
// 获取当前日期
|
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
|
|
|
|
|
// 定义日期格式
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
|
|
|
|
// 格式化当前日期
|
|
|
|
String formattedDate = currentDate.format(formatter); |
|
|
|
List<DeviceQrtzFileEntity> qrtzFileEntityList = deviceQrtzFileMapper.selectList(new QueryWrapper<DeviceQrtzFileEntity>().eq("device_sn", deviceSn).eq("exec_date", formattedDate).eq("status", DeviceQrtzConstants.QRTZ_FILE_STATUS_1).orderByAsc("sort")); |
|
|
|
if(!qrtzFileEntityList.isEmpty()){ |
|
|
|
DeviceQrtzFileEntity deviceQrtzFileEntity = qrtzFileEntityList.get(0); |
|
|
|
List<DeviceQrtzDateEntity> qrtzDateEntityList = deviceQrtzDateMapper.listDeviceQrtzDateByQrtzAndDate(deviceQrtzFileEntity.getQrtzId()); |
|
|
|
if(!qrtzDateEntityList.isEmpty()){ |
|
|
|
// 获取当前日期和时间
|
|
|
|
LocalDateTime currentDateTime = LocalDateTime.now(); |
|
|
|
for (DeviceQrtzDateEntity qrtzDate : qrtzDateEntityList) { |
|
|
|
if (!currentDateTime.isBefore(Convert.toLocalDateTime(qrtzDate.getStartDate())) && !currentDateTime.isAfter(Convert.toLocalDateTime(qrtzDate.getEndDate()))){ |
|
|
|
//获取航线数据发送之类
|
|
|
|
//获取是否是工单航线,是修改状态
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|