diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls index 46630da..44ac6a1 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls and b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls differ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index d3a2ea8..0e67aee 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -217,7 +217,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic //标准版-机械手对接位 if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { lnshPalletizingManipulatorSiteDeviceDriver = (LnshPalletizingManipulatorSiteDeviceDriver) device.getDeviceDriver(); - lnshPalletizingManipulatorSiteDeviceDriver.writing(3); + lnshPalletizingManipulatorSiteDeviceDriver.writing(2); if (lnshPalletizingManipulatorSiteDeviceDriver.getMode() != 0 && lnshPalletizingManipulatorSiteDeviceDriver.getMove() != 0 && (lnshPalletizingManipulatorSiteDeviceDriver.getIo_action() == 3 || lnshPalletizingManipulatorSiteDeviceDriver.getIo_action() == 1) @@ -364,7 +364,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) device.getDeviceDriver(); lnshFoldDiscSiteDeviceDriver.writing(3); if (lnshFoldDiscSiteDeviceDriver.getMode() != 0 - && lnshFoldDiscSiteDeviceDriver.getMove() != 0) { + && lnshFoldDiscSiteDeviceDriver.getContainer_qty() > 0) { // && (lnshFoldDiscSiteDeviceDriver.getIo_action() == 3 || lnshFoldDiscSiteDeviceDriver.getIo_action() == 1) // && (lnshFoldDiscSiteDeviceDriver.getAction() == 3 || lnshFoldDiscSiteDeviceDriver.getAction() == 1) inst.setExecute_status("1"); @@ -453,7 +453,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic //标准版-机械手对接位 if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { lnshPalletizingManipulatorSiteDeviceDriver = (LnshPalletizingManipulatorSiteDeviceDriver) device.getDeviceDriver(); - lnshPalletizingManipulatorSiteDeviceDriver.writing(5); + lnshPalletizingManipulatorSiteDeviceDriver.writing(3); if (lnshPalletizingManipulatorSiteDeviceDriver.getMode() != 0 && lnshPalletizingManipulatorSiteDeviceDriver.getMove() == 0 && (lnshPalletizingManipulatorSiteDeviceDriver.getIo_action() == 3 || lnshPalletizingManipulatorSiteDeviceDriver.getIo_action() == 2) @@ -592,7 +592,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) device.getDeviceDriver(); lnshFoldDiscSiteDeviceDriver.writing(5); if (lnshFoldDiscSiteDeviceDriver.getMode() != 0 - && lnshFoldDiscSiteDeviceDriver.getMove() != 0 + && lnshFoldDiscSiteDeviceDriver.getContainer_qty() == 0 // && (lnshFoldDiscSiteDeviceDriver.getIo_action() == 3 || lnshFoldDiscSiteDeviceDriver.getIo_action() == 2) ) { inst.setExecute_status("5"); @@ -844,7 +844,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) device.getDeviceDriver(); lnshFoldDiscSiteDeviceDriver.writing(4); if (lnshFoldDiscSiteDeviceDriver.getMode() != 0 - && lnshFoldDiscSiteDeviceDriver.getMove() == 0 +// && lnshFoldDiscSiteDeviceDriver.getContainer_qty() == 0 // && (lnshFoldDiscSiteDeviceDriver.getIo_action() == 1 || lnshFoldDiscSiteDeviceDriver.getIo_action() == 3) // && (lnshFoldDiscSiteDeviceDriver.getAction() == 2 || lnshFoldDiscSiteDeviceDriver.getAction() == 3) ) { @@ -1086,7 +1086,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) { lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) device.getDeviceDriver(); if (lnshFoldDiscSiteDeviceDriver.getMode() != 0 - && lnshFoldDiscSiteDeviceDriver.getMove() != 0 +// && lnshFoldDiscSiteDeviceDriver.getMove() != 0 // && (lnshFoldDiscSiteDeviceDriver.getIo_action() == 2 || lnshFoldDiscSiteDeviceDriver.getIo_action() == 3) ) { inst.setExecute_status("6"); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java index ebf13e5..51cba48 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java @@ -1,18 +1,175 @@ package org.nl.acs.device_driver.driver; -import org.nl.acs.opc.OpcConfig; +import org.nl.acs.opc.*; import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessorFactory; +import org.nl.acs.udw.UnifiedDataAppService; +import org.nl.modules.wql.exception.WDKException; +import org.nl.modules.wql.util.SpringContextHolder; +import org.openscada.opc.lib.da.Group; +import org.openscada.opc.lib.da.Item; +import org.openscada.opc.lib.da.ItemState; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver { UnifiedDataAccessor opcUdw; + @Autowired + private OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService .class); + public AbstractOpcDeviceDriver() { this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); } + + private Date sendTime; + private String last_items; + private int noLog_sendTimeOut; + private Date noLog_sendTime; + private String noLog_last_items; + @Override public UnifiedDataAccessor getOpcValueAccessor() { return this.opcUdw; } + + + public void checkcontrol(Map itemValues) throws Exception { + Group group = opcServerService.getServer(this.getOpcServer()); + Map write = new HashMap(); + Map readitems = new LinkedHashMap(); + List itemsString = new ArrayList(); + itemsString = new ArrayList<> (itemValues.keySet()); + Iterator is = itemsString.iterator(); + + while (is.hasNext()) { + String string = (String) is.next(); + try { + readitems.put(string, group.addItem(string)); + } catch (Exception e) { + e.printStackTrace(); + } + } + int i = 0; + while(true) { + //下发信号 + control( itemValues); + Map read = new HashMap(); + Map itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0])); + Set items = itemStatus.keySet(); + Iterator var15 = items.iterator(); + + while(var15.hasNext()) { + Item item = (Item)var15.next(); + ItemState itemState = (ItemState)itemStatus.get(item); + Object value = OpcUtl.getValue(item, itemState); + read.put(item.getId(), value); + } + + boolean check = true; + Iterator var24 = itemsString.iterator(); + + while(var24.hasNext()) { + String itemString = (String)var24.next(); + if (!ObjectUtl.isEquals(itemValues.get(itemString), JsonUtl.parse(read.get(itemString)))) { + check = false; + } + } + if (check) { + return; + } + + if (i > 0) { + ThreadUtl.sleep(300L); + } + + if (i > 3) { + throw new WDKException("写入次数超过3次而失败"); + } + ++i; + } + } + + + public boolean control(Map itemValues) { + + Iterator> it = itemValues.entrySet().iterator(); + + ItemValue p2[]; + p2 = new ItemValue[itemValues.size()]; + int i=0; + while (it.hasNext()) { + Map.Entry entry = it.next(); + System.out.println("即将写入值:"+entry.getKey() + ":" + entry.getValue()); + p2[i] = new ItemValue(); + p2[i].setItem_code(entry.getKey()); + p2[i].setItem_value(entry.getValue()); + i++; + } + + return this.control(p2); + } + + + + public boolean control(ItemValue[] itemValues) { + if (itemValues != null && itemValues.length != 0) { + String this_items = JsonUtl.parseWithoutException(itemValues); + boolean need_write = false; + StringBuilder sb = new StringBuilder(); + ItemValue[] var5 = itemValues; + int var6 = itemValues.length; + + for (int var7 = 0; var7 < var6; ++var7) { + ItemValue itemValue = var5[var7]; + String code = itemValue.getItem_code(); + Object udw_value = this.getUdwValue(code); + Object write_value = itemValue.getItem_value(); + sb.append(code); + sb.append(":"); + sb.append(JsonUtl.parseWithoutException(udw_value)); + sb.append(";"); + if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) { + need_write = true; + } else { + //log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value ); + } + } + // need_write = true; + + if (need_write) { + Date date = new Date(); + /*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) { + log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check); + return false; + }*/ + + this.last_items = this_items; + this.sendTime = date; + /* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName()); + this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items}); + OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/ + + OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class); + + opcServerService.writeInteger(this.getOpcServer(), itemValues); + UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor(); + ItemValue[] var17 = itemValues; + int var18 = itemValues.length; + + for (int var19 = 0; var19 < var18; ++var19) { + ItemValue itemValue = var17[var19]; + String code = itemValue.getItem_code(); + Object value = itemValue.getItem_value(); + opcValueAccessor.setValue(code, value); + } + } + + return true; + } else { + throw new WDKException("下发 无内容"); + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java index 9e70c52..474dd7b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java @@ -58,7 +58,8 @@ public interface OpcDeviceDriver extends DeviceDriver { } default Integer getIntegeregerValue(String protocol) { - return (Integer) this.getValue(protocol); + Object value = this.getValue(protocol)==null?"0":this.getValue(protocol); + return Integer.parseInt(value.toString()); } default int[] getIntegeregerArrayValue(String protocol) { @@ -86,4 +87,7 @@ public interface OpcDeviceDriver extends DeviceDriver { return this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDeviceCode() + "." + item; } + default Object getUdwValue(String protocol) { + return this.getOpcValueAccessor().getValue(protocol); + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java index 5071654..d0a5c5f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java @@ -155,12 +155,14 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i request.setVehicle_type(String.valueOf(container_type)); ApplySignalStatusResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)), ApplySignalStatusResponse.class); message = RequestMethodEnum.getName("real_time_set_point") + "real_time_set_point 接口请求LMS..."; - lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request))); + lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "请求参数:" + JSON.toJSONString(request))); if (resp.getCode() == 200) { message = RequestMethodEnum.getName("real_time_set_point") + "real_time_set_point 接口请求成功" + resp.getMessage();; + lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "返回参数:" + JSON.toJSONString(request))); } else { message = RequestMethodEnum.getName("real_time_set_point") + "real_time_set_point 接口请求失败" + resp.getMessage();; + lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "返回参数:" + JSON.toJSONString(request))); } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java index f454ac2..7d8537d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java @@ -2,6 +2,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site; import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.Getter; import lombok.Setter; @@ -10,9 +11,12 @@ import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RequestMethodEnum; 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.ext.wms.data.AcsToWmsData.applyTask.ApplyTaskRequest; +import org.nl.acs.ext.wms.data.AcsToWmsData.applyTask.ApplyTaskResponse; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; @@ -21,11 +25,14 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.Device; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.task.service.TaskService; +import org.nl.modules.lucene.service.LuceneExecuteLogService; +import org.nl.modules.lucene.service.dto.LuceneLogDto; import org.nl.modules.wql.util.SpringContextHolder; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import java.lang.reflect.Method; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -41,6 +48,8 @@ import java.util.Map; public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { protected ItemProtocol itemProtocol = new ItemProtocol(this); + LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); @@ -190,17 +199,21 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem message = ""; Instruction instruction = null; List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: -// int max_emptypalletnum = Integer.parseInt(this.getDevice().getExtraValue().get("max_emptypalletnum").toString()); -// //当前数量等于最大数量,则生成搬运任务 -// if (!requireSucess && container_qty >= max_emptypalletnum) { -// putStorage(); -// } - break; + + if (mode > 2 && !requireSucess) { + if (ObjectUtil.isNotEmpty(this.device.getExtraValue().get(String.valueOf(mode)))) { + String modethod = this.device.getExtraValue().get(String.valueOf(mode)).toString(); + try { + applyRequest(modethod); + } catch (Exception e) { + message = "错误:" + e.getMessage(); + this.setIserror(true); + } + } else { + message = "无效模式请求,驱动未配置此请求方法"; + } + } else { + message = "无请求"; } } @@ -216,34 +229,57 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem /** - * 拆垛完成 + * 请求 * * @param */ - public synchronized boolean palletizing() { + public synchronized boolean applyRequest(String modethod) throws Exception { + Object obj1 = this; 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; - JSONObject json = new JSONObject(); - json.put("device_code", device_code); - json.put("type", "3"); - HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json); - if (ObjectUtil.isNotEmpty(result)) { - if (result.getStatus() == HttpStatus.OK.value()) { - JSONObject jsonObject = JSONObject.parseObject(result.body()); - if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) { - this.writing(200); - requireSucess = true; - } - } + Object obj = this.getClass().getDeclaredConstructor().newInstance(); + Method method1 = this.getClass().getMethod(modethod, null); + method1.invoke(this, null); + return true; + } + } + + + /** + * 申请取走空料盅托盘 + * + * @param + */ + public synchronized boolean apply_take_empty_vehicle() { + if(move == 1) { + ApplyTaskRequest request = new ApplyTaskRequest(); + request.setDevice_code(this.getDevice_code()); + request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName()); + request.setRequest_medthod_name(RequestMethodEnum.getName(Thread.currentThread().getStackTrace()[1].getMethodName())); + ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class); + message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 接口请求LMS..."; + lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request))); + + if (resp.getCode() == 200) { + this.writing(200); + this.setRequireSucess(true); + } else { + this.writing(400); + message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 接口请求失败" + resp.getMessage();; } return true; + } else { + message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 设备无货未请求LMS..."; + lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message)); + return false; } } + public void writing(String param, String value) { String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java index 94f35b8..dcf6141 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java @@ -400,7 +400,7 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class); if (resp.getCode() == 200) { - this.writing(200); + this.writing(101); this.setRequireSucess(true); } else { this.writing(400); @@ -423,7 +423,7 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class); if (resp.getCode() == 200) { - this.writing(200); + this.writing(102); this.setRequireSucess(true); } else { this.writing(400); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java index 54e4969..7050475 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java @@ -429,7 +429,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class); if (resp.getCode() == 200) { - this.writing(200); + this.writing(101); this.setRequireSucess(true); } else { this.writing(400); @@ -452,7 +452,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class); if (resp.getCode() == 200) { - this.writing(200); + this.writing(102); this.setRequireSucess(true); } else { this.writing(400); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java index 60df5c6..9fd0be2 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java @@ -256,80 +256,83 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic String message = null; try { device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - io_action = this.itemProtocol.getIoAction(); - action = this.itemProtocol.getAction(); - weight = this.itemProtocol.getWeight(); - material = this.itemProtocol.getMaterial(); - barcode = this.itemProtocol.getBarcode(); - AlongSide = this.itemProtocol.getAlongSide(); - BshortSide = this.itemProtocol.getBshortSide(); - Htrapezoidal = this.itemProtocol.getHtrapezoidal(); - Wthickness = this.itemProtocol.getWthickness(); - encoder_qty = this.itemProtocol.getEncoder_qty(); - unqualified_qty = this.itemProtocol.getUnqualified_qty(); - - product_code = this.itemProtocol.getProduct_code(); - AlongSide = this.itemProtocol.getAlongSide(); - BshortSide = this.itemProtocol.getBshortSide(); - Htrapezoidal = this.itemProtocol.getHtrapezoidal(); - Wthickness = this.itemProtocol.getWthickness(); - tray_qty = this.itemProtocol.getTray_qty(); - tray_high = this.itemProtocol.getTray_high(); - crib_category = this.itemProtocol.getCrib_category(); - palletX1_line = this.itemProtocol.getPalletX1_line(); - palletY1_row = this.itemProtocol.getPalletY1_row(); - palletA1_angle = this.itemProtocol.getPalletA1_angle(); - palletX2_line = this.itemProtocol.getPalletX2_line(); - palletY2_row = this.itemProtocol.getPalletY2_row(); - palletA2_angle = this.itemProtocol.getPalletA2_angle(); - palletX3_line = this.itemProtocol.getPalletX3_line(); - palletY3_row = this.itemProtocol.getPalletY3_row(); - palletA3_angle = this.itemProtocol.getPalletA3_angle(); - pressCribX1_line = this.itemProtocol.getPressCribX1_line(); - pressCribY1_row = this.itemProtocol.getPressCribY1_row(); - pressCribA1_angle = this.itemProtocol.getPressCribA1_angle(); - pressCribX2_line = this.itemProtocol.getPressCribX2_line(); - pressCribY2_row = this.itemProtocol.getPressCribY2_row(); - pressCribA2_angle = this.itemProtocol.getPressCribA2_angle(); - pressCribX3_line = this.itemProtocol.getPressCribX3_line(); - pressCribY3_row = this.itemProtocol.getPressCribY3_row(); - pressCribA3_angle = this.itemProtocol.getPressCribA3_angle(); - Zoffset = this.itemProtocol.getZoffset(); - pallet_layerQty = this.itemProtocol.getPallet_layerQty(); - pressCrib_layerQty = this.itemProtocol.getPressCrib_layerQty(); - codeLayerX1_interval = this.itemProtocol.getCodeLayerX1_interval(); - codeLayerY1_interval = this.itemProtocol.getCodeLayerY1_interval(); - codeLayerX2_interval = this.itemProtocol.getCodeLayerX2_interval(); - codeLayerY2_interval = this.itemProtocol.getCodeLayerY2_interval(); - codeLayerX3_interval = this.itemProtocol.getCodeLayerX3_interval(); - codeLayerY3_interval = this.itemProtocol.getcodeLayerY3_interval(); - codeLayerX1_offset = this.itemProtocol.getCodeLayerX1_offset(); - codeLayerY1_offset = this.itemProtocol.getCodeLayerY1_offset(); - codeLayerX2_offset = this.itemProtocol.getCodeLayerX2_offset(); - codeLayerY2_offset = this.itemProtocol.getCodeLayerY2_offset(); - codeLayerX3_offset = this.itemProtocol.getCodeLayerX3_offset(); - codeLayerY3_offset = this.itemProtocol.getCodeLayerY3_offset(); - pressLayerX1_interval = this.itemProtocol.getPressLayerX1_interval(); - pressLayerY1_interval = this.itemProtocol.getPressLayerY1_interval(); - pressLayerX2_interval = this.itemProtocol.getPressLayerX2_interval(); - pressLayerY2_interval = this.itemProtocol.getPressLayerY2_interval(); - pressLayerX3_interval = this.itemProtocol.getPressLayerX3_interval(); - pressLayerY3_interval = this.itemProtocol.getPressLayerY3_interval(); - pressLayerX1_offset = this.itemProtocol.getPressLayerX1_offset(); - pressLayerY1_offset = this.itemProtocol.getPressLayerY1_offset(); - pressLayerX2_offset = this.itemProtocol.getPressLayerX2_offset(); - pressLayerY2_offset = this.itemProtocol.getPressLayerY2_offset(); - pressLayerX3_offset = this.itemProtocol.getPressLayerX3_offset(); - pressLayerY3_offset = this.itemProtocol.getPressLayerY3_offset(); - tool_coordinate = this.itemProtocol.getTool_coordinate(); - tool_coordinate = this.itemProtocol.getTool_coordinate(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + move = this.itemProtocol.getMove(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + io_action = this.itemProtocol.getIoAction(); + action = this.itemProtocol.getAction(); + weight = this.itemProtocol.getWeight(); + material = this.itemProtocol.getMaterial(); + barcode = this.itemProtocol.getBarcode(); + AlongSide = this.itemProtocol.getAlongSide(); + BshortSide = this.itemProtocol.getBshortSide(); + Htrapezoidal = this.itemProtocol.getHtrapezoidal(); + Wthickness = this.itemProtocol.getWthickness(); + encoder_qty = this.itemProtocol.getEncoder_qty(); + unqualified_qty = this.itemProtocol.getUnqualified_qty(); + + product_code = this.itemProtocol.getProduct_code(); + AlongSide = this.itemProtocol.getAlongSide(); + BshortSide = this.itemProtocol.getBshortSide(); + Htrapezoidal = this.itemProtocol.getHtrapezoidal(); + Wthickness = this.itemProtocol.getWthickness(); + tray_qty = this.itemProtocol.getTray_qty(); + tray_high = this.itemProtocol.getTray_high(); + crib_category = this.itemProtocol.getCrib_category(); + palletX1_line = this.itemProtocol.getPalletX1_line(); + palletY1_row = this.itemProtocol.getPalletY1_row(); + palletA1_angle = this.itemProtocol.getPalletA1_angle(); + palletX2_line = this.itemProtocol.getPalletX2_line(); + palletY2_row = this.itemProtocol.getPalletY2_row(); + palletA2_angle = this.itemProtocol.getPalletA2_angle(); + palletX3_line = this.itemProtocol.getPalletX3_line(); + palletY3_row = this.itemProtocol.getPalletY3_row(); + palletA3_angle = this.itemProtocol.getPalletA3_angle(); + pressCribX1_line = this.itemProtocol.getPressCribX1_line(); + pressCribY1_row = this.itemProtocol.getPressCribY1_row(); + pressCribA1_angle = this.itemProtocol.getPressCribA1_angle(); + pressCribX2_line = this.itemProtocol.getPressCribX2_line(); + pressCribY2_row = this.itemProtocol.getPressCribY2_row(); + pressCribA2_angle = this.itemProtocol.getPressCribA2_angle(); + pressCribX3_line = this.itemProtocol.getPressCribX3_line(); + pressCribY3_row = this.itemProtocol.getPressCribY3_row(); + pressCribA3_angle = this.itemProtocol.getPressCribA3_angle(); + Zoffset = this.itemProtocol.getZoffset(); + pallet_layerQty = this.itemProtocol.getPallet_layerQty(); + pressCrib_layerQty = this.itemProtocol.getPressCrib_layerQty(); + codeLayerX1_interval = this.itemProtocol.getCodeLayerX1_interval(); + codeLayerY1_interval = this.itemProtocol.getCodeLayerY1_interval(); + codeLayerX2_interval = this.itemProtocol.getCodeLayerX2_interval(); + codeLayerY2_interval = this.itemProtocol.getCodeLayerY2_interval(); + codeLayerX3_interval = this.itemProtocol.getCodeLayerX3_interval(); + codeLayerY3_interval = this.itemProtocol.getcodeLayerY3_interval(); + codeLayerX1_offset = this.itemProtocol.getCodeLayerX1_offset(); + codeLayerY1_offset = this.itemProtocol.getCodeLayerY1_offset(); + codeLayerX2_offset = this.itemProtocol.getCodeLayerX2_offset(); + codeLayerY2_offset = this.itemProtocol.getCodeLayerY2_offset(); + codeLayerX3_offset = this.itemProtocol.getCodeLayerX3_offset(); + codeLayerY3_offset = this.itemProtocol.getCodeLayerY3_offset(); + pressLayerX1_interval = this.itemProtocol.getPressLayerX1_interval(); + pressLayerY1_interval = this.itemProtocol.getPressLayerY1_interval(); + pressLayerX2_interval = this.itemProtocol.getPressLayerX2_interval(); + pressLayerY2_interval = this.itemProtocol.getPressLayerY2_interval(); + pressLayerX3_interval = this.itemProtocol.getPressLayerX3_interval(); + pressLayerY3_interval = this.itemProtocol.getPressLayerY3_interval(); + pressLayerX1_offset = this.itemProtocol.getPressLayerX1_offset(); + pressLayerY1_offset = this.itemProtocol.getPressLayerY1_offset(); + pressLayerX2_offset = this.itemProtocol.getPressLayerX2_offset(); + pressLayerY2_offset = this.itemProtocol.getPressLayerY2_offset(); + pressLayerX3_offset = this.itemProtocol.getPressLayerX3_offset(); + pressLayerY3_offset = this.itemProtocol.getPressLayerY3_offset(); + tool_coordinate = this.itemProtocol.getTool_coordinate(); + tool_coordinate = this.itemProtocol.getTool_coordinate(); if (mode != last_mode) { this.setRequireSucess(false); + if(mode==2){ + writing(0); + } logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java index 417ef08..af97176 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java @@ -5,22 +5,15 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachineDeviceDriver; -import org.nl.acs.device_driver.lnsh.lnsh_package_site.LnshPackageSiteDeviceDriver; -import org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator_site.LnshPalletizingManipulatorSiteDeviceDriver; -import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.service.DeviceExecuteLogService; @@ -32,33 +25,39 @@ import org.nl.acs.route.service.RouteLineService; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.util.SpringContextHolder; import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; +import java.lang.reflect.Field; import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 嘉耐双工位RGV */ @Slf4j -@Getter -@Setter +@Data @RequiredArgsConstructor public class LnshRGVDeviceDriver 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"); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - + @Autowired DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Instruction inst = null; + //当前指令1 Instruction inst1 = null; //当前指令2 @@ -66,44 +65,14 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - //工作模式 int mode = 0; - int last_mode = 0; - //设备状态 - int status = 0; - int last_status = 0; - //前后工位光电信号 - int move1 = 0; - int last_move1 = 0; - int move2 = 0; - int last_move2 = 0; - //前后工位动作信号 - int action1 = 0; - int last_action1 = 0; - int action2 = 0; - int last_action2 = 0; - //报警信号 int error = 0; + int last_mode = 0; int last_error = 0; - //行走列 - int walk_y = 0; - int last_walk_y = 0; - //前后工位任务号 - int task1 = 0; - int last_task1 = 0; - int task2 = 0; - int last_task2 = 0; - - String open_time = null; - String last_open_time = null; - int standby_time = 0; - int last_standby_time = 0; - int production_time = 0; - int last_production_time = 0; - int error_time = 0; - int last_error_time = 0; - Boolean isonline = true; + Boolean requireSucess1 = false; + Boolean requireSucess2 = false; + //后工位申请任务请求标记 Boolean requireBackSucess = false; //前工位申请任务请求标记 @@ -119,14 +88,83 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi int flag; String device_code; + int status = 0; + int last_status = 0; + int move_1 = 0; + int last_move_1 = 0; + int move_2 = 0; + int last_move_2 = 0; + int action_1 = 0; + int last_action_1 = 0; + int action_2 = 0; + int last_action_2 = 0; + int walk_y = 0; + int last_walk_y = 0; + int task1 = 0; + int last_task1 = 0; + int task2 = 0; + int last_task2 = 0; + //开机时间 + int open_time = 0; + int last_open_time = 0; + //待机时间 + int standby_time = 0; + int last_standby_time = 0; + //生产时间 + int production_time = 0; + int last_production_time = 0; + //故障时间 + int error_time = 0; + int last_error_time = 0; + //当前任务数量 + int task_qty = 0; + int last_task_qty = 0; + //完成任务数量 + int finishTask_qty = 0; + int last_finishTask_qty = 0; + + int batch = 0; + int last_batch = 0; + + int qty = 0; + int last_qty = 0; + + int to_command1 = 0; + int to_oneset1 = 0; + int to_target1 = 0; + int to_task1 = 0; + + int last_to_command1 = 0; + int last_to_oneset1 = 0; + int last_to_target1 = 0; + int last_to_task1 = 0; + + int to_command2 = 0; + int to_oneset2 = 0; + int to_target2 = 0; + int to_task2 = 0; + + int to_container_type = 0; + int last_to_container_type = 0; + + int last_to_command2 = 0; + int last_to_oneset2 = 0; + int last_to_target2 = 0; + int last_to_task2 = 0; + String specifications = ""; + String last_specifications = ""; - - //后工位申请任务请求时间 private Date instruction_require_time = new Date(); - //前工位申请任务请求时间 - private Date instruction_head_time = new Date(); - //请求超时时间 + private Date instruction_finished_time = new Date(); + private Date instruction_update_time = new Date(); + private Date instruction_apply_time = new Date(); + + private Date instruction_require_time2 = new Date(); + private Date instruction_finished_time2 = new Date(); + private Date instruction_apply_time2 = new Date(); + private int instruction_require_time_out = 3000; + private int instruction_update_time_out = 500; @Override public Device getDevice() { @@ -141,358 +179,164 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); status = this.itemProtocol.getStatus(); - move1 = this.itemProtocol.getMove1(); - move2 = this.itemProtocol.getMove2(); - action1 = this.itemProtocol.getAction1(); - action2 = this.itemProtocol.getAction2(); + move_1 = this.itemProtocol.getMove1(); + move_2 = this.itemProtocol.getMove2(); + action_1 = this.itemProtocol.getAction1(); + action_2 = this.itemProtocol.getAction2(); walk_y = this.itemProtocol.getWalk_y(); error = this.itemProtocol.getError(); task1 = this.itemProtocol.getTask1(); task2 = this.itemProtocol.getTask2(); - open_time = this.itemProtocol.getOpen_time(); standby_time = this.itemProtocol.getStandby_time(); production_time = this.itemProtocol.getProduction_time(); error_time = this.itemProtocol.getError_time(); - + to_task1 = this.itemProtocol.getTo_task1(); + to_command1 = this.itemProtocol.getTo_command1(); + to_oneset1 = this.itemProtocol.getTo_onset1(); + to_target1 = this.itemProtocol.getTo_target1(); + to_task2 = this.itemProtocol.getTo_task2(); + to_command2 = this.itemProtocol.getTo_command2(); + to_oneset2 = this.itemProtocol.getTo_onset2(); + to_target2 = this.itemProtocol.getTo_target2(); if (mode != last_mode) { - if (mode == 0) { - this.setRequireHeadSucess(false); - this.setRequireBackSucess(false); + if (mode == 2) { + inst = null; + this.setRequireSucess1(false); + logServer.deviceExecuteLog(this.device_code, "", "", "模式变待机,复位前工位请求标记requireSucess1:" + requireSucess1); } logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (to_container_type != last_to_container_type) { + logServer.deviceItemValue(this.device_code, "to_container_type", String.valueOf(to_container_type)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号container_type:" + last_to_container_type + "->" + to_container_type); } if (error != last_error) { logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); } if (status != last_status) { logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status); + logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status); } - if (move1 != last_move1) { - if (move1 == 0) { - this.setRequireHeadSucess(false); + if (move_1 != last_move_1) { + if (move_1 == 0) { + this.setRequireSucess1(false); + logServer.deviceExecuteLog(this.device_code, "", "", "前工位有货变无货,复位前工位请求标记requireSucess1:" + requireSucess1); } - logServer.deviceItemValue(this.device_code, "move1", String.valueOf(move1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move1:" + last_move1 + " -> " + move1); + logServer.deviceItemValue(this.device_code, "move_1", String.valueOf(move_1)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move_1:" + last_move_1 + "->" + move_1); } - if (move2 != last_move2) { - if (move2 == 0) { - this.setRequireBackSucess(false); + if (move_2 != last_move_2) { + if (move_2 == 0) { + this.setRequireSucess2(false); + logServer.deviceExecuteLog(this.device_code, "", "", "后工位有货变无货,复位后工位请求标记requireSucess2:" + requireSucess2); } - logServer.deviceItemValue(this.device_code, "move2", String.valueOf(move2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move2:" + last_move2 + " -> " + move2); +// logServer.deviceExecuteLog(this.device_code, "", "", "信号move_2:" + last_move_2 + "->" + move_2); } - if (action1 != last_action1) { - logServer.deviceItemValue(this.device_code, "action1", String.valueOf(action1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action1:" + last_action1 + " -> " + action1); + if (action_1 != last_action_1) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号action_1:" + last_action_1 + "->" + action_1); } - if (action2 != last_action2) { - logServer.deviceItemValue(this.device_code, "action2", String.valueOf(action2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action2:" + last_action2 + " -> " + action2); + if (action_2 != last_action_2) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号action_2:" + last_action_2 + "->" + action_2); } if (walk_y != last_walk_y) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + " -> " + walk_y); + logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); } if (task1 != last_task1) { - logServer.deviceItemValue(this.device_code, "task1", String.valueOf(task1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task1:" + last_task1 + " -> " + task1); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task1:" + last_task1 + "->" + task1); } if (task2 != last_task2) { - logServer.deviceItemValue(this.device_code, "task2", String.valueOf(task2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + " -> " + task2); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2); + } + if (task_qty != last_task_qty) { +// logServer.deviceExecuteLog(this.device_code, "", "", "信号task_qty:" + last_task_qty + "->" + task_qty); } - if (!open_time.equals(last_open_time)) { - logServer.deviceItemValue(this.device_code, "open_time", String.valueOf(open_time)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号open_time:" + last_open_time + " -> " + open_time); + if (finishTask_qty != last_finishTask_qty) { +// logServer.deviceExecuteLog(this.device_code, "", "", "信号finishTask_qty:" + last_finishTask_qty + "->" + finishTask_qty); } - if (standby_time != last_standby_time) { - logServer.deviceItemValue(this.device_code, "standby_time", String.valueOf(standby_time)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号standby_time:" + last_standby_time + " -> " + standby_time); + if (batch != last_batch) { +// logServer.deviceExecuteLog(this.device_code, "", "", "信号batch:" + last_batch + "->" + batch); } - if (production_time != last_production_time) { - logServer.deviceItemValue(this.device_code, "production_time", String.valueOf(production_time)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号production_time:" + last_production_time + " -> " + production_time); + if (qty != last_qty) { +// logServer.deviceExecuteLog(this.device_code, "", "", "信号qty:" + last_qty + "->" + qty); } - if (error_time != last_error_time) { - logServer.deviceItemValue(this.device_code, "error_time", String.valueOf(error_time)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error_time:" + last_error_time + " -> " + error_time); + if (!StrUtil.equals(specifications, last_specifications)) { +// logServer.deviceExecuteLog(this.device_code, "", "", "信号specifications:" + last_specifications + "->" + specifications); } - //前工位任务就绪->执行 - if (mode != 0 && error == 0 && status != 3 && task1 > 0) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - inst1.setInstruction_status("1"); - instructionService.update(inst1); - } - } + if (to_task1 != last_to_task1) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task1:" + last_to_task1 + "->" + to_task1); + } + if (to_target1 != last_to_target1) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target1:" + last_to_target1 + "->" + to_target1); + } + if (to_oneset1 != last_to_oneset1) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_oneset1:" + last_to_oneset1 + "->" + to_oneset1); + } + if (to_command1 != last_to_command1) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command1:" + last_to_command1 + "->" + to_command1); } - //前工位放货完成 任务完成 - if (mode == 3 && error == 0 && status != 3 && action1 == 4 && move1 == 0 && task1 > 0) { - //inst_message - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "1")) { - finish_instruction(inst1); - logServer.deviceExecuteLog(this.device_code, "", "", "RGV前工位任务完成。"); - this.writing("to_command1", "0"); - this.writing("to_onset1", "0"); - this.writing("to_target1", "0"); - this.writing("to_task1", "0"); - this.writing("to_command1", "0"); - this.writing("to_onset1", "0"); - this.writing("to_target1", "0"); - this.writing("to_task1", "0"); - this.setRequireHeadSucess(false); - } - } + if (to_task2 != last_to_task2) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task2:" + last_to_task2 + "->" + to_task2); + } + if (to_target2 != last_to_target2) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target2:" + last_to_target2 + "->" + to_target2); + } + if (to_oneset2 != last_to_oneset2) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_oneset2:" + last_to_oneset2 + "->" + to_oneset2); + } + if (to_command2 != last_to_command2) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command2:" + last_to_command2 + "->" + to_command2); } - //后工位任务就绪->执行 - if (mode != 0 && error == 0 && status != 3 && task2 > 0) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), "0")) { - inst2.setInstruction_status("1"); - instructionService.update(inst2); - } - } + + if (task1 > 0 || task2 > 0) { + update_instruction_status(); } - //后工位放货完成 任务完成 - if (mode == 3 && error == 0 && status != 3 && action2 == 4 && move2 == 0 && task2 > 0) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), "1")) { - finish_instruction(inst2); - logServer.deviceExecuteLog(this.device_code, "", "", "后工位任务完成。"); - this.writing("to_command2", "0"); - this.writing("to_onset2", "0"); - this.writing("to_target2", "0"); - this.writing("to_task2", "0"); - this.writing("to_command2", "0"); - this.writing("to_onset2", "0"); - this.writing("to_target2", "0"); - this.writing("to_task2", "0"); - this.setRequireBackSucess(false); - } + + //双任务下 后工位取货完成,然后给前工位下发取满盘任务取货命令 + if (mode == 3 && action_2 == 2 && action_1 == 0 && move_2 != 0 && move_1 == 0 && task2 > 0 && to_task1 > 0 && to_task2 > 0) { + if (to_command1 != 1) { + writing("to_command1", "1"); } } - //前工位取货时判断取货位光电信号 - if (mode == 3 && error == 0 && status != 3 && action1 == 1 && move1 == 0 && task1 > 0 && action2 != 1) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - String start_device_code = inst1.getStart_device_code(); - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - if (startDevice.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { - LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) startDevice.getDeviceDriver(); - if (driver.getMode() != 0 - && driver.getMove() != 0 - && (driver.getIo_action() == 3 || driver.getIo_action() == 1) - && (driver.getAction() == 3 || driver.getAction() == 1)) { - this.writing("to_command1", "2"); - driver.setMessage(""); - logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV前工位取货。"); - } else { - String msg = ""; - if (driver.getMode() == 0) { - msg += "站点未联机,"; - } else { - if (driver.getMove() == 0) { - msg += "站点无货,"; - } - if (driver.getIo_action() != 3 && driver.getIo_action() != 1) { - msg += "站点不允许进入,"; - } - if (driver.getAction() != 3 && driver.getAction() != 1) { - msg += "站点不允许取货,"; - } - } - msg += "不允许RGV前工位取货。"; - driver.setMessage(msg); - logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", msg); - } - } else if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - this.writing("to_command1", "2"); - logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV前工位取货。"); + //双任务下发 前后工位取货完成 给后工位放货命令 + if (mode == 3 && action_2 == 2 && action_1 == 2 && move_2 != 0 && move_1 != 0 && task2 > 0 && task1 > 0) { + if (to_command2 != 2) { + writing("to_command2", "2"); } } - //前工位放货时判断放货位光电信号 - if (mode == 3 && error == 0 && status != 3 && action1 == 3 && move1 != 0 && task1 > 0 && action2 != 3) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - String next_device_code = inst1.getNext_device_code(); - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - if (nextDevice.getDeviceDriver() instanceof LnshStationDeviceDriver) { - LnshStationDeviceDriver driver = (LnshStationDeviceDriver) nextDevice.getDeviceDriver(); - if (driver.getMode() != 0 - && driver.getMove() == 0 - && (driver.getAction() == 2 || driver.getAction() == 3) - && (driver.getIo_action() == 1 || driver.getIo_action() == 3)) { - this.writing("to_command1", "3"); - driver.setMessage(""); - logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV前工位放货。"); - } else { - String msg = ""; - if (driver.getMode() == 0) { - msg += "站点未联机,"; - } else { - if (driver.getMove() != 0) { - msg += "站点有货,"; - } - if (driver.getIo_action() != 1 && driver.getIo_action() != 3) { - msg += "站点不允许进入,"; - } - if (driver.getAction() != 2 && driver.getAction() != 3) { - msg += "站点不允许放货,"; - } - } - msg += "不允许RGV前工位放货。"; - driver.setMessage(msg); - logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", msg); - } - } else if (nextDevice.getDeviceDriver() instanceof LnshPackageSiteDeviceDriver) { - LnshPackageSiteDeviceDriver driver = (LnshPackageSiteDeviceDriver) nextDevice.getDeviceDriver(); - if (driver.getMode() != 0 - && driver.getMove() == 0 - && (driver.getAction() == 2 || driver.getAction() == 3) - && (driver.getIoaction() == 1 || driver.getIoaction() == 3)) { - this.writing("to_command1", "3"); - driver.setMessage(""); - logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV前工位放货。"); - } else { - String msg = ""; - if (driver.getMode() == 0) { - msg += "站点未联机,"; - } else { - if (driver.getMove() != 0) { - msg += "站点有货,"; - } - if (driver.getIoaction() != 1 && driver.getIoaction() != 3) { - msg += "站点不允许进入,"; - } - if (driver.getAction() != 2 && driver.getAction() != 3) { - msg += "站点不允许放货,"; - } - } - msg += "不允许RGV前工位放货。"; - driver.setMessage(msg); - logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", msg); - } + //双任务下发 后工位放货完成 给前工位下发放货 + if (mode == 3 && action_2 == 4 && action_1 == 2 && move_2 == 0 && move_1 != 0 && task2 > 0 && task1 > 0) { + if (to_command1 != 2) { + writing("to_command1", "2"); } } - //后工位取货时判断取货位光电信号 - if (mode == 3 && error == 0 && status != 3 && action2 == 1 && move2 == 0 && task2 > 0) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); - String start_device_code = inst1.getStart_device_code(); - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - if (startDevice.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) { - LnshLaminatingMachineDeviceDriver driver = (LnshLaminatingMachineDeviceDriver) startDevice.getDeviceDriver(); - if (driver.getMode() != 0 - && driver.getMove() != 0) { - this.writing("to_command2", "2"); - driver.setMessage(""); - logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV后工位取货。"); - } else { - String msg = ""; - if (driver.getMode() == 0) { - msg += "站点未联机,"; - } else { - if (driver.getMove() == 0) { - msg += "站点无货,"; - } - } - msg += "不允许RGV后工位取货。"; - driver.setMessage(msg); - logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", msg); - } - } else if (startDevice.getDeviceDriver() instanceof LnshStationDeviceDriver) { - LnshStationDeviceDriver driver = (LnshStationDeviceDriver) startDevice.getDeviceDriver(); - if (driver.getMode() != 0 - && driver.getMove() != 0 - && (driver.getIo_action() == 3 || driver.getIo_action() == 1) - && (driver.getAction() == 3 || driver.getAction() == 1)) { - this.writing("to_command2", "2"); - driver.setMessage(""); - logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", "允许RGV后工位取货。"); - } else { - String msg = ""; - if (driver.getMode() == 0) { - msg += "站点未联机,"; - } else { - if (driver.getMove() == 0) { - msg += "站点无货,"; - } - if (driver.getIo_action() != 3 && driver.getIo_action() != 1) { - msg += "站点不允许进入,"; - } - if (driver.getAction() != 3 && driver.getAction() != 1) { - msg += "站点不允许取货,"; - } - } - msg += "不允许RGV后工位取货。"; - driver.setMessage(msg); - logServer.deviceExecuteLog(startDevice.getDevice_code(), "", "", msg); - } + //后工位单任务下发 空托或者半托缓存任务 + if (mode == 3 && action_2 == 2 && action_1 == 0 && move_2 > 0 && move_1 == 0 && task2 > 0 && task1 == 0 && to_task1 == 0) { + if (to_command2 != 2) { + writing("to_command2", "2"); } } - //后工位放货时判断放货位光电信号 - if (mode == 3 && error == 0 && status != 3 && action2 == 3 && move2 != 0 && task2 > 0 && action1 != 1) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); - String next_device_code = inst1.getNext_device_code(); - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - if (nextDevice.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { - LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) nextDevice.getDeviceDriver(); - if (driver.getMode() != 0 - && driver.getMove() == 0 - && (driver.getIo_action() == 1 || driver.getIo_action() == 3) - && (driver.getAction() == 2 || driver.getAction() == 3)) { - this.writing("to_command2", "3"); - driver.setMessage(""); - logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV后工位放货。"); - } else { - String msg = ""; - if (driver.getMode() == 0) { - msg += "站点未联机,"; - } else { - if (driver.getMove() != 0) { - msg += "站点有货,"; - } - if (driver.getIo_action() != 1 && driver.getIo_action() != 3) { - msg += "站点不允许进入,"; - } - if (driver.getAction() != 2 && driver.getAction() != 3) { - msg += "站点不允许放货,"; - } - } - msg += "不允许RGV后工位放货。"; - driver.setMessage(msg); - logServer.deviceExecuteLog(device_code, "", "", msg); - } - } else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - this.writing("to_command2", "3"); - logServer.deviceExecuteLog(nextDevice.getDevice_code(), "", "", "允许RGV后工位放货。"); + //前工位单任务下发 强制包装的任务 + if (mode == 3 && action_1 == 2 && action_2 == 0 && move_1 > 0 && move_2 == 0 && task1 > 0 && task2 == 0 && to_task2 == 0) { + if (to_command1 != 2) { + writing("to_command1", "2"); } } + } catch (Exception var17) { return; } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { + if (mode == 0) { this.setIsonline(false); this.setIserror(true); message = "未联机"; @@ -513,33 +357,35 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi log.debug("设备运转模式:等待工作"); return; case 2: - //后工位申请任务 - if (mode == 2 && move2 == 0 && action2 == 0 && !requireBackSucess && task2 == 0) { - logServer.deviceExecuteLog(this.device_code, "", "", "RGV开始申请后工位任务。"); - instruction_require2(); - } - //前工位申请任务 - if (mode == 2 && move2 == 0 && action2 == 0 && task2 == 0 && move1 == 0 && !requireHeadSucess && !requireBackSucess && task1 == 0) { - logServer.deviceExecuteLog(this.device_code, "", "", "RGV开始申请前工位任务。"); + // 申请任务 + if (move_1 == 0 && move_2 == 0 && action_1 == 0 && action_2 == 0 && task1 == 0 && task2 == 0 && !requireSucess1) { instruction_require(); } break; case 3: - //前工位申请任务 - if (mode == 3 && action2 == 1 && move1 == 0 && !requireHeadSucess && task1 == 0) { - logServer.deviceExecuteLog(this.device_code, "", "", "RGV开始申请前工位任务。"); - instruction_require(); - } + break; + } + + switch (flag) { + //取货完成 + case 1: + writing1(2); + return; + //放货完成 + case 2: + writing1(3); + return; + } } last_mode = mode; last_error = error; last_status = status; - last_move1 = move1; - last_move2 = move2; - last_action1 = action1; - last_action2 = action2; + last_move_1 = move_1; + last_move_2 = move_2; + last_action_1 = action_1; + last_action_2 = action_2; last_walk_y = walk_y; last_task1 = task1; last_task2 = task2; @@ -547,56 +393,44 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi last_standby_time = standby_time; last_production_time = production_time; last_error_time = error_time; + last_task_qty = task_qty; + last_finishTask_qty = finishTask_qty; + last_specifications = specifications; + last_batch = batch; + last_qty = qty; + last_to_command1 = to_command1; + last_to_oneset1 = to_oneset1; + last_to_target1 = to_target1; + last_to_task1 = to_task1; + last_to_command2 = to_command2; + last_to_oneset2 = to_oneset2; + last_to_target2 = to_target2; + last_to_task2 = to_task2; + last_to_container_type = to_container_type; } //申请前工位任务 - public synchronized boolean instruction_require() { + public synchronized boolean instruction_require() throws Exception { Date date = new Date(); - if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time); + if (date.getTime() - this.instruction_apply_time2.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return false; } else { - this.instruction_head_time = date; + this.instruction_apply_time2 = date; //前工位取货关联设备 List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code1"); //前工位放货关联设备 List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code1"); + TaskDto task = null; - if (mode == 3) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); - getDeviceCodeList = new ArrayList() {{ - add(inst2.getNext_device_code()); - }}; - } + for (int i = 0; i < getDeviceCodeList.size(); i++) { - String startDeviceCode = getDeviceCodeList.get(i); - List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - TaskDto taskDto = taskDtos.get(0); - if (!putDeviceCodeList.contains(taskDto.getNext_device_code())) { - continue; - } - Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); - instruction.setInstruction_status("1"); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); - this.sendHeadSignalType(instruction); - requireHeadSucess = true; - logServer.deviceExecuteLog(device_code, "", "", "RGV申请前工位任务成功,任务为重新创建指令的任务,指令号:" + instruction.getInstruction_code()); - return true; - } else { - List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtoList)) { - task = taskDtoList.get(0); - if (!putDeviceCodeList.contains(task.getNext_device_code())) { - continue; - } - } - if (ObjectUtil.isNotEmpty(task)) break; + if (ObjectUtil.isNotEmpty(taskserver.queryTaskByDeviceCode(getDeviceCodeList.get(i).replace("\"", "")))) { + task = taskserver.queryTaskByDeviceCode(getDeviceCodeList.get(i).replace("\"", "")).get(0); } + if (ObjectUtil.isNotEmpty(task)) break; } - if (!ObjectUtil.isEmpty(task)) { String taskid = task.getTask_id(); String taskcode = task.getTask_code(); @@ -604,9 +438,21 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi String priority = task.getPriority(); String start_point_code = task.getStart_point_code(); String start_device_code = task.getStart_device_code(); + String start_device_code2 = task.getStart_device_code2(); String route_plan_code = task.getRoute_plan_code(); String next_point_code = task.getNext_point_code(); String next_device_code = task.getNext_device_code(); + String next_device_code2 = task.getNext_device_code2(); + Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); + Device startdevice2 = null; + Device nextdevice2 = null; + if (ObjectUtil.isNotEmpty(start_device_code2)) { + startdevice2 = deviceAppservice.findDeviceByCode(start_device_code2); + } + if (ObjectUtil.isNotEmpty(next_device_code2)) { + nextdevice2 = deviceAppservice.findDeviceByCode(next_device_code2); + } Instruction instdto = new Instruction(); instdto.setInstruction_id(IdUtil.simpleUUID()); @@ -624,167 +470,114 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi instdto.setNext_device_code(next_device_code); instdto.setStart_point_code(start_point_code); instdto.setNext_point_code(next_point_code); + instdto.setStart_device_code2(start_device_code2); + instdto.setNext_device_code2(next_device_code2); + instdto.setStart_point_code2(start_device_code2); + instdto.setNext_point_code2(next_device_code2); instdto.setPriority(priority); instdto.setInstruction_status("0"); instdto.setExecute_device_code(start_point_code); - + instdto.setVehicle_type(task.getVehicle_type()); try { instructionService.create(instdto); } catch (Exception e) { e.printStackTrace(); } + //创建指令后修改任务状态 + WQLObject taskwo = WQLObject.getWQLObject("acs_task"); + task.setTask_status("1"); //创建指令后修改任务状态 task.setTask_status("1"); - task.setUpdate_time(DateUtil.now()); taskserver.update(task); - this.sendHeadSignalType(instdto); - requireHeadSucess = true; - logServer.deviceExecuteLog(this.device_code, "", "", "RGV申请前工位任务成功,任务为就绪状态下的任务,指令号:" + instdto.getInstruction_code()); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "RGV申请前工位任务失败,未找到前工位取货位关联设备的起点任务!"); - } - } - return true; - } - //申请后工位任务 - public synchronized boolean instruction_require2() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time); - return false; - } else { - this.instruction_require_time = date; - - //后工位取货关联设备 - List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code2"); - //后工位放货关联设备 - List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code2"); - - TaskDto task = null; - for (int i = 0; i < getDeviceCodeList.size(); i++) { - String startDeviceCode = getDeviceCodeList.get(i); - List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - TaskDto taskDto = taskDtos.get(0); - if (!putDeviceCodeList.contains(taskDto.getNext_device_code())) { - continue; - } - Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); - instruction.setInstruction_status("1"); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); - this.sendBackSignalType(instruction); - requireBackSucess = true; - logServer.deviceExecuteLog(this.device_code, "", "", "RGV申请后工位任务成功,任务为重新创建指令的任务,指令号:" + instruction.getInstruction_code()); - return true; + //下发4个点任务 + if (ObjectUtil.isNotEmpty(start_device_code2) && ObjectUtil.isNotEmpty(next_device_code2)) { + sendHeadBackSignalType(instdto); + requireSucess1 = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请前后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); } else { - List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtoList)) { - task = taskDtoList.get(0); - if (!putDeviceCodeList.contains(task.getNext_device_code())) { - continue; - } + sendHeadSignalType(instdto); + requireSucess1 = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); + } + } else { + //申请后工位任务 + TaskDto task2 = null; + for (int i = 0; i < putDeviceCodeList.size(); i++) { + if (ObjectUtil.isNotEmpty(taskserver.queryTaskByDeviceCode(putDeviceCodeList.get(i).replace("\"", "")))) { + task2 = taskserver.queryTaskByDeviceCode(putDeviceCodeList.get(i).replace("\"", "")).get(0); } - if (ObjectUtil.isNotEmpty(task)) break; + if (ObjectUtil.isNotEmpty(task2)) break; } - } - - if (!ObjectUtil.isEmpty(task)) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_point_code = task.getNext_point_code(); - String next_device_code = task.getNext_device_code(); - - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - 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(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); + if (!ObjectUtil.isEmpty(task2)) { + String taskid = task2.getTask_id(); + String taskcode = task2.getTask_code(); + String vehiclecode = task2.getVehicle_code(); + String priority = task2.getPriority(); + String start_point_code = task2.getStart_point_code(); + String start_device_code = task2.getStart_device_code(); + String start_device_code2 = task2.getStart_device_code2(); + String route_plan_code = task2.getRoute_plan_code(); + String next_point_code = task2.getNext_point_code(); + String next_device_code = task2.getNext_device_code(); + String next_device_code2 = task2.getNext_device_code2(); + Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); + Device startdevice2 = null; + Device nextdevice2 = null; + if (ObjectUtil.isNotEmpty(start_device_code2)) { + startdevice2 = deviceAppservice.findDeviceByCode(start_device_code2); + } + if (ObjectUtil.isNotEmpty(next_device_code2)) { + nextdevice2 = deviceAppservice.findDeviceByCode(next_device_code2); + } - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(task2.getRemark()); + instdto.setMaterial(task2.getMaterial()); + instdto.setQuantity(task2.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + 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.setStart_device_code2(start_device_code2); + instdto.setNext_device_code2(next_device_code2); + instdto.setStart_point_code2(start_device_code2); + instdto.setNext_point_code2(next_device_code2); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + instdto.setVehicle_type(task2.getVehicle_type()); + + try { + instructionService.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + } + //创建指令后修改任务状态 + WQLObject taskwo = WQLObject.getWQLObject("acs_task"); + task2.setTask_status("1"); + //创建指令后修改任务状态 + task2.setTask_status("1"); + taskserver.update(task2); + sendBackSignalType(instdto); + requireSucess1 = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code()); } - - //创建指令后修改任务状态 - task.setTask_status("1"); - taskserver.update(task); - this.sendBackSignalType(instdto); - requireBackSucess = true; - logServer.deviceExecuteLog(this.device_code, "", "", "RGV申请后工位任务成功,任务为就绪状态下的任务,指令号:" + instdto.getInstruction_code()); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "RGV申请后工位任务失败,未找到后工位取货位关联设备的起点任务!"); } } return true; } - public synchronized void sendHeadSignalType(Instruction dto) { - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - this.isSetAddress(startDevice); - this.isSetAddress(nextDevice); - String start_addr = startDevice.getExtraValue().get("OPCServer").toString(); - String next_addr = nextDevice.getExtraValue().get("OPCServer").toString(); - this.writing("to_onset1", start_addr); - this.writing("to_target1", next_addr); - this.writing("to_task1", dto.getInstruction_code()); - this.writing("to_command1", "1"); - this.writing("to_onset1", start_addr); - this.writing("to_target1", next_addr); - this.writing("to_task1", dto.getInstruction_code()); - this.writing("to_command1", "1"); - } - - public synchronized void sendBackSignalType(Instruction dto) { - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - this.isSetAddress(startDevice); - this.isSetAddress(nextDevice); - String start_addr = startDevice.getExtraValue().get("OPCServer").toString(); - String next_addr = nextDevice.getExtraValue().get("OPCServer").toString(); - this.writing("to_onset2", start_addr); - this.writing("to_target2", next_addr); - this.writing("to_task2", dto.getInstruction_code()); - this.writing("to_command2", "1"); - this.writing("to_onset2", start_addr); - this.writing("to_target2", next_addr); - this.writing("to_task2", dto.getInstruction_code()); - this.writing("to_command2", "1"); - } - - //判断点位是否设置电气值 - public void isSetAddress(Device device) { - if (ObjectUtil.isEmpty(device.getExtraValue().get("OPCServer"))) { - throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!"); - } - } public boolean exe_error() { if (this.error == 0) { @@ -799,13 +592,16 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi 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 itemMap = new HashMap(); itemMap.put(to_param, value); - ReadUtil.write(itemMap, server); - logServer.deviceExecuteLog(this.device_code, "", "", param + " 写入 " + value); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + } + logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value); } public boolean exe_business() { @@ -818,10 +614,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi public void executing(int command, Instruction instruction, String appendMessage) { - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); + this.control(itemMap); } @@ -833,139 +628,126 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); + this.control(itemMap); } public void writing1(int command) { String to_command1 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "." + ItemProtocol.item_to_command1; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); itemMap.put(to_command1, command); - ReadUtil.write(itemMap, server); - + this.control(itemMap); + logServer.deviceExecuteLog(this.device_code, "", "", to_command1 + " 写入 " + command); } public void writing2(int command) { String to_command2 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "." + ItemProtocol.item_to_command2; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); itemMap.put(to_command2, command); - ReadUtil.write(itemMap, server); + this.control(itemMap); + logServer.deviceExecuteLog(this.device_code, "", "", to_command2 + " 写入 " + command); + } + + public void writing(int type, int command) { + Map itemMap = new HashMap(); + this.control(itemMap); } - //将扩展表中的字符串数组数据转换成集合 - public List getExtraDeviceCodes(String extraName) { - String extraValue = (String) this.getDevice().getExtraValue().get(extraName); - if (StrUtil.isEmpty(extraValue)) { - return new ArrayList<>(); + public static Boolean isExistFieldName(String fieldName, Object obj) throws NoSuchFieldException { + if (obj == null || StrUtil.isBlank(fieldName)) { + return null; } - String devicesString = extraValue.substring(1, extraValue.length() - 1); - List devicesList = new ArrayList<>(); - String[] devices = devicesString.split(","); - for (int i = 0; i < devices.length; i++) { - String s = devices[i].replace("\"", "").replace("\"", ""); - devicesList.add(s); + //获取这个类的所有属性 + Field[] fields = obj.getClass().getDeclaredFields(); + boolean flag = false; + //循环遍历所有的fields + for (int i = 0; i < fields.length; i++) { + if (fields[i].getName().equals("item_" + fieldName)) { + flag = true; + break; + } } - return devicesList; + return flag; } @Override public JSONObject getDeviceStatusName() { - String mode; - String status; - String move_1; - String move_2; - String action_1; - String action_2; - - switch (this.mode) { - case 0: - mode = "脱机"; - break; - case 2: - mode = "待机"; - break; - case 3: - mode = "运行中"; - break; - default: - mode = String.valueOf(this.mode); + JSONObject jo = new JSONObject(); + String move_1 = ""; + String move_2 = ""; + String action_1 = ""; + String action_2 = ""; + String walk_y = ""; + String mode = ""; + String status = ""; + + if (this.getMode() == 0) { + mode = "未联机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "联机"; + } else if (this.getMode() == 3) { + mode = "运行中"; } - switch (this.status) { - case 1: - status = "待机"; - break; - case 2: - status = "生产中"; - break; - case 3: - status = "故障"; - break; - default: - status = String.valueOf(this.status); + if (this.getStatus() == 1) { + status = "待机"; + } else if (this.getStatus() == 2) { + status = "生产中"; + } else if (this.getStatus() == 3) { + status = "故障"; } - if (this.move1 == 0) { + if (this.getMove_1() == 0) { move_1 = "无货"; - } else { + } else if (this.getMove_1() == 1) { move_1 = "有货"; + } else if (this.getMove_1() == 2) { + move_1 = "有托盘有货"; } - if (this.move2 == 0) { + if (this.getMove_2() == 0) { move_2 = "无货"; - } else { + } else if (this.getMove_2() == 1) { move_2 = "有货"; + } else if (this.getMove_2() == 2) { + move_2 = "有托盘有货"; } - switch (this.action1) { - case 0: - action_1 = "无动作"; - break; - case 1: - action_1 = "请求取货"; - break; - case 2: - action_1 = "取货完成"; - break; - case 3: - action_1 = "请求放货"; - break; - case 4: - action_1 = "放货完成"; - break; - default: - action_1 = String.valueOf(this.action1); + if (this.getAction_1() == 1) { + action_1 = "取货中"; + } else if (this.getAction_1() == 2) { + action_1 = "取货完成"; + } else if (this.getAction_1() == 3) { + action_1 = "放货中"; + } else if (this.getAction_1() == 4) { + action_1 = "放货完成"; } - switch (this.action2) { - case 0: - action_2 = "无动作"; - break; - case 1: - action_2 = "请求取货"; - break; - case 2: - action_2 = "取货完成"; - break; - case 3: - action_2 = "请求放货"; - break; - case 4: - action_2 = "放货完成"; - break; - default: - action_2 = String.valueOf(this.action2); + if (this.getAction_2() == 1) { + action_2 = "取货中"; + } else if (this.getAction_2() == 2) { + action_2 = "取货完成"; + } else if (this.getAction_2() == 3) { + action_2 = "放货中"; + } else if (this.getAction_2() == 4) { + action_2 = "放货完成"; } - JSONObject jo = new JSONObject(); + if (this.getWalk_y() == 0) { + walk_y = "原位"; + } else if (this.getWalk_y() == 2) { + walk_y = "非原位"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); jo.put("mode", mode); jo.put("status", status); jo.put("move_1", move_1); @@ -973,15 +755,23 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi jo.put("action_1", action_1); jo.put("action_2", action_2); jo.put("walk_y", walk_y); - jo.put("task1", task1); - jo.put("task2", task2); - jo.put("open_time", open_time); - jo.put("standby_time", standby_time); - jo.put("production_time", production_time); - jo.put("error_time", error_time); - jo.put("isError", iserror); - jo.put("isOnline", isonline); - jo.put("message", message); + if (this.getIserror()) { + jo.put("error", "设备有故障"); + } + jo.put("task1", this.getTask1()); + jo.put("task2", this.getTask2()); + jo.put("isOnline", this.getIsonline()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("open_time", this.getOpen_time()); + jo.put("standby_time", this.getStandby_time()); + jo.put("production_time", this.getProduction_time()); + jo.put("error_time", this.getError_time()); + jo.put("task_qty", this.getTask_qty()); + jo.put("finishTask_qty", this.getFinishTask_qty()); + jo.put("batch", this.getBatch()); + jo.put("specifications", this.getSpecifications()); + jo.put("qty", this.getQty()); return jo; } @@ -989,4 +779,207 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi public void setDeviceStatus(JSONObject data) { } + + + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + + if (task1 > 0 && task2 > 0 && action_1 == 4 && action_2 == 4 && move_1 == 0 && move_2 == 0) { + //inst_message + inst1 = checkInst(); + if (inst1 != null) { + try { + finish_instruction(inst1); + } catch (Exception e) { + log.error("RGV 前工位完成指令异常", e); + logServer.deviceExecuteLog(this.device_code, "", "", "前工位指令" + task1 + "完成异常,异常原因:" + e.getMessage()); + } + writing("to_command1", "0"); + writing("to_onset1", "0"); + writing("to_target1", "0"); + writing("to_task1", "0"); + writing("to_command2", "0"); + writing("to_onset2", "0"); + writing("to_target2", "0"); + writing("to_task2", "0"); + writing("to_container_type", "0"); + + } + this.requireSucess1 = false; + //单独的后工位任务 + } else if (action_2 == 4 && move_2 == 0 && task2 > 0 && action_1 == 0 && move_2 == 0 && task1 == 0) { + //inst_message + inst2 = checkInst(); + if (inst2 != null) { + try { + finish_instruction(inst2); + } catch (Exception e) { + log.error("RGV 前工位完成指令异常", e); + logServer.deviceExecuteLog(this.device_code, "", "", "后工位指令" + task1 + "完成异常,异常原因:" + e.getMessage()); + } + writing("to_command2", "0"); + writing("to_onset2", "0"); + writing("to_target2", "0"); + writing("to_task2", "0"); + + } + this.requireSucess1 = false; + } else if (action_1 == 4 && move_1 == 0 && task1 > 0 && action_2 == 0 && move_2 == 0 && task2 == 0) { + inst1 = checkInst(); + if (inst1 != null) { + try { + finish_instruction(inst1); + } catch (Exception e) { + log.error("RGV 前工位完成指令异常", e); + logServer.deviceExecuteLog(this.device_code, "", "", "前工位指令" + task1 + "完成异常,异常原因:" + e.getMessage()); + } + writing("to_command1", "0"); + writing("to_onset1", "0"); + writing("to_target1", "0"); + writing("to_task1", "0"); + writing("to_container_type", "0"); + } + this.requireSucess1 = false; + } + + + if (task1 > 0) { + inst1 = checkInst(); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + instructionService.update(inst1); + } + } + } + if (task2 > 0) { + inst2 = checkInst(); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "0")) { + inst2.setInstruction_status("1"); + instructionService.update(inst2); + } + } + } + } + } + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task1 > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task1))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task1)); + return inst; + } + } else { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task2))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task2)); + return inst; + } + } + + } else { + + if (this.task1 > 0) { + inst = instructionService.findByCodeFromCache(String.valueOf(task1)); + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task2)); + } + return inst; + } + } + + + public void isSetAddress(Device device) { + if (ObjectUtil.isEmpty(device.getExtraValue().get("OPCServer"))) { + throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!"); + } + } + + + /** + * 下发前工位任务 + * @param dto + */ + public synchronized void sendHeadSignalType(Instruction dto) { + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + this.isSetAddress(startDevice); + this.isSetAddress(nextDevice); + String start_addr = startDevice.getExtraValue().get("OPCServer").toString(); + String next_addr = nextDevice.getExtraValue().get("OPCServer").toString(); + this.writing("to_onset1", start_addr); + this.writing("to_target1", next_addr); + this.writing("to_task1", dto.getInstruction_code()); + this.writing("to_command1", "1"); + } + + /** + * 下发后工位任务 + * @param dto + */ + public synchronized void sendBackSignalType(Instruction dto) { + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + this.isSetAddress(startDevice); + this.isSetAddress(nextDevice); + String start_addr = startDevice.getExtraValue().get("OPCServer").toString(); + String next_addr = nextDevice.getExtraValue().get("OPCServer").toString(); + this.writing("to_onset2", start_addr); + this.writing("to_target2", next_addr); + this.writing("to_task2", dto.getInstruction_code()); + this.writing("to_command2", "1"); + this.writing("to_onset2", start_addr); + this.writing("to_target2", next_addr); + this.writing("to_task2", dto.getInstruction_code()); + this.writing("to_command2", "1"); + } + + /** + * 下发前后工位任务 + * @param dto + */ + public synchronized void sendHeadBackSignalType(Instruction dto) { + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + String start_device_code2 = dto.getStart_device_code2(); + String next_device_code2 = dto.getNext_device_code2(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); + Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); + this.isSetAddress(startDevice); + this.isSetAddress(nextDevice); + this.isSetAddress(startDevice2); + this.isSetAddress(nextDevice2); + String start_addr = startDevice.getExtraValue().get("OPCServer").toString(); + String next_addr = nextDevice.getExtraValue().get("OPCServer").toString(); + String start_addr2 = startDevice2.getExtraValue().get("OPCServer").toString(); + String next_addr2 = nextDevice2.getExtraValue().get("OPCServer").toString(); + this.writing("to_onset1", start_addr); + this.writing("to_target1", next_addr); + this.writing("to_task1", dto.getInstruction_code()); + //this.writing("to_command1", "1"); + this.writing("to_onset2", start_addr2); + this.writing("to_target2", next_addr2); + this.writing("to_task2", dto.getInstruction_code()); + this.writing("to_command2", "1"); + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java index 3d5d1fd..c2fb212 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java @@ -258,8 +258,6 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements } else { message = "无请求"; } - - Object ignore_pickup_check = this.getExtraValue().get("ignore_pickup_check"); } last_mode = mode; @@ -599,7 +597,7 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements * @param */ public synchronized boolean apply_take_empty_vehicle() { - if(move == 0) { + if(move == 1) { ApplyTaskRequest request = new ApplyTaskRequest(); request.setDevice_code(this.getDevice_code()); request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName()); @@ -619,7 +617,7 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements } return true; } else { - message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 设备有货未请求LMS..."; + message = RequestMethodEnum.getName("apply_take_empty_vehicle") + "apply_take_empty_vehicle 设备无货未请求LMS..."; lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message)); return false; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/AcsToWmsData/applyTask/ApplyTaskResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/AcsToWmsData/applyTask/ApplyTaskResponse.java index df3cb4c..f0c3857 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/AcsToWmsData/applyTask/ApplyTaskResponse.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/AcsToWmsData/applyTask/ApplyTaskResponse.java @@ -22,4 +22,8 @@ public class ApplyTaskResponse extends BaseResponse { private String mix_num; private String weight; + + + //private String is_order_finish; + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 2df56e6..0d825b5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -855,10 +855,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("device_code", device.getDevice_code()); jo.put("mode", lnshRGVDeviceDriver.getMode()); jo.put("status", lnshRGVDeviceDriver.getStatus()); - jo.put("move1", lnshRGVDeviceDriver.getMove1()); - jo.put("move2", lnshRGVDeviceDriver.getMove2()); - jo.put("action1", lnshRGVDeviceDriver.getAction1()); - jo.put("action2", lnshRGVDeviceDriver.getAction2()); + jo.put("move1", lnshRGVDeviceDriver.getMove_1()); + jo.put("move2", lnshRGVDeviceDriver.getMove_2()); + jo.put("action1", lnshRGVDeviceDriver.getAction_1()); + jo.put("action2", lnshRGVDeviceDriver.getAction_2()); jo.put("walk_y", lnshRGVDeviceDriver.getWalk_y()); jo.put("error", lnshRGVDeviceDriver.getError()); jo.put("task1", lnshRGVDeviceDriver.getTask1()); @@ -1064,10 +1064,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("device_code", device.getDevice_code()); jo.put("mode", lnshRGVDeviceDriver.getMode()); jo.put("status", lnshRGVDeviceDriver.getStatus()); - jo.put("move_1", lnshRGVDeviceDriver.getMove1()); - jo.put("move_2", lnshRGVDeviceDriver.getMove2()); - jo.put("action_1", lnshRGVDeviceDriver.getAction1()); - jo.put("action_2", lnshRGVDeviceDriver.getAction2()); + jo.put("move_1", lnshRGVDeviceDriver.getMove_1()); + jo.put("move_2", lnshRGVDeviceDriver.getMove_2()); + jo.put("action_1", lnshRGVDeviceDriver.getAction_1()); + jo.put("action_2", lnshRGVDeviceDriver.getAction_2()); jo.put("walk_y", lnshRGVDeviceDriver.getWalk_y()); jo.put("error", lnshRGVDeviceDriver.getError()); jo.put("task1", lnshRGVDeviceDriver.getTask1()); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/JsonUtl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/JsonUtl.java new file mode 100644 index 0000000..b09be1f --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/JsonUtl.java @@ -0,0 +1,125 @@ +package org.nl.acs.opc; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.type.TypeFactory; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class JsonUtl { + private static ObjectMapper objectMapper = null; + private static ObjectMapper objectMapperLog = null; + + private JsonUtl() { + } + + private static ObjectMapper init() { + ObjectMapper objectMapper = new ObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); +// simpleModule.addSerializer(Enum.class, new EnumSerializer()); +// simpleModule.addSerializer(Date.class, new DateSerializer()); +// simpleModule.addDeserializer(Enum.class, new EnumDeserializer()); +// simpleModule.addDeserializer(Date.class, new DateDeserializers.DateDeserializer()); + objectMapper.registerModule(simpleModule); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + return objectMapper; + } + + public static ObjectMapper getInstance() { + if (objectMapper == null) { + Class var0 = JsonUtl.class; + synchronized(JsonUtl.class) { + if (objectMapper == null) { + objectMapper = init(); + } + } + } + + return objectMapper; + } + + public static ObjectMapper getInstanceLog() { + if (objectMapperLog == null) { + Class var0 = JsonUtl.class; + synchronized(JsonUtl.class) { + if (objectMapperLog == null) { + objectMapperLog = init(); + objectMapperLog.setSerializationInclusion(Include.NON_NULL); + } + } + } + + return objectMapperLog; + } + + public static ObjectMapper getObjectMapper() { + return getInstance(); + } + + public static String parse(Object object) throws RuntimeException { + try { + return getObjectMapper().writeValueAsString(object); + } catch (JsonProcessingException var2) { + throw new RuntimeException(var2); + } + } + + public static String parseWithoutException(Object object) { + try { + return parse(object); + } catch (Exception var2) { + return null; + } + } + + public static String parseLog(Object object) { + try { + return getInstanceLog().writeValueAsString(object); + } catch (Exception var2) { + return null; + } + } + + public static T format(String json, Class clazz) throws RuntimeException { + try { + return getObjectMapper().readValue(json, clazz); + } catch (IOException var3) { + throw new RuntimeException(var3); + } + } + + public static List formatList(String json, Class clazz) throws RuntimeException { + try { + JavaType type = getObjectMapper().getTypeFactory().constructParametricType(List.class, new Class[]{clazz}); + return (List)getObjectMapper().readValue(json, type); + } catch (IOException var3) { + throw new RuntimeException(var3); + } + } + + public static Map formatMap(String json, Class clazzKey, Class clazzValue) throws RuntimeException { + try { + JavaType type = getObjectMapper().getTypeFactory().constructParametricType(Map.class, new Class[]{clazzKey, clazzValue}); + return (Map)getObjectMapper().readValue(json, type); + } catch (IOException var4) { + throw new RuntimeException(var4); + } + } + + public static List> formatListTwo(String json, Class clazz) throws RuntimeException { + try { + TypeFactory typeFactory = getObjectMapper().getTypeFactory(); + JavaType type = typeFactory.constructParametrizedType(List.class, List.class, new Class[]{clazz}); + type = typeFactory.constructParametrizedType(List.class, List.class, new JavaType[]{type}); + return (List)getObjectMapper().readValue(json, type); + } catch (IOException var4) { + throw new RuntimeException(var4); + } + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index 504d7ff..63b3c5b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -248,4 +248,8 @@ public class TaskDto implements Serializable { */ private String direction; + /** + * 放货设备编号(覆膜机) + */ + private String put_device_code; } diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java index 31c7793..51f5a04 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java @@ -740,39 +740,39 @@ public class StageServiceImpl implements StageService { status = "故障"; } - if (lnshRGVDeviceDriver.getMove1() == 0) { + if (lnshRGVDeviceDriver.getMove_1() == 0) { move_1 = "无货"; - } else if (lnshRGVDeviceDriver.getMove1() == 1) { + } else if (lnshRGVDeviceDriver.getMove_1() == 1) { move_1 = "有货"; - } else if (lnshRGVDeviceDriver.getMove1() == 2) { + } else if (lnshRGVDeviceDriver.getMove_1() == 2) { move_1 = "有托盘有货"; } - if (lnshRGVDeviceDriver.getMove2() == 0) { + if (lnshRGVDeviceDriver.getMove_2() == 0) { move_2 = "无货"; - } else if (lnshRGVDeviceDriver.getMove2() == 1) { + } else if (lnshRGVDeviceDriver.getMove_2() == 1) { move_2 = "有货"; - } else if (lnshRGVDeviceDriver.getMove2() == 2) { + } else if (lnshRGVDeviceDriver.getMove_2() == 2) { move_2 = "有托盘有货"; } - if (lnshRGVDeviceDriver.getAction1() == 1) { + if (lnshRGVDeviceDriver.getAction_1() == 1) { action_1 = "取货中"; - } else if (lnshRGVDeviceDriver.getAction1() == 2) { + } else if (lnshRGVDeviceDriver.getAction_1() == 2) { action_1 = "取货完成"; - } else if (lnshRGVDeviceDriver.getAction1() == 3) { + } else if (lnshRGVDeviceDriver.getAction_1() == 3) { action_1 = "放货中"; - } else if (lnshRGVDeviceDriver.getAction1() == 4) { + } else if (lnshRGVDeviceDriver.getAction_1() == 4) { action_1 = "放货完成"; } - if (lnshRGVDeviceDriver.getAction2() == 1) { + if (lnshRGVDeviceDriver.getAction_2() == 1) { action_2 = "取货中"; - } else if (lnshRGVDeviceDriver.getAction2() == 2) { + } else if (lnshRGVDeviceDriver.getAction_2() == 2) { action_2 = "取货完成"; - } else if (lnshRGVDeviceDriver.getAction2() == 3) { + } else if (lnshRGVDeviceDriver.getAction_2() == 3) { action_2 = "放货中"; - } else if (lnshRGVDeviceDriver.getAction2() == 4) { + } else if (lnshRGVDeviceDriver.getAction_2() == 4) { action_2 = "放货完成"; } diff --git a/acs/nladmin-ui/src/views/acs/device/driver/lnsh/lnsh_fold_disc_site.vue b/acs/nladmin-ui/src/views/acs/device/driver/lnsh/lnsh_fold_disc_site.vue index 9dc2b0a..6bc543a 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/lnsh/lnsh_fold_disc_site.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/lnsh/lnsh_fold_disc_site.vue @@ -166,6 +166,68 @@ + +
+ 交互相关: +
+
+ + + + + 新增一行 + + + +
+
+ + + + + + + + + + + +
+
+
PLC读取字段: @@ -301,11 +363,20 @@ export default { opc_id: '', opc_code: '', configLoading: false, + requestMethodList: [], dataOpcservers: [], dataOpcPlcs: [], deviceList: [], data1: [], data2: [], + modeform: { + tableData: [ + { + mode: '8', + request: 'apply_force_take_full_vehicle' + } + ] + }, form: { inspect_in_stocck: true, ignore_pickup_check: true, @@ -360,9 +431,16 @@ export default { deviceCrud.selectDeviceList().then(data => { this.deviceList = data }) + deviceCrud.selectRequestMethodList().then(data => { + this.requestMethodList = data + }) }) }, methods: { + deleteRow(index, rows) { + debugger + rows.splice(index, 1) + }, finishReadEdit(data) { // 编辑的是code列,并且值包含mode if (data.code.indexOf('mode') !== -1) { @@ -493,7 +571,7 @@ export default { parentForm.is_route = true parentForm.plc_id = this.plc_id parentForm.opc_id = this.opc_id - updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => { + updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => { this.notify('保存成功', 'success') this.configLoading = false }).catch(err => { diff --git a/acs/nladmin-ui/src/views/acs/instruction/index.vue b/acs/nladmin-ui/src/views/acs/instruction/index.vue index 0da6e7f..b364ff7 100644 --- a/acs/nladmin-ui/src/views/acs/instruction/index.vue +++ b/acs/nladmin-ui/src/views/acs/instruction/index.vue @@ -127,9 +127,13 @@ - + - + + + + +