|
@@ -12,14 +12,15 @@ import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
import com.fjhx.item.enums.ProductAvailableRecordType;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
|
|
|
+import com.fjhx.sale.entity.arrival.po.Arrival;
|
|
|
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.service.arrival.ArrivalService;
|
|
|
import com.fjhx.sale.service.purchase.EhsdPurchaseProductService;
|
|
|
import com.fjhx.sale.service.purchase.EhsdPurchaseProjectService;
|
|
|
import com.fjhx.sale.service.purchase.EhsdPurchaseService;
|
|
|
-import com.fjhx.wms.entity.stock.po.StockWaitDetails;
|
|
|
import com.fjhx.wms.service.stock.StockWaitDetailsService;
|
|
|
import com.fjhx.wms.service.stock.StockWaitService;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
@@ -53,6 +54,8 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
|
|
|
private StockWaitDetailsService stockWaitDetailsService;
|
|
|
@Autowired
|
|
|
private StockWaitService stockWaitService;
|
|
|
+ @Autowired
|
|
|
+ private ArrivalService arrivalService;
|
|
|
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
@@ -66,6 +69,7 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
|
|
|
public Long start(Long flowId, JSONObject submitData) {
|
|
|
EhsdPurchaseDto purchase = submitData.toJavaObject(EhsdPurchaseDto.class);
|
|
|
Assert.notEmpty(purchase.getId(), "原采购订单id不能为空");
|
|
|
+
|
|
|
|
|
|
purchase.setOldPurchaseId(purchase.getId());
|
|
|
purchase.setId(null);
|
|
@@ -76,6 +80,11 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
|
|
|
|
|
|
Long oldPurchaseId = purchase.getOldPurchaseId();
|
|
|
|
|
|
+
|
|
|
+ if (arrivalService.count(q -> q.eq(Arrival::getPurchaseId, oldPurchaseId)) > 0) {
|
|
|
+ throw new ServiceException("该采购订单存在到货记录,禁止变更!");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
EhsdPurchase oldPurchase = ehsdPurchaseService.getById(oldPurchaseId);
|
|
|
Assert.notEmpty(oldPurchase, "查询不到原采购订单信息");
|
|
@@ -141,40 +150,39 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
|
|
|
List<AvailableStockBo> availableStockBoList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
- Long stockWaitId = null;
|
|
|
for (EhsdPurchaseProduct oldPurchaseProduct : oldPurchaseProductList) {
|
|
|
|
|
|
BigDecimal newQuantity = newQuantityMap.get(oldPurchaseProduct.getId());
|
|
|
-
|
|
|
- StockWaitDetails stockWaitDetails = stockWaitDetailsService.getOne(q -> q.eq(StockWaitDetails::getBusinessDetailsId, oldPurchaseProduct.getId()));
|
|
|
- stockWaitId = stockWaitDetails.getStockWaitId();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
AvailableStockBo availableStockBo = new AvailableStockBo();
|
|
|
availableStockBo.setProductId(oldPurchaseProduct.getProductId());
|
|
|
availableStockBo.setQuantity(oldPurchaseProduct.getQuantity());
|
|
|
availableStockBo.setNewQuantity(newQuantity);
|
|
|
- availableStockBo.setInStockQuantity(stockWaitDetails.getReceiptQuantity());
|
|
|
+ availableStockBo.setInStockQuantity(BigDecimal.ZERO);
|
|
|
|
|
|
availableStockBoList.add(availableStockBo);
|
|
|
|
|
|
|
|
|
-
|
|
|
- if (ObjectUtils.isEmpty(newQuantity)) {
|
|
|
-
|
|
|
- stockWaitDetailsService.removeById(stockWaitDetails);
|
|
|
- } else {
|
|
|
- stockWaitDetails.setQuantity(newQuantity);
|
|
|
-
|
|
|
- int status = stockWaitDetails.getReceiptQuantity().compareTo(stockWaitDetails.getQuantity()) >= 0 ? 2 : 1;
|
|
|
- if (stockWaitDetails.getReceiptQuantity().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- status = 0;
|
|
|
- }
|
|
|
- stockWaitDetails.setStatus(status);
|
|
|
- stockWaitDetailsService.updateById(stockWaitDetails);
|
|
|
-
|
|
|
- stockWaitService.updateStatus(stockWaitDetails.getStockWaitId());
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -191,19 +199,19 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
|
|
|
availableStockBo.setInStockQuantity(null);
|
|
|
availableStockBoList.add(availableStockBo);
|
|
|
|
|
|
-
|
|
|
- Assert.notEmpty(stockWaitId, "查询不到待入库信息!");
|
|
|
- StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
- stockWaitDetails.setStockWaitId(stockWaitId);
|
|
|
- stockWaitDetails.setBusinessDetailsId(newPurchaseProduct.getId());
|
|
|
- stockWaitDetails.setPurchaseDetailId(newPurchaseProduct.getId());
|
|
|
-
|
|
|
- stockWaitDetails.setProductId(newPurchaseProduct.getProductId());
|
|
|
- stockWaitDetails.setQuantity(newPurchaseProduct.getQuantity());
|
|
|
- stockWaitDetails.setStatus(0);
|
|
|
- stockWaitDetailsService.save(stockWaitDetails);
|
|
|
-
|
|
|
- stockWaitService.updateStatus(stockWaitDetails.getStockWaitId());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|