|
@@ -219,7 +219,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 订单分配
|
|
* 订单分配
|
|
- *
|
|
|
|
|
|
+ * 只能完全分配
|
|
* @param orderNo
|
|
* @param orderNo
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -230,9 +230,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
if (orderHeader == null) {
|
|
if (orderHeader == null) {
|
|
return AjaxResult.error("没有查询到订单");
|
|
return AjaxResult.error("没有查询到订单");
|
|
}
|
|
}
|
|
- // TODO 改成可以部分分配
|
|
|
|
if (!orderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS00.getValue())) {
|
|
if (!orderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS00.getValue())) {
|
|
- return AjaxResult.error("出库单为创建状态才可以分配");
|
|
|
|
|
|
+ return AjaxResult.success("出库单为创建状态才可以分配");
|
|
}
|
|
}
|
|
boolean isbf = false;
|
|
boolean isbf = false;
|
|
boolean isAllocation = false;
|
|
boolean isAllocation = false;
|
|
@@ -255,9 +254,9 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (isbf) {
|
|
if (isbf) {
|
|
|
|
+ // 不可部分分配
|
|
orderHeader.setOrderStatus(Constant.ORDER_STS.STS10.getValue());
|
|
orderHeader.setOrderStatus(Constant.ORDER_STS.STS10.getValue());
|
|
wmsDocOrderHeaderService.updateWmsDocOrderHeader(orderHeader);
|
|
wmsDocOrderHeaderService.updateWmsDocOrderHeader(orderHeader);
|
|
- // TODO 改成可以部分分配
|
|
|
|
throw new ServiceException("库存数量不足,分配失败!" + orderNo);
|
|
throw new ServiceException("库存数量不足,分配失败!" + orderNo);
|
|
}
|
|
}
|
|
if (isAllocation) {
|
|
if (isAllocation) {
|
|
@@ -280,23 +279,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
@Override
|
|
@Override
|
|
public AjaxResult doAllocationBH(String orderNo) {
|
|
public AjaxResult doAllocationBH(String orderNo) {
|
|
WmsDocOrderHeader orderHeader = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderByOrderNo(orderNo);
|
|
WmsDocOrderHeader orderHeader = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderByOrderNo(orderNo);
|
|
- // 为了可以重复下任务
|
|
|
|
- if (StringUtils.isEmpty(orderHeader.getUserdefine6())) {
|
|
|
|
- orderHeader.setUserdefine6("N");
|
|
|
|
- }
|
|
|
|
if (orderHeader == null) {
|
|
if (orderHeader == null) {
|
|
return AjaxResult.error("没有查询到订单");
|
|
return AjaxResult.error("没有查询到订单");
|
|
}
|
|
}
|
|
- if (!orderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS23.getValue())) {
|
|
|
|
- return AjaxResult.error("出库单为备货完成才可以分配");
|
|
|
|
- }
|
|
|
|
- // 是否已经生成分配明细
|
|
|
|
- ActAllocationDetails allocationDetailsQuery = new ActAllocationDetails();
|
|
|
|
- allocationDetailsQuery.setOrderNo(orderNo);
|
|
|
|
- allocationDetailsQuery.setStatus(Constant.ORDER_STS.STS20.getValue());
|
|
|
|
- List<ActAllocationDetails> actAllocationDetailsList = actAllocationDetailsService.selectActAllocationDetailsList(allocationDetailsQuery);
|
|
|
|
- if (actAllocationDetailsList.size() > 0) {
|
|
|
|
- return AjaxResult.error("出库单已经生成分配明细!");
|
|
|
|
|
|
+ if (!orderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS00.getValue())
|
|
|
|
+ && !orderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS10.getValue())){
|
|
|
|
+ return AjaxResult.success("出库单状态不可分配!");
|
|
}
|
|
}
|
|
|
|
|
|
boolean isbf = false;
|
|
boolean isbf = false;
|
|
@@ -304,7 +292,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
BigDecimal total = BigDecimal.ZERO;
|
|
BigDecimal total = BigDecimal.ZERO;
|
|
List<WmsDocOrderDetails> orderDetails = orderHeader.getWmsDocOrderDetailsList();
|
|
List<WmsDocOrderDetails> orderDetails = orderHeader.getWmsDocOrderDetailsList();
|
|
for (WmsDocOrderDetails o : orderDetails) {
|
|
for (WmsDocOrderDetails o : orderDetails) {
|
|
- total = total.add(o.getQtyOrdered());
|
|
|
|
|
|
+ total = total.add(o.getQtyOrdered().subtract(o.getQtyAllocated()));
|
|
}
|
|
}
|
|
for (WmsDocOrderDetails o : orderDetails) {
|
|
for (WmsDocOrderDetails o : orderDetails) {
|
|
AjaxResult result = wmsDocOrderHeaderService.doAllocationDetailsBH(orderHeader, o);
|
|
AjaxResult result = wmsDocOrderHeaderService.doAllocationDetailsBH(orderHeader, o);
|
|
@@ -320,20 +308,16 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (isbf) {
|
|
if (isbf) {
|
|
- orderHeader.setOrderStatus(Constant.ORDER_STS.STS22.getValue());
|
|
|
|
|
|
+ orderHeader.setOrderStatus(Constant.ORDER_STS.STS10.getValue());
|
|
wmsDocOrderHeaderService.updateWmsDocOrderHeader(orderHeader);
|
|
wmsDocOrderHeaderService.updateWmsDocOrderHeader(orderHeader);
|
|
- if (!orderHeader.getUserdefine6().equals("Y")) {
|
|
|
|
- throw new ServiceException("库存数量不足,分配失败!" + orderNo);
|
|
|
|
- }
|
|
|
|
|
|
+ return AjaxResult.success("部分分配成功!");
|
|
}
|
|
}
|
|
if (isAllocation) {
|
|
if (isAllocation) {
|
|
- orderHeader.setOrderStatus(Constant.ORDER_STS.STS23.getValue());
|
|
|
|
- // 偷懒 卡个bug
|
|
|
|
- orderHeader.setUserdefine6("Y"); // 代表已经校验成功
|
|
|
|
|
|
+ orderHeader.setOrderStatus(Constant.ORDER_STS.STS20.getValue());
|
|
wmsDocOrderHeaderService.updateWmsDocOrderHeader(orderHeader);
|
|
wmsDocOrderHeaderService.updateWmsDocOrderHeader(orderHeader);
|
|
- return AjaxResult.success("分配成功");
|
|
|
|
|
|
+ return AjaxResult.success("分配成功!");
|
|
} else {
|
|
} else {
|
|
- return AjaxResult.error("分配失败,没有可用的库存");
|
|
|
|
|
|
+ return AjaxResult.error("分配失败,没有可用的库存!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -343,14 +327,18 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
for (String s : orderNoList) {
|
|
for (String s : orderNoList) {
|
|
AjaxResult ajaxResult = null;
|
|
AjaxResult ajaxResult = null;
|
|
WmsDocOrderHeader header = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(s);
|
|
WmsDocOrderHeader header = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(s);
|
|
- // 判断是否是已经备货完成的备货单
|
|
|
|
- if (header.getOrderType().equals(Constant.ORDER_TYP.BH.getValue())
|
|
|
|
- && header.getOrderStatus().equals(Constant.ORDER_STS.STS23.getValue())) {
|
|
|
|
|
|
+ // 备货单
|
|
|
|
+ if (header.getOrderType().equals(Constant.ORDER_TYP.BH.getValue())) {
|
|
// 同一个类事务会失效 通过重新注入自己解决事务失效问题
|
|
// 同一个类事务会失效 通过重新注入自己解决事务失效问题
|
|
ajaxResult = wmsDocOrderHeaderService.doAllocationBH(s);
|
|
ajaxResult = wmsDocOrderHeaderService.doAllocationBH(s);
|
|
- } else {
|
|
|
|
|
|
+ // 正常出库单
|
|
|
|
+ } else if (header.getOrderType().equals(Constant.ORDER_TYP.ZC.getValue())) {
|
|
// 同一个类事务会失效 通过重新注入自己解决事务失效问题
|
|
// 同一个类事务会失效 通过重新注入自己解决事务失效问题
|
|
ajaxResult = wmsDocOrderHeaderService.doAllocation(s);
|
|
ajaxResult = wmsDocOrderHeaderService.doAllocation(s);
|
|
|
|
+ // 库内理货单
|
|
|
|
+ } else if (header.getOrderType().equals(Constant.ORDER_TYP.LH.getValue())) {
|
|
|
|
+ // 库内理货不需要分配
|
|
|
|
+ ajaxResult = AjaxResult.success();
|
|
}
|
|
}
|
|
if (!ajaxResult.isSuccess()) {
|
|
if (!ajaxResult.isSuccess()) {
|
|
builder.append(s).append(":").append(ajaxResult.getMsg()).append(";");
|
|
builder.append(s).append(":").append(ajaxResult.getMsg()).append(";");
|
|
@@ -373,17 +361,22 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public synchronized AjaxResult doAllocationDetails(WmsDocOrderHeader header, WmsDocOrderDetails details) {
|
|
public synchronized AjaxResult doAllocationDetails(WmsDocOrderHeader header, WmsDocOrderDetails details) {
|
|
- // TODO 改成可以部分分配
|
|
|
|
if (!details.getLineStatus().equals(Constant.ORDER_STS.STS00.getValue())) {
|
|
if (!details.getLineStatus().equals(Constant.ORDER_STS.STS00.getValue())) {
|
|
return AjaxResult.error("出库明细为创建状态才可以分配!");
|
|
return AjaxResult.error("出库明细为创建状态才可以分配!");
|
|
}
|
|
}
|
|
|
|
+ String orderNo = header.getOrderNo();
|
|
LotattDTO lotattDTO = new LotattDTO();
|
|
LotattDTO lotattDTO = new LotattDTO();
|
|
- // 备货分配
|
|
|
|
- if (!StringUtils.isEmpty(header.getUserdefine1())) {
|
|
|
|
- //如果备货的只能查询属于该出库单的库存
|
|
|
|
- lotattDTO.setLotatt14(header.getOrderNo());
|
|
|
|
- }
|
|
|
|
- List<InvLotLocId> invList = invLotLocIdService.queryInvOrderBy(details.getLotnum(), details.getSku(), details.getLocation(), Constant.CUSTOMER_ID, lotattDTO);
|
|
|
|
|
|
+ // 根据sku查询出仓储区空闲库存
|
|
|
|
+ List<InvLotLocIdForm> invListAll = invLotLocIdService.queryInvOrderBy(details.getLotnum()
|
|
|
|
+ , details.getSku(), details.getLocation()
|
|
|
|
+ , Constant.CUSTOMER_ID, lotattDTO);
|
|
|
|
+ // 筛选出没有被分配过的库存
|
|
|
|
+ List<InvLotLocIdForm> invList = invListAll.stream().filter(v -> {
|
|
|
|
+ if (StringUtils.isEmpty(v.getLotatt15()) || orderNo.equals(v.getLotatt15())) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
// 原始订单需分配数
|
|
// 原始订单需分配数
|
|
BigDecimal originalOrderQty = details.getQtyOrdered().subtract(details.getQtyAllocated());
|
|
BigDecimal originalOrderQty = details.getQtyOrdered().subtract(details.getQtyAllocated());
|
|
// 订单需分配数
|
|
// 订单需分配数
|
|
@@ -394,18 +387,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
? item.getQty().doubleValue() - item.getQtyallocated().doubleValue() : 0)
|
|
? item.getQty().doubleValue() - item.getQtyallocated().doubleValue() : 0)
|
|
.sum();
|
|
.sum();
|
|
if (qtySum < orderQty.doubleValue()) {
|
|
if (qtySum < orderQty.doubleValue()) {
|
|
- // TODO 改成可以部分分配
|
|
|
|
return AjaxResult.error("库存不足分配失败");
|
|
return AjaxResult.error("库存不足分配失败");
|
|
}
|
|
}
|
|
- for (InvLotLocId inv : invList) {
|
|
|
|
|
|
+ for (InvLotLocIdForm inv : invList) {
|
|
if (orderQty.doubleValue() == 0) {
|
|
if (orderQty.doubleValue() == 0) {
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
}
|
|
}
|
|
- //可以叫料且合格的库存
|
|
|
|
- InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
|
|
|
|
- if (!lotAtt.getLotatt05().equals("90") || !lotAtt.getLotatt12().equals("Y")) {
|
|
|
|
-// continue;
|
|
|
|
- }
|
|
|
|
|
|
|
|
BigDecimal canallocatedQty = inv.getQty().subtract(inv.getQtyallocated());
|
|
BigDecimal canallocatedQty = inv.getQty().subtract(inv.getQtyallocated());
|
|
if (canallocatedQty.doubleValue() > 0) {
|
|
if (canallocatedQty.doubleValue() > 0) {
|
|
@@ -426,6 +413,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
//生成分配明细
|
|
//生成分配明细
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
, Constant.ORDER_STS.STS20.getValue());
|
|
, Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ //库位对应所有库存lotatt15记录分配出库单号
|
|
|
|
+ invLotLocIdService.updateLotatt15ByLocationId(inv.getLocationId(),orderNo);
|
|
} else {
|
|
} else {
|
|
throw new ServiceException("占用库存分配数失败");
|
|
throw new ServiceException("占用库存分配数失败");
|
|
}
|
|
}
|
|
@@ -445,6 +434,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
//生成分配明细
|
|
//生成分配明细
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
, Constant.ORDER_STS.STS20.getValue());
|
|
, Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ //库位对应所有库存lotatt15记录分配出库单号
|
|
|
|
+ invLotLocIdService.updateLotatt15ByLocationId(inv.getLocationId(),orderNo);
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
} else {
|
|
} else {
|
|
throw new ServiceException("占用库存分配数失败");
|
|
throw new ServiceException("占用库存分配数失败");
|
|
@@ -463,6 +454,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
//生成分配明细
|
|
//生成分配明细
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details
|
|
, Constant.ORDER_STS.STS20.getValue());
|
|
, Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ //库位对应所有库存lotatt15记录分配出库单号
|
|
|
|
+ invLotLocIdService.updateLotatt15ByLocationId(inv.getLocationId(),orderNo);
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -475,7 +468,6 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
return AjaxResult.success("库存数不足,部分分配", originalOrderQty.subtract(orderQty));
|
|
return AjaxResult.success("库存数不足,部分分配", originalOrderQty.subtract(orderQty));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 每次分配只能进入一条线程
|
|
* 每次分配只能进入一条线程
|
|
*
|
|
*
|
|
@@ -486,62 +478,108 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public synchronized AjaxResult doAllocationDetailsBH(WmsDocOrderHeader header, WmsDocOrderDetails details) {
|
|
public synchronized AjaxResult doAllocationDetailsBH(WmsDocOrderHeader header, WmsDocOrderDetails details) {
|
|
- if (!details.getLineStatus().equals(Constant.ORDER_STS.STS23.getValue())) {
|
|
|
|
- return AjaxResult.error("出库明细为备货完成状态才可以分配!");
|
|
|
|
|
|
+ if (!details.getLineStatus().equals(Constant.ORDER_STS.STS00.getValue())
|
|
|
|
+ && !details.getLineStatus().equals(Constant.ORDER_STS.STS10.getValue())) {
|
|
|
|
+ return AjaxResult.error("出库明细状态不可分配!");
|
|
}
|
|
}
|
|
|
|
+ String orderNo = header.getOrderNo();
|
|
LotattDTO lotattDTO = new LotattDTO();
|
|
LotattDTO lotattDTO = new LotattDTO();
|
|
- // 备货对应的出库单库存
|
|
|
|
- lotattDTO.setLotatt14(header.getOrderNo());
|
|
|
|
- List<InvLotLocId> invList = invLotLocIdService.queryInvOrderBy(details.getLotnum(), details.getSku(), details.getLocation(), Constant.CUSTOMER_ID, lotattDTO);
|
|
|
|
|
|
+ // 根据sku查询出仓储区空闲库存
|
|
|
|
+ List<InvLotLocIdForm> invListAll = invLotLocIdService.queryInvOrderBy(details.getLotnum()
|
|
|
|
+ , details.getSku(), details.getLocation()
|
|
|
|
+ , Constant.CUSTOMER_ID, lotattDTO);
|
|
|
|
+ // 筛选出没有被分配过的库存
|
|
|
|
+ List<InvLotLocIdForm> invList = invListAll.stream().filter(v -> {
|
|
|
|
+ if (StringUtils.isEmpty(v.getLotatt15()) || orderNo.equals(v.getLotatt15())) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
// 原始订单需分配数
|
|
// 原始订单需分配数
|
|
- BigDecimal originalOrderQty = details.getQtyOrdered();
|
|
|
|
|
|
+ BigDecimal originalOrderQty = details.getQtyOrdered().subtract(details.getQtyAllocated());
|
|
// 订单需分配数
|
|
// 订单需分配数
|
|
- BigDecimal orderQty = details.getQtyOrdered();
|
|
|
|
|
|
+ BigDecimal orderQty = details.getQtyOrdered().subtract(details.getQtyAllocated());
|
|
// 判断匹配库存总数是否足够分配
|
|
// 判断匹配库存总数是否足够分配
|
|
- double qtySum = invList.stream()
|
|
|
|
- .mapToDouble(item -> item.getQty().doubleValue())
|
|
|
|
- .sum();
|
|
|
|
- if (qtySum < orderQty.doubleValue() && !header.getUserdefine6().equals("Y")) {
|
|
|
|
- return AjaxResult.error("库存不足分配失败");
|
|
|
|
- }
|
|
|
|
- for (InvLotLocId inv : invList) {
|
|
|
|
|
|
+// double qtySum = invList.stream()
|
|
|
|
+// .mapToDouble(item -> item.getQty().doubleValue() > item.getQtyallocated().doubleValue()
|
|
|
|
+// ? item.getQty().doubleValue() - item.getQtyallocated().doubleValue() : 0)
|
|
|
|
+// .sum();
|
|
|
|
+// if (qtySum < orderQty.doubleValue()) {
|
|
|
|
+ // 备货可以部分分配
|
|
|
|
+// return AjaxResult.error("库存不足分配失败");
|
|
|
|
+// }
|
|
|
|
+ for (InvLotLocIdForm inv : invList) {
|
|
if (orderQty.doubleValue() == 0) {
|
|
if (orderQty.doubleValue() == 0) {
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
return AjaxResult.success("分配完成", originalOrderQty);
|
|
}
|
|
}
|
|
- //可以叫料且合格的库存
|
|
|
|
- InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
|
|
|
|
- if (!lotAtt.getLotatt05().equals("90") || !lotAtt.getLotatt12().equals("Y")) {
|
|
|
|
-// continue;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- BigDecimal canallocatedQty = inv.getQty();
|
|
|
|
|
|
+ BigDecimal canallocatedQty = inv.getQty().subtract(inv.getQtyallocated());
|
|
if (canallocatedQty.doubleValue() > 0) {
|
|
if (canallocatedQty.doubleValue() > 0) {
|
|
if (inv.getQty().intValue() > 0) {
|
|
if (inv.getQty().intValue() > 0) {
|
|
// 当前库存可分配数量 < 订单需分配数
|
|
// 当前库存可分配数量 < 订单需分配数
|
|
- if (inv.getQty().compareTo(orderQty) == -1) {
|
|
|
|
|
|
+ if (inv.getQty().subtract(inv.getQtyallocated()).compareTo(orderQty) == -1) {
|
|
//可以分配的库存
|
|
//可以分配的库存
|
|
- BigDecimal allocatedQty = inv.getQty();
|
|
|
|
- orderQty = orderQty.subtract(allocatedQty);
|
|
|
|
- //生成分配明细
|
|
|
|
- actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
|
|
- , Constant.ORDER_STS.STS20.getValue());
|
|
|
|
-
|
|
|
|
|
|
+ BigDecimal allocatedQty = inv.getQty().subtract(inv.getQtyallocated());
|
|
|
|
+ inv.setQtyallocated(inv.getQtyallocated().add(allocatedQty));
|
|
|
|
+ inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(allocatedQty));
|
|
|
|
+ if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
|
|
|
|
+ orderQty = orderQty.subtract(allocatedQty);
|
|
|
|
+ //修改出库单状态
|
|
|
|
+ details.setQtyAllocated(details.getQtyAllocated().add(allocatedQty));
|
|
|
|
+ details.setQtyAllocatedEach(details.getQtyAllocated());
|
|
|
|
+ details.setLineStatus(Constant.ORDER_STS.STS10.getValue());
|
|
|
|
+ wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
|
|
|
|
+ //生成分配明细
|
|
|
|
+ actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
|
|
+ , Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ //库位对应所有库存lotatt15记录分配出库单号
|
|
|
|
+ invLotLocIdService.updateLotatt15ByLocationId(inv.getLocationId(),orderNo);
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException("占用库存分配数失败");
|
|
|
|
+ }
|
|
// 当前库存可分配数量 = 订单需分配数
|
|
// 当前库存可分配数量 = 订单需分配数
|
|
- } else if (inv.getQty().compareTo(orderQty) == 0) {
|
|
|
|
|
|
+ } else if (inv.getQty().subtract(inv.getQtyallocated()).compareTo(orderQty) == 0) {
|
|
//可以分配的库存
|
|
//可以分配的库存
|
|
- BigDecimal allocatedQty = inv.getQty();
|
|
|
|
- //生成分配明细
|
|
|
|
- actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
|
|
- , Constant.ORDER_STS.STS20.getValue());
|
|
|
|
- return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
|
-
|
|
|
|
|
|
+ BigDecimal allocatedQty = inv.getQty().subtract(inv.getQtyallocated());
|
|
|
|
+ inv.setQtyallocated(inv.getQtyallocated().add(allocatedQty));
|
|
|
|
+ inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(allocatedQty));
|
|
|
|
+ if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
|
|
|
|
+ orderQty = orderQty.subtract(allocatedQty);
|
|
|
|
+ //修改出库单状态
|
|
|
|
+ details.setLineStatus(Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ details.setQtyAllocated(details.getQtyAllocated().add(allocatedQty));
|
|
|
|
+ details.setQtyAllocatedEach(details.getQtyAllocatedEach().add(allocatedQty));
|
|
|
|
+ wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
|
|
|
|
+ //生成分配明细
|
|
|
|
+ actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details
|
|
|
|
+ , Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ //库位对应所有库存lotatt15记录分配出库单号
|
|
|
|
+ invLotLocIdService.updateLotatt15ByLocationId(inv.getLocationId(),orderNo);
|
|
|
|
+ return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException("占用库存分配数失败");
|
|
|
|
+ }
|
|
// 当前库存可分配数量 > 订单需分配数
|
|
// 当前库存可分配数量 > 订单需分配数
|
|
} else {
|
|
} else {
|
|
BigDecimal currentQty = orderQty;
|
|
BigDecimal currentQty = orderQty;
|
|
- //生成分配明细
|
|
|
|
- actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details
|
|
|
|
- , Constant.ORDER_STS.STS20.getValue());
|
|
|
|
- return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
|
|
|
+ inv.setQtyallocated(inv.getQtyallocated().add(currentQty));
|
|
|
|
+ inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(currentQty));
|
|
|
|
+ if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
|
|
|
|
+ //修改出库单状态
|
|
|
|
+ details.setLineStatus(Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ details.setQtyAllocated(details.getQtyAllocated().add(currentQty));
|
|
|
|
+ details.setQtyAllocatedEach(details.getQtyAllocatedEach().add(currentQty));
|
|
|
|
+ wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
|
|
|
|
+ //生成分配明细
|
|
|
|
+ actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details
|
|
|
|
+ , Constant.ORDER_STS.STS20.getValue());
|
|
|
|
+ //库位对应所有库存lotatt15记录分配出库单号
|
|
|
|
+ invLotLocIdService.updateLotatt15ByLocationId(inv.getLocationId(),orderNo);
|
|
|
|
+ return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException("占用库存分配数失败");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|