mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
feat(warehouse): 添加供应商报告功能
- 在 WarehouseReceiptController 中新增 supplierReport 方法处理供应商报告请求- 在 WarehouseReceiptService 中实现 supplierReport 方法的业务逻辑 -该功能通过查询数据库生成供应商相关的入库报告,包括入库单数量、入库单明细数量、入库商品种数、入库商品数量和入库商品总价等信息
This commit is contained in:
@@ -64,4 +64,5 @@ public class WarehouseGoodsController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -71,5 +71,9 @@ public class WarehouseReceiptController {
|
||||
return this.service.report(request);
|
||||
}
|
||||
|
||||
@PostMapping("/supplierReport")
|
||||
public Object supplierReport(@RequestBody WarehouseReportRequest request) {
|
||||
return this.service.supplierReport(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +100,10 @@ public class WarehouseReceiptService
|
||||
if (CollectionUtils.isNotEmpty(entity.getDetail())) {
|
||||
|
||||
entity.getDetail()
|
||||
.forEach(item -> {item.setSupplier(null);});
|
||||
.forEach(
|
||||
item -> {
|
||||
item.setSupplier(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -939,4 +942,320 @@ from (
|
||||
criteriaBuilder.and(
|
||||
root.get("detail").get("goods").get("id").in(ids)));
|
||||
}
|
||||
|
||||
public Object supplierReport(WarehouseReportRequest request) {
|
||||
|
||||
request.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
|
||||
String sql =
|
||||
FreeMakerUtils.render(
|
||||
"""
|
||||
|
||||
|
||||
with tmp1 as (
|
||||
|
||||
|
||||
select s.*,
|
||||
|
||||
(select count(distinct re.id)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
on re.id = d.receipt_id
|
||||
inner join t_warehouse_goods gs on d.goods_id = gs.id
|
||||
where re.organization_id = s.organization_id
|
||||
and re.receipt_type = '0'
|
||||
and d.supplier_id = s.id
|
||||
<#if startTime??>
|
||||
and re.receipt_date >= :startTime
|
||||
</#if>
|
||||
<#if endTime??>
|
||||
and re.receipt_date <= :endTime
|
||||
</#if>
|
||||
<#if reason??>
|
||||
and re.reason like '%' || :reason || '%'
|
||||
</#if>
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
|
||||
) as "入库单数量",
|
||||
|
||||
(select count(d.id)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
on re.id = d.receipt_id
|
||||
inner join t_warehouse_goods gs on d.goods_id = gs.id
|
||||
where re.organization_id = s.organization_id
|
||||
and re.receipt_type = '0'
|
||||
and d.supplier_id = s.id
|
||||
|
||||
<#if startTime??>
|
||||
and re.receipt_date >= :startTime
|
||||
</#if>
|
||||
<#if endTime??>
|
||||
and re.receipt_date <= :endTime
|
||||
</#if>
|
||||
<#if reason??>
|
||||
and re.reason like '%' || :reason || '%'
|
||||
</#if>
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
) as "入库单明细数量",
|
||||
|
||||
(select count(distinct d.goods_id)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
on re.id = d.receipt_id
|
||||
inner join t_warehouse_goods gs on d.goods_id = gs.id
|
||||
where re.organization_id = s.organization_id
|
||||
and re.receipt_type = '0'
|
||||
and d.supplier_id = s.id
|
||||
<#if startTime??>
|
||||
and re.receipt_date >= :startTime
|
||||
</#if>
|
||||
<#if endTime??>
|
||||
and re.receipt_date <= :endTime
|
||||
</#if>
|
||||
<#if reason??>
|
||||
and re.reason like '%' || :reason || '%'
|
||||
</#if>
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
|
||||
) as "入库商品种数",
|
||||
|
||||
(select round(sum(d.number)::::numeric, 2)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
on re.id = d.receipt_id
|
||||
inner join t_warehouse_goods gs on d.goods_id = gs.id
|
||||
where re.organization_id = s.organization_id
|
||||
and re.receipt_type = '0'
|
||||
and d.supplier_id = s.id
|
||||
<#if startTime??>
|
||||
and re.receipt_date >= :startTime
|
||||
</#if>
|
||||
<#if endTime??>
|
||||
and re.receipt_date <= :endTime
|
||||
</#if>
|
||||
<#if reason??>
|
||||
and re.reason like '%' || :reason || '%'
|
||||
</#if>
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
) as "入库商品数量",
|
||||
|
||||
(select round(sum(d.amount)::::numeric, 2)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
on re.id = d.receipt_id
|
||||
inner join t_warehouse_goods gs on d.goods_id = gs.id
|
||||
where re.organization_id = s.organization_id
|
||||
and re.receipt_type = '0'
|
||||
and d.supplier_id = s.id
|
||||
|
||||
<#if startTime??>
|
||||
and re.receipt_date >= :startTime
|
||||
</#if>
|
||||
<#if endTime??>
|
||||
and re.receipt_date <= :endTime
|
||||
</#if>
|
||||
<#if reason??>
|
||||
and re.reason like '%' || :reason || '%'
|
||||
</#if>
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
|
||||
) as "入库商品总价"
|
||||
|
||||
|
||||
from t_warehouse_supplier s
|
||||
where s.organization_id = :organizationId
|
||||
)
|
||||
|
||||
|
||||
select * from tmp1
|
||||
|
||||
|
||||
<#if excludeEmpty>
|
||||
|
||||
where "入库单数量" > 0
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
""",
|
||||
request);
|
||||
|
||||
var countSql = "select count(1) from (" + sql + ") as t";
|
||||
|
||||
var selectSql =
|
||||
"select * from ("
|
||||
+ sql
|
||||
+ ") as t limit "
|
||||
+ request.getPageSize()
|
||||
+ " offset "
|
||||
+ request.getPageNo() * request.getPageSize();
|
||||
|
||||
Integer count = JpaUtils.execNativeQuery(em, countSql, request, Integer.class).get(0);
|
||||
|
||||
List<Tuple> data = JpaUtils.execNativeQuery(em, selectSql, request, Tuple.class);
|
||||
|
||||
var resultList = JpaUtils.convertTuplesToMap(data);
|
||||
|
||||
var ans =
|
||||
resultList.stream()
|
||||
.map(
|
||||
x ->
|
||||
((Map) x)
|
||||
.entrySet().stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
(Map.Entry e) ->
|
||||
CaseFormat
|
||||
.LOWER_UNDERSCORE
|
||||
.to(
|
||||
CaseFormat
|
||||
.LOWER_CAMEL,
|
||||
e.getKey()
|
||||
.toString()),
|
||||
e ->
|
||||
ObjectUtils
|
||||
.defaultIfNull(
|
||||
e
|
||||
.getValue(),
|
||||
""))))
|
||||
.toList();
|
||||
|
||||
return new PageImpl<>(ans, PageRequest.of(0, request.getPageSize()), count);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user