自动下发指令、自动重连
This commit is contained in:
@@ -75,7 +75,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
|||||||
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) {
|
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) {
|
||||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||||
String instcode = inst.getInstruction_code();
|
String instcode = inst.getInstruction_code();
|
||||||
int type = Integer.parseInt(inst.getAgv_inst_type());
|
int type = Integer.parseInt(inst.getInstruction_type());
|
||||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
inst.setSend_status("1");
|
inst.setSend_status("1");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
}
|
}
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
//任务完毕
|
//任务完毕
|
||||||
//(无车id及状态)
|
//(无车id及状态)
|
||||||
@@ -168,13 +168,13 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
} else {
|
} else {
|
||||||
log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!");
|
log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!");
|
||||||
}
|
}
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
log.info("指令号:{},已反馈agv任务完成!");
|
log.info("指令号:{},已反馈agv任务完成!");
|
||||||
}
|
}
|
||||||
//请求删除任务
|
//请求删除任务
|
||||||
//(需要WCS反馈)
|
//(需要WCS反馈)
|
||||||
else if (phase == 0x30) {
|
else if (phase == 0x30) {
|
||||||
data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0,0,0,0,0);
|
data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
//任务删除确认
|
//任务删除确认
|
||||||
//(需要WCS反馈)
|
//(需要WCS反馈)
|
||||||
@@ -185,7 +185,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//上报异常信息
|
//上报异常信息
|
||||||
@@ -255,7 +255,17 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
dos.flush();
|
dos.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
try {
|
||||||
|
Thread.sleep(5000L);
|
||||||
|
log.info("再次下发agv数据:" + Bytes2HexString(b));
|
||||||
|
System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||||
|
dos.write(b);
|
||||||
|
dos.flush();
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public class ItemProtocol {
|
|||||||
public static String item_move = "move";
|
public static String item_move = "move";
|
||||||
public static String item_action = "action";
|
public static String item_action = "action";
|
||||||
public static String item_error = "error";
|
public static String item_error = "error";
|
||||||
public static String item_task = "task";
|
|
||||||
public static String item_to_command = "to_command";
|
public static String item_to_command = "to_command";
|
||||||
public static String item_to_target = "to_target";
|
public static String item_to_target = "to_target";
|
||||||
public static String item_to_task = "to_task";
|
public static String item_to_task = "to_task";
|
||||||
@@ -50,9 +49,6 @@ public class ItemProtocol {
|
|||||||
return this.getOpcIntegerValue(item_error);
|
return this.getOpcIntegerValue(item_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTask() {
|
|
||||||
return this.getOpcIntegerValue(item_task);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaterialType() {
|
public int getMaterialType() {
|
||||||
return this.getOpcIntegerValue(item_material_type);
|
return this.getOpcIntegerValue(item_material_type);
|
||||||
@@ -99,8 +95,7 @@ public class ItemProtocol {
|
|||||||
list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true)));
|
list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true)));
|
||||||
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3"));
|
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3"));
|
||||||
list.add(new ItemDto(item_action, "取放信号", "DB600.B4"));
|
list.add(new ItemDto(item_action, "取放信号", "DB600.B4"));
|
||||||
list.add(new ItemDto(item_task, "任务号", "DB600.D6"));
|
list.add(new ItemDto(item_material_type, "物料类型", "DB600.D6"));
|
||||||
list.add(new ItemDto(item_material_type, "任务号", "DB600.D6"));
|
|
||||||
list.add(new ItemDto(item_error, "报警信号", "DB600.B7"));
|
list.add(new ItemDto(item_error, "报警信号", "DB600.B7"));
|
||||||
list.add(new ItemDto(item_barcode, "条码", "DB600.D8"));
|
list.add(new ItemDto(item_barcode, "条码", "DB600.D8"));
|
||||||
return list;
|
return list;
|
||||||
@@ -109,8 +104,6 @@ public class ItemProtocol {
|
|||||||
public static List<ItemDto> getWriteableItemDtos() {
|
public static List<ItemDto> getWriteableItemDtos() {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
|
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
|
||||||
list.add(new ItemDto(item_to_target, "目标站", "DB601.W4"));
|
|
||||||
list.add(new ItemDto(item_to_task, "任务号", "DB601.D8"));
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,16 +146,19 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
String device_code = this.getDeviceCode();
|
devicecode = this.getDeviceCode();
|
||||||
mode = this.itemProtocol.getMode();
|
mode = this.itemProtocol.getMode();
|
||||||
error = this.itemProtocol.getError();
|
error = this.itemProtocol.getError();
|
||||||
move = this.itemProtocol.getMove();
|
move = this.itemProtocol.getMove();
|
||||||
task = this.itemProtocol.getTask();
|
|
||||||
hasGoods = this.itemProtocol.getMove();
|
hasGoods = this.itemProtocol.getMove();
|
||||||
action = this.itemProtocol.getAction();
|
action = this.itemProtocol.getAction();
|
||||||
material_type = this.itemProtocol.getMaterialType();
|
material_type = this.itemProtocol.getMaterialType();
|
||||||
|
barcode=this.itemProtocol.getBarcode();
|
||||||
if (mode != last_mode) {
|
if (mode != last_mode) {
|
||||||
this.setRequireSucess(false);
|
this.setRequireSucess(false);
|
||||||
|
if(mode==2){
|
||||||
|
this.writing(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (move != last_move) {
|
if (move != last_move) {
|
||||||
}
|
}
|
||||||
@@ -196,25 +199,25 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
//叫料
|
//叫料
|
||||||
if (move==0){
|
if (move==0 && !requireSucess){
|
||||||
apply(4);
|
apply(4);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
//满料出库
|
//满料出库
|
||||||
if(move==1){
|
if(move==1 && !requireSucess){
|
||||||
apply(5);
|
apply(5);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
//申请空盘
|
//申请空盘
|
||||||
if (move==0){
|
if (move==0 && !requireSucess){
|
||||||
apply(6);
|
apply(6);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
//空托盘出库
|
//空托盘出库
|
||||||
if(move==1){
|
if(move==1 && !requireSucess){
|
||||||
apply(7);
|
apply(7);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -238,6 +241,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
|||||||
last_move = move;
|
last_move = move;
|
||||||
last_task = task;
|
last_task = task;
|
||||||
last_material_type = material_type;
|
last_material_type = material_type;
|
||||||
|
last_barcode=barcode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,7 +448,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
|||||||
request.setDevice_code(devicecode);
|
request.setDevice_code(devicecode);
|
||||||
request.setMaterial_type(String.valueOf(material_type));
|
request.setMaterial_type(String.valueOf(material_type));
|
||||||
request.setVehicle_code(String.valueOf(barcode));
|
request.setVehicle_code(String.valueOf(barcode));
|
||||||
if (devicecode.startsWith("TBX")&&type==5) {
|
if (devicecode.startsWith("TBX")&&type==5&&barcode>0) {
|
||||||
//满架下料
|
//满架下料
|
||||||
request.setRequest_medthod_code(RequestMethodEnum.apply_mjxl.getCode());
|
request.setRequest_medthod_code(RequestMethodEnum.apply_mjxl.getCode());
|
||||||
request.setRequest_medthod_name(RequestMethodEnum.apply_mjxl.getName());
|
request.setRequest_medthod_name(RequestMethodEnum.apply_mjxl.getName());
|
||||||
@@ -456,15 +460,15 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
|||||||
//空托盘出库,包片机和销售出库空位都可以
|
//空托盘出库,包片机和销售出库空位都可以
|
||||||
request.setRequest_medthod_code(RequestMethodEnum.apply_kghjrk.getCode());
|
request.setRequest_medthod_code(RequestMethodEnum.apply_kghjrk.getCode());
|
||||||
request.setRequest_medthod_name(RequestMethodEnum.apply_kghjrk.getName());
|
request.setRequest_medthod_name(RequestMethodEnum.apply_kghjrk.getName());
|
||||||
}else if(devicecode.startsWith("BP")){
|
}else if(devicecode.startsWith("BP")&&material_type>0){
|
||||||
request.setRequest_medthod_code(RequestMethodEnum.apply_bpsl.getCode());
|
request.setRequest_medthod_code(RequestMethodEnum.apply_bpsl.getCode());
|
||||||
request.setRequest_medthod_name(RequestMethodEnum.apply_bpsl.getName());
|
request.setRequest_medthod_name(RequestMethodEnum.apply_bpsl.getName());
|
||||||
}
|
}
|
||||||
String resp = acsToWmsService.applyTask(request);
|
String resp = acsToWmsService.applyTask(request);
|
||||||
JSONObject res_jo = JSONObject.parseObject(resp);
|
JSONObject res_jo = JSONObject.parseObject(resp);
|
||||||
if (StrUtil.equals(res_jo.getString("status"), "200")) {
|
if (StrUtil.equals(res_jo.getString("code"), "200")) {
|
||||||
this.writing(type);
|
this.writing(type);
|
||||||
this.setSucess(true);
|
this.setRequireSucess(true);
|
||||||
log.info("acs申请任务", this.devicecode, "满盅入库任务申请成功!");
|
log.info("acs申请任务", this.devicecode, "满盅入库任务申请成功!");
|
||||||
}else{
|
}else{
|
||||||
this.writing(99);
|
this.writing(99);
|
||||||
|
|||||||
@@ -1,37 +1,96 @@
|
|||||||
package org.nl.acs.device_driver.driver;
|
package org.nl.acs.device_driver.driver;
|
||||||
|
|
||||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
import org.nl.acs.opc.*;
|
||||||
import org.nl.acs.opc.OpcConfig;
|
|
||||||
import org.nl.acs.opc.OpcServerService;
|
|
||||||
import org.nl.acs.opc.OpcServerServiceImpl;
|
|
||||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||||
|
import org.nl.acs.udw.UnifiedDataAppService;
|
||||||
import org.nl.common.exception.BadRequestException;
|
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.openscada.opc.lib.da.Group;
|
||||||
|
import org.openscada.opc.lib.da.Item;
|
||||||
|
import org.openscada.opc.lib.da.ItemState;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
|
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
|
||||||
UnifiedDataAccessor opcUdw;
|
UnifiedDataAccessor opcUdw;
|
||||||
|
|
||||||
|
private OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService.class);
|
||||||
|
|
||||||
|
public AbstractOpcDeviceDriver() {
|
||||||
|
this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Date sendTime;
|
private Date sendTime;
|
||||||
private String last_items;
|
private String last_items;
|
||||||
private int noLog_sendTimeOut;
|
private int noLog_sendTimeOut;
|
||||||
private Date noLog_sendTime;
|
private Date noLog_sendTime;
|
||||||
private String noLog_last_items;
|
private String noLog_last_items;
|
||||||
|
|
||||||
public AbstractOpcDeviceDriver() {
|
|
||||||
this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UnifiedDataAccessor getOpcValueAccessor() {
|
public UnifiedDataAccessor getOpcValueAccessor() {
|
||||||
return this.opcUdw;
|
return this.opcUdw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void checkcontrol(Map<String, Object> itemValues) throws Exception {
|
||||||
|
Group group = opcServerService.getServer(this.getOpcServer());
|
||||||
|
Map<String, Object> write = new HashMap();
|
||||||
|
Map<String, Item> readitems = new LinkedHashMap();
|
||||||
|
List<String> itemsString = new ArrayList();
|
||||||
|
itemsString = new ArrayList<> (itemValues.keySet());
|
||||||
|
Iterator is = itemsString.iterator();
|
||||||
|
|
||||||
|
while (is.hasNext()) {
|
||||||
|
String string = (String) is.next();
|
||||||
|
try {
|
||||||
|
readitems.put(string, group.addItem(string));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
while(true) {
|
||||||
|
//下发信号
|
||||||
|
control( itemValues);
|
||||||
|
Map<String, Object> read = new HashMap();
|
||||||
|
Map<Item, ItemState> itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
|
||||||
|
Set<Item> items = itemStatus.keySet();
|
||||||
|
Iterator var15 = items.iterator();
|
||||||
|
|
||||||
|
while(var15.hasNext()) {
|
||||||
|
Item item = (Item)var15.next();
|
||||||
|
ItemState itemState = (ItemState)itemStatus.get(item);
|
||||||
|
Object value = OpcUtl.getValue(item, itemState);
|
||||||
|
read.put(item.getId(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean check = true;
|
||||||
|
Iterator var24 = itemsString.iterator();
|
||||||
|
|
||||||
|
while(var24.hasNext()) {
|
||||||
|
String itemString = (String)var24.next();
|
||||||
|
if (!ObjectUtl.isEquals(itemValues.get(itemString), JsonUtl.parse(read.get(itemString)))) {
|
||||||
|
check = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (check) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
ThreadUtl.sleep(300L);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > 3) {
|
||||||
|
throw new RuntimeException("写入次数超过3次而失败");
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean control(Map<String, Object> itemValues) {
|
public boolean control(Map<String, Object> itemValues) {
|
||||||
|
|
||||||
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
|
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
|
||||||
@@ -48,7 +107,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.control(p2);
|
return this.control(p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,11 +129,13 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
sb.append(":");
|
sb.append(":");
|
||||||
sb.append(JsonUtl.parseWithoutException(udw_value));
|
sb.append(JsonUtl.parseWithoutException(udw_value));
|
||||||
sb.append(";");
|
sb.append(";");
|
||||||
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
|
if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
|
||||||
// need_write = true;
|
need_write = true;
|
||||||
// }
|
} else {
|
||||||
|
//log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
need_write = true;
|
// need_write = true;
|
||||||
|
|
||||||
if (need_write) {
|
if (need_write) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
@@ -85,9 +146,9 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
|
|
||||||
this.last_items = this_items;
|
this.last_items = this_items;
|
||||||
this.sendTime = date;
|
this.sendTime = date;
|
||||||
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
|
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
|
||||||
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
|
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
|
||||||
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
|
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
|
||||||
|
|
||||||
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
|
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
|
||||||
|
|
||||||
@@ -106,7 +167,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException("下发 无内容");
|
throw new RuntimeException("下发 无内容");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.nl.acs.instruction.rest;
|
package org.nl.acs.instruction.rest;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import org.nl.common.logging.annotation.Log;
|
import org.nl.common.logging.annotation.Log;
|
||||||
import org.nl.acs.instruction.domain.Instruction;
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
@@ -36,6 +37,9 @@ public class InstructionController {
|
|||||||
@ApiOperation("查询指令")
|
@ApiOperation("查询指令")
|
||||||
//@PreAuthorize("@el.check('instruction:list')")
|
//@PreAuthorize("@el.check('instruction:list')")
|
||||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||||
|
if(ObjectUtil.isEmpty(whereJson.get("status"))) {
|
||||||
|
whereJson.put("status", "1");
|
||||||
|
}
|
||||||
return new ResponseEntity<>(instructionService.queryAll(whereJson, page), HttpStatus.OK);
|
return new ResponseEntity<>(instructionService.queryAll(whereJson, page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
// private final RedisUtils redisUtils;
|
// private final RedisUtils redisUtils;
|
||||||
@Autowired
|
@Autowired
|
||||||
InstructionMapper instructionMapper;
|
InstructionMapper instructionMapper;
|
||||||
|
@Autowired
|
||||||
TaskMapper taskMapper;
|
TaskMapper taskMapper;
|
||||||
List<Instruction> instructions = new CopyOnWriteArrayList();
|
List<Instruction> instructions = new CopyOnWriteArrayList();
|
||||||
// List<InstructionMybatis> instructions_mybatis = new CopyOnWriteArrayList();
|
// List<InstructionMybatis> instructions_mybatis = new CopyOnWriteArrayList();
|
||||||
@@ -409,8 +410,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dto.setCreate_by(currentUsername);
|
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername)?currentUsername:"admin");
|
||||||
dto.setUpdate_by(currentUsername);
|
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername)?currentUsername:"admin");
|
||||||
dto.setUpdate_time(now);
|
dto.setUpdate_time(now);
|
||||||
dto.setCreate_time(now);
|
dto.setCreate_time(now);
|
||||||
dto.setStart_parent_code(task.getStart_parent_code());
|
dto.setStart_parent_code(task.getStart_parent_code());
|
||||||
@@ -728,7 +729,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finish(String id) {
|
public void finish(String id) {
|
||||||
Instruction entity = (Instruction) this.findById(id);
|
InstructionDto entity = this.findById(id);
|
||||||
// if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
// if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
@@ -807,7 +808,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||||
taskService.finish(task.getTask_id());
|
taskService.finish(task.getTask_id());
|
||||||
} else {
|
} else {
|
||||||
finishAndCreateNextInst(entity);
|
finishAndCreateNextInst((Instruction) entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -968,7 +969,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
public void cancel(String id) throws Exception {
|
public void cancel(String id) throws Exception {
|
||||||
// flag= true时取消指令
|
// flag= true时取消指令
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
Instruction entity = (Instruction) this.findById(id);
|
InstructionDto entity = this.findById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
}
|
}
|
||||||
@@ -987,7 +988,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||||
// NDC agv指令不当场取消指令,需要等agv上报
|
// NDC agv指令不当场取消指令,需要等agv上报
|
||||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||||
ndcAgvService.deleteAgvInstToNDC(entity);
|
ndcAgvService.deleteAgvInstToNDC((Instruction)entity);
|
||||||
} else {
|
} else {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
@@ -1077,7 +1078,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
public void forceCancel(String id) throws Exception {
|
public void forceCancel(String id) throws Exception {
|
||||||
// flag= true时取消指令
|
// flag= true时取消指令
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
Instruction entity = (Instruction) this.findById(id);
|
InstructionDto entity = this.findById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
}
|
}
|
||||||
@@ -1133,7 +1134,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
@Override
|
@Override
|
||||||
public void cancelNOSendAgv(String id) throws Exception {
|
public void cancelNOSendAgv(String id) throws Exception {
|
||||||
// flag= true时取消指令
|
// flag= true时取消指令
|
||||||
Instruction entity = (Instruction) this.findById(id);
|
InstructionDto entity = this.findById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
}
|
}
|
||||||
@@ -1524,7 +1525,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(String id) {
|
public void init(String id) {
|
||||||
Instruction inst = (Instruction) this.findById(id);
|
InstructionDto inst = this.findById(id);
|
||||||
if (inst == null) {
|
if (inst == null) {
|
||||||
throw new BadRequestException("指令不存在或已删除");
|
throw new BadRequestException("指令不存在或已删除");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.nl.acs.task.rest;
|
package org.nl.acs.task.rest;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.nl.common.logging.annotation.Log;
|
import org.nl.common.logging.annotation.Log;
|
||||||
import org.nl.acs.task.domain.Task;
|
import org.nl.acs.task.domain.Task;
|
||||||
@@ -38,6 +39,9 @@ public class TaskController {
|
|||||||
//@PreAuthorize("@el.check('task:list')")
|
//@PreAuthorize("@el.check('task:list')")
|
||||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||||
// return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK);
|
// return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK);
|
||||||
|
if(ObjectUtil.isEmpty(whereJson.get("status"))) {
|
||||||
|
whereJson.put("status", "1");
|
||||||
|
}
|
||||||
return new ResponseEntity<>(taskService.queryAll(whereJson, page), HttpStatus.OK);
|
return new ResponseEntity<>(taskService.queryAll(whereJson, page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user