mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
feat: 完善报表
This commit is contained in:
@@ -21,6 +21,7 @@ public class TimeStatementInspector implements StatementInspector {
|
||||
String startTime = (String) ThreadLocalUtils.get("startTime", null);
|
||||
|
||||
String endTime = (String) ThreadLocalUtils.get("endTime", null);
|
||||
String supplierId = (String) ThreadLocalUtils.get("supplierId", null);
|
||||
|
||||
if (startTime != null) {
|
||||
sql = sql.replace(":startTime", startTime);
|
||||
@@ -30,6 +31,12 @@ public class TimeStatementInspector implements StatementInspector {
|
||||
sql = sql.replace(":endTime", endTime);
|
||||
}
|
||||
|
||||
|
||||
if (supplierId != null) {
|
||||
sql = sql.replace(":supplier", supplierId);
|
||||
}
|
||||
|
||||
return sql;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ select
|
||||
g.shelf_life,
|
||||
d.warehouse_id as warehouse_id,
|
||||
count(d.id) over (partition by g.id) as detail_count,
|
||||
round((sum(d.number) filter ( where d.receipt_type = '0' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
round((sum(d.number) filter ( where d.receipt_type = '0' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) :supplier ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
2) as type0number,
|
||||
round((sum(d.number) filter ( where d.receipt_type = '1' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
round((sum(d.number) filter ( where d.receipt_type = '1' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) :supplier ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
2) as type1number,
|
||||
|
||||
round((sum(d.amount) filter ( where d.receipt_type = '0' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
round((sum(d.amount) filter ( where d.receipt_type = '0' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) :supplier ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
2) as type0amount,
|
||||
round((sum(d.amount) filter ( where d.receipt_type = '1' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
round((sum(d.amount) filter ( where d.receipt_type = '1' and (r.receipt_date >= :startTime and r.receipt_date <= :endTime) :supplier ) over (partition by g.id, d.warehouse_id))::numeric,
|
||||
2) as type1amount
|
||||
|
||||
from t_warehouse_goods g
|
||||
|
||||
@@ -113,6 +113,8 @@ public class WarehouseGoodsSummaryService
|
||||
ThreadLocalUtils.remove("startTime");
|
||||
ThreadLocalUtils.remove("endTime");
|
||||
|
||||
ThreadLocalUtils.remove("supplierId");
|
||||
|
||||
ThreadLocalUtils.remove("enableTimeStatementInspector");
|
||||
|
||||
Page<WarehouseGoodsSummaryDto> dtos = page.map(this.mapper::toDto);
|
||||
@@ -126,6 +128,7 @@ public class WarehouseGoodsSummaryService
|
||||
|
||||
CommonQuery.QueryItem endTimeItem = copy.deleteItem("endTime");
|
||||
|
||||
|
||||
if (startTimeItem == null || conversionService.convert(startTimeItem.getValue(), LocalDateTime.class).equals(MIN_TIME)) {
|
||||
return dtos;
|
||||
}
|
||||
@@ -137,6 +140,8 @@ public class WarehouseGoodsSummaryService
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
copy.getItems().add(new CommonQuery.QueryItem().withKey("startTime").withValue(LocalDateTimeUtil.format(startTime, "yyyy-MM-dd HH:mm:ss")));
|
||||
copy.getItems().add(new CommonQuery.QueryItem().withKey("endTime").withValue(LocalDateTimeUtil.format(endTime, "yyyy-MM-dd HH:mm:ss")));
|
||||
copy.getItems().add(new CommonQuery.QueryItem().withKey("id").withOpt("in").withValue(dtos.getContent().stream().map(WarehouseGoodsSummaryDto::getId).collect(Collectors.joining(","))));
|
||||
@@ -167,6 +172,7 @@ public class WarehouseGoodsSummaryService
|
||||
CommonQuery.QueryItem startTimeItem = query.deleteItem("startTime");
|
||||
|
||||
CommonQuery.QueryItem endTimeItem = query.deleteItem("endTime");
|
||||
CommonQuery.QueryItem supplierIdItem = query.deleteItem("supplierId");
|
||||
|
||||
LocalDateTime startTime =
|
||||
startTimeItem == null
|
||||
@@ -178,6 +184,9 @@ public class WarehouseGoodsSummaryService
|
||||
? MAX_TIME
|
||||
: conversionService.convert(endTimeItem.getValue(), LocalDateTime.class);
|
||||
|
||||
|
||||
String supplierId = supplierIdItem == null ? "" : "and d.supplier_id = '%s'".formatted(supplierIdItem.getValue());
|
||||
|
||||
ThreadLocalUtils.set(
|
||||
"startTime",
|
||||
"'%s'::timestamp"
|
||||
@@ -192,6 +201,9 @@ public class WarehouseGoodsSummaryService
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.format(endTime)));
|
||||
|
||||
ThreadLocalUtils.set("supplierId", supplierId);
|
||||
|
||||
|
||||
ThreadLocalUtils.set("enableTimeStatementInspector", true);
|
||||
}
|
||||
|
||||
@@ -227,6 +239,8 @@ public class WarehouseGoodsSummaryService
|
||||
ThreadLocalUtils.remove("startTime");
|
||||
ThreadLocalUtils.remove("endTime");
|
||||
|
||||
ThreadLocalUtils.remove("supplierId");
|
||||
|
||||
ThreadLocalUtils.remove("enableTimeStatementInspector");
|
||||
|
||||
return mapper.toDto(resultList.get(0));
|
||||
|
||||
@@ -435,7 +435,7 @@ public class WarehouseReceiptService
|
||||
}
|
||||
});
|
||||
|
||||
List<String> list = ch.stream().map(x -> x.getParent().getId()).toList();
|
||||
List<String> list = ch.stream().filter(x -> x.getParent()!=null).map(x -> x.getParent().getId()).toList();
|
||||
|
||||
Collection<String> notSelected = CollectionUtils.removeAll(list, dto.getIds());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user