数据修复
parent
c368688860
commit
6d3e1b631b
|
|
@ -1,5 +1,6 @@
|
|||
package com.njzscloud.supervisory.statistics.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.njzscloud.supervisory.statistics.pojo.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -25,4 +26,6 @@ public interface TianQingStatisticsMapper {
|
|||
Double disposeWeight(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||
|
||||
List<OrderAmountSummary> getOrderAmountSummary(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||
|
||||
List<String> getGoodsNames(@Param("ew") Wrapper<Object> ew, @Param("count") int count);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,6 @@ public class GarbageDisposeSummary {
|
|||
private Double weight;
|
||||
private Integer depotType;
|
||||
private String depotName;
|
||||
private String icon;
|
||||
private Double percentage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,13 +46,19 @@ public class ShouJuStatisticsService implements StatisticsService {
|
|||
});
|
||||
CompletableFuture<List<GarbageDisposeSummary>> garbageDisposeSummary = CompletableFuture.supplyAsync(statisticsMapper::getGarbageDisposeSummary)
|
||||
.thenApply(list -> {
|
||||
Double garbageDisposeSummary_totalWeight = list.stream()
|
||||
Double garbageDisposeSummary_totalWeight_1 = list.stream()
|
||||
.filter(it -> it.getDepotType() == 1)
|
||||
.map(GarbageDisposeSummary::getWeight)
|
||||
.reduce(Double::sum).orElse(0D);
|
||||
Double garbageDisposeSummary_totalWeight_2 = list.stream()
|
||||
.filter(it -> it.getDepotType() == 2)
|
||||
.map(GarbageDisposeSummary::getWeight)
|
||||
.reduce(Double::sum).orElse(0D);
|
||||
|
||||
for (GarbageDisposeSummary disposeSummary : list) {
|
||||
disposeSummary.setPercentage(garbageDisposeSummary_totalWeight == 0 ? 0 : disposeSummary.getWeight() / garbageDisposeSummary_totalWeight * 100);
|
||||
disposeSummary.setPercentage(disposeSummary.getDepotType() == 1 ?
|
||||
garbageDisposeSummary_totalWeight_1 == 0 ? 0 : disposeSummary.getWeight() / garbageDisposeSummary_totalWeight_1 * 100 :
|
||||
garbageDisposeSummary_totalWeight_2 == 0 ? 0 : disposeSummary.getWeight() / garbageDisposeSummary_totalWeight_2 * 100);
|
||||
}
|
||||
return list;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
|
|||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.Week;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.njzscloud.common.core.tuple.Tuple2;
|
||||
import com.njzscloud.common.core.tuple.Tuple3;
|
||||
import com.njzscloud.common.core.utils.GroupUtil;
|
||||
|
|
@ -45,13 +46,19 @@ public class TianQingStatisticsService implements StatisticsService {
|
|||
});
|
||||
CompletableFuture<List<GarbageDisposeSummary>> garbageDisposeSummary = CompletableFuture.supplyAsync(statisticsMapper::getGarbageDisposeSummary)
|
||||
.thenApply(list -> {
|
||||
Double garbageDisposeSummary_totalWeight = list.stream()
|
||||
Double garbageDisposeSummary_totalWeight_1 = list.stream()
|
||||
.filter(it -> it.getDepotType() == 1)
|
||||
.map(GarbageDisposeSummary::getWeight)
|
||||
.reduce(Double::sum).orElse(0D);
|
||||
Double garbageDisposeSummary_totalWeight_2 = list.stream()
|
||||
.filter(it -> it.getDepotType() == 2)
|
||||
.map(GarbageDisposeSummary::getWeight)
|
||||
.reduce(Double::sum).orElse(0D);
|
||||
|
||||
for (GarbageDisposeSummary disposeSummary : list) {
|
||||
disposeSummary.setPercentage(garbageDisposeSummary_totalWeight == 0 ? 0 : disposeSummary.getWeight() / garbageDisposeSummary_totalWeight * 100);
|
||||
disposeSummary.setPercentage(disposeSummary.getDepotType() == 1 ?
|
||||
garbageDisposeSummary_totalWeight_1 == 0 ? 0 : disposeSummary.getWeight() / garbageDisposeSummary_totalWeight_1 * 100 :
|
||||
garbageDisposeSummary_totalWeight_2 == 0 ? 0 : disposeSummary.getWeight() / garbageDisposeSummary_totalWeight_2 * 100);
|
||||
}
|
||||
return list;
|
||||
})
|
||||
|
|
@ -62,12 +69,22 @@ public class TianQingStatisticsService implements StatisticsService {
|
|||
|
||||
CompletableFuture<List<GarbageDisposeSummary>> currentMonthGarbageDisposeSummary = CompletableFuture.supplyAsync(statisticsMapper::getCurrentMonthGarbageDisposeSummary)
|
||||
.thenApply(list -> {
|
||||
if (list.size() < 6) {
|
||||
List<String> goodsNames = statisticsMapper.getGoodsNames(Wrappers.query().eq("depot_type", 2), 6 - list.size());
|
||||
for (String goodsName : goodsNames) {
|
||||
list.add(new GarbageDisposeSummary()
|
||||
.setGarbageName(goodsName)
|
||||
.setWeight(0D));
|
||||
}
|
||||
}
|
||||
|
||||
Double currentMonthGarbageDisposeSummary_totalWeight = list.stream()
|
||||
.map(GarbageDisposeSummary::getWeight)
|
||||
.reduce(Double::sum).orElse(0D);
|
||||
|
||||
for (GarbageDisposeSummary disposeSummary : list) {
|
||||
disposeSummary.setPercentage(disposeSummary.getWeight() / currentMonthGarbageDisposeSummary_totalWeight * 100);
|
||||
disposeSummary.setPercentage(currentMonthGarbageDisposeSummary_totalWeight == 0 ? 0 :
|
||||
disposeSummary.getWeight() / currentMonthGarbageDisposeSummary_totalWeight * 100);
|
||||
}
|
||||
return list;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ spring:
|
|||
multipart:
|
||||
location: D:\ProJects\gov_manage\njzscloud-supervisory-svr\logs\temp
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:33061/green_frog?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
||||
username: dbard01
|
||||
password: mik9uvNZ
|
||||
url: jdbc:mysql://localhost:33061/greenfrog?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
||||
username: greenfrog
|
||||
password: admin999
|
||||
security:
|
||||
auth-ignores: /statistics/**
|
||||
|
||||
|
|
@ -13,13 +13,13 @@ mybatis-plus:
|
|||
tunnel:
|
||||
enable: true
|
||||
ssh:
|
||||
host: 121.43.155.83
|
||||
host: 47.117.76.168
|
||||
port: 22
|
||||
user: root
|
||||
credentials: D:/我的/再昇云/客户信息归档/达州首炬/dzsj.pem
|
||||
credentials: D:/我的/再昇云/客户资料/扬州天勤/tqhost.pem
|
||||
localPort: 33061
|
||||
db:
|
||||
host: rm-bp1w3397b718u1882.mysql.rds.aliyuncs.com
|
||||
host: 127.0.0.1
|
||||
port: 3306
|
||||
|
||||
app:
|
||||
|
|
|
|||
|
|
@ -27,23 +27,25 @@
|
|||
</select>
|
||||
<select id="getGarbageDisposeSummary"
|
||||
resultType="com.njzscloud.supervisory.statistics.pojo.GarbageDisposeSummary">
|
||||
SELECT garbage_name, weight, 1 depot_type, '入库' depot_name
|
||||
FROM (SELECT garbage_name, weight
|
||||
FROM (SELECT b.name garbage_name, SUM(a.weight) weight
|
||||
SELECT garbage_name, weight, icon, 1 depot_type, '入库' depot_name
|
||||
FROM (SELECT d.name garbage_name, t.weight, d.icon
|
||||
FROM (SELECT b.id, SUM(a.weight) weight
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_goods b ON b.id = a.goods_id AND b.depot_type = 1
|
||||
INNER JOIN ba_goods_category c ON c.id = b.category_id
|
||||
GROUP BY b.name) t
|
||||
GROUP BY b.id) t
|
||||
INNER JOIN ba_goods d ON d.id = t.id
|
||||
ORDER BY weight DESC
|
||||
LIMIT 3) t1
|
||||
UNION ALL
|
||||
SELECT garbage_name, weight, 2 depot_type, '出库' depot_name
|
||||
FROM (SELECT garbage_name, weight
|
||||
FROM (SELECT b.name garbage_name, SUM(a.weight) weight
|
||||
SELECT garbage_name, weight, icon, 2 depot_type, '出库' depot_name
|
||||
FROM (SELECT d.name garbage_name, t.weight, d.icon
|
||||
FROM (SELECT b.id, SUM(a.weight) weight
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_goods b ON b.id = a.goods_id AND b.depot_type = 2
|
||||
INNER JOIN ba_goods_category c ON c.id = b.category_id
|
||||
GROUP BY b.name) t
|
||||
GROUP BY b.id) t
|
||||
INNER JOIN ba_goods d ON d.id = t.id
|
||||
ORDER BY weight DESC
|
||||
LIMIT 3) t2
|
||||
</select>
|
||||
|
|
@ -117,4 +119,12 @@
|
|||
AND a.out_time >= #{startTime}
|
||||
AND a.out_time <![CDATA[ <= ]]> #{endTime}
|
||||
</select>
|
||||
<select id="getGoodsNames" resultType="java.lang.String">
|
||||
SELECT name
|
||||
FROM ba_goods
|
||||
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
LIMIT #{count}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue