Browse Source

修改到货数量为采购数量+退货数量

fgd 1 year ago
parent
commit
42b21845a9

+ 2 - 2
sd-business/src/main/java/com/sd/business/service/purchase/impl/PurchaseBomServiceImpl.java

@@ -141,7 +141,7 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
         wrapper.like("p", Purchase::getCode, dto.getPurchaseCode());
         wrapper.like("bs", BomSpec::getCode, dto.getBomSpecCode());
         wrapper.like("bs", BomSpec::getName, dto.getBomSpecName());
-        wrapper.apply("pb.purchase_quantity > pb.arrival_quantity");
+        wrapper.apply("(pb.purchase_quantity + pb.return_quantity) > pb.arrival_quantity");
         wrapper.orderByAsc("bs", BomSpec::getCode)
                 .orderByDesc("bs", BomSpec::getLength)
                 .orderByAsc("bs", BomSpec::getWidth)
@@ -264,7 +264,7 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
         IWrapper<PurchaseBom> wrapper = getWrapper();
         wrapper.in("pb", PurchaseBom::getBomSpecId, bomSpecIds);
         wrapper.eq("p", Purchase::getStatus, PurchaseStatusEnum.UNDER_PURCHASE.getKey());
-        wrapper.apply("pb.purchase_quantity > pb.arrival_quantity");
+        wrapper.apply("(pb.purchase_quantity + pb.return_quantity) > pb.arrival_quantity");
         wrapper.groupBy("pb.bom_spec_id");
         return this.baseMapper.getPurchaseBomInTransitSum(wrapper);
     }

+ 3 - 3
sd-business/src/main/java/com/sd/business/service/purchase/impl/PurchaseServiceImpl.java

@@ -270,7 +270,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
                 purchaseBomService.update(q -> q.eq(PurchaseBom::getId, bom.getId()).set(PurchaseBom::getArrivalQuantity, bom.getArrivalQuantity().add(inOutStorageBom.getQuantity())));
 
                 // 查询当前采购在途数量
-                long count = purchaseBomService.count(q -> q.eq(PurchaseBom::getPurchaseId, purchaseId).apply("purchase_quantity > arrival_quantity"));
+                long count = purchaseBomService.count(q -> q.eq(PurchaseBom::getPurchaseId, purchaseId).apply("(purchase_quantity + return_quantity) > arrival_quantity"));
                 if (count == 0) {
                     // 如果为0,将入库状态设置为已完成
                     this.update(q -> q.set(Purchase::getStorageStatus, StatusConstant.YES)
@@ -292,9 +292,9 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
         this.updateById(purchase);
 
         // 合同终止将bom到货数量设置为采购数量
-        List<PurchaseBom> purchaseBomList = purchaseBomService.list(q -> q.eq(PurchaseBom::getPurchaseId, id).apply("purchase_quantity > arrival_quantity"));
+        List<PurchaseBom> purchaseBomList = purchaseBomService.list(q -> q.eq(PurchaseBom::getPurchaseId, id).apply("(purchase_quantity + return_quantity) > arrival_quantity"));
         for (PurchaseBom purchaseBom : purchaseBomList) {
-            purchaseBom.setArrivalQuantity(purchaseBom.getPurchaseQuantity());
+            purchaseBom.setArrivalQuantity(purchaseBom.getPurchaseQuantity().add(purchaseBom.getReturnQuantity()));
         }
         purchaseBomService.updateBatchById(purchaseBomList);
     }

+ 1 - 1
sd-business/src/main/resources/mapper/purchase/PurchaseBomMapper.xml

@@ -170,7 +170,7 @@
                 from
                     purchase_bom pb
                     left join purchase p on pb.purchase_id = p.id
-                where pb.purchase_quantity > pb.arrival_quantity
+                where (pb.purchase_quantity + pb.return_quantity) > pb.arrival_quantity
                     and p.storage_status = 0
                     and p.delivery_date > now()
                 group by pb.bom_spec_id