diff --git a/shkj-admin/src/main/resources/application-pro.yml b/shkj-admin/src/main/resources/application-pro.yml index aea6e12..2a27bf4 100644 --- a/shkj-admin/src/main/resources/application-pro.yml +++ b/shkj-admin/src/main/resources/application-pro.yml @@ -64,7 +64,7 @@ spring: # redis 配置 redis: # 地址 - host: 127.0.0.1 + host: 192.168.155.145 # 端口,默认为6379 port: 6379 # 数据库索引 diff --git a/shkj-common/src/main/java/com/shkj/common/constant/RedisConstant.java b/shkj-common/src/main/java/com/shkj/common/constant/RedisConstant.java index 7f16e3e..fec5256 100644 --- a/shkj-common/src/main/java/com/shkj/common/constant/RedisConstant.java +++ b/shkj-common/src/main/java/com/shkj/common/constant/RedisConstant.java @@ -30,7 +30,8 @@ public class RedisConstant { //任务下发时间 public static String redisTaskTime ="redisTaskTime:"; - public static String redisTaskOut ="redisTaskOut:"; + public static String redisTaskOutOne ="redisTaskOutOne:"; + public static String redisTaskOutTwo ="redisTaskOutTwo:"; public static String redisTaskIn ="redisTaskIn:"; diff --git a/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java b/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java index 0e7e8b6..4dcc8d1 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java @@ -78,7 +78,7 @@ public class PlcEventTask { @Autowired PlcInit plcInit; - @Scheduled(fixedDelay = 4000) + @Scheduled(fixedDelay = 5000) public void init() { //查询需要连接的PLC,初始化连接对象 List plcList =(List) redisTemplate.opsForValue().get(RedisConstant.redisPlcListConnect); @@ -407,12 +407,18 @@ public class PlcEventTask { Long taskIdOne = 0L; //1楼是否请求分配 if (pointMap.containsKey(oneAllotAddress) && Boolean.valueOf(pointMap.get(oneAllotAddress).toString())) { - //请求入库分配时,判断是否有正在执行的出库任务,如果有则返回 - Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); - if (taskOutId != null) { - log.info("1楼入库分配请求时,有出库任务,不可分配,返回"); - return; - } +// //请求入库分配时,判断是否有正在执行的出库任务,如果有则返回 +// Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); +// if (oneTaskOutId != null) { +// log.info("1楼入库分配请求时,1楼有出库任务,不可分配:"+oneTaskOutId); +// return; +// } +// +// Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); +// if (twoTaskOutId != null) { +// log.info("1楼入库分配请求时,2楼有出库任务,不可分配:"+twoTaskOutId); +// return; +// } //读取托盘条码内容 String barcodeValueOne = pointMap.get(onePalletAddress).toString(); @@ -467,9 +473,10 @@ public class PlcEventTask { log.info("1楼按下入库按钮时,给输送线写命令数据:{}" + allMap); Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); + log.info("1楼按下入库按钮时,写入的命令返回结果:"+taskBoolean.toString()); if (taskBoolean) { //分配任务成功时,记录已下发入库任务,不可在下发出库或入库任务 - redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskIdOne); + log.info("分配成功后写入redis的数据:"+taskIdOne); //更改入库计划为1 iBusinOutInPlanService.updPlanStatus(taskIdOne, PlanStatusEnum.DOING.getValue()); } @@ -481,11 +488,17 @@ public class PlcEventTask { if (pointMap.containsKey(twoAllotAddress) && Boolean.valueOf(pointMap.get(twoAllotAddress).toString())) { Long taskIdTwo = 0L; //请求入库分配时,判断是否有正在执行的出库任务,如果有则返回 - Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); - if (taskOutId != null) { - log.info("2楼入库分配请求时,有出库任务,不可分配,返回"); - return; - } +// Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); +// if (oneTaskOutId != null) { +// log.info("2F入库分配请求时,1F有出库任务,不可分配,返回"); +// return; +// } +// +// Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); +// if (twoTaskOutId != null) { +// log.info("2F入库分配请求时,2F有出库任务,不可分配,返回"); +// return; +// } //读取托盘条码内容 String barcodeValueTwo = pointMap.get(twoPalletAddress).toString(); log.info("1楼请求入库时,读取的条码内容:" + barcodeValueTwo); @@ -540,7 +553,7 @@ public class PlcEventTask { Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); if (taskBoolean) { //分配任务成功时,记录已下发入库任务,不可在下发出库任务 - redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskIdTwo); + //redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskIdTwo); //更改入库计划为1 iBusinOutInPlanService.updPlanStatus(taskIdTwo, PlanStatusEnum.DOING.getValue()); } @@ -769,18 +782,22 @@ public class PlcEventTask { if (plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap))) { //堆垛机完成状态后,把redis中的ID删除,代表此任务已经完成 Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); - Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); + if (taskInId != null && String.valueOf(taskInId).equals(taskId.toString())) { + log.info("入库完成时,删除redis中的入库任务状态记录:"); + redisTemplate.delete(RedisConstant.redisTaskIn); + } - if (taskOutId != null && String.valueOf(taskOutId).equals(taskId.toString())) { + Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); + if (oneTaskOutId != null && String.valueOf(oneTaskOutId).equals(taskId.toString())) { log.info("出库完成时,删除redis中的出库任务状态记录"); - redisTemplate.delete(RedisConstant.redisTaskOut); + redisTemplate.delete(RedisConstant.redisTaskOutOne); } - if (taskInId != null && String.valueOf(taskInId).equals(taskId.toString())) { - log.info("入库完成时,删除redis中的入库任务状态记录"); - redisTemplate.delete(RedisConstant.redisTaskIn); + Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); + if (twoTaskOutId != null && String.valueOf(twoTaskOutId).equals(taskId.toString())) { + log.info("出库完成时,删除redis中的出库任务状态记录"); + redisTemplate.delete(RedisConstant.redisTaskOutTwo); } - log.info("给堆垛机下发完成信号为0,成功:" + taskId); //请求成功,记录已下发 redisTemplate.delete(RedisConstant.redisReqWare + taskId); @@ -811,9 +828,15 @@ public class PlcEventTask { return false; } - Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); - if (taskOutId != null) { - log.info("有出库任务在执行,无法下发入库任务:" + taskOutId); + Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); + if (oneTaskOutId != null) { + log.info("1F有出库任务在执行,无法下发入库任务:" + oneTaskOutId); + return false; + } + + Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); + if (twoTaskOutId != null) { + log.info("2F有出库任务在执行,无法下发入库任务:" + twoTaskOutId); return false; } @@ -972,6 +995,7 @@ public class PlcEventTask { log.info(taskId + "请求入库:任务下发之前" + JsonUtil.toJSONString(allMap)); if (plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap))) { log.info(taskId + "请求入库,任务下发成功:"); + redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskId); //请求成功,记录已下发 redisTemplate.opsForValue().set(RedisConstant.redisReqWare + taskId, taskId, 24, TimeUnit.HOURS); //请求分配任务ID dps diff --git a/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java b/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java index 4f1d33a..2d7d305 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java @@ -74,19 +74,26 @@ public class StkCallUtil { return Result.err().msg("有入库任务在执行,无法下发出库任务"); } - Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); - if (taskOutId !=null ){ - log.info("有出库任务在执行,无法下发出库任务:"+taskOutId); - return Result.err().msg("有出库任务在执行,无法下发出库任"); + Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); + if (oneTaskOutId !=null ){ + log.info("1F有出库任务在执行,无法下发出库任务:"+oneTaskOutId); + return Result.err().msg("1F有出库任务在执行,无法下发出库任务"); } + + Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); + if (twoTaskOutId !=null ){ + log.info("2F有出库任务在执行,无法下发出库任务:"+twoTaskOutId); + return Result.err().msg("2F有出库任务在执行,无法下发出库任务"); + } + Long taskId = stkMoveBo.getTaskId(); SysThirdExceptionRequest one = sysThirdExceptionRequestService.getOneByOrderNo(taskId.toString()); - if (one != null){ - if (!one.getCode().equals(taskId.toString())){ - log.info("有更早未执行的任务,排队执行:"+JsonUtil.toJSONString(one)); - return Result.err().msg("有更早未执行的任务,排队执行"); - } - } +// if (one != null){ +// if (!one.getCode().equals(taskId.toString())){ +// log.info("有更早未执行的任务,排队执行:"+JsonUtil.toJSONString(one)); +// return Result.err().msg("有更早未执行的任务,排队执行"); +// } +// } String fromLayer = stkMoveBo.getFromLayer(); String fromColumn = stkMoveBo.getFromColumn(); @@ -296,11 +303,16 @@ public class StkCallUtil { finishPointMap.put(finishPointVT, 0); allMap.put(finishPoint, finishPointMap); PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); - if ( plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap)) ){ + if ( plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap)) && layer ==1 ){ + redisTemplate.opsForValue().set(RedisConstant.redisTaskTime, DateUtils.getNowDate()); + redisTemplate.opsForValue().set(RedisConstant.redisTaskOutOne, taskId); + return Result.ok(); + }else if ( plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap)) && layer ==2 ){ redisTemplate.opsForValue().set(RedisConstant.redisTaskTime, DateUtils.getNowDate()); - redisTemplate.opsForValue().set(RedisConstant.redisTaskOut, taskId); + redisTemplate.opsForValue().set(RedisConstant.redisTaskOutTwo, taskId); return Result.ok(); - } else { + } + else { log.info(one.getTaskId()+"堆垛机下发命令失败"); return Result.err(); } diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseContainerServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseContainerServiceImpl.java index 17edba4..84e6b2c 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseContainerServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseContainerServiceImpl.java @@ -169,6 +169,7 @@ public class BaseContainerServiceImpl extends ServiceImpl checkContainerCodeNoInv(String containerCode) { + log.info("扫描的托盘编号:"+containerCode); LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.eq(BaseContainer::getContainerCode, containerCode); lqw.eq(BaseContainer::getBranchId, SecurityUtils.getCurrentBranchId()).last("limit 1"); diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java index 01a46b8..8fa4c39 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java @@ -604,11 +604,17 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl x.getId()).collect(Collectors.toList())); } //堆垛机非自动完成状态后,把redis中的ID删除,代表此任务已经完成 - Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); Long orderNo = updList.get(0).getOrderNo(); - if (taskOutId !=null && String.valueOf(taskOutId).equals(orderNo.toString())){ + Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); + if (oneTaskOutId !=null && String.valueOf(oneTaskOutId).equals(orderNo.toString())){ log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo); - redisTemplate.delete(RedisConstant.redisTaskOut); + redisTemplate.delete(RedisConstant.redisTaskOutOne); + } + + Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); + if (twoTaskOutId !=null && String.valueOf(twoTaskOutId).equals(orderNo.toString())){ + log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo); + redisTemplate.delete(RedisConstant.redisTaskOutTwo); } //出库成功写入wcs异常点位为0 @@ -1013,20 +1019,12 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl eq = new LambdaQueryWrapper() .eq(BusinOutInPlan::getContainerCode, containerCode) .in(BusinOutInPlan::getPlanStatus,PlanStatusEnum.WAIT.getValue(),PlanStatusEnum.DOING.getValue()) - //.eq(BusinOutInPlan::getPlanStatus, PlanStatusEnum.WAIT.getValue()) .in(BusinOutInPlan::getType,PlanTypeEnum.IN.getValue(),PlanTypeEnum.BACK.getValue(),PlanTypeEnum.INV_BACK.getValue(),PlanTypeEnum.EMPTY_IN.getValue()) .orderByDesc(BusinOutInPlan::getCreateTime) - // .eq(BusinOutInPlan::getType, planType) -// .last("limit 1") ; List ones = this.list(eq); @@ -1043,7 +1041,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl businStockInvs = iBusinStockInvService.queryStockInvList(one.getOrderNo().toString()); + List businStockInvs = iBusinStockInvService.queryStockInvList(one.getDirection().toString()); //存的盘点单号 long qtySum = businStockInvs.stream().mapToLong(x -> x.getQty().longValue()).sum(); long invQtySum = businStockInvs.stream().mapToLong(x -> x.getInvQty().longValue()).sum(); if (qtySum == invQtySum && qtySum !=0 && qtySum !=0){ @@ -1122,25 +1120,16 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl detailList = redisCache.getCacheList(RedisLockConstants.containerCode + "_" + container.getContainerCode()); -// List detailList = sysStockDetailService.getByContainerId(container.getId()); - /*if (CollectionUtils.isEmpty(detailList)) { - log.info("不需要处理数据了 = {}", container); - isEmpty = true; - //return Result.err().data(StringUtils.EMPTY); - }*/ //去掉库存为0的 List newDetailList=null; if ( !CollectionUtils.isEmpty(detailList) ){ newDetailList = detailList.stream().filter(x -> x.getQty().add(x.getInQty()).add(x.getOutQty()).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); } - - if (CollectionUtils.isEmpty(newDetailList)) { isEmpty = true; } log.info("是否是空托盘了 = {}", isEmpty); - List inPlans = new ArrayList<>(); Long no = IntIdUtil.generateIntId();; @@ -1166,11 +1155,6 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl moldBarcodeList = newDetailList.stream().map(x -> x.getBarcode()).collect(Collectors.toList()); - List baseMoldBarcodeList = baseMoldService.queryByMoldBarcodeList(moldBarcodeList);*/ - //baseMoldBarcodeList 一定都有库存的 location = sysStockDetailService.findLocationByContainer(container.getContainerCode(),SecurityUtils.erpBranchId); } if (location == null) { @@ -1193,17 +1173,6 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl x.setLocationId(finalLocation.getId())); this.saveBatch(inPlans); - - //老数据需要清空 新货位先预占然后在实际回库的时候进行更新 -// sysStockDetailService.removeByIds(detailList.stream().map(x -> x.getId()).collect(Collectors.toList())); -// detailList.forEach(detail -> { -// detail.setQty(BigDecimal.ZERO) -// .setInQty(BigDecimal.ZERO) -// .setOutQty(BigDecimal.ZERO) -// .setContainerId(0L) -// .setContainerCode("-"); -// }); -// sysStockDetailService.updateBatchById(detailList); //增加预库存 if (!isEmpty) { sysStockDetailService.addStockByIn(inPlans, location, false); diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinStockInvServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinStockInvServiceImpl.java index a1fe458..29d01cf 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinStockInvServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinStockInvServiceImpl.java @@ -133,13 +133,6 @@ public class BusinStockInvServiceImpl extends ServiceImpl insertByAddBo(BusinStockInvAddBo bo) { - - Long branchId = SecurityUtils.getCurrentBranchId(); -// Result result = sysSeqManaService.generatorCode(NumberPreEnum.PD.getValue(), NumberPreEnum.PD.getType(), branchId); -// if (!Result.isOk(result)) { -// return Result.err().msg(result.getMsg()); -// } -// String orderNo = result.getData(); Long orderNo = IntIdUtil.generateIntId(); List addList = new ArrayList<>(); for (Long stockId : bo.getIds()) { @@ -320,8 +313,9 @@ public class BusinStockInvServiceImpl extends ServiceImpl checkAppNeedUpdate(String code) { - SysAppVersion one = getOne(new LambdaQueryWrapper() + /* SysAppVersion one = getOne(new LambdaQueryWrapper() .eq(SysAppVersion::getBranchId, SecurityUtils.getCurrentBranchId()) .orderByDesc(SysAppVersion::getCreateTime) .last("limit 1")); if (one == null) { - // return Result.err().msg("没有版本"); + return Result.err().msg("没有版本"); } if (!one.getCode().equals(code) || StringUtils.isBlank(code)) { @@ -96,8 +96,9 @@ public class SysAppVersionServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SysThirdExceptionRequest::getStatus, ThirdApiStatusEnum.fail.getValue()); wrapper.orderByAsc(SysThirdExceptionRequest::getCreateTime); - wrapper.last("limit 1"); List thirdExceptionRequestList = list(wrapper); // log.info("定时任务当前执行数量 = {}", thirdExceptionRequestList.size()); for (SysThirdExceptionRequest request : thirdExceptionRequestList) { diff --git a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml index 2303c2c..f7fa455 100644 --- a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml +++ b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml @@ -406,7 +406,7 @@ and (loc.location_code like concat('%', #{locationMsg}, '%')) - + order by location_column desc