|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.ams.business;
|
|
|
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.ruoyi.ams.agv.ndc.common.ByteUtil;
|
|
|
import com.ruoyi.ams.agv.ndc.common.CRC16Util;
|
|
@@ -147,7 +148,15 @@ 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);
|
|
@@ -160,6 +169,14 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
wcsTaskList.addAll(this.genTask(locationFrom, locationTo, flowConfigHeaderVO, agvCallDTO, token));
|
|
|
|
|
|
} 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) {
|
|
@@ -201,6 +218,30 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检查同列的未完成任务类型是否与当前任务类型一致
|
|
|
+ * @param colNo
|
|
|
+ * @param colIndex
|
|
|
+ * @param zoneId
|
|
|
+ * @param type 任务类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean checkWcsSameColumnNotFinish(String colNo, Long colIndex, Long zoneId,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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public BaseLocationInfo inLocationAllocation(InWarehouseDTO inWarehouseDTO, Long token) {
|
|
@@ -313,7 +354,13 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
}
|
|
|
if (locationType.equals("locationFrom")) {
|
|
|
|
|
|
- locationInfo = checkTheSameColumnLocation(locationInfoList, token, false);
|
|
|
+ // 如果是出库 调用无需判断阻挡的方法
|
|
|
+ if (type.equals("SO")){
|
|
|
+ locationInfo = checkTheSameColumnLocationSO(locationInfoList, token);
|
|
|
+ }else {
|
|
|
+ locationInfo = checkTheSameColumnLocation(locationInfoList, token, false);
|
|
|
+ }
|
|
|
+
|
|
|
if (locationInfo == null) {
|
|
|
if (type.equals("ASN")) { // 入库
|
|
|
fromMsg = "起始点没有可以分配的库存!";
|
|
@@ -365,21 +412,23 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
//同列是否有任务
|
|
|
List<BaseLocationInfo> occupyByLocs = baseLocationInfoMapper.queryByListOccupyByLoc(location);
|
|
|
if (occupyByLocs.size() > 0) {
|
|
|
+ log.info("同列有任务=========={}",occupyByLocs);
|
|
|
continue;
|
|
|
}
|
|
|
//同列前方是否有阻挡
|
|
|
List<BaseLocationInfo> inStockByLocs = baseLocationInfoMapper.queryByListInStockByLoc(location);
|
|
|
if (inStockByLocs.size() > 0) {
|
|
|
+ log.info("同列有阻挡=========={}",inStockByLocs);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
// 是否目标点
|
|
|
- if (!isReleaseGoods) {
|
|
|
+ if (!isReleaseGoods) { // 起始点位状态必须空闲且没有被锁住
|
|
|
if (!location.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())
|
|
|
|| redisCache.checkIsLock(RedisKey.LOCK_LOCATION + location.getId())) {
|
|
|
continue;
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else { // 目标点状态为空闲、空、且没有被锁住
|
|
|
if (!location.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())
|
|
|
|| !location.getIsEmpty().equals(Constant.IS_YES.Y.name())
|
|
|
|| redisCache.checkIsLock(RedisKey.LOCK_LOCATION + location.getId())) {
|
|
@@ -398,6 +447,35 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
return basLocation;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * AGV出库任务生成时的起始位置不判断是否阻挡
|
|
|
+ * @param basLocationList
|
|
|
+ * @param token
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BaseLocationInfo checkTheSameColumnLocationSO(List<BaseLocationInfo> basLocationList, Long token) {
|
|
|
+ BaseLocationInfo basLocation = null;
|
|
|
+ //筛选2次 第2次去除同列占用和阻挡条件 todo 先筛选一次吧
|
|
|
+ for (int i = 0; i < 1 && basLocation == null; i++) {
|
|
|
+ for (BaseLocationInfo location : basLocationList) {
|
|
|
+
|
|
|
+ // 起始点位状态必须空闲且没有被锁住
|
|
|
+ if (!location.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())
|
|
|
+ || 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;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<BaseLocationInfo> convertLocation(String locationNoOrZoneId, Long warehouseId, String orderBy) {
|
|
@@ -578,6 +656,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);
|
|
|
AmsTask amsTask = new AmsTask();
|
|
|
amsTask.setTaskNo(wcsTask.getTaskNo());
|
|
|
if (wcsTask.getBusinessType() == null || wcsTask.getBusinessType().equals("")) {
|
|
@@ -646,6 +725,28 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
//转发任务
|
|
|
if (StringUtils.isNotEmpty(wcsTask.getTaskType())
|
|
|
&& wcsTask.getTaskType().equals(Constant.TASK_TYPE.FORWARD.getValue())) {
|
|
|
+ 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())))){
|
|
|
+ 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);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //同列前方是否有阻挡
|
|
|
+ List<BaseLocationInfo> inStockByLocs = baseLocationInfoMapper.queryByListInStockByLoc(baseLocationInfo);
|
|
|
+ if (inStockByLocs.size() > 0) {
|
|
|
+ log.info("同列有阻挡=========={}",inStockByLocs);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
sendTask(wcsTask);
|
|
|
wcsTask.setState(10L);
|
|
|
wcsTaskService.updateWcsTask(wcsTask);
|