|
@@ -282,7 +282,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
Long STAGE01 = Constant.LOC_STAGE_CACHE;
|
|
Long STAGE01 = Constant.LOC_STAGE_CACHE;
|
|
WmsDocOrderHeader wmsDocOrderHeader;
|
|
WmsDocOrderHeader wmsDocOrderHeader;
|
|
List<WmsDocOrderDetails> orderDetails = new ArrayList<>();
|
|
List<WmsDocOrderDetails> orderDetails = new ArrayList<>();
|
|
- Map<String, List<WmsDocOrderDTO>> orderMap = new HashMap<>();
|
|
|
|
|
|
|
|
//查询托盘是否存在,生成托盘绑定信息
|
|
//查询托盘是否存在,生成托盘绑定信息
|
|
WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
|
|
WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
|
|
@@ -321,32 +320,36 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
//当前订单总数
|
|
//当前订单总数
|
|
BigDecimal totalQty = new BigDecimal(stockForm.getQty());
|
|
BigDecimal totalQty = new BigDecimal(stockForm.getQty());
|
|
|
|
|
|
- //备货入库
|
|
|
|
- if (stockForm.getStockTag().equals("Y") && StringUtils.isEmpty(stockForm.getOrderNo())) {
|
|
|
|
- return AjaxResult.error("备货必须选择出库单号");
|
|
|
|
|
|
+ // 不同的产品类型不允许放一个托盘上
|
|
|
|
+ boolean isSameType = checkSameTypeByPalletNo(stockForm.getPalletNo(), codeSkuRelationshipVO.getSku());
|
|
|
|
+ if (!isSameType) {
|
|
|
|
+ throw new ServiceException("不同的产品类型不允许放一个托盘上");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 成品数量默认为1
|
|
|
|
+ if (codeSkuRelationshipVO.isProduct()) {
|
|
|
|
+ stockForm.setQty(BigDecimal.ONE.toString());
|
|
|
|
+ totalQty = BigDecimal.ONE;
|
|
}
|
|
}
|
|
- //校验出库单
|
|
|
|
|
|
+
|
|
|
|
+ // 匹配出库单 计算备货数量是否已经超出出库单可分配数量
|
|
if (stockForm.getStockTag().equals("Y")) {
|
|
if (stockForm.getStockTag().equals("Y")) {
|
|
//查询出库单
|
|
//查询出库单
|
|
wmsDocOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(stockForm.getOrderNo());
|
|
wmsDocOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(stockForm.getOrderNo());
|
|
- if (wmsDocOrderHeader == null) {
|
|
|
|
- return AjaxResult.error("出库单不存在");
|
|
|
|
- }
|
|
|
|
- if (wmsDocOrderHeader.getOrderStatus().equals("90") || wmsDocOrderHeader.getOrderStatus().equals("98") || wmsDocOrderHeader.getOrderStatus().equals("99")) {
|
|
|
|
- return AjaxResult.error("出库单已完成");
|
|
|
|
|
|
+ if (wmsDocOrderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS99.getValue())
|
|
|
|
+ || wmsDocOrderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS90.getValue())
|
|
|
|
+ || wmsDocOrderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS23.getValue())) {
|
|
|
|
+ return AjaxResult.error("出库单已完成,不可备货!");
|
|
}
|
|
}
|
|
//每个托盘只允许码一个出库单
|
|
//每个托盘只允许码一个出库单
|
|
- InvLotAtt queryAtt = new InvLotAtt();
|
|
|
|
- queryAtt.setLotatt14(stockForm.getOrderNo());
|
|
|
|
- queryAtt.setLotatt07(stockForm.getPalletNo());
|
|
|
|
- List<InvLotLocId> invList = invLotLocIdService.queryInvByInvLotatt(queryAtt);
|
|
|
|
- if (invList != null && invList.size() > 1) {
|
|
|
|
- throw new ServiceException("每个托盘只允许码一个出库单");
|
|
|
|
|
|
+ AjaxResult ajaxResult = invLotLocIdService.checkPalletIsOnlyOrderNo(stockForm.getPalletNo(), wmsDocOrderHeader.getOrderNo());
|
|
|
|
+ if (!ajaxResult.isSuccess()) {
|
|
|
|
+ return ajaxResult;
|
|
}
|
|
}
|
|
|
|
|
|
orderDetails = wmsDocOrderHeader.getWmsDocOrderDetailsList();
|
|
orderDetails = wmsDocOrderHeader.getWmsDocOrderDetailsList();
|
|
|
|
|
|
- //匹配出库单
|
|
|
|
|
|
+ //匹配出库单,根据sku统计可分配的数量
|
|
BigDecimal orderQty = BigDecimal.ZERO;
|
|
BigDecimal orderQty = BigDecimal.ZERO;
|
|
for (WmsDocOrderDetails de : orderDetails) {
|
|
for (WmsDocOrderDetails de : orderDetails) {
|
|
if (!de.getSku().equals(codeSkuRelationshipVO.getSku())) {
|
|
if (!de.getSku().equals(codeSkuRelationshipVO.getSku())) {
|
|
@@ -355,43 +358,16 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
if (de.getQtyOrdered().compareTo(de.getQtyAllocated()) == 1) {
|
|
if (de.getQtyOrdered().compareTo(de.getQtyAllocated()) == 1) {
|
|
BigDecimal current = de.getQtyOrdered().subtract(de.getQtyAllocated());
|
|
BigDecimal current = de.getQtyOrdered().subtract(de.getQtyAllocated());
|
|
orderQty = orderQty.add(current);
|
|
orderQty = orderQty.add(current);
|
|
- List<WmsDocOrderDTO> list = orderMap.get(de.getSku());
|
|
|
|
- if (list == null) {
|
|
|
|
- list = new ArrayList<>();
|
|
|
|
- }
|
|
|
|
- WmsDocOrderDTO orderDTO = new WmsDocOrderDTO();
|
|
|
|
- orderDTO.setOrderNo(de.getOrderNo());
|
|
|
|
- orderDTO.setOrderLineNo(de.getOrderLineNo().longValue());
|
|
|
|
- orderDTO.setQty(current);
|
|
|
|
- list.add(orderDTO);
|
|
|
|
- orderMap.put(de.getSku(), list);
|
|
|
|
- if (orderQty.compareTo(totalQty) == 0) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (orderQty.compareTo(BigDecimal.ZERO) != 1 || orderQty.compareTo(new BigDecimal(stockForm.getQty())) == -1) {
|
|
|
|
|
|
+ //可分配数量小于传入数量
|
|
|
|
+ if (orderQty.compareTo(new BigDecimal(stockForm.getQty())) == -1) {
|
|
return AjaxResult.error("接收数超出出货单需求数量");
|
|
return AjaxResult.error("接收数超出出货单需求数量");
|
|
}
|
|
}
|
|
-
|
|
|
|
- wmsDocOrderHeader.setUserdefine1("Stock");
|
|
|
|
- wmsDocOrderHeaderService.updateWmsDocOrderHeader(wmsDocOrderHeader);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // 不同的产品类型不允许放一个托盘上
|
|
|
|
- boolean isSameType = checkSameTypeByPalletNo(stockForm.getPalletNo(), codeSkuRelationshipVO.getSku());
|
|
|
|
- if (!isSameType) {
|
|
|
|
- throw new ServiceException("不同的产品类型不允许放一个托盘上");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 成品数量默认为1
|
|
|
|
- if (codeSkuRelationshipVO.isProduct()) {
|
|
|
|
- stockForm.setQty(BigDecimal.ONE.toString());
|
|
|
|
- totalQty = BigDecimal.ONE;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- //匹配对应的入库单,出库单
|
|
|
|
|
|
+ //匹配对应的入库单
|
|
if (stockForm.getAsnNo() != null && stockForm.getAsnNo().size() > 0) {
|
|
if (stockForm.getAsnNo() != null && stockForm.getAsnNo().size() > 0) {
|
|
List<WmsDocAsnDetails> list = wmsDocAsnDetailsMapper.selectDetailsListByAsnNos(stockForm.getAsnNo(), codeSkuRelationshipVO.getSku());
|
|
List<WmsDocAsnDetails> list = wmsDocAsnDetailsMapper.selectDetailsListByAsnNos(stockForm.getAsnNo(), codeSkuRelationshipVO.getSku());
|
|
if (list == null || list.size() == 0) {
|
|
if (list == null || list.size() == 0) {
|
|
@@ -453,16 +429,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
} else {
|
|
} else {
|
|
throw new ServiceException("更新接收数失败");
|
|
throw new ServiceException("更新接收数失败");
|
|
}
|
|
}
|
|
- if (!StringUtils.isEmpty(stockForm.getOrderNo())) {
|
|
|
|
- //绑定对应入库单号 todo 这边修改了个寂寞
|
|
|
|
- WmsDocAsnDetails updateDetails = new WmsDocAsnDetails();
|
|
|
|
- updateDetails.setAsnNo(details.getAsnNo());
|
|
|
|
- updateDetails.setAsnLineNo(details.getAsnLineNo());
|
|
|
|
- updateDetails.setUpdateTime(new Date());
|
|
|
|
- updateDetails.setUpdateBy(loginUser.getUsername());
|
|
|
|
- wmsDocAsnDetailsMapper.updateWmsDocAsnDetails(updateDetails);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//修改头单状态
|
|
//修改头单状态
|
|
WmsDocAsnDetails detailsQuery = new WmsDocAsnDetails();
|
|
WmsDocAsnDetails detailsQuery = new WmsDocAsnDetails();
|
|
detailsQuery.setAsnNo(details.getAsnNo());
|
|
detailsQuery.setAsnNo(details.getAsnNo());
|
|
@@ -480,18 +446,26 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
headerUpdate.setUpdateTime(new Date());
|
|
headerUpdate.setUpdateTime(new Date());
|
|
wmsDocAsnHeaderMapper.updateWmsDocAsnHeader(headerUpdate);
|
|
wmsDocAsnHeaderMapper.updateWmsDocAsnHeader(headerUpdate);
|
|
|
|
|
|
|
|
+ if (stockForm.getStockTag().equals("Y")) {
|
|
|
|
+ // 匹配对应出库单 修改出库单备货数量
|
|
|
|
+ wmsDocOrderHeaderService.modifystockCompletionStatusAsn(stockForm.getOrderNo(), codeSkuRelationshipVO.getSku(), current);
|
|
|
|
+ }
|
|
|
|
+
|
|
//生成库存
|
|
//生成库存
|
|
LotattDTO lotattDTO = new LotattDTO();
|
|
LotattDTO lotattDTO = new LotattDTO();
|
|
-// if (codeSkuRelationshipVO.isProduct()) {
|
|
|
|
lotattDTO.setLotatt02(stockForm.getSkuSn());
|
|
lotattDTO.setLotatt02(stockForm.getSkuSn());
|
|
-// }
|
|
|
|
lotattDTO.setLotatt05("90");
|
|
lotattDTO.setLotatt05("90");
|
|
lotattDTO.setLotatt07(stockForm.getPalletNo());
|
|
lotattDTO.setLotatt07(stockForm.getPalletNo());
|
|
lotattDTO.setLotatt08(details.getAsnNo());
|
|
lotattDTO.setLotatt08(details.getAsnNo());
|
|
lotattDTO.setLotatt12("Y");
|
|
lotattDTO.setLotatt12("Y");
|
|
lotattDTO.setLotatt13(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
|
|
lotattDTO.setLotatt13(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
|
|
- lotattDTO.setLotatt14(stockForm.getOrderNo());
|
|
|
|
- invLotLocIdService.initInv(STAGE01.toString(), codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, BigDecimal.ZERO);
|
|
|
|
|
|
+ if (stockForm.getStockTag().equals("Y")) {
|
|
|
|
+ lotattDTO.setLotatt14(stockForm.getOrderNo());
|
|
|
|
+ // 生成完全分配的库存
|
|
|
|
+ invLotLocIdService.initInv(STAGE01.toString(), codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, current);
|
|
|
|
+ }else {
|
|
|
|
+ invLotLocIdService.initInv(STAGE01.toString(), codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, BigDecimal.ZERO);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
break;
|
|
break;
|
|
}
|
|
}
|