Commit 6f439f44 LN

库存报表bug修改

1 个父辈 19826964
...@@ -992,23 +992,40 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -992,23 +992,40 @@ public class StoragePosManagerImpl implements IStoragePosManager {
} }
// c.and("barcode.status").is(BARCODE_STATUS.IN_STORE); // c.and("barcode.status").is(BARCODE_STATUS.IN_STORE);
c=c.and("barcode.subCodeList").exists(true); c=c.and("barcode.subCodeList").exists(true);
// Aggregation agg = Aggregation.newAggregation(
// Aggregation.match(c),
// Aggregation.unwind("barcode.subCodeList"),
// Aggregation.group("barcode.subCodeList.partNumber")
// .first("barcode.subCodeList.partNumber").as("partNumber")
// .first("barcode.barcode").as("boxName")
// .first("barcode.subCodeList.barcode").as("gekouName")
// .first("barcode.subCodeList.pn").as("partname")
// .first("wareHouseCode").as("wareHouseCode")
// .sum("barcode.subCodeList.amount").as("stockCount").count().as("stockReel"),
// Aggregation.project("stockCount", "stockReel")
// .and("partNumber").as("partNumber")
// .and("boxName").as("boxName")
// .and("partname").as("partname")
// .and("gekouName").as("gekouName")
// .and("wareHouseCode").as("wareHouseCode")
//
// );
Aggregation agg = Aggregation.newAggregation( Aggregation agg = Aggregation.newAggregation(
Aggregation.match(c), Aggregation.match(c),
Aggregation.unwind("barcode.subCodeList"), Aggregation.unwind("barcode.subCodeList"),
Aggregation.group("barcode.subCodeList.partNumber") Aggregation.group("barcode.subCodeList.partNumber")
.first("barcode.subCodeList.partNumber").as("partNumber") .first("barcode.subCodeList.partNumber").as("partNumberGroup")
.first("barcode.barcode").as("boxName") .first("barcode.barcode").as("boxName")
.first("barcode.subCodeList.barcode").as("gekouName") .first("barcode.subCodeList.barcode").as("gekouName")
.first("barcode.subCodeList.pn").as("partname") .first("barcode.subCodeList.pn").as("partname")
.first("wareHouseCode").as("wareHouseCode") .first("wareHouseCode").as("wareHouseCode")
.sum("barcode.subCodeList.amount").as("stockCount").count().as("stockReel"), .sum("barcode.subCodeList.amount").as("totalStockCount").count().as("stockReel"),
Aggregation.project("stockCount", "stockReel") Aggregation.project("totalStockCount", "stockReel")
.and("partNumber").as("partNumber") .and("partNumberGroup").as("partNumber")
.and("boxName").as("boxName") .and("boxName").as("boxName")
.and("partname").as("partname") .and("partname").as("partname")
.and("gekouName").as("gekouName") .and("gekouName").as("gekouName")
.and("wareHouseCode").as("wareHouseCode") .and("wareHouseCode").as("wareHouseCode")
); );
AggregationResults<InventoryItem> results = storagePosDao.getMongoTemplate().aggregate(agg, StoragePos.class, InventoryItem.class); AggregationResults<InventoryItem> results = storagePosDao.getMongoTemplate().aggregate(agg, StoragePos.class, InventoryItem.class);
return results.getMappedResults(); return results.getMappedResults();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!