localizer
lzq 2025-10-24 15:54:01 +08:00
parent 9febbb1874
commit 80c60840f1
3 changed files with 71 additions and 13 deletions

View File

@ -56,6 +56,12 @@ public interface SupervisionStatisticsMapper {
@SuppressWarnings("MybatisXMapperMethodInspection")
Map<String, Object> userStatistics();
@SuppressWarnings("MybatisXMapperMethodInspection")
Map<String, Object> activeProjectStatistics();
@SuppressWarnings("MybatisXMapperMethodInspection")
Map<String, Object> transStatistics();
@SuppressWarnings("MybatisXMapperMethodInspection")
List<Map<String, Object>> dataTable();
}

View File

@ -183,7 +183,7 @@ public class SupervisionStatisticsService {
});
for (long l = 0; l < days; l++) {
LocalDateTime localDateTime = startTime.plusYears(l);
LocalDateTime localDateTime = startTime.plusDays(l);
String day = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String, Object>> dayData = timepointMap.getOrDefault(day, Collections.emptyList());
Optional<Integer> weight = dayData.stream()
@ -216,6 +216,16 @@ public class SupervisionStatisticsService {
log.error("数据获取失败", ex);
return Collections.emptyMap();
});
CompletableFuture<Map<String, Object>> activeProjectStatisticsFuture = CompletableFuture.supplyAsync(supervisionStatisticsMapper::activeProjectStatistics, threadPoolExecutor)
.exceptionally(ex -> {
log.error("数据获取失败", ex);
return Collections.emptyMap();
});
CompletableFuture<Map<String, Object>> transStatisticsFuture = CompletableFuture.supplyAsync(supervisionStatisticsMapper::transStatistics, threadPoolExecutor)
.exceptionally(ex -> {
log.error("数据获取失败", ex);
return Collections.emptyMap();
});
CompletableFuture<Map<String, Object>> userStatisticsFuture = CompletableFuture.supplyAsync(supervisionStatisticsMapper::userStatistics, threadPoolExecutor)
.exceptionally(ex -> {
log.error("数据获取失败", ex);
@ -235,7 +245,9 @@ public class SupervisionStatisticsService {
Map<String, Double> trendStatistics = trendStatisticsFuture.get();
List<Map<String, Object>> categoryStatistics = categoryStatisticsFuture.get();
Map<String, Object> orderStatistics = orderStatisticsFuture.get();
Map<String, Object> activeProjectStatistics = activeProjectStatisticsFuture.get();
Map<String, Object> userStatistics = userStatisticsFuture.get();
Map<String, Object> transStatistics = transStatisticsFuture.get();
Map<String, Object> weightStatistics = weightStatisticsFuture.get();
List<Map<String, Object>> dataTable = dataTableFuture.get();
return MapUtil.<String, Object>builder()
@ -246,6 +258,8 @@ public class SupervisionStatisticsService {
.put("trendStatistics", trendStatistics)
.put("categoryStatistics", categoryStatistics)
.put("orderStatistics", orderStatistics)
.put("activeProjectStatistics", activeProjectStatistics)
.put("transStatistics", transStatistics)
.put("userStatistics", userStatistics)
.put("weightStatistics", weightStatistics)
.put("dataTable", dataTable)

View File

@ -306,14 +306,14 @@
</select>
<select id="categoryStatistics" resultType="java.util.Map">
SELECT d.category_name categoryName, ROUND(SUM(b.settle_weight) / 1000, 2) weight
SELECT c.goods_name categoryName, ROUND(SUM(b.settle_weight) / 1000, 2) weight
FROM order_info a
INNER JOIN order_car_in_out b ON b.id = a.car_in_out_id
INNER JOIN order_goods c ON c.id = a.goods_id
INNER JOIN goods_category d ON d.id = c.goods_category_id
WHERE a.deleted = 0
AND a.order_status = 'YiWanCheng'
GROUP BY d.category_name
GROUP BY c.goods_name
</select>
<select id="orderStatistics" resultType="java.util.Map">
SELECT MAX(IF(t_ = 1, c_, 0)) totalCount,
@ -363,15 +363,53 @@
AND create_time <![CDATA[ < ]]> DATE_ADD(CURDATE(), INTERVAL 1 DAY)) t
</select>
<select id="dataTable" resultType="java.util.Map">
SELECT ROUND(SUM(b.settle_weight) / 1000, 2) totalWeight, COUNT(*) totalCount
FROM order_info a
INNER JOIN order_car_in_out b ON b.id = a.car_in_out_id
INNER JOIN order_cargo_place c ON c.id = a.cargo_place_id
INNER JOIN order_goods d ON c.id = a.goods_id
WHERE a.deleted = 0
AND a.order_status = 'YiWanCheng'
AND b.out_time >= CURDATE()
AND b.out_time <![CDATA[ < ]]> DATE_ADD(CURDATE(), INTERVAL 1 DAY)
GROUP BY c.area, d.goods_name
select areaName,
goodsName,
weight,
complateCount,
totalCount,
ROUND((complateCount / totalCount) * 100, 2) complateRate
from (SELECT c.area_name areaName,
d.goods_name goodsName,
ROUND(SUM(if(a.order_status = 'YiWanCheng', b.settle_weight, 0)) / 1000, 2) weight,
count(if(a.order_status = 'YiWanCheng', 1, null)) complateCount,
count(*) totalCount
FROM order_info a
INNER JOIN order_car_in_out b ON b.id = a.car_in_out_id
INNER JOIN order_cargo_place c ON c.id = a.cargo_place_id
INNER JOIN order_goods d ON d.id = a.goods_id
WHERE a.deleted = 0
AND a.order_status = 'YiWanCheng'
AND b.out_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
AND b.out_time &lt; DATE_ADD(CURDATE(), INTERVAL 1 DAY)
GROUP BY c.area_name, d.goods_name) t
</select>
<select id="activeProjectStatistics" resultType="java.util.Map">
SELECT MAX(IF(t_ = 1, c_, 0)) totalCount,
MAX(IF(t_ = 2, c_, 0)) incCount
FROM (SELECT count(*) c_, 1 t_
FROM biz_project a
WHERE a.deleted = 0
UNION ALL
SELECT count(*) c_, 2 t_
FROM biz_project a
WHERE a.deleted = 0
AND a.create_time >= CURDATE()
AND a.create_time <![CDATA[ < ]]> DATE_ADD(CURDATE(), INTERVAL 1 DAY)) t
</select>
<select id="transStatistics" resultType="java.util.Map">
SELECT MAX(IF(t_ = 1, c_, 0)) totalCount,
MAX(IF(t_ = 2, c_, 0)) incCount
FROM (SELECT COUNT(*) c_, 1 t_
FROM sys_user
WHERE biz_obj IN ('QiYe', 'GeTi')
UNION ALL
SELECT COUNT(*) c_, 2 t_
FROM sys_user
WHERE biz_obj IN ('QiYe', 'GeTi')
AND create_time >= CURDATE()
AND create_time <![CDATA[ < ]]> DATE_ADD(CURDATE(), INTERVAL 1 DAY)) t
</select>
</mapper>