更新
This commit is contained in:
@@ -82,6 +82,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code();
|
||||
}
|
||||
log.info("下发agv任务请求:{}", agvurl);
|
||||
log.info("下发agv任务参数:{}", jo.toString());
|
||||
|
||||
HttpResponse result = HttpRequest.post(agvurl)
|
||||
.body(String.valueOf(jo))//表单内容
|
||||
@@ -114,7 +115,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
HttpResponse result = HttpRequest.get(agvurl)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute();
|
||||
System.out.println("查询agv指令数据:" + result.body());
|
||||
|
||||
log.info("查询agv指令数据:{}", result.body());
|
||||
|
||||
return result;
|
||||
} else {
|
||||
|
||||
@@ -78,6 +78,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
Boolean isonline = true;
|
||||
|
||||
Boolean iserror = false;
|
||||
String inst_message;
|
||||
|
||||
//1-执行任务;2-取货完成;3-放货完成;
|
||||
int flag;
|
||||
@@ -87,6 +88,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
int last_error = 0;
|
||||
|
||||
String device_code;
|
||||
Instruction inst = null;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
@@ -103,16 +105,14 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
device_code = this.getDeviceCode();
|
||||
heartbeat = this.itemProtocol.getItem_heartbeat();
|
||||
mode = this.itemProtocol.getItem_mode();
|
||||
move = this.itemProtocol.getItem_mode();
|
||||
move = this.itemProtocol.getItem_move();
|
||||
error = this.itemProtocol.getItem_error();
|
||||
task = this.itemProtocol.getItem_task();
|
||||
action = this.itemProtocol.getItem_action();
|
||||
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(false);
|
||||
}
|
||||
if (move != last_move) {
|
||||
this.setRequireSucess(false);
|
||||
if (move == 0) {
|
||||
thingToNothing();
|
||||
}
|
||||
@@ -148,9 +148,24 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
break;
|
||||
case 2:
|
||||
//申请任务
|
||||
if (move > 0 && !requireSucess) {
|
||||
if (move > 0) {
|
||||
instruction_require();
|
||||
}
|
||||
if (mode == 2 && move != 0 && task > 0) {
|
||||
//inst_message
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
if (inst != null) {
|
||||
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code();
|
||||
if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
|
||||
finish_instruction();
|
||||
}
|
||||
if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (flag) {
|
||||
//取货完成
|
||||
@@ -170,6 +185,10 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
last_error = error;
|
||||
}
|
||||
|
||||
public synchronized boolean finish_instruction() throws Exception {
|
||||
instructionService.finish(inst);
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean instruction_apply(String container_code) throws Exception {
|
||||
Date date = new Date();
|
||||
@@ -295,6 +314,10 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
+ "." + ItemProtocol.item_to_target;
|
||||
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_task;
|
||||
String to_door = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_door;
|
||||
String to_floor = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_floor;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
@@ -304,18 +327,23 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
} else if (type == 2) {
|
||||
itemMap.put(to_target, command);
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_target + ",value:" + command);
|
||||
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_task + ",value:" + command);
|
||||
} else if (type == 4) {
|
||||
itemMap.put(to_door, command);
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_door + ",value:" + command);
|
||||
} else if (type == 5) {
|
||||
itemMap.put(to_floor, command);
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_floor + ",value:" + command);
|
||||
}
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String device_code = this.getDevice_code();
|
||||
String mode = "";
|
||||
String action = "";
|
||||
String move = "";
|
||||
|
||||
@@ -16,6 +16,7 @@ public class ItemProtocol {
|
||||
public static String item_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_container_type = "container_type";
|
||||
public static String item_task = "task";
|
||||
|
||||
|
||||
@@ -50,10 +51,15 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getItem_container_type() {
|
||||
return this.getOpcIntegerValue(item_container_type);
|
||||
}
|
||||
|
||||
public int getItem_task() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
@@ -75,7 +81,8 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_move, "光电信号", "VW4"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "VW6"));
|
||||
list.add(new ItemDto(item_error, "故障", "VW8"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD10"));
|
||||
list.add(new ItemDto(item_container_type, "托盘类型", "VW10"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD12"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -232,10 +232,10 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
break;
|
||||
case 2:
|
||||
//申请任务
|
||||
if (move > 0 && !StrUtil.isEmpty(barcode()) && !requireSucess) {
|
||||
if (!StrUtil.isEmpty(barcode()) && !requireSucess) {
|
||||
instruction_require(barcode());
|
||||
}
|
||||
if (move > 0 && !StrUtil.isEmpty(barcode()) && !applySucess) {
|
||||
if (!StrUtil.isEmpty(barcode()) && !applySucess) {
|
||||
instruction_apply(barcode());
|
||||
}
|
||||
}
|
||||
@@ -320,31 +320,34 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
|
||||
public void writing(int type, int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
+ "." + org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.ItemProtocol.item_to_command;
|
||||
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_target;
|
||||
+ "." + org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.ItemProtocol.item_to_target;
|
||||
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_task;
|
||||
+ "." + org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.ItemProtocol.item_to_task;
|
||||
String to_door = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_door;
|
||||
+ "." + org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.ItemProtocol.item_to_door;
|
||||
String to_floor = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_floor;
|
||||
+ "." + org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.ItemProtocol.item_to_floor;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
if (type == 1) {
|
||||
itemMap.put(to_command, command);
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_command + ",value:" + command);
|
||||
} else if (type == 2) {
|
||||
itemMap.put(to_target, command);
|
||||
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_target + ",value:" + command);
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
} else if (type == 4) {
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_task + ",value:" + command);
|
||||
} else if (type == 4) {
|
||||
itemMap.put(to_door, command);
|
||||
} else if (type == 5) {
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_task + ",value:" + command);
|
||||
} else if (type == 5) {
|
||||
itemMap.put(to_floor, command);
|
||||
log.info("设备:" + device_code + ",下发PLC信号" + to_task + ",value:" + command);
|
||||
}
|
||||
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
|
||||
@@ -304,7 +304,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
//输送线相关需要给任务字段进行赋值,通过任务来判断输送线当前执行到哪一步
|
||||
if (startdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
|
||||
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||
cargoLiftConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){
|
||||
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver();
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(1,1);
|
||||
@@ -320,15 +319,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
if (StrUtil.isEmpty(floor)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
|
||||
}
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(2, Integer.parseInt(address));
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.parseInt(task_code));
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(4, Integer.parseInt(door));
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(5, Integer.parseInt(floor));
|
||||
cargoLiftConveyorDeviceDriver.writing(1, 0);
|
||||
cargoLiftConveyorDeviceDriver.writing(1, 1);
|
||||
cargoLiftConveyorDeviceDriver.writing(2, Integer.parseInt(address));
|
||||
cargoLiftConveyorDeviceDriver.writing(3, Integer.parseInt(dto.getInstruction_code()));
|
||||
cargoLiftConveyorDeviceDriver.writing(4, Integer.parseInt(door));
|
||||
cargoLiftConveyorDeviceDriver.writing(5, Integer.parseInt(floor));
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
|
||||
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver();
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||
if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver){
|
||||
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
||||
cargoLiftConveyorDeviceDriver.writing(1,1);
|
||||
@@ -344,10 +344,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
if (StrUtil.isEmpty(floor)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
|
||||
}
|
||||
cargoLiftConveyorDeviceDriver.writing(2, Integer.parseInt(address));
|
||||
cargoLiftConveyorDeviceDriver.writing(3, Integer.parseInt(task_code));
|
||||
cargoLiftConveyorDeviceDriver.writing(4, Integer.parseInt(door));
|
||||
cargoLiftConveyorDeviceDriver.writing(5, Integer.parseInt(floor));
|
||||
cargoLiftConveyorDeviceDriver.writing(1, 0);
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(1, 1);
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(2, Integer.parseInt(address));
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.parseInt(dto.getInstruction_code()));
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(4, Integer.parseInt(door));
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(5, Integer.parseInt(floor));
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) {
|
||||
@@ -898,27 +900,48 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
entity.setRoute_plan_code(task.getRoute_plan_code());
|
||||
}
|
||||
|
||||
// != 0 为agv任务 1=magic 2=NDC 3=XZ,4=ZHEDA
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")
|
||||
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
||||
MagicAgvService magicAgvService = SpringContextHolder.getBean(MagicAgvService.class);
|
||||
magicAgvService.deleteAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code());
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
throw new Exception(entity.getStart_device_code() + "->" + entity.getNext_device_code() + "路由不通");
|
||||
}
|
||||
String type = shortPathsList.get(0).getType();
|
||||
|
||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
//NDC agv指令不当场取消指令,需要等agv上报
|
||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||
ndcAgvService.deleteAgvInstToNDC(entity);
|
||||
RouteLineDto route = null;
|
||||
for (int i = 0; i < shortPathsList.size(); i++) {
|
||||
RouteLineDto routeLineDto = shortPathsList.get(i);
|
||||
String route_device = routeLineDto.getDevice_code();
|
||||
String route_next_device = routeLineDto.getNext_device_code();
|
||||
if (route_device.equals(entity.getStart_device_code()) && route_next_device.equals(entity.getNext_device_code())){
|
||||
route = routeLineDto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isEmpty(route)){
|
||||
throw new BadRequestException("未查询到相关路由!");
|
||||
}
|
||||
if (StrUtil.equals(route.getType(), "1")) {
|
||||
// != 0 为agv任务 1=magic 2=NDC 3=XZ,4=ZHEDA
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")
|
||||
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
||||
MagicAgvService magicAgvService = SpringContextHolder.getBean(MagicAgvService.class);
|
||||
magicAgvService.deleteAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
|
||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
//NDC agv指令不当场取消指令,需要等agv上报
|
||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||
ndcAgvService.deleteAgvInstToNDC(entity);
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")
|
||||
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
||||
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
|
||||
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")
|
||||
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
||||
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
|
||||
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
|
||||
@@ -187,6 +187,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
++this.error_num;
|
||||
if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
|
||||
|
||||
@@ -45,14 +45,12 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
|
||||
}while (ObjectUtil.isEmpty(pros));
|
||||
Set<String> keys = pros.keySet();
|
||||
Iterator var4 = keys.iterator();
|
||||
System.out.println("test:" + var4.hasNext());
|
||||
//代码执行一次
|
||||
while (var4.hasNext()) {
|
||||
String key = (String) var4.next();
|
||||
List<List<OpcItemDto>> list = (List) pros.get(key);
|
||||
OpcServerManageDto opcServer = (OpcServerManageDto) servers.get(key);
|
||||
Iterator var8 = list.iterator();
|
||||
System.out.println("test2:" + var8.hasNext());
|
||||
|
||||
while (var8.hasNext()) {
|
||||
List<OpcItemDto> groupProtols = (List) var8.next();
|
||||
|
||||
Reference in New Issue
Block a user