庞晟豪
1 year ago
34 changed files with 924 additions and 171 deletions
@ -0,0 +1,125 @@ |
|||
package org.nl.acs.opc; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude.Include; |
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.DeserializationFeature; |
|||
import com.fasterxml.jackson.databind.JavaType; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.databind.module.SimpleModule; |
|||
import com.fasterxml.jackson.databind.type.TypeFactory; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public class JsonUtl { |
|||
private static ObjectMapper objectMapper = null; |
|||
private static ObjectMapper objectMapperLog = null; |
|||
|
|||
private JsonUtl() { |
|||
} |
|||
|
|||
private static ObjectMapper init() { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
SimpleModule simpleModule = new SimpleModule(); |
|||
// simpleModule.addSerializer(Enum.class, new EnumSerializer());
|
|||
// simpleModule.addSerializer(Date.class, new DateSerializer());
|
|||
// simpleModule.addDeserializer(Enum.class, new EnumDeserializer());
|
|||
// simpleModule.addDeserializer(Date.class, new DateDeserializers.DateDeserializer());
|
|||
objectMapper.registerModule(simpleModule); |
|||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
|||
return objectMapper; |
|||
} |
|||
|
|||
public static ObjectMapper getInstance() { |
|||
if (objectMapper == null) { |
|||
Class var0 = JsonUtl.class; |
|||
synchronized(JsonUtl.class) { |
|||
if (objectMapper == null) { |
|||
objectMapper = init(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return objectMapper; |
|||
} |
|||
|
|||
public static ObjectMapper getInstanceLog() { |
|||
if (objectMapperLog == null) { |
|||
Class var0 = JsonUtl.class; |
|||
synchronized(JsonUtl.class) { |
|||
if (objectMapperLog == null) { |
|||
objectMapperLog = init(); |
|||
objectMapperLog.setSerializationInclusion(Include.NON_NULL); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return objectMapperLog; |
|||
} |
|||
|
|||
public static ObjectMapper getObjectMapper() { |
|||
return getInstance(); |
|||
} |
|||
|
|||
public static String parse(Object object) throws RuntimeException { |
|||
try { |
|||
return getObjectMapper().writeValueAsString(object); |
|||
} catch (JsonProcessingException var2) { |
|||
throw new RuntimeException(var2); |
|||
} |
|||
} |
|||
|
|||
public static String parseWithoutException(Object object) { |
|||
try { |
|||
return parse(object); |
|||
} catch (Exception var2) { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static String parseLog(Object object) { |
|||
try { |
|||
return getInstanceLog().writeValueAsString(object); |
|||
} catch (Exception var2) { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static <T> T format(String json, Class<T> clazz) throws RuntimeException { |
|||
try { |
|||
return getObjectMapper().readValue(json, clazz); |
|||
} catch (IOException var3) { |
|||
throw new RuntimeException(var3); |
|||
} |
|||
} |
|||
|
|||
public static <T> List<T> formatList(String json, Class<T> clazz) throws RuntimeException { |
|||
try { |
|||
JavaType type = getObjectMapper().getTypeFactory().constructParametricType(List.class, new Class[]{clazz}); |
|||
return (List)getObjectMapper().readValue(json, type); |
|||
} catch (IOException var3) { |
|||
throw new RuntimeException(var3); |
|||
} |
|||
} |
|||
|
|||
public static <T, U> Map<T, U> formatMap(String json, Class<T> clazzKey, Class<U> clazzValue) throws RuntimeException { |
|||
try { |
|||
JavaType type = getObjectMapper().getTypeFactory().constructParametricType(Map.class, new Class[]{clazzKey, clazzValue}); |
|||
return (Map)getObjectMapper().readValue(json, type); |
|||
} catch (IOException var4) { |
|||
throw new RuntimeException(var4); |
|||
} |
|||
} |
|||
|
|||
public static <T> List<List<T>> formatListTwo(String json, Class<T> clazz) throws RuntimeException { |
|||
try { |
|||
TypeFactory typeFactory = getObjectMapper().getTypeFactory(); |
|||
JavaType type = typeFactory.constructParametrizedType(List.class, List.class, new Class[]{clazz}); |
|||
type = typeFactory.constructParametrizedType(List.class, List.class, new JavaType[]{type}); |
|||
return (List)getObjectMapper().readValue(json, type); |
|||
} catch (IOException var4) { |
|||
throw new RuntimeException(var4); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,341 @@ |
|||
package org.nl.quartz.task; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.ObjectUtils; |
|||
import org.nl.acs.AcsConfig; |
|||
import org.nl.acs.device.domain.Device; |
|||
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
|||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; |
|||
import org.nl.acs.instruction.domain.Instruction; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.opc.DeviceAppService; |
|||
import org.nl.acs.opc.DeviceAppServiceImpl; |
|||
import org.nl.acs.route.service.RouteLineService; |
|||
import org.nl.acs.route.service.dto.RouteLineDto; |
|||
import org.nl.acs.task.service.TaskService; |
|||
import org.nl.acs.task.service.dto.TaskDto; |
|||
import org.nl.config.SpringContextHolder; |
|||
import org.nl.system.service.param.ISysParamService; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 自动创建指令 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class AutoCreateInst { |
|||
/** |
|||
* 根据任务状态创建指令、生成下一条指令 |
|||
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货 |
|||
*/ |
|||
public void run() throws Exception { |
|||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); |
|||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); |
|||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); |
|||
ISysParamService acsConfigService = SpringContextHolder.getBean(ISysParamService.class); |
|||
List<TaskDto> list = taskserver.queryByStauts("0"); |
|||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|||
for (int i = 0; i < list.size(); i++) { |
|||
TaskDto acsTask = list.get(i); |
|||
String taskid = acsTask.getTask_id(); |
|||
String taskcode = acsTask.getTask_code(); |
|||
String vehiclecode = acsTask.getVehicle_code(); |
|||
String priority = acsTask.getPriority(); |
|||
String start_point_code = acsTask.getStart_point_code(); |
|||
String start_device_code = acsTask.getStart_device_code(); |
|||
String route_plan_code = acsTask.getRoute_plan_code(); |
|||
String vehicleType = acsTask.getVehicle_type(); |
|||
//是否复合任务 =0非复合任务
|
|||
String compound_task = acsTask.getCompound_task(); |
|||
String compound_task_data = null; |
|||
String next_point_code = acsTask.getNext_point_code(); |
|||
String next_device_code = acsTask.getNext_device_code(); |
|||
if (StrUtil.isEmpty(start_device_code)) { |
|||
log.info("任务 [" + taskcode + "] 起点设备为空,无法生成指令。"); |
|||
acsTask.setRemark("任务 [" + taskcode + "] 起点设备为空,无法生成指令。"); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
continue; |
|||
} |
|||
if (StrUtil.isEmpty(next_device_code)) { |
|||
log.info("任务 [" + taskcode + "] 终点设备为空,无法生成指令。"); |
|||
acsTask.setRemark("任务 [" + taskcode + "] 终点设备为空,无法生成指令。"); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
continue; |
|||
} |
|||
List<Instruction> instructions = instructionService.queryAll("instruction_status < 2"); |
|||
String maxInstnumber = acsConfigService.findByCode(AcsConfig.MAXINSTNUMBER).getValue(); |
|||
if (ObjectUtils.isNotEmpty(maxInstnumber)) { |
|||
if (instructions.size() >= Integer.parseInt(maxInstnumber)) { |
|||
log.info("已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。"); |
|||
acsTask.setRemark("已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。"); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
continue; |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 开始平均分解校验 |
|||
*/ |
|||
String this_device_code = taskserver.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); |
|||
if (StrUtil.isEmpty(this_device_code)) { |
|||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); |
|||
RouteLineDto routeLineDto = shortPathsList.get(0); |
|||
String path = routeLineDto.getPath(); |
|||
String type = routeLineDto.getType(); |
|||
String[] str = path.split("->"); |
|||
List<String> pathlist = Arrays.asList(str); |
|||
if (StrUtil.equals(acsTask.getTask_type(), "2")) { |
|||
for (int j = 0; j < pathlist.size(); j++) { |
|||
if (j == 0) { |
|||
compound_task_data = pathlist.get(j).trim(); |
|||
} else { |
|||
compound_task_data = compound_task_data + "->" + pathlist.get(j).trim(); |
|||
} |
|||
} |
|||
next_device_code = pathlist.get(pathlist.size() - 1); |
|||
|
|||
} else { |
|||
int index = 0; |
|||
for (int m = 0; m < pathlist.size(); m++) { |
|||
if (pathlist.get(m).equals(start_device_code)) { |
|||
index = m + 1; |
|||
break; |
|||
} |
|||
} |
|||
next_device_code = pathlist.get(index); |
|||
} |
|||
} else { |
|||
next_device_code = this_device_code; |
|||
} |
|||
//校验路由关系
|
|||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); |
|||
if (ObjectUtils.isEmpty(shortPathsList)) { |
|||
log.info("任务 [" + taskcode + "] 路由不通无法生成指令。"); |
|||
acsTask.setRemark("任务 [" + taskcode + "] 路由不通无法生成指令。"); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
continue; |
|||
} |
|||
|
|||
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { |
|||
continue; |
|||
} |
|||
Device startdevice = appService.findDeviceByCode(start_device_code); |
|||
Device nextdevice = appService.findDeviceByCode(next_device_code); |
|||
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { |
|||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); |
|||
} else { |
|||
next_point_code = next_device_code; |
|||
} |
|||
if (ObjectUtils.isEmpty(startdevice)) { |
|||
log.info("任务 [" + taskcode + "] 起点设备编码 [" + start_device_code + "] 对应设备未找到,无法生成指令。"); |
|||
continue; |
|||
} |
|||
if (ObjectUtils.isEmpty(nextdevice)) { |
|||
log.info("任务 [" + taskcode + "] 终点设备编码 [" + next_device_code + "] 对应设备未找到,无法生成指令。"); |
|||
continue; |
|||
} |
|||
//普通站点
|
|||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; |
|||
// StandardEmptyPalletSiteDeviceDriver standardEmptsyPalletSiteDeviceDriver;
|
|||
// LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
|
|||
// LnshFoldDiscSiteDeviceDriver lnshFoldDiscSiteDeviceDriver;
|
|||
|
|||
String createTaskCheck = acsConfigService.findByCode(AcsConfig.CREATETASKCHECK).getValue(); |
|||
|
|||
if (StrUtil.equals(createTaskCheck, "1")) { |
|||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); |
|||
if (standardInspectSiteDeviceDriver.getMode() != 2) { |
|||
log.info("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|||
acsTask.setRemark("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
//this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code());
|
|||
//this.execute_log.log("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode);
|
|||
continue; |
|||
} |
|||
} |
|||
// if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) {
|
|||
// standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver();
|
|||
// if (standardEmptsyPalletSiteDeviceDriver.getMode() != 2) {
|
|||
// log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode);
|
|||
// acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode);
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
// }
|
|||
// if (startdevice.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) {
|
|||
// lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) startdevice.getDeviceDriver();
|
|||
// if (lnshFoldDiscSiteDeviceDriver.getMode() != 2) {
|
|||
// log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode);
|
|||
// acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode);
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
// }
|
|||
|
|||
//校验 是否同任务是否存在相同终点、未完成的指令
|
|||
int sameqty = instructionService.querySameDestinationInst(next_point_code); |
|||
if (sameqty > 0) { |
|||
log.info("存在相同终点的指令,任务号:" + taskcode); |
|||
acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
continue; |
|||
} |
|||
} |
|||
|
|||
//空盘位生成指令需要另外逻辑
|
|||
// if (nextdevice.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) {
|
|||
// lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) nextdevice.getDeviceDriver();
|
|||
// if (lnshFoldDiscSiteDeviceDriver.getMode() == 0) {
|
|||
// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// } else if (lnshFoldDiscSiteDeviceDriver.getError() != 0
|
|||
// || lnshFoldDiscSiteDeviceDriver.getStatus() == 3) {
|
|||
// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
// int max_emptypalletnum = Integer.parseInt(nextdevice.getExtraValue().get("max_emptypalletnum").toString());
|
|||
// int nowNumber = lnshFoldDiscSiteDeviceDriver.getContainer_qty();
|
|||
// if (nowNumber >= max_emptypalletnum) {
|
|||
// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已满,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已满,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
// // 查看是否有相同终点的指令
|
|||
// int count = instructionService.queryDeviceInstCount(next_device_code);
|
|||
// if (count > 0) {
|
|||
// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已被占用,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已被占用,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code());
|
|||
// //this.execute_log.log("存在相同终点的指令,任务号:" + taskcode);
|
|||
// continue;
|
|||
// }
|
|||
// next_point_code = next_device_code + "." + (nowNumber + 1);
|
|||
// } else if (nextdevice.getDeviceDriver() instanceof LnshStationDeviceDriver
|
|||
// && "true".equals(nextdevice.getExtraValue().get("inspect_in_stocck"))) {
|
|||
// LnshStationDeviceDriver deviceDriver = (LnshStationDeviceDriver) nextdevice.getDeviceDriver();
|
|||
// if (deviceDriver.getMode() == 0) {
|
|||
// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// } else if (deviceDriver.getMove() != 0) {
|
|||
// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 有货,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 有货,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// } else if (deviceDriver.getError() != 0) {
|
|||
// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
// }
|
|||
|
|||
// if (startdevice.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) {
|
|||
// lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) startdevice.getDeviceDriver();
|
|||
// if (lnshFoldDiscSiteDeviceDriver.getMode() == 0) {
|
|||
// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// } else if (lnshFoldDiscSiteDeviceDriver.getError() != 0
|
|||
// || lnshFoldDiscSiteDeviceDriver.getStatus() == 3) {
|
|||
// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
//
|
|||
// int container_qty = lnshFoldDiscSiteDeviceDriver.getContainer_qty();
|
|||
// int max_emptypalletnum = Integer.parseInt(startdevice.getExtraValue().get("max_emptypalletnum").toString());
|
|||
// if (container_qty < (max_emptypalletnum / 2)) {
|
|||
// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 可用托盘数量少于最大托盘数量 [" + max_emptypalletnum + "] / 2,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 可用托盘数量少于最大托盘数量 [" + max_emptypalletnum + "] / 2,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
//
|
|||
// int count = instructionService.queryDeviceInstCount(start_device_code);
|
|||
// if (count > 0) {
|
|||
// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 已被占用,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 已被占用,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code());
|
|||
// //this.execute_log.log("存在相同终点的指令,任务号:" + taskcode);
|
|||
// continue;
|
|||
// }
|
|||
//
|
|||
// start_point_code = start_device_code + ".1";
|
|||
// } else if (startdevice.getDeviceDriver() instanceof LnshStationDeviceDriver
|
|||
// && "true".equals(startdevice.getExtraValue().get("inspect_in_stocck"))) {
|
|||
// LnshStationDeviceDriver deviceDriver = (LnshStationDeviceDriver) startdevice.getDeviceDriver();
|
|||
// if (deviceDriver.getMode() == 0) {
|
|||
// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// } else if (deviceDriver.getMove() == 0) {
|
|||
// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 无货,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 无货,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// } else if (deviceDriver.getError() != 0) {
|
|||
// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。");
|
|||
// taskserver.updateByCodeFromCache(acsTask);
|
|||
// continue;
|
|||
// }
|
|||
// }
|
|||
|
|||
Instruction instdto = new Instruction(); |
|||
instdto.setInstruction_type(acsTask.getTask_type()); |
|||
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|||
instdto.setRoute_plan_code(route_plan_code); |
|||
instdto.setRemark(acsTask.getRemark()); |
|||
instdto.setMaterial(acsTask.getMaterial()); |
|||
instdto.setQuantity(acsTask.getQuantity()); |
|||
instdto.setTask_id(taskid); |
|||
instdto.setTask_code(taskcode); |
|||
instdto.setVehicle_code(vehiclecode); |
|||
String now = DateUtil.now(); |
|||
instdto.setCreate_time(now); |
|||
instdto.setCreate_by("auto"); |
|||
instdto.setStart_device_code(start_device_code); |
|||
instdto.setNext_device_code(next_device_code); |
|||
instdto.setStart_point_code(start_point_code); |
|||
instdto.setNext_point_code(next_point_code); |
|||
instdto.setCompound_inst_data(compound_task_data); |
|||
instdto.setPriority(priority); |
|||
instdto.setInstruction_status("0"); |
|||
instdto.setExecute_device_code(start_point_code); |
|||
instdto.setVehicle_type(vehicleType); |
|||
try { |
|||
instructionService.create(instdto); |
|||
} catch (Exception e) { |
|||
acsTask.setRemark(e.getMessage()); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
continue; |
|||
} |
|||
log.info("任务 [" + taskcode + "] 指令成功生成!"); |
|||
//创建指令后修改任务状态
|
|||
acsTask.setTask_status("1"); |
|||
taskserver.update(acsTask); |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
package org.nl.quartz.task; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.auto.run.AutoRunService; |
|||
import org.nl.system.service.param.ISysParamService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* NDC自动重连 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class NdcAutoReconnection { |
|||
|
|||
@Autowired |
|||
ISysParamService paramService; |
|||
|
|||
@Autowired |
|||
AutoRunService autoRunService; |
|||
|
|||
public void run(String threadCode) throws Exception { |
|||
String[] threadCodes = threadCode.split(","); |
|||
for (String code : threadCodes) { |
|||
if (!autoRunService.getThreadByCode(code).isAlive()) { |
|||
autoRunService.startThread(code); |
|||
} |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue