|
@@ -50,6 +50,7 @@ import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.ams.order.mapper.WmsDocOrderHeaderMapper;
|
|
|
import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
|
|
|
import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
/**
|
|
@@ -201,7 +202,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
* @param orderNo
|
|
|
* @return
|
|
|
*/
|
|
|
- @Transactional
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
@Override
|
|
|
public AjaxResult doAllocation(String orderNo) {
|
|
|
WmsDocOrderHeader orderHeader = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderByOrderNo(orderNo);
|
|
@@ -234,7 +235,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
if (isbf) {
|
|
|
orderHeader.setOrderStatus("10");
|
|
|
wmsDocOrderHeaderService.updateWmsDocOrderHeader(orderHeader);
|
|
|
- return AjaxResult.success("部分分配");
|
|
|
+ throw new ServiceException("库存数量不足,分配失败!" + orderNo);
|
|
|
}
|
|
|
if (isAllocation) {
|
|
|
orderHeader.setOrderStatus("20");
|
|
@@ -245,10 +246,10 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
@Override
|
|
|
public AjaxResult doAllocation(List<String> orderNoList) {
|
|
|
for (String s : orderNoList) {
|
|
|
+ // 同一个类事务会失效 通过重新注入自己解决事务失效问题
|
|
|
wmsDocOrderHeaderService.doAllocation(s);
|
|
|
}
|
|
|
return AjaxResult.success("分配成功");
|
|
@@ -271,7 +272,10 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
//库存可分配数小于订单数
|
|
|
BigDecimal orderQty = details.getQtyOrdered();
|
|
|
//判断总数是否足够分配
|
|
|
- double qtySum = invList.stream().mapToDouble(item -> item.getQty().doubleValue() > item.getQtyallocated().doubleValue() ? item.getQty().doubleValue() : 0).sum();
|
|
|
+ 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("库存不足分配失败");
|
|
|
}
|
|
@@ -282,7 +286,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
//可以叫料且合格的库存
|
|
|
InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
|
|
|
if (!lotAtt.getLotatt05().equals("90") || !lotAtt.getLotatt12().equals("Y")) {
|
|
|
- continue;
|
|
|
+// continue;
|
|
|
}
|
|
|
|
|
|
BigDecimal canallocatedQty = inv.getQty().subtract(inv.getQtyallocated());
|
|
@@ -306,7 +310,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
//生成分配明细
|
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details, "20");
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ throw new ServiceException("占用库存分配数失败");
|
|
|
}
|
|
|
} else if (inv.getQty().subtract(inv.getQtyallocated()).compareTo(orderQty) == 0) {
|
|
|
//可以分配的库存
|
|
@@ -731,6 +735,17 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
System.out.println(extParam);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> changeErpNoToOrderNo(List<String> erpNos) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String changeErpNoToOrderNo(String erpNo) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void addOrUpdateErp(List<ErpOrderList> erpOrderLists) {
|
|
|
String orderNo = idSequenceUtils.generateId("ORDERNO");
|