|
@@ -281,124 +281,211 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
@Override
|
|
@Override
|
|
public BaseLocationInfo zoneLocationAllocation(List<BaseLocationInfo> locationInfoList, String locationType
|
|
public BaseLocationInfo zoneLocationAllocation(List<BaseLocationInfo> locationInfoList, String locationType
|
|
, String type, AsnSoStrategy asnSoStrategy, Long token) {
|
|
, String type, AsnSoStrategy asnSoStrategy, Long token) {
|
|
|
|
+// BaseLocationInfo locationInfo = null;
|
|
|
|
+// if (type.equals("ASN")) {
|
|
|
|
+// //入库
|
|
|
|
+// if (locationType.equals("locationFrom")) {
|
|
|
|
+// for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+// if (!b.getStockStatus().equals("00")) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// locationInfo = b;
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// if (locationInfo == null) {
|
|
|
|
+// throw new ServiceException("入库起始库位没有可以分配的空库位", token);
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+// if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// locationInfo = b;
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// if (locationInfo == null) {
|
|
|
|
+// throw new ServiceException("入库目标点没有可以分配的库位", token);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// } else if (type.equals("SO")) {
|
|
|
|
+// //起始库位
|
|
|
|
+// if (locationType.equals("locationFrom")) {
|
|
|
|
+// for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+// if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("N") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// locationInfo = b;
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// if (locationInfo == null) {
|
|
|
|
+// throw new ServiceException("出库起始点没有可以分配的库存!", token);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else { //目标库位
|
|
|
|
+// for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+// if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// locationInfo = b;
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// if (locationInfo == null) {
|
|
|
|
+// throw new ServiceException("出库目标点没有可以分配的库位", token);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// } else { //移库
|
|
|
|
+// if (locationType.equals("locationFrom")) {
|
|
|
|
+//
|
|
|
|
+// for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+// if (!b.getStockStatus().equals("00") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// locationInfo = b;
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //进行判断
|
|
|
|
+// if (locationInfo == null) {
|
|
|
|
+// throw new ServiceException("移库起始点没有可以分配的库位", token);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else {
|
|
|
|
+// for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+// if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+// locationInfo = b;
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //进行判断
|
|
|
|
+// if (locationInfo == null) {
|
|
|
|
+// throw new ServiceException("移库目标点没有可以分配的库位", token);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// return locationInfo;
|
|
BaseLocationInfo locationInfo = null;
|
|
BaseLocationInfo locationInfo = null;
|
|
- if (type.equals("ASN")) {
|
|
|
|
- //入库
|
|
|
|
|
|
+ String fromMsg = "";
|
|
|
|
+ String toMsg = "";
|
|
|
|
+ if (type.equals("ASN")) { // 入库
|
|
if (locationType.equals("locationFrom")) {
|
|
if (locationType.equals("locationFrom")) {
|
|
- for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
- if (!b.getStockStatus().equals("00")) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- locationInfo = b;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (locationInfo == null) {
|
|
|
|
- throw new ServiceException("入库起始库位没有可以分配的空库位", token);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
- if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- // 第六层不能放数量超过2的货
|
|
|
|
- int boxNum = Integer.parseInt(asnSoStrategy.getAsnHeightLimit());
|
|
|
|
- if (b.getShiftNo().equals("6")) {
|
|
|
|
- if (boxNum > 2) continue;
|
|
|
|
- } else {
|
|
|
|
- // 其他层数放置箱子数量不能超过6
|
|
|
|
- if (boxNum > 6) {
|
|
|
|
- log.error("入库箱数量不能超过6!");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- locationInfo = b;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (locationInfo == null) {
|
|
|
|
- throw new ServiceException("入库目标点没有可以分配的库位", token);
|
|
|
|
- }
|
|
|
|
|
|
+ } else { //目标库位
|
|
}
|
|
}
|
|
- } else if (type.equals("SO")) {
|
|
|
|
- //起始库位
|
|
|
|
|
|
+ } else if (type.equals("SO")) { // 出库
|
|
if (locationType.equals("locationFrom")) {
|
|
if (locationType.equals("locationFrom")) {
|
|
- for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
- if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("N") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- // 判断起始库位上的库存质检状态是否可以出库
|
|
|
|
- boolean con = invLotLocIdService.verifyInventoryCanOutbound(b.getId().toString());
|
|
|
|
- if (!con) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- locationInfo = b;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (locationInfo == null) {
|
|
|
|
- throw new ServiceException("出库起始点没有可以分配的库存!", token);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
} else { //目标库位
|
|
} else { //目标库位
|
|
- for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
- if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- locationInfo = b;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (locationInfo == null) {
|
|
|
|
- throw new ServiceException("出库目标点没有可以分配的库位", token);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
} else { //移库
|
|
} else { //移库
|
|
if (locationType.equals("locationFrom")) {
|
|
if (locationType.equals("locationFrom")) {
|
|
|
|
+ } else {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (locationType.equals("locationFrom")) {
|
|
|
|
+ for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+ }
|
|
|
|
+ locationInfo = checkTheSameColumnLocation(locationInfoList, token, false);
|
|
|
|
+ if (locationInfo == null) {
|
|
|
|
+ if (type.equals("ASN")) { // 入库
|
|
|
|
+ fromMsg = "起始点没有可以分配的库存!";
|
|
|
|
+ } else if (type.equals("SO")) { // 出库
|
|
|
|
+ fromMsg = "起始点没有可以分配的库存!";
|
|
|
|
+ } else { //移库
|
|
|
|
+ fromMsg = "起始点没有可以分配的库位";
|
|
|
|
+ }
|
|
|
|
+ throw new ServiceException(fromMsg, token);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
+ }
|
|
|
|
+ locationInfo = checkTheSameColumnLocation(locationInfoList, token, true);
|
|
|
|
+ if (locationInfo == null) {
|
|
|
|
+ if (type.equals("ASN")) { // 入库
|
|
|
|
+ toMsg = "目标点没有可以分配的库位";
|
|
|
|
+ } else if (type.equals("SO")) { // 出库
|
|
|
|
+ toMsg = "目标点没有可以分配的库位";
|
|
|
|
+ } else { //移库
|
|
|
|
+ toMsg = "目标点没有可以分配的库位";
|
|
|
|
+ }
|
|
|
|
+ throw new ServiceException(toMsg, token);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return locationInfo;
|
|
|
|
+ }
|
|
|
|
|
|
- for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
- if (!b.getStockStatus().equals("00") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 校验同列任务任务状态和阻挡
|
|
|
|
+ *
|
|
|
|
+ * @param basLocationList
|
|
|
|
+ * @param token
|
|
|
|
+ * @param isReleaseGoods 是否目标点位
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public BaseLocationInfo checkTheSameColumnLocation(List<BaseLocationInfo> basLocationList, Long token, boolean isReleaseGoods) {
|
|
|
|
+ boolean isBlock = false; // 是否阻挡
|
|
|
|
+ BaseLocationInfo basLocation = null;
|
|
|
|
+ //筛选2次 第2次去除同列占用和阻挡条件 todo 先筛选一次吧
|
|
|
|
+ for (int i = 0; i < 1 && basLocation == null; i++) {
|
|
|
|
+ for (BaseLocationInfo location : basLocationList) {
|
|
|
|
+ //如果库位类型不为地堆则不用判断同列占用和阻挡
|
|
|
|
+ if (location.getLocationType().equals("2")) {
|
|
|
|
+ isBlock = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //只有第一次判断同列任务占用和阻挡
|
|
|
|
+ if (i == 0 && isBlock) {
|
|
|
|
+ //同列是否有任务
|
|
|
|
+ List<BaseLocationInfo> occupyByLocs = baseLocationInfoMapper.queryByListOccupyByLoc(location);
|
|
|
|
+ if (occupyByLocs.size() > 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
|
|
+ //同列前方是否有阻挡
|
|
|
|
+ List<BaseLocationInfo> inStockByLocs = baseLocationInfoMapper.queryByListInStockByLoc(location);
|
|
|
|
+ if (inStockByLocs.size() > 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- locationInfo = b;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //进行判断
|
|
|
|
- if (locationInfo == null) {
|
|
|
|
- throw new ServiceException("移库起始点没有可以分配的库位", token);
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- } else {
|
|
|
|
- for (BaseLocationInfo b : locationInfoList) {
|
|
|
|
- if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
|
|
|
|
|
|
+ // 是否目标点
|
|
|
|
+ if (!isReleaseGoods) {
|
|
|
|
+ if (!location.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())
|
|
|
|
+ || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + location.getId())) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
|
|
|
|
|
|
+ } 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())) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- locationInfo = b;
|
|
|
|
- break;
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- //进行判断
|
|
|
|
- if (locationInfo == null) {
|
|
|
|
- throw new ServiceException("移库目标点没有可以分配的库位", token);
|
|
|
|
|
|
+ if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + location.getId()
|
|
|
|
+ , location.getId().toString()
|
|
|
|
+ , token)) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ basLocation = location;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return locationInfo;
|
|
|
|
|
|
+ return basLocation;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|