更新检测站点
This commit is contained in:
@@ -2,6 +2,7 @@ package org.nl.acs.device_driver.standard_inspect_site;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -13,6 +14,7 @@ import org.nl.acs.device_driver.DeviceDriver;
|
||||
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.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
@@ -50,6 +52,8 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
@@ -88,6 +92,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
boolean inrequireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
@@ -280,6 +285,22 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
this.instruction_require(container);
|
||||
|
||||
}
|
||||
|
||||
case 5:
|
||||
if (!requireSucess){
|
||||
//mode = 5 并且工位上无货时申请空托盘
|
||||
if (move == 0){
|
||||
this.execute_log.log("设备:" + devicecode + ",move:" + move);
|
||||
this.apply_empty_require(container);
|
||||
}
|
||||
}
|
||||
case 6:
|
||||
if (!inrequireSucess){
|
||||
if (move == 1){
|
||||
this.execute_log.log("设备:" + devicecode + ",move:" + move);
|
||||
this.apply_in_require(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
@@ -399,6 +420,193 @@ 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 boolean apply_empty_require(String container_code) {
|
||||
return apply_empty_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
public boolean apply_in_require(String container_code) {
|
||||
return apply_in_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
*
|
||||
* @param container_code
|
||||
* @param container_type
|
||||
*/
|
||||
public synchronized boolean apply_in_require(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.getSuperiorShortPathLinesByCode(this.getDevice().getDevice_code(), "normal");
|
||||
StandardInspectSiteDeviceDriver 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(next_device_code);
|
||||
//判断终点设备驱动是否为检测站点驱动
|
||||
if (route_link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) route_link_device.getDeviceDriver();
|
||||
//判断该终点设备是否有货,有货就结束循环
|
||||
if (standardInspectSiteDeviceDriver.getMove() != 0 || standardInspectSiteDeviceDriver.getMode() != 2) {
|
||||
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("101");
|
||||
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 {
|
||||
taskserver.create(dto);
|
||||
//任务创建成功 锁定终点设备
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("islock", "1");
|
||||
map.put("update_by", "auto");
|
||||
map.put("update_time", DateUtil.now());
|
||||
runpointwo.update(map, "device_code = '" + next_device_code + "'");
|
||||
flag = true;
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "创建任务失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//生成任务成功
|
||||
if (flag) {
|
||||
requireSucess = false;
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
*
|
||||
* @param container_code
|
||||
* @param container_type
|
||||
*/
|
||||
public synchronized boolean apply_empty_require(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");
|
||||
StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver;
|
||||
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 StandardEmptyPalletSiteDeviceDriver){
|
||||
standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) route_link_device.getDeviceDriver();
|
||||
// TODO 判断堆叠位是否有货,没货就结束本次循环
|
||||
if (standardEmptyPalletSiteDeviceDriver.getMove() != 1) {
|
||||
continue;
|
||||
}
|
||||
//判断堆叠位的数量是否大于0,如果=0就结束本次循环
|
||||
if (standardEmptyPalletSiteDeviceDriver.getNumber() == 0){
|
||||
continue;
|
||||
}
|
||||
//判断是否已经有到该终点设备的任务,如果有就结束循环
|
||||
int num = taskserver.querySameOriginTask(start_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("101");
|
||||
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 {
|
||||
taskserver.create(dto);
|
||||
//任务创建成功 锁定该终点设备
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("islock", "1");
|
||||
map.put("update_by", "auto");
|
||||
map.put("update_time", DateUtil.now());
|
||||
runpointwo.update(map, "device_code = '" + next_device_code + "'");
|
||||
flag = true;
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "创建任务失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//生成任务成功
|
||||
if (flag) {
|
||||
requireSucess = false;
|
||||
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
|
||||
@@ -565,7 +565,7 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RouteLineDto routeLineDto = (RouteLineDto) iterator.next();
|
||||
if (StrUtil.equals(routeLineDto.getNext_device_code(), device_code)) {
|
||||
if (StrUtil.equals(routeLineDto.getDevice_code(), device_code)) {
|
||||
result.add(routeLineDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,4 +253,20 @@ public interface TaskService {
|
||||
*/
|
||||
Integer querySameTaskByType(String taskType);
|
||||
|
||||
/**
|
||||
* 查询相同终任务的数量
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Integer querySameDestinationTask(String code);
|
||||
|
||||
/**
|
||||
* 查询相同起任务的数量
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Integer querySameOriginTask(String code);
|
||||
|
||||
}
|
||||
|
||||
@@ -548,9 +548,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {
|
||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() == 0) {
|
||||
/* if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() == 0) {
|
||||
throw new Exception("任务起点需满足待机有货!");
|
||||
}
|
||||
}*/
|
||||
if (!StrUtil.isEmpty(standardInspectSiteDeviceDriver.getMaterial())) {
|
||||
dto.setMaterial(standardInspectSiteDeviceDriver.getMaterial());
|
||||
}
|
||||
@@ -574,10 +574,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
// }
|
||||
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
/* standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() != 0) {
|
||||
throw new Exception("任务终点需满足待机无货!");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
@@ -1541,4 +1541,38 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameDestinationTask(String devicecode) {
|
||||
int num = 0;
|
||||
for (int i = 0; i < this.tasks.size(); i++) {
|
||||
TaskDto task = tasks.get(i);
|
||||
//处理空盘位站点
|
||||
String next_device_code = task.getNext_device_code();
|
||||
if (next_device_code.indexOf(".") != -1) {
|
||||
next_device_code = next_device_code.substring(0, next_device_code.indexOf("."));
|
||||
}
|
||||
if (StrUtil.equals(devicecode, next_device_code)) {
|
||||
num = num + 1;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameOriginTask(String devicecode) {
|
||||
int num = 0;
|
||||
for (int i = 0; i < this.tasks.size(); i++) {
|
||||
TaskDto task = tasks.get(i);
|
||||
//处理空盘位站点
|
||||
String start_device_code = task.getStart_device_code();
|
||||
if (start_device_code.indexOf(".") != -1) {
|
||||
start_device_code = start_device_code.substring(0, start_device_code.indexOf("."));
|
||||
}
|
||||
if (StrUtil.equals(devicecode, start_device_code)) {
|
||||
num = num + 1;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user