From 71b3878aabd0d9f78976f32f0866a846196c753a Mon Sep 17 00:00:00 2001 From: judy <278197488@qq.com> Date: Wed, 14 Aug 2024 17:15:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=9D=A0=E5=88=B0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/shkj/wms/bo/AssingEmptyLocBo.java | 2 + .../shkj/wms/scheduled/ScheduledTasks.java | 337 +++++++----------- .../wms/service/IBaseLocationService.java | 8 + .../service/impl/BaseLocationServiceImpl.java | 140 +++++++- .../impl/BusinDataTaskServiceImpl.java | 5 +- .../impl/IBusinEnptyContainerServiceImpl.java | 13 +- .../impl/PutInOutStorageServiceImpl.java | 4 +- .../mapper/wms/BaseLocationMapper.xml | 6 +- 8 files changed, 296 insertions(+), 219 deletions(-) diff --git a/shkj-wms/src/main/java/com/shkj/wms/bo/AssingEmptyLocBo.java b/shkj-wms/src/main/java/com/shkj/wms/bo/AssingEmptyLocBo.java index d147b5c..a00a5a8 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/bo/AssingEmptyLocBo.java +++ b/shkj-wms/src/main/java/com/shkj/wms/bo/AssingEmptyLocBo.java @@ -27,5 +27,7 @@ public class AssingEmptyLocBo implements Serializable { private String taskId; private List businDataTaskGoodsVos; + private Long areaId; + } diff --git a/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java b/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java index ade10bd..f08aef9 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java +++ b/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java @@ -199,9 +199,7 @@ public class ScheduledTasks { taskQueryBo.setTaskType("1"); List businDataTaskVo1 = iBusinDataTaskService.selectBusinDataTask1(taskQueryBo); businDataTaskVos.addAll(businDataTaskVo1); - taskQueryBo.setTaskType("2"); - List businDataTaskVo2 = iBusinDataTaskService.selectBusinDataTask1(taskQueryBo); - businDataTaskVos.addAll(businDataTaskVo2); + //越库模式下或暂停出库,需要设置暂停出库 String startStopOutbound= StartStopOutboundEnum.STOP.getValue(); @@ -270,7 +268,7 @@ public class ScheduledTasks { //查询下挂任务目前的车型:入库:3LN(20秒) 出库:3UG(40秒) 空托和保险杠交替进行 4和15 //从redis中写入 - if (inVehicheModel.equals("3LN") || inVehicheModel.equals("3UE")) {//下发车型为3LN的时候,根据出库任务数量执行空托任务 + if (inVehicheModel.equals("3LN") || inVehicheModel.equals("3UE")) {//下挂车型为3LN的时候,根据出库任务数量执行空托任务 //获取出库任务下发成功数 if (redisTemplate.hasKey(RedisConstant.redisSurplusWaitIssueEmpFixTaskNum)) { Integer lastSurpTaskNum = (Integer) redisTemplate.opsForValue().get(RedisConstant.redisSurplusWaitIssueEmpFixTaskNum); @@ -520,163 +518,7 @@ public class ScheduledTasks { } else if (taskType.equals("2")) { - Long plcId = 0L; - Long stkPlcId = 0L; - Boolean NUMBER = true; - //维修异常 呼叫AGV - //获取起始点位 - String startPoint = businDataTaskVo.getTaskPath(); - //查询维修地点是否有空闲 - String tepairGroup = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.scanexc_group); -// String tmpPoint = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.putout_point_tmp); - - pointQueryBo.setGroupNo(tepairGroup); - BasePointDeviceVo basePointDeviceVo = null; - List basePointDeviceVos = baseLocationPlcMapper.selectBasePointByGroupno(pointQueryBo); - List points = new ArrayList<>(); - points.add(startPoint); - Map snPointMap = new HashMap<>(3); - snPointMap.put("1", startPoint); - //获取机械手上报点 - String tepairGroupin = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.putout_point); - BasePointDeviceQueryBo pointQueryBoup = new BasePointDeviceQueryBo(); - pointQueryBoup.setGroupNo(tepairGroupin); - BasePointDeviceVo pointDevice = new BasePointDeviceVo(); - pointDevice = basePointDeviceMapper.selectBasePointByGroupno(pointQueryBoup); - points.add(pointDevice.getHandshakePoint()); - snPointMap.put("2", pointDevice.getHandshakePoint()); - BaseLocationVo locationVo = null; - BusinTaskExeBo exeBo = new BusinTaskExeBo(); - //无空闲区 分配异常区库位 -// if (basePointDeviceVos.size() ==0) { -// NUMBER=false; -// -// if (businDataTaskVo.getWarehouseType().equals("2")) { -// String tepairGroup1 = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.P_in01); -// pointQueryBo.setGroupNo(tepairGroup1); -// BasePointDeviceVo pointDeviceout = basePointDeviceMapper.selectBasePointByGroupno(pointQueryBo); -// basePointDeviceVo = pointDeviceout; -// } else { -// //异常区ID -// Long abnormalArea =Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.abnormal_area)); -// List baseLocationVos = baseLocationMapper.getLocationByAreaId(abnormalArea); -// if (baseLocationVos.size() > 0) { -// locationVo = baseLocationVos.get(0); -// } -// businDataTaskVo.setToColumn(locationVo.getLocationColumn()); -// businDataTaskVo.setToLayer(locationVo.getLayer()); -// businDataTaskVo.setToRow(locationVo.getLocationRow()); -// //获取货位及巷道; -// String tunnel = locationVo.getTunnel(); -// businDataTaskVo.setTunnel(tunnel); -// pointQueryBo=new BasePointDeviceQueryBo(); -// pointQueryBo.setTunnel(tunnel); -// pointQueryBo.setDirection("0"); -// basePointDeviceVos = baseLocationPlcMapper.selectBasePointByGroupno(pointQueryBo); -// if (basePointDeviceVos.size() > 0) { -// basePointDeviceVo = basePointDeviceVos.get(0); -// basePointDeviceVo.setPlcId(Long.valueOf(isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.LK_plc_id))); -// -// } -// //获取巷道对应的堆垛机信息 -// pointQueryBo.setDevType("1"); -// BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointQueryBo); -// stkPlcId = baseDevicePlcVo.getPlcId(); -// List businDataTaskGoodsVos = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(businDataTaskVo.getId()); -//// exeBo.setTaskCode(taskId); -//// exeBo.setBusinDataTaskGoodsVo(businDataTaskGoodsVos); -//// exeBo.setContainerId(containerId); -//// exeBo.setBaseLocationVo(locationVo); -//// exeBo.setTransNo("1"); -//// exeBo.setTransQual("1"); -// } -// }else { - basePointDeviceVo = basePointDeviceVos.get(0); -// } - - //plcId =basePointDeviceVo.getPlcId(); -// String toPointNo = basePointDeviceVo.getPointNo(); -// snPointMap.put("3",toPointNo); -// points.add(toPointNo); -// int agvTaskType = Integer.valueOf(basePointDeviceVo.getIsDown()); - - String toPointNo = basePointDeviceVo.getPointNo(); - ; - int agvTaskType = 33; - snPointMap.put("3", "XX"); - points.add("XX"); - snPointMap.put("4", "XX"); - points.add("XX"); - snPointMap.put("5", toPointNo); - points.add(toPointNo); - // TODO 中科 测试 需要删除 - businDataTaskVo.setPoints(JsonUtil.toJSONString(snPointMap)); - businDataTaskVo.setIsDown(String.valueOf(agvTaskType)); - Result booleanResult = new Result<>(); - //呼叫AGV - if (StringUtils.isNotEmpty(businDataTaskVo.getAgvNo())) { - booleanResult = callAGV(taskId, agvTaskType, points, businDataTaskVo.getAgvNo()); - } else { - booleanResult = callAGV(taskId, agvTaskType, points); - } - if (booleanResult.getCode() == HttpStatus.ERROR.getCode()) { - BusinDataTask businDataTask = new BusinDataTask(); - businDataTask.setId(businDataTaskVo.getId()); - businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); - businDataTask.setTaskPath(toPointNo); - iBusinDataTaskService.updateById(businDataTask); - return; - } - //呼叫AGV成功 - if (booleanResult.getCode() == HttpStatus.SUCCESS.getCode()) { - businDataTaskVo.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); - businDataTaskVo.setTaskPath(toPointNo); - // TODO 中科 测试 需要还原 -// //把占用的点位改为已占用 - if (NUMBER) { - BasePoint basePoint = iBasePointService.getById(basePointDeviceVo.getPointId()); - basePoint.setIsOccupy("1"); - iBasePointService.updateById(basePoint); - } -// //更改货位状态为4已分配 -// if (ObjectUtils.isNotEmpty(locationVo)){ -// BaseLocation baseLocation = iBaseLocationService.getById(locationVo.getId()); -// baseLocation.setLocationStatus("4"); -// iBaseLocationService.updateById(baseLocation); -// } - // TODO 中科 测试 需要还原 - // TODO 中科 测试 需要还原 - } -// 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))); -// businDataTaskVo.setTaskStatus(TaskStatusEnum.err.getValue()); -// businDataTaskVo.setExceptionMsg(booleanResult.getMsg()); -// if (a<3L){ -// long l = a + 1; -// redisTemplate.opsForValue().set(RedisConstant.redisAgvTaskerror+taskId,l); -// }else { -// businDataTaskVo.setTaskStatus("-2"); -// } -// } - // TODO 测试注释 要打开 -// //更新入库条码表状态为异常 - List barcodesIns = new ArrayList<>(); - List goodsVos = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(taskId); - for (BusinDataTaskGoodsVo goodsVo : goodsVos) { - BaseBarcodesIn baseBarcodesIn = iBaseBarcodesInService.getOne(new LambdaQueryWrapper() - .eq(BaseBarcodesIn::getQrCode, goodsVo.getQrCode()) - ); - baseBarcodesIn.setInStatus("4"); - baseBarcodesIn.setInDate(DateUtils.getDate()); - barcodesIns.add(baseBarcodesIn); - } - iBaseBarcodesInService.saveOrUpdateBatch(barcodesIns); - - businDataTaskVo.setDpsNoOne(plcId); - businDataTaskVo.setDpsNoTwo(stkPlcId); + //异常杠下挂区域直接调度 } else if (taskType.equals("1")) { Long plcId = 0L; @@ -1336,13 +1178,6 @@ public class ScheduledTasks { Result taskResult1 = outTask(businDataTaskVo); if (taskResult1.getCode() == HttpStatus.SUCCESS.getCode()) { businDataTaskVo.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); - //生成出库单 - BusinTaskExeBo exeBo = new BusinTaskExeBo(); - exeBo.setTaskCode(taskId); - exeBo.setBusinDataTaskGoodsVo(goodsVo); - exeBo.setBaseLocationVo(baseLocationVo); - exeBo.setTransNo("2"); - exeBo.setTransQual("2"); // Result billResult = iPutInOutStorageService.exeTaskPutinStorage(exeBo); // businDataTaskVo.setTransId(billResult.getData()); @@ -1407,14 +1242,6 @@ public class ScheduledTasks { } BaseLocation baseLocationVo = baseLocationService.getOne(new LambdaQueryWrapper() .eq(BaseLocation::getId, businDataTaskVo.getLocationId())); - //生成出库单 - BusinTaskExeBo exeBo = new BusinTaskExeBo(); - exeBo.setTaskCode(taskId); - exeBo.setBusinDataTaskGoodsVo(goodsVo); - exeBo.setBaseLocationVo(BeanUtil.toBean(baseLocationVo,BaseLocationVo.class)); - exeBo.setTransNo("2"); - exeBo.setTransQual("2"); - // Result billResult = iPutInOutStorageService.exeTaskPutinStorage(exeBo); // businDataTaskVo.setTransId(billResult.getData()); //添加货位预占和库存预占 @@ -1441,8 +1268,6 @@ public class ScheduledTasks { businDataTaskVo.setTaskStatus(TaskStatusEnum.err.getValue()); } } - - } else if (taskType.equals("22")) { BusinDataTask businDataTask = iBusinDataTaskService.getById(businDataTaskVo.getId()); @@ -1851,9 +1676,6 @@ public class ScheduledTasks { //生成异常出库任务 BusinDataTask task = new BusinDataTask(); - int randomoperands = (int) Math.round(Math.random() * 1000); - String taskCode = "T_" + DateUtils.dateTimeNow() + randomoperands; - task.setTaskCode(taskCode); task.setTaskType(TaskTypeEnum.abnormal_delivery.getValue()); task.setBatch(DateUtils.getDate()); task.setPriority("2"); @@ -1903,9 +1725,6 @@ public class ScheduledTasks { //生成冲孔出库任务 BusinDataTask task = new BusinDataTask(); - int randomoperands = (int) Math.round(Math.random() * 1000); - String taskCode = "T_" + DateUtils.dateTimeNow() + randomoperands; - task.setTaskCode(taskCode); task.setTaskType("21"); task.setBatch(DateUtils.getDate()); task.setPriority("2"); @@ -1914,10 +1733,7 @@ public class ScheduledTasks { task.setCreateTime(DateUtils.getNowDate()); task.setTaskPath(toPointNo); task.setTaskStatus("0"); - iBusinDataTaskService.insertBusinDataTask(task); - - } } @@ -1951,9 +1767,9 @@ public class ScheduledTasks { //获取要出入库的条码信息 List businDataTaskGoodsVos = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(businDataTaskVo.getId()); String taskType = businDataTaskVo.getTaskType(); - if (ObjectUtils.isEmpty(businDataTaskGoodsVos) || (!taskType.equals("0") && !taskType.equals("3")) ) { - return; - } + if (!taskType.equals("0") && !taskType.equals("3") && !taskType.equals("2")) + { return;} + if ("3".equals(taskType)){ Long plcId = 0L; @@ -2007,6 +1823,7 @@ public class ScheduledTasks { List businDataTaskGoodsVoList = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(businDataTaskVo.getId()); AssingEmptyLocBo assingEmptyLocBo = new AssingEmptyLocBo(); assingEmptyLocBo.setBusinDataTaskGoodsVos(businDataTaskGoodsVoList); + assingEmptyLocBo.setAreaId(punchingArea); //冲孔杠分配货位 Result locationVoResult = iBaseLocationService.assignEmptyLocatioPunching(assingEmptyLocBo); @@ -2084,7 +1901,8 @@ public class ScheduledTasks { businDataTaskVo.setDpsNoOne(plcId); businDataTaskVo.setDpsNoTwo(stkPlcId); iBusinDataTaskService.updateById(BeanUtil.toBean(businDataTaskVo, BusinDataTask.class)); - }else { + } + else if ("0".equals(taskType)){ BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo(); BusinDataTaskGoodsVo goodsVo = businDataTaskGoodsVos.get(0); String vehicheModel = goodsVo.getVehicheModel(); @@ -2092,8 +1910,6 @@ public class ScheduledTasks { String startPoint = businDataTaskVo.getTaskPath(); redisTemplate.opsForValue().set(RedisConstant.redisInVehicheModel, vehicheModel); - - /** * 1.判断是否启动越库 * 2.判断此入库的保险杠是否是有出库任务,如果有,送往小组装 @@ -2278,30 +2094,22 @@ public class ScheduledTasks { //到达组装线等待上报点进行的业务处理 String reportPointGroup = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.report_point); BasePointDeviceQueryBo pointReportQueryBo = new BasePointDeviceQueryBo(); - String reportPoint = ""; pointReportQueryBo.setGroupNo(reportPointGroup); BasePointDeviceVo reportPointDeviceOut = basePointDeviceMapper.selectBasePointByGroupno(pointReportQueryBo); if (ObjectUtils.isEmpty(reportPointDeviceOut)) { log.error("请维护组装线上报点"); return; } - reportPoint = reportPointDeviceOut.getPointNo(); //越库到小组装的下挂点 toLocation =outTaskVos.get(0).getTaskPath(); points.add(businDataTaskVo.getTaskPath()); - // points.add(pointDevice.getHandshakePoint()); - // points.add(reportPoint); points.add(toLocation); snPointMap.put("1", businDataTaskVo.getTaskPath()); -// snPointMap.put("2", pointDevice.getHandshakePoint()); -// snPointMap.put("3", reportPoint); snPointMap.put("2", toLocation); } - - //呼叫AGV Result booleanResult = new Result<>(); if (taskType.equals("7")) { @@ -2355,8 +2163,135 @@ public class ScheduledTasks { } iBusinDataTaskService.updateById(BeanUtil.toBean(businDataTaskVo, BusinDataTask.class)); } + else if ("2".equals(taskType)){ + Long plcId = 0L; + Long stkPlcId = 0L; + Boolean NUMBER = true; + BaseLocationVo locationVo = null; + String toPointNo=""; + int agvTaskType=33; + //获取起始点位 + String startPoint = businDataTaskVo.getTaskPath(); + //获取机械手上报点 + List points = new ArrayList<>(); + Map snPointMap = new HashMap<>(3); + String tepairGroupin = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.putout_point); + BasePointDeviceQueryBo pointQueryBoup = new BasePointDeviceQueryBo(); + pointQueryBoup.setGroupNo(tepairGroupin); + BasePointDeviceVo pointDevice = basePointDeviceMapper.selectBasePointByGroupno(pointQueryBoup); + points.add(startPoint); + snPointMap.put("1", startPoint); + points.add(pointDevice.getHandshakePoint()); + snPointMap.put("2", pointDevice.getHandshakePoint()); + //查询维修地点是否有空闲 + String tepairGroup = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.scanexc_group); + BasePointDeviceQueryBo pointQueryBo = new BasePointDeviceQueryBo(); + pointQueryBo.setGroupNo(tepairGroup); + BasePointDeviceVo basePointDeviceVo = null; + List basePointDeviceVos = baseLocationPlcMapper.selectBasePointByGroupno(pointQueryBo); + + //无空闲区 分配异常区库位 + if (basePointDeviceVos.size() == 0) { + NUMBER = false; + agvTaskType=RCSTaskTypeEnum.A_TO_B_HAND_PUT.getValue(); + if (businDataTaskVo.getWarehouseType().equals("2")) { + String tepairGroup1 = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.P_in01); + pointQueryBo.setGroupNo(tepairGroup1); + basePointDeviceVo = basePointDeviceMapper.selectBasePointByGroupno(pointQueryBo); + + } else { + //异常区ID + Long abnormalArea = Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.abnormal_area)); + //分配货位 + List businDataTaskGoodsVoList = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(businDataTaskVo.getId()); + AssingEmptyLocBo assingEmptyLocBo = new AssingEmptyLocBo(); + assingEmptyLocBo.setBusinDataTaskGoodsVos(businDataTaskGoodsVoList); + assingEmptyLocBo.setAreaId(abnormalArea); + Result locationVoResult = iBaseLocationService.assignEmptyLocatioError(assingEmptyLocBo); + if (Result.isOk(locationVoResult)){ + locationVo = locationVoResult.getData(); + } + businDataTaskVo.setToColumn(locationVo.getLocationColumn()); + businDataTaskVo.setToLayer(locationVo.getLayer()); + businDataTaskVo.setToRow(locationVo.getLocationRow()); + businDataTaskVo.setLocationId(locationVo.getId()); + //获取货位及巷道; + String tunnel = locationVo.getTunnel(); + businDataTaskVo.setTunnel(tunnel); + pointQueryBo = new BasePointDeviceQueryBo(); + pointQueryBo.setTunnel(tunnel); + pointQueryBo.setDirection("0"); + basePointDeviceVos = baseLocationPlcMapper.selectBasePointByGroupno(pointQueryBo); + if (basePointDeviceVos.size() > 0) { + basePointDeviceVo = basePointDeviceVos.get(0); + } + //获取巷道对应的堆垛机信息 + pointQueryBo.setDevType("1"); + BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointQueryBo); + stkPlcId = baseDevicePlcVo.getPlcId(); + plcId =Long.valueOf(isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.LK_plc_id)); + toPointNo = basePointDeviceVo.getPointNo(); + snPointMap.put("3",toPointNo); + points.add(toPointNo); + } + } else { + agvTaskType = 33; + basePointDeviceVo = basePointDeviceVos.get(0); + toPointNo = basePointDeviceVo.getPointNo(); + snPointMap.put("3", "XX"); + points.add("XX"); + snPointMap.put("4", "XX"); + points.add("XX"); + snPointMap.put("5", toPointNo); + points.add(toPointNo); + } + businDataTaskVo.setPoints(JsonUtil.toJSONString(snPointMap)); + businDataTaskVo.setIsDown(String.valueOf(agvTaskType)); + + Result booleanResult; + //呼叫AGV + if (StringUtils.isNotEmpty(businDataTaskVo.getAgvNo())) { + booleanResult = callAGV(taskId, agvTaskType, points, businDataTaskVo.getAgvNo()); + } else { + booleanResult = callAGV(taskId, agvTaskType, points); + } + if (booleanResult.getCode() == HttpStatus.ERROR.getCode()) { + BusinDataTask businDataTask = new BusinDataTask(); + businDataTask.setId(businDataTaskVo.getId()); + businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); + businDataTask.setTaskPath(toPointNo); + iBusinDataTaskService.updateById(businDataTask); + return; + } + //呼叫AGV成功 + if (booleanResult.getCode() == HttpStatus.SUCCESS.getCode()) { + businDataTaskVo.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); + businDataTaskVo.setTaskPath(toPointNo); + if (NUMBER) { + BasePoint basePoint = iBasePointService.getById(basePointDeviceVo.getPointId()); + basePoint.setIsOccupy("1"); + iBasePointService.updateById(basePoint); + } + } + //更新入库条码表状态为异常 + List barcodesIns = new ArrayList<>(); + List goodsVos = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(taskId); + for (BusinDataTaskGoodsVo goodsVo : goodsVos) { + BaseBarcodesIn baseBarcodesIn = iBaseBarcodesInService.getOne(new LambdaQueryWrapper() + .eq(BaseBarcodesIn::getQrCode, goodsVo.getQrCode()) + ); + baseBarcodesIn.setInStatus("4"); + baseBarcodesIn.setInDate(DateUtils.getDate()); + barcodesIns.add(baseBarcodesIn); + } + iBaseBarcodesInService.saveOrUpdateBatch(barcodesIns); + businDataTaskVo.setDpsNoOne(plcId); + businDataTaskVo.setDpsNoTwo(stkPlcId); + businDataTaskVo.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); + iBusinDataTaskService.updateById(BeanUtil.toBean(businDataTaskVo, BusinDataTask.class)); + } } } diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/IBaseLocationService.java b/shkj-wms/src/main/java/com/shkj/wms/service/IBaseLocationService.java index e68a410..cf67744 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/IBaseLocationService.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/IBaseLocationService.java @@ -167,6 +167,14 @@ public interface IBaseLocationService extends IService { Result assignEmptyLocatioPunching(AssingEmptyLocBo assingEmptyLocBo); + /** + * 异常杠分配货位 + * @param assingEmptyLocBo + * @return + */ + Result assignEmptyLocatioError(AssingEmptyLocBo assingEmptyLocBo); + + /** * 检查货位是否有对应双深位 * diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseLocationServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseLocationServiceImpl.java index c42b430..a620fba 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseLocationServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseLocationServiceImpl.java @@ -814,6 +814,12 @@ public class BaseLocationServiceImpl extends ServiceImpl assignEmptyLocationAll(AssingEmptyLocBo assingEmptyLocBo, String lcoatinTunnel) { BaseLocationVo locationVo = null; @@ -1054,6 +1060,7 @@ public class BaseLocationServiceImpl extends ServiceImpl baseLocationVos = this.baseMapper.queryBaseLocationListByGoodsPunching(bo); if (baseLocationVos.size() == 0) { @@ -1166,6 +1173,132 @@ public class BaseLocationServiceImpl extends ServiceImpl assignEmptyLocatioError(AssingEmptyLocBo assingEmptyLocBo) { + List businDataTaskGoodsVos = assingEmptyLocBo.getBusinDataTaskGoodsVos(); + String goodsNo = ""; + String vehicheModel = assingEmptyLocBo.getVehicheModel(); + String batch = assingEmptyLocBo.getBatch(); + + BaseLocationVo locationVo = null; + /* if (businDataTaskGoodsVos != null && businDataTaskGoodsVos.size() > 0) { + BusinDataTaskGoodsVo businDataTaskGoodsVo = businDataTaskGoodsVos.get(0); + String taskCode = businDataTaskGoodsVo.getTaskCode(); + goodsNo = businDataTaskGoodsVo.getGoodsNo(); + log.info("异常入库分配货位任务号:" + taskCode + " 保险杠编号:" + goodsNo); + } else { + return Result.err().msg("无保险杠信息"); + }*/ + BaseLocationQueryListBo bo = new BaseLocationQueryListBo(); + // bo.setGoodsNo(goodsNo); + bo.setLocationStatus("0"); + bo.setAreaId(assingEmptyLocBo.getAreaId()); + log.info("异常保险杠分配货位查询条件:" + JsonUtil.toJSONString(bo)); + List baseLocationVos = this.baseMapper.queryBaseLocationListByGoodsPunching(bo); + if (baseLocationVos.size() == 0) { + //查看缓冲区是否还有货位 + Long bufferArea = Long.valueOf(sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.buffer_area)); + List baseLocationVoList = baseLocationMapper.getLocationByAreaId(bufferArea); + log.info("异常保险杠保险杠缓冲区分配到的货位信息:" + baseLocationVoList.size()); + if (baseLocationVoList.size() < 0) { + log.info("异常保险杠车型及缓冲区都未查询到空货位"); + return Result.err().msg("异常保险杠保险杠分配货位暂无空货位可用"); + } + baseLocationVos = baseLocationVoList; + } + + //拿到所有可用货位,根据巷道号对双深位的巷道进行处理 + //空货位所在巷道列表,同时过滤掉已有入库任务的巷道 + List tunnelList = baseLocationVos.stream().map(e -> e.getTunnel()).distinct().collect(Collectors.toList()); + log.info("异常保险杠分配货位查询到的货位对应的巷道信息:" + JsonUtil.toJSONString(tunnelList)); + //从存在空货位的巷道里选择较优的巷道进行入库 + //首选选择任务数为空或者任务数最少的巷道 + //任务数相同时选取空货位最多的巷道;24.06.27改为查询库存数量最少并且空货位数最多的 + List tunnelResult = new ArrayList<>(); + Integer minTaskNum = 0; + Integer maxEmptyLocationNum = 0; + Integer minGoodsQty = 0; + for (int i = 0; i < tunnelList.size(); i++) { + String tunnel = tunnelList.get(i); + Integer taskNum = tunnelTaskUtil.getTotalTaskNum(tunnel, 0); + List currTunnelLocationVos = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()); + int curEmptyNum = currTunnelLocationVos.size(); + BaseLocationVo baseLocationVo = currTunnelLocationVos.get(0); + int currGoodsQty = 0; + if (baseLocationVo.getGoodQty() != null) { + currGoodsQty = baseLocationVo.getGoodQty(); + } + //获取巷道内库存数量最少并且空货位数最多的 + log.info("异常保险杠分配之前----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum + " 当前库存量:" + currGoodsQty); + if (minTaskNum == 0 && taskNum.equals(minTaskNum)) { + if (i != 0) { + if (currGoodsQty < minGoodsQty) { + minGoodsQty = currGoodsQty; + if (curEmptyNum > maxEmptyLocationNum) { + tunnelResult.clear(); + tunnelResult.add(tunnel); + maxEmptyLocationNum = curEmptyNum; + } + } + } else { + minGoodsQty = currGoodsQty; + minTaskNum = taskNum; + tunnelResult.add(tunnel); + maxEmptyLocationNum = curEmptyNum; + } + } else if (minTaskNum == 0) { + if (i == 0) { + minGoodsQty = currGoodsQty; + minTaskNum = taskNum; + tunnelResult.add(tunnel); + maxEmptyLocationNum = curEmptyNum; + } + } else if (minTaskNum != 0 && taskNum.equals(minTaskNum)) { + if (currGoodsQty < minGoodsQty) { + minGoodsQty = currGoodsQty; + if (curEmptyNum > maxEmptyLocationNum) { + tunnelResult.clear(); + tunnelResult.add(tunnel); + maxEmptyLocationNum = curEmptyNum; + } + } + } else if (minTaskNum != 0 && taskNum < minTaskNum) { + minGoodsQty = currGoodsQty; + minTaskNum = taskNum; + tunnelResult.clear(); + tunnelResult.add(tunnel); + maxEmptyLocationNum = curEmptyNum; + } + log.info("保险杠分配之后----当前巷道:" + tunnel + " 目前任务数:" + taskNum + " 当前空货位数量:" + curEmptyNum + " 最小任务数:" + minTaskNum + " 最大空货位数:" + maxEmptyLocationNum + " 当前库存量:" + currGoodsQty); + } + + log.info("异常杠巷道的任务数量:" + JsonUtil.toJSONString(tunnelResult)); + //从选取的巷道中选择库位 + if (tunnelResult.size() > 0) { + String tunnel = tunnelResult.get(0); + List resultLocationList = baseLocationVos.stream().filter(e -> tunnel.equals(e.getTunnel())).collect(Collectors.toList()); + locationVo = resultLocationList.get(0); + log.info("异常杠分配的货位:" + JsonUtil.toJSONString(locationVo)); + //巷道中货位数大于1时,进行分配 + if (resultLocationList.size() > 0) { + //判断是否是双深位相关 + BaseLocationVo assginLocation = assginLocation(resultLocationList, batch, vehicheModel, businDataTaskGoodsVos); + if (assginLocation != null) { + locationVo = assginLocation; + log.info("最终分配的货位信息:" + assginLocation); + } + } + } + if (locationVo != null) { + //确定分配该库位,并将库位状态改为已分配 + this.changeLocationStatus(locationVo.getId(), "4"); + locationVo.setLocationStatus("4"); + return Result.ok().data(locationVo); + } else { + return Result.err(); + } + } + /** * 保险杠分配货位检查是否是双深位 * @@ -1205,8 +1338,6 @@ public class BaseLocationServiceImpl extends ServiceImpl baseInventoryRatioList = baseInventoryRatioService.getInfoByvehicheModel(model); //获取下料点点位 - String taskCode = "T_" + DateUtils.dateTimeNow(); + String transId = com.shkj.common.utils.uuid.UUID.randomUUID().toString(); BusinTaskAddBo businTaskAddBo =new BusinTaskAddBo(); - businTaskAddBo.setTaskCode(taskCode); businTaskAddBo.setPlcId(plcIP); businTaskAddBo.setTaskStatus(TaskStatusEnum.wait_put.getValue()); businTaskAddBo.setCreateTime(DateUtils.getNowDate()); diff --git a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml index a0577f5..b1999b2 100644 --- a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml +++ b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml @@ -577,8 +577,10 @@ WHERE bl.is_del = '0' AND ba.is_del = '0' - AND bs.is_del = '0' and bl.area_id =17 - + AND bs.is_del = '0' + + and bl.area_id = #{areaId} + and ifnull(bl.location_status,'0') = #{locationStatus}