终点寻找起点路由生成指令改造
This commit is contained in:
@@ -1098,6 +1098,11 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
standardInspectSiteDeviceDriver.setBatch(batch);
|
||||
device.setMaterial_type(material_type);
|
||||
device.setBatch(batch);
|
||||
if (!StrUtil.isEmpty(hasGoodStatus)) {
|
||||
standardInspectSiteDeviceDriver.setHasGoods(Integer.parseInt(hasGoodStatus));
|
||||
device.setHas_goods(Integer.parseInt(hasGoodStatus));
|
||||
standardInspectSiteDeviceDriver.setMove(Integer.parseInt(hasGoodStatus));
|
||||
}
|
||||
} else if (device.getDeviceDriver() instanceof YkbkSpecialDeviceDriver) {
|
||||
ykbkSpecialDeviceDriver = (YkbkSpecialDeviceDriver) device.getDeviceDriver();
|
||||
ykbkSpecialDeviceDriver.setMaterial(material_type);
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
@@ -141,9 +142,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
devicecode = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
move = this.itemProtocol.getMove();
|
||||
task = this.itemProtocol.getTask();
|
||||
hasGoods = this.itemProtocol.getMove();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setEmptyrequireSucess(false);
|
||||
@@ -291,38 +290,32 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
this.instruction_require(container);
|
||||
}
|
||||
break;
|
||||
//申请
|
||||
//申请
|
||||
case 3:
|
||||
|
||||
if (!inrequireSucess){
|
||||
if (move == 1){
|
||||
if (!inrequireSucess) {
|
||||
if (move != 0) {
|
||||
this.execute_log.log("设备:" + devicecode + ",move:" + move);
|
||||
this.apply_in_require(container);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//取消
|
||||
//取消
|
||||
case 4:
|
||||
|
||||
this.cancle_require();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (!emptyrequireSucess){
|
||||
//mode = 5 并且工位上无货时申请空托盘
|
||||
if (move == 0){
|
||||
this.execute_log.log("设备:" + devicecode + ",move:" + move);
|
||||
this.apply_empty_require(container);
|
||||
}
|
||||
//终点查找起点是否有货,生成任务
|
||||
if (!inrequireSucess) {
|
||||
this.execute_log.log("设备:" + devicecode + ",move:" + move);
|
||||
this.apply_in_require_endPoint(container);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (!inrequireSucess){
|
||||
if (move == 1){
|
||||
this.execute_log.log("设备:" + devicecode + ",move:" + move);
|
||||
this.apply_in_require(container);
|
||||
}
|
||||
}
|
||||
this.cancle_require_endpoint();
|
||||
//终点取消任务
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -443,16 +436,21 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
public boolean instruction_require(String container_code) {
|
||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
public synchronized boolean apply_empty_require(String container_code) {
|
||||
|
||||
public synchronized boolean apply_empty_require(String container_code) {
|
||||
return apply_empty_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
public synchronized boolean apply_in_require(String container_code) {
|
||||
|
||||
public synchronized boolean apply_in_require(String container_code) {
|
||||
return apply_in_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
|
||||
public synchronized boolean apply_in_require_endPoint(String container_code) {
|
||||
return apply_in_require_endPoint(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求取消指令
|
||||
*
|
||||
*/
|
||||
public synchronized boolean cancle_require() throws Exception {
|
||||
Date date = new Date();
|
||||
@@ -461,19 +459,19 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
List<TaskDto> taskList = taskserver.queryTaskByDeviceCode(this.devicecode);
|
||||
try{
|
||||
if(taskList.size() != 0){
|
||||
for(int i=0;i<taskList.size();i++){
|
||||
List<TaskDto> taskList = taskserver.queryTaskByDeviceCode(this.devicecode);
|
||||
try {
|
||||
if (taskList.size() != 0) {
|
||||
for (int i = 0; i < taskList.size(); i++) {
|
||||
TaskDto task = taskList.get(i);
|
||||
Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code());
|
||||
if(ObjectUtil.isNotEmpty(inst)){
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
instructionService.cancel(inst.getInstruction_id());
|
||||
}
|
||||
taskserver.cancel(task.getTask_id());
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
writing(4);
|
||||
@@ -481,6 +479,31 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 终点请求取消指令
|
||||
*/
|
||||
public synchronized boolean cancle_require_endpoint() throws Exception {
|
||||
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 task = taskserver.findByNextCode(this.devicecode);
|
||||
try {
|
||||
Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
instructionService.cancel(inst.getInstruction_id());
|
||||
}
|
||||
taskserver.cancel(task.getTask_id());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
writing(6);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
@@ -509,7 +532,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
//获取该路由终点设备信息
|
||||
Device route_link_device = deviceAppservice.findDeviceByCode(next_device_code);
|
||||
//判断终点设备驱动是否为检测站点驱动
|
||||
if (route_link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
if (route_link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) route_link_device.getDeviceDriver();
|
||||
//判断该终点设备是否有货,有货就结束循环
|
||||
if (standardInspectSiteDeviceDriver.getMove() != 0 || standardInspectSiteDeviceDriver.getMode() != 2) {
|
||||
@@ -573,7 +596,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
writing(3);
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "创建任务失败");
|
||||
this.execute_log.log("设备:" + devicecode + "", "", "创建任务失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -582,7 +605,113 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
if (flag) {
|
||||
|
||||
inrequireSucess = true;
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定");
|
||||
this.execute_log.log("设备:" + devicecode + "", "", "对应路由设备,生成任务成功已锁定");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 终点请求指令
|
||||
*
|
||||
* @param container_code
|
||||
* @param container_type
|
||||
*/
|
||||
public synchronized boolean apply_in_require_endPoint(String container_code, String container_type) {
|
||||
WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
Date date = new Date();
|
||||
Boolean flag = false;
|
||||
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;
|
||||
//查询该设备所有路由
|
||||
List<RouteLineDto> pathLinesByCode = routelineserver.getPathLinesByCode(this.getDevice().getDevice_code(), "normal");
|
||||
StandardOrdinarySiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
for (int i = 0; i < pathLinesByCode.size(); i++) {
|
||||
RouteLineDto routeLineDto = pathLinesByCode.get(i);
|
||||
//获取该路由的起点设备编码
|
||||
String start_device_code = routeLineDto.getDevice_code();
|
||||
//获取该路由的终点设备编码
|
||||
String next_device_code = routeLineDto.getNext_device_code();
|
||||
//获取该路由终点设备信息
|
||||
Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code);
|
||||
//判断终点设备驱动是否为检测站点驱动
|
||||
if (route_link_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardInspectSiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) route_link_device.getDeviceDriver();
|
||||
// //判断该终点设备是否无货,无货就结束循环
|
||||
// if (standardInspectSiteDeviceDriver.getHasGoods() == 0) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//判断是否已经有该起点设备的任务,如果有就结束循环
|
||||
int num1 = taskserver.querySameOriginTask(start_device_code);
|
||||
if (num1 != 0) {
|
||||
continue;
|
||||
}
|
||||
//判断是否有相同终点的任务,有就结束本次循环
|
||||
int num = taskserver.querySameDestinationTask(next_device_code);
|
||||
if (num != 0) {
|
||||
continue;
|
||||
}
|
||||
/* //判断检测站点是否锁定,如果锁定就结束本次循环
|
||||
JSONObject jsonObject = runpointwo.query("device_code = '" + next_device_code + "' and islock = '1'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject)) {
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备," + next_device_code + "已锁定");
|
||||
continue;
|
||||
}*/
|
||||
//创建任务
|
||||
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.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("1");
|
||||
dto.setMaterial(this.getDevice().getMaterial_type());
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
dto.setStart_device_code(start_device_code);
|
||||
dto.setStart_point_code(start_device_code);
|
||||
dto.setNext_device_code(next_device_code);
|
||||
dto.setNext_point_code(next_device_code);
|
||||
try {
|
||||
//判断是否已经有该起点设备的任务,如果有就结束循环
|
||||
int num2 = taskserver.querySameOriginTask(start_device_code);
|
||||
if (num2 != 0) {
|
||||
continue;
|
||||
}
|
||||
//判断是否有相同终点的任务,有就结束本次循环
|
||||
int num3 = taskserver.querySameDestinationTask(next_device_code);
|
||||
if (num3 != 0) {
|
||||
continue;
|
||||
}
|
||||
taskserver.create(dto);
|
||||
/* //任务创建成功 锁定终点设备
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("islock", "true");
|
||||
map.put("update_by", "auto");
|
||||
map.put("update_time", DateUtil.now());
|
||||
runpointwo.update(map, "device_code = '" + next_device_code + "'");*/
|
||||
flag = true;
|
||||
writing(5);
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
this.execute_log.log("设备:" + devicecode + "", "", "创建任务失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//生成任务成功
|
||||
if (flag) {
|
||||
|
||||
inrequireSucess = true;
|
||||
this.execute_log.log("设备:" + devicecode + "", "", "对应路由设备,生成任务成功已锁定");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -616,7 +745,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
//获取起点设备的信息
|
||||
Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code);
|
||||
//判断起点设备驱动是否为堆叠位驱动
|
||||
if (route_link_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver){
|
||||
if (route_link_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) {
|
||||
standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) route_link_device.getDeviceDriver();
|
||||
// TODO 判断堆叠位是否有货,没货就结束本次循环
|
||||
//判断堆叠位的数量是否大于0,如果=0就结束本次循环
|
||||
@@ -679,7 +808,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
flag = true;
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "创建任务失败");
|
||||
this.execute_log.log("设备:" + devicecode + "", "", "创建任务失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -687,7 +816,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
//生成任务成功
|
||||
if (flag) {
|
||||
emptyrequireSucess = true;
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定");
|
||||
this.execute_log.log("设备:" + devicecode + "", "", "对应路由设备,生成任务成功已锁定");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -517,16 +517,18 @@ public class StageActorServiceImpl implements StageActorService {
|
||||
} else if (standardInspectSiteDevicedriver.getMode() == 2) {
|
||||
mode = "联机";
|
||||
}
|
||||
if (standardInspectSiteDevicedriver.getMove() == 0) {
|
||||
if (standardInspectSiteDevicedriver.getHasGoods() == 0) {
|
||||
move = "无货";
|
||||
} else if (standardInspectSiteDevicedriver.getMove() == 1) {
|
||||
} else if (standardInspectSiteDevicedriver.getHasGoods() == 1) {
|
||||
move = "有货";
|
||||
} else if (standardInspectSiteDevicedriver.getMove() == 2) {
|
||||
} else if (standardInspectSiteDevicedriver.getHasGoods() == 2) {
|
||||
move = "有托盘有货";
|
||||
}
|
||||
obj.put("device_name", standardInspectSiteDevicedriver.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
//点击弹出
|
||||
jo.put("is_click", true);
|
||||
jo.put("hasGoods", standardInspectSiteDevicedriver.getHasGoods());
|
||||
jo.put("isOnline", standardInspectSiteDevicedriver.getIsonline());
|
||||
jo.put("error", standardInspectSiteDevicedriver.getError());
|
||||
|
||||
@@ -279,22 +279,22 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
}
|
||||
//普通站点
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
// if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) {
|
||||
// inst.setExecute_status("1");
|
||||
// instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
if (device.getHas_goods() != 0) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
log.info("AGV请求取货设备{}无货,无法反馈", device_code);
|
||||
}
|
||||
}
|
||||
// } else {
|
||||
// if (device.getHas_goods() != 0) {
|
||||
// inst.setExecute_status("1");
|
||||
// instructionService.update(inst);
|
||||
// data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
// flag = true;
|
||||
// } else {
|
||||
// log.info("AGV请求取货设备{}无货,无法反馈", device_code);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
//标准版-货架
|
||||
|
||||
Reference in New Issue
Block a user