This commit is contained in:
USER-20220102CG\noblelift
2023-02-28 18:39:32 +08:00
parent 0b0b7e62bf
commit 0c3075584d
22 changed files with 931 additions and 421 deletions

View File

@@ -8,6 +8,7 @@ import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.service.InstructionService;
@@ -132,6 +133,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
String device_code = null;
String old_device_code = null;
String emptyNum = null;
//自动门
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
if (agvaddr != 0) {
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
if (StrUtil.contains(old_device_code, "-")) {
@@ -187,6 +190,34 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
instructionService.cancelNOSendAgv(inst.getInstruction_id());
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else if (phase == 0x50) {
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
standardAutodoorDeviceDriver.writing("to_open","1");
standardAutodoorDeviceDriver.writing("to_close","0");
if(standardAutodoorDeviceDriver.getOpen() == 1){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
} else if (phase == 0x51) {
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
standardAutodoorDeviceDriver.writing("to_close","1");
standardAutodoorDeviceDriver.writing(
"to_open","0");
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
} else {
//上报异常信息
//不需要WCS反馈

View File

@@ -47,7 +47,9 @@ public enum DriverTypeEnum {
SIEMENS_ONEFLOOR_AGV_CONVEYOR(17, "siemens_onefloor_agv_conveyor", "西门子-1LAGV-输送机驱动", "conveyor"),
PHOTOELECTRIC_INSPECTION_SITE(19, "photoelectric_inspection_site", "光电-检测站点", "conveyor");
PHOTOELECTRIC_INSPECTION_SITE(19, "photoelectric_inspection_site", "光电-检测站点", "conveyor"),
STANDARD_AUTODOOR(20, "standard_autodoor", "标准版-自动门", "autodoor");
//驱动索引

View File

@@ -12,6 +12,8 @@ import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.photoelectric_inspection_site.PhotoelectricInspectionSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
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.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
@@ -114,6 +116,10 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
StandardStorageDeviceDriver standardStorageDeviceDriver;
//普通-光电检测
PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
//标准-光电检测
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
//自动门
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
if (phase == 0x02) {
if (ObjectUtil.isEmpty(inst)) {
@@ -184,6 +190,12 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) device.getDeviceDriver();
if(photoelectricInspectionSiteDeviceDriver.getMove() == 1)
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing("to_command","1");
if(standardInspectSiteDeviceDriver.getMove() == 1 && standardInspectSiteDeviceDriver.getAction() == 1){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
@@ -240,6 +252,12 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
this.setPhase(phase);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing("to_command","0");
if(standardInspectSiteDeviceDriver.getMove() == 0 ){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
@@ -419,6 +437,12 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) device.getDeviceDriver();
if(photoelectricInspectionSiteDeviceDriver.getMove() == 0)
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing("to_command","1");
if(standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getAction() ==1 ){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
@@ -474,6 +498,12 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
}
this.setPhase(phase);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing("to_command","0");
if(standardInspectSiteDeviceDriver.getMove() == 1 ){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
@@ -481,9 +511,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
//到达放货点
//Itype=1、3,需要WCS反馈
else if (phase == 0x10) {
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
return;
@@ -601,22 +628,15 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
} //进入区域phase值
else if (phase == 0x50) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
region = agvaddr;
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
//离开区域phase值
else if (phase == 0x51) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
region = agvaddr;
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
//上报异常信息
//不需要WCS反馈

View File

@@ -16,6 +16,7 @@ import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.photoelectric_inspection_site.PhotoelectricInspectionSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
@@ -87,7 +88,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private int instruction_require_time_out;
private int instruction_require_time_out = 3000;
//行架机械手申请任务成功标识
boolean requireSucess = false;
@@ -531,33 +532,40 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver();
if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!";
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:"+instruction.getInstruction_code();
return false;
}
}
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:"+instruction.getInstruction_code();
return false;
}
}
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "无货,无法下发指令!";
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:"+instruction.getInstruction_code();
return false;
}
}
if (nextdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) nextdevice.getDeviceDriver();
if (photoelectricInspectionSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "有货,无法下发指令!";
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "有货,无法下发指令!指令号:"+instruction.getInstruction_code();
return false;
}
}
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "有货,无法下发指令!";
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:"+instruction.getInstruction_code();
return false;
}
}
@@ -584,7 +592,10 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
this.writing("to_target", next_addr);
this.writing("to_task", instruction.getInstruction_code());
this.writing("to_command", "1");
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing("to_open_door","1");
}
this.setNow_steps_type(2);
this.setRequireSucess(true);
return true;
@@ -603,6 +614,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code());
PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver();
if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) {
@@ -610,6 +622,13 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
return false;
}
}
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "光电无货,无法生成指令!";
return false;
}
}
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) {
@@ -632,6 +651,13 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
return false;
}
}
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "光电有货,无法生成指令!";
return false;
}
}
String taskid = task.getTask_id();
String taskcode = task.getTask_code();
String vehiclecode = task.getVehicle_code();

