Преглед изворни кода

Merge remote-tracking branch 'origin/jnmc-jinco' into jnmc-jinco

star пре 1 година
родитељ
комит
b822b27dae

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/nieyan/controller/pda/PdaAgvCallController.java

@@ -295,7 +295,7 @@ public class PdaAgvCallController {
             return AjaxResult.error("起始库位为空!");
         }
         String locationFrom = agvCallForm.getLocationFrom();
-        String locationTo = agvCallForm.getLocationTo();
+        String locationTo = agvCallForm.getLocationTo(); // null 待分配
         String createUser = agvCallForm.getCreateUser();
         return agvCallProxyService.productsOutboundLSN(locationFrom, locationTo, createUser);
     }

+ 218 - 53
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -148,18 +148,81 @@ public class BusinessServiceImpl implements IBusinessService {
                 }
 
                 if (flowConfigHeaderVO.getFlowType().equals("ASN")) {
-                    // 判断队列中是否有未完成的出库任务
-                    BaseLocationInfo baseLocInfo = baseLocationInfoMapper.selectBaseLocationInfoById(Long.parseLong(paramLocationFrom));
-                    boolean isFinish = checkWcsSameColumnNotFinish(baseLocInfo.getColNo(), baseLocInfo.getColIndex(), baseLocInfo.getZoneId(),"ASN");
-                    if (!isFinish){
-                        throw new ServiceException("当前列有未完成的出库任务");
-                    }
 
                     List<BaseLocationInfo> locationFromList = this.convertLocation(paramLocationFrom, agvCallDTO.getWarehouseId(), null);
-                    //
                     List<BaseLocationInfo> locationToList = this.convertLocation(paramLocationTo, agvCallDTO.getWarehouseId(), null);
-                    locationFrom = this.zoneLocationAllocation(locationFromList, "locationFrom", "ASN", asnSoStrategy, token);
-                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "ASN", asnSoStrategy, token);
+
+                    // 如果是废料入库 需要判断同列是否有出库任务
+                    if (flowConfigHeaderVO.getId().equals(Long.valueOf("4"))
+                            || flowConfigHeaderVO.getId().equals(Long.valueOf("6"))) {
+                        String currentColNo = null;// 当前列
+                        Long currentZoneId = null; // 当前库区
+                        List<BaseLocationInfo> locationInfos = new ArrayList();
+                        for (BaseLocationInfo baseLocationInfo : locationToList) {
+                            // 如果当前库位的列和库区和标记的列和库区相同 跳过当前库位
+                            if (baseLocationInfo.getColNo().equals(currentColNo) && baseLocationInfo.getZoneId().equals(currentZoneId)) {
+                                continue;
+                            }
+                            boolean hasDiff = checkCurrentColumnDiffTaskType(baseLocationInfo, null);
+                            // 同列有未完成的其他类型任务
+                            if (hasDiff){
+                                // 记录当前库位区域和列id
+                                currentColNo = baseLocationInfo.getColNo();
+                                currentZoneId = baseLocationInfo.getZoneId();
+                                continue;
+                            }else {
+                                locationInfos.add(baseLocationInfo);
+                            }
+                        }
+                        locationToList = locationInfos;
+                    }
+
+                    // 如果是成品入库任务需要进行判断班组信息和同列是否有出库任务
+                    if (flowConfigHeaderVO.getId().equals(Long.valueOf("9")) || flowConfigHeaderVO.getId().equals(Long.valueOf("10"))
+                            || flowConfigHeaderVO.getId().equals(Long.valueOf("12"))
+                            || flowConfigHeaderVO.getId().equals(Long.valueOf("13"))) {
+                        // 查询同班组的库存
+                        String team = agvCallDTO.getTeamNo();
+                        List<BaseLocationInfo> locationInfos = new ArrayList();
+                        String currentColNo = null;// 当前列
+                        Long currentZoneId = null; // 当前库区
+                        for (BaseLocationInfo baseLocationInfo : locationToList) {
+                            // 如果当前库位的列和库区和标记的列和库区相同 跳过当前库位
+                            if (baseLocationInfo.getColNo().equals(currentColNo) && baseLocationInfo.getZoneId().equals(currentZoneId)) {
+                                continue;
+                            }
+                            // 标记当前列是否可分配
+                            Boolean columnAvailable = true;
+                            // 查询当前库位的库存包含批次属性
+                            List<InvLotLocIdLotattVO> invLotLocIdLotattVOS = invLotLocIdService.selectInvLocIdLotattByLocationId(baseLocationInfo.getId());
+                            for (InvLotLocIdLotattVO invLotLocIdLotattVO : invLotLocIdLotattVOS) {
+                                // 当前库存某列有不同班组
+                                if (Objects.nonNull(invLotLocIdLotattVO) && !invLotLocIdLotattVO.getLotatt09().equals(team)) {
+                                    // 标记当前列不分配
+                                    columnAvailable = false;
+                                    currentColNo = baseLocationInfo.getColNo();
+                                    currentZoneId = baseLocationInfo.getZoneId();
+                                    log.info("==========当前库位有不同班组批次{}{}", baseLocationInfo, invLotLocIdLotattVO.getLotatt09());
+                                    break;
+                                }
+                            }
+                            if (columnAvailable) {
+                                // 检查同列是否有不同班组的库存
+                                boolean hasDiff = checkCurrentColumnDiffTaskType(baseLocationInfo, team);
+                                if (hasDiff){
+                                    currentColNo = baseLocationInfo.getColNo();
+                                    currentZoneId = baseLocationInfo.getZoneId();
+                                    continue;
+                                }else {
+                                    locationInfos.add(baseLocationInfo);
+                                }
+                            }
+                        }
+                        locationToList = locationInfos;
+                    }
+
+                    locationFrom = this.zoneLocationAllocation(locationFromList, "locationFrom", "ASN", asnSoStrategy, token, flowConfigHeaderVO.getId());
+                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "ASN", asnSoStrategy, token, flowConfigHeaderVO.getId());
                     // 初始化库存
                     if (agvCallDTO.getAgvCallItemDTOList().size() > 0) {
                         iInvLotAttService.deleteInvLotAttBylocationId(locationFrom.getId());
@@ -170,13 +233,6 @@ public class BusinessServiceImpl implements IBusinessService {
 
                 } else if (flowConfigHeaderVO.getFlowType().equals("SO")) {
 
-                    // 判断同列中是否有未完成的入库任务
-                    BaseLocationInfo baseLocInfo = baseLocationInfoMapper.selectBaseLocationInfoById(Long.parseLong(paramLocationFrom));
-                    boolean isFinish = checkWcsSameColumnNotFinish(baseLocInfo.getColNo(), baseLocInfo.getColIndex(), baseLocInfo.getZoneId(),"SO");
-                    if (!isFinish){
-                        throw new ServiceException("当前列有未完成的入库任务");
-                    }
-
                     List<BaseLocationInfo> locationFromListEnd = new ArrayList<>();
                     boolean isLocation = baseLocationInfoService.checkIsLocation(paramLocationFrom, Constant.WAREHOUSE_ID);
                     if (isLocation) {
@@ -192,15 +248,21 @@ public class BusinessServiceImpl implements IBusinessService {
                         locationFromListEnd = locationFromList;
                     }
                     List<BaseLocationInfo> locationToList = this.convertLocation(paramLocationTo, agvCallDTO.getWarehouseId(), null);
-                    locationFrom = this.zoneLocationAllocation(locationFromListEnd, "locationFrom", "SO", asnSoStrategy, token);
-                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "SO", asnSoStrategy, token);
+
+                    // 如果是从仓储区出库的任务 检查同列是否有未完成的其它类型任务
+                    if (flowConfigHeaderVO.getId().equals(Long.valueOf("14")) || flowConfigHeaderVO.getId().equals(Long.valueOf("15"))) {
+                        Assert.isTrue(checkWcsSameColumnNotFinish(locationFromListEnd, "SO"), "同列有未完成的入库任务");
+                    }
+
+                    locationFrom = this.zoneLocationAllocation(locationFromListEnd, "locationFrom", "SO", asnSoStrategy, token, flowConfigHeaderVO.getId());
+                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "SO", asnSoStrategy, token, flowConfigHeaderVO.getId());
                     wcsTaskList.addAll(this.genTask(locationFrom, locationTo, flowConfigHeaderVO, agvCallDTO, token));
 
                 } else if (flowConfigHeaderVO.getFlowType().equals("MV")) {
                     List<BaseLocationInfo> locationFromList = this.convertLocation(paramLocationFrom, agvCallDTO.getWarehouseId(), null);
                     List<BaseLocationInfo> locationToList = this.convertLocation(paramLocationTo, agvCallDTO.getWarehouseId(), null);
-                    locationFrom = this.zoneLocationAllocation(locationFromList, "locationFrom", "MV", asnSoStrategy, token);
-                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "MV", asnSoStrategy, token);
+                    locationFrom = this.zoneLocationAllocation(locationFromList, "locationFrom", "MV", asnSoStrategy, token, flowConfigHeaderVO.getId());
+                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "MV", asnSoStrategy, token, flowConfigHeaderVO.getId());
                     // 初始化库存
                     if (agvCallDTO.getAgvCallItemDTOList().size() > 0) {
                         iInvLotAttService.deleteInvLotAttBylocationId(locationFrom.getId());
@@ -219,29 +281,67 @@ public class BusinessServiceImpl implements IBusinessService {
     }
 
     /**
-     * 检查同列的未完成任务类型是否与当前任务类型一致
-     * @param colNo
-     * @param colIndex
-     * @param zoneId
-     * @param type 任务类型
+     * 入库检查同列是否有出库类型(且不同班组)的任务
+     * @param baseLocationInfo
      * @return
      */
-    public boolean checkWcsSameColumnNotFinish(String colNo, Long colIndex, Long zoneId,String type){
+    public boolean checkCurrentColumnDiffTaskType(BaseLocationInfo baseLocationInfo,String team){
+        log.info("============检查入库任务同列的未完成任务类型及班组是否与当前任务类型一致");
+        // 判断当前库位同列是否有不同类型任务
+        List<BaseLocationInfo> blsList = baseLocationInfoService.selectWcsSameColumnAndTeamNotFinish(baseLocationInfo.getColNo(),
+                team, baseLocationInfo.getZoneId(), Constant.WAREHOUSE_ID, "ASN");
+        // 当前列有不同类型未完成任务 继续遍历下一库位
+        if (blsList != null && blsList.size() > 0) {
+            log.info("==========当前库位同列有未完成的出库任务,库位编号:{},列:{}", baseLocationInfo.getId(), baseLocationInfo.getColNo());
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 出库检查同列的未完成任务类型是否与当前任务类型一致
+     *
+     * @param baseLocationInfoList
+     * @param type
+     * @return
+     */
+    public Boolean checkWcsSameColumnNotFinish(List<BaseLocationInfo> baseLocationInfoList, String type) {
         log.info("检查同列的未完成任务类型是否与当前任务类型一致============");
-        // 查询任务状态不为2(完成),6(卸货完成),7(取消)的同列任务
-        List<WcsTask> wcsTaskList = wcsTaskService.selectWcsSameColumnNotFinish(colNo, colIndex, zoneId,Constant.WAREHOUSE_ID);
-        if (wcsTaskList != null && wcsTaskList.size()>0){
-            for(WcsTask wcsTask : wcsTaskList){
-                FlowConfigHeaderVO flowConfigHeaderVO = flowConfigHeaderService.selectFlowConfigHeaderById(Long.valueOf(wcsTask.getExt7()));
-                if (Objects.nonNull(flowConfigHeaderVO) && !flowConfigHeaderVO.getFlowType().equals(type)){
-                    log.info("同列的未完成任务类型与当前任务类型不同{}====",wcsTask);
-                    return false;
-                }
+        for (BaseLocationInfo locationInfo : baseLocationInfoList) {
+            // 查询任务状态不为2(完成),6(卸货完成),7(取消)的同列任务
+            List<BaseLocationInfo> blsList = baseLocationInfoService.selectWcsSameColumnNotFinish(locationInfo.getColNo(),
+                    locationInfo.getColIndex(), locationInfo.getZoneId(), Constant.WAREHOUSE_ID, type);
+            // 如果同列有不同类型的未完成任务
+            if (blsList != null && blsList.size() > 0) {
+                log.info("==========当前库位同列有未完成的入库任务,库位编号:{},列:{}", locationInfo.getId(), locationInfo.getColNo());
+                return false;
             }
         }
         return true;
     }
 
+    /**
+     * 检查同列的未完成任务类型及班组是否与当前任务类型一致
+     *
+     * @param baseLocationInfoList
+     * @param type
+     * @return
+     */
+    public List<BaseLocationInfo> checkWcsSameColumnAndTeamNotFinish(List<BaseLocationInfo> baseLocationInfoList, String type, String team) {
+        log.info("检查同列的未完成任务类型及班组是否与当前任务类型一致============");
+        List<BaseLocationInfo> resultList = new ArrayList<>();
+        for (BaseLocationInfo locationInfo : baseLocationInfoList) {
+            // 查询任务状态不为2(完成),6(卸货完成),7(取消)的同列任务
+            List<BaseLocationInfo> blsList = baseLocationInfoService.selectWcsSameColumnAndTeamNotFinish(locationInfo.getColNo(),
+                    team, locationInfo.getZoneId(), Constant.WAREHOUSE_ID, type);
+            // 如果同列有不同类型的未完成任务
+            if (blsList != null && blsList.size() > 0) {
+                resultList.addAll(blsList);
+            }
+        }
+        return resultList;
+    }
+
     @Transactional
     @Override
     public BaseLocationInfo inLocationAllocation(InWarehouseDTO inWarehouseDTO, Long token) {
@@ -335,7 +435,7 @@ public class BusinessServiceImpl implements IBusinessService {
 
     @Override
     public BaseLocationInfo zoneLocationAllocation(List<BaseLocationInfo> locationInfoList, String locationType
-            , String type, AsnSoStrategy asnSoStrategy, Long token) {
+            , String type, AsnSoStrategy asnSoStrategy, Long token, Long flowId) {
         BaseLocationInfo locationInfo = null;
         String fromMsg = "";
         String toMsg = "";
@@ -354,10 +454,10 @@ public class BusinessServiceImpl implements IBusinessService {
         }
         if (locationType.equals("locationFrom")) {
 
-            // 如果是出库 调用无需判断阻挡的方法
-            if (type.equals("SO")){
+            // 如果是从仓储区出库 调用无需判断阻挡的方法
+            if (type.equals("SO") && (flowId.equals(Long.valueOf("14")) || flowId.equals(Long.valueOf("15")))) {
                 locationInfo = checkTheSameColumnLocationSO(locationInfoList, token);
-            }else {
+            } else {
                 locationInfo = checkTheSameColumnLocation(locationInfoList, token, false);
             }
 
@@ -372,8 +472,15 @@ public class BusinessServiceImpl implements IBusinessService {
                 throw new ServiceException(fromMsg, token);
             }
         } else {
-
-            locationInfo = checkTheSameColumnLocation(locationInfoList, token, true);
+            // 是到仓储区的入库任务
+            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) {
                 if (type.equals("ASN")) { // 入库
                     toMsg = "目标点没有可以分配的库位";
@@ -388,6 +495,37 @@ public class BusinessServiceImpl implements IBusinessService {
         return locationInfo;
     }
 
+    /**
+     * 入库判断目标点位
+     *
+     * @param locationInfoList
+     * @param token
+     * @param isReleaseGoods
+     * @return
+     */
+    private BaseLocationInfo checkTheSameColumnLocationASN(List<BaseLocationInfo> locationInfoList, Long token, boolean isReleaseGoods) {
+        BaseLocationInfo basLocation = null;
+        //筛选2次 第2次去除同列占用和阻挡条件 todo 先筛选一次吧
+        for (int i = 0; i < 1 && basLocation == null; i++) {
+            for (BaseLocationInfo location : locationInfoList) {
+                // 目标点位必须空闲、空且没有被锁住
+                if (!location.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())
+                        || !location.getIsEmpty().equals(Constant.IS_YES.Y.name())
+                        || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + location.getId())) {
+                    continue;
+                }
+                if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + location.getId()
+                        , location.getId().toString()
+                        , token)) {
+                    continue;
+                }
+                basLocation = location;
+                break;
+            }
+        }
+        return basLocation;
+    }
+
     /**
      * 校验同列任务任务状态和阻挡
      *
@@ -412,13 +550,13 @@ public class BusinessServiceImpl implements IBusinessService {
                     //同列是否有任务
                     List<BaseLocationInfo> occupyByLocs = baseLocationInfoMapper.queryByListOccupyByLoc(location);
                     if (occupyByLocs.size() > 0) {
-                        log.info("同列有任务=========={}",occupyByLocs);
+                        log.info("同列有任务=========={}", occupyByLocs);
                         continue;
                     }
                     //同列前方是否有阻挡
                     List<BaseLocationInfo> inStockByLocs = baseLocationInfoMapper.queryByListInStockByLoc(location);
                     if (inStockByLocs.size() > 0) {
-                        log.info("同列有阻挡=========={}",inStockByLocs);
+                        log.info("同列有阻挡=========={}", inStockByLocs);
                         continue;
                     }
                 }
@@ -449,6 +587,7 @@ public class BusinessServiceImpl implements IBusinessService {
 
     /**
      * AGV出库任务生成时的起始位置不判断是否阻挡
+     *
      * @param basLocationList
      * @param token
      * @return
@@ -656,7 +795,7 @@ public class BusinessServiceImpl implements IBusinessService {
     public AjaxResult sendTask(WcsTask wcsTask) {
         BaseLocationInfo locFrom = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(wcsTask.getLocationFrom(), Constant.WAREHOUSE_ID);
         BaseLocationInfo locTo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(wcsTask.getLocationTo(), Constant.WAREHOUSE_ID);
-        log.info("进入AMS任务下发=========={}",wcsTask);
+        log.info("进入AMS任务下发=========={}", wcsTask);
         AmsTask amsTask = new AmsTask();
         amsTask.setTaskNo(wcsTask.getTaskNo());
         if (wcsTask.getBusinessType() == null || wcsTask.getBusinessType().equals("")) {
@@ -671,11 +810,11 @@ public class BusinessServiceImpl implements IBusinessService {
         amsTask.setExt1(wcsTask.getExt1());
         amsTask.setExt2(wcsTask.getExt2());
         amsTask.setExt3(wcsTask.getExt3());
-        if(wcsTask.getBusinessType().equals(Constant.TASK_BUSINESS_TYPE.TASK_POWER.getValue())){
+        if (wcsTask.getBusinessType().equals(Constant.TASK_BUSINESS_TYPE.TASK_POWER.getValue())) {
             amsTask.setStFrom(Integer.valueOf(wcsTask.getLocationFrom()));
             amsTask.setStTo(Integer.valueOf(wcsTask.getLocationTo()));
             amsTask.setDeviceName(wcsTask.getDeviceName());
-        }else{
+        } else {
             amsTask.setStFrom(locFrom.getAgvStation().intValue());
             amsTask.setStTo(locTo.getAgvStation().intValue());
         }
@@ -725,34 +864,59 @@ public class BusinessServiceImpl implements IBusinessService {
                 //转发任务
                 if (StringUtils.isNotEmpty(wcsTask.getTaskType())
                         && wcsTask.getTaskType().equals(Constant.TASK_TYPE.FORWARD.getValue())) {
-                    log.info("进入转发任务{}=={}========", wcsTask.getTaskType(),wcsTask.getExt7());
+                    log.info("进入转发任务{}=={}========", wcsTask.getTaskType(), wcsTask.getExt7());
                     // 判断如果是出库任务
                     if (StringUtils.isNotEmpty(wcsTask.getExt7())
                             && (wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.FOURTEEN.getValue()))
-                            || wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.FIFTEEN.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);
-                        //同列是否有任务
+                        // 同列外方是否有任务
                         List<BaseLocationInfo> occupyByLocs = baseLocationInfoMapper.queryByListOccupyByLoc(baseLocationInfo);
                         if (occupyByLocs.size() > 0) {
-                            log.info("同列有任务=========={}",occupyByLocs);
+                            log.info("同列外面有任务=========={}", occupyByLocs);
+                            continue;
+                        }
+                        //同列前方是否有阻挡
+                        List<BaseLocationInfo> inStockByLocs = baseLocationInfoMapper.queryByListInStockByLoc(baseLocationInfo);
+                        if (inStockByLocs.size() > 0) {
+                            log.info("同列有阻挡=========={}", inStockByLocs);
                             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()))
+                            || wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.TWELVE.getValue()))
+                            || wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.THIRTEEN.getValue()))
+                            || wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.FOUR.getValue()))
+                            || wcsTask.getExt7().equals(String.valueOf(Constant.FLOW_CONFIG_ID.SIX.getValue())))) {
+                        log.info("入库任务下发AMS调用AGV{}", JSON.toJSONString(wcsTask));
+                        // 根据起始地查询库位信息
+                        BaseLocationInfo baseLocationInfo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(wcsTask.getLocationFrom(), Constant.WAREHOUSE_ID);
+                        // 同列里面是否有任务
+                        List<BaseLocationInfo> occupyByLocs = baseLocationInfoMapper.queryByListOccupyByLocOR(baseLocationInfo);
+                        for (int i = 0; i < occupyByLocs.size(); i++) {
+                            // 查询前方是否有未取货完成的任务
+                            WcsTask wTask = wcsTaskService.selectWcsTaskByLocationTo(occupyByLocs.get(i).getId());
+                            if (wTask != null) {
+                                wcsTask.setRemark("目标库位同列后方存在未取货完成的任务,请等待!");
+                                break;
+                            }
+                        }
                         //同列前方是否有阻挡
                         List<BaseLocationInfo> inStockByLocs = baseLocationInfoMapper.queryByListInStockByLoc(baseLocationInfo);
                         if (inStockByLocs.size() > 0) {
-                            log.info("同列有阻挡=========={}",inStockByLocs);
+                            log.info("同列有阻挡=========={}", inStockByLocs);
+                            wcsTask.setRemark("目标库位同列有阻挡,请处理!");
                             continue;
                         }
                     }
-
                     sendTask(wcsTask);
                     wcsTask.setState(10L);
                     wcsTaskService.updateWcsTask(wcsTask);
                     break;
                 }
-
                 try {
                     //任务下发判断
                     businessService.taskDispatchStack(wcsTask);
@@ -760,6 +924,7 @@ public class BusinessServiceImpl implements IBusinessService {
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
+
             }
         }
     }

+ 1 - 1
warewms-ams/src/main/java/com/ruoyi/ams/business/IBusinessService.java

@@ -69,7 +69,7 @@ public interface IBusinessService {
      * @param asnSoStrategy    策略对象
      * @return
      */
-    BaseLocationInfo zoneLocationAllocation(List<BaseLocationInfo> locationInfoList, String locationType, String type, AsnSoStrategy asnSoStrategy, Long token);
+    BaseLocationInfo zoneLocationAllocation(List<BaseLocationInfo> locationInfoList, String locationType, String type, AsnSoStrategy asnSoStrategy, Long token, Long flowId);
 
     /***
      *  根据id转换库位列表(如果是库位id直接返回库位如果是区域id则返回相应的库位)

+ 4 - 0
warewms-ams/src/main/java/com/ruoyi/ams/config/domain/dto/AgvCallDTO.java

@@ -20,5 +20,9 @@ public class AgvCallDTO {
     private Boolean theWeighing; // 是否复称
     private Boolean asnType; // TRUE-中转入库  FALSE-中转入库
     private String ext3; //任务类型
+    /**
+     * 班组编号
+     */
+    private String teamNo;
     private List<AgvCallItemDTO> agvCallItemDTOList = new ArrayList<>();
 }

+ 10 - 0
warewms-ams/src/main/java/com/ruoyi/ams/nieyan/service/impl/AgvCallProxyService.java

@@ -10,6 +10,7 @@ import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.config.domain.dto.AgvCallDTO;
 import com.ruoyi.ams.config.domain.dto.AgvCallItemDTO;
+import com.ruoyi.ams.config.domain.dto.LotattDTO;
 import com.ruoyi.ams.config.mapper.AsnSoStrategyMapper;
 import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
 import com.ruoyi.ams.inv.service.IInvLotAttService;
@@ -247,6 +248,7 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        agvCallDTO.setTeamNo(agvCallItemDTOList.get(0).getLotattDTO().getLotatt09());
         // 增加硫酸镍标识
         for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
             agvCallItemDTO.getLotattDTO().setLotatt18("Y"); //是否硫酸镍,Y代表是
@@ -274,6 +276,7 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        agvCallDTO.setTeamNo(agvCallItemDTOList.get(0).getLotattDTO().getLotatt09());
         // 增加硫酸镍标识
         for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
             agvCallItemDTO.getLotattDTO().setLotatt18("Y"); //是否硫酸镍,Y代表是
@@ -346,10 +349,12 @@ public class AgvCallProxyService {
             return AjaxResult.error("裹膜点无货!");
         }
         AgvCallDTO agvCallDTO = new AgvCallDTO();
+
         agvCallDTO.setLocationFrom(locationFrom);
         agvCallDTO.setLocationTo(locationTo);
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
+        agvCallDTO.setTeamNo(invLotLocIdLotattVOList.get(0).getLotatt09());
         if (isLSN) {
             // 硫酸镍
             return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TEN.getValue(), agvCallDTO);
@@ -378,6 +383,7 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        agvCallDTO.setTeamNo(agvCallItemDTOList.get(0).getLotattDTO().getLotatt09());
         // 增加氯化镍标识
         for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
             agvCallItemDTO.getLotattDTO().setLotatt18("N"); //是否硫酸镍,N代表否
@@ -405,6 +411,7 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        agvCallDTO.setTeamNo(agvCallItemDTOList.get(0).getLotattDTO().getLotatt09());
         // 增加氯化镍标识
         for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
             agvCallItemDTO.getLotattDTO().setLotatt18("N"); //是否硫酸镍,N代表否
@@ -448,6 +455,8 @@ public class AgvCallProxyService {
         agvCallDTO.setLocationTo(locationTo);
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
+        agvCallDTO.setTeamNo(invLotLocIdLotattVOList.get(0).getLotatt09());
+
         if (isLSN) {
             // 硫酸镍
             return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TEN.getValue(), agvCallDTO);
@@ -485,6 +494,7 @@ public class AgvCallProxyService {
         // todo 判断起始库位库存需要是合格
         List<InvLotLocIdLotattVO> invLotLocIdLotattVOList = invLotLocIdService.selectInvLocIdLotattByLocationId(Long.valueOf(locationFrom));
         if (invLotLocIdLotattVOList.size() == 0) {
+            log.info("=========所选库位无库存!:{}",locationFrom);
             return AjaxResult.error("所选库位无库存!");
         }
         AgvCallDTO agvCallDTO = new AgvCallDTO();

+ 3 - 9
warewms-ams/src/main/java/com/ruoyi/ams/task/mapper/WcsTaskMapper.java

@@ -3,6 +3,7 @@ package com.ruoyi.ams.task.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.ams.task.dto.WcsTaskLocationDTO;
+import com.ruoyi.base.domain.BaseLocationInfo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -110,13 +111,6 @@ public interface WcsTaskMapper extends BaseMapper<WcsTask>
      */
      List<WcsTask> selectBeforeTask(@Param("taskNo") String taskNo);
 
-    /**
-     * 查询任务状态不为2(完成),6(卸货完成),7(取消)的同列任务
-     * @param colNo
-     * @param colIndex
-     * @param zoneId
-     * @param warehouseId
-     * @return
-     */
-     List<WcsTask> selectWcsSameColumnNotFinish(@Param("colNo") String colNo,@Param("colIndex") Long colIndex,@Param("zoneId") Long zoneId,@Param("warehouseId") Long warehouseId);
+
+    WcsTask selectWcsTaskByLocationTo(@Param("locationTo")Long locationTo);
 }

+ 2 - 2
warewms-ams/src/main/java/com/ruoyi/ams/task/service/IWcsTaskService.java

@@ -3,6 +3,7 @@ package com.ruoyi.ams.task.service;
 import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.ams.task.dto.LargeScreenWcsTaskDTO;
 import com.ruoyi.ams.task.dto.WcsTaskLocationDTO;
+import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.common.core.domain.AjaxResult;
 
 import java.util.List;
@@ -184,6 +185,5 @@ public interface IWcsTaskService {
      */
     AjaxResult moveStartingPointToDestination(WcsTask wcsTask);
 
-
-    List<WcsTask> selectWcsSameColumnNotFinish(String colNo, Long colIndex, Long zoneId,Long warehouseId);
+    WcsTask selectWcsTaskByLocationTo(Long id);
 }

+ 2 - 2
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -600,8 +600,8 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
     }
 
     @Override
-    public List<WcsTask> selectWcsSameColumnNotFinish(String colNo, Long colIndex, Long zoneId, Long warehouseId) {
-        return wcsTaskMapper.selectWcsSameColumnNotFinish(colNo, colIndex, zoneId, warehouseId);
+    public WcsTask selectWcsTaskByLocationTo(Long locationTo) {
+        return wcsTaskMapper.selectWcsTaskByLocationTo(locationTo);
     }
 
 

+ 6 - 14
warewms-ams/src/main/resources/mapper/ams/WcsTaskMapper.xml

@@ -314,20 +314,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by priority
     </select>
 
-    <select id="selectWcsSameColumnNotFinish" resultMap="WcsTaskDTOResult">
-        select w.* from wcs_task w left join base_location_info i on w.location_from = i.id
-        where w.state not in (2,6,7)
-        <if test="colNo != null  and colNo != ''">
-            and i.col_no = #{colNo}
-        </if>
-        <if test=" warehouseId!= null  and warehouseId != ''">
-            and w.shop_id = #{warehouseId}
-        </if>
-        <if test="zoneId != null  and zoneId != ''">
-            and i.zone_id = #{zoneId}
-        </if>
-    </select>
-
     <select id="selectTaskByColNoAfter" resultMap="WcsTaskDTOResult">
         select w.*,i.col_no,i.col_index from wcs_task w left join base_location_info i on w.location_to = i.id
         where w.state = 9
@@ -351,5 +337,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select * from wcs_task
         where task_no = #{taskNo} and state not in (2,7,4,11,12)
     </select>
+    <select id="selectWcsTaskByLocationTo" resultType="com.ruoyi.ams.task.domain.WcsTask">
+        select * from wcs_task
+        where location_to = #{locationTo}
+        and state in (9,10,1)
+        order by create_date desc
+    </select>
 
 </mapper>

+ 6 - 0
warewms-base/src/main/java/com/ruoyi/base/mapper/BaseLocationInfoMapper.java

@@ -272,4 +272,10 @@ public interface BaseLocationInfoMapper {
      * 根据库区查询空闲的库位
      */
     List<BaseLocationInfo> selectEmptyLocationByZoneId(@Param("zoneId") String zoneId);
+
+    List<BaseLocationInfo> selectWcsSameColumnNotFinish(@Param("colNo")String colNo, @Param("colIndex")Long colIndex, @Param("zoneId")Long zoneId, @Param("warehouseId")Long warehouseId, @Param("type")String type);
+
+    List<BaseLocationInfo> selectWcsSameColumnAndTeamNotFinish(@Param("colNo")String colNo, @Param("team")String team, @Param("zoneId")Long zoneId, @Param("warehouseId")Long warehouseId,@Param("type") String type);
+
+    List<BaseLocationInfo> queryByListOccupyByLocOR(BaseLocationInfo baseLocationInfo);
 }

+ 22 - 0
warewms-base/src/main/java/com/ruoyi/base/service/IBaseLocationInfoService.java

@@ -304,4 +304,26 @@ public interface IBaseLocationInfoService {
      * 根据库区查询空闲的库位
      */
     List<BaseLocationInfo> selectEmptyLocationByZoneId(String zoneId);
+
+    /**
+     * 出库检查同列的未完成任务类型是否与当前任务类型一致
+     * @param colNo
+     * @param colIndex
+     * @param zoneId
+     * @param warehouseId
+     * @param type
+     * @return
+     */
+    List<BaseLocationInfo> selectWcsSameColumnNotFinish(String colNo, Long colIndex, Long zoneId, Long warehouseId, String type);
+
+    /**
+     * 检查同列的未完成任务类型及班组是否与当前任务类型一致
+     * @param colNo
+     * @param team
+     * @param zoneId
+     * @param warehouseId
+     * @param type
+     * @return
+     */
+    List<BaseLocationInfo> selectWcsSameColumnAndTeamNotFinish(String colNo, String team, Long zoneId, Long warehouseId, String type);
 }

+ 10 - 0
warewms-base/src/main/java/com/ruoyi/base/service/impl/BaseLocationInfoServiceImpl.java

@@ -425,4 +425,14 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
 
         return baseLocationInfoMapper.selectEmptyLocationByZoneId(zoneId);
     }
+
+    @Override
+    public List<BaseLocationInfo> selectWcsSameColumnNotFinish(String colNo, Long colIndex, Long zoneId, Long warehouseId, String type) {
+        return baseLocationInfoMapper.selectWcsSameColumnNotFinish(colNo, colIndex, zoneId, warehouseId,type);
+    }
+
+    @Override
+    public List<BaseLocationInfo> selectWcsSameColumnAndTeamNotFinish(String colNo, String team, Long zoneId, Long warehouseId, String type) {
+        return baseLocationInfoMapper.selectWcsSameColumnAndTeamNotFinish(colNo, team, zoneId, warehouseId, type);
+    }
 }

+ 61 - 3
warewms-base/src/main/resources/mapper/base/BaseLocationInfoMapper.xml

@@ -192,11 +192,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where stock_status = '10' and location_type ='2'
           and zone_id = #{zoneId}
           and col_no = #{colNo}
-          and col_index != #{colIndex}
+          and col_index &gt; #{colIndex}
 
     </select>
 
-    <!--根据库位返回同库区同列目标有货的库位list 同列前方是否有阻挡    -->
+    <!--根据库位返回同库区同列目标有货的库位list 同列前方是否有阻挡-->
     <select id="queryByListInStockByLoc" resultMap="BaseLocationInfoResult" parameterType="BaseLocationInfo">
         select *
         from base_location_info
@@ -649,7 +649,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="laneCheck" resultMap="BaseLocationInfoResult">
-        select b.* from wcs_task w left join bas_location_info b
+        select b.* from wcs_task w left join base_location_info b
         <if test="laneType == 'LANE_FROM'">
            on w.location_from = b.id where w.state in (0,1,3,10,13)
         </if>
@@ -693,4 +693,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectBaseLocationInfoVo"/>
         where zone_id = #{zoneId}  and stock_status ='00'
     </select>
+
+    <select id="selectWcsSameColumnNotFinish" resultMap="BaseLocationInfoResult">
+        select i.* from base_location_info i left join wcs_task w on w.location_from = i.id
+        where w.state not in (2,6,7)
+        <if test="colNo != null  and colNo != ''">
+            and i.col_no = #{colNo}
+        </if>
+        <if test=" warehouseId!= null  and warehouseId != ''">
+            and w.shop_id = #{warehouseId}
+        </if>
+        <if test="zoneId != null  and zoneId != ''">
+            and i.zone_id = #{zoneId}
+        </if>
+        <if test="type != null and type != '' and type == 'SO'">
+            and w.ext7 in ('4','6','9','10','12','13')
+        </if>
+        <if test="type != null and type != '' and type == 'ASN'">
+            and w.ext7 in ('14','15')
+        </if>
+    </select>
+
+    <!--满足 同列未完成任务的库位,是同一班组,相同类型任务-->
+    <select id="selectWcsSameColumnAndTeamNotFinish" resultMap="BaseLocationInfoResult">
+        select b.*
+        from base_location_info b
+        left join wcs_task w on w.location_from = b.id
+        left join inv_lot_loc_id inv on inv.location_id = b.id
+        left join inv_lot_att att on inv.lotnum = att.lotnum
+        where w.state not in (2,6,7)
+        <if test="colNo != null and colNo != ''">
+            and b.col_no = #{colNo}
+        </if>
+        <if test=" warehouseId!= null and warehouseId != ''">
+            and w.shop_id = #{warehouseId}
+        </if>
+        <if test="zoneId != null and zoneId != ''">
+            and b.zone_id = #{zoneId}
+        </if>
+        <if test="type != null and type != '' and type == 'SO'">
+            and w.ext7 in ('4','6','9','10','12','13')
+        </if>
+        <if test="type != null and type != '' and type == 'ASN'">
+            and w.ext7 in ('14','15')
+        </if>
+        <if test="team != null and team != ''">
+            and att.lotatt09 = #{team}
+        </if>
+    </select>
+
+    <!--入库判断里面是否有任务-->
+    <select id="queryByListOccupyByLocOR" resultMap="BaseLocationInfoResult" parameterType="BaseLocationInfo">
+        select *
+        from base_location_info
+        where stock_status = '10' and location_type ='2'
+          and zone_id = #{zoneId}
+          and col_no = #{colNo}
+          and col_index &lt; #{colIndex}
+    </select>
 </mapper>