Browse Source

rev:自动创建指令

master
gengby 5 months ago
parent
commit
ce1b322793
  1. 3
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java
  2. 23
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  3. 28
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

3
acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java

@ -60,6 +60,9 @@ public interface TaskService {
List<TaskDto> queryAll(String whereJson); List<TaskDto> queryAll(String whereJson);
List<TaskDto> queryAllFromCacheByStatus(String task_status);
/** /**
* 查询所有数据不分页 * 查询所有数据不分页
* *

23
acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -113,6 +113,16 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return list; return list;
} }
@Override
public List<TaskDto> queryAllFromCacheByStatus(String task_status){
return Optional.ofNullable(this.tasks)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(taskDto -> taskDto.getTask_status().equals(task_status))
.sorted(Comparator.comparing(TaskDto::getCreate_time))
.collect(Collectors.toList());
}
@Override @Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) { public Map<String, Object> queryAll(Map whereJson, Pageable page) {
@ -747,8 +757,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
taskFeedbackService.update(feefbackdto); taskFeedbackService.update(feefbackdto);
} }
} else { } else {
int status = body.getStatus(); int status = 0;
JSONObject jo = JSONObject.parseObject(body.body()); JSONObject jo = new JSONObject();
if (body == null){
status = 400;
}else {
status = body.getStatus();
jo = JSONObject.parseObject(body.body());
}
if (ObjectUtil.isEmpty(feefbackdto)) { if (ObjectUtil.isEmpty(feefbackdto)) {
feefbackdto = new TaskFeedbackDto(); feefbackdto = new TaskFeedbackDto();
feefbackdto.setTask_id(entity.getTask_id()); feefbackdto.setTask_id(entity.getTask_id());
@ -756,7 +773,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
feefbackdto.setTask_status(entity.getTask_status()); feefbackdto.setTask_status(entity.getTask_status());
feefbackdto.setVehicle_type(entity.getVehicle_type()); feefbackdto.setVehicle_type(entity.getVehicle_type());
feefbackdto.setVehicle_code(entity.getVehicle_code()); feefbackdto.setVehicle_code(entity.getVehicle_code());
feefbackdto.setError_code(String.valueOf(body.getStatus())); feefbackdto.setError_code(String.valueOf(status));
feefbackdto.setStart_device_code(entity.getStart_device_code()); feefbackdto.setStart_device_code(entity.getStart_device_code());
feefbackdto.setStart_point_code(entity.getNext_point_code()); feefbackdto.setStart_point_code(entity.getNext_point_code());
feefbackdto.setNext_device_code(entity.getNext_device_code()); feefbackdto.setNext_device_code(entity.getNext_device_code());

28
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

@ -42,8 +42,7 @@ public class AutoCreateInst {
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
List<TaskDto> list = taskserver.queryAll("task_status = '0' ORDER BY create_time ASC"); List<TaskDto> list = taskserver.queryAllFromCacheByStatus("0");
List<TaskDto> list2 = taskserver.queryAll("task_status = '1' ORDER BY create_time ASC");
Map<String, List<TaskDto>> collect = list.stream().sorted(Comparator.comparing(TaskDto::getCreate_time).thenComparing(TaskDto::getTask_code)) Map<String, List<TaskDto>> collect = list.stream().sorted(Comparator.comparing(TaskDto::getCreate_time).thenComparing(TaskDto::getTask_code))
.collect(Collectors.groupingBy(TaskDto::getPriority)); .collect(Collectors.groupingBy(TaskDto::getPriority));
TreeMap<String, List<TaskDto>> treeMap = new TreeMap<>(new Comparator<String>() { TreeMap<String, List<TaskDto>> treeMap = new TreeMap<>(new Comparator<String>() {
@ -80,8 +79,8 @@ public class AutoCreateInst {
} }
} }
if (flag) { if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败"); //acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask); //taskserver.updateByCodeFromCache(acsTask);
continue; continue;
} }
} else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { } else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
@ -96,13 +95,14 @@ public class AutoCreateInst {
} }
} }
if (flag) { if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败"); // acsTask.setRemark("同列终点已存在,创建指令失败");
taskserver.update(acsTask); //taskserver.updateByCodeFromCache(acsTask);
continue; continue;
} }
} }
} }
Boolean flag2 = false; Boolean flag2 = false;
List<TaskDto> list2 = taskserver.queryAllFromCacheByStatus("1");
if (CollUtil.isNotEmpty(list2)) { if (CollUtil.isNotEmpty(list2)) {
for (TaskDto taskDto : list2) { for (TaskDto taskDto : list2) {
if (taskDto.getTask_type().equals(acsTask.getTask_type())) { if (taskDto.getTask_type().equals(acsTask.getTask_type())) {
@ -122,8 +122,8 @@ public class AutoCreateInst {
} }
} }
if (flag) { if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败"); //acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask); //taskserver.updateByCodeFromCache(acsTask);
flag2 = true; flag2 = true;
break; break;
} }
@ -143,8 +143,8 @@ public class AutoCreateInst {
} }
} }
if (flag) { if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败"); //acsTask.setRemark("同列终点已存在,创建指令失败");
taskserver.update(acsTask); //taskserver.updateByCodeFromCache(acsTask);
flag2 = true; flag2 = true;
break; break;
} }
@ -192,8 +192,8 @@ public class AutoCreateInst {
//校验路由关系 //校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) { if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令"); //acsTask.setRemark("路由不通无法生成指令");
taskserver.updateByCodeFromCache(acsTask); //taskserver.updateByCodeFromCache(acsTask);
continue; continue;
} }
@ -259,8 +259,8 @@ public class AutoCreateInst {
try { try {
instructionService.create(instdto); instructionService.create(instdto);
} catch (Exception e) { } catch (Exception e) {
acsTask.setRemark(e.getMessage()); //acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask); //taskserver.updateByCodeFromCache(acsTask);
log.info("自动创建指令失败{}", e.getMessage()); log.info("自动创建指令失败{}", e.getMessage());
continue; continue;
} }

Loading…
Cancel
Save