diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index e29dfcf..d1c9d24 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -29,7 +29,7 @@ public interface NDCAgvService { */ public void sendAgvInstToNDC(String agv_system_type,Instruction inst) throws Exception; - public byte[] sendAgvOneModeInst(int phase, int index,int result); + public byte[] sendAgvOneModeInst(int phase, int index,int result,int startPoint,int nextPoint,int startHigh,int nextHigh); public byte[] sendAgvTwoModeInst(int phase, int index,int result); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index c4ce0e5..ea08887 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -75,7 +75,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { public void sendAgvInstToNDC(String agv_system_type, Instruction inst) { if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { String instcode = inst.getInstruction_code(); - int type = Integer.parseInt(inst.getAgv_inst_type()); + int type = Integer.parseInt(inst.getInstruction_type()); int priority = Integer.parseInt(inst.getPriority()) + 128; DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); @@ -125,23 +125,35 @@ public class NDCAgvServiceImpl implements NDCAgvService { } @Override - public byte[] sendAgvOneModeInst(int phase, int index, int result) { + public byte[] sendAgvOneModeInst(int phase, int index, int result,int startPoint,int nextPoint,int startHigh,int nextHigh) { if (phase < 0 || index < 0) return null; byte indexhigh = (byte) IntToHexHigh(index); byte indexlow = (byte) IntToHexLow(index); byte phasehigh = (byte) IntToHexHigh(phase); byte phaselow = (byte) IntToHexLow(phase); + byte startPointHigh =(byte) IntToHexHigh(startPoint); + byte startPointLow =(byte) IntToHexLow(startPoint); + byte nextPointHigh =(byte) IntToHexHigh(nextPoint); + byte nextPointLow =(byte) IntToHexLow(nextPoint); + byte startHighHigh =(byte) IntToHexHigh(startHigh); + byte startHighLow =(byte) IntToHexLow(startHigh); + byte nextHighHigh =(byte) IntToHexHigh(nextHigh); + byte nextHighLow =(byte) IntToHexLow(nextHigh); byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, + (byte) 0X00, (byte) 0X12, (byte) 0X00, (byte) 0X01, (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, + (byte) 0X00, (byte) 0X0E, (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow + (byte) 0X01, (byte) 0X14, + (byte) phasehigh, (byte) phaselow, + (byte) startPointHigh, (byte) startPointLow, + (byte) nextPointHigh, (byte) nextPointLow, + (byte) startHighHigh, (byte) startHighLow, + (byte) nextHighHigh, (byte) nextHighLow }; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index 3149f00..1c6c92b 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -158,7 +158,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setSend_status("1"); instructionService.update(inst); } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); } //任务完毕 //(无车id及状态) @@ -168,13 +168,13 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } else { log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!"); } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); log.info("指令号:{},已反馈agv任务完成!"); } //请求删除任务 //(需要WCS反馈) else if (phase == 0x30) { - data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0); + data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0); } //任务删除确认 //(需要WCS反馈) @@ -185,7 +185,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { instructionService.cancelNOSendAgv(inst.getInstruction_id()); } } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); } else { //上报异常信息 @@ -255,7 +255,17 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { dos.flush(); } catch (IOException e) { // TODO Auto-generated catch block - e.printStackTrace(); + try { + Thread.sleep(5000L); + log.info("再次下发agv数据:" + Bytes2HexString(b)); + System.out.println("再次下发agv数据:" + Bytes2HexString(b)); + dos.write(b); + dos.flush(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } } } + diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index 937e61c..35cf45d 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.basedriver.agv.ndcone; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpResponse; @@ -17,6 +18,7 @@ import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDevic import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; import org.nl.acs.device_driver.driver.AbstractDeviceDriver; +import org.nl.acs.ext.wms.data.BaseRequest; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.instruction.domain.Instruction; @@ -26,7 +28,9 @@ import org.nl.acs.log.LokiLog; import org.nl.acs.log.LokiLogType; import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.task.domain.Task; import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.impl.TaskServiceImpl; import org.nl.system.service.param.ISysParamService; import org.nl.config.SpringContextHolder; @@ -111,7 +115,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (arr[18] * 256 + arr[19] == 0) { } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0); } //普通站点 @@ -121,6 +125,12 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic // SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + TaskDto task =taskService.findById(inst.getTask_id()); + int start_height= ObjectUtil.isNotEmpty(task.getStart_height())?Integer.parseInt(task.getStart_height()):0; + int next_height= ObjectUtil.isNotEmpty(task.getNext_height())?Integer.parseInt(task.getNext_height()):0; + String start_point=task.getStart_point_code(); + String next_point=task.getNext_point_code(); + //分配 车id //(不需要WCS反馈) if (phase == 0x02) { @@ -166,30 +176,11 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic return; } - Object reqWms = device.getExtraValue().get("reqWms"); - if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) { - JSONArray req = new JSONArray(); - JSONObject map = new JSONObject(); - map.put("vehicle_code", inst.getVehicle_code()); - map.put("status", "1"); - map.put("device_code", inst.getStart_point_code()); - map.put("task_code", inst.getTask_code()); - req.add(map); - HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); - if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { - JSONObject resp = JSONObject.parseObject(httpResponse.body()); - if (resp.getInteger("status") == 200) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code()); - } else { - log.warn("指令号:{},acs请求wms取货申请成功,wms不允许agv申请取货,未反馈agv允许取货", inst.getInstruction_code()); - } - } else { - log.warn("指令号:{},acs请求wms取货申请失败,连接被拒绝,未反馈agv允许取货", inst.getInstruction_code()); - } - } else { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } + data = getData(data, index, inst, task); + //到达取货等待点 + //(需要WCS反馈) + } else if (phase == 0x04) { + data = getData(data, index, inst, task); //取货完毕 //(需要WCS反馈) } else if (phase == 0x05) { @@ -226,31 +217,10 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); return; } - - Object reqWms = device.getExtraValue().get("reqWms"); - if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) { - JSONArray req = new JSONArray(); - JSONObject map = new JSONObject(); - map.put("vehicle_code", inst.getVehicle_code()); - map.put("status", "2"); - map.put("device_code", inst.getStart_point_code()); - map.put("task_code", inst.getTask_code()); - req.add(map); - HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); - if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { - JSONObject resp = JSONObject.parseObject(httpResponse.body()); - if (resp.getInteger("status") == 200) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - log.info("指令号:{},acs反馈wms取货完成成功,wms允许agv取货完成,已反馈agv取货完成", inst.getInstruction_code()); - } else { - log.warn("指令号:{},acs反馈wms取货完成成功,wms不允许agv取货完成,未反馈agv取货完成", inst.getInstruction_code()); - } - } else { - log.warn("指令号:{},acs反馈wms取货完成失败,连接被拒绝,未反馈agv取货完成", inst.getInstruction_code()); - } - } else { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } + data = getData(data, index, inst, task); + //到达放货等待点 + //(需要WCS反馈) + } else if (phase == 0x06) { //到达放货点 //(需要WCS反馈) } else if (phase == 0x07) { @@ -284,30 +254,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic log.info("未找到关联编号{}对应的指令", ikey); return; } - Object reqWms = device.getExtraValue().get("reqWms"); - if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) { - JSONArray req = new JSONArray(); - JSONObject map = new JSONObject(); - map.put("vehicle_code", inst.getVehicle_code()); - map.put("status", "3"); - map.put("device_code", inst.getNext_point_code()); - map.put("task_code", inst.getTask_code()); - req.add(map); - HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); - if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { - JSONObject resp = JSONObject.parseObject(httpResponse.body()); - if (resp.getInteger("status") == 200) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code()); - } else { - log.warn("指令号:{},acs请求wms放货申请成功,wms不允许agv申请放货,未反馈agv允许放货", inst.getInstruction_code()); - } - } else { - log.warn("指令号:{},acs请求wms放货申请失败,连接被拒绝,未反馈agv允许放货", inst.getInstruction_code()); - } - } else { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } + data = getData(data, index, inst, task); + //放货完毕 //(需要WCS反馈) } else if (phase == 0x09) { @@ -342,25 +290,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic log.info("未找到编号{}对应的指令", ikey); return; } - Object reqWms = device.getExtraValue().get("reqWms"); - if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) { - JSONArray req = new JSONArray(); - JSONObject map = new JSONObject(); - map.put("vehicle_code", inst.getVehicle_code()); - map.put("status", "4"); - map.put("device_code", inst.getNext_point_code()); - map.put("task_code", inst.getTask_code()); - req.add(map); - HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); - if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code()); - } else { - log.warn("指令号:{},acs请求wms放货申请失败,连接被拒绝,未反馈agv允许放货", inst.getInstruction_code()); - } - } else { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0); } //到达位置点 //(需要WCS反馈) @@ -368,13 +298,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备 agvaddr = arr[18] * 256 + arr[19]; agvaddr_copy = agvaddr; - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } else if (phase == 0x50) {//进入交通灯区域 - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } else if (phase == 0x51) {//离开交通灯区域 - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0,0,0,0,0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } if (!ObjectUtil.isEmpty(data)) { @@ -383,4 +313,39 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } } + private byte[] getData(byte[] data, int index, Instruction inst, TaskDto task) { + String next_point; + String start_point; + int next_height; + int start_height; + if(!"2".equals(task.getTask_type())) { + BaseRequest request = new BaseRequest(); + request.setRequestNo(IdUtil.simpleUUID()); + request.setTaskId(task.getExt_task_id()); + JSONObject resp = JSONObject.parseObject(acsToWmsService.feedbackState(request)); + if("200".equals(resp.getString("code"))){ + start_height=resp.getJSONObject("parameters").getInteger("start_height"); + next_height=resp.getJSONObject("parameters").getInteger("next_height"); + start_point=resp.getJSONObject("parameters").getString("start_point"); + next_point=resp.getJSONObject("parameters").getString("next_point"); + task.setStart_height(String.valueOf(start_height)); + task.setNext_height(String.valueOf(next_height)); + task.setStart_point_code(start_point); + task.setStart_device_code(start_point); + task.setNext_point_code(next_point); + task.setNext_device_code(next_point); + int start_address=deviceService.queryAddressBydeviceCode(start_point); + int next_address=deviceService.queryAddressBydeviceCode(next_point); + taskService.update(task); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, start_address, next_address, start_height, next_height); + log.info("指令号:{},phase:{},acs请求wms申请成功", inst.getInstruction_code(),phase); + }else{ + log.info("指令号:{},phase:{},acs请求wms申请失败", inst.getInstruction_code(),phase); + } + }else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); + } + return data; + } + } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java index 7b9fc6f..592ca4a 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java @@ -16,7 +16,6 @@ public class ItemProtocol { public static String item_move = "move"; public static String item_action = "action"; public static String item_error = "error"; - public static String item_task = "task"; public static String item_to_command = "to_command"; public static String item_to_target = "to_target"; public static String item_to_task = "to_task"; @@ -50,9 +49,6 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_error); } - public int getTask() { - return this.getOpcIntegerValue(item_task); - } public int getMaterialType() { return this.getOpcIntegerValue(item_material_type); @@ -99,8 +95,7 @@ public class ItemProtocol { list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3")); list.add(new ItemDto(item_action, "取放信号", "DB600.B4")); - list.add(new ItemDto(item_task, "任务号", "DB600.D6")); - list.add(new ItemDto(item_material_type, "任务号", "DB600.D6")); + list.add(new ItemDto(item_material_type, "物料类型", "DB600.D6")); list.add(new ItemDto(item_error, "报警信号", "DB600.B7")); list.add(new ItemDto(item_barcode, "条码", "DB600.D8")); return list; @@ -109,8 +104,6 @@ public class ItemProtocol { public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); return list; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index 11884d3..a7b4de8 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -146,16 +146,19 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp public void execute() { String message = null; try { - String device_code = this.getDeviceCode(); + devicecode = this.getDeviceCode(); mode = this.itemProtocol.getMode(); error = this.itemProtocol.getError(); move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); hasGoods = this.itemProtocol.getMove(); action = this.itemProtocol.getAction(); material_type = this.itemProtocol.getMaterialType(); + barcode=this.itemProtocol.getBarcode(); if (mode != last_mode) { this.setRequireSucess(false); + if(mode==2){ + this.writing(0); + } } if (move != last_move) { } @@ -196,25 +199,25 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp break; case 4: //叫料 - if (move==0){ + if (move==0 && !requireSucess){ apply(4); } break; case 5: //满料出库 - if(move==1){ + if(move==1 && !requireSucess){ apply(5); } break; case 6: //申请空盘 - if (move==0){ + if (move==0 && !requireSucess){ apply(6); } break; case 7: //空托盘出库 - if(move==1){ + if(move==1 && !requireSucess){ apply(7); } break; @@ -238,6 +241,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp last_move = move; last_task = task; last_material_type = material_type; + last_barcode=barcode; } @@ -442,8 +446,9 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp this.time = date; FeedBackTaskStatusRequest request = new FeedBackTaskStatusRequest(); request.setDevice_code(devicecode); + request.setMaterial_type(String.valueOf(material_type)); request.setVehicle_code(String.valueOf(barcode)); - if (devicecode.startsWith("TBX")&&type==5) { + if (devicecode.startsWith("TBX")&&type==5&&barcode>0) { //满架下料 request.setRequest_medthod_code(RequestMethodEnum.apply_mjxl.getCode()); request.setRequest_medthod_name(RequestMethodEnum.apply_mjxl.getName()); @@ -455,15 +460,15 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp //空托盘出库,包片机和销售出库空位都可以 request.setRequest_medthod_code(RequestMethodEnum.apply_kghjrk.getCode()); request.setRequest_medthod_name(RequestMethodEnum.apply_kghjrk.getName()); - }else if(devicecode.startsWith("BP")){ + }else if(devicecode.startsWith("BP")&&material_type>0){ request.setRequest_medthod_code(RequestMethodEnum.apply_bpsl.getCode()); request.setRequest_medthod_name(RequestMethodEnum.apply_bpsl.getName()); } String resp = acsToWmsService.applyTask(request); JSONObject res_jo = JSONObject.parseObject(resp); - if (StrUtil.equals(res_jo.getString("status"), "200")) { + if (StrUtil.equals(res_jo.getString("code"), "200")) { this.writing(type); - this.setSucess(true); + this.setRequireSucess(true); log.info("acs申请任务", this.devicecode, "满盅入库任务申请成功!"); }else{ this.writing(99); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java index 5935872..9b93ce4 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java @@ -126,7 +126,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("1"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0,0,0); agvphase = 0; index = 0; inst = null; @@ -141,7 +141,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("2"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0,0,0); // OneNDCSocketConnectionAutoRun.write(data); agvphase = 0; index = 0; @@ -157,7 +157,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("5"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0,0,0); // OneNDCSocketConnectionAutoRun.write(data); agvphase = 0; index = 0; @@ -172,7 +172,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple if (ObjectUtil.isNotEmpty(inst)) { inst.setExecute_status("6"); instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); + byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0,0,0,0,0); // OneNDCSocketConnectionAutoRun.write(data); agvphase = 0; index = 0; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java index 9e58407..a864698 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java @@ -1,37 +1,96 @@ package org.nl.acs.device_driver.driver; -import org.nl.acs.ext.wms.data.JsonUtl; -import org.nl.acs.opc.OpcConfig; -import org.nl.acs.opc.OpcServerService; -import org.nl.acs.opc.OpcServerServiceImpl; +import org.nl.acs.opc.*; import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessorFactory; - -import org.nl.common.exception.BadRequestException; +import org.nl.acs.udw.UnifiedDataAppService; import org.nl.config.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.Date; -import java.util.Iterator; -import java.util.Map; +import java.util.*; public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver { UnifiedDataAccessor opcUdw; + 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; - public AbstractOpcDeviceDriver() { - this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); - } - @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 RuntimeException("写入次数超过3次而失败"); + } + ++i; + } + } + + public boolean control(Map itemValues) { Iterator> it = itemValues.entrySet().iterator(); @@ -48,7 +107,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc i++; } - return this.control(p2); + return this.control(p2); } @@ -70,11 +129,13 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc sb.append(":"); sb.append(JsonUtl.parseWithoutException(udw_value)); sb.append(";"); -// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) { -// need_write = true; -// } + if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) { + need_write = true; + } else { + //log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value ); + } } - need_write = true; + // need_write = true; if (need_write) { Date date = new Date(); @@ -85,9 +146,9 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc 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();*/ + /* 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); @@ -106,7 +167,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc return true; } else { - throw new BadRequestException("下发 无内容"); + throw new RuntimeException("下发 无内容"); } } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/BaseRequest.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/BaseRequest.java index a35e7dc..8006730 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/BaseRequest.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/BaseRequest.java @@ -63,6 +63,10 @@ public class BaseRequest { */ private String state; + /** + * 任务号 + */ + private String taskId; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/feedBackTaskStatus/FeedBackTaskStatusRequest.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/feedBackTaskStatus/FeedBackTaskStatusRequest.java index eb3267b..bd0dfd0 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/feedBackTaskStatus/FeedBackTaskStatusRequest.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/feedBackTaskStatus/FeedBackTaskStatusRequest.java @@ -41,5 +41,10 @@ public class FeedBackTaskStatusRequest extends BaseRequest { */ private String action; + /** + * 1-正极板;2-负极板;3-边负极板 + */ + private String material_type; + } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 4b00ea8..e3af8f8 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -127,4 +127,9 @@ public interface AcsToWmsService { * ACS向WMS反馈任务状态 */ String notify(BaseRequest request); + + /** + * 任务阶段反馈最新点位 + */ + String feedbackState(BaseRequest request); } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index d18663b..e473525 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -592,4 +592,18 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { MDC.remove(log_file_type); } } + + @Override + public String feedbackState(BaseRequest requestParam) { + try { + MDC.put(log_file_type, log_type); + String api = addressService.findByCode("feedbackState").getMethods_url(); + log.info("feedbackState-----输入参数{}", JSON.toJSONString(requestParam, SerializerFeature.DisableCircularReferenceDetect)); + String result = LmsUtil.notifyAcs(api, requestParam); + log.info("feedbackState-----输出参数{}", result); + return result; + } finally { + MDC.remove(log_file_type); + } + } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/rest/InstructionController.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/rest/InstructionController.java index ec58e83..398d3e3 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/rest/InstructionController.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/rest/InstructionController.java @@ -1,6 +1,7 @@ package org.nl.acs.instruction.rest; import cn.dev33.satoken.annotation.SaIgnore; +import cn.hutool.core.util.ObjectUtil; import org.nl.common.logging.annotation.Log; import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.service.InstructionService; @@ -36,6 +37,9 @@ public class InstructionController { @ApiOperation("查询指令") //@PreAuthorize("@el.check('instruction:list')") public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { + if(ObjectUtil.isEmpty(whereJson.get("status"))) { + whereJson.put("status", "1"); + } return new ResponseEntity<>(instructionService.queryAll(whereJson, page), HttpStatus.OK); } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 450fb52..32d0498 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -85,6 +85,7 @@ public class InstructionServiceImpl extends CommonServiceImpl instructions = new CopyOnWriteArrayList(); // List instructions_mybatis = new CopyOnWriteArrayList(); @@ -384,13 +385,13 @@ public class InstructionServiceImpl extends CommonServiceImpl 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/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java index 8c2f34c..4020563 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java @@ -1,6 +1,7 @@ package org.nl.acs.task.rest; import cn.dev33.satoken.annotation.SaIgnore; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import org.nl.common.logging.annotation.Log; import org.nl.acs.task.domain.Task; @@ -38,6 +39,9 @@ public class TaskController { //@PreAuthorize("@el.check('task:list')") public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { // return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK); + if(ObjectUtil.isEmpty(whereJson.get("status"))) { + whereJson.put("status", "1"); + } return new ResponseEntity<>(taskService.queryAll(whereJson, page), HttpStatus.OK); } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index c80a62d..96c0712 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -290,4 +290,16 @@ public class TaskDto implements Serializable { * 烘箱温度 */ private String temperature; + + /** + * 起点高度 + */ + private String start_height; + + /** + * 终点高度 + */ + private String next_height; + + } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/AutoCreateInst.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/AutoCreateInst.java new file mode 100644 index 0000000..8da8e35 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/AutoCreateInst.java @@ -0,0 +1,341 @@ +package org.nl.quartz.task; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.AcsConfig; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.config.SpringContextHolder; +import org.nl.system.service.param.ISysParamService; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; + +/** + * 自动创建指令 + */ +@Slf4j +@Component +public class AutoCreateInst { + /** + * 根据任务状态创建指令、生成下一条指令 + * 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货 + */ + public void run() throws Exception { + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + ISysParamService acsConfigService = SpringContextHolder.getBean(ISysParamService.class); + List list = taskserver.queryByStauts("0"); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + for (int i = 0; i < list.size(); i++) { + TaskDto acsTask = list.get(i); + String taskid = acsTask.getTask_id(); + String taskcode = acsTask.getTask_code(); + String vehiclecode = acsTask.getVehicle_code(); + String priority = acsTask.getPriority(); + String start_point_code = acsTask.getStart_point_code(); + String start_device_code = acsTask.getStart_device_code(); + String route_plan_code = acsTask.getRoute_plan_code(); + String vehicleType = acsTask.getVehicle_type(); + //是否复合任务 =0非复合任务 + String compound_task = acsTask.getCompound_task(); + String compound_task_data = null; + String next_point_code = acsTask.getNext_point_code(); + String next_device_code = acsTask.getNext_device_code(); + if (StrUtil.isEmpty(start_device_code)) { + log.info("任务 [" + taskcode + "] 起点设备为空,无法生成指令。"); + acsTask.setRemark("任务 [" + taskcode + "] 起点设备为空,无法生成指令。"); + taskserver.updateByCodeFromCache(acsTask); + continue; + } + if (StrUtil.isEmpty(next_device_code)) { + log.info("任务 [" + taskcode + "] 终点设备为空,无法生成指令。"); + acsTask.setRemark("任务 [" + taskcode + "] 终点设备为空,无法生成指令。"); + taskserver.updateByCodeFromCache(acsTask); + continue; + } + List instructions = instructionService.queryAll("instruction_status < 2"); + String maxInstnumber = acsConfigService.findByCode(AcsConfig.MAXINSTNUMBER).getValue(); + if (ObjectUtils.isNotEmpty(maxInstnumber)) { + if (instructions.size() >= Integer.parseInt(maxInstnumber)) { + log.info("已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。"); + acsTask.setRemark("已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。"); + taskserver.updateByCodeFromCache(acsTask); + continue; + } + } + + + /** + * 开始平均分解校验 + */ + String this_device_code = taskserver.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); + if (StrUtil.isEmpty(this_device_code)) { + List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + if (StrUtil.equals(acsTask.getTask_type(), "2")) { + for (int j = 0; j < pathlist.size(); j++) { + if (j == 0) { + compound_task_data = pathlist.get(j).trim(); + } else { + compound_task_data = compound_task_data + "->" + pathlist.get(j).trim(); + } + } + next_device_code = pathlist.get(pathlist.size() - 1); + + } else { + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; + } + } + next_device_code = pathlist.get(index); + } + } else { + next_device_code = this_device_code; + } + //校验路由关系 + List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList)) { + log.info("任务 [" + taskcode + "] 路由不通无法生成指令。"); + acsTask.setRemark("任务 [" + taskcode + "] 路由不通无法生成指令。"); + taskserver.updateByCodeFromCache(acsTask); + continue; + } + + if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { + continue; + } + Device startdevice = appService.findDeviceByCode(start_device_code); + Device nextdevice = appService.findDeviceByCode(next_device_code); + if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); + } else { + next_point_code = next_device_code; + } + if (ObjectUtils.isEmpty(startdevice)) { + log.info("任务 [" + taskcode + "] 起点设备编码 [" + start_device_code + "] 对应设备未找到,无法生成指令。"); + continue; + } + if (ObjectUtils.isEmpty(nextdevice)) { + log.info("任务 [" + taskcode + "] 终点设备编码 [" + next_device_code + "] 对应设备未找到,无法生成指令。"); + continue; + } + //普通站点 + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; +// StandardEmptyPalletSiteDeviceDriver standardEmptsyPalletSiteDeviceDriver; +// LampThreecolorDeviceDriver lampThreecolorDeviceDriver; +// LnshFoldDiscSiteDeviceDriver lnshFoldDiscSiteDeviceDriver; + + String createTaskCheck = acsConfigService.findByCode(AcsConfig.CREATETASKCHECK).getValue(); + + if (StrUtil.equals(createTaskCheck, "1")) { + if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMode() != 2) { + log.info("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); + acsTask.setRemark("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); + taskserver.updateByCodeFromCache(acsTask); + //this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); + //this.execute_log.log("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); + continue; + } + } +// if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { +// standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver(); +// if (standardEmptsyPalletSiteDeviceDriver.getMode() != 2) { +// log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); +// acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// } +// if (startdevice.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) { +// lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) startdevice.getDeviceDriver(); +// if (lnshFoldDiscSiteDeviceDriver.getMode() != 2) { +// log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); +// acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// } + + //校验 是否同任务是否存在相同终点、未完成的指令 + int sameqty = instructionService.querySameDestinationInst(next_point_code); + if (sameqty > 0) { + log.info("存在相同终点的指令,任务号:" + taskcode); + acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); + taskserver.updateByCodeFromCache(acsTask); + continue; + } + } + + //空盘位生成指令需要另外逻辑 +// if (nextdevice.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) { +// lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) nextdevice.getDeviceDriver(); +// if (lnshFoldDiscSiteDeviceDriver.getMode() == 0) { +// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } else if (lnshFoldDiscSiteDeviceDriver.getError() != 0 +// || lnshFoldDiscSiteDeviceDriver.getStatus() == 3) { +// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// int max_emptypalletnum = Integer.parseInt(nextdevice.getExtraValue().get("max_emptypalletnum").toString()); +// int nowNumber = lnshFoldDiscSiteDeviceDriver.getContainer_qty(); +// if (nowNumber >= max_emptypalletnum) { +// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已满,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已满,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// // 查看是否有相同终点的指令 +// int count = instructionService.queryDeviceInstCount(next_device_code); +// if (count > 0) { +// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已被占用,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 已被占用,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); +// //this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); +// continue; +// } +// next_point_code = next_device_code + "." + (nowNumber + 1); +// } else if (nextdevice.getDeviceDriver() instanceof LnshStationDeviceDriver +// && "true".equals(nextdevice.getExtraValue().get("inspect_in_stocck"))) { +// LnshStationDeviceDriver deviceDriver = (LnshStationDeviceDriver) nextdevice.getDeviceDriver(); +// if (deviceDriver.getMode() == 0) { +// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } else if (deviceDriver.getMove() != 0) { +// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 有货,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 有货,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } else if (deviceDriver.getError() != 0) { +// log.info("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 终点 [" + nextdevice.getDevice_name() + "] 异常,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// } + +// if (startdevice.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) { +// lnshFoldDiscSiteDeviceDriver = (LnshFoldDiscSiteDeviceDriver) startdevice.getDeviceDriver(); +// if (lnshFoldDiscSiteDeviceDriver.getMode() == 0) { +// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } else if (lnshFoldDiscSiteDeviceDriver.getError() != 0 +// || lnshFoldDiscSiteDeviceDriver.getStatus() == 3) { +// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// +// int container_qty = lnshFoldDiscSiteDeviceDriver.getContainer_qty(); +// int max_emptypalletnum = Integer.parseInt(startdevice.getExtraValue().get("max_emptypalletnum").toString()); +// if (container_qty < (max_emptypalletnum / 2)) { +// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 可用托盘数量少于最大托盘数量 [" + max_emptypalletnum + "] / 2,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 可用托盘数量少于最大托盘数量 [" + max_emptypalletnum + "] / 2,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// +// int count = instructionService.queryDeviceInstCount(start_device_code); +// if (count > 0) { +// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 已被占用,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 已被占用,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); +// //this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); +// continue; +// } +// +// start_point_code = start_device_code + ".1"; +// } else if (startdevice.getDeviceDriver() instanceof LnshStationDeviceDriver +// && "true".equals(startdevice.getExtraValue().get("inspect_in_stocck"))) { +// LnshStationDeviceDriver deviceDriver = (LnshStationDeviceDriver) startdevice.getDeviceDriver(); +// if (deviceDriver.getMode() == 0) { +// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 未联机,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } else if (deviceDriver.getMove() == 0) { +// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 无货,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 无货,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } else if (deviceDriver.getError() != 0) { +// log.info("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。"); +// acsTask.setRemark("任务 [" + taskcode + "] 起点 [" + startdevice.getDevice_name() + "] 异常,无法生成指令。"); +// taskserver.updateByCodeFromCache(acsTask); +// continue; +// } +// } + + Instruction instdto = new Instruction(); + instdto.setInstruction_type(acsTask.getTask_type()); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(acsTask.getRemark()); + instdto.setMaterial(acsTask.getMaterial()); + instdto.setQuantity(acsTask.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.setCompound_inst_data(compound_task_data); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + instdto.setVehicle_type(vehicleType); + try { + instructionService.create(instdto); + } catch (Exception e) { + acsTask.setRemark(e.getMessage()); + taskserver.updateByCodeFromCache(acsTask); + continue; + } + log.info("任务 [" + taskcode + "] 指令成功生成!"); + //创建指令后修改任务状态 + acsTask.setTask_status("1"); + taskserver.update(acsTask); + + } + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/NdcAutoReconnection.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/NdcAutoReconnection.java new file mode 100644 index 0000000..2b43ffc --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/NdcAutoReconnection.java @@ -0,0 +1,30 @@ +package org.nl.quartz.task; + +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.auto.run.AutoRunService; +import org.nl.system.service.param.ISysParamService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * NDC自动重连 + */ +@Slf4j +@Component +public class NdcAutoReconnection { + + @Autowired + ISysParamService paramService; + + @Autowired + AutoRunService autoRunService; + + public void run(String threadCode) throws Exception { + String[] threadCodes = threadCode.split(","); + for (String code : threadCodes) { + if (!autoRunService.getThreadByCode(code).isAlive()) { + autoRunService.startThread(code); + } + } + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/AcsToWmsController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/AcsToWmsController.java index d23863c..3e04561 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/AcsToWmsController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/AcsToWmsController.java @@ -56,6 +56,15 @@ public class AcsToWmsController { return new ResponseEntity<>(acsToWmsService.status(param), HttpStatus.OK); } + @PostMapping("/feedbackState") + @Log("ACS系统反馈AGV取放货状态") + @ApiOperation("ACS系统反馈AGV取放货状态") + //@SaCheckPermission("@el.check('schBaseTask:add')") + @SaIgnore + public ResponseEntity feedbackState(@RequestBody JSONObject param) { + return new ResponseEntity<>(acsToWmsService.feedbackState(param), HttpStatus.OK); + } + @PostMapping("/notify") @Log("acs通知wms") @ApiOperation("acs通知wms") @@ -64,4 +73,13 @@ public class AcsToWmsController { public ResponseEntity notify(@RequestBody JSONObject param) { return new ResponseEntity<>(acsToWmsService.notify(param), HttpStatus.OK); } + +// @PostMapping("/notify") +// @Log("acs通知wms") +// @ApiOperation("acs通知wms") +// //@SaCheckPermission("@el.check('schBaseTask:add')") +// @SaIgnore +// public ResponseEntity notify(@RequestBody JSONObject param) { +// return new ResponseEntity<>(acsToWmsService.notify(param), HttpStatus.OK); +// } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/AcsToWmsService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/AcsToWmsService.java index 6b49d06..cc74c00 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/AcsToWmsService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/AcsToWmsService.java @@ -15,7 +15,10 @@ public interface AcsToWmsService { /** 任务反馈 */ BaseResponse status(JSONObject param); - /** 任务反馈 */ + /** 任务阶段反馈最新点位 */ + BaseResponse feedbackState(JSONObject param); + + /** acs通知wms */ BaseResponse notify(JSONObject param); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java index e909a03..26ae64b 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java @@ -11,6 +11,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; import org.nl.system.service.notice.ISysNoticeService; +import org.nl.system.service.param.ISysParamService; import org.nl.wms.database.material.service.IMdBaseMaterialService; import org.nl.wms.database.material.service.dao.MdBaseMaterial; import org.nl.wms.ext.service.AcsToWmsService; @@ -39,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -179,4 +181,44 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { return BaseResponse.responseOk(requestNo, "反馈成功!"); } + /** + * 任务阶段反馈最新点位 + * todo + * */ + + @Override + public BaseResponse feedbackState(JSONObject param) { + String requestNo = param.getString("requestNo"); + String taskId = param.getString("taskId"); + BaseResponse result = BaseResponse.build(requestNo); + try { + SchBaseTask schBaseTask=taskService.getById(taskId); + if(ObjectUtil.isEmpty(schBaseTask)){ + throw new BadRequestException("任务不存在!taskId:"+taskId); + } + AbstractTask task = taskFactory.getTask(schBaseTask.getConfig_code()); + // 执行创建任务 + task.feedbackState(param,schBaseTask,result); + taskService.update(schBaseTask); + Map map=new HashMap<>(); + map.put("start_point",schBaseTask.getPoint_code1()); + map.put("next_point",schBaseTask.getPoint_code2()); + map.put("start_height",schBaseTask.getPoint_code1_height()); + map.put("next_height",schBaseTask.getPoint_code2_height()); + result.setParameters(map); + } catch (Exception e) { + String message = ObjectUtil.isEmpty(e.getMessage()) + ? ((InvocationTargetException) e).getTargetException().getMessage() + : e.getMessage(); + log.error("ACS请求LMS出现错误: {}", message); + result.setCode(HttpStatus.HTTP_BAD_REQUEST); + result.setMessage(message); + result.setRequestNo(requestNo); + // 消息通知 + noticeService.createNotice("异常信息:" + message, "acsApply: " + param.getString("request_medthod_code"), + NoticeTypeEnum.EXCEPTION.getCode()); + } + return result; + } + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/SchBasePoint.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/SchBasePoint.java index b2a335f..b2073d0 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/SchBasePoint.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/SchBasePoint.java @@ -141,4 +141,10 @@ public class SchBasePoint implements Serializable { @TableField(exist = false) private String group_id; + @ApiModelProperty(value = "取货等待点") + private String start_wait_point; + + @ApiModelProperty(value = "放货等待点") + private String next_wait_point; + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/dao/SchBaseTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/dao/SchBaseTask.java index 635327f..3b33d43 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/dao/SchBaseTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/dao/SchBaseTask.java @@ -120,4 +120,10 @@ public class SchBaseTask implements Serializable { @ApiModelProperty(value = "修改时间") private String update_time; + @ApiModelProperty(value = "点位1高度") + private String point_code1_height="0"; + + @ApiModelProperty(value = "点位2高度") + private String point_code2_height="0"; + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java index 9184c48..2bebcc8 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.nl.common.exception.BadRequestException; import org.nl.wms.database.material.service.IMdBaseMaterialService; import org.nl.wms.database.material.service.dao.MdBaseMaterial; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.point.service.ISchBasePointService; @@ -23,7 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author ldjun @@ -227,4 +230,16 @@ public abstract class AbstractTask { this.updateStatus(task_code, status); } + /** + * 任务阶段反馈最新点位 + * + * @param param + * @throws BadRequestException + */ + public void feedbackState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) throws BadRequestException { + this.feedbackTaskState(param,schBaseTask,result); + } + + protected abstract void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask,BaseResponse result); + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java index 53c8a94..27a20db 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; import org.nl.config.MapOf; import org.nl.wms.ext.service.WmsToAcsService; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -85,7 +86,8 @@ public class BPSLTask extends AbstractTask { continue; } // 设置起点并修改创建成功状态 - task.setPoint_code1(point.getPoint_code()); + // 取料先去等待点 + task.setPoint_code1(point.getStart_wait_point()); task.setTask_status(TaskStatus.CREATED.getCode()); task.setRemark(""); taskService.update(task); @@ -214,4 +216,13 @@ public class BPSLTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + //todo 重算最优点 + JSONObject jsonObject = JSONObject.parseObject(schBaseTask.getExt_group_data()); + SchBasePoint point = this.findNextPoint(jsonObject); + // 设置起点并修改创建成功状态 + schBaseTask.setPoint_code1(point.getPoint_code()); + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java index 1199992..9b24457 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; import org.nl.config.MapOf; import org.nl.wms.ext.service.WmsToAcsService; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -175,4 +176,9 @@ public class KGHJRKTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + //todo 重算最优点 + } } \ No newline at end of file diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java index 6bdd795..e34a3f2 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -30,6 +31,7 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.util.List; +import java.util.Map; /** * @Author: psh @@ -241,4 +243,9 @@ public class MJXLTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + //无需重算,返回当前点位即可 + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java index 5acdcf9..0e4b895 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; import org.nl.config.MapOf; import org.nl.wms.ext.service.WmsToAcsService; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -181,4 +182,9 @@ public class TBXBKJTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + //todo 重算最优点 + } } \ No newline at end of file diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java index 64381fd..d92d171 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; import org.nl.config.MapOf; import org.nl.wms.ext.service.WmsToAcsService; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -88,7 +89,8 @@ public class XSCKTask extends AbstractTask { continue; } // 设置起点并修改创建成功状态 - task.setPoint_code1(point.getPoint_code()); + // 取料先去等待点 + task.setPoint_code1(point.getStart_wait_point()); task.setTask_status(TaskStatus.CREATED.getCode()); task.setRemark(""); taskService.update(task); @@ -226,4 +228,14 @@ public class XSCKTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + // 重算最优点 + SchBasePoint nextPoint=pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, schBaseTask.getPoint_code2())); + SchBasePoint point = this.findNextPoint(nextPoint,JSONObject.parseObject(schBaseTask.getExt_group_data())); + // 设置起点并修改创建成功状态 + schBaseTask.setPoint_code1(point.getPoint_code()); + } } \ No newline at end of file diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ZJBZKDDTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ZJBZKDDTask.java index 0ae7ac9..c1306b5 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ZJBZKDDTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ZJBZKDDTask.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; import org.nl.config.MapOf; import org.nl.wms.ext.service.WmsToAcsService; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -88,4 +89,9 @@ public class ZJBZKDDTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + //todo 重算最优点 + } } \ No newline at end of file diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java index 8060f56..a4b0663 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java @@ -11,6 +11,7 @@ import org.nl.common.exception.BadRequestException; import org.nl.config.MapOf; import org.nl.wms.database.material.service.dao.MdBaseMaterial; import org.nl.wms.ext.service.WmsToAcsService; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -279,4 +280,10 @@ public class GHSFMTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + //todo 重算最优点 + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSQHTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSQHTask.java index a7e9a06..2a549eb 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSQHTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSQHTask.java @@ -6,10 +6,12 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; import org.nl.config.MapOf; import org.nl.wms.ext.service.WmsToAcsService; +import org.nl.wms.ext.service.dto.to.BaseResponse; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; @@ -97,7 +99,8 @@ public class GHSQHTask extends AbstractTask { log.info("未找到当前符合允许放货的缓存点,暂不生成任务Vehicle_type:{}",schBasePoint.getVehicle_type()); return; } - this.createTask(schBasePoint,nextPoint.getPoint_code()); + // 放料先去等待点 + this.createTask(schBasePoint,nextPoint.getNext_wait_point()); } @@ -292,4 +295,17 @@ public class GHSQHTask extends AbstractTask { public void cancel(String task_code) { this.updateStatus(task_code, TaskStatus.CANCELED); } + + @SneakyThrows + @Override + protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { + //todo 重算最优点 + SchBasePoint startPoint=pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, schBaseTask.getPoint_code1())); + SchBasePoint nextPoint=this.findNextPoint(startPoint); + if(ObjectUtil.isEmpty(nextPoint)){ + throw new Exception("当前起点"+schBaseTask.getPoint_code1()+"未找到合适的放货点位"); + } + schBaseTask.setPoint_code2(nextPoint.getPoint_code()); + } } diff --git a/lms/nladmin-ui/src/views/wms/sch/group/index.vue b/lms/nladmin-ui/src/views/wms/sch/group/index.vue index 2b186a1..9d23a3b 100644 --- a/lms/nladmin-ui/src/views/wms/sch/group/index.vue +++ b/lms/nladmin-ui/src/views/wms/sch/group/index.vue @@ -253,6 +253,7 @@ +