diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java index 4aec5f4..5e79f72 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java @@ -150,12 +150,7 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i 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 = "未联机"; @@ -258,16 +253,14 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i return false; } else { this.instruction_require_time = date; - JSONObject jo = acsToWmsService.getVehicleCode(this.device_code); if (jo.getInteger("status") == 200) { String vehicle_code = jo.getString("vehicle_code"); - - this.writing(this.mode); this.writing("to_barcode",vehicle_code); + this.writing(this.mode); + requireSucess = true; } - requireSucess = true; return true; } } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java index 9b75d0e..ad57956 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java @@ -3,6 +3,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -13,6 +14,7 @@ import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; @@ -49,7 +51,8 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); @Autowired DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); String device_code; int mode = 0; int error = 0; @@ -70,6 +73,12 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem int branchProtocol = 0; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + private int instruction_finished_time_out; + String message; int status = 0; int last_status = 0; @@ -181,7 +190,9 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem break; case 3: - + if (!requireSucess) { + palletizing(); + } break; case 4: break; @@ -198,6 +209,31 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem last_container_qty = container_qty; } + + /** + * 拆垛完成 + * + * @param + */ + public synchronized boolean palletizing() { + 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 (result.getStatus() == 200) { + this.writing(this.mode); + requireSucess = true; + } + return true; + } + } + 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/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java index 2ae12d7..5b2481a 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java @@ -186,12 +186,7 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen 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 = "未联机"; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java index 29ac7e8..d1747d6 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java @@ -34,10 +34,7 @@ import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; import java.lang.reflect.Field; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 晟华-包装码垛机械手 @@ -603,12 +600,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD 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 = "未联机"; @@ -651,6 +643,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD case 6: //码垛完成 if (!requireSucess) { + applyEmpty(); palletizing(); } break; @@ -665,6 +658,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD if (!requireSucess) { applyEmpty(); } + break; case 9: //工单完成 if (!requireSucess && !order_No.equals("0")) { @@ -791,13 +785,13 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD this.writing(this.mode); ProduceshiftorderDto dto = produceshiftorderService.findByCode(order_No); if (this.mode == 4) { - dto.setOrder_status("0"); + dto.setOrder_status("1"); } else if (this.mode == 9){ dto.setOrder_status("2"); } produceshiftorderService.update(dto); + requireSucess = true; } - requireSucess = true; return true; } } @@ -815,7 +809,11 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD } else { this.instruction_require_time = date; JSONObject json = new JSONObject(); - json.put("device_code",this.device_code); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("vehicle_code",barcode); JSONObject jo = acsToWmsService.getVehicle(json); @@ -883,7 +881,6 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD String two_qty = content.getString("two_qty"); String tool_coordinate = content.getString("tool_coordinate"); - this.writing(this.mode); this.writing("to_material_qty",qty); this.writing("to_material_code",material_code); this.writing("to_product_code",product_code); @@ -944,9 +941,10 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD this.writing("to_one_qty",one_qty); this.writing("to_two_qty",two_qty); this.writing("to_tool_coordinate",tool_coordinate); + this.writing(this.mode); + requireSucess = true; } - requireSucess = true; return true; } } @@ -964,7 +962,11 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD } else { this.instruction_require_time = date; JSONObject json = new JSONObject(); - json.put("device_code",this.device_code); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("qty",qty); json.put("vehicle_code",barcode); json.put("is_full","1"); @@ -1030,8 +1032,8 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD HttpResponse result = acsToWmsService.applyTaskManipulatorToWms(json); if (result.getStatus() == 200) { this.writing(this.mode); + requireSucess = true; } - requireSucess = true; return true; } } @@ -1049,7 +1051,11 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD } else { this.instruction_require_time = date; JSONObject json = new JSONObject(); - json.put("device_code",this.device_code); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("qty",qty); json.put("vehicle_code",barcode); json.put("is_full","0"); @@ -1115,8 +1121,8 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD HttpResponse result = acsToWmsService.applyTaskManipulatorToWms(json); if (result.getStatus() == 200) { this.writing(this.mode); + requireSucess = true; } - requireSucess = true; return true; } } @@ -1134,16 +1140,17 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD } else { this.instruction_require_time = date; JSONObject json = new JSONObject(); - json.put("device_code",this.device_code); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("type","4"); - json.put("qty",qty); - json.put("vehicle_code",barcode); HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json); if (result.getStatus() == 200) { this.writing(this.mode); + requireSucess = true; } - - requireSucess = true; return true; } } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java index 3460a38..685af1c 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java @@ -3,6 +3,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_package_site; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.Data; @@ -16,6 +17,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; @@ -54,7 +56,8 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); @Autowired DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); //放货准备锁 String putReadyLock = null; //有货标记 @@ -178,16 +181,7 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme return; } - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else 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 = "未联机"; @@ -210,15 +204,12 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme case 2: break; case 3: - //申请空盘 - if (!requireSucess && this.move == 0) { - applyEmpty(); - } + break; case 4: - //申请搬运任务 - if (!requireSucess && this.move != 0) { - autoCreateTask(); + //申请贴标 + if (!requireSucess && this.move != 0 && !StrUtil.equals("0",barcode)) { + applyBarcode(); } break; case 5: @@ -238,130 +229,32 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme } /** - * 生成搬运任务 + * 申请贴标 * * @return */ - public synchronized boolean autoCreateTask() { + public synchronized boolean applyBarcode() { Date date = new Date(); if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return false; } else { this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setStart_device_code(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - next_device_code = ""; - continue; - } - if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) { - break; - } - } + JSONObject json = new JSONObject(); + json.put("device_code",this.device_code); + json.put("vehicle_code",barcode); + HttpResponse result = acsToWmsService.applyBarcode(json); + if (result.getStatus() == 200) { + this.writing(this.mode); + requireSucess = true; } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setRequireSucess(true); + return true; } } - public synchronized boolean applyEmpty() { - - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String start_device_code = ""; - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - - JSONArray ja = routelineserver.querySuperiorLine(this.getDevice().getDevice_code(), plan_uuid); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - start_device_code = jo.get("device_code").toString(); - Device start_device = appService.findDeviceByCode(start_device_code); - StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; - if (start_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) start_device.getDeviceDriver(); - //根据路由 寻找取空盘的设备 -// if(standardEmptyPalletSiteDeviceDriver.getNumber() < Integer.parseInt(standardEmptyPalletSiteDeviceDriver.getDevice().getExtraValue().get("max_emptypalletnum").toString()) ) { -// break; -// } - if (standardEmptyPalletSiteDeviceDriver.getMode() == 2 && standardEmptyPalletSiteDeviceDriver.getNumber() > 0) { - break; - } - } - } - dto.setTask_type("1"); - dto.setEmptypallet_num("1"); - dto.setNext_device_code(this.getDevice().getDevice_code()); - dto.setNext_point_code(this.getDevice().getDevice_code()); - dto.setStart_point_code(start_device_code); - dto.setStart_device_code(start_device_code); - if (StrUtil.isEmpty(start_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setRequireSucess(true); - this.setBranchProtocol(0); - return true; - } - } - public void finish_instruction(Instruction instruction) throws Exception { instruction_finished(instruction); } @@ -446,52 +339,14 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme } - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.lnsh.lnsh_station.ItemProtocol.item_to_command; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); } public void writing(int type, int command) { diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java index 81ef4d4..e1c0203 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java @@ -26,14 +26,17 @@ public class ItemProtocol { public static String item_standby_time = "standby_time"; public static String item_production_time = "production_time"; public static String item_error_time = "error_time"; - public static String item_to_command = "to_command"; + + public static String item_to_command1 = "to_command1"; public static String item_to_onset1 = "to_onset1"; public static String item_to_target1 = "to_target1"; - public static String item_to_task = "to_task"; + public static String item_to_task1 = "to_task1"; + public static String item_to_command2 = "to_command2"; public static String item_to_task2 = "to_task2"; public static String item_to_onset2 = "to_onset2"; public static String item_to_target2 = "to_target2"; + private LnshRGVDeviceDriver driver; public ItemProtocol(LnshRGVDeviceDriver driver) { @@ -100,8 +103,8 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_task2); } - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); + public int getTo_command1() { + return this.getOpcIntegerValue(item_to_command1); } public int getTo_onset1() { @@ -120,14 +123,19 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_to_target2); } - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); + public int getTo_command2() { + return this.getOpcIntegerValue(item_to_command2); + } + + public int getTo_task1() { + return this.getOpcIntegerValue(item_to_task1); } public int getTo_task2() { return this.getOpcIntegerValue(item_to_task2); } + //是否有货 public int hasGoods(int move) { return move; @@ -170,13 +178,14 @@ public class ItemProtocol { public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); - list.add(new ItemDto(item_to_onset1, "下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_target1, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D8")); - list.add(new ItemDto(item_to_onset2, "下发起始站", "DB2.W12")); - list.add(new ItemDto(item_to_target2, "下发目标站", "DB2.W14")); - list.add(new ItemDto(item_to_task2, "下发任务号2", "DB2.D20")); + list.add(new ItemDto(item_to_command1, "前工位下发命令", "DB51.W0")); + list.add(new ItemDto(item_to_onset1, "下发起始站", "DB51.W2")); + list.add(new ItemDto(item_to_target1, "下发目标站", "DB51.W4")); + list.add(new ItemDto(item_to_task1, "下发任务号", "DB51.D6")); + list.add(new ItemDto(item_to_command2, "后工位下发命令", "DB51.W10")); + list.add(new ItemDto(item_to_onset2, "下发起始站2", "DB51.W12")); + list.add(new ItemDto(item_to_target2, "下发目标站2", "DB51.W14")); + list.add(new ItemDto(item_to_task2, "下发任务号2", "DB51.D16")); return list; } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java index ee2d815..84c9a87 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java @@ -24,13 +24,11 @@ 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.utils.SpringContextHolder; +import org.nl.wql.core.bean.WQLObject; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 晟华RGV @@ -52,6 +50,13 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); @Autowired DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + //当前指令1 + Instruction inst1 = null; + //当前指令2 + Instruction inst2 = null; int mode = 0; int error = 0; @@ -73,6 +78,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 int flag; + Boolean requireSucess1 = false; + Boolean requireSucess2 = false; + String device_code; int status = 0; int last_status = 0; @@ -110,7 +118,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi @Override - public void execute() throws Exception{ + public void execute() throws Exception { String message = null; try { device_code = this.getDeviceCode(); @@ -131,72 +139,118 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi if (mode != last_mode) { this.setRequireSucess(false); - logServer.deviceItemValue(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); } if (error != last_error) { - logServer.deviceItemValue(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code,"","","信号error:" + last_error + "->" + error); + logServer.deviceItemValue(this.device_code, "error", String.valueOf(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.deviceItemValue(this.device_code, "status", String.valueOf(status)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status); } if (move_1 != last_move_1) { - logServer.deviceItemValue(this.device_code,"move_1" ,String.valueOf(move_1)); - logServer.deviceExecuteLog(this.device_code,"","","信号move_1:" + last_move_1 + "->" + move_1); + logServer.deviceItemValue(this.device_code, "move_1", String.valueOf(move_1)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move_1:" + last_move_1 + "->" + move_1); } if (move_2 != last_move_2) { - logServer.deviceItemValue(this.device_code,"move_2" ,String.valueOf(move_2)); - logServer.deviceExecuteLog(this.device_code,"","","信号move_2:" + last_move_2 + "->" + move_2); + logServer.deviceItemValue(this.device_code, "move_2", String.valueOf(move_2)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move_2:" + last_move_2 + "->" + move_2); } if (action_1 != last_action_1) { - logServer.deviceItemValue(this.device_code,"action_1" ,String.valueOf(action_1)); - logServer.deviceExecuteLog(this.device_code,"","","信号action_1:" + last_action_1 + "->" + action_1); + logServer.deviceItemValue(this.device_code, "action_1", String.valueOf(action_1)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action_1:" + last_action_1 + "->" + action_1); } if (action_2 != last_action_2) { - logServer.deviceItemValue(this.device_code,"action_2" ,String.valueOf(action_2)); - logServer.deviceExecuteLog(this.device_code,"","","信号action_2:" + last_action_2 + "->" + action_2); + logServer.deviceItemValue(this.device_code, "action_2", String.valueOf(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.deviceItemValue(this.device_code, "walk_y", String.valueOf(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.deviceItemValue(this.device_code, "task1", String.valueOf(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.deviceItemValue(this.device_code, "task2", String.valueOf(task2)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2); } if (open_time != 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); + logServer.deviceItemValue(this.device_code, "open_time", String.valueOf(open_time)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号open_time:" + last_open_time + "->" + open_time); } 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); + logServer.deviceItemValue(this.device_code, "standby_time", String.valueOf(standby_time)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号standby_time:" + last_standby_time + "->" + standby_time); } 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); + logServer.deviceItemValue(this.device_code, "production_time", String.valueOf(production_time)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号production_time:" + last_production_time + "->" + production_time); } 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); + logServer.deviceItemValue(this.device_code, "error_time", String.valueOf(error_time)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error_time:" + last_error_time + "->" + error_time); } } catch (Exception var17) { return; } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { + if (task1 > 0) { + //inst_message + inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + instructionService.update(inst1); + } + } + } + if (action_1 == 4 && move_1 == 0 && task1 > 0) { + //inst_message + inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "1")) { + finish_instruction(inst1); + } + } + } + + if (task2 > 0) { + //inst_message + inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "0")) { + inst2.setInstruction_status("1"); + instructionService.update(inst2); + } + } + } + if (action_2 == 4 && move_2 == 0 && task2 > 0) { + //inst_message + inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "1")) { + finish_instruction(inst2); + } + } + } + + //给后工位下发空盘放货信号 + if (mode == 3 && action_1 == 2 && action_2 == 2 && move_1 == 1 && move_2 == 1 && task1 > 0 && task2 > 0) { + writing("to_command2", "2"); + } + + + //给前工位下发放货信号 + if (mode == 3 && action_2 == 4 && move_1 == 1 && move_2 == 0 && task1 > 0) { + writing("to_command1", "2"); + } + + if (mode == 0) { this.setIsonline(false); this.setIserror(true); message = "未联机"; @@ -217,25 +271,29 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi log.debug("设备运转模式:等待工作"); return; case 2: - //申请任务 - if (walk_y == 1 && move_1 == 0 && !requireSucess ) { - instruction_apply(); + //后工位申请任务 + if (mode == 2 && move_2 == 0 && action_2 == 0 && !requireSucess2) { + instruction_require2(); } break; + case 3: + //前工位申请任务 + if (mode == 3 && move_2 == 1 && action_2 == 1 && move_1 == 0 && !requireSucess1) { + instruction_require(); + } } switch (flag) { //取货完成 case 1: - writing(2); + writing1(2); return; //放货完成 case 2: - writing(3); + writing1(3); return; } - } last_mode = mode; last_error = error; @@ -263,126 +321,187 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi } } - /** - * 请求指令 - */ - public synchronized boolean instruction_apply() throws Exception { + + 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); + + } + + public synchronized boolean finish_instruction(Instruction inst) throws Exception { + instructionService.finish(inst); + return true; + } + + //申请前工位任务 + public synchronized boolean instruction_require() throws Exception { Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return false; } else { - this.instruction_require_time = date; - - Object[] value = (Object[]) this.device.getExtraValue().get("get_device_code"); - Object[] value2 = (Object[]) this.device.getExtraValue().get("load_device_code"); - Object[] value3 = (Object[]) this.device.getExtraValue().get("put_device_code"); - - for (int i = 0; i < value.length; i++) { - String get_device_code = value[i].toString(); - //Device device = appService.findDeviceByCode(get_device_code); - TaskDto task = taskserver.findByStartCode(get_device_code); - if (!ObjectUtil.isEmpty(task)) { - for (int j = 0; j < value2.length; j++) { - String putdevice_code = value2[j].toString(); - if (StrUtil.equals(task.getNext_device_code(), putdevice_code)) { - 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(); - - 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(putdevice_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(putdevice_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instructionService.create(instdto); - //创建指令后修改任务状态 - task.setTask_status("1"); - taskserver.update(task); - requireSucess = true; - writing(instdto); - break; - } - } + this.instruction_apply_time = date; + String linkobj = (String)this.getDevice().getExtraValue().get("get_device_code1"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List device_code_list = Arrays.asList(demoArray); + TaskDto task = null; + for(int i=0;i device_code_list = Arrays.asList(demoArray); + TaskDto task = null; + for(int i=0;i itemMap = new HashMap(); + itemMap.put(to_param, value); + ReadUtil.write(itemMap, server); } } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDefination.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDefination.java index b4adb48..84498b6 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDefination.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDefination.java @@ -66,7 +66,7 @@ public class LnshSplitManipulatorDefination implements OpcDeviceDriverDefination list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB7.D520")); list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB7.D524")); list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB7.D528")); - list.add(new ItemDto(ItemProtocol.item_material, "物料", "DB7.D532")); + list.add(new ItemDto(ItemProtocol.item_material, "物料", "DB7.S532")); list.add(new ItemDto(ItemProtocol.item_total_split, "累计拆垛数量", "DB7.D536")); list.add(new ItemDto(ItemProtocol.item_product_code, "产品编号", "DB7.D544")); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java index 6df00f2..e89d1dd 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java @@ -31,10 +31,7 @@ import org.nl.wql.core.bean.WQLObject; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 晟华拆垛机械手 @@ -628,6 +625,12 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im } break; case 7: + //申请出库 + if (!requireSucess) { + callMaterial(); + } + break; + case 8: //申请空盘 if (!requireSucess) { applyEmpty(); @@ -742,12 +745,16 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im } else { this.instruction_require_time = date; JSONObject json = new JSONObject(); - json.put("device_code",this.device_code); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(getStation-1).replace("\"","")); json.put("vehicle_code",barcode); JSONObject jo = acsToWmsService.getVehicle(json); if (jo.getInteger("status") == 200) { - JSONObject content = jo.getJSONObject("content"); + JSONObject content = jo.getJSONObject("data"); String qty = content.getString("qty"); String material_code = content.getString("material_code"); String material_name = content.getString("material_name"); @@ -810,7 +817,6 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im String two_qty = content.getString("two_qty"); String tool_coordinate = content.getString("tool_coordinate"); - this.writing(this.mode); this.writing("to_material",material_code); this.writing("to_AlongSide",AlongSide); this.writing("to_BshortSide",BshortSide); @@ -869,9 +875,9 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im this.writing("to_one_qty",one_qty); this.writing("to_two_qty",two_qty); this.writing("to_tool_coordinate",tool_coordinate); - + this.writing(this.mode); + requireSucess = true; } - requireSucess = true; return true; } } @@ -889,74 +895,47 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im } else { this.instruction_require_time = date; JSONObject json = new JSONObject(); - json.put("device_code",this.device_code); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(getStation-1).replace("\"","")); + json.put("type","3"); json.put("qty",total_split); json.put("vehicle_code",barcode); - json.put("is_full","1"); - json.put("product_code",product_code); - json.put("AlongSide",AlongSide); - json.put("BshortSide",BshortSide); - json.put("Htrapezoidal",Htrapezoidal); - json.put("Wthickness",Wthickness); - json.put("tray_qty",tray_qty); - json.put("tray_high",tray_high); - json.put("crib_category",crib_category); - json.put("palletX1_line",palletX1_line); - json.put("palletY1_row",palletY1_row); - json.put("palletA1_angle",palletA1_angle); - json.put("palletX2_line",palletX2_line); - json.put("palletY2_row",palletY2_row); - json.put("palletA2_angle",palletA2_angle); - json.put("palletX3_line",palletX3_line); - json.put("palletY3_row",palletY3_row); - json.put("palletA3_angle",palletA3_angle); - json.put("pressCribX1_line",pressCribX1_line); - json.put("pressCribY1_row",pressCribY1_row); - json.put("pressCribA1_angle",pressCribA1_angle); - json.put("pressCribX2_line",pressCribX2_line); - json.put("pressCribY2_row",pressCribY2_row); - json.put("pressCribA2_angle",pressCribA2_angle); - json.put("pressCribX3_line",pressCribX3_line); - json.put("pressCribY3_row",pressCribY3_row); - json.put("pressCribA3_angle",pressCribA3_angle); - json.put("Zoffset",Zoffset); - json.put("pallet_layerQty",pallet_layerQty); - json.put("pressCrib_layerQty",pressCrib_layerQty); - json.put("codeLayerX1_interval",codeLayerX1_interval); - json.put("codeLayerY1_interval",codeLayerY1_interval); - json.put("codeLayerX2_interval",codeLayerX2_interval); - json.put("codeLayerY2_interval",codeLayerY2_interval); - json.put("codeLayerX3_interval",codeLayerX3_interval); - json.put("codeLayerY3_interval",codeLayerY3_interval); - json.put("codeLayerX1_offset",codeLayerX1_offset); - json.put("codeLayerY1_offset",codeLayerY1_offset); - json.put("codeLayerX2_offset",codeLayerX2_offset); - json.put("codeLayerY2_offset",codeLayerY2_offset); - json.put("codeLayerX3_offset",codeLayerX3_offset); - json.put("codeLayerY3_offset",codeLayerY3_offset); - json.put("pressLayerX1_interval",pressLayerX1_interval); - json.put("pressLayerY1_interval",pressLayerY1_interval); - json.put("pressLayerX2_interval",pressLayerX2_interval); - json.put("pressLayerY2_interval",pressLayerY2_interval); - json.put("pressLayerX3_interval",pressLayerX3_interval); - json.put("pressLayerY3_interval",pressLayerY3_interval); - json.put("pressLayerX1_offset",pressLayerX1_offset); - json.put("pressLayerY1_offset",pressLayerY1_offset); - json.put("pressLayerX2_offset",pressLayerX2_offset); - json.put("pressLayerY2_offset",pressLayerY2_offset); - json.put("pressLayerX3_offset",pressLayerX3_offset); - json.put("pressLayerY3_offset",pressLayerY3_offset); - json.put("one_cribTotal",one_cribTotal); - json.put("two_cribTotal",two_cribTotal); - json.put("one_qty",one_qty); - json.put("two_qty",two_qty); - json.put("tool_coordinate",tool_coordinate); + HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json); + if (result.getStatus() == 200) { + this.writing(this.mode); + requireSucess = true; + } + return true; + } + } - HttpResponse result = acsToWmsService.applyTaskManipulatorToWms(json); + /** + * 叫料 + * + * @param + */ + public synchronized boolean callMaterial() { + 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(); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(getStation-1).replace("\"","")); json.put("type","2"); + json.put("is_full","1"); + HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json); if (result.getStatus() == 200) { this.writing(this.mode); + requireSucess = true; } - requireSucess = true; return true; } } @@ -974,7 +953,11 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im } else { this.instruction_require_time = date; JSONObject json = new JSONObject(); - json.put("device_code",this.device_code); + String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List demoList = Arrays.asList(demoArray); + json.put("device_code",demoList.get(getStation-1).replace("\"","")); json.put("type","4"); json.put("qty",total_split); json.put("vehicle_code",barcode); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 687c749..eb40bbc 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -18,6 +18,12 @@ public interface AcsToWmsService { */ HttpResponse lnshApplyTaskToWms(JSONObject json); + + /** + * ACS向WMS申请贴标 + */ + HttpResponse applyBarcode(JSONObject json); + /** * 申请入窑 * @param json diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 43c0806..cfedf7d 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -226,6 +226,47 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { + @Override + public HttpResponse applyBarcode(JSONObject json) { + try { + MDC.put(log_file_type, log_type); + String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); + AddressDto addressDto = addressService.findByCode("getVehicleInfoBycode"); + String url = wmsurl + addressDto.getMethods_url(); + + String device_code = json.getString("device_code"); + + String parent_device_code = ""; + JSONObject jo = new JSONObject(); + JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + device_code + "'").uniqueResult(0); + if (!device_json.isEmpty()) { + parent_device_code = (String) device_json.get("parent_storage_cell") == null ? device_code : (String) device_json.get("parent_storage_cell"); + } + jo.put("device_code", parent_device_code); + jo.putAll(json); + + log.info("lnshApplyTaskToWms-----请求参数{}", jo.toString()); + HttpResponse result2 = null; + try { + //{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"} + result2 = HttpRequest.post(url) + .header("Authorization", token) + .body(String.valueOf(jo)) + .execute(); + System.out.println(result2); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + System.out.println(msg); + } + log.info("lnshApplyTaskToWms-----输出参数{}", result2.body()); + return result2; + } finally { + MDC.remove(log_file_type); + } + + } + @Override public HttpResponse lnshApplyTaskToWms(JSONObject json) { try { diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index ac98704..e425a09 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -219,8 +219,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu public Instruction findByTaskcodeToWms(String code) { WQLObject wo = WQLObject.getWQLObject("acs_instruction"); JSONObject json = wo.query("task_code ='" + code + "'","create_time desc").uniqueResult(0); - final Instruction obj = json.toJavaObject(Instruction.class); - return obj; + if (ObjectUtil.isNotEmpty(json)) + return json.toJavaObject(Instruction.class); + return null; } @Override diff --git a/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml b/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml index 90b8c42..fec9f7c 100644 --- a/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml +++ b/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml @@ -8,17 +8,24 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:ch_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lnsh_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + # url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:rljn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} - password: ${DB_PWD:123456} + # password: ${DB_PWD:P@ssw0rd} + password: ${DB_PWD:Root.123456} + # password: ${DB_PWD:123456} # 初始连接数 initial-size: 5 # 最小连接数 min-idle: 15 # 最大连接数 max-active: 30 + # 是否自动回收超时连接 + remove-abandoned: true + # 超时时间(以秒数为单位) + remove-abandoned-timeout: 180 # 获取连接超时时间 - max-wait: 5000 + max-wait: 3000 # 连接有效性检测时间 time-between-eviction-runs-millis: 60000 # 连接在池中最小生存的时间 @@ -38,11 +45,8 @@ spring: enabled: true stat-view-servlet: enabled: true - # 控制台管理用户名和密码 url-pattern: /druid/* reset-enable: false - login-username: admin - login-password: 123456 filter: stat: enabled: true @@ -52,10 +56,11 @@ spring: merge-sql: true wall: config: - multi-statement-allow: true + multi-statement-alagvslow: true + redis: #数据库索引 - database: ${REDIS_DB:0} + database: ${REDIS_DB:2} host: ${REDIS_HOST:127.0.0.1} port: ${REDIS_PORT:6379} password: ${REDIS_PWD:} @@ -79,7 +84,7 @@ login: heigth: 36 # 内容长度 length: 2 - # 字体名称,为空则使用默认字体,如遇到线上乱码,设置其他字体即可 + # 字体名称,为空则使用默认字体 font-name: # 字体大小 font-size: 25 @@ -91,36 +96,29 @@ jwt: token-start-with: Bearer # 必须使用最少88位的Base64对该令牌进行编码 base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI= - # 令牌过期时间 此处单位/毫秒 ,默认2小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html - token-validity-in-seconds: 7200000 + # 令牌过期时间 此处单位/毫秒 ,默认4小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html + token-validity-in-seconds: 14400000 # 在线用户key online-key: online-token- # 验证码 code-key: code-key- - # token 续期检查时间范围(默认30分钟,单位默认毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期 + # token 续期检查时间范围(默认30分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期 detect: 1800000 - # 续期时间范围,默认 1小时,这里单位毫秒 + # 续期时间范围,默认1小时,单位毫秒 renew: 3600000 -# IP 本地解析 -ip: - local-parsing: true - #是否允许生成代码,生产环境设置为false generator: - enabled: false - -#如果生产环境要开启swagger,需要配置请求地址 -#springfox: -# documentation: -# swagger: -# v2: -# host: # 接口域名或外网ip + enabled: true #是否开启 swagger-ui swagger: enabled: true +# IP 本地解析 +ip: + local-parsing: true + # 文件存储路径 file: mac: @@ -135,6 +133,33 @@ file: # 文件大小 /M maxSize: 100 avatarMaxSize: 5 + + + +jetcache: + defaultCacheType: LOCAL + statIntervalMinutes: 15 + areaInCacheName: false + hiddenPackages: com.yb + local: + default: + type: caffeine + limit: 100 + keyConvertor: fastjson + expireAfterWriteInMillis: 60000 + remote: + default: + type: redis.lettuce + keyConvertor: fastjson + valueEncoder: kryo + valueDecoder: kryo + poolConfig: + minIdle: 5 + maxIdle: 200 + maxTotal: 1000 + uri: + - redis://127.0.0.1:6379 loki: url: http://localhost:3100/loki/api/v1 systemName: acs + diff --git a/acs/hd/nladmin-system/src/main/resources/logback-spring.xml b/acs/hd/nladmin-system/src/main/resources/logback-spring.xml index 250d7bc..a61e494 100644 --- a/acs/hd/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/hd/nladmin-system/src/main/resources/logback-spring.xml @@ -136,9 +136,42 @@ https://juejin.cn/post/6844903775631572999 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue b/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue index 6cf6d30..5683d2f 100644 --- a/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue +++ b/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue @@ -1,5 +1,5 @@