|
|
@@ -3,6 +3,7 @@ import fs from 'fs';
|
|
3
|
3
|
import { promises as fsPromises } from 'fs';
|
|
4
|
4
|
import mps, { ArrYear, getDistrict } from '../../model/mps.js';
|
|
5
|
5
|
import commonModel from '../../model/commonModel.js';
|
|
|
6
|
+import { globalCache } from '../../util/GlobalCache.js';
|
|
6
|
7
|
import config from '../../config/index.js';
|
|
7
|
8
|
import _ from 'lodash';
|
|
8
|
9
|
import axios from 'axios';
|
|
|
@@ -241,30 +242,43 @@ export async function GetMPSWish(ctx) {
|
|
241
|
242
|
ID: ctx.query.ID || 0,
|
|
242
|
243
|
};
|
|
243
|
244
|
|
|
244
|
|
- let list = await mps.GetMPSWish(param);
|
|
245
|
|
- let num = 1;
|
|
246
|
|
-
|
|
247
|
|
- if (param.WishType === "all") {
|
|
248
|
|
- num = 5;
|
|
249
|
|
- list = _.shuffle(list);
|
|
250
|
|
- } else if (param.WishType === "school") {
|
|
251
|
|
- num = 3;
|
|
252
|
|
- } else if (param.WishType === "schoolAll") {
|
|
253
|
|
- num = list.length;
|
|
254
|
|
- }
|
|
|
245
|
+ const functionName="GetMPSWish?WishType=all";
|
|
|
246
|
+ let result=0;
|
|
|
247
|
+ if (param.WishType=="all")
|
|
|
248
|
+ result=globalCache.get(functionName);
|
|
255
|
249
|
|
|
256
|
|
- const arr = [];
|
|
257
|
|
- for (let i = 0; i < num; i++) {
|
|
258
|
|
- if (list[i]) {
|
|
259
|
|
- arr.push(buildWish(list[i], param.WishType));
|
|
|
250
|
+ if (result==0){
|
|
|
251
|
+ let list = await mps.GetMPSWish(param);
|
|
|
252
|
+ let num = 1;
|
|
|
253
|
+
|
|
|
254
|
+ if (param.WishType === "all") {
|
|
|
255
|
+ num = 5;
|
|
|
256
|
+ list = _.shuffle(list);
|
|
|
257
|
+ } else if (param.WishType === "school") {
|
|
|
258
|
+ num = 3;
|
|
|
259
|
+ } else if (param.WishType === "schoolAll") {
|
|
|
260
|
+ num = list.length;
|
|
260
|
261
|
}
|
|
261
|
|
- }
|
|
262
|
262
|
|
|
263
|
|
- if (param.WishType === "school" && list.length > 0) {
|
|
264
|
|
- list[0].RowCount = list.length;
|
|
|
263
|
+ let arr = [];
|
|
|
264
|
+ for (let i = 0; i < num; i++) {
|
|
|
265
|
+ if (list[i]) {
|
|
|
266
|
+ arr.push(buildWish(list[i], param.WishType));
|
|
|
267
|
+ }
|
|
|
268
|
+ }
|
|
|
269
|
+
|
|
|
270
|
+ if (param.WishType === "school" && list.length > 0) {
|
|
|
271
|
+ list[0].RowCount = list.length;
|
|
|
272
|
+ }
|
|
|
273
|
+
|
|
|
274
|
+ result = arr;
|
|
|
275
|
+ if (param.WishType=="all"){
|
|
|
276
|
+ globalCache.set(functionName, result, config.BufferMemoryTimeLowNormal);
|
|
|
277
|
+ console.log("缓存");
|
|
|
278
|
+ }
|
|
265
|
279
|
}
|
|
266
|
280
|
|
|
267
|
|
- ctx.body = {errcode: 10000, result: arr};
|
|
|
281
|
+ ctx.body = {errcode: 10000, result: result};
|
|
268
|
282
|
}
|
|
269
|
283
|
|
|
270
|
284
|
// 更新反馈状态
|