修改相关聚合问题
This commit is contained in:
parent
1f32324701
commit
78b8409ba3
|
@ -134,7 +134,9 @@ class ClientMapper {
|
|||
.addSelect('name', 'name')
|
||||
.addSelect('icon', 'icon')
|
||||
.addSelect('sum(num)', 'sum')
|
||||
.groupBy('id')
|
||||
.groupBy('name')
|
||||
.addGroupBy('icon')
|
||||
.addGroupBy('id')
|
||||
.orderBy('sum')
|
||||
.take(topLimit)
|
||||
.getRawMany();
|
||||
|
@ -142,52 +144,22 @@ class ClientMapper {
|
|||
|
||||
async queryMpInfo({ id, startTime }) {
|
||||
const obj: any = {};
|
||||
// if (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)', {
|
||||
id,
|
||||
});
|
||||
// if (startTime && endTime) {
|
||||
// sql.andWhere(`date between '${startTime}' and '${endTime}'`);
|
||||
// }
|
||||
if (startTime) {
|
||||
sql.andWhere(`date >= '${startTime}'`);
|
||||
}
|
||||
return sql
|
||||
.select('name')
|
||||
.addSelect('icon')
|
||||
.addSelect('id')
|
||||
.select('id', 'id')
|
||||
.addSelect('num')
|
||||
.addSelect('date')
|
||||
.groupBy('date')
|
||||
.addGroupBy('num')
|
||||
.addGroupBy('id')
|
||||
.orderBy('date', 'DESC')
|
||||
.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 }) {
|
||||
|
|
|
@ -120,10 +120,6 @@ export class ClientService {
|
|||
}
|
||||
const st = Time.getRecentDay(6)
|
||||
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) => {
|
||||
if (obj[e.id]) {
|
||||
obj[e.id].dayNumList.push({
|
||||
|
|
Loading…
Reference in New Issue
Block a user