|
|
@@ -68,52 +68,56 @@ export async function GetMPSDistrictPersonNum(ctx) {
|
|
68
|
68
|
Year: ctx.query.Year || ArrYear[1].Name,
|
|
69
|
69
|
};
|
|
70
|
70
|
|
|
71
|
|
- const url = "GetMPSDistrictPersonNum?DistrictID=" + param.DistrictID;
|
|
|
71
|
+ let info=null;
|
|
|
72
|
+ if (param.DistrictID!="NaN"){
|
|
72
|
73
|
|
|
73
|
|
- let info = await BufferMemoryClass.get(url);
|
|
|
74
|
+ const url = "GetMPSDistrictPersonNum?DistrictID=" + param.DistrictID;
|
|
74
|
75
|
|
|
75
|
|
- if (process.env.NODE_ENV == 'development')
|
|
76
|
|
- info = [];
|
|
|
76
|
+ info = await BufferMemoryClass.get(url);
|
|
77
|
77
|
|
|
78
|
|
- if (!info || info.length == 0) {
|
|
79
|
|
- const year2 = Number(param.Year) - 1;
|
|
|
78
|
+ if (process.env.NODE_ENV == 'development')
|
|
|
79
|
+ info = [];
|
|
80
|
80
|
|
|
81
|
|
- let str = "";
|
|
82
|
|
- if (param.DistrictID && param.DistrictID != 0)
|
|
83
|
|
- str = " and s.DistrictID=" + param.DistrictID;
|
|
84
|
|
- const arr = [];
|
|
85
|
|
- const sql = "select c.SchoolType2Short,s.ScoreYear,sum(s.PlanNum) as PlanNum from MPS_Score s inner join MPS_School c on s.SchoolTarget=c.ID where s.ScoreYear in ('" + year2 + "','" + param.Year + "') and s.SchoolTargetRemark not in('4国际(本市)','5国际(非本市)') and s.PlanNum>0 " + str + " group by c.SchoolType2Short,s.ScoreYear order by c.SchoolType2Short desc,s.ScoreYear;";
|
|
|
81
|
+ if (!info || info.length == 0) {
|
|
|
82
|
+ const year2 = Number(param.Year) - 1;
|
|
86
|
83
|
|
|
87
|
|
- const list = await commonModel.RunSql({}, sql);
|
|
88
|
|
- if (list && list.length > 0) {
|
|
89
|
|
- for(let i=0;i<list.length;i++){
|
|
90
|
|
- list[i].PlanNum=Number(list[i].PlanNum);
|
|
|
84
|
+ let str = "";
|
|
|
85
|
+ if (param.DistrictID && param.DistrictID != 0)
|
|
|
86
|
+ str = " and s.DistrictID=" + param.DistrictID;
|
|
|
87
|
+ const arr = [];
|
|
|
88
|
+ const sql = "select c.SchoolType2Short,s.ScoreYear,sum(s.PlanNum) as PlanNum from MPS_Score s inner join MPS_School c on s.SchoolTarget=c.ID where s.ScoreYear in ('" + year2 + "','" + param.Year + "') and s.SchoolTargetRemark not in('4国际(本市)','5国际(非本市)') and s.PlanNum>0 " + str + " group by c.SchoolType2Short,s.ScoreYear order by c.SchoolType2Short desc,s.ScoreYear;";
|
|
|
89
|
+
|
|
|
90
|
+ const list = await commonModel.RunSql({}, sql);
|
|
|
91
|
+ if (list && list.length > 0) {
|
|
|
92
|
+ for(let i=0;i<list.length;i++){
|
|
|
93
|
+ list[i].PlanNum=Number(list[i].PlanNum);
|
|
|
94
|
+ }
|
|
|
95
|
+ arr.push({ "Name": "能上" + list[1].SchoolType2Short, "Year1": list[1].PlanNum, "Year2": list[1].PlanNum - list[0].PlanNum });
|
|
|
96
|
+ arr.push({ "Name": "能上" + list[5].SchoolType2Short, "Year1": list[5].PlanNum + list[3].PlanNum, "Year2": list[5].PlanNum + list[3].PlanNum - list[4].PlanNum - list[2].PlanNum });
|
|
|
97
|
+ arr.push({ "Name": "能上" + list[7].SchoolType2Short, "Year1": list[7].PlanNum, "Year2": list[7].PlanNum - list[6].PlanNum });
|
|
|
98
|
+ arr.push({ "Name": "能上高中总计", "Year1": arr[0].Year1 + arr[1].Year1 + arr[2].Year1, "Year2": arr[0].Year2 + arr[1].Year2 + arr[2].Year2 });
|
|
|
99
|
+
|
|
|
100
|
+ arr[0].Rate = Math.round(100 * arr[0].Year1 / arr[3].Year1);
|
|
|
101
|
+ arr[1].Rate = Math.round(100 * arr[1].Year1 / arr[3].Year1);
|
|
|
102
|
+ arr[2].Rate = Math.round(100 * arr[2].Year1 / arr[3].Year1);
|
|
91
|
103
|
}
|
|
92
|
|
- arr.push({ "Name": "能上" + list[1].SchoolType2Short, "Year1": list[1].PlanNum, "Year2": list[1].PlanNum - list[0].PlanNum });
|
|
93
|
|
- arr.push({ "Name": "能上" + list[5].SchoolType2Short, "Year1": list[5].PlanNum + list[3].PlanNum, "Year2": list[5].PlanNum + list[3].PlanNum - list[4].PlanNum - list[2].PlanNum });
|
|
94
|
|
- arr.push({ "Name": "能上" + list[7].SchoolType2Short, "Year1": list[7].PlanNum, "Year2": list[7].PlanNum - list[6].PlanNum });
|
|
95
|
|
- arr.push({ "Name": "能上高中总计", "Year1": arr[0].Year1 + arr[1].Year1 + arr[2].Year1, "Year2": arr[0].Year2 + arr[1].Year2 + arr[2].Year2 });
|
|
96
|
|
-
|
|
97
|
|
- arr[0].Rate = Math.round(100 * arr[0].Year1 / arr[3].Year1);
|
|
98
|
|
- arr[1].Rate = Math.round(100 * arr[1].Year1 / arr[3].Year1);
|
|
99
|
|
- arr[2].Rate = Math.round(100 * arr[2].Year1 / arr[3].Year1);
|
|
100
|
|
- }
|
|
101
|
104
|
|
|
102
|
|
- info = {
|
|
103
|
|
- Year: param.Year,
|
|
104
|
|
- List: arr
|
|
105
|
|
- };
|
|
|
105
|
+ info = {
|
|
|
106
|
+ Year: param.Year,
|
|
|
107
|
+ List: arr
|
|
|
108
|
+ };
|
|
106
|
109
|
|
|
107
|
|
- const obj = {
|
|
108
|
|
- KeyName: url,
|
|
109
|
|
- ValueString: JSON.stringify(info)
|
|
110
|
|
- };
|
|
111
|
|
- await BufferMemoryClass.add(obj);
|
|
112
|
|
- console.log("缓存");
|
|
113
|
|
- }
|
|
114
|
|
- else {
|
|
115
|
|
- info = info[0].ValueString;
|
|
116
|
|
- info = JSON.parse(info);
|
|
|
110
|
+ const obj = {
|
|
|
111
|
+ KeyName: url,
|
|
|
112
|
+ ValueString: JSON.stringify(info)
|
|
|
113
|
+ };
|
|
|
114
|
+ await BufferMemoryClass.add(obj);
|
|
|
115
|
+ console.log("缓存");
|
|
|
116
|
+ }
|
|
|
117
|
+ else {
|
|
|
118
|
+ info = info[0].ValueString;
|
|
|
119
|
+ info = JSON.parse(info);
|
|
|
120
|
+ }
|
|
117
|
121
|
}
|
|
118
|
122
|
|
|
119
|
123
|
ctx.body = { "errcode": 10000, result: info };
|