|
@@ -18,17 +18,19 @@ import com.fjhx.item.enums.ProductAvailableRecordType;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.purchase.entity.purchase.enums.PurchaseDataResourceEnum;
|
|
|
import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
|
|
|
+import com.fjhx.purchase.entity.subscribe.po.SubscribeDetail;
|
|
|
+import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
|
|
|
import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
|
|
|
import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProduct;
|
|
|
import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProject;
|
|
|
import com.fjhx.sale.entity.sample.po.Sample;
|
|
|
+import com.fjhx.sale.mapper.purchase.EhsdPurchaseProductMapper;
|
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
|
import com.fjhx.sale.service.purchase.EhsdPurchaseProductService;
|
|
|
import com.fjhx.sale.service.purchase.EhsdPurchaseProjectService;
|
|
|
import com.fjhx.sale.service.purchase.EhsdPurchaseService;
|
|
|
-import com.fjhx.sale.service.sample.SampleProductService;
|
|
|
import com.fjhx.sale.service.sample.SampleService;
|
|
|
import com.fjhx.wms.entity.stock.emums.JournalType;
|
|
|
import com.fjhx.wms.entity.stock.po.StockWait;
|
|
@@ -42,6 +44,7 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -64,8 +67,6 @@ public class EhsdPurchaseFlow extends FlowDelegate {
|
|
|
|
|
|
@Autowired
|
|
|
private EhsdPurchaseProjectService purchaseProjectService;
|
|
|
- @Autowired
|
|
|
- private SampleProductService sampleProductService;
|
|
|
|
|
|
@Autowired
|
|
|
private CodingRuleService codingRuleService;
|
|
@@ -79,6 +80,10 @@ public class EhsdPurchaseFlow extends FlowDelegate {
|
|
|
private StockWaitService stockWaitService;
|
|
|
@Autowired
|
|
|
private StockWaitDetailsService stockWaitDetailsService;
|
|
|
+ @Autowired
|
|
|
+ private EhsdPurchaseProductMapper purchaseProductMapper;
|
|
|
+ @Autowired
|
|
|
+ private SubscribeDetailService subscribeDetailService;
|
|
|
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
@@ -220,6 +225,30 @@ public class EhsdPurchaseFlow extends FlowDelegate {
|
|
|
inOutBo.setQuantity(purchaseProduct.getQuantity());
|
|
|
inOutBoList.add(inOutBo);
|
|
|
}
|
|
|
+
|
|
|
+ //数据来源是合同
|
|
|
+ if (Objects.equals(purchaseProduct.getDataResource(), PurchaseDataResourceEnum.DATA_RESOURCE_1.getKey())) {
|
|
|
+ //获取采购,待采购信息
|
|
|
+ Long subscribeDetailId = purchaseProduct.getSubscribeDetailId();
|
|
|
+ BigDecimal purchaseSumCount = purchaseProductMapper.getPurchaseQuantitySumBySubscribeDetailId(subscribeDetailId);
|
|
|
+ SubscribeDetail subscribeDetail = subscribeDetailService.getById(subscribeDetailId);
|
|
|
+ Assert.notEmpty(subscribeDetail, "查询不到待采购信息!");
|
|
|
+
|
|
|
+ //已采购数量>待采购 本次超采量=已采购数量-待采购量-((已采购-本次采购)-待采购量)
|
|
|
+ if (purchaseSumCount.compareTo(subscribeDetail.getCount()) > 0) {
|
|
|
+ //计算超采量
|
|
|
+ BigDecimal oldPurchaseCount = purchaseSumCount.subtract(purchaseProduct.getQuantity());//(已采购-本次采购)
|
|
|
+ BigDecimal subtract = oldPurchaseCount.subtract(subscribeDetail.getCount());//((已采购-本次采购)-待采购量)
|
|
|
+ BigDecimal exceedQuantity = purchaseSumCount.subtract(subscribeDetail.getCount()).subtract(subtract);
|
|
|
+
|
|
|
+ purchaseProduct.setExceedQuantity(exceedQuantity);
|
|
|
+
|
|
|
+ AvailableStockBo inOutBo = new AvailableStockBo();
|
|
|
+ inOutBo.setProductId(purchaseProduct.getProductId());
|
|
|
+ inOutBo.setQuantity(exceedQuantity);
|
|
|
+ inOutBoList.add(inOutBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
productInfoService.editAvailableQuantity(inOutBoList, businessId, ProductAvailableRecordType.PURCHASE_PASS, purchase.getCompanyId());
|
|
|
|