#更新计算累计路程相关
This commit is contained in:
@@ -24,6 +24,7 @@ import com.maibu.core.business.DeviceTaskPlanRule;
|
||||
import com.maibu.core.business.WorkRecord;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.core.business.dto.DeviceTaskCommandDTO;
|
||||
import com.maibu.core.domain.entity.SysRegion;
|
||||
import com.maibu.core.domain.entity.SysSite;
|
||||
import com.maibu.core.domain.model.LoginUser;
|
||||
import com.maibu.core.enums.DeviceTaskStaus;
|
||||
@@ -34,6 +35,7 @@ import com.maibu.dto.DeviceWorkStatisticsDTO;
|
||||
import com.maibu.mapper.DeviceMapper;
|
||||
import com.maibu.mapper.DevicePlanMapper;
|
||||
import com.maibu.mapper.DevicePlanTaskMapper;
|
||||
import com.maibu.mapper.SysRegionMapper;
|
||||
import com.maibu.mapper.SysSiteMapper;
|
||||
import com.maibu.mapper.WorkRecordMapper;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
@@ -63,6 +65,9 @@ public class DeviceTaskService {
|
||||
@Autowired
|
||||
private SysSiteMapper sysSiteMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRegionMapper sysRegionMapper;
|
||||
|
||||
public int insertOrUpdate(DevicePlan devicePlan, LoginUser loginUser) {
|
||||
Long id = devicePlan.getId();
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(devicePlan.getOrgId(), devicePlan.getSiteId());
|
||||
@@ -477,6 +482,35 @@ public class DeviceTaskService {
|
||||
return task.getId();
|
||||
}
|
||||
|
||||
public Long createRegionDeviceTask(DeviceTaskCommandDTO dto, String username) {
|
||||
LambdaQueryWrapper<SysRegion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysRegion::getId, dto.getRegionId());
|
||||
SysRegion region = sysRegionMapper.selectOne(queryWrapper);
|
||||
|
||||
if (region == null || region.getBindRoute() == null) {
|
||||
throw new RuntimeException("区域未绑定线路!");
|
||||
}
|
||||
DevicePlanTask task = new DevicePlanTask();
|
||||
task.setRouteId(region.getBindRoute());
|
||||
task.setOrgId(dto.getOrgId());
|
||||
task.setSiteId(dto.getSiteId());
|
||||
task.setTaskStaus(DeviceTaskStaus.NEW);
|
||||
task.setDeviceId(dto.getDeviceId());
|
||||
task.setCreateBy(username);
|
||||
task.setCreateTime(LocalDateTime.now());
|
||||
task.setStartTime(dto.getStartTime());
|
||||
devicePlanTaskMapper.saveOrUpdate(task);
|
||||
if (dto.getOrgId() == null) {
|
||||
SysSite site = sysSiteMapper.selectById(dto.getSiteId());
|
||||
if (site != null) {
|
||||
dto.setOrgId(site.getOrgId());
|
||||
}
|
||||
}
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(task.getOrgId(), task.getSiteId());
|
||||
siteMemory.addDevicePlanPrepare(task);
|
||||
return task.getId();
|
||||
}
|
||||
|
||||
public boolean cancelTask(DeviceTaskCommandDTO dto) throws MqttException {
|
||||
String deviceId = dto.getDeviceId();
|
||||
DevicePlanTask devicePlanTask = null;
|
||||
@@ -489,9 +523,9 @@ public class DeviceTaskService {
|
||||
}
|
||||
NettyDevice device = deviceSessionManager.getDevice(deviceId);
|
||||
if (device != null && device.getTask() != null) {
|
||||
if(dto.isForceCancel()){
|
||||
if (dto.isForceCancel()) {
|
||||
return device.canceledTask();
|
||||
}else {
|
||||
} else {
|
||||
return device.cancelingTask();
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user