|
@@ -261,6 +261,15 @@ public class ContractUpdateFlow extends FlowDelegate {
|
|
|
//已采购数量
|
|
|
BigDecimal purchaseQuantity = collect.getOrDefault(materialId, BigDecimal.ZERO);
|
|
|
|
|
|
+ //获取原需采购量
|
|
|
+ SubscribeDetail subscribeDetail = subscribeDetailService.getOne(q -> q.eq(SubscribeDetail::getContractId, oldContractId)
|
|
|
+ .eq(SubscribeDetail::getProductId, materialId)
|
|
|
+ );
|
|
|
+ BigDecimal demandPurchaseCount = BigDecimal.ZERO;
|
|
|
+ if (ObjectUtils.isNotEmpty(subscribeDetail)) {
|
|
|
+ demandPurchaseCount = subscribeDetail.getCount();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//生成操作可用库存的实体
|
|
|
AvailableStockBo availableStockBo = new AvailableStockBo();
|
|
@@ -268,37 +277,10 @@ public class ContractUpdateFlow extends FlowDelegate {
|
|
|
availableStockBo.setQuantity(oldContractProductBom.getQuantity());
|
|
|
availableStockBo.setNewQuantity(newQuantity);
|
|
|
availableStockBo.setInStockQuantity(purchaseQuantity);
|
|
|
+ availableStockBo.setDemandPurchaseCount(demandPurchaseCount);
|
|
|
|
|
|
availableStockBoList.add(availableStockBo);
|
|
|
|
|
|
-
|
|
|
-// //操作待采购数据
|
|
|
-// SubscribeDetail subscribeDetail = subscribeDetailService.getOne(q -> q.eq(SubscribeDetail::getContractId, oldContractId)
|
|
|
-// .eq(SubscribeDetail::getProductId, materialId)
|
|
|
-// );
|
|
|
-// if (ObjectUtils.isEmpty(newQuantity)) {
|
|
|
-// //原数据被删,检查已采购数量
|
|
|
-// if (ObjectUtils.isEmpty(purchaseQuantity)) {
|
|
|
-// subscribeDetailService.removeById(subscribeDetail);
|
|
|
-// } else {
|
|
|
-// subscribeDetailService.update(q -> q
|
|
|
-// .eq(SubscribeDetail::getContractId, oldContractId)
|
|
|
-// .eq(SubscribeDetail::getProductId, materialId)
|
|
|
-// .set(SubscribeDetail::getCount, BigDecimal.ZERO)
|
|
|
-// );
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// subscribeDetail.setCount(newQuantity);
|
|
|
-//
|
|
|
-// //计算状态
|
|
|
-// int status = purchaseQuantity.compareTo(newQuantity) >= 0 ? 20 : 30;
|
|
|
-// if (purchaseQuantity.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
-// status = 15;
|
|
|
-// }
|
|
|
-// subscribeDetail.setStatus(status);
|
|
|
-// subscribeDetailService.updateById(subscribeDetail);
|
|
|
-// }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//新添加的数据处理
|
|
@@ -318,18 +300,9 @@ public class ContractUpdateFlow extends FlowDelegate {
|
|
|
availableStockBo.setQuantity(null);
|
|
|
availableStockBo.setNewQuantity(newPurchaseProduct.getQuantity());
|
|
|
availableStockBo.setInStockQuantity(null);
|
|
|
- availableStockBoList.add(availableStockBo);
|
|
|
-
|
|
|
+ availableStockBo.setDemandPurchaseCount(BigDecimal.ZERO);
|
|
|
|
|
|
-// //生成待采购
|
|
|
-// SubscribeDetail subscribeDetail = new SubscribeDetail();
|
|
|
-// subscribeDetail.setProductId(materialId);
|
|
|
-// subscribeDetail.setCount(newPurchaseProduct.getQuantity());
|
|
|
-// subscribeDetail.setStatus(15);//待采购
|
|
|
-// subscribeDetail.setContractId(oldContractId);
|
|
|
-// subscribeDetail.setDataType(1);
|
|
|
-// subscribeDetail.setCompanyId(oldContract.getCompanyId());
|
|
|
-// subscribeDetailService.save(subscribeDetail);
|
|
|
+ availableStockBoList.add(availableStockBo);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -347,15 +320,9 @@ public class ContractUpdateFlow extends FlowDelegate {
|
|
|
|
|
|
BigDecimal requiredQuantity = availableStockBo.getNewQuantity();
|
|
|
|
|
|
- //需采购=已采购 虚采购量=0
|
|
|
- if (requiredQuantity.compareTo(availableStockBo.getInStockQuantity()) == 0 && requiredQuantity.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- if (ObjectUtils.isNotEmpty(subscribeDetail)) {
|
|
|
- subscribeDetailService.removeById(subscribeDetail);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
//需采购量>0
|
|
|
- else if (requiredQuantity.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (requiredQuantity.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
if (ObjectUtils.isEmpty(subscribeDetail)) {
|
|
|
//生成待采购
|
|
|
subscribeDetail = new SubscribeDetail();
|
|
@@ -379,6 +346,11 @@ public class ContractUpdateFlow extends FlowDelegate {
|
|
|
subscribeDetail.setStatus(status);
|
|
|
|
|
|
subscribeDetailService.saveOrUpdate(subscribeDetail);
|
|
|
+ } else {
|
|
|
+ //需采购==0不显示或删除,<不存在
|
|
|
+ if (ObjectUtils.isNotEmpty(subscribeDetail)) {
|
|
|
+ subscribeDetailService.removeById(subscribeDetail);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|