修改相关聚合问题
This commit is contained in:
parent
1f32324701
commit
78b8409ba3
|
@ -134,7 +134,9 @@ class ClientMapper {
|
||||||
.addSelect('name', 'name')
|
.addSelect('name', 'name')
|
||||||
.addSelect('icon', 'icon')
|
.addSelect('icon', 'icon')
|
||||||
.addSelect('sum(num)', 'sum')
|
.addSelect('sum(num)', 'sum')
|
||||||
.groupBy('id')
|
.groupBy('name')
|
||||||
|
.addGroupBy('icon')
|
||||||
|
.addGroupBy('id')
|
||||||
.orderBy('sum')
|
.orderBy('sum')
|
||||||
.take(topLimit)
|
.take(topLimit)
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
|
@ -142,52 +144,22 @@ class ClientMapper {
|
||||||
|
|
||||||
async queryMpInfo({ id, startTime }) {
|
async queryMpInfo({ id, startTime }) {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
// if (id) {
|
|
||||||
obj.id = id;
|
obj.id = id;
|
||||||
// return await MpInfo.find({
|
|
||||||
// where: obj,
|
|
||||||
// take: topLimit,
|
|
||||||
// });
|
|
||||||
// 计算最近7天的起始时间
|
|
||||||
// const toData = new Date(new Date().toLocaleDateString()).getTime();
|
|
||||||
// startTime = moment(startTime).format(
|
|
||||||
// 'YYYY-MM-DD 00:00:00',
|
|
||||||
// );
|
|
||||||
// endTime = moment(endTime).format(
|
|
||||||
// 'YYYY-MM-DD 23:59:59',
|
|
||||||
// );
|
|
||||||
const sql = MpInfo.createQueryBuilder().where('id in (:...id)', {
|
const sql = MpInfo.createQueryBuilder().where('id in (:...id)', {
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
// if (startTime && endTime) {
|
|
||||||
// sql.andWhere(`date between '${startTime}' and '${endTime}'`);
|
|
||||||
// }
|
|
||||||
if (startTime) {
|
if (startTime) {
|
||||||
sql.andWhere(`date >= '${startTime}'`);
|
sql.andWhere(`date >= '${startTime}'`);
|
||||||
}
|
}
|
||||||
return sql
|
return sql
|
||||||
.select('name')
|
.select('id', 'id')
|
||||||
.addSelect('icon')
|
|
||||||
.addSelect('id')
|
|
||||||
.addSelect('num')
|
.addSelect('num')
|
||||||
.addSelect('date')
|
.addSelect('date')
|
||||||
.groupBy('date')
|
.groupBy('date')
|
||||||
|
.addGroupBy('num')
|
||||||
.addGroupBy('id')
|
.addGroupBy('id')
|
||||||
.orderBy('date', 'DESC')
|
.orderBy('date', 'DESC')
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
// } else {
|
|
||||||
// const sql = MpInfo.createQueryBuilder();
|
|
||||||
// if (startTime && endTime) {
|
|
||||||
// sql.where(`date between ${startTime} and ${endTime}`);
|
|
||||||
// }
|
|
||||||
// return sql
|
|
||||||
// .select('name')
|
|
||||||
// .addSelect('icon')
|
|
||||||
// .addSelect('id')
|
|
||||||
// .addSelect('num')
|
|
||||||
// .addSelect('date')
|
|
||||||
// .getRawMany();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryArchiveList({ areaCode, pageNo, pageSize, type }) {
|
async queryArchiveList({ areaCode, pageNo, pageSize, type }) {
|
||||||
|
|
|
@ -120,10 +120,6 @@ export class ClientService {
|
||||||
}
|
}
|
||||||
const st = Time.getRecentDay(6)
|
const st = Time.getRecentDay(6)
|
||||||
const info = await clientMapper.queryMpInfo({ id, startTime: st });
|
const info = await clientMapper.queryMpInfo({ id, startTime: st });
|
||||||
// const [count, info] = await Promise.all([
|
|
||||||
// clientMapper.queryMpNum({ areaCode ,startTime, endTime}),
|
|
||||||
// clientMapper.queryMpInfo({ areaCode, topLimit, startTime, endTime }),
|
|
||||||
// ]);
|
|
||||||
info.forEach((e) => {
|
info.forEach((e) => {
|
||||||
if (obj[e.id]) {
|
if (obj[e.id]) {
|
||||||
obj[e.id].dayNumList.push({
|
obj[e.id].dayNumList.push({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user