View File

@@ -102,7 +102,7 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
private Date require_empty_in_time = new Date();
private Date require_empty_out_time = new Date();
private int instruction_require_time_out;
private int instruction_require_time_out =3000;
// 行架机械手申请任务成功标识
boolean requireSucess = false;
boolean requireApplyLabelingSuccess = false;
@@ -214,24 +214,12 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
var17.printStackTrace();
inst_message = var17.getMessage();
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage());
// return;
}
// if (!this.itemProtocol.getIsonline()) {
// this.setIsonline(false);
// this.setIserror(true);
// message = "信号量同步异常";
// //未联机
// } else
if (mode == 0) {
this.setIsonline(false);
message = "未联机";
// 有报警
// } else if (error != 0) {
// this.setIsonline(false);
// this.setIserror(true);
// message = "有报警";
// //无报警
} else {
this.setIsonline(true);
this.setIserror(false);

View File

@@ -225,19 +225,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
inst1.setInstruction_status("1");
inst1.setExecute_device_code(this.getDevice_code());
instructionService.update(inst1);
// TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
// if (!ObjectUtil.isEmpty(taskDto)) {
// if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
// JSONArray array = new JSONArray();
// JSONObject map = new JSONObject();
// map.put("task_id", taskDto.getExt_task_id());
// map.put("task_status", "1");
// array.add(map);
// acsToWmsService.feedbackTaskStatusToWms(array);
// }
// }
;
//this.setNow_steps_type1(1);
}
}
}
@@ -1213,8 +1200,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(value));

View File

@@ -0,0 +1,82 @@
package org.nl.acs.device_driver.basedriver.standard_autodoor;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ItemProtocol {
public static String item_open = "open";
public static String item_close = "close";
public static String item_to_open = "to_open";
public static String item_to_close = "to_close";
private StandardAutodoorDeviceDriver driver;
public ItemProtocol(StandardAutodoorDeviceDriver driver) {
this.driver = driver;
}
public int getOpen() {
return this.getOpcIntegerValue(item_open);
}
public int getClose() {
return this.getOpcIntegerValue(item_close);
}
public int getToOpen() {
return this.getOpcIntegerValue(item_to_open);
}
public int getToClose() {
return this.getOpcIntegerValue(item_to_close);
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
} else {
return value;
}
return 0;
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isEmpty(value)) {
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_open, "开到位", "10001"));
list.add(new ItemDto(item_close, "关到位", "10002"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_open, "下发开门", "00001" ));
list.add(new ItemDto(item_to_close, "下发关门", "00002"));
return list;
}
@Override
public String toString() {
return "";
}
}

View File

