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> 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;
}
@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
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
@ -747,8 +757,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
taskFeedbackService.update(feefbackdto);
}
} else {
int status = body.getStatus();
JSONObject jo = JSONObject.parseObject(body.body());
int status = 0;
JSONObject jo = new JSONObject();
if (body == null){
status = 400;
}else {
status = body.getStatus();
jo = JSONObject.parseObject(body.body());
}
if (ObjectUtil.isEmpty(feefbackdto)) {
feefbackdto = new TaskFeedbackDto();
feefbackdto.setTask_id(entity.getTask_id());
@ -756,7 +773,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
feefbackdto.setTask_status(entity.getTask_status());
feefbackdto.setVehicle_type(entity.getVehicle_type());
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_point_code(entity.getNext_point_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);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
List<TaskDto> list = taskserver.queryAll("task_status = '0' ORDER BY create_time ASC");
List<TaskDto> list2 = taskserver.queryAll("task_status = '1' ORDER BY create_time ASC");
List<TaskDto> list = taskserver.queryAllFromCacheByStatus("0");
Map<String, List<TaskDto>> collect = list.stream().sorted(Comparator.comparing(TaskDto::getCreate_time).thenComparing(TaskDto::getTask_code))
.collect(Collectors.groupingBy(TaskDto::getPriority));
TreeMap<String, List<TaskDto>> treeMap = new TreeMap<>(new Comparator<String>() {
@ -80,8 +79,8 @@ public class AutoCreateInst {
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
//acsTask.setRemark("同列起点已存在,创建指令失败");
//taskserver.updateByCodeFromCache(acsTask);
continue;
}
} else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
@ -96,13 +95,14 @@ public class AutoCreateInst {
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
// acsTask.setRemark("同列终点已存在,创建指令失败");
//taskserver.updateByCodeFromCache(acsTask);
continue;
}
}
}
Boolean flag2 = false;
List<TaskDto> list2 = taskserver.queryAllFromCacheByStatus("1");
if (CollUtil.isNotEmpty(list2)) {
for (TaskDto taskDto : list2) {
if (taskDto.getTask_type().equals(acsTask.getTask_type())) {
@ -122,8 +122,8 @@ public class AutoCreateInst {
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
//acsTask.setRemark("同列起点已存在,创建指令失败");
//taskserver.updateByCodeFromCache(acsTask);
flag2 = true;
break;
}
@ -143,8 +143,8 @@ public class AutoCreateInst {
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
//acsTask.setRemark("同列终点已存在,创建指令失败");
//taskserver.updateByCodeFromCache(acsTask);
flag2 = true;
break;
}
@ -192,8 +192,8 @@ public class AutoCreateInst {
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.updateByCodeFromCache(acsTask);
//acsTask.setRemark("路由不通无法生成指令");
//taskserver.updateByCodeFromCache(acsTask);
continue;
}
@ -259,8 +259,8 @@ public class AutoCreateInst {
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask);
//acsTask.setRemark(e.getMessage());
//taskserver.updateByCodeFromCache(acsTask);
log.info("自动创建指令失败{}", e.getMessage());
continue;
}

Loading…
Cancel
Save