Ver Fonte

加入入库缓存任务

dfsfs há 1 ano atrás
pai
commit
466164129d

+ 57 - 3
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -250,7 +250,7 @@ public class BusinessServiceImpl implements IBusinessService {
                     List<BaseLocationInfo> locationToList = this.convertLocation(paramLocationTo, agvCallDTO.getWarehouseId(), null);
 
                     // 如果是从仓储区出库的任务 检查同列是否有未完成的其它类型任务
-                    if (flowConfigHeaderVO.getId().equals(Long.valueOf("14")) || flowConfigHeaderVO.getId().equals(Long.valueOf("15"))) {
+                    if (flowConfigHeaderVO.getId().equals(Constant.FLOW_CONFIG_ID.FOURTEEN.getValue()) || flowConfigHeaderVO.getId().equals(Constant.FLOW_CONFIG_ID.FIFTEEN.getValue())) {
                         Assert.isTrue(checkWcsSameColumnNotFinish(locationFromListEnd, "SO"), "同列有未完成的入库任务");
                     }
 
@@ -476,15 +476,25 @@ public class BusinessServiceImpl implements IBusinessService {
             if (type.equals("ASN") && !flowId.equals(Long.valueOf("8"))
                                     && !flowId.equals(Long.valueOf("11"))
                                     && !flowId.equals(Long.valueOf("16"))) {
-                // 不判断同列任务和阻挡情况
+                // 入库目标点不判断同列任务和阻挡情况
                 locationInfo = checkTheSameColumnLocationASN(locationInfoList, token, true);
             } else {
                 locationInfo = checkTheSameColumnLocation(locationInfoList, token, true);
             }
             if (locationInfo == null) {
+                // 如果是从仓储区出库的任务 即使出库目标点位都暂时无法分配 但是该任务需要先下发 然后autoSend中再临时分配
+                if (type.equals("SO") && (flowId.equals(Constant.FLOW_CONFIG_ID.FOURTEEN.getValue()) || flowId.equals(Constant.FLOW_CONFIG_ID.FIFTEEN.getValue()))){
+                    BaseLocationInfo locationTo = new BaseLocationInfo();
+                    // 设置待分配标识 999表示需要后续分配
+                    locationTo.setId(999l);
+                    locationTo.setZoneId(999l);
+                    log.info("=======出库接驳位暂时无库位可分配,产生缓存任务,{}",new Date());
+                    return locationTo;
+                }
                 if (type.equals("ASN")) { // 入库
                     toMsg = "目标点没有可以分配的库位";
                 } else if (type.equals("SO")) { // 出库
+
                     toMsg = "目标点没有可以分配的库位";
                 } else { //移库
                     toMsg = "目标点没有可以分配的库位";
@@ -730,7 +740,8 @@ public class BusinessServiceImpl implements IBusinessService {
         if (!StringUtils.isEmpty(wcsTask.getLocationFrom())) {
             baseLocationInfoService.updateLocationStockStatus(Long.parseLong(wcsTask.getLocationFrom()), Constant.STOCK_STATUS.STOCK10.getValue());
         }
-        if (!StringUtils.isEmpty(wcsTask.getLocationTo())) {
+        // 如果目标库位不是需要再次分配的 就锁定库位
+        if (!StringUtils.isEmpty(wcsTask.getLocationTo()) && !wcsTask.getLocationTo().equals("999")) {
             baseLocationInfoService.updateLocationStockStatus(Long.parseLong(wcsTask.getLocationTo()), Constant.STOCK_STATUS.STOCK10.getValue());
         }
 
@@ -870,6 +881,7 @@ public class BusinessServiceImpl implements IBusinessService {
                             && (wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.FOURTEEN.getValue()))
                             || wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.FIFTEEN.getValue())))) {
                         log.info("出库任务下发AMS调用AGV{}", JSON.toJSONString(wcsTask));
+
                         // 根据起始地查询库位信息
                         BaseLocationInfo baseLocationInfo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(wcsTask.getLocationFrom(), Constant.WAREHOUSE_ID);
                         // 同列外方是否有任务
@@ -884,6 +896,10 @@ public class BusinessServiceImpl implements IBusinessService {
                             log.info("同列有阻挡=========={}", inStockByLocs);
                             continue;
                         }
+                        // 判断当前出库任务是否有未分配目标库位,是的话分配目标点位
+                        if (wcsTask.getLocationTo().equals("999")){
+                            if (allocationLocationTo(wcsTask)) continue;
+                        }
                     } else if (StringUtils.isNotEmpty(wcsTask.getExt7()) // 判断如果是入库且到仓储区的任务
                             && (wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.NINE.getValue()))
                             || wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.TEN.getValue()))
@@ -924,8 +940,46 @@ public class BusinessServiceImpl implements IBusinessService {
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
+            }
+        }
+    }
 
+    /**
+     * 为没有分配目标库位的出库任务重新分配目标库位
+     * @param wcsTask
+     * @return
+     */
+    private boolean allocationLocationTo(WcsTask wcsTask) {
+        try {
+            FlowConfigHeaderVO flowConfigHeaderVO = flowConfigHeaderService.selectFlowConfigHeaderById(Long.valueOf(wcsTask.getExt7()));
+            // 查询目标区域的所有库位
+            List<BaseLocationInfo> locationToList = new ArrayList<>();
+            if (!StringUtils.isEmpty(flowConfigHeaderVO.getLocationTo())) {
+                String[] zoneIds = flowConfigHeaderVO.getLocationTo().split(",");
+                for (String zoneId : zoneIds) {
+                    List<BaseLocationInfo> infoList = baseLocationInfoService.selectSortedLocatinListByZoneId(Long.parseLong(zoneId), Constant.WAREHOUSE_ID, null);
+                    locationToList.addAll(infoList);
+                }
             }
+            Assert.isTrue(locationToList.size()>0, "目标区域没有库位");
+
+            // 重新分配目标点位
+            BaseLocationInfo locationTo = this.checkTheSameColumnLocation(locationToList, Long.valueOf(wcsTask.getExt8()), true);
+            // 没有分配到目标库位
+            if (locationTo == null){
+                return true;
+            }
+            wcsTask.setAreaTo(flowConfigHeaderVO.getLocationTo());
+            wcsTask.setLocationTo(locationTo.getId().toString());
+            // 更改任务的目标库位
+            wcsTaskService.updateWcsTask(wcsTask);
+            // 更改目标库位状态为占用(有任务)
+            baseLocationInfoService.updateLocationStockStatus(Long.parseLong(wcsTask.getLocationTo()), Constant.STOCK_STATUS.STOCK10.getValue());
+            return false;
+        } catch (Exception e) {
+            log.error("任务下发失败!", e);
+            redisCache.unlockCacheObject(Long.valueOf(wcsTask.getExt8())); // 异常捕获的话要释放锁
+            throw new ServiceException(e.getMessage(), Long.valueOf(wcsTask.getExt8()));
         }
     }