Ver código fonte

统计扣库存

wangqifan 3 anos atrás
pai
commit
a9cf1af18f

+ 3 - 0
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -202,6 +202,9 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
     @Query("select sum(c.total) from Collection c where c.source = 'OFFICIAL' and c.name like ?1 and c.type = 'DEFAULT'")
     Long sumAllByNameLike(String name);
 
+    @Query("select sum(c.stock) from Collection c where c.source = 'OFFICIAL' and c.name like ?1 and c.type = 'DEFAULT'")
+    Long sumStockByNameLike(String name);
+
     Collection findFirstByOnShelfAndAssetId(boolean onShelf, Long assetId);
 
     List<Collection> findAllByOasisIdInAndSourceInAndStockGreaterThan(List<Long> oasisIds, List<CollectionSource> sources, int sale);

+ 3 - 1
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -236,9 +236,11 @@ public class CollectionController extends BaseController {
         long transactingNum = collectionService.all(pageQuery).getTotal();
         Long destroyedAssets = 0L;
         Long total = 0L;
+        Long stock = 0L;
         destroyedAssets = collectionService.countDestroyAssets(search);
         total = collectionRepo.sumAllByNameLike("%" + search + "%");
-        Long tranferCount = total - destroyedAssets;
+        stock = collectionRepo.sumStockByNameLike("%" + search + "%");
+        Long tranferCount = total - destroyedAssets - stock;
         Map<String, String> map = new HashMap<>();
         map.put("onlyShowNum", String.valueOf(onlyShowNum));
         map.put("consignmentNum", String.valueOf(consignmentNum));