From 9b64e345ccecdbe7c25162f86e0fa42f51b1de79 Mon Sep 17 00:00:00 2001 From: judy <278197488@qq.com> Date: Wed, 17 Jul 2024 16:24:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=BA=93=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/shkj/wms/bo/BaseLocationUrgentBo.java | 5 + .../java/com/shkj/wms/enums/TaskTypeEnum.java | 17 +- .../java/com/shkj/wms/plc/PlcEventTask.java | 591 +++++++------- .../main/java/com/shkj/wms/plc/PlcInit.java | 2 +- .../impl/BusinDataTaskServiceImpl.java | 751 +++++++++--------- .../java/com/shkj/wms/third/rcs/RCSUtil.java | 425 +++++----- .../mapper/wms/BaseLocationMapper.xml | 7 +- 7 files changed, 935 insertions(+), 863 deletions(-) diff --git a/shkj-wms/src/main/java/com/shkj/wms/bo/BaseLocationUrgentBo.java b/shkj-wms/src/main/java/com/shkj/wms/bo/BaseLocationUrgentBo.java index ed11db2..8f5852d 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/bo/BaseLocationUrgentBo.java +++ b/shkj-wms/src/main/java/com/shkj/wms/bo/BaseLocationUrgentBo.java @@ -27,5 +27,10 @@ public class BaseLocationUrgentBo extends BaseEntity { @NotNull(message = "原库存不得为空") private Long stockId; + /** + * 巷道 + */ + private String tunnel; + } diff --git a/shkj-wms/src/main/java/com/shkj/wms/enums/TaskTypeEnum.java b/shkj-wms/src/main/java/com/shkj/wms/enums/TaskTypeEnum.java index 83cea28..6a50353 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/enums/TaskTypeEnum.java +++ b/shkj-wms/src/main/java/com/shkj/wms/enums/TaskTypeEnum.java @@ -53,10 +53,7 @@ public enum TaskTypeEnum { */ call_container("8", "呼叫空治具"), - /** - * 9 移库 - */ - relocation("9", "跨巷道移库"), + /** * 10 补货出库 @@ -117,7 +114,17 @@ public enum TaskTypeEnum { /** * 指定货位出库 */ - named_loc("22","指定货位出库"); + named_loc("22","指定货位出库"), + + /** + * 23 跨巷道移库出库 + */ + relocation_out("23", "跨巷道移库出库"), + + /** + * 24 跨巷道移库入库 + */ + relocation_in("24", "跨巷道移库入库"); private String value; diff --git a/shkj-wms/src/main/java/com/shkj/wms/plc/PlcEventTask.java b/shkj-wms/src/main/java/com/shkj/wms/plc/PlcEventTask.java index a5e77a7..17c3fa2 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/plc/PlcEventTask.java +++ b/shkj-wms/src/main/java/com/shkj/wms/plc/PlcEventTask.java @@ -33,6 +33,7 @@ import com.shkj.wms.service.IBaseGoodsDataService; import com.shkj.wms.service.IBusinDataTaskService; import com.shkj.wms.service.IPutInOutStorageService; import com.shkj.wms.utils.JsonUtil; +import com.sun.xml.internal.bind.v2.TODO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -136,7 +137,7 @@ public class PlcEventTask { private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(8); - @Scheduled(fixedRate = 200) + // @Scheduled(fixedRate = 200) public void init() { //查询需要连接的PLC,初始化连接对象 List plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1")); @@ -144,59 +145,59 @@ public class PlcEventTask { return; } for (WcsPlcConnectVo conn : plcList) { - if ("1".equals(conn.getDevType())){ - if(conn.getPlcIp().contains(".60")){ + if ("1".equals(conn.getDevType())) { + if (conn.getPlcIp().contains(".60")) { PlcOperate plcOperate_60 = plcInit.getPlcOperate_60(); - if (plcOperate_60 ==null){ + if (plcOperate_60 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcOperate_60, conn, conn.getPointTables()); - doDevStatus(plcOperate_60,"1"); + doDevStatus(plcOperate_60, "1"); } - if(conn.getPlcIp().contains(".70")){ + if (conn.getPlcIp().contains(".70")) { PlcOperate plcOperate_70 = plcInit.getPlcOperate_70(); - if (plcOperate_70 ==null){ + if (plcOperate_70 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcOperate_70, conn, conn.getPointTables()); - doDevStatus(plcOperate_70,"2"); + doDevStatus(plcOperate_70, "2"); } - if(conn.getPlcIp().contains(".80")){ + if (conn.getPlcIp().contains(".80")) { PlcOperate plcOperate_80 = plcInit.getPlcOperate_80(); - if (plcOperate_80 ==null){ + if (plcOperate_80 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcOperate_80, conn, conn.getPointTables()); - doDevStatus(plcOperate_80,"3"); + doDevStatus(plcOperate_80, "3"); } - if(conn.getPlcIp().contains(".90")){ + if (conn.getPlcIp().contains(".90")) { PlcOperate plcOperate_90 = plcInit.getPlcOperate_90(); - if (plcOperate_90 ==null){ + if (plcOperate_90 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcOperate_90, conn, conn.getPointTables()); - doDevStatus(plcOperate_90,"4"); + doDevStatus(plcOperate_90, "4"); } - if(conn.getPlcIp().contains(".100")){ + if (conn.getPlcIp().contains(".100")) { PlcOperate plcOperate_100 = plcInit.getPlcOperate_100(); - if (plcOperate_100 ==null){ + if (plcOperate_100 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcOperate_100, conn, conn.getPointTables()); - doDevStatus(plcOperate_100,"5"); + doDevStatus(plcOperate_100, "5"); } - if(conn.getPlcIp().contains(".110")){ + if (conn.getPlcIp().contains(".110")) { PlcOperate plcOperate_110 = plcInit.getPlcOperate_110(); - if (plcOperate_110 ==null){ + if (plcOperate_110 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcOperate_110, conn, conn.getPointTables()); - doDevStatus(plcOperate_110,"6"); + doDevStatus(plcOperate_110, "6"); } } // if(conn.getPlcIp().contains(".41")){ @@ -219,7 +220,7 @@ public class PlcEventTask { } } - @Scheduled(fixedRate = 200) + // @Scheduled(fixedRate = 200) public void init1() { //查询需要连接的PLC,初始化连接对象 List plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1")); @@ -227,9 +228,9 @@ public class PlcEventTask { return; } for (WcsPlcConnectVo conn : plcList) { - if ("2".equals(conn.getDevType()) && conn.getPlcIp().contains(".41")){ + if ("2".equals(conn.getDevType()) && conn.getPlcIp().contains(".41")) { PlcOperate plcOperate_41 = plcInit.getPlcOperate_41(); - if (plcOperate_41 ==null){ + if (plcOperate_41 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcInit.getPlcOperate_41(), conn, conn.getPointTables()); @@ -237,7 +238,7 @@ public class PlcEventTask { } } - @Scheduled(fixedRate = 200) + // @Scheduled(fixedRate = 200) public void init2() { //查询需要连接的PLC,初始化连接对象 List plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1")); @@ -245,9 +246,9 @@ public class PlcEventTask { return; } for (WcsPlcConnectVo conn : plcList) { - if ("3".equals(conn.getDevType()) && conn.getPlcIp().contains(".50")){ + if ("3".equals(conn.getDevType()) && conn.getPlcIp().contains(".50")) { PlcOperate plcOperate_50 = plcInit.getPlcOperate_50(); - if (plcOperate_50 ==null){ + if (plcOperate_50 == null) { plcInit.connect(conn.getPlcIp()); } plcTask(plcOperate_50, conn, conn.getPointTables()); @@ -255,14 +256,14 @@ public class PlcEventTask { } } - @Scheduled(fixedDelay = 6000) - public void writePlcheartbeat(){ + // @Scheduled(fixedDelay = 6000) + public void writePlcheartbeat() { //根据连接的plcId获取属性 PlcOperate plcOperate = plcInit.getPlcOperate_41(); PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); - Map readPointMap = new HashMap<>(); - String heartbeat="DB320.2.0"; - readPointMap.put(heartbeat,"Boolean"); + Map readPointMap = new HashMap<>(); + String heartbeat = "DB320.2.0"; + readPointMap.put(heartbeat, "Boolean"); Map pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(readPointMap)); //读取心跳,并判断是写入true还是false; @@ -277,14 +278,13 @@ public class PlcEventTask { Map allHbMap = new HashMap<>(1); allHbMap.put(heartbeat, writeHbMap); Boolean heartType = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allHbMap)); - if(!heartType){ + if (!heartType) { log.info("心跳写入失败,重连服务器"); plcInit.connect(null); } } - public void plcTask(PlcOperate plcOperate, WcsPlcConnectVo conn, String pointTables) { LocalTime start = LocalTime.now(); try { @@ -301,7 +301,7 @@ public class PlcEventTask { PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); Map pointMap = plcReadAndWrite.readPlcData(plcOperate, pointTables); //读取数据失败时,进行重连 - if (ObjectUtils.isEmpty(pointMap)){ + if (ObjectUtils.isEmpty(pointMap)) { plcInit.connect(conn.getPlcIp()); return; } @@ -322,16 +322,16 @@ public class PlcEventTask { String hbValueType = ""; String autoAddress = ""; - String writeopen=""; - String writeopenType=""; - String writopenRelPoint=""; + String writeopen = ""; + String writeopenType = ""; + String writopenRelPoint = ""; String startPointno = isysParameterService.selectConfigByKey(branchId, ParameterConstants.ParameterSystem.putout_point); BasePointDeviceQueryBo pointQueryBoup = new BasePointDeviceQueryBo(); pointQueryBoup.setGroupNo(startPointno); BasePointDeviceVo pointDevice = basePointDeviceMapper.selectBasePointByGroupno(pointQueryBoup); - String startPoint=pointDevice.getPointNo(); + String startPoint = pointDevice.getPointNo(); for (WcsPlcProperty wcsPlcProperty : propertyList) { //产品到达出入口请求AGV @@ -347,29 +347,29 @@ public class PlcEventTask { hbValueType = wcsPlcProperty.getValueType(); } else if (wcsPlcProperty.getPointType().equals("10")) { autoAddress = wcsPlcProperty.getAddress(); - }else if (wcsPlcProperty.getPointType().equals("1")){ + } else if (wcsPlcProperty.getPointType().equals("1")) { //是否放行 - writeopen= wcsPlcProperty.getAddress(); - writeopenType= wcsPlcProperty.getValueType(); - writopenRelPoint=wcsPlcProperty.getRelPoint(); + writeopen = wcsPlcProperty.getAddress(); + writeopenType = wcsPlcProperty.getValueType(); + writopenRelPoint = wcsPlcProperty.getRelPoint(); } } - if (redisTemplate.opsForValue().get("PLCAuto")==null){ - redisTemplate.opsForValue().set("PLCAuto",true); + if (redisTemplate.opsForValue().get("PLCAuto") == null) { + redisTemplate.opsForValue().set("PLCAuto", true); } - redisTemplate.opsForValue().set("PLCAuto",true); + redisTemplate.opsForValue().set("PLCAuto", true); - if (pointMap.containsKey(writeopen) && Boolean.valueOf(pointMap.get(writeopen).toString())){ + if (pointMap.containsKey(writeopen) && Boolean.valueOf(pointMap.get(writeopen).toString())) { Map map = new HashMap(); - map.put("posId",writopenRelPoint); + map.put("posId", writopenRelPoint); //rcsUtil.openRun(map); } // 电柜状态是否是自动,如果是自动则继续流程 if (ObjectUtils.isNotEmpty(pointMap) && Boolean.valueOf(pointMap.get(autoAddress).toString())) { - redisTemplate.opsForValue().set("PLCAuto",true); + redisTemplate.opsForValue().set("PLCAuto", true); if (pointMap.containsKey(readAddress) && Boolean.valueOf(pointMap.get(readAddress).toString())) { //读取条码治具点位内容 String firstBarcode = pointMap.get(firstBarAddress).toString().trim(); @@ -377,10 +377,10 @@ public class PlcEventTask { String thirdBarcode = pointMap.get(thirdBarAddress).toString().trim(); String containerCode = pointMap.get(containerCodeAddress).toString().trim(); // containerCode=containerCode.substring(0,containerCode.length()-1); - log.info("治具编号"+containerCode +"first:"+firstBarcode+"second:"+secondBarcode+"third:"+thirdBarcode); + log.info("治具编号" + containerCode + "first:" + firstBarcode + "second:" + secondBarcode + "third:" + thirdBarcode); //连续读到相同治具编号时不生成新任务 String redisContainerCode = redisTemplate.opsForValue().get("autoTask").toString(); - if (redisContainerCode.equals(containerCode)){ + if (redisContainerCode.equals(containerCode)) { return; } @@ -395,10 +395,10 @@ public class PlcEventTask { mhbo.setFirstBarcode(firstBarcode); mhbo.setSecondBarcode(secondBarcode); mhbo.setThirdBarcode(thirdBarcode); - BaseContainer one= new BaseContainer(); - if(containerCode.equals("ERROR")){ + BaseContainer one = new BaseContainer(); + if (containerCode.equals("ERROR")) { one.setId(0L); - }else { + } else { one = iBaseContainerService.getOne(new LambdaQueryWrapper() .eq(BaseContainer::getContainerCode, containerCode)); } @@ -417,11 +417,11 @@ public class PlcEventTask { Map allMap = new HashMap<>(1); allMap.put(writeTaskId, writeMap); Boolean execWrite = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); - log.info("写入机械手输送线任务号"+taskId+"写入地址"+writeTaskId+"是否成功"+execWrite); - log.info("生成新任务:"+ taskId + "治具编号:"+ containerCode); - scheduledTasks.inTask(taskId,one.getId()); - if (ObjectUtils.isNotEmpty(taskId)){ - redisTemplate.opsForValue().set("autoTask",containerCode); + log.info("写入机械手输送线任务号" + taskId + "写入地址" + writeTaskId + "是否成功" + execWrite); + log.info("生成新任务:" + taskId + "治具编号:" + containerCode); + scheduledTasks.inTask(taskId, one.getId()); + if (ObjectUtils.isNotEmpty(taskId)) { + redisTemplate.opsForValue().set("autoTask", containerCode); } } } @@ -462,10 +462,10 @@ public class PlcEventTask { for (WcsPlcProperty plcProperty : propertyList) { String tunnel = plcProperty.getTunnel(); //第一巷道 - if ("01".equals(tunnel) ) { + if ("01".equals(tunnel)) { dpsTask(plcProperty, pointMap); } else if ("02".equals(tunnel)) { - if (plcProperty.getPlcId()==680){ + if (plcProperty.getPlcId() == 680) { log.info("11111111111"); } dpsTask(plcProperty, pointMap); @@ -477,8 +477,7 @@ public class PlcEventTask { dpsTask(plcProperty, pointMap); } else if ("06".equals(tunnel)) { dpsTask(plcProperty, pointMap); - } - else if("99".equals(tunnel)){ + } else if ("99".equals(tunnel)) { dpsTask(plcProperty, pointMap); } } @@ -489,7 +488,7 @@ public class PlcEventTask { String readTaskPoint = null; String readfinishPoint = null; //处理状态是否完成,完成时改为true;把堆垛机状态清零 - Boolean checkValue=false; + Boolean checkValue = false; int readValue = 0; for (WcsPlcProperty wcsPlcProperty : propertyList) { @@ -498,10 +497,10 @@ public class PlcEventTask { } else if (wcsPlcProperty.getPointType().equals("111")) { readTaskPoint = wcsPlcProperty.getAddress(); } else if (wcsPlcProperty.getPointType().contains("35") || wcsPlcProperty.getPointType().contains("36") - || wcsPlcProperty.getPointType().contains("37") || wcsPlcProperty.getPointType().contains("42") - || wcsPlcProperty.getPointType().contains("43") || wcsPlcProperty.getPointType().contains("44")) { - if(pointMap.containsKey(wcsPlcProperty.getAddress())){ - redisTemplate.opsForValue().set(wcsPlcProperty.getPointType(),Integer.valueOf((String) pointMap.get(wcsPlcProperty.getAddress()))); + || wcsPlcProperty.getPointType().contains("37") || wcsPlcProperty.getPointType().contains("42") + || wcsPlcProperty.getPointType().contains("43") || wcsPlcProperty.getPointType().contains("44")) { + if (pointMap.containsKey(wcsPlcProperty.getAddress())) { + redisTemplate.opsForValue().set(wcsPlcProperty.getPointType(), Integer.valueOf((String) pointMap.get(wcsPlcProperty.getAddress()))); } } } @@ -511,26 +510,28 @@ public class PlcEventTask { if (pointMap.containsKey(readTaskPoint)) { taskId = Long.valueOf((String) pointMap.get(readTaskPoint)); } - Long redisTaskId=0L; - if(redisTemplate.opsForValue().get(RedisConstant.redisSTKWare + taskId)!=null){ + Long redisTaskId = 0L; + if (redisTemplate.opsForValue().get(RedisConstant.redisSTKWare + taskId) != null) { Object temp = redisTemplate.opsForValue().get(RedisConstant.redisSTKWare + taskId); - redisTaskId= ObjectUtils.isNotEmpty(temp) ? Long.valueOf(temp.toString()) : 0L; + redisTaskId = ObjectUtils.isNotEmpty(temp) ? Long.valueOf(temp.toString()) : 0L; } String tunnel = ""; //判断redis中是否已有此任务号,如果有则不再执行; - if (taskId !=0 && !redisTaskId.equals(taskId) && readValue == 1) { - log.info("堆垛机完成信号:"+readValue+" 对应的任务号:"+taskId + "开始处理库存"); + if (taskId != 0 && !redisTaskId.equals(taskId) && readValue == 1) { + log.info("堆垛机完成信号:" + readValue + " 对应的任务号:" + taskId + "开始处理库存"); //调用入库完成库存逻辑接口 BusinDataTask businDataTaskServiceById = iBusinDataTaskService.getById(taskId); tunnel = businDataTaskServiceById.getTunnel(); String taskType = businDataTaskServiceById.getTaskType(); - if (!taskType.equals("4") && !taskType.equals("5") && !taskType.equals("15") && !taskType.equals("16")&& !taskType.equals("21")) { + if (!taskType.equals("4") && !taskType.equals("5") && !taskType.equals("15") + && !taskType.equals("16") && !taskType.equals("21") && !taskType.equals("9")) { + //增加库存 Result booleanResult = iPutInOutStorageService.productDeposit(taskId); //处理成功 返回状态,写入状态位为0 if (booleanResult.getCode() == HttpStatus.SUCCESS) { - checkValue=true; + checkValue = true; } - } else if(taskType.equals(TaskTypeEnum.seat_adjustment.getValue())){ + } else if (taskType.equals(TaskTypeEnum.seat_adjustment.getValue())) { // 处理货位调整的库存 BaseLocationQueryBo bo = new BaseLocationQueryBo(); bo.setLocationRow(businDataTaskServiceById.getFromRow()); @@ -551,7 +552,7 @@ public class PlcEventTask { baseLocation.setLocationStatus("0"); baseLocation.setUpdateTime(DateUtils.getNowDate()); boolean oldbool = iBaseLocationService.updateById(baseLocation); - log.info("更新旧的货位状态:"+oldbool); + log.info("更新旧的货位状态:" + oldbool); BaseLocationVo baseLocationVoNew = BaseLocationVoListNew.get(0); BaseLocation baseLocationNew = BeanUtil.toBean(baseLocationVoNew, BaseLocation.class); @@ -559,25 +560,26 @@ public class PlcEventTask { baseLocationNew.setLocationStatus(baseLocationVo.getLocationStatus()); baseLocationNew.setUpdateTime(DateUtils.getNowDate()); boolean newbool = iBaseLocationService.updateById(baseLocationNew); - log.info("更新新的货位状态:"+newbool); - boolean changeType = iBusinDataTaskDetailService.updateInfoByLocationCode(BaseLocationVoListOld.get(0).getId(),BaseLocationVoListNew.get(0).getId()) > 0; - if(changeType){ - checkValue=true; + log.info("更新新的货位状态:" + newbool); + boolean changeType = iBusinDataTaskDetailService.updateInfoByLocationCode(BaseLocationVoListOld.get(0).getId(), BaseLocationVoListNew.get(0).getId()) > 0; + if (changeType) { + checkValue = true; } } else if (TaskTypeEnum.normal_out.getValue().equals(taskType) || TaskTypeEnum.urgent_out.getValue().equals(taskType) - ||TaskTypeEnum.abnormal_delivery.getValue().equals(taskType) - || "21".equals(taskType) - || TaskTypeEnum.replenish_out.getValue().equals(taskType)){ + || TaskTypeEnum.abnormal_delivery.getValue().equals(taskType) + || TaskTypeEnum.punching_out.getValue().equals(taskType) + || TaskTypeEnum.replenish_out.getValue().equals(taskType) + || TaskTypeEnum.named_loc.getValue().equals(taskType)) { //处理 4正常出库 5紧急出库 17异常出库 21冲孔出库 10补货出库 库存 - log.info("扣减库存的任务类型:"+taskType); + log.info("扣减库存的任务类型:" + taskType); Boolean delStock = iBusinPickupService.subtractStockDetailByLocation(businDataTaskServiceById); - log.info("扣减库存的结果:"+delStock); - if (delStock){ - checkValue=true; + log.info("扣减库存的结果:" + delStock); + if (delStock) { + checkValue = true; } } else { - if (taskType.equals(TaskTypeEnum.emptyContainer_out.getValue())){ + if (taskType.equals(TaskTypeEnum.emptyContainer_out.getValue())) { //处理 15空治具出库 库存 BusinDpscontainerRecord oneByTask = businDpsContainerRecordMapper.selectByTaskid(String.valueOf(taskId)); oneByTask.setIsState("1"); @@ -596,14 +598,14 @@ public class PlcEventTask { //请求成功,记录已下发 redisTemplate.opsForValue().set(RedisConstant.redisSTKWare + taskId, taskId); } - checkValue=true; + checkValue = true; } - }else{ - log.info("任务命令已下发,任务号:"+taskId); + } else { + log.info("任务命令已下发,任务号:" + taskId); } - if (checkValue){ - log.info("堆垛机完成的任务号:"+taskId); + if (checkValue) { + log.info("堆垛机完成的任务号:" + taskId); Map writeMap = new HashMap<>(1); writeMap.put("SHORT", 0); Map allMap = new HashMap<>(1); @@ -612,7 +614,7 @@ public class PlcEventTask { //请求成功,记录已下发 redisTemplate.opsForValue().set(RedisConstant.redisSTKWare + taskId, taskId); } - redisTemplate.opsForValue().set("stackerLock:"+tunnel, "false"); + redisTemplate.opsForValue().set("stackerLock:" + tunnel, "false"); } break; case "4": @@ -637,44 +639,44 @@ public class PlcEventTask { //获取治具编号 BusinDataTask businDataTask = iBusinDataTaskService.getById(taskId); //出库组装区接驳点位 TODO - String fromPoint =""; - iBusinEnptyContainerService.emptyContainerFlowDir(fromPoint,businDataTask.getContainerId(),"",null); - break; - default: - log.error("无匹配的设备类型"); + String fromPoint = ""; + iBusinEnptyContainerService.emptyContainerFlowDir(fromPoint, businDataTask.getContainerId(), "", null); break; case "5": - String arriveAddres=""; - String arrivepoint=""; + String arriveAddres = ""; + String arrivepoint = ""; //出库位置按钮合 for (WcsPlcProperty wcsPlcProperty : propertyList) { - if (wcsPlcProperty.getPointType().equals("10")){ - arriveAddres=wcsPlcProperty.getAddress(); - arrivepoint=wcsPlcProperty.getRelPoint(); + if (wcsPlcProperty.getPointType().equals("10")) { + arriveAddres = wcsPlcProperty.getAddress(); + arrivepoint = wcsPlcProperty.getRelPoint(); } } - if (pointMap.containsKey(arriveAddres)&&Boolean.valueOf(pointMap.get(arriveAddres).toString())){ + if (pointMap.containsKey(arriveAddres) && Boolean.valueOf(pointMap.get(arriveAddres).toString())) { //查询对应出库点位已完成的任务 BusinDataTask businTask = iBusinDataTaskService.getOne(new LambdaQueryWrapper() .eq(BusinDataTask::getTaskPath, arriveAddres) .eq(BusinDataTask::getTaskStatus, "2")); - if(ObjectUtils.isNotEmpty(businTask)) { - //出库完成减去库存出库组装区接驳点位 - Result resultboolean = iPutInOutStorageService.reduceInventory(businTask.getId()); - //将货位状态改为0既货位为空 - BaseLocation baseLocation = iBaseLocationService.getById(businTask.getLocationId()); - baseLocation.setLocationStatus("0"); - iBaseLocationService.updateById(baseLocation); - iBusinEnptyContainerService.emptyContainerFlowDir(businTask.getTaskPath(), businTask.getContainerId(), businTask.getAgvNo(),null); - } + if (ObjectUtils.isNotEmpty(businTask)) { + //出库完成减去库存出库组装区接驳点位 + Result resultboolean = iPutInOutStorageService.reduceInventory(businTask.getId()); + //将货位状态改为0既货位为空 + BaseLocation baseLocation = iBaseLocationService.getById(businTask.getLocationId()); + baseLocation.setLocationStatus("0"); + iBaseLocationService.updateById(baseLocation); + iBusinEnptyContainerService.emptyContainerFlowDir(businTask.getTaskPath(), businTask.getContainerId(), businTask.getAgvNo(), null); + } } break; + default: + log.error("无匹配的设备类型"); + break; } LocalTime end = LocalTime.now(); Duration between = Duration.between(start, end); - long seconds = between.getSeconds()% 60; - log.info("执行plctask用时:"+seconds); + long seconds = between.getSeconds() % 60; + log.info("执行plctask用时:" + seconds); } catch (Exception e) { e.printStackTrace(); @@ -683,8 +685,14 @@ public class PlcEventTask { } + /** + * 立库输送线业务信息 + * + * @param plcProperty + * @param pointMap + */ public void dpsTask(WcsPlcProperty plcProperty, Map pointMap) { - Long stkPlcId=0L; + Long stkPlcId = 0L; //有料请求接料 String requestPoint = null; String requestTaskId = null; @@ -700,27 +708,27 @@ public class PlcEventTask { String requestPutTaskIdTwo = null; // 立库输送线放货完成后删除货位 - String performAddress=null; - String performrelPoint=null; + String performAddress = null; + String performrelPoint = null; - String Overonaddress=""; + String Overonaddress = ""; String taskIdPoint = ""; Long relDev = null; //前杠正常放行 - String frontPoint =""; - String frontPointValueType =""; + String frontPoint = ""; + String frontPointValueType = ""; //后杠正常放行 - String afterPoint=""; - String afterPointValueType=""; + String afterPoint = ""; + String afterPointValueType = ""; String pointType = plcProperty.getPointType(); //有料请求接料 if (PlcPropertyEnum.five.getValue().equals(pointType)) { requestPoint = plcProperty.getAddress(); - requestPointTwe=plcProperty.getRelPoint(); + requestPointTwe = plcProperty.getRelPoint(); } //请求接料任务ID即出库任务ID if (PlcPropertyEnum.twentytwo.getValue().equals(pointType)) { @@ -738,20 +746,20 @@ public class PlcEventTask { requestPutTaskIdTwo = plcProperty.getRelPoint(); } //放料完成,删除对应点位货架(one是是否允许放货) - if (PlcPropertyEnum.one.getValue().equals(pointType)){ + if (PlcPropertyEnum.one.getValue().equals(pointType)) { performAddress = plcProperty.getAddress(); performrelPoint = plcProperty.getRelPoint(); } //前杠正常放行 - if("23".equals(pointType)){ - frontPoint=plcProperty.getAddress(); - frontPointValueType=plcProperty.getValueType(); + if ("23".equals(pointType)) { + frontPoint = plcProperty.getAddress(); + frontPointValueType = plcProperty.getValueType(); } //后杠正常放行 - if("25".equals(pointType)){ - afterPoint=plcProperty.getAddress(); - afterPointValueType=plcProperty.getValueType(); + if ("25".equals(pointType)) { + afterPoint = plcProperty.getAddress(); + afterPointValueType = plcProperty.getValueType(); } //立库输送线允许放货后删除货架 @@ -764,64 +772,64 @@ public class PlcEventTask { // rcsUtil.openRun(map); // } - Long taskId=0L; + Long taskId = 0L; //有料请求接料,给AGV下发搬运任务 if (pointMap.containsKey(requestPoint) && Boolean.valueOf(String.valueOf(pointMap.get(requestPoint)))) { - log.error("有料请求接料,接收到PLC出库信号!"); - relDev =Long.valueOf(plcProperty.getRelDev()); + log.info("有料请求接料,接收到PLC出库信号!"); + relDev = Long.valueOf(plcProperty.getRelDev()); //根据设备ID获取设备对应的巷道信息,及设备关联的点位; BasePointQueryBo queryBo = new BasePointQueryBo(); queryBo.setDevCode(relDev); BasePointVo basePointVo = iBasePointService.selectBasePointByQuery(queryBo); - log.error("关联设备对应点位:"+basePointVo.getPointNo()); - if (basePointVo ==null){ + log.info("关联设备对应点位:" + basePointVo.getPointNo()); + if (basePointVo == null) { return; } //到达组装线等待上报点进行的业务处理 String reportPointGroup = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.report_point); BasePointDeviceQueryBo pointReportQueryBo = new BasePointDeviceQueryBo(); - String reportPoint =""; + String reportPoint = ""; pointReportQueryBo.setGroupNo(reportPointGroup); BasePointDeviceVo reportPointDeviceOut = basePointDeviceMapper.selectBasePointByGroupno(pointReportQueryBo); - if(ObjectUtils.isEmpty(reportPointDeviceOut)){ + if (ObjectUtils.isEmpty(reportPointDeviceOut)) { log.error("请维护组装线上报点"); return; } reportPoint = reportPointDeviceOut.getPointNo(); - if (requestPointTwe!=null){ - taskId = Long.valueOf((String) pointMap.get(requestPointTwe)) ; + if (requestPointTwe != null) { + taskId = Long.valueOf((String) pointMap.get(requestPointTwe)); } //从redis中验证是否已经下发任务 - BusinDataTask redisTask = (BusinDataTask)redisTemplate.opsForValue().get(RedisConstant.redisReqMate + taskId); - if(redisTask != null){ + BusinDataTask redisTask = (BusinDataTask) redisTemplate.opsForValue().get(RedisConstant.redisReqMate + taskId); + if (redisTask != null) { return; } - log.info("立库输送线读取的任务号:"+taskId); - if (taskId!=null&&taskId !=0) { + log.info("立库输送线读取的任务号:" + taskId); + if (taskId != null && taskId != 0) { //获取任务信息 BusinDataTask businDataTask = iBusinDataTaskService.getById(taskId); - if (businDataTask == null){ - log.info("当前任务号未查询到任务信息:"+taskId); + if (businDataTask == null) { + log.info("当前任务号未查询到任务信息:" + taskId); return; } //AGV节点信息 List agvPoints = new ArrayList<>(); - Map snPointMap = new HashMap<>(3); + Map snPointMap = new HashMap<>(3); int agvTaskType = 0; agvPoints.add(basePointVo.getPointNo()); agvPoints.add(basePointVo.getHandshakePoint()); - snPointMap.put("1",basePointVo.getPointNo()); - snPointMap.put("2",basePointVo.getHandshakePoint()); + snPointMap.put("1", basePointVo.getPointNo()); + snPointMap.put("2", basePointVo.getHandshakePoint()); if ("4".equals(businDataTask.getTaskType()) || "5".equals(businDataTask.getTaskType())) { agvPoints.add(reportPoint); agvPoints.add(businDataTask.getTaskPath()); snPointMap.put("3", reportPoint); - snPointMap.put("4",businDataTask.getTaskPath()); - }else if (TaskTypeEnum.abnormal_delivery.getValue().equals(businDataTask.getTaskType())) { + snPointMap.put("4", businDataTask.getTaskPath()); + } else if (TaskTypeEnum.abnormal_delivery.getValue().equals(businDataTask.getTaskType())) { // TODO 人车分流相关 需要修改对应的任务类型为 33 需要添加在RCS地图上添加对应的点位 abnormal_wait_point String abnormalWaitPintGroup = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.abnormalWaitPint); BasePointDeviceQueryBo abnormalWaitPintBo = new BasePointDeviceQueryBo(); @@ -832,16 +840,18 @@ public class PlcEventTask { agvPoints.add(abnormalWaitPintDeviceVo.getPointNo()); agvPoints.add(businDataTask.getTaskPath()); - snPointMap.put("3",abnormalWaitPintDeviceVo.getPointNo()); - snPointMap.put("4",abnormalWaitPintDeviceVo.getPointNo()); - snPointMap.put("5",businDataTask.getTaskPath()); + snPointMap.put("3", abnormalWaitPintDeviceVo.getPointNo()); + snPointMap.put("4", abnormalWaitPintDeviceVo.getPointNo()); + snPointMap.put("5", businDataTask.getTaskPath()); agvTaskType = Integer.valueOf(abnormalWaitPintDeviceVo.getIsDown()); - }else{ + } else if (businDataTask.getTaskType().equals(TaskTypeEnum.relocation.getValue())) { + // TODO 跨巷道移库AGV的模板尚未提供 + } else { agvPoints.add(businDataTask.getTaskPath()); snPointMap.put("3", businDataTask.getTaskPath()); - if ("15".equals(businDataTask.getTaskType())&&"KW16".equals(businDataTask.getTaskPath())){ + if ("15".equals(businDataTask.getTaskType()) && "KW16".equals(businDataTask.getTaskPath())) { agvPoints.add("KW17"); snPointMap.put("4", "KW17"); } @@ -859,25 +869,25 @@ public class PlcEventTask { //TODO 测试注释 要打开 修改 数据库base_point_group 中 立库输送线出 对应的 is_down 为31 24 只有一个上报点位。 31 有俩上报点位 bo.setTaskType(Integer.valueOf(basePointVo.getIsDown())); - if ("15".equals(businDataTask.getTaskType())&&"KW16".equals(businDataTask.getTaskPath())){ + if ("15".equals(businDataTask.getTaskType()) && "KW16".equals(businDataTask.getTaskPath())) { bo.setTaskType(RCSTaskTypeEnum.A_TO_B_HAND_PUT1.getValue()); businDataTask.setPlcId(30L); } - if ("15".equals(businDataTask.getTaskType())&&"KW20".equals(businDataTask.getTaskPath())){ + if ("15".equals(businDataTask.getTaskType()) && "KW20".equals(businDataTask.getTaskPath())) { bo.setTaskType(RCSTaskTypeEnum.A_TO_B_NO_PUT.getValue()); // businDataTask.setPlcId(30L); } - if (("15".equals(businDataTask.getTaskType())||"5".equals(businDataTask.getTaskType()))&&"Urgent_out".equals(businDataTask.getTaskPath())){ + if (("15".equals(businDataTask.getTaskType()) || "5".equals(businDataTask.getTaskType())) && "Urgent_out".equals(businDataTask.getTaskPath())) { bo.setTaskType(24); businDataTask.setPlcId(30L); } - if (TaskTypeEnum.abnormal_delivery.getValue().equals(businDataTask.getTaskType())){ + if (TaskTypeEnum.abnormal_delivery.getValue().equals(businDataTask.getTaskType())) { bo.setTaskType(agvTaskType); businDataTask.setPlcId(30L); } if ("21".equals(businDataTask.getTaskType()) - || TaskTypeEnum.replenish_out.getValue().equals(businDataTask.getTaskType())){ + || TaskTypeEnum.replenish_out.getValue().equals(businDataTask.getTaskType())) { bo.setTaskType(24); businDataTask.setPlcId(30L); } @@ -885,11 +895,11 @@ public class PlcEventTask { //目的点位 // bo.setToLocation(businDataTask.getTaskPath()); Result booleanResult = rcsUtil.moveByAGV(bo); - if (booleanResult.getCode()== HttpStatus.SUCCESS){ + if (booleanResult.getCode() == HttpStatus.SUCCESS) { //更新任务状态 businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); businDataTask.setTaskStarttime(DateUtils.getNowDate()); - businDataTask.setIsDown(bo.getTaskType()+""); + businDataTask.setIsDown(bo.getTaskType() + ""); iBusinDataTaskService.updateById(businDataTask); redisTemplate.opsForValue().set(RedisConstant.redisReqMate + taskId, businDataTask); //扣减巷道任务数 @@ -899,102 +909,102 @@ public class PlcEventTask { } //请求入库,给堆垛机下发命令 - if(pointMap.containsKey(requestPutOne) || pointMap.containsKey(requestPutTwo)){ - if( Boolean.valueOf(String.valueOf(pointMap.get(requestPutOne))) || 0 != Integer.valueOf(String.valueOf(pointMap.get(requestPutTwo)))){ - taskId = Long.valueOf((String) pointMap.get(requestPutTwo)); - if (taskId ==0){ - taskId = Long.valueOf((String) pointMap.get(requestPutTaskIdTwo)); - } - //从redis中验证是否已经下发任务 - BusinDataTask redisTask = (BusinDataTask)redisTemplate.opsForValue().get(RedisConstant.redisReqWare + taskId); - if(redisTask != null){ - return; - } - - //获取任务ID - BusinDataTask businDataTask = iBusinDataTaskService.getById(taskId); - String toLayer = businDataTask.getToLayer(); - String toColumn = businDataTask.getToColumn(); - String toRow = businDataTask.getToRow(); - //获取堆垛机 - BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo(); - pointQueryBo.setDevType("1"); - pointQueryBo.setTunnel(businDataTask.getTunnel()); - BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointQueryBo); - stkPlcId = baseDevicePlcVo.getPlcId(); - PlcOperate stkOperate = plcInit.getPlcOperateByIp(baseDevicePlcVo.getPlcIp()); - - List propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(stkPlcId); - String plcTaskId =""; - String plcToRow =""; - String plcToColumn =""; - String plcToLayer =""; - String plcHs =""; - String plcml=""; - WcsPlcConnect plcConnect = iWcsPlcConnectService.getById(stkPlcId); - //堆垛机是否空闲 - String readNullPoint=""; - for (WcsPlcProperty stkProperty : propertyList) { - //获取要堆垛机要写入的点位 - if (stkProperty.getPointType().equals("101")) { - plcTaskId = stkProperty.getAddress(); - }else if (stkProperty.getPointType().equals("108")){ - plcToRow = stkProperty.getAddress(); - }else if (stkProperty.getPointType().equals("109")){ - plcToColumn =stkProperty.getAddress(); - }else if (stkProperty.getPointType().equals("110")){ - plcToLayer=stkProperty.getAddress(); - }else if (stkProperty.getPointType().equals("103")){ - plcHs=stkProperty.getAddress(); - }else if(stkProperty.getPointType().equals("102")){ - plcml=stkProperty.getAddress(); - }else if (stkProperty.getPointType().equals("12")){ - readNullPoint=stkProperty.getAddress(); - }else if(stkProperty.getPointType().equals("4")){ - Overonaddress= stkProperty.getAddress(); - } - } - //根据连接的plcId获取属性 - PLCReadAndWrite plcReadAndWriteD = new PLCReadAndWrite(); - Map pointDMap = plcReadAndWriteD.readPlcData(stkOperate, plcConnect.getPointTables()); - if (pointDMap.containsKey(readNullPoint)&&Boolean.valueOf(pointDMap.get(readNullPoint).toString())&&pointDMap.get(Overonaddress).equals("0")) { - //请求入库成功 给堆垛机下命令判断是否 加锁 加锁则返回 - if (ObjectUtils.isNotEmpty(redisTemplate.opsForValue().get("stackerLock:"+businDataTask.getTunnel())) - && redisTemplate.opsForValue().get("stackerLock:"+businDataTask.getTunnel()).toString().equals("true")){ - return; - }else { - redisTemplate.opsForValue().set("stackerLock:"+businDataTask.getTunnel(), "true"); - } - //给堆垛机写命令 - Map allMap = new HashMap<>(1); - Map plcTaskIdMap = new HashMap<>(1); - plcTaskIdMap.put("INTEGER", taskId); - allMap.put(plcTaskId, plcTaskIdMap); - Map plcToRowMap = new HashMap<>(1); - plcToRowMap.put("SHORT", toRow); - allMap.put(plcToRow, plcToRowMap); - Map plcToColumnMap = new HashMap<>(1); - plcToColumnMap.put("SHORT", toColumn); - allMap.put(plcToColumn, plcToColumnMap); - Map plcToLayerMap = new HashMap<>(1); - plcToLayerMap.put("SHORT", toLayer); - allMap.put(plcToLayer, plcToLayerMap); - Map plcHsMap = new HashMap<>(1); - plcHsMap.put("SHORT", 1); - allMap.put(plcHs, plcHsMap); - Map plcMLMap = new HashMap<>(1); - plcMLMap.put("Short", 1); - allMap.put(plcml, plcMLMap); - - PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); - if (plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap))) { - //请求成功,记录已下发 - redisTemplate.opsForValue().set(RedisConstant.redisReqWare + taskId, businDataTask); - } - //解锁 - //redisTemplate.opsForValue().set("stackerLock:"+taskId, "false"); - } - } + if (pointMap.containsKey(requestPutOne) || pointMap.containsKey(requestPutTwo)) { + if (Boolean.valueOf(String.valueOf(pointMap.get(requestPutOne))) || 0 != Integer.valueOf(String.valueOf(pointMap.get(requestPutTwo)))) { + taskId = Long.valueOf((String) pointMap.get(requestPutTwo)); + if (taskId == 0) { + taskId = Long.valueOf((String) pointMap.get(requestPutTaskIdTwo)); + } + //从redis中验证是否已经下发任务 + BusinDataTask redisTask = (BusinDataTask) redisTemplate.opsForValue().get(RedisConstant.redisReqWare + taskId); + if (redisTask != null) { + return; + } + + //获取任务ID + BusinDataTask businDataTask = iBusinDataTaskService.getById(taskId); + String toLayer = businDataTask.getToLayer(); + String toColumn = businDataTask.getToColumn(); + String toRow = businDataTask.getToRow(); + //获取堆垛机 + BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo(); + pointQueryBo.setDevType("1"); + pointQueryBo.setTunnel(businDataTask.getTunnel()); + BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointQueryBo); + stkPlcId = baseDevicePlcVo.getPlcId(); + PlcOperate stkOperate = plcInit.getPlcOperateByIp(baseDevicePlcVo.getPlcIp()); + + List propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(stkPlcId); + String plcTaskId = ""; + String plcToRow = ""; + String plcToColumn = ""; + String plcToLayer = ""; + String plcHs = ""; + String plcml = ""; + WcsPlcConnect plcConnect = iWcsPlcConnectService.getById(stkPlcId); + //堆垛机是否空闲 + String readNullPoint = ""; + for (WcsPlcProperty stkProperty : propertyList) { + //获取要堆垛机要写入的点位 + if (stkProperty.getPointType().equals("101")) { + plcTaskId = stkProperty.getAddress(); + } else if (stkProperty.getPointType().equals("108")) { + plcToRow = stkProperty.getAddress(); + } else if (stkProperty.getPointType().equals("109")) { + plcToColumn = stkProperty.getAddress(); + } else if (stkProperty.getPointType().equals("110")) { + plcToLayer = stkProperty.getAddress(); + } else if (stkProperty.getPointType().equals("103")) { + plcHs = stkProperty.getAddress(); + } else if (stkProperty.getPointType().equals("102")) { + plcml = stkProperty.getAddress(); + } else if (stkProperty.getPointType().equals("12")) { + readNullPoint = stkProperty.getAddress(); + } else if (stkProperty.getPointType().equals("4")) { + Overonaddress = stkProperty.getAddress(); + } + } + //根据连接的plcId获取属性 + PLCReadAndWrite plcReadAndWriteD = new PLCReadAndWrite(); + Map pointDMap = plcReadAndWriteD.readPlcData(stkOperate, plcConnect.getPointTables()); + if (pointDMap.containsKey(readNullPoint) && Boolean.valueOf(pointDMap.get(readNullPoint).toString()) && pointDMap.get(Overonaddress).equals("0")) { + //请求入库成功 给堆垛机下命令判断是否 加锁 加锁则返回 + if (ObjectUtils.isNotEmpty(redisTemplate.opsForValue().get("stackerLock:" + businDataTask.getTunnel())) + && redisTemplate.opsForValue().get("stackerLock:" + businDataTask.getTunnel()).toString().equals("true")) { + return; + } else { + redisTemplate.opsForValue().set("stackerLock:" + businDataTask.getTunnel(), "true"); + } + //给堆垛机写命令 + Map allMap = new HashMap<>(1); + Map plcTaskIdMap = new HashMap<>(1); + plcTaskIdMap.put("INTEGER", taskId); + allMap.put(plcTaskId, plcTaskIdMap); + Map plcToRowMap = new HashMap<>(1); + plcToRowMap.put("SHORT", toRow); + allMap.put(plcToRow, plcToRowMap); + Map plcToColumnMap = new HashMap<>(1); + plcToColumnMap.put("SHORT", toColumn); + allMap.put(plcToColumn, plcToColumnMap); + Map plcToLayerMap = new HashMap<>(1); + plcToLayerMap.put("SHORT", toLayer); + allMap.put(plcToLayer, plcToLayerMap); + Map plcHsMap = new HashMap<>(1); + plcHsMap.put("SHORT", 1); + allMap.put(plcHs, plcHsMap); + Map plcMLMap = new HashMap<>(1); + plcMLMap.put("Short", 1); + allMap.put(plcml, plcMLMap); + + PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); + if (plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap))) { + //请求成功,记录已下发 + redisTemplate.opsForValue().set(RedisConstant.redisReqWare + taskId, businDataTask); + } + //解锁 + //redisTemplate.opsForValue().set("stackerLock:"+taskId, "false"); + } + } } Map taskidMap = new HashMap(1); @@ -1005,19 +1015,19 @@ public class PlcEventTask { BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointQueryBo); //组装线前杠正常放行 - if(pointMap.containsKey(frontPoint) && Boolean.valueOf(String.valueOf(pointMap.get(frontPoint)))){ + if (pointMap.containsKey(frontPoint) && Boolean.valueOf(String.valueOf(pointMap.get(frontPoint)))) { log.info("组装线前杠正常放行"); - PlcOperate plcOperate= plcInit.getPlcOperateByIp(baseDevicePlcVo.getPlcIp()); + PlcOperate plcOperate = plcInit.getPlcOperateByIp(baseDevicePlcVo.getPlcIp()); TaskwriteMap.put(frontPointValueType, "False"); taskidMap.put(frontPoint, TaskwriteMap); PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); Boolean aBoolean = plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(taskidMap)); - iBusinPickupService.savePickupRecordByAssemblyLine("front"); + iBusinPickupService.savePickupRecordByAssemblyLine("front"); } //组装线后杠正常放行 //组装线现分为一个点位,暂时注释,后续打开 - if(pointMap.containsKey(afterPoint) && Boolean.valueOf(String.valueOf(pointMap.get(afterPoint)))){ + if (pointMap.containsKey(afterPoint) && Boolean.valueOf(String.valueOf(pointMap.get(afterPoint)))) { log.info("组装线后杠正常放行"); PlcOperate plcOperate = plcInit.getPlcOperateByIp(baseDevicePlcVo.getPlcIp()); TaskwriteMap.put(afterPointValueType, "False"); @@ -1028,17 +1038,17 @@ public class PlcEventTask { iBusinPickupService.savePickupRecordByAssemblyLine("after"); } - } + } - private void doDevStatus(PlcOperate plcOperate,String tunnel){ + private void doDevStatus(PlcOperate plcOperate, String tunnel) { try { - String freeOrRun ="DB20.0.2"; - String fault="DB20.4.7"; + String freeOrRun = "DB20.0.2"; + String fault = "DB20.4.7"; Map addreesMap = new HashMap(); - addreesMap.put(freeOrRun,"Boolean"); - addreesMap.put(fault,"Boolean"); + addreesMap.put(freeOrRun, "Boolean"); + addreesMap.put(fault, "Boolean"); PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); Map pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(addreesMap)); @@ -1046,36 +1056,36 @@ public class PlcEventTask { BusinPlcStatus businPlcStatus = new BusinPlcStatus(); businPlcStatus.setTunnel(tunnel); - if (pointMap.containsKey(freeOrRun)){ + if (pointMap.containsKey(freeOrRun)) { String stkFreeOrRun = pointMap.get(freeOrRun).toString(); //1空闲 0运行中 - if (stkFreeOrRun.equals("true")){ + if (stkFreeOrRun.equals("true")) { businPlcStatus.setStkFree("1"); - }else { + } else { businPlcStatus.setStkRun("1"); } } - if (pointMap.containsKey(fault)){ + if (pointMap.containsKey(fault)) { String stkFault = pointMap.get(fault).toString(); - if (stkFault.equals("true")){ + if (stkFault.equals("true")) { businPlcStatus.setStkFault("1"); - }else { + } else { businPlcStatus.setStkFault("0"); } } - redisTemplate.opsForValue().set(RedisConstant.redisStkStatus+tunnel,businPlcStatus ); + redisTemplate.opsForValue().set(RedisConstant.redisStkStatus + tunnel, businPlcStatus); - }catch (Exception e ){ - log.error("处理设备状态{}"+e.getMessage()); + } catch (Exception e) { + log.error("处理设备状态{}" + e.getMessage()); } } - // @Scheduled(cron = " 0/5 * * * * ? ") + // @Scheduled(cron = " 0/5 * * * * ? ") public void CharigingPile() { WcsPlcConnect wcsPlcConnect = iWcsPlcConnectService.getById("39"); - PlcOperate automation =plcInit.getPlcOperateByIp(wcsPlcConnect.getPlcIp()); + PlcOperate automation = plcInit.getPlcOperateByIp(wcsPlcConnect.getPlcIp()); Long plcId = wcsPlcConnect.getId(); PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); //获取所有agv的状态 @@ -1129,16 +1139,16 @@ public class PlcEventTask { } - PLCUtil plcUtil = new PLCUtil(); - String temp = plcUtil.readPlc(Address,valueType,automation,0); - if(!temp.equals(TrueValue.toString().toLowerCase())){ - Boolean write = plcReadAndWrite.execWrite(automation, JSON.toJSONString(allwriteMap)); - int i = 0; - while (!write && i < 10) { - write = plcReadAndWrite.execWrite(automation, JSON.toJSONString(allwriteMap)); - i++; + PLCUtil plcUtil = new PLCUtil(); + String temp = plcUtil.readPlc(Address, valueType, automation, 0); + if (!temp.equals(TrueValue.toString().toLowerCase())) { + Boolean write = plcReadAndWrite.execWrite(automation, JSON.toJSONString(allwriteMap)); + int i = 0; + while (!write && i < 10) { + write = plcReadAndWrite.execWrite(automation, JSON.toJSONString(allwriteMap)); + i++; + } } - } // log.error("写入充电桩充电中成功:写入点位:" + Address + " 写入点位类型为:" + valueType + " 写入值为:" + writeMap.get(valueType)); } @@ -1146,5 +1156,4 @@ public class PlcEventTask { } - } diff --git a/shkj-wms/src/main/java/com/shkj/wms/plc/PlcInit.java b/shkj-wms/src/main/java/com/shkj/wms/plc/PlcInit.java index 4c94631..e3f80f5 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/plc/PlcInit.java +++ b/shkj-wms/src/main/java/com/shkj/wms/plc/PlcInit.java @@ -42,7 +42,7 @@ public class PlcInit { RedisTemplate redisTemplate; private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); - @PostConstruct + // @PostConstruct public void init(){ log.info("初始化连接对象"); executorService.scheduleWithFixedDelay( diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java index 54eb917..9a42c35 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fasterxml.jackson.databind.ser.impl.FailingSerializer; import com.google.common.collect.Sets; +import com.shkj.common.annotation.Log; import com.shkj.common.constant.RedisConstant; import com.shkj.common.core.domain.Result; import com.shkj.common.enums.HttpStatus; @@ -68,7 +69,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl insertBusinTask(BaseContainerCallBo callBo) { String pointType = callBo.getPointType(); - String toPoint =callBo.getPointNo(); + String toPoint = callBo.getPointNo(); - if (StringUtils.isNull(toPoint) || StringUtils.isEmpty(toPoint)){ - if (pointType.equals("out")){ + if (StringUtils.isNull(toPoint) || StringUtils.isEmpty(toPoint)) { + if (pointType.equals("out")) { //获取出库异常区接驳点 @@ -147,11 +148,11 @@ public class BusinDataTaskServiceImpl extends ServiceImpl insertBusinTask(BusinDataTask businDataTask) { int randomoperands = (int) Math.round(Math.random() * 1000); - String taskCode = "T_" + DateUtils.dateTimeNow()+randomoperands; - if (businDataTask.getTaskType().isEmpty()){ + String taskCode = "T_" + DateUtils.dateTimeNow() + randomoperands; + if (businDataTask.getTaskType().isEmpty()) { businDataTask.setTaskType(TaskTypeEnum.call_container.getValue()); } businDataTask.setTaskCode(taskCode); - if (businDataTask.getTaskStatus().isEmpty()){ + if (businDataTask.getTaskStatus().isEmpty()) { businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue()); } this.save(businDataTask); @@ -205,7 +206,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl insertBusinTask(List bs) { - log.info("出库任务信息:"+JsonUtil.toJSONString(bs)); + log.info("出库任务信息:" + JsonUtil.toJSONString(bs)); List taskList = new ArrayList<>(); @@ -223,14 +224,14 @@ public class BusinDataTaskServiceImpl extends ServiceImpl baseStorageVos = iBaseStorageService.queryBaseStorageListA(baseStorageQueryListBo); for (BaseStorageVo baseStorageVo : baseStorageVos) { - if("P01".equals(baseStorageVo.getStorageCode())){ + if ("P01".equals(baseStorageVo.getStorageCode())) { proportionP01 = Integer.parseInt(baseStorageVo.getExtend1()); - }else if("P02".equals(baseStorageVo.getStorageCode())){ + } else if ("P02".equals(baseStorageVo.getStorageCode())) { proportionP02 = Integer.parseInt(baseStorageVo.getExtend1()); } } @@ -239,28 +240,27 @@ public class BusinDataTaskServiceImpl extends ServiceImpl taskGoodsList = new ArrayList<>(); BaseBarcodesOutAddBo baseBarcodesOut = bs.get(i); //回填出库队列的状态 @@ -328,9 +328,9 @@ public class BusinDataTaskServiceImpl extends ServiceImpl goodsDataList = iBaseGoodsDataService.getBaseGoodDataInByDerice(baseDerive); - log.info("查询到的前杠产品:"+JsonUtil.toJSONString(goodsDataList)); + log.info("查询到的前杠产品:" + JsonUtil.toJSONString(goodsDataList)); //查询后杠的产品 List goodsDatarearList = iBaseGoodsDataService.getBaseGoodDatarear(baseDerive); - log.info("查询到的后杠产品:"+JsonUtil.toJSONString(goodsDatarearList)); + log.info("查询到的后杠产品:" + JsonUtil.toJSONString(goodsDatarearList)); goodsDataList.addAll(goodsDatarearList); for (BaseGoodsData baseGoodsData : goodsDataList) { //根据派生信息查找物料信息,需要前杠和后杠 @@ -380,21 +380,21 @@ public class BusinDataTaskServiceImpl extends ServiceImpl assemblePointTypeAfter){ + if (assemblePointTypeBefore > assemblePointTypeAfter) { taskTemp.setTaskPath(urgencyAfter); - }else if(assemblePointTypeBefore < assemblePointTypeAfter){ + } else if (assemblePointTypeBefore < assemblePointTypeAfter) { taskTemp.setTaskPath(urgencyBefore); - }else if(assemblePointTypeBefore == assemblePointTypeAfter){ + } else if (assemblePointTypeBefore == assemblePointTypeAfter) { taskTemp.setTaskPath(urgencyBefore); } businDataTaskMapper.updateById(taskTemp); @@ -404,7 +404,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl goods = new ArrayList<>(); //判断保险杠是否是一套,如果选择的保险杠有分体,就默认是一套保险杠,下一个出库任务 - boolean isSuite=false; + boolean isSuite = false; for (BaseGoodsDervieBo bo : bos) { String isSplit = bo.getIsSplit(); - if (isSplit.equals("1")){ - isSuite=true; + if (isSplit.equals("1")) { + isSuite = true; } } //TODO 判断出库的保险杠是否有库存 @@ -429,18 +429,18 @@ public class BusinDataTaskServiceImpl extends ServiceImpl taskList = new ArrayList<>(); List taskGoodsList = new ArrayList<>(); //获取出库组装接驳点位 - String urgency= sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.urgent_out_point); + String urgency = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.urgent_out_point); - if (StringUtils.isEmpty(urgency)){ + if (StringUtils.isEmpty(urgency)) { return Result.err().msg("未设定紧急出库接驳点"); } //一套保险杠 - if (isSuite){ - int index=0; - Long taskId=0L; + if (isSuite) { + int index = 0; + Long taskId = 0L; for (BaseGoodsDervieBo bo : bos) { - if(index ==0) { + if (index == 0) { //生成作业任务 BusinDataTask task = new BusinDataTask(); String taskCode = "T" + DateUtils.dateTimeNow(); @@ -466,7 +466,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl insertBusinTask(String locationCode){ + @Transactional(rollbackFor = Exception.class) + public Result insertBusinTask(String locationCode) { /** * 1.查询当前货位是不是有库存 * 2、查询当前货位是不是双深位,如果是,则查询单深位是否有货,如果有货,则提示不可出库 @@ -516,24 +517,24 @@ public class BusinDataTaskServiceImpl extends ServiceImpl sysStockDetailVoList =null; + List sysStockDetailVoList = null; //检查货位是否是双深位 Result booleanResult = checkIsSleep(baseLocationVo); - if (!Result.isOk(booleanResult)){ + if (!Result.isOk(booleanResult)) { return booleanResult; } //确认出库的货位是否有库存信息 Result> stockListResult = iSysStockDetailService.queryByLocation(baseLocationVo.getId()); - if (Result.isOk(stockListResult)){ + if (Result.isOk(stockListResult)) { sysStockDetailVoList = stockListResult.getData(); - if (sysStockDetailVoList == null && sysStockDetailVoList.size() ==0 ){ - return Result.err().msg("此货位未查询到保险杠信息,请确认!"+locationCode); + if (sysStockDetailVoList == null && sysStockDetailVoList.size() == 0) { + return Result.err().msg("此货位未查询到保险杠信息,请确认!" + locationCode); } } @@ -544,16 +545,16 @@ public class BusinDataTaskServiceImpl extends ServiceImpl pointList = iBasePointService.list(new LambdaQueryWrapper() .in(BasePoint::getPointNo, toPoints) - .eq(BasePoint::getIsOccupy,"0") - .eq(BasePoint::getIsActive,"1") + .eq(BasePoint::getIsOccupy, "0") + .eq(BasePoint::getIsActive, "1") ); - String taskPath=""; - if (pointList !=null && pointList.size()==0){ + String taskPath = ""; + if (pointList != null && pointList.size() == 0) { return Result.err().msg("搬运码头无空闲,不可出库"); } BasePoint basePoint = pointList.get(0); - taskPath= basePoint.getPointNo(); + taskPath = basePoint.getPointNo(); //预占码头信息 basePoint.setIsOccupy("1"); iBasePointService.updateBasePoint(basePoint); @@ -562,12 +563,12 @@ public class BusinDataTaskServiceImpl extends ServiceImpl taskGoodsList = new ArrayList<>(); List sysStockDetails = new ArrayList<>(); - Long taskId=0L; + Long taskId = 0L; for (SysStockDetailVo sysStockDetailVo : sysStockDetailVoList) { - if(index ==0) { + if (index == 0) { BusinDataTask task = new BusinDataTask(); task.setTaskType(TaskTypeEnum.named_loc.getValue()); task.setPriority("2"); @@ -606,10 +607,10 @@ public class BusinDataTaskServiceImpl extends ServiceImpl detailVos = sysStockDetailMapper.getInventoryInStockByGoods(goodsNoList,barcode.getLocationCode().equals("1") ? goodsDataList1.get(0).getGoodsNo() : null); + Map detailVos = sysStockDetailMapper.getInventoryInStockByGoods(goodsNoList, barcode.getLocationCode().equals("1") ? goodsDataList1.get(0).getGoodsNo() : null); //生成待执行任务 - this.insertBusinDataTask(detailVos,bo.getStartPoint()); + this.insertBusinDataTask(detailVos, bo.getStartPoint()); } } return Result.ok(); @@ -695,12 +696,12 @@ public class BusinDataTaskServiceImpl extends ServiceImpl detailVos,String startPoint){ + public Boolean insertBusinDataTask(Map detailVos, String startPoint) { try { //生成作业任务 BusinDataTask task = new BusinDataTask(); - String taskCode = "T"+DateUtils.dateTimeNow(); + String taskCode = "T" + DateUtils.dateTimeNow(); task.setTaskCode(taskCode); task.setTaskPath(startPoint); task.setTaskType(TaskTypeEnum.replenish_out.getValue()); @@ -718,7 +719,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl selectBusinDataTask(BusinTaskQueryBo bo) { return businDataTaskMapper.selectBusinDataTask(bo); } + @Override public List selectBusinDataTask1(BusinTaskQueryBo bo) { return businDataTaskMapper.selectBusinDataTask1(bo); @@ -811,12 +814,13 @@ public class BusinDataTaskServiceImpl extends ServiceImpl goods,String id){ - log.info("要出库的保险杠信息:"+JsonUtil.toJSONString(goods)); + public synchronized BusinTaskExeBo outboundInfo_old(List goods, String id) { + log.info("要出库的保险杠信息:" + JsonUtil.toJSONString(goods)); //获取任务信息 BusinDataTask businDataTask = iBusinDataTaskService.getById(id); //如果这次是二次分配货位那么需要将原货位的状态由已分配改为有物料,将库存明细表改为原装太 @@ -838,19 +842,19 @@ public class BusinDataTaskServiceImpl extends ServiceImpl taskList = new ArrayList<>(); - BusinDataTaskGoodsVo good=goods.get(0); - log.info("要出库的保险杠编号:"+good.getGoodsNo()); + BusinDataTaskGoodsVo good = goods.get(0); + log.info("要出库的保险杠编号:" + good.getGoodsNo()); //根据物料查询所在仓库 List tunnelVo = baseLocationService.getTUunnel(good.getGoodsNo()); //log.info("查询到的保险杠所在的货位信息:"+JsonUtil.toJSONString(tunnelVo)); List tunnelall = tunnelVo.stream().map(e -> e.getTunnel()).collect(Collectors.toList()); - // log.info("查询到保险杠所在的巷道:"+JsonUtil.toJSONString(tunnelall)); + // log.info("查询到保险杠所在的巷道:"+JsonUtil.toJSONString(tunnelall)); //拿到任务数最少的巷道 - String tunnelone=this.quickSort(tunnelall); - log.info("任务数最少的巷道:"+tunnelone); + String tunnelone = this.quickSort(tunnelall); + log.info("任务数最少的巷道:" + tunnelone); List tunnelLocation = tunnelVo.stream().filter(e -> e.getTunnel().equals(tunnelone)).collect(Collectors.toList()); - // log.info("当前巷道的有库存的货位信息:"+JsonUtil.toJSONString(tunnelLocation)); - List listlocationId=new ArrayList<>(); + // log.info("当前巷道的有库存的货位信息:"+JsonUtil.toJSONString(tunnelLocation)); + List listlocationId = new ArrayList<>(); //生成出库明细 BusinTaskExeBo exeBo = new BusinTaskExeBo(); exeBo.setTaskCode(businDataTask.getId()); @@ -858,34 +862,34 @@ public class BusinDataTaskServiceImpl extends ServiceImpl() - .eq(BaseLocation::getRoute,baseLovationVO.getRoute()) - .eq(BaseLocation::getIsDeep,"1") - .eq(BaseLocation::getTunnel,baseLovationVO.getTunnel()) - .eq(BaseLocation::getAreaId,baseLovationVO.getAreaId())); - if (one!=null&&(one.getLocationStatus().equals("4")||one.getLocationStatus().equals("1")||one.getLocationStatus().equals("2"))){ + .eq(BaseLocation::getRoute, baseLovationVO.getRoute()) + .eq(BaseLocation::getIsDeep, "1") + .eq(BaseLocation::getTunnel, baseLovationVO.getTunnel()) + .eq(BaseLocation::getAreaId, baseLovationVO.getAreaId())); + if (one != null && (one.getLocationStatus().equals("4") || one.getLocationStatus().equals("1") || one.getLocationStatus().equals("2"))) { listlocationId.add(baseLovationVO.getId()); } } } - log.info("单深位有库存:"+JsonUtil.toJSONString(listlocationId)); - if (listlocationId.size()>0){ - for (int i=0;i 0) { + for (int i = 0; i < tunnelLocation.size(); i++) { + int number = i; listlocationId.stream().forEach( - e->{ - if (e.equals(tunnelLocation.get(number).getId())){ + e -> { + if (e.equals(tunnelLocation.get(number).getId())) { tunnelLocation.remove(number); } } ); } } - if(tunnelLocation.size()==0){ - log.info("没有可出货的货位了:"+good.getGoodsNo()); + if (tunnelLocation.size() == 0) { + log.info("没有可出货的货位了:" + good.getGoodsNo()); return exeBo; } @@ -900,10 +904,10 @@ public class BusinDataTaskServiceImpl extends ServiceImpl basePointDeviceVos = new ArrayList<>(); @@ -914,10 +918,8 @@ public class BusinDataTaskServiceImpl extends ServiceImpl businDataTaskGoodsList = iBusinDataTaskGoodsService.list(new LambdaQueryWrapper() - .eq(BusinDataTaskGoods::getTaskCode,id)); + .eq(BusinDataTaskGoods::getTaskCode, id)); //根据货位查询物料信息 // SysStockDetailQueryBo stockDetailQueryBo = new SysStockDetailQueryBo(); // stockDetailQueryBo.setLocationId(baseLocationVo.getId()); // stockDetailQueryBo.setQty(new BigDecimal("1")); List sysStockDetailList = iSysStockDetailService.list(new LambdaQueryWrapper() - .eq(SysStockDetail::getLocationId,baseLocationVo.getId()) - .eq(SysStockDetail::getQty,1) - .isNull(SysStockDetail::getOutQty)); + .eq(SysStockDetail::getLocationId, baseLocationVo.getId()) + .eq(SysStockDetail::getQty, 1) + .isNull(SysStockDetail::getOutQty)); // List sysStockDetailList = iSysStockDetailService.queryList(stockDetailQueryBo); // System.out.println("是否相等"+sysStockDetailList.get(0).getGoodsNo().equals(businDataTaskGoodsList.get(0).getGoodsNo())); - for (SysStockDetail stockDetail :sysStockDetailList) { + for (SysStockDetail stockDetail : sysStockDetailList) { businDataTaskGoodsList.stream().forEach( - e->{ - log.info("内部是否相等:"+e.getGoodsNo().equals(stockDetail.getGoodsNo())+"任务保险杠编码:"+e.getGoodsNo()+" 库存保险杠条码:"+stockDetail.getGoodsNo()); - if (e.getGoodsNo().equals(stockDetail.getGoodsNo())){ + e -> { + log.info("内部是否相等:" + e.getGoodsNo().equals(stockDetail.getGoodsNo()) + "任务保险杠编码:" + e.getGoodsNo() + " 库存保险杠条码:" + stockDetail.getGoodsNo()); + if (e.getGoodsNo().equals(stockDetail.getGoodsNo())) { e.setQrCode(stockDetail.getQrCode()); } } ); } - //更新任务物料明细 + //更新任务物料明细 iBusinDataTaskGoodsService.saveOrUpdateBatch(businDataTaskGoodsList); // //取待补货区上的货不满足应发任务的货物时 // if (sysStockDetailList.size()<=businDataTaskGoodsList.size()){ @@ -1006,21 +1007,21 @@ public class BusinDataTaskServiceImpl extends ServiceImpl goods,String id){ - log.info("要出库的保险杠信息:"+JsonUtil.toJSONString(goods)); + public synchronized BusinTaskExeBo outboundInfo(List goods, String id) { + log.info("要出库的保险杠信息:" + JsonUtil.toJSONString(goods)); //获取任务信息 BusinDataTask businDataTask = iBusinDataTaskService.getById(id); //如果这次是二次分配货位那么需要将原货位的状态由已分配改为有物料,将库存明细表改为原装太 @@ -1042,14 +1043,14 @@ public class BusinDataTaskServiceImpl extends ServiceImpl taskList = new ArrayList<>(); - BusinDataTaskGoodsVo good=goods.get(0); - log.info("要出库的保险杠编号:"+good.getGoodsNo()); + BusinDataTaskGoodsVo good = goods.get(0); + log.info("要出库的保险杠编号:" + good.getGoodsNo()); //根据物料查询所在仓库 // TODO: 2024/6/27 出库时查询巷道任务数最少及库存量最多的 List tunnelVo = baseLocationService.getTUunnel(good.getGoodsNo()); - if (tunnelVo !=null && tunnelVo.size()==0){ - log.info("要出库的保险杠编号:"+good.getGoodsNo()); + if (tunnelVo != null && tunnelVo.size() == 0) { + log.info("要出库的保险杠编号:" + good.getGoodsNo()); return null; } Map tunnelLocQtyDic = tunnelVo.stream().collect(Collectors.groupingBy(BaseLocationVo::getTunnel, Collectors.counting())); @@ -1058,13 +1059,13 @@ public class BusinDataTaskServiceImpl extends ServiceImplcomparingByValue().reversed()).forEachOrdered(e -> tunnelLocQtyDicSort.put(e.getKey(), e.getValue().intValue())); //log.info("查询到的保险杠所在的货位信息:"+JsonUtil.toJSONString(tunnelVo)); List tunnelall = tunnelVo.stream().map(e -> e.getTunnel()).collect(Collectors.toList()); - // log.info("查询到保险杠所在的巷道:"+JsonUtil.toJSONString(tunnelall)); + // log.info("查询到保险杠所在的巷道:"+JsonUtil.toJSONString(tunnelall)); //拿到任务数最少的巷道并且库存量是最大的 - String tunnelone=this.quickSortTaskQty(tunnelLocQtyDicSort); - log.info("任务数最少的巷道:"+tunnelone); + String tunnelone = this.quickSortTaskQty(tunnelLocQtyDicSort); + log.info("任务数最少的巷道:" + tunnelone); List tunnelLocation = tunnelVo.stream().filter(e -> e.getTunnel().equals(tunnelone)).collect(Collectors.toList()); //log.info("当前巷道的有库存的货位信息:"+JsonUtil.toJSONString(tunnelLocation)); - List listlocationId=new ArrayList<>(); + List listlocationId = new ArrayList<>(); //生成出库明细 BusinTaskExeBo exeBo = new BusinTaskExeBo(); exeBo.setTaskCode(businDataTask.getId()); @@ -1072,34 +1073,34 @@ public class BusinDataTaskServiceImpl extends ServiceImpl() - .eq(BaseLocation::getRoute,baseLovationVO.getRoute()) - .eq(BaseLocation::getIsDeep,"1") - .eq(BaseLocation::getTunnel,baseLovationVO.getTunnel()) - .eq(BaseLocation::getAreaId,baseLovationVO.getAreaId())); - if (one!=null&&(one.getLocationStatus().equals("4")||one.getLocationStatus().equals("1")||one.getLocationStatus().equals("2"))){ + .eq(BaseLocation::getRoute, baseLovationVO.getRoute()) + .eq(BaseLocation::getIsDeep, "1") + .eq(BaseLocation::getTunnel, baseLovationVO.getTunnel()) + .eq(BaseLocation::getAreaId, baseLovationVO.getAreaId())); + if (one != null && (one.getLocationStatus().equals("4") || one.getLocationStatus().equals("1") || one.getLocationStatus().equals("2"))) { listlocationId.add(baseLovationVO.getId()); } } } - log.info("单深位有库存:"+JsonUtil.toJSONString(listlocationId)); - if (listlocationId.size()>0){ - for (int i=0;i 0) { + for (int i = 0; i < tunnelLocation.size(); i++) { + int number = i; listlocationId.stream().forEach( - e->{ - if (e.equals(tunnelLocation.get(number).getId())){ + e -> { + if (e.equals(tunnelLocation.get(number).getId())) { tunnelLocation.remove(number); } } ); } } - if(tunnelLocation.size()==0){ - log.error("没有可出货的货位了:"+good.getGoodsNo()); + if (tunnelLocation.size() == 0) { + log.error("没有可出货的货位了:" + good.getGoodsNo()); return exeBo; } @@ -1115,9 +1116,9 @@ public class BusinDataTaskServiceImpl extends ServiceImpl basePointDeviceVos = new ArrayList<>(); @@ -1128,7 +1129,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl businDataTaskGoodsList = iBusinDataTaskGoodsService.list(new LambdaQueryWrapper() - .eq(BusinDataTaskGoods::getTaskCode,id)); + .eq(BusinDataTaskGoods::getTaskCode, id)); //根据货位查询物料信息 // SysStockDetailQueryBo stockDetailQueryBo = new SysStockDetailQueryBo(); // stockDetailQueryBo.setLocationId(baseLocationVo.getId()); // stockDetailQueryBo.setQty(new BigDecimal("1")); List sysStockDetailList = iSysStockDetailService.list(new LambdaQueryWrapper() - .eq(SysStockDetail::getLocationId,baseLocationVo.getId()) - .eq(SysStockDetail::getQty,1) + .eq(SysStockDetail::getLocationId, baseLocationVo.getId()) + .eq(SysStockDetail::getQty, 1) .isNull(SysStockDetail::getOutQty)); // List sysStockDetailList = iSysStockDetailService.queryList(stockDetailQueryBo); // System.out.println("是否相等"+sysStockDetailList.get(0).getGoodsNo().equals(businDataTaskGoodsList.get(0).getGoodsNo())); - for (SysStockDetail stockDetail :sysStockDetailList) { + for (SysStockDetail stockDetail : sysStockDetailList) { businDataTaskGoodsList.stream().forEach( - e->{ - log.info("内部是否相等:"+e.getGoodsNo().equals(stockDetail.getGoodsNo())+"任务保险杠编码:"+e.getGoodsNo()+" 库存保险杠条码:"+stockDetail.getGoodsNo()); - if (e.getGoodsNo().equals(stockDetail.getGoodsNo())){ + e -> { + log.info("内部是否相等:" + e.getGoodsNo().equals(stockDetail.getGoodsNo()) + "任务保险杠编码:" + e.getGoodsNo() + " 库存保险杠条码:" + stockDetail.getGoodsNo()); + if (e.getGoodsNo().equals(stockDetail.getGoodsNo())) { e.setQrCode(stockDetail.getQrCode()); } } @@ -1217,21 +1217,21 @@ public class BusinDataTaskServiceImpl extends ServiceImpl tunnelLocQtyDicSort){ + public String quickSortTaskQty(Map tunnelLocQtyDicSort) { List taskQtyVoList = new ArrayList<>(); - for (String tunnel:tunnelLocQtyDicSort.keySet()) { - TunnelTaskQtyVo tunnelTaskQtyVo=new TunnelTaskQtyVo(); + for (String tunnel : tunnelLocQtyDicSort.keySet()) { + TunnelTaskQtyVo tunnelTaskQtyVo = new TunnelTaskQtyVo(); Integer totalTaskNum = tunnelTaskUtil.getTotalTaskNum(tunnel, 1); Integer tunnelLocQty = tunnelLocQtyDicSort.get(tunnel); tunnelTaskQtyVo.setTunnel(tunnel); @@ -1247,24 +1247,25 @@ public class BusinDataTaskServiceImpl extends ServiceImpl tunnelall){ - String tunnel= ""; - Map tunnelmap =new HashMap<>(); + public String quickSort(List tunnelall) { + String tunnel = ""; + Map tunnelmap = new HashMap<>(); tunnelall.stream().forEach( - e->{ - tunnelmap.put(e, tunnelTaskUtil.getTotalTaskNum(e,1)); + e -> { + tunnelmap.put(e, tunnelTaskUtil.getTotalTaskNum(e, 1)); } ); List collect = tunnelmap.values().stream().sorted().collect(Collectors.toList()); - for (String key: + for (String key : tunnelmap.keySet()) { - if (tunnelmap.get(key).equals(collect.get(0))){ - tunnel=key; + if (tunnelmap.get(key).equals(collect.get(0))) { + tunnel = key; } } @@ -1279,129 +1280,137 @@ public class BusinDataTaskServiceImpl extends ServiceImpl selectOutBoundDataTask(String goods){ + public List selectOutBoundDataTask(String goods) { return businDataTaskMapper.selectOutBoundDataTask(goods); } /** * 任务管理查询页面接口 - * @param bo 页面查询条件 + * + * @param bo 页面查询条件 * @return */ @Override - public List selectTaskManagement(BusinTaskManageQueryBo bo){ + public List selectTaskManagement(BusinTaskManageQueryBo bo) { List businDataTaskManageVos = businDataTaskMapper.selectTaskManagement(bo); return businDataTaskManageVos; } /** * 任务管理--取消任务 + * * @param bo * @return */ @Override - public Result cancelTask(BusinTaskManageDistributeBo bo){ + public Result cancelTask(BusinTaskManageDistributeBo bo) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(BusinDataTask::getId, bo.getTaskId()).last("limit 1"); BusinDataTask businDataTask = getOne(wrapper); - if(!businDataTask.getTaskStatus().equals("0")){ + if (!businDataTask.getTaskStatus().equals("0")) { return Result.err().msg("此任务不可取消"); } businDataTask.setTaskStatus("3"); - return this.updateById(businDataTask)?Result.ok():Result.err(); + return this.updateById(businDataTask) ? Result.ok() : Result.err(); } /** * 任务管理--重新下发 + * * @param bo * @return */ @Override - public Result reissueTask(BusinTaskManageDistributeBo bo){ - return null; + public Result reissueTask(BusinTaskManageDistributeBo bo) { + return null; } /** * 任务管理--立即下发 + * * @param bo * @return */ @Override - public Result instantlyTask(BusinTaskManageDistributeBo bo){ + public Result instantlyTask(BusinTaskManageDistributeBo bo) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(BusinDataTask::getId, bo.getTaskId()).last("limit 1"); BusinDataTask businDataTask = getOne(wrapper); //改完为下发,走调度执行 businDataTask.setTaskStatus("0"); - return this.updateById(businDataTask)?Result.ok():Result.err(); + return this.updateById(businDataTask) ? Result.ok() : Result.err(); } /** * 提升任务的优先级 + * * @param bo * @return */ @Override - public Result elevatePriorityTask(BusinTaskManageDistributeBo bo){ + public Result elevatePriorityTask(BusinTaskManageDistributeBo bo) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(BusinDataTask::getId, bo.getTaskId()).last("limit 1"); BusinDataTask businDataTask = getOne(wrapper); - if(!businDataTask.getTaskStatus().equals("0")){ + if (!businDataTask.getTaskStatus().equals("0")) { return Result.err().msg("此任务不可提升优先级"); } //提升优先级 businDataTask.setPriority("1"); - return this.updateById(businDataTask)?Result.ok():Result.err(); + return this.updateById(businDataTask) ? Result.ok() : Result.err(); } /** * 暂停任务 + * * @param bo * @return */ @Override - public Result pauseTask(BusinTaskManageDistributeBo bo){ + public Result pauseTask(BusinTaskManageDistributeBo bo) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(BusinDataTask::getId, bo.getTaskId()).last("limit 1"); BusinDataTask businDataTask = getOne(wrapper); - if(!businDataTask.getTaskStatus().equals("0")){ + if (!businDataTask.getTaskStatus().equals("0")) { return Result.err().msg("此任务不可暂停"); } //任务暂停 businDataTask.setTaskStatus("4"); - return this.updateById(businDataTask)?Result.ok():Result.err(); + return this.updateById(businDataTask) ? Result.ok() : Result.err(); } /** * 任务启用 + * * @param bo * @return */ @Override - public Result activeTask(BusinTaskManageDistributeBo bo){ + public Result activeTask(BusinTaskManageDistributeBo bo) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(BusinDataTask::getId, bo.getTaskId()).last("limit 1"); BusinDataTask businDataTask = getOne(wrapper); - if(!businDataTask.getTaskStatus().equals("4")){ + if (!businDataTask.getTaskStatus().equals("4")) { return Result.err().msg("此任务不可启用"); } //任务暂停 businDataTask.setTaskStatus("0"); - return this.updateById(businDataTask)?Result.ok():Result.err(); + return this.updateById(businDataTask) ? Result.ok() : Result.err(); } @Override public List queryinTask() { - return this.baseMapper.queryinTask(); + return this.baseMapper.queryinTask(); } @Override @@ -1422,24 +1431,24 @@ public class BusinDataTaskServiceImpl extends ServiceImpl businDataTaskVos = businDataTaskMapper.gettaskAbnormal(point); BusinDataTaskVo businDataTaskVo = new BusinDataTaskVo(); if (businDataTaskVos.size() <= 0) { return Result.err().msg("当前点位没有车辆"); } - businDataTaskVo=businDataTaskVos.get(0); + businDataTaskVo = businDataTaskVos.get(0); Long containerId = businDataTaskVo.getContainerId(); //创建任务,任务类型异常指定agv车辆 BusinDataTask businDataTask = new BusinDataTask(); int randomOperands = (int) Math.round(Math.random() * 1000); - String taskCode = "T_" + DateUtils.dateTimeNow()+randomOperands; + String taskCode = "T_" + DateUtils.dateTimeNow() + randomOperands; businDataTask.setTaskCode(taskCode); businDataTask.setTaskStatus("0"); businDataTask.setTaskType("1"); @@ -1448,7 +1457,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl getEmergencyOutboundDtl() { - List goodsVos =(List) redisTemplate.opsForValue().get(RedisConstant.redisEmergencyOutbound); + List goodsVos = (List) redisTemplate.opsForValue().get(RedisConstant.redisEmergencyOutbound); return goodsVos; } /** * 紧急出库到达接驳口时,确认按钮 + * * @param bo * @return */ @@ -1528,26 +1539,26 @@ public class BusinDataTaskServiceImpl extends ServiceImpl oldBoGoods = bo.getOldBo().getGoods(); List newBoGoods = bo.getNewBo().getGoods(); - boolean equals =false; - if (oldBoGoods !=null && newBoGoods !=null){ + boolean equals = false; + if (oldBoGoods != null && newBoGoods != null) { equals = isEquals(oldBoGoods, newBoGoods); } BusinDataTask oldtask = iBusinDataTaskService.getById(bo.getTaskId()); //获取紧急出库接驳点点位 String fromPoint = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.urgency_out_point); BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo(); - String outPoint =""; + String outPoint = ""; pointQueryBo.setGroupNo(fromPoint); BasePointDeviceVo pointDeviceout = basePointDeviceMapper.selectBasePointByGroupno(pointQueryBo); - if (pointDeviceout==null){ + if (pointDeviceout == null) { log.error("请维护紧急出库接驳点"); } - outPoint=pointDeviceout.getPointNo(); + outPoint = pointDeviceout.getPointNo(); //true 到货和取货一样,走空治具返回流程 - if (equals){ - iBusinEnptyContainerService.emptyContainerFlowDir(outPoint, bo.getContainerId(),oldtask.getAgvNo(),null); - }else{ + if (equals) { + iBusinEnptyContainerService.emptyContainerFlowDir(outPoint, bo.getContainerId(), oldtask.getAgvNo(), null); + } else { //部分取货,获取取货后剩余的物料,走入库流程 List diffGoods = new ArrayList<>(Sets.difference(Sets.newHashSet(oldBoGoods), Sets.newHashSet(newBoGoods))); @@ -1559,22 +1570,22 @@ public class BusinDataTaskServiceImpl extends ServiceImpl newBarcodes = new ArrayList<>(); for (int i = 0; i < diffGoods.size(); i++) { int goodsI = i; - barcodeInAddBos.stream().forEach(e->{ - if (e.getGoodsNo().equals(diffGoods.get(goodsI))){ + barcodeInAddBos.stream().forEach(e -> { + if (e.getGoodsNo().equals(diffGoods.get(goodsI))) { newBarcodes.add(e); } }); } billTaskAddbo.setBarcodesList(newBarcodes); - Result taskidresult=iPutInOutStorageService.saveBillTaskIn(billTaskAddbo,null); + Result taskidresult = iPutInOutStorageService.saveBillTaskIn(billTaskAddbo, null); //下发带有agv编号的命令 TODO Long newtaskId = (Long) taskidresult.getData(); BusinDataTask newTask = iBusinDataTaskService.getById(newtaskId); - runReplenishIn(newTask,oldtask.getAgvNo()); + runReplenishIn(newTask, oldtask.getAgvNo()); } - Result booleanResult = iPutInOutStorageService.reduceInventory(taskId,newBoGoods); + Result booleanResult = iPutInOutStorageService.reduceInventory(taskId, newBoGoods); //确认完成后,从redis中删除 redisTemplate.delete(RedisConstant.redisEmergencyOutbound); @@ -1584,12 +1595,12 @@ public class BusinDataTaskServiceImpl extends ServiceImpl() - .eq(BaseContainer::getContainerCode,baseDeriveTraverseVo.getContainerId())); + .eq(BaseContainer::getContainerCode, baseDeriveTraverseVo.getContainerId())); baseDeriveTraverseVo.setContainerId(String.valueOf(baseContainer.getId())); BusinDataTask dataTask = this.getOne(new LambdaQueryWrapper() - .eq(BusinDataTask::getContainerId,baseContainer.getId()) - .eq(BusinDataTask::getTaskStatus,"1") - .eq(BusinDataTask::getTaskType,"15") + .eq(BusinDataTask::getContainerId, baseContainer.getId()) + .eq(BusinDataTask::getTaskStatus, "1") + .eq(BusinDataTask::getTaskType, "15") .orderByDesc(BusinDataTask::getUpdateTime) .last("limit 1")); String fromPoint = dataTask.getTaskPath(); @@ -1627,8 +1638,8 @@ public class BusinDataTaskServiceImpl extends ServiceImpl businDataTaskGoodsList = new ArrayList<>(); - List businDataTaskGoodsVoList =baseDeriveTraverseVo.getBusinDataTaskGoodsList(); - for (BusinDataTaskGoodsVo businDataTaskGoodsVo:businDataTaskGoodsVoList + List businDataTaskGoodsVoList = baseDeriveTraverseVo.getBusinDataTaskGoodsList(); + for (BusinDataTaskGoodsVo businDataTaskGoodsVo : businDataTaskGoodsVoList ) { BusinDataTaskGoods taskGoods = new BusinDataTaskGoods(); taskGoods.setGoodsNo(businDataTaskGoodsVo.getGoodsNo()); @@ -1645,7 +1656,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl pointDeviceout = basePointDeviceMapper.getBasePointByGroupNoList(pointQueryBo); List dbTableColumnNames = pointDeviceout.stream().map(BasePointDeviceVo::getPointNo).collect(Collectors.toList()); - String urgency= null; + String urgency = null; String urgencyBefore = null; String urgencyAfter = null; for (String str : dbTableColumnNames @@ -1669,20 +1680,20 @@ public class BusinDataTaskServiceImpl extends ServiceImpl() .eq(BaseGoodsData::getGoodsNo, businDataTaskGoodsVoList.get(0).getGoodsNo())); - if(("0").equals(baseGoodsData.getLocation())){ + if (("0").equals(baseGoodsData.getLocation())) { urgency = urgencyBefore; - }else if(("1").equals(baseGoodsData.getLocation())){ + } else if (("1").equals(baseGoodsData.getLocation())) { urgency = urgencyAfter; } - }else{ - if(assemblePointTypeBefore > assemblePointTypeAfter){ + } else { + if (assemblePointTypeBefore > assemblePointTypeAfter) { urgency = urgencyAfter; - }else if(assemblePointTypeBefore < assemblePointTypeAfter){ + } else if (assemblePointTypeBefore < assemblePointTypeAfter) { urgency = urgencyBefore; - }else if(assemblePointTypeBefore == assemblePointTypeAfter){ + } else if (assemblePointTypeBefore == assemblePointTypeAfter) { urgency = urgencyBefore; } } @@ -1696,9 +1707,9 @@ public class BusinDataTaskServiceImpl extends ServiceImpl snPointMap = new HashMap<>(); + Map snPointMap = new HashMap<>(); List idList = new ArrayList<>(); dto.setMapId(1); @@ -1711,8 +1722,8 @@ public class BusinDataTaskServiceImpl extends ServiceImpl booleanResult = rcsUtil.rcsCreateTask(dto); - if (booleanResult.getCode()== HttpStatus.SUCCESS.getCode()){ + Result booleanResult = rcsUtil.rcsCreateTask(dto); + if (booleanResult.getCode() == HttpStatus.SUCCESS.getCode()) { businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); this.updateById(businDataTask); Result billResult = iPutInOutStorageService.exeTaskPutinStorage(exeBo); //扣除库存 - List DataTaskGoodsList =baseDeriveTraverseVo.getBusinDataTaskGoodsList(); - for (BusinDataTaskGoodsVo dateTaskgoods:DataTaskGoodsList - ) { + List DataTaskGoodsList = baseDeriveTraverseVo.getBusinDataTaskGoodsList(); + for (BusinDataTaskGoodsVo dateTaskgoods : DataTaskGoodsList + ) { SysStockDetail sysStockDetail = iSysStockDetailService.getOne(new LambdaQueryWrapper() .eq(SysStockDetail::getQrCode, dateTaskgoods.getQrCode()) .eq(SysStockDetail::getQty, "1") @@ -1740,8 +1751,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl() .eq(SysStockDetail::getQrCode, qrCode) .isNull(SysStockDetail::getLocationId) - .ne(SysStockDetail::getQty,"0")); - if (ObjectUtils.isNotEmpty(sysStockDetail)){ + .ne(SysStockDetail::getQty, "0")); + if (ObjectUtils.isNotEmpty(sysStockDetail)) { //通过goodsNo拿到产品信息 BaseGoodsData baseGoodsData = iBaseGoodsDataService.getOne(new LambdaQueryWrapper() .eq(BaseGoodsData::getGoodsNo, sysStockDetail.getGoodsNo())); @@ -1765,7 +1775,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl() // .eq(BaseDerive::getColor, baseGoodsData.getColor()) // .eq(BaseDerive::getVehicheModel, baseGoodsData.getVehicheModel())); - BusinDataTaskGoodsVo businDataTaskGoodsVo =new BusinDataTaskGoodsVo(); + BusinDataTaskGoodsVo businDataTaskGoodsVo = new BusinDataTaskGoodsVo(); businDataTaskGoodsVo.setQrCode(qrCode); businDataTaskGoodsVo.setLocation(baseGoodsData.getLocation()); businDataTaskGoodsVo.setVehicheModel(baseGoodsData.getVehicheModel()); @@ -1778,27 +1788,27 @@ public class BusinDataTaskServiceImpl extends ServiceImpl points = new ArrayList<>(); - Map snPointMap = new HashMap<>(3); + Map snPointMap = new HashMap<>(3); List basePointDeviceVos = new ArrayList<>(); //点位对象 - BasePointDeviceVo basePointDeviceVo=null; + BasePointDeviceVo basePointDeviceVo = null; //库位对象 BaseLocationVo locationVo = null; // 获取待补货区域货位及巷道 暂时屏蔽,使用缓冲区 - Long outbound_point =Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.outbound_point)); + Long outbound_point = Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.outbound_point)); List baseLocationVos = baseLocationMapper.getLocationByAreaId(19L); if (baseLocationVos.size() > 0) { @@ -1809,7 +1819,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl booleanResult = callAGV(taskId, agvTaskType, points,agvno); + Result booleanResult = callAGV(taskId, agvTaskType, points, agvno); if (booleanResult.getCode() == HttpStatus.SUCCESS.getCode()) { businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); businDataTask.setTaskPath(toPointNo); - }else{ - if (redisTemplate.opsForValue().get(RedisConstant.redisAgvTaskerror+taskId)==null){ - redisTemplate.opsForValue().set(RedisConstant.redisAgvTaskerror+taskId,0); + } else { + if (redisTemplate.opsForValue().get(RedisConstant.redisAgvTaskerror + taskId) == null) { + redisTemplate.opsForValue().set(RedisConstant.redisAgvTaskerror + taskId, 0); } - Long a=Long.valueOf(String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisAgvTaskerror+taskId))); + Long a = Long.valueOf(String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisAgvTaskerror + taskId))); businDataTask.setTaskStatus(TaskStatusEnum.err.getValue()); businDataTask.setExceptionMsg(booleanResult.getMsg()); - if (a<3L){ + if (a < 3L) { long l = a + 1; - redisTemplate.opsForValue().set(RedisConstant.redisAgvTaskerror+taskId,l); - }else { + redisTemplate.opsForValue().set(RedisConstant.redisAgvTaskerror + taskId, l); + } else { businDataTask.setTaskStatus("-2"); } } @@ -1862,7 +1872,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl callAGV(Long taskId,int taskType, List points,String agvno){ + public Result callAGV(Long taskId, int taskType, List points, String agvno) { AGVMoveBo moveBo = new AGVMoveBo(); moveBo.setTaskId(taskId); moveBo.setTaskType(taskType); @@ -1875,13 +1885,14 @@ public class BusinDataTaskServiceImpl extends ServiceImpl * @return */ - public > boolean isEquals(List list1, List list2){ - if(list1.size() != list2.size()) { + public > boolean isEquals(List list1, List list2) { + if (list1.size() != list2.size()) { return false; } list1 = new ArrayList(list1); @@ -1893,7 +1904,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl addMoveTask(BusinStockMoveDAddBo bo){ + public Result addMoveTask(BusinStockMoveDAddBo bo) { /** * 1.巷道内移库 * 1.1 生成巷道内移库任务,任务类型为16 给堆垛机下发任务(货位对货位任务) @@ -1913,76 +1924,96 @@ public class BusinDataTaskServiceImpl extends ServiceImpl sysStockDetailVos = iSysStockDetailService.queryList(stockDetailQueryBo); - if (sysStockDetailVos == null && sysStockDetailVos.size()==0){ + if (sysStockDetailVos == null && sysStockDetailVos.size() == 0) { return Result.err().msg("移出货位无保险杠库存"); } - BaseLocation outBaseLocation = iBaseLocationService.getById(outLocationId); //查看是否时双深位,如果是则判断单深位是否有库存 Result booleanResult = checkIsSleep(outBaseLocation); - if (!Result.isOk(booleanResult)){ + if (!Result.isOk(booleanResult)) { return booleanResult; } // 查询移出货位是否有未完成的任务 LambdaQueryWrapper wrapper = new LambdaQueryWrapper() - .notIn(BusinDataTask::getTaskStatus, Arrays.asList("2","3")) - .in(BusinDataTask::getTaskType,Arrays.asList("9","16")) - .eq(BusinDataTask::getFromLayer,outBaseLocation.getLayer()) - .eq(BusinDataTask::getFromColumn,outBaseLocation.getLocationColumn()) - .eq(BusinDataTask::getFromRow,outBaseLocation.getLocationRow()).last("limit 1"); + .notIn(BusinDataTask::getTaskStatus, Arrays.asList("2", "3")) + .in(BusinDataTask::getTaskType, Arrays.asList("9", "16")) + .eq(BusinDataTask::getFromLayer, outBaseLocation.getLayer()) + .eq(BusinDataTask::getFromColumn, outBaseLocation.getLocationColumn()) + .eq(BusinDataTask::getFromRow, outBaseLocation.getLocationRow()).last("limit 1"); BusinDataTask businDataTask = getOne(wrapper); - if (businDataTask !=null){ + if (businDataTask != null) { return Result.err().msg("移出货位有未完成的货位移动任务,不可重复移动"); } //查询目标货位,并预占 Long inLocationId = bo.getInLocationId(); BaseLocation inBaseLocation = iBaseLocationService.getById(inLocationId); - if (inBaseLocation == null){ + if (inBaseLocation == null) { return Result.err().msg("未获取到移入货位信息"); } - if (!inBaseLocation.getLocationStatus().equals("0")){ - return Result.err().msg("移入货位已被占用:"+inBaseLocation.getLocationCode()); + if (!inBaseLocation.getLocationStatus().equals("0")) { + return Result.err().msg("移入货位已被占用:" + inBaseLocation.getLocationCode()); } inBaseLocation.setLocationStatus("4"); iBaseLocationService.updateById(inBaseLocation); - //更改货位状态未移库中,此货位不可在出库 outBaseLocation.setLocationStatus("5"); iBaseLocationService.updateById(outBaseLocation); - //生成移库任务 - int index=0; + //生成移库出库任务 + int index = 0; List taskGoodsList = new ArrayList<>(); List sysStockDetails = new ArrayList<>(); + + + String inTunnel = inBaseLocation.getTunnel(); + String outTunnel = outBaseLocation.getTunnel(); + BusinDataTask dataTaskAdd = new BusinDataTask(); + BusinDataTask dataTaskOut = new BusinDataTask(); + BusinDataTask dataTaskIn = new BusinDataTask(); + + if (!inTunnel.equals(outTunnel)) { + dataTaskOut.setTaskStatus("0"); + dataTaskOut.setBatch(DateUtils.getDate()); + dataTaskOut.setIsUrgent("0");//非紧急任务 + dataTaskOut.setIsTop("0"); + dataTaskOut.setPriority("0"); + dataTaskOut.setFromColumn(outBaseLocation.getLocationColumn()); + dataTaskOut.setFromLayer(outBaseLocation.getLayer()); + dataTaskOut.setFromRow(outBaseLocation.getLocationRow()); + dataTaskOut.setTaskType(TaskTypeEnum.relocation_out.getValue(); + + dataTaskIn.setTaskStatus("0"); + dataTaskIn.setBatch(DateUtils.getDate()); + dataTaskIn.setIsUrgent("0");//非紧急任务 + dataTaskIn.setIsTop("0"); + dataTaskIn.setPriority("0"); + dataTaskIn.setToLayer(inBaseLocation.getLayer()); + dataTaskIn.setToRow(inBaseLocation.getLocationRow()); + dataTaskIn.setToColumn(inBaseLocation.getLocationColumn()); + dataTaskIn.setTaskType(TaskTypeEnum.relocation_in.getValue()); + + } else { + dataTaskAdd.setTaskStatus("0"); + dataTaskAdd.setBatch(DateUtils.getDate()); + dataTaskAdd.setIsUrgent("0");//非紧急任务 + dataTaskAdd.setIsTop("0"); + dataTaskAdd.setPriority("0"); + dataTaskAdd.setToLayer(inBaseLocation.getLayer()); + dataTaskAdd.setToRow(inBaseLocation.getLocationRow()); + dataTaskAdd.setToColumn(inBaseLocation.getLocationColumn()); + dataTaskAdd.setTaskType(TaskTypeEnum.seat_adjustment.getValue()); + } + for (SysStockDetailVo sysStockDetailVo : sysStockDetailVos) { - Long taskId=0L; - if(index ==0) { - BusinDataTask dataTaskAdd = new BusinDataTask(); - dataTaskAdd.setTaskStatus("0"); - dataTaskAdd.setBatch(DateUtils.getDate()); - dataTaskAdd.setIsUrgent("0");//非紧急任务 - dataTaskAdd.setIsTop("0"); - dataTaskAdd.setPriority("0"); - dataTaskAdd.setFromColumn(outBaseLocation.getLocationColumn()); - dataTaskAdd.setFromLayer(outBaseLocation.getLayer()); - dataTaskAdd.setFromRow(outBaseLocation.getLocationRow()); - - String taskType =TaskTypeEnum.relocation.getValue(); - String inTunnel = inBaseLocation.getTunnel(); - if (inTunnel.equals(outBaseLocation.getTunnel())){ - taskType=TaskTypeEnum.seat_adjustment.getValue(); - dataTaskAdd.setToRow(inBaseLocation.getLocationRow()); - dataTaskAdd.setToColumn(inBaseLocation.getLocationColumn()); - dataTaskAdd.setToLayer(inBaseLocation.getLayer()); - dataTaskAdd.setTaskPath(inBaseLocation.getLocationCode()); - }else { + Long taskInId = 0L; + Long taskOutId = 0L; + if (index == 0) { + if (!inTunnel.equals(outTunnel)) { //根据巷道获取目标货位的输送线的agv接驳点 - - //移出巷道的任务 BasePointQueryBo pointQueryBo = new BasePointQueryBo(); pointQueryBo.setTunnel(inTunnel); pointQueryBo.setGroupNo("4"); @@ -1990,64 +2021,74 @@ public class BusinDataTaskServiceImpl extends ServiceImpl checkIsSleep(BaseLocation baseLocationVo){ - List sysStockDetailVoList =null; + public Result checkIsSleep(BaseLocation baseLocationVo) { + List sysStockDetailVoList = null; //查询指定出库的货位是不是双深位,如果是,则查询单深位是否有库存 - if (baseLocationVo.getIsDeep().equals("2")){ + if (baseLocationVo.getIsDeep().equals("2")) { String locationRow = baseLocationVo.getLocationRow(); String locationColumn = baseLocationVo.getLocationColumn(); String layer = baseLocationVo.getLayer(); - if (locationRow.equals("1")){ - locationRow="2"; - }else if (locationRow.equals("4")){ - locationRow="3"; - }else if (locationRow.equals("16")){ - locationRow="15"; + if (locationRow.equals("1")) { + locationRow = "2"; + } else if (locationRow.equals("4")) { + locationRow = "3"; + } else if (locationRow.equals("16")) { + locationRow = "15"; } - BaseLocation one = iBaseLocationService.getOne(new LambdaQueryWrapper() + BaseLocation one = iBaseLocationService.getOne(new LambdaQueryWrapper() .eq(BaseLocation::getLocationRow, locationRow) .eq(BaseLocation::getLocationColumn, locationColumn) .eq(BaseLocation::getLayer, layer)); Result> stockListResult = iSysStockDetailService.queryByLocation(one.getId()); - if (Result.isOk(stockListResult)){ + if (Result.isOk(stockListResult)) { sysStockDetailVoList = stockListResult.getData(); - if (sysStockDetailVoList != null && sysStockDetailVoList.size() !=0 ){ - return Result.err().msg("指定出库货位是双深位,单深位有货,不可出库"+baseLocationVo.getLocationCode()); + if (sysStockDetailVoList != null && sysStockDetailVoList.size() != 0) { + return Result.err().msg("指定出库货位是双深位,单深位有货,不可出库" + baseLocationVo.getLocationCode()); } } } diff --git a/shkj-wms/src/main/java/com/shkj/wms/third/rcs/RCSUtil.java b/shkj-wms/src/main/java/com/shkj/wms/third/rcs/RCSUtil.java index 9340cce..7dae3dd 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/third/rcs/RCSUtil.java +++ b/shkj-wms/src/main/java/com/shkj/wms/third/rcs/RCSUtil.java @@ -189,13 +189,13 @@ public class RCSUtil { * @return {@code Result} */ public synchronized Result rcsCreateTask(RcsCreateTaskDto dto) { - log.info("AGV下发任务信息:"+JsonUtil.toJSONString(dto)); - if (ObjectUtils.isNotEmpty(redisTemplate.opsForValue().get(RedisConstant.out17+dto.getTaskId()))){ - return Result.err().msg("此任务已经下发至rcs任务号:"+dto.getTaskId()); + log.info("AGV下发任务信息:" + JsonUtil.toJSONString(dto)); + if (ObjectUtils.isNotEmpty(redisTemplate.opsForValue().get(RedisConstant.out17 + dto.getTaskId()))) { + return Result.err().msg("此任务已经下发至rcs任务号:" + dto.getTaskId()); } //获取任务详细信息,下发给RCS设置行号 BusinDataTask businDataTask = iBusinDataTaskService.getById(dto.getTaskId()); - if (StringUtils.isNotEmpty(businDataTask.getToRow())){ + if (StringUtils.isNotEmpty(businDataTask.getToRow())) { dto.setStation(businDataTask.getToRow()); } String json = JSONObject.toJSONString(dto); @@ -205,10 +205,10 @@ public class RCSUtil { .addHeaders(headerMap) .body(json) .execute().body(); - log.info(dto.getTaskId() + "AGV下发任务返回结果:"+res); + log.info(dto.getTaskId() + "AGV下发任务返回结果:" + res); Result result = parseThirdRcsResult(res); - if (result.getCode() == 200){ - redisTemplate.opsForValue().set(RedisConstant.out17+dto.getTaskId(),result.toString()); + if (result.getCode() == 200) { + redisTemplate.opsForValue().set(RedisConstant.out17 + dto.getTaskId(), result.toString()); } return result; } catch (Exception e) { @@ -217,34 +217,35 @@ public class RCSUtil { return Result.err().msg(e.getMessage()); } } + /** * 更改AGV点位信息 */ - public Result removePoint(AGVUploadStatusBo bo){ - log.info("AGV更新点位信息:"+JsonUtil.toJSONString(bo)); + public Result removePoint(AGVUploadStatusBo bo) { + log.info("AGV更新点位信息:" + JsonUtil.toJSONString(bo)); BusinDataTask byId = iBusinDataTaskService.getById(bo.getTaskId()); String sn = bo.getSn(); if (ObjectUtils.isNotEmpty(byId)) { - Map map =new HashMap(); - map.put("taskId",byId.getId()); + Map map = new HashMap(); + map.put("taskId", byId.getId()); Result result = new Result(); result.setCode(0); List list = new ArrayList(); - if (StringUtils.isEmpty(byId.getNewDestination())){ + if (StringUtils.isEmpty(byId.getNewDestination())) { return Result.err(); } - if (!"1".equals(byId.getTaskStatus())){ + if (!"1".equals(byId.getTaskStatus())) { return Result.err(); } Map points = (Map) JSON.parse(byId.getPoints()); - int pointnumber= points.size(); - if (pointnumber>Integer.valueOf(sn)) { + int pointnumber = points.size(); + if (pointnumber > Integer.valueOf(sn)) { Map mapSn = new HashMap<>(); mapSn.put("sn", pointnumber); mapSn.put("id", byId.getNewDestination()); mapSn.put("action", "singleMove"); list.add(mapSn); - return result.data(list); + return result.data(list); } } return null; @@ -328,7 +329,7 @@ public class RCSUtil { RcsCreateTaskDto dto = new RcsCreateTaskDto(); dto.setMapId(1); dto.setTaskType(bo.getTaskType()); - if (StringUtils.isNotEmpty(bo.getRobotId())){ + if (StringUtils.isNotEmpty(bo.getRobotId())) { dto.setRobotId(bo.getRobotId()); } dto.setTaskId(bo.getTaskId().toString()); @@ -346,11 +347,11 @@ public class RCSUtil { // return Result.ok(); } - public Result moveByAGV(AGVMoveBo bo,String toRow) { + public Result moveByAGV(AGVMoveBo bo, String toRow) { RcsCreateTaskDto dto = new RcsCreateTaskDto(); dto.setMapId(1); dto.setTaskType(bo.getTaskType()); - if (StringUtils.isNotEmpty(bo.getRobotId())){ + if (StringUtils.isNotEmpty(bo.getRobotId())) { dto.setRobotId(bo.getRobotId()); } dto.setTaskId(bo.getTaskId().toString()); @@ -373,10 +374,9 @@ public class RCSUtil { } - public Result moveByAGVTmp(BusinTaskQueryBo bo) { //呼叫AGV - String targetPoint = isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.putin_point); + String targetPoint = isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.putin_point); String tmpPoint = isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.putout_point_tmp); String startPoint = isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.target_point); @@ -396,18 +396,18 @@ public class RCSUtil { businTaskAddBo.setTaskCode(taskCode); businTaskAddBo.setAgvNo(agvNo); - Map snPointMap = new HashMap<>(3); - snPointMap.put("1",startPoint); - snPointMap.put("2",tmpPoint); - snPointMap.put("3",tmpPoint); - snPointMap.put("4",targetPoint); + Map snPointMap = new HashMap<>(3); + snPointMap.put("1", startPoint); + snPointMap.put("2", tmpPoint); + snPointMap.put("3", tmpPoint); + snPointMap.put("4", targetPoint); //新增任务单据 businTaskAddBo.setTaskStatus("1"); businTaskAddBo.setPoints(JsonUtil.toJSONString(snPointMap)); BusinDataTask businDataTask = BeanUtil.toBean(businTaskAddBo, BusinDataTask.class); iBusinDataTaskService.insertBusinDataTask(businDataTask); - Long taskId =businDataTask.getId(); + Long taskId = businDataTask.getId(); RcsCreateTaskDto dto = new RcsCreateTaskDto(); dto.setMapId(1); dto.setTaskType(25); @@ -429,7 +429,7 @@ public class RCSUtil { idList.add(midIdTwo); idList.add(endId); dto.setTargets(idList); - return rcsCreateTask(dto); + return rcsCreateTask(dto); } /** @@ -449,10 +449,9 @@ public class RCSUtil { //获取AGV状态信息 推送前端及存储数据库及存储redis res = res.trim(); RcsThirdResult thirdResult = JSONObject.parseObject(res, RcsThirdResult.class); - if (thirdResult.getCode() == 0){ + if (thirdResult.getCode() == 0) { return Result.ok().data(thirdResult.getData()).msg(thirdResult.getComment()); - }else - { + } else { return Result.err().msg(thirdResult.getComment()); } } catch (Exception e) { @@ -510,17 +509,18 @@ public class RCSUtil { /** * 根据任务ID检查是否紧急出库 + * * @param taskId */ - public void checkEmergencyOutbound(Long taskId){ + public void checkEmergencyOutbound(Long taskId) { List businDataTaskGoodsVos = null; BusinDataTask businDataTask = businDataTaskMapper.selectById(taskId); - if (businDataTask != null){ + if (businDataTask != null) { String taskType = businDataTask.getTaskType(); //是否是紧急出库 - if(taskType.equals(TaskTypeEnum.urgent_out.getValue())){ + if (taskType.equals(TaskTypeEnum.urgent_out.getValue())) { //查询物料明细 - businDataTaskGoodsVos = businDataTaskGoodsMapper.getTaskGoodsByTaskCodeForOut(taskId); + businDataTaskGoodsVos = businDataTaskGoodsMapper.getTaskGoodsByTaskCodeForOut(taskId); } } redisTemplate.opsForValue().set(RedisConstant.redisEmergencyOutbound, businDataTaskGoodsVos); @@ -534,71 +534,73 @@ public class RCSUtil { * @return {@code Result} */ public Result uploadAgvTaskStatusTmp(AGVUploadStatusBo bo) { - log.info("AGV上报信息:"+JsonUtil.toJSONString(bo)); + log.info("AGV上报信息:" + JsonUtil.toJSONString(bo)); Long taskID = null; String[] idArr = bo.getTaskId().split("_"); - if(idArr.length > 1){ + if (idArr.length > 1) { taskID = Long.valueOf(idArr[0]); - }else{ + } else { taskID = Long.valueOf(bo.getTaskId()); } BusinDataTask businDataTask = businDataTaskMapper.selectById(taskID); - if (businDataTask == null){ - return Result.err().msg("当前任务号未找到任务信息:"+taskID); + if (businDataTask == null) { + return Result.err().msg("当前任务号未找到任务信息:" + taskID); } + + String taskType = businDataTask.getTaskType(); //log.info("AGV上报数据查询到的任务信息:" + JsonUtil.toJSONString(businDataTask)); - String tunnl=null; - tunnl=businDataTask.getTunnel(); + String tunnl = null; + tunnl = businDataTask.getTunnel(); Long plcId = businDataTask.getPlcId(); - Long DPSplcId=businDataTask.getDpsNoOne(); - if (StringUtils.isNotEmpty(tunnl)&&(plcId==null||!bo.getSn().equals("2"))&&!"15".equals(businDataTask.getTaskType())){ - plcId=DPSplcId; - } - if("15".equals(businDataTask.getTaskType())){ - if(bo.getSn().equals("2")){ + Long DPSplcId = businDataTask.getDpsNoOne(); + if (StringUtils.isNotEmpty(tunnl) && (plcId == null || !bo.getSn().equals("2")) && !"15".equals(taskType)) { + plcId = DPSplcId; + } + if ("15".equals(taskType)) { + if (bo.getSn().equals("2")) { plcId = 39L; } } - if("1".equals(businDataTask.getTaskType())){ - if(2 < Integer.parseInt(bo.getSn())){ + if ("1".equals(taskType)) { + if (2 < Integer.parseInt(bo.getSn())) { plcId = 39L; } } String points = businDataTask.getPoints(); Map agvMap = new HashMap<>(); - if(StringUtils.isNotEmpty(points)){ + if (StringUtils.isNotEmpty(points)) { agvMap = JsonUtil.JsonStrToMap(points); } - log.info("AGV的点位信息:"+agvMap.toString()); + log.info("AGV的点位信息:" + agvMap.toString()); WcsPlcConnect conn = iWcsPlcConnectService.selectWcsPlcConnectById(plcId); String readAddress = ""; String readValueType = ""; - String agvPoint=""; + String agvPoint = ""; String putAddress = ""; String putAddressVtype = ""; - String putAgvPoint =""; + String putAgvPoint = ""; - String TaskAddress=""; - String TaskddressVtype=""; - String TaskPoint=""; + String TaskAddress = ""; + String TaskddressVtype = ""; + String TaskPoint = ""; - String overAddress=""; - String overValueType=""; - String overputAgvPoint=""; + String overAddress = ""; + String overValueType = ""; + String overputAgvPoint = ""; - String waringWaitpoint=""; - String waringWaitpointType=""; + String waringWaitpoint = ""; + String waringWaitpointType = ""; Result result = new Result(); result.setCode(200); result.setResult(true); //空治具回库 - if (businDataTask.getTaskType().equals(TaskTypeEnum.emptyCon.getValue())){ + if (taskType.equals(TaskTypeEnum.emptyCon.getValue())) { BusinDataTask fontbusinDataTask = businDataTaskMapper.selectfrontById(businDataTask); if (ObjectUtils.isNotEmpty(fontbusinDataTask)) { QueryWrapper pickupQueryWrapper = new QueryWrapper<>(); @@ -606,7 +608,7 @@ public class RCSUtil { List businPickupList = businPickupMapper.selectList(pickupQueryWrapper); if (businPickupList.size() > 0) { BusinPickup businPickup = businPickupList.get(0); - log.info("空治具回库时,释放码头点位信息:"+JsonUtil.toJSONString(businPickup)); + log.info("空治具回库时,释放码头点位信息:" + JsonUtil.toJSONString(businPickup)); BasePoint basePoint = iBasePointService.selectBasePointById(Long.valueOf(businPickup.getPointNo())); basePoint.setIsActive("1"); basePoint.setIsOccupy("0"); @@ -620,56 +622,55 @@ public class RCSUtil { /** * 只针对机械手输送线和立库输送线 */ - if (wcsPlcProperty.getPointType().equals("8") ) { - if (StringUtils.isNotEmpty(tunnl)&&(wcsPlcProperty.getTunnel()).equals(tunnl)){ + if (wcsPlcProperty.getPointType().equals("8")) { + if (StringUtils.isNotEmpty(tunnl) && (wcsPlcProperty.getTunnel()).equals(tunnl)) { //放料完成点位 putAddress = wcsPlcProperty.getAddress(); putAddressVtype = wcsPlcProperty.getValueType(); - agvPoint =wcsPlcProperty.getRelPoint(); - }else if (StringUtils.isEmpty(tunnl)){ + agvPoint = wcsPlcProperty.getRelPoint(); + } else if (StringUtils.isEmpty(tunnl)) { //放料完成点位 putAddress = wcsPlcProperty.getAddress(); putAddressVtype = wcsPlcProperty.getValueType(); agvPoint = wcsPlcProperty.getRelPoint(); - }else if (businDataTask.getTaskType().equals("15")){ + } else if (taskType.equals("15")) { putAddress = wcsPlcProperty.getAddress(); putAddressVtype = wcsPlcProperty.getValueType(); - agvPoint =wcsPlcProperty.getRelPoint(); + agvPoint = wcsPlcProperty.getRelPoint(); } - } else if (wcsPlcProperty.getPointType().equals("1") ) { - if (StringUtils.isNotEmpty(tunnl)&&(wcsPlcProperty.getTunnel()).equals(tunnl)){ - //点位类型=1,是否允许放料 - readAddress = wcsPlcProperty.getAddress(); - readValueType = wcsPlcProperty.getValueType(); - putAgvPoint=wcsPlcProperty.getRelPoint(); - }else if (StringUtils.isEmpty(tunnl)){ + } else if (wcsPlcProperty.getPointType().equals("1")) { + if (StringUtils.isNotEmpty(tunnl) && (wcsPlcProperty.getTunnel()).equals(tunnl)) { + //点位类型=1,是否允许放料 + readAddress = wcsPlcProperty.getAddress(); + readValueType = wcsPlcProperty.getValueType(); + putAgvPoint = wcsPlcProperty.getRelPoint(); + } else if (StringUtils.isEmpty(tunnl)) { //点位类型=1,是否允许放料 readAddress = wcsPlcProperty.getAddress(); readValueType = wcsPlcProperty.getValueType(); - putAgvPoint=wcsPlcProperty.getRelPoint(); + putAgvPoint = wcsPlcProperty.getRelPoint(); } - }else if(wcsPlcProperty.getPointType().equals("6") && StringUtils.isNotEmpty(tunnl)&&(wcsPlcProperty.getTunnel()).equals(tunnl)){ + } else if (wcsPlcProperty.getPointType().equals("6") && StringUtils.isNotEmpty(tunnl) && (wcsPlcProperty.getTunnel()).equals(tunnl)) { //请求入库 //只针对立库输送线 - TaskAddress= wcsPlcProperty.getAddress(); - TaskddressVtype=wcsPlcProperty.getValueType(); - TaskPoint=wcsPlcProperty.getRelPoint(); - } - else if(wcsPlcProperty.getPointType().equals("7")){ - if (StringUtils.isNotEmpty(tunnl)&&(wcsPlcProperty.getTunnel()).equals(tunnl)||wcsPlcProperty.getTunnel().equals("0")){ + TaskAddress = wcsPlcProperty.getAddress(); + TaskddressVtype = wcsPlcProperty.getValueType(); + TaskPoint = wcsPlcProperty.getRelPoint(); + } else if (wcsPlcProperty.getPointType().equals("7")) { + if (StringUtils.isNotEmpty(tunnl) && (wcsPlcProperty.getTunnel()).equals(tunnl) || wcsPlcProperty.getTunnel().equals("0")) { //点位类型=7,取料完成 overAddress = wcsPlcProperty.getAddress(); overValueType = wcsPlcProperty.getValueType(); - overputAgvPoint=wcsPlcProperty.getRelPoint(); - }else if (StringUtils.isEmpty(tunnl)){ + overputAgvPoint = wcsPlcProperty.getRelPoint(); + } else if (StringUtils.isEmpty(tunnl)) { //点位类型=7,取料完成 overAddress = wcsPlcProperty.getAddress(); overValueType = wcsPlcProperty.getValueType(); - overputAgvPoint=wcsPlcProperty.getRelPoint(); + overputAgvPoint = wcsPlcProperty.getRelPoint(); } - }else if(wcsPlcProperty.getPointType().equals("wait")){ + } else if (wcsPlcProperty.getPointType().equals("wait")) { waringWaitpoint = wcsPlcProperty.getAddress(); waringWaitpointType = wcsPlcProperty.getValueType(); } @@ -700,60 +701,60 @@ public class RCSUtil { Map allWriteMap = new HashMap(2); Map overWriteMap = new HashMap(2); - log.info("overputAgvPoint:"+overputAgvPoint); + log.info("overputAgvPoint:" + overputAgvPoint); //写入agv取货完成 - if(StringUtils.isNotEmpty(overputAgvPoint)) { + if (StringUtils.isNotEmpty(overputAgvPoint)) { if (bo.getStatus().equals("completed") && overputAgvPoint.equals(taskAgvpoint)) { Map writeMap = new HashMap(1); writeMap.put(overValueType, "true"); overWriteMap.put(overAddress, writeMap); Boolean over = plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(overWriteMap)); - int i=0; - while (!over&&i<50){ + int i = 0; + while (!over && i < 50) { over = plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(overWriteMap)); i++; } - log.info("是否取货完成"+over+" 取货完成点位:"+overputAgvPoint+" 任务号:"+bo.getTaskId()+" 写入次数:"+i+" 写入点位:"+overAddress); + log.info("是否取货完成" + over + " 取货完成点位:" + overputAgvPoint + " 任务号:" + bo.getTaskId() + " 写入次数:" + i + " 写入点位:" + overAddress); if (businDataTask.getTaskPath().equals(ParameterConstants.ParameterSystem.assemble_point_before) || businDataTask.getTaskPath().equals(ParameterConstants.ParameterSystem.assemble_point_after)) { int temp = 0; String assemblePointType = RedisConstant.assemblePointBeforeTaskCount; //小组装等待点位为一个,设置等待数也只需要一个 - if(businDataTask.getTaskPath().equals(ParameterConstants.ParameterSystem.assemble_point_after)){ + if (businDataTask.getTaskPath().equals(ParameterConstants.ParameterSystem.assemble_point_after)) { assemblePointType = RedisConstant.assemblePointAfterTaskCount; } if (ObjectUtils.isEmpty(redisTemplate.opsForValue().get(assemblePointType))) { redisTemplate.opsForValue().set(assemblePointType, 1); - }else{ + } else { temp = Integer.parseInt(redisTemplate.opsForValue().get(assemblePointType).toString()); if (temp < 3) { redisTemplate.opsForValue().set(assemblePointType, ++temp); } } - log.info("添加小组装等待数完成!点位:"+assemblePointType+"数量为:" + temp); + log.info("添加小组装等待数完成!点位:" + assemblePointType + "数量为:" + temp); } } } //到达紧急出库点位时调用checkEmergencyOutbound方法 String tepairGroup = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.urgency_out_point); BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo(); - String outPoint =""; + String outPoint = ""; pointQueryBo.setGroupNo(tepairGroup); BasePointDeviceVo pointDeviceout = basePointDeviceMapper.selectBasePointByGroupno(pointQueryBo); - if (pointDeviceout==null){ + if (pointDeviceout == null) { log.info("请维护紧急出库接驳点"); } - outPoint=pointDeviceout.getPointNo(); + outPoint = pointDeviceout.getPointNo(); if (bo.getStatus().equals("completed") && outPoint.equals(taskAgvpoint)) { checkEmergencyOutbound(Long.valueOf(bo.getTaskId())); } //放置治具完成状态,回填AGV放置治具完成状态 - log.info("agvPoint:"+agvPoint); - log.info("taskAgvPoint:"+taskAgvpoint); + log.info("agvPoint:" + agvPoint); + log.info("taskAgvPoint:" + taskAgvpoint); if (bo.getStatus().equals("completed") && agvPoint.equals(taskAgvpoint)) { Map writeMap = new HashMap(1); writeMap.put(putAddressVtype, "true"); @@ -761,36 +762,36 @@ public class RCSUtil { * A-->b-->c场景不适用写入 */ allWriteMap.put(putAddress, writeMap); - if (tunnl != ""&&tunnl!=null && !businDataTask.getTaskType().equals("15")) { + if (tunnl != "" && tunnl != null && !taskType.equals("15")) { Map taskidMap = new HashMap(1); Map TaskwriteMap = new HashMap(1); TaskwriteMap.put(TaskddressVtype, bo.getTaskId()); taskidMap.put(TaskAddress, TaskwriteMap); - Boolean aBoolean=plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(taskidMap)); - int i=0; - while (!aBoolean&&i<50) { + Boolean aBoolean = plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(taskidMap)); + int i = 0; + while (!aBoolean && i < 50) { aBoolean = plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(taskidMap)); i++; } - log.info("写入放货完成任务号是否成功:"+aBoolean+" 任务号:"+bo.getTaskId()+" 写入次数:"+i+" 写入内容:"+TaskAddress); + log.info("写入放货完成任务号是否成功:" + aBoolean + " 任务号:" + bo.getTaskId() + " 写入次数:" + i + " 写入内容:" + TaskAddress); } - Boolean aBoolean=plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(allWriteMap)); - int i=0; - while (!aBoolean&&i<50) { + Boolean aBoolean = plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(allWriteMap)); + int i = 0; + while (!aBoolean && i < 50) { aBoolean = plcReadAndWrite.execWrite(plcOperate, JSON.toJSONString(allWriteMap)); i++; } - log.info("写入放货完成是否成功:"+aBoolean+" 任务号:"+bo.getTaskId()+" 写入次数:"+i+" 写入的点位:"+putAddress); + log.info("写入放货完成是否成功:" + aBoolean + " 任务号:" + bo.getTaskId() + " 写入次数:" + i + " 写入的点位:" + putAddress); - if(TaskTypeEnum.mechainical.getValue().equals(businDataTask.getTaskType())|| TaskTypeEnum.emptyContainer_out.getValue().equals(businDataTask.getTaskType())){ + if (TaskTypeEnum.mechainical.getValue().equals(taskType) || TaskTypeEnum.emptyContainer_out.getValue().equals(taskType)) { BusinDpscontainerRecord oneByTask = businDpsContainerRecordMapper.selectByTaskid(String.valueOf(businDataTask.getId())); oneByTask.setIsState("3"); businDpsContainerRecordMapper.updateById(oneByTask); } - if (TaskTypeEnum.emptyCon.getValue().equals(businDataTask.getTaskType()) || - TaskTypeEnum.mechainical.getValue().equals(businDataTask.getTaskType()) - ||TaskTypeEnum.emptyContainer_out.getValue().equals(businDataTask.getTaskType())) { + if (TaskTypeEnum.emptyCon.getValue().equals(taskType) || + TaskTypeEnum.mechainical.getValue().equals(taskType) + || TaskTypeEnum.emptyContainer_out.getValue().equals(taskType)) { //更改任务状态为已完成 businDataTask.setTaskStatus("2"); businDataTaskMapper.updateById(businDataTask); @@ -807,35 +808,35 @@ public class RCSUtil { // 4#入口 DB320.2.8 // 5#入口 DB320.2.10 // 6#入口 DB320.2.12 - if ("KW5".equals(businDataTask.getTaskPath())){ - write1.put("Boolean","true"); + if ("KW5".equals(businDataTask.getTaskPath())) { + write1.put("Boolean", "true"); allHbMap.put("DB320.2.2", write1); } - if ("KW7".equals(businDataTask.getTaskPath())){ - write1.put("Boolean","true"); + if ("KW7".equals(businDataTask.getTaskPath())) { + write1.put("Boolean", "true"); allHbMap.put("DB320.2.4", write1); } - if ("KW9".equals(businDataTask.getTaskPath())){ - write1.put("Boolean","true"); + if ("KW9".equals(businDataTask.getTaskPath())) { + write1.put("Boolean", "true"); allHbMap.put("DB320.2.5", write1); } - if ("KW22".equals(businDataTask.getTaskPath())){ - write1.put("Boolean","true"); + if ("KW22".equals(businDataTask.getTaskPath())) { + write1.put("Boolean", "true"); allHbMap.put("DB320.2.8", write1); } - if ("KW24".equals(businDataTask.getTaskPath())){ - write1.put("Boolean","true"); + if ("KW24".equals(businDataTask.getTaskPath())) { + write1.put("Boolean", "true"); allHbMap.put("DB320.2.10", write1); } - if ("KW26".equals(businDataTask.getTaskPath())){ - write1.put("Boolean","true"); + if ("KW26".equals(businDataTask.getTaskPath())) { + write1.put("Boolean", "true"); allHbMap.put("DB320.2.12", write1); } String writePoint = JSON.toJSONString(allHbMap); - PlcOperate plcOperateWrite =plcInit.getPlcOperateByIp(conn1.getPlcIp()); + PlcOperate plcOperateWrite = plcInit.getPlcOperateByIp(conn1.getPlcIp()); Boolean execWrite = plcReadAndWrite.execWrite(plcOperateWrite, writePoint); - if (execWrite){ - log.info("++++++++++++" + businDataTask.getTaskPath()+"打开安全光电成功"); + if (execWrite) { + log.info("++++++++++++" + businDataTask.getTaskPath() + "打开安全光电成功"); } return Result.ok(); @@ -997,24 +998,23 @@ public class RCSUtil { // } - String assemblePointGroupBefore = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.Manual_drop_point); BasePointDeviceQueryBo pointReportQueryBoBefore = new BasePointDeviceQueryBo(); - String assemblePointBefore =""; - String assemblePointAfter =""; + String assemblePointBefore = ""; + String assemblePointAfter = ""; pointReportQueryBoBefore.setGroupNo(assemblePointGroupBefore); List assemblePointDeviceOutBefore = basePointDeviceMapper.getBasePointByGroupNoList(pointReportQueryBoBefore); - if(ObjectUtils.isEmpty(assemblePointDeviceOutBefore)){ + if (ObjectUtils.isEmpty(assemblePointDeviceOutBefore)) { log.info("请维护组装线点位"); } for (BasePointDeviceVo str : assemblePointDeviceOutBefore) { if (str.getPointNo().equals(ParameterConstants.ParameterSystem.assemble_point_after)) { - assemblePointAfter =ParameterConstants.ParameterSystem.assemble_point_after; + assemblePointAfter = ParameterConstants.ParameterSystem.assemble_point_after; } if (str.getPointNo().equals(ParameterConstants.ParameterSystem.assemble_point_before)) { - assemblePointBefore =ParameterConstants.ParameterSystem.assemble_point_before; + assemblePointBefore = ParameterConstants.ParameterSystem.assemble_point_before; } } @@ -1027,7 +1027,7 @@ public class RCSUtil { assemblyLineAddBo.setTaskId(businDataTask.getId()); assemblyLineAddBo.setAgvNo(businDataTask.getAgvNo()); - assemblyLineAddBo.setTaskType(businDataTask.getTaskType()); + assemblyLineAddBo.setTaskType(taskType); assemblyLineAddBo.setContainerId(businDataTask.getContainerId()); assemblyLineAddBo.setPointNo(assemblePointBefore); @@ -1050,13 +1050,13 @@ public class RCSUtil { } // 到达组装线前杠点位之后的业务逻辑处理 - if (bo.getStatus().equals("completed") && assemblePointAfter.equals(taskAgvpoint)&& businDataTask.getTaskPath().equals(assemblePointAfter) && assemblePointAfter.equals(ParameterConstants.ParameterSystem.assemble_point_after)) { + if (bo.getStatus().equals("completed") && assemblePointAfter.equals(taskAgvpoint) && businDataTask.getTaskPath().equals(assemblePointAfter) && assemblePointAfter.equals(ParameterConstants.ParameterSystem.assemble_point_after)) { // TODO 测试注释 要打开 AssemblyLineAddBo assemblyLineAddBo = new AssemblyLineAddBo(); assemblyLineAddBo.setTaskId(businDataTask.getId()); assemblyLineAddBo.setAgvNo(businDataTask.getAgvNo()); - assemblyLineAddBo.setTaskType(businDataTask.getTaskType()); + assemblyLineAddBo.setTaskType(taskType); assemblyLineAddBo.setContainerId(businDataTask.getContainerId()); assemblyLineAddBo.setPointNo(assemblePointAfter); @@ -1072,10 +1072,10 @@ public class RCSUtil { pointQueryBo.setGroupNo(abnormalWaitPintGroup); // TODO 中科 测试 需要删除 修改平库释放后直接去下挂逻辑,后续不需要可以删掉 - if(bo.getSn().equals("3") && bo.getStatus().equals("completed")&&"KW18".equals(taskAgvpoint)){ + if (bo.getSn().equals("3") && bo.getStatus().equals("completed") && "KW18".equals(taskAgvpoint)) { businDataTask.setTaskStatus("2"); iBusinDataTaskService.updateById(businDataTask); - // 创建任务 + // 创建任务 // BusinDataTask task = new BusinDataTask(); // task.setTaskCode("T_" + DateUtils.dateTimeNow()); // task.setTaskPath("KW16"); @@ -1131,7 +1131,7 @@ public class RCSUtil { // log.error(task.toString()); //平库空治具流向接口 Result kw18Result = iBusinEnptyContainerService.emptyContainerFlowDir("KW18", businDataTask.getContainerId(), bo.getRobotId(), null); - log.info("平库空治具流向接口:"+kw18Result.getMsg()); + log.info("平库空治具流向接口:" + kw18Result.getMsg()); } // TODO 中科 测试 需要删除 @@ -1216,26 +1216,27 @@ public class RCSUtil { List basePointDeviceVos = baseLocationPlcMapper.selectBasePointByGroupno(pointQueryBo); if (basePointDeviceVos.size() > 0) { - for (BasePointDeviceVo basePointDeviceVo: basePointDeviceVos) { - if(basePointDeviceVo.getPointNo().contains("KW11")){ + for (BasePointDeviceVo basePointDeviceVo : basePointDeviceVos) { + if (basePointDeviceVo.getPointNo().contains("KW11")) { toPointNoTwo = basePointDeviceVo.getPointNo(); - }else{ + } else { toPointNoOne = basePointDeviceVo.getPointNo(); } } } // 如果到达 冲孔取货点位 就修改当前任务ID并且将任务ID存入redis 用于之后的冲孔流程使用 - if(bo.getStatus().equals("completed")&& toPointNoOne.equals(taskAgvpoint) && toPointNoOne.equals(businDataTask.getTaskPath())){ + if (bo.getStatus().equals("completed") && toPointNoOne.equals(taskAgvpoint) && toPointNoOne.equals(businDataTask.getTaskPath())) { businDataTask.setTaskStatus("2"); iBusinDataTaskService.updateById(businDataTask); BasePunchRecord basePunchRecord = iBasePunchRecordService.getOne(new LambdaQueryWrapper() - .eq(BasePunchRecord::getTaskCode,Long.valueOf(bo.getTaskId())) + .eq(BasePunchRecord::getTaskCode, Long.valueOf(bo.getTaskId())) .last("limit 1")); basePunchRecord.setAgvNo(bo.getRobotId()); - iBasePunchRecordService.updateById(basePunchRecord);; - redisTemplate.opsForValue().set(RedisConstant.startPunchingTaskId, bo.getTaskId()+"_"+bo.getRobotId()+"_"+businDataTask.getContainerId()); - redisTemplate.opsForValue().set(RedisConstant.endPunchingTaskId, bo.getTaskId()+"_"+bo.getRobotId()+"_"+businDataTask.getContainerId()); + iBasePunchRecordService.updateById(basePunchRecord); + ; + redisTemplate.opsForValue().set(RedisConstant.startPunchingTaskId, bo.getTaskId() + "_" + bo.getRobotId() + "_" + businDataTask.getContainerId()); + redisTemplate.opsForValue().set(RedisConstant.endPunchingTaskId, bo.getTaskId() + "_" + bo.getRobotId() + "_" + businDataTask.getContainerId()); } // 如果到达 冲孔放货点位 就修改当前任务ID并且将任务ID存入redis 用于之后的冲孔流程使用 @@ -1269,16 +1270,17 @@ public class RCSUtil { // } // } - // 新增安全光电相关逻辑 + // 新增安全光电相关逻辑 // if (TaskTypeEnum.normal_in.getValue().equals(businDataTask.getTaskType()) // ||TaskTypeEnum.empty_in.getValue().equals(businDataTask.getTaskType()) // && bo.getSn().equals("3") && bo.getStatus().equals("completed")){ // // } - if (TaskTypeEnum.emptyContainer_out.getValue().equals(businDataTask.getTaskType()) - ||TaskTypeEnum.normal_out.getValue().equals(businDataTask.getTaskType()) - ||TaskTypeEnum.urgent_out.getValue().equals(businDataTask.getTaskType())){ + if (TaskTypeEnum.emptyContainer_out.getValue().equals(taskType) + || TaskTypeEnum.normal_out.getValue().equals(taskType) + || TaskTypeEnum.urgent_out.getValue().equals(taskType) + || TaskTypeEnum.named_loc.getValue().equals(taskType)) { Map pointMap = JsonUtil.JsonStrToMap(businDataTask.getPoints()); String s1 = pointMap.get("1"); String s2 = pointMap.get("2"); @@ -1288,80 +1290,79 @@ public class RCSUtil { // 4#出口 DB320.2.9 // 5#出口 DB320.2.11 // 6#出口 DB320.2.13 - if ("1".equals(bo.getSn())&&"completed".equals(bo.getStatus())){ - if ("KW6".equals(s1)){ - writeMap1.put("Boolean","false"); + if ("1".equals(bo.getSn()) && "completed".equals(bo.getStatus())) { + if ("KW6".equals(s1)) { + writeMap1.put("Boolean", "false"); allHbMap.put("DB320.2.3", writeMap1); } - if ("KW8".equals(s1)){ - writeMap1.put("Boolean","false"); + if ("KW8".equals(s1)) { + writeMap1.put("Boolean", "false"); allHbMap.put("DB320.2.7", writeMap1); } - if ("KW10".equals(s1)){ - writeMap1.put("Boolean","false"); + if ("KW10".equals(s1)) { + writeMap1.put("Boolean", "false"); allHbMap.put("DB320.2.6", writeMap1); } - if ("KW23".equals(s1)){ - writeMap1.put("Boolean","false"); + if ("KW23".equals(s1)) { + writeMap1.put("Boolean", "false"); allHbMap.put("DB320.2.9", writeMap1); } - if ("KW25".equals(s1)){ - writeMap1.put("Boolean","false"); + if ("KW25".equals(s1)) { + writeMap1.put("Boolean", "false"); allHbMap.put("DB320.2.11", writeMap1); } - if ("KW27".equals(s1)){ - writeMap1.put("Boolean","false"); + if ("KW27".equals(s1)) { + writeMap1.put("Boolean", "false"); allHbMap.put("DB320.2.13", writeMap1); } } - if("2".equals(bo.getSn())&&"completed".equals(bo.getStatus())){ - if ("LY80".equals(s2)){ - writeMap1.put("Boolean","true"); + if ("2".equals(bo.getSn()) && "completed".equals(bo.getStatus())) { + if ("LY80".equals(s2)) { + writeMap1.put("Boolean", "true"); allHbMap.put("DB320.2.3", writeMap1); } - if ("LY82".equals(s2)){ - writeMap1.put("Boolean","true"); + if ("LY82".equals(s2)) { + writeMap1.put("Boolean", "true"); allHbMap.put("DB320.2.7", writeMap1); } - if ("LY84".equals(s2)){ - writeMap1.put("Boolean","true"); + if ("LY84".equals(s2)) { + writeMap1.put("Boolean", "true"); allHbMap.put("DB320.2.6", writeMap1); } - if ("LY244".equals(s1)){ - writeMap1.put("Boolean","true"); + if ("LY244".equals(s1)) { + writeMap1.put("Boolean", "true"); allHbMap.put("DB320.2.9", writeMap1); } - if ("LY247".equals(s1)){ - writeMap1.put("Boolean","true"); + if ("LY247".equals(s1)) { + writeMap1.put("Boolean", "true"); allHbMap.put("DB320.2.11", writeMap1); } - if ("LY250".equals(s1)){ - writeMap1.put("Boolean","true"); + if ("LY250".equals(s1)) { + writeMap1.put("Boolean", "true"); allHbMap.put("DB320.2.13", writeMap1); } } String writePoint = JSON.toJSONString(allHbMap); PlcOperate plcOperateWrite = plcInit.getPlcOperateByIp(conn1.getPlcIp()); Boolean execWrite = plcReadAndWrite.execWrite(plcOperateWrite, writePoint); - if (execWrite){ - log.info("++++++++++++" + s1+"关闭安全光电成功"); + if (execWrite) { + log.info("++++++++++++" + s1 + "关闭安全光电成功"); } - } log.info("agv上报接口执行结束"); return Result.ok(); } - /** * 呼叫AGV + * * @param taskId * @param taskType * @param points * @return */ - public Result callAGV(Long taskId,int taskType, List points){ + public Result callAGV(Long taskId, int taskType, List points) { AGVMoveBo moveBo = new AGVMoveBo(); moveBo.setTaskId(taskId); moveBo.setTaskType(taskType); @@ -1372,44 +1373,47 @@ public class RCSUtil { /** * 添加角度 - * @author Comair - * @date 2023/7/21 20:09 + * * @param taskId * @param taskType * @param points * @param toRow * @return com.shkj.common.core.domain.Result + * @author Comair + * @date 2023/7/21 20:09 */ - public Result callAGV(Long taskId,int taskType, List points,String toRow){ + public Result callAGV(Long taskId, int taskType, List points, String toRow) { // List list = Arrays.asList(1,2,5,7,9,11,13,14); AGVMoveBo moveBo = new AGVMoveBo(); moveBo.setTaskId(taskId); moveBo.setTaskType(taskType); moveBo.setPoints(points); Result booleanResult = null; - if("0".equals(taskType) || "7".equals(taskType)){ - booleanResult = moveByAGV(moveBo,toRow); + if ("0".equals(taskType) || "7".equals(taskType)) { + booleanResult = moveByAGV(moveBo, toRow); // if(list.contains(Integer.parseInt(toRow))){ // // }else{ // booleanResult = moveByAGV(moveBo,0); // } - }else{ + } else { booleanResult = moveByAGV(moveBo); } return booleanResult; } + /** * 添加角度 - * @author Comair - * @date 2023/7/21 20:09 + * * @param taskId * @param taskType * @param points * @param toRow * @return com.shkj.common.core.domain.Result + * @author Comair + * @date 2023/7/21 20:09 */ - public Result callAGV(Long taskId,int taskType, List points,String toRow,String agvno){ + public Result callAGV(Long taskId, int taskType, List points, String toRow, String agvno) { //List list = Arrays.asList(1,2,5,7,9,11,13,14); AGVMoveBo moveBo = new AGVMoveBo(); moveBo.setTaskId(taskId); @@ -1417,31 +1421,31 @@ public class RCSUtil { moveBo.setPoints(points); moveBo.setRobotId(agvno); Result booleanResult = null; - if("0".equals(taskType) || "7".equals(taskType)){ - booleanResult = moveByAGV(moveBo,toRow); + if ("0".equals(taskType) || "7".equals(taskType)) { + booleanResult = moveByAGV(moveBo, toRow); // if(list.contains(Integer.parseInt(toRow))){ // // }else{ // booleanResult = moveByAGV(moveBo,0); // } - }else{ + } else { booleanResult = moveByAGV(moveBo); } - return booleanResult; } /** * 获取AGV的实时数据,并存储至Redis中 + * * @param mapId */ - public void doAgvStates(String mapId){ + public void doAgvStates(String mapId) { //获取AGV系统的实时数据 String agvData = rcsRobotsStatesForString(mapId); - // log.info("AGV实时数据:"+agvData); + // log.info("AGV实时数据:"+agvData); //处理设备信息,存redis中 this.doAGVRobotsStatesForRedis(agvData); } @@ -1454,10 +1458,10 @@ public class RCSUtil { * @return {@code Result} */ public String rcsRobotsStatesForString(String mapId) { - Map map = new HashMap<>(); - // map.put("mapId",Integer.parseInt(mapId)); + Map map = new HashMap<>(); + // map.put("mapId",Integer.parseInt(mapId)); String json = JSONObject.toJSONString(map); - String res=""; + String res = ""; try { Map headerMap = getHeaderMap(); res = HttpRequest.post(agvStatesUrl) @@ -1475,13 +1479,14 @@ public class RCSUtil { /** * AGV设备实时状态,存储至Redis中 + * * @param agvData */ - public void doAGVRobotsStatesForRedis(String agvData){ + public void doAGVRobotsStatesForRedis(String agvData) { //log.info("处理agv设备状态信息开始"); - if (StringUtils.isNotEmpty(agvData)){ + if (StringUtils.isNotEmpty(agvData)) { RcsThirdResult thirdResult = JSONObject.parseObject(agvData, RcsThirdResult.class); - List redisList = new ArrayList<>(); + List redisList = new ArrayList<>(); List list = JSONArray.parseArray(thirdResult.getData().toString(), BusinAgvRealInfo.class); BusinAgvRealRedisInfo businAgvRealRedisInfo = null; for (BusinAgvRealInfo businAgvRealInfo : list) { @@ -1493,17 +1498,17 @@ public class RCSUtil { businAgvRealRedisInfo.setTaskId(businAgvRealInfo.getTaskId()); //如果在线状态是离线,则为离线,其他为AGV状态信息 - if (online.equals("false")){ + if (online.equals("false")) { businAgvRealRedisInfo.setAgvState(online); - }else { + } else { businAgvRealRedisInfo.setAgvState(agvState); } businAgvRealRedisInfo.setErrors(businAgvRealInfo.getErrors()); redisList.add(businAgvRealRedisInfo); } - redisTemplate.opsForValue().set(RedisConstant.redisAgvRealInfo ,redisList); - }else { + redisTemplate.opsForValue().set(RedisConstant.redisAgvRealInfo, redisList); + } else { log.info("AGV实时数据为空"); } } diff --git a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml index e7fb933..b93d376 100644 --- a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml +++ b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml @@ -518,7 +518,7 @@