Browse Source

更新

master
gengby 2 years ago
parent
commit
463731f391
  1. 16
      hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
  2. 137
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java
  3. 27
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java
  4. 42
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
  5. 18
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

16
hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java

@ -75,6 +75,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
private final AcsConfigService acsConfigService;
@Autowired
TaskService taskService;
List<StorageCellDto> storageCells = new ArrayList<>();
private Map<String, Integer> storage_address = new HashMap();
@ -507,13 +508,15 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' and region != '' and is_config= 'true' ").getResultJSONArray(0);
JSONArray result = new JSONArray();
WQLObject wo = WQLObject.getWQLObject("sys_dict_detail");
// status=2 代表查询请求的设备 =3代表查询相应的设备
if (status.equals("2")) {
for (int i = 0; i < arr.size(); i++) {
JSONObject devicejo = new JSONObject();
JSONObject obj = arr.getJSONObject(i);
String region = obj.optString("region");
JSONObject jsonObject = wo.query("name = 'region_type' and value = '" + region + "'").uniqueResult(0);
region = jsonObject.getString("label");
String device_code = obj.optString("device_code");
Device device = appService.findDeviceByCode(device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
@ -536,6 +539,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONObject devicejo = new JSONObject();
JSONObject obj = arr.getJSONObject(i);
String region = obj.optString("region");
JSONObject jsonObject = wo.query("name = 'region_type' and value = '" + region + "'").uniqueResult(0);
region = jsonObject.getString("label");
String device_code = obj.optString("device_code");
Device device = appService.findDeviceByCode(device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
@ -558,6 +563,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONObject devicejo = new JSONObject();
JSONObject obj = arr.getJSONObject(i);
String region = obj.optString("region");
JSONObject jsonObject = wo.query("name = 'region_type' and value = '" + region + "'").uniqueResult(0);
region = jsonObject.getString("label");
String device_code = obj.optString("device_code");
Device device = appService.findDeviceByCode(device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
@ -1182,8 +1189,14 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
//判断是否已经有该起点设备的任务,如果有就结束循环
int num1 = taskService.querySameOriginTask(start_device_code);
if (num1 != 0){
throw new BadRequestException("起点任务已存在,创建失败");
}
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setBranchProtocol(4);
standardOrdinarySiteDeviceDriver.setRequireSucess(false);
standardOrdinarySiteDeviceDriver.setMaterial(material_type);
standardOrdinarySiteDeviceDriver.setBatch(batch);
}
@ -1231,6 +1244,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setBranchProtocol(0);
standardOrdinarySiteDeviceDriver.setHasGoods(0);
JSONObject jsonjo = new JSONObject();
jsonjo.put("device_code", start_device_code);

137
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java

@ -17,6 +17,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_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
@ -25,11 +26,14 @@ import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.WcsConfig;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SpringContextHolder;
import org.nl.wql.core.bean.WQLObject;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
@ -57,7 +61,8 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
String container;
String container_type_desc;
String last_container_type_desc;
@ -105,7 +110,7 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver
Instruction inst = null;
//上次指令
Instruction last_inst = null;
int max_emptypalletnum;
//触摸屏手动触发任务
private Boolean is_has_task = false;
@ -120,7 +125,7 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver
try {
String device_code = this.getDeviceCode();
int max_emptypalletnum = Integer.parseInt(this.getDevice().getExtraValue().get("max_emptypalletnum").toString());
max_emptypalletnum = Integer.parseInt(this.getDevice().getExtraValue().get("max_emptypalletnum").toString());
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
@ -141,6 +146,9 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver
}
}
if (number != last_number) {
if (number == max_emptypalletnum){
requireSucess = false;
}
this.execute_log.setResource(this.getDevicecode(), this.getDevice().getDevice_name());
this.execute_log.log("设备:" + device_code + ",last_number -> number:" + last_number + "->" + number);
}
@ -183,7 +191,13 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver
log.debug("设备运转模式:等待工作");
return;
case 2:
String apply_task ="";
if (!requireSucess){
if (move > 0) {
this.execute_log.log("设备:" + devicecode + ",move:" + move);
this.apply_take_empty(container);
}
}
/* String apply_task ="";
if (ObjectUtil.isNotEmpty(this.getDevice().getExtraValue().get("apply_task"))) {
apply_task = this.getDevice().getExtraValue().get("apply_task").toString();
}
@ -227,7 +241,7 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver
}
}
}
}*/
break;
default:
@ -343,6 +357,119 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver
instruction_finished(instruction);
}
public synchronized boolean apply_take_empty(String container_code) {
return apply_take_empty(container_code, WcsConfig.task_container_type_default_desc);
}
/**
* 请求指令
*
* @param container_code
* @param container_type
*/
public synchronized boolean apply_take_empty(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;
if (number != max_emptypalletnum){
return true;
}
//查询该设备所有路由
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 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 = '" + start_device_code + "' and islock = 'true'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonObject)) {
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备," + devicecode + "已锁定");
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 {
//判断是否已经有该起点设备的任务,如果有就结束循环
int num3 = taskserver.querySameOriginTask(start_device_code);
if (num3 != 0) {
continue;
}
//判断是否有相同终点的任务,有就结束本次循环
int num4 = taskserver.querySameDestinationTask(next_device_code);
if (num4 != 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 = '" + start_device_code + "'");*/
flag = true;
break;
} catch (Exception e) {
this.execute_log.log("设备:" + devicecode+ "", "", "创建任务失败");
}
}
}
//生成任务成功
if (flag) {
requireSucess = true;
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定");
}
return true;
}
}
/**
* 完成指令
*

27
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java

@ -470,6 +470,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
if (standardInspectSiteDeviceDriver.getMove() != 0 || standardInspectSiteDeviceDriver.getMode() != 2) {
continue;
}
//判断是否已经有该起点设备的任务,如果有就结束循环
int num1 = taskserver.querySameOriginTask(start_device_code);
if (num1 != 0) {
@ -505,6 +506,16 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
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();
@ -522,6 +533,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
//生成任务成功
if (flag) {
inrequireSucess = true;
this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定");
}
@ -564,11 +576,6 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
if (standardEmptyPalletSiteDeviceDriver.getMove() != 1 || standardEmptyPalletSiteDeviceDriver.getNumber() == 0) {
continue;
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//判断是否已经有该起点设备的任务,如果有就结束循环
int num = taskserver.querySameOriginTask(start_device_code);
if (num != 0) {
@ -604,6 +611,16 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
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();

42
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java

@ -13,6 +13,7 @@ import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
@ -23,6 +24,7 @@ import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SpringContextHolder;
import org.nl.wql.core.bean.WQLObject;
@ -170,26 +172,39 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid");
JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid);
StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = (JSONObject) ja.get(i);
next_device_code = jo.get("next_device_code").toString();
Device nextdevice = appService.findDeviceByCode(next_device_code);
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver();
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value");
if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) {
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
this.execute_log.log("设备:" + devicecode + ",当前任务数量超过允许最大数量");
continue;
}
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) {
if (standardInspectSiteDeviceDriver.getHasGoods() == 0) {
break;
}
}
if (nextdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver){
standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) nextdevice.getDeviceDriver();
int number = standardEmptyPalletSiteDeviceDriver.getNumber();
if (number == standardEmptyPalletSiteDeviceDriver.getMax_emptypalletnum()){
continue;
}
//判断是否已经有该起点设备的任务,如果有就结束循环
int num1 = taskserver.querySameOriginTask(next_device_code);
int num2 = taskserver.querySameDestinationTask(next_device_code);
if (num1 != 0 || num2 != 0) {
continue;
}
break;
}
}
if (StrUtil.isEmpty(next_device_code)) {
throw new RuntimeException("该设备未找到对应路由");
@ -198,7 +213,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
dto.setNext_point_code(next_device_code);
dto.setUpdate_time(now);
dto.setCreate_time(now);
//判断是否已经有该起点设备的任务,如果有就结束循环
try {
taskserver.create(dto);
} catch (Exception e) {
@ -240,7 +255,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid");
JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid);
StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
for (int j = 0; j < ja.size(); j++) {
JSONObject jo = (JSONObject) ja.get(j);
@ -260,6 +275,19 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
break;
}
}
if (nextdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver){
standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) nextdevice.getDeviceDriver();
int number = standardEmptyPalletSiteDeviceDriver.getNumber();
if (number == standardEmptyPalletSiteDeviceDriver.getMax_emptypalletnum()){
continue;
}
//判断是否已经有该起点设备的任务,如果有就结束循环
int num1 = taskserver.querySameOriginTask(next_device_code);
int num2 = taskserver.querySameDestinationTask(next_device_code);
if (num1 != 0 || num2 != 0) {
continue;
}
}
}
if (StrUtil.isEmpty(next_device_code)) {
throw new RuntimeException("该设备未找到对应路由");

18
hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

@ -242,6 +242,14 @@ public class AutoCreateInst {
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode);
continue;
}
if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver){
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver();
if (next_device_code.equals("Q1") || next_device_code.equals("P1")){
int number = standardEmptsyPalletSiteDeviceDriver.getNumber();
start_device_code = start_device_code + "." + number;
start_point_code = start_point_code + "." + number;
}
}
}
if (nextdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) {
@ -345,10 +353,20 @@ public class AutoCreateInst {
} else {
start_point_code = start_point_code + "." + num;
}
} else {
//目的点校验
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if (next_device_code.equals("Q1") || next_device_code.equals("P1")){
int number = standardEmptsyPalletSiteDeviceDriver.getNumber();
start_device_code = start_device_code + "." + number;
start_point_code = start_point_code + "." + number;
}
} else {
start_point_code = start_point_code + "." + 1;
}
}
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(acsTask.getTask_type());
instdto.setInstruction_id(IdUtil.simpleUUID());

Loading…
Cancel
Save