@@ -0,0 +1,63 @@
package org.nl.acs.device_driver.basedriver.standard_autodoor;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 自动门驱动定义
*/
@Service
public class StandardAutodoorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "standard_autodoor";
}
@Override
public String getDriverName() {
return "标准版-自动门";
}
@Override
public String getDriverDescription() {
return "标准版-自动门";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StandardAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StandardAutodoorDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -0,0 +1,69 @@
package org.nl.acs.device_driver.basedriver.standard_autodoor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.Device;
import org.nl.modules.wql.util.SpringContextHolder;
import java.util.HashMap;
import java.util.Map;
/**
* 自动门驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
int open = 0;
int close = 0;
int last_open = 0;
int last_close = 0;
String device_code = null;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
String message = null;
device_code = this.getDevice().getDevice_code();
open = this.itemProtocol.getOpen();
close = this.itemProtocol.getClose();
if (open != last_open) {
}
if (close != last_close) {
}
last_open = open;
last_close = close;
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(value));
this.control(itemMap);
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
}
}

View File

@@ -507,22 +507,6 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
message ="当前载具号"+container_code+"查找对应指令起点与当前设备不符";
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务"
+"当前载具号"+container_code+"查找对应指令起点与当前设备不符");
// this.setIserror(true);
// List list = new ArrayList();
// Map map = new HashMap();
// map.put("code","to_target");
// map.put("value","1011");
// list.add(map);
// Map map2 = new HashMap();
// map2.put("code","to_command");
// map2.put("value","1");
// Map map3 = new HashMap();
// map3.put("code","to_task");
// map3.put("value","0");
// list.add(map3);
// this.writing(list);
// this.setRequireSucess(true);
// this.setApplySucess(true);
return false;
}
this.setIserror(false);
@@ -555,16 +539,22 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
message = "下发电气任务号成功";
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号"+container_code
+"已存在对应任务,下发电气信号");
// if(task != Integer.parseInt(instdto.getInstruction_code()) ){
// this.writing(list);
// logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发电气信号");
// }
requireSucess = true;
applySucess = true;
} else {
message = "任务号:" + taskdto.getTask_code() + "未找到指令";
}
return true;
} else {
//需要判断指令中的指令 再次请求不能生成
if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(),"1"))) {
{
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code
+ "已存在对应任务");
requireSucess = true;
applySucess = true;
}
}
}
String taskid = taskdto.getTask_id();
@@ -722,6 +712,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
map3.put("value","0");
list.add(map3);
this.writing(list);
requireSucess = true;
applySucess = true;
message = "申请任务失败接口不通下发退回";
} else {
if (jo.getInteger("status") == 200) {

View File

@@ -14,13 +14,12 @@ public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_ioaction = "ioaction";
public static String item_action = "action";
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_target = "to_target";
public static String item_to_task = "to_task";
public static String item_weight = "weight";
private StandardInspectSiteDeviceDriver driver;
@@ -40,8 +39,8 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_move);
}
public int getIoaction() {
return this.getOpcIntegerValue(item_ioaction);
public int getAction() {
return this.getOpcIntegerValue(item_action);
}
public int getError() {
@@ -87,16 +86,17 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(item_task, "任务", "DB600.D8"));
list.add(new ItemDto(item_mode, "工作状态", "DB600.B2"));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3"));
list.add(new ItemDto(item_action, "动作信号", "DB600.B4"));
list.add(new ItemDto(item_error, "报警信", "DB600.B5"));
list.add(new ItemDto(item_task, "任务号", "DB600.D6"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
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"));
list.add(new ItemDto(item_to_target, "目标站", "DB601.W4"));
list.add(new ItemDto(item_to_task, "任务号", "DB601.D8"));
return list;

View File

@@ -50,19 +50,10 @@ public class StandardInspectSiteDefination implements OpcDeviceDriverDefination
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true));
list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2"));
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8"));
return list;
return ItemProtocol.getReadableItemDtos();
}
@Override
@@ -70,4 +61,5 @@ public class StandardInspectSiteDefination implements OpcDeviceDriverDefination
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -15,6 +15,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
@@ -43,14 +44,10 @@ import java.util.Map;
@RequiredArgsConstructor
public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver , DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
@Autowired
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
String container;
String container_type_desc;
String last_container_type_desc;
@@ -64,6 +61,8 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
int error = 0;
int move = 0;
int task = 0;
int action = 0;
int last_action = 0;
int last_mode = 0;
int last_error = 0;
int last_move = 0;
@@ -117,7 +116,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
String devicecode;
String device_code = null;
@Override
public Device getDevice() {
@@ -129,91 +128,41 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
public void execute() {
String message = null;
try {
String device_code = this.getDeviceCode();
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
action = this.itemProtocol.getAction();
task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove();
if (mode != last_mode) {
this.setRequireSucess(false);
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
}
if (move != last_move) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move);
}
if (error != last_error) {
}
if (this.getApply_handling()) {
String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device link_device = appService.findDeviceByCode(link_device_code);
StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver;
if (link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver();
// if(standardInspectSiteDevicedriver.getMode() != 2){
// log.debug("设备未待机");
// return;
// }
// if(standardInspectSiteDevicedriver.getMove() != 0){
// log.debug("设备不满足放货条件");
// return;
// }
//如果目标设备申请叫料 则允许生成任务
if (standardInspectSiteDevicedriver.getApply_material()) {
TaskDto dto = new TaskDto();
String now = DateUtil.now();
dto.setTask_id(IdUtil.simpleUUID());
dto.setCreate_by(this.getDevice().getDevice_code());
dto.setUpdate_by(this.getDevice().getDevice_code());
dto.setStart_point_code(this.getDevice().getDevice_code());
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
dto.setPriority("101");
// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
// String next_device_codecode = jo.getNext_device_code();
// if(StrUtil.isEmpty(next_device_codecode)){
// throw new RuntimeException("该设备未找到对应路由");
// }
dto.setNext_point_code(standardInspectSiteDevicedriver.getDevicecode());
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json);
standardInspectSiteDevicedriver.setApply_material(false);
}
}
this.setApply_handling(false);
if (action != last_action) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号action" + last_action + "->" + action);
}
} catch (Exception var17) {
return;
}
if (!this.itemProtocol.getIsonline()) {
if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
if (error != 0) {
this.setIserror(true);
message = "有报警";
}
message = "";
Instruction instruction = null;
List toInstructions;
@@ -222,76 +171,14 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
log.debug("设备运转模式:等待工作");
return;
case 2:
//申请任务
// if (this.getApply_handling()) {
// String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
// Device link_device = appService.findDeviceByCode(link_device_code);
// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver;
// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver();
// if(standardInspectSiteDevicedriver.getMode() != 2){
// log.debug("设备未待机");
// return;
// }
// if(standardInspectSiteDevicedriver.getMove() != 0){
// log.debug("设备不满足放货条件");
// return;
// }
//
// //如果目标设备申请叫料 则允许生成任务
// if(standardInspectSiteDevicedriver.getApply_material()){
// TaskDto dto = new TaskDto();
// String now = DateUtil.now();
// dto.setTask_id(IdUtil.simpleUUID());
// dto.setCreate_by(this.getDevice().getDevice_code());
// dto.setUpdate_by(this.getDevice().getDevice_code());
// dto.setStart_point_code(this.getDevice().getDevice_code());
//
// String taskcode = CodeGenerateUtil.getNewCode("TASK_NO");
// dto.setTask_code("-"+taskcode);
// dto.setTask_status("0");
// dto.setPriority("101");
// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
// String next_device_codecode = jo.getNext_device_code();
// if(StrUtil.isEmpty(next_device_codecode)){
// throw new RuntimeException("该设备未找到对应路由");
// }
// dto.setNext_point_code(next_device_codecode);
// dto.setUpdate_time(now);
// dto.setCreate_time(now);
//
// WQLObject wo = WQLObject.getWQLObject("acs_task");
// JSONObject json = (JSONObject) JSONObject.toJSON(dto);
// wo.insert(json);
// standardInspectSiteDevicedriver.setApply_material(false);
// }
// }
// this.setApply_handling(false);
// }
if (material.length() > 0 && qty.length() > 0 && !requireSucess) {
this.instruction_require(container);
}
}
switch (flag) {
//取货完成
case 1:
writing(2);
return;
//放货完成
case 2:
writing(3);
return;
break;
}
}
last_mode = mode;
last_error = error;
last_move = move;
last_action = action;
last_task = task;
}
@@ -306,137 +193,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
}
}
protected void thingToNothing() {
log.debug("从有货到无货 清理数据");
this.set_last_container(container, container_type_desc);
}
public void set_last_container(String barcode, String type_desc) {
this.set_last_container(barcode);
this.set_last_container_type_desc(type_desc);
}
public void set_last_container(String barcode) {
}
public void set_last_container_type_desc(String type) {
}
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + 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;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
if (appendMessage == null) {
appendMessage = "";
}
if (instruction != null) {
instruction_num = Integer.parseInt(instruction.getInstruction_code());
}
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, 1);
itemMap.put(to_task, instruction_num);
this.control(itemMap);
}
public void executing(Server server, Map<String, Object> itemMap) {
this.control(itemMap);
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
this.control(itemMap);
}
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;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + 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 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);
} else if (type == 2) {
itemMap.put(to_target, command);
} else if (type == 3) {
itemMap.put(to_task, command);
}
this.control(itemMap);
}
public boolean instruction_require(String container_code) {
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
}
/**
* 请求指令
*
* @param container_code
* @param container_type
*/
public synchronized boolean instruction_require(String container_code, String container_type) {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
TaskDto dto = new TaskDto();
String now = DateUtil.now();
dto.setTask_id(IdUtil.simpleUUID());
dto.setCreate_by(this.getDevice().getDevice_code());
dto.setUpdate_by(this.getDevice().getDevice_code());
dto.setStart_point_code(this.getDevice().getDevice_code());
dto.setVehicle_code(container_code);
dto.setVehicle_type(container_type);
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
dto.setPriority("101");
RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
String next_device_codecode = jo.getNext_device_code();
if (StrUtil.isEmpty(next_device_codecode)) {
throw new RuntimeException("该设备未找到对应路由");
}
dto.setNext_point_code(next_device_codecode);
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json);
requireSucess = false;
return true;
}
}
@Override
public JSONObject getDeviceStatusName() {
@@ -479,4 +236,14 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
public void setDeviceStatus(JSONObject data) {
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(value));
this.control(itemMap);
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
}
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.ext.wms.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@@ -527,6 +528,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
continue;
}
if(StrUtil.equals(task_type,"8")){
next_device_code = request.getPut_device_code();
put_device_code = request.getNext_device_code();
}
JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0);
if (!ObjectUtil.isEmpty(start_device_json)) {
@@ -654,8 +659,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
JSONObject jo = new JSONObject();
jo.put("task_id", IdUtil.simpleUUID());
jo.put("task_code", task_code);
jo.put("task_id", ext_task_id);
jo.put("start_point_code", start_point_code);
jo.put("next_point_code", next_point_code);
jo.put("start_point_code2", start_point_code2);
@@ -688,7 +693,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (StrUtil.equals(task_dto.getTask_type(), "7")) {
//创建临时指令 不创建、不生成
//等立库反馈成功才能创建任务和指令
Instruction inst = taskService.createTemporaryInst(task_dto);
Instruction inst = null;
try {
inst = taskService.createTemporaryInst(task_dto);
} catch (Exception e){
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", e.getMessage());
errArr.add(json);
continue;
}
Resp resp = acsToLiKuService.sendInst(task_dto.getStorage_task_type(),inst);
if(StrUtil.equals(resp.result,"true")){
@@ -798,10 +813,11 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
JSONObject resultJson = new JSONObject();
if (ObjectUtil.isEmpty(errArr)) {
resultJson.put("status", HttpStatus.OK);
} else {
resultJson.put("status", HttpStatus.BAD_REQUEST);
resultJson.put("status", HttpStatus.OK.value());
resultJson.put("message", "操作成功");
} else {
resultJson.put("status", HttpStatus.BAD_REQUEST.value());
resultJson.put("message", "操作失败");
if(ObjectUtil.isNotEmpty(errArr)){
resultJson.put("errArr",errArr);
}

View File

@@ -88,6 +88,8 @@ public interface InstructionService {
Instruction findByTaskcodeAndStatus(String code);
Instruction findByTaskcodeAndStatus(String code,String status);
/**
* 根据任务id查询
*
@@ -158,6 +160,13 @@ public interface InstructionService {
void finishAndCreateNextInst(Instruction dto) throws Exception;
/**
* 完成并创建指令
*
* @param
*/
void finishAndCreateHXInst(Instruction dto) throws Exception;
/**
* 取消指令
*
@@ -261,14 +270,6 @@ public interface InstructionService {
*/
Integer querySameOriginInst(String code);
/**
* 查询相同起点、终点指令的数量
*
* @param code
* @return
*/
//Integer querySameOriginInst(String code);
boolean removeByCodeFromCache(String code);

View File

@@ -261,6 +261,21 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
return null;
}
@Override
public Instruction findByTaskcodeAndStatus(String code,String status) {
Iterator var3 = instructions.iterator();
while (var3.hasNext()) {
Instruction instruction = (Instruction) var3.next();
if (StrUtil.equals(instruction.getTask_code(), code)
&& StrUtil.equals(instruction.getInstruction_status(), status)) {
return instruction;
}
}
return null;
}
@Override
public Instruction findByTaskid(String id, String wherecaluse) {
if (!StrUtil.isEmpty(wherecaluse)) {
@@ -728,11 +743,30 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
TaskDto obj = taskjson.toJavaObject(TaskDto.class);
// =0 则不用再次请求
if (StrUtil.equals(obj.getRequest_again(), "0")) {
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
if(StrUtil.equals(obj.getTask_type(),"8")){
//中转为空
if(StrUtil.isEmpty(obj.getPut_device_code())){
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
} else {
finishAndCreateNextInst(entity);
}
} else {
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
finishAndCreateHXInst(entity);
} else if (StrUtil.equals(obj.getPut_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
}
}
} else {
finishAndCreateNextInst(entity);
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
} else {
finishAndCreateNextInst(entity);
}
}
}
removeByCodeFromCache(entity.getInstruction_code());
@@ -755,11 +789,30 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
TaskDto obj = taskjson.toJavaObject(TaskDto.class);
// =0 则不用再次请求
if (StrUtil.equals(obj.getRequest_again(), "0")) {
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
if(StrUtil.equals(obj.getTask_type(),"8")){
//中转为空
if(StrUtil.isEmpty(obj.getPut_device_code())){
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
} else {
finishAndCreateNextInst(dto);
}
} else {
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
finishAndCreateHXInst(dto);
} else if (StrUtil.equals(obj.getPut_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
}
}
} else {
finishAndCreateNextInst(dto);
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
} else {
finishAndCreateNextInst(dto);
}
}
}
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
@@ -876,6 +929,71 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void finishAndCreateHXInst(Instruction dto) {
dto = foramte(dto);
String device_code = dto.getNext_device_code();
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0);
TaskDto acsTask = taskjson.toJavaObject(TaskDto.class);
String next_device_code = acsTask.getPut_device_code();
String start_device_code = dto.getNext_device_code();
String start_point_code = null;
String next_point_code = null;
String start_device =
deviceAppService
.findDeviceByCode(start_device_code)
.getDeviceDriverDefination()
.getFitDeviceTypes()
.get(0)
.name();
String next_device =
deviceAppService
.findDeviceByCode(next_device_code)
.getDeviceDriverDefination()
.getFitDeviceTypes()
.get(0)
.name();
if (StrUtil.equals("storage", start_device)) {
start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z();
} else {
start_point_code = start_device_code;
}
if (StrUtil.equals("storage", next_device)) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(acsTask.getRoute_plan_code());
instdto.setRemark(acsTask.getRemark());
instdto.setMaterial(acsTask.getMaterial());
instdto.setQuantity(acsTask.getQuantity());
instdto.setTask_id(acsTask.getTask_id());
instdto.setTask_code(acsTask.getTask_code());
instdto.setVehicle_code(acsTask.getVehicle_code());
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.setPriority(acsTask.getPriority());
instdto.setInstruction_status("0");
instdto.setExecute_device_code(dto.getNext_device_code());
try {
this.create(instdto);
} catch (Exception e) {
e.printStackTrace();
log.error("完成并创建下一条指令", e.getMessage());
}
}
@Override
public void cancel(String id) throws Exception {
// flag= true时取消指令

View File

@@ -367,6 +367,23 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (ObjectUtil.isNotEmpty(instruction)) {
list.add(task);
}
} else {
if(StrUtil.equals(task.getTask_type(),"8") && StrUtil.isNotEmpty(task.getPut_device_code()))
{
// if(task.getNext_device_code().equals(device_code)
// && StrUtil.equals(task.getTask_status(), "1")){
// Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
// if (ObjectUtil.isNotEmpty(instruction)) {
// list.add(task);
// }
// }
Instruction instruction = instructionService.findByDeviceCodeFromCache(device_code);
if (ObjectUtil.isNotEmpty(instruction)) {
if(StrUtil.equals(instruction.getStart_device_code(),device_code)){
list.add(task);
}
}
}
}
}
return list;
@@ -777,7 +794,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code());
System.out.println(feefbackdto == null);
JSONObject feed_jo = new JSONObject();
feed_jo.put("task_id", entity.getTask_id());
feed_jo.put("task_id", entity.getExt_task_id());
feed_jo.put("task_code", entity.getTask_code());
feed_jo.put("task_status", entity.getTask_status());
JSONArray ja = new JSONArray();
@@ -909,7 +926,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
JSONObject feed_jo = new JSONObject();
feed_jo.put("task_id", entity.getTask_id());
feed_jo.put("task_id", entity.getExt_task_id());
feed_jo.put("task_code", entity.getTask_code());
feed_jo.put("task_status", entity.getTask_status());
JSONArray ja = new JSONArray();
@@ -939,11 +956,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
// InstructionDto inst = instructionservice.findByTaskid(acsTask, "instruction_status < 2
// ");
// if (inst != null) {
// throw new BadRequestException("有指令未完成!");
// }
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
@@ -975,6 +987,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
start_device_code, acsTask.getNext_device_code(), route_plan_code);
if(ObjectUtil.isEmpty(shortPathsList)){
throw new BadRequestException(start_device_code + "->" + acsTask.getNext_device_code() + "路由不通!");
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();

View File

@@ -65,7 +65,6 @@ public class AutoCreateInst {
String next_point_code2 = acsTask.getNext_point_code2();
String next_device_code2 = acsTask.getNext_device_code2();
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
@@ -158,6 +157,8 @@ public class AutoCreateInst {
instdto.setAgv_inst_type("2");
} else if (StrUtil.equals(task_type, "2")) {
instdto.setAgv_inst_type("3");
} else if (StrUtil.equals(task_type, "8")) {
instdto.setAgv_inst_type("2");
}
} else {
instdto.setAgv_inst_type("4");