| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 |
- import { promises as fs } from 'fs';
- import moment from 'moment';
- import BufferMemoryClass from '../../model/BufferMemoryClass.js';
- import { stringUtils } from '../../util/stringClass.js';
- import commonModel from '../../model/commonModel.js';
- import mps, { ArrYear, getDistrict } from '../../model/mps.js';
- import _ from 'lodash';
- // 更新学校点赞数
- export async function UpdateMPSUserSchoolLikeNum(ctx) {
- const param = {
- UserID: ctx.request.body.UserID || 0,
- SchoolID: ctx.request.body.SchoolID || 0,
- SchoolType1: ctx.request.body.SchoolType1 || '高中',
- LikeNum: ctx.request.body.LikeNum || 0
- };
- var sql="select * from MPS_UserSchoolClickLike where UserID="+param.UserID+" and SchoolID="+param.SchoolID;
- var list = await commonModel.RunSql(null,sql);
- if (list && list.length>0){
- if (list[0].ClickLikeID!=param.ClickLikeID) {
- param.ID=list[0].ID;
- await mps.UpdateMPSUserSchoolClickLike(param);
- }
- }
- else{
- await mps.AddMPSUserSchoolClickLike(param);
- }
- result = await commonModel.RunSql({}, sql);
- ctx.body = { "errcode": 10000, result: result };
- }
- // 获取学校点赞数
- export async function GetMPSSchoolLikeNum(ctx) {
- const param = {
- SchoolID: ctx.query.SchoolID || 0,
- UserID: ctx.query.UserID || 0,
- };
- let sql="select ClickLikeID,count(*) as Count from MPS_UserSchoolClickLike where SchoolID="+param.SchoolID+" group by ClickLikeID order by Count desc,ClickLikeID;";
- let list = await commonModel.RunSql(null,sql);
- if (list && list.length>0){
- list[0].Show=1;
- let sql2="select * from MPS_UserSchoolClickLike where SchoolID="+param.SchoolID+" and UserID="+param.UserID+";";
- //console.log(sql2);
- let user=await commonModel.RunSql(null,sql2);
- if (user && user.length>0) {
- for (let i = 0; i < list.length; i++) {
- if (user[0].ClickLikeID == list[i].ClickLikeID) {
- list[i].Show = 1;
- }
- }
- }
- ctx.body = {errcode: 10000,result:list};
- }
- else{
- ctx.body = {errcode: 10000,result:[]};
- }
- }
- // 获取区县人数
- export async function GetMPSDistrictPersonNum(ctx) {
- let param = {
- DistrictID: ctx.query.DistrictID || '0', //所在区
- Year: ctx.query.Year || ArrYear[0].Name,
- };
- if (param.DistrictID==10 || param.DistrictID==12 || param.DistrictID==15 || param.DistrictID==16 )
- param.Year=ArrYear[0].Name;
- let info=null;
- if (param.DistrictID!="NaN"){
- const url = "GetMPSDistrictPersonNum?DistrictID=" + param.DistrictID;
- info = await BufferMemoryClass.get(url);
- if (process.env.NODE_ENV == 'development')
- info = [];
- if (!info || info.length == 0) {
- const year2 = Number(param.Year) - 1;
- let str = "";
- if (param.DistrictID && param.DistrictID != 0)
- str = " and s.DistrictID=" + param.DistrictID;
- const arr = [];
- 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;";
- const list = await commonModel.RunSql({}, sql);
- if (list && list.length > 0) {
- for(let i=0;i<list.length;i++){
- list[i].PlanNum=Number(list[i].PlanNum);
- }
- arr.push({ "Name": "能上" + list[1].SchoolType2Short, "Year1": list[1].PlanNum, "Year2": list[1].PlanNum - list[0].PlanNum });
- 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 });
- arr.push({ "Name": "能上" + list[7].SchoolType2Short, "Year1": list[7].PlanNum, "Year2": list[7].PlanNum - list[6].PlanNum });
- arr.push({ "Name": "能上高中总计", "Year1": arr[0].Year1 + arr[1].Year1 + arr[2].Year1, "Year2": arr[0].Year2 + arr[1].Year2 + arr[2].Year2 });
- arr[0].Rate = Math.round(100 * arr[0].Year1 / arr[3].Year1);
- arr[1].Rate = Math.round(100 * arr[1].Year1 / arr[3].Year1);
- arr[2].Rate = Math.round(100 * arr[2].Year1 / arr[3].Year1);
- }
- info = {
- Year: param.Year,
- List: arr
- };
- const obj = {
- KeyName: url,
- ValueString: JSON.stringify(info)
- };
- await BufferMemoryClass.add(obj);
- console.log("缓存");
- }
- else {
- info = info[0].ValueString;
- info = JSON.parse(info);
- }
- }
- ctx.body = { "errcode": 10000, result: info };
- }
- // 获取城市招生人数
- export async function GetMPSCityPersonNum(ctx) {
- const param = {
- Year: ctx.query.Year || ArrYear[1].Name,
- };
- const url = "GetMPSCityPersonNum";
- let info = await BufferMemoryClass.get(url);
- // if (process.env.NODE_ENV == 'development')
- // info = [];
- if (!info || info.length == 0) {
- const year2 = Number(param.Year) - 1;
- 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 group by c.SchoolType2Short,s.ScoreYear order by c.SchoolType2Short desc,s.ScoreYear;";
- const list = await commonModel.RunSql({}, sql);
- const sql2 = "select sum(PlanNum) as PlanNum from MPS_Score where ScoreYear='" + ArrYear[0].Name + "' and SchoolTarget in (1,2,3,4) and SchoolTargetRemark not in('4国际(本市)','5国际(非本市)');";
- const list2 = await commonModel.RunSql({}, sql2);
- for(let i=0;i<list.length;i++){
- list[i].PlanNum=Number(list[i].PlanNum);
- }
- list2[0].PlanNum=Number(list2[0].PlanNum);
- const arr = [];
- arr.push({ "Name": "能上" + list[1].SchoolType2Short, "Year1": list[1].PlanNum, "Year2": list[1].PlanNum - list[0].PlanNum, "Other": "「四校」招生计划数 " + list2[0].PlanNum + "人" });
- 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, "Other": "特色高中招生计划数 " + list[3].PlanNum + "人" });
- arr.push({ "Name": "能上" + list[7].SchoolType2Short, "Year1": list[7].PlanNum, "Year2": list[7].PlanNum - list[6].PlanNum });
- arr.push({ "Name": "能上高中总计", "Year1": arr[0].Year1 + arr[1].Year1 + arr[2].Year1, "Year2": arr[0].Year2 + arr[1].Year2 + arr[2].Year2 });
- arr[0].Rate = Math.round(100 * arr[0].Year1 / arr[3].Year1);
- arr[1].Rate = Math.round(100 * arr[1].Year1 / arr[3].Year1);
- arr[2].Rate = Math.round(100 * arr[2].Year1 / arr[3].Year1);
- info = {
- Year: param.Year,
- List: arr
- };
- const obj = {
- KeyName: url,
- ValueString: JSON.stringify(info)
- };
- await BufferMemoryClass.add(obj);
- console.log("缓存");
- }
- else {
- info = info[0].ValueString;
- info = JSON.parse(info);
- }
- ctx.body = { "errcode": 10000, result: info };
- }
- // 得到分数线(小程序使用)
- export async function GetMPSScore(ctx) {
- var param = {
- ScoreYear: ctx.query.ScoreYear || ArrYear[0].Name,
- ScoreType: ctx.query.ScoreType || '1-15志愿',
- DistrictID: ctx.query.DistrictID || 0,
- };
- var url="GetMPSScore?ScoreYear="+param.ScoreYear+"&ScoreType="+param.ScoreType+"&DistrictID="+param.DistrictID;
- var list = await BufferMemoryClass.get(url);
- if (process.env.NODE_ENV == 'development')
- list=[];
- if (!list || list.length==0) {
- var sql0 = "SELECT f.ID,x.DistrictID as 'DistrictName',x.District as 'DistrictNameArea',f.DistrictID,f.ScoreType,f.SchoolOfGraduation,f.SchoolFullNameJunior,f.SchoolTarget,x.SchoolFullName,x.SchoolShortName,x.SchoolType2ShortID,x.SchoolType2Short,x.Accommodation,x.PublicOrPrivate,f.SchoolTargetRemark," +
- "f.PlanNum,f.ScoreTotal,f.Score1,f.Score2,f.Score3,f.Score4,f.SchoolTargetRemark2,f.PlanNumDifferenceValue,f.ScoreTotalDifferenceValue,x.PublicOrPrivate FROM MPS_Score f inner join MPS_School x on f.SchoolTarget=x.ID ";
- if (param.ScoreType == "名额到校") {
- sql0 += " inner join MPS_School c on f.SchoolOfGraduation = c.ID ";
- }
- sql0 += " where f.ScoreType='" + param.ScoreType + "'";
- var sql = sql0;
- var scoreYear = param.ScoreYear;
- sql += " and f.ScoreYear='" + scoreYear + "'";
- if (param.ScoreType != "自主招生") {
- sql += " and (f.PlanNum>0 || f.PlanNum=-999) and f.ScoreTotal>=0";
- }
- if (param.DistrictID != "全部" && param.DistrictID >= 0) {
- sql += " and f.DistrictID=" + param.DistrictID;
- }
- else if (param.DistrictID == -1) {
- sql += " and (f.SchoolTargetRemark='4国际(本市)' or f.SchoolTargetRemark='5国际(非本市)') ";
- }
- var sqlOrder = "";
- if (param.ScoreType == "名额到校")
- sqlOrder += " order by f.DistrictID,CAST(f.SchoolOfGraduation AS UNSIGNED),f.ScoreTotal desc;";
- else if (param.ScoreType == "名额到区")
- sqlOrder += " order by f.DistrictID,f.ScoreTotal desc;";
- else if (param.ScoreType == "1-15志愿")
- sqlOrder += " order by f.DistrictID,x.SchoolType2ShortID,f.ScoreTotal desc;";
- else if (param.ScoreType == "自主招生") {
- if (param.DistrictID == -1)
- sqlOrder += " order by f.DistrictID,x.DistrictID,x.OrderID,f.SchoolTarget,f.SchoolTargetRemark;";
- else
- sqlOrder += " order by f.DistrictID,x.DistrictID,x.OrderID2,f.SchoolTarget,f.SchoolTargetRemark;";
- }
- else
- sqlOrder += " order by f.DistrictID,x.DistrictID,x.SchoolNumber,f.SchoolTargetRemark;";
- sql += sqlOrder;
- //console.log(sql);
- var list = await commonModel.RunSql({}, sql);
- if (param.ScoreType == "自主招生") {
- var arrTemp = [], temp = 0, obj = {
- "学科": 0,
- "体育": 0,
- "艺术": 0,
- "国际(本市)": 0,
- "国际(非本市)": 0,
- "学科差": null,
- "体育差": null,
- "艺术差": null,
- "国际(本市)差": null,
- "国际(非本市)差": null
- };
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- if (i > 0 && temp != item.SchoolTarget) {
- arrTemp.push(obj);
- obj = {
- "学科": 0,
- "体育": 0,
- "艺术": 0,
- "国际(本市)": 0,
- "国际(非本市)": 0,
- "学科差": null,
- "体育差": null,
- "艺术差": null,
- "国际(本市)差": null,
- "国际(非本市)差": null
- };
- }
- item.DistrictName = getDistrict(item.DistrictName);
- if (item.DistrictName == "上海市")
- item.DistrictName = "委属";
- obj.ID = item.SchoolTarget;
- obj.SchoolFullName = item.SchoolFullName;
- obj.ScoreType = item.ScoreType;
- obj.DistrictName = item.DistrictName;
- obj.DistrictNameArea = item.DistrictNameArea;
- obj.SchoolType2Short = item.SchoolType2Short;
- obj.Accommodation = item.Accommodation;
- obj.PublicOrPrivate = item.PublicOrPrivate;
- obj[item.SchoolTargetRemark.substr(1)] = item.PlanNum;
- obj[item.SchoolTargetRemark.substr(1) + "差"] = item.PlanNumDifferenceValue;
- obj.Name = item.SchoolShortName;
- temp = item.SchoolTarget;
- }
- arrTemp.push(obj);
- for (var i = 0; i < arrTemp.length; i++) {
- arrTemp[i]["国际"] = arrTemp[i]["国际(本市)"] + arrTemp[i]["国际(非本市)"];
- if (arrTemp[i]["国际(本市)差"] && arrTemp[i]["国际(非本市)差"])
- arrTemp[i]["国际差"] = arrTemp[i]["国际(本市)差"] + arrTemp[i]["国际(非本市)差"];
- }
- list = arrTemp;
- }
- else {
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- item.DistrictName = getDistrict(item.DistrictName);
- item.ID = item.SchoolTarget;
- if (item.DistrictName == "上海市")
- item.DistrictName = "委属";
- if (param.ScoreType == "名额到区")
- item.Height = 121;
- else if (param.ScoreType == "1-15志愿") {
- if (item.SchoolTargetRemark && item.SchoolTargetRemark.indexOf("(") >= 0) {
- // item.SchoolShortName += "\n" + item.SchoolTargetRemark;
- // item.SchoolShortName = item.SchoolShortName.replace("(", "·");
- // item.SchoolShortName = item.SchoolShortName.replace(")", "");
- item.Height = 159;
- }
- else {
- item.Height = 121;
- if (item.SchoolTargetRemark || item.SchoolShortName.length > 5)
- item.Height = 159;
- }
- }
- else if (param.ScoreType == "名额到校")
- item.Height = 93;
- if (i > 0) {
- item.SchoolOfGraduationTemp = list[i - 1].SchoolOfGraduation;
- item.SchoolType2ShortIDTemp = list[i - 1].SchoolType2ShortID;
- }
- item.Name = item.SchoolShortName;
- }
- }
- var today=moment().format("MM-DD");
- var year=moment().format("YYYY");
- if (ArrYear[0].IsNullScoreLine && param.ScoreYear==year){
- sql=sql.replace(ArrYear[0].Name,ArrYear[1].Name);
- var list2 = await commonModel.RunSql({}, sql);
- for(var i=0;i<list.length;i++){
- for(var j=0;j<list2.length;j++){
- if (list[i].DistrictID==list2[j].DistrictID
- && list[i].SchoolTarget==list2[j].SchoolTarget
- && (!list[i].SchoolOfGraduation || (list[i].SchoolOfGraduation && list[i].SchoolOfGraduation==list2[j].SchoolOfGraduation))){
- list[i].ScoreTotal=list2[j].ScoreTotal;
- list[i].Score1=list2[j].Score1;
- list[i].Score2=list2[j].Score2;
- list[i].Score3=list2[j].Score3;
- list[i].Score4=list2[j].Score4;
- list[i].ScoreTotalDifferenceValue=list2[j].ScoreTotalDifferenceValue;
- break;
- }
- }
- if (list[i].DistrictID=="12" && param.ScoreType=="名额到校") {
- if (list[i].SchoolTarget <= "5") {
- list[i].ID = "0";
- list[i].SchoolTarget = "0";
- list[i].Name = "委属市重点";
- list[i].SchoolShortName = "委属市重点";
- }
- }
- }
- if (param.ScoreType=="名额到区")
- list=_.orderBy(list, ['DistrictID','ScoreTotal'], ['asc','desc']);
- else if (param.ScoreType=="名额到校") {
- list = _.orderBy(list, ['DistrictID', 'SchoolOfGraduation', 'ScoreTotal'], ['asc', 'asc', 'desc']);
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- item.SchoolOfGraduationTemp = "";
- item.SchoolType2ShortIDTemp = "";
- }
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- if (i > 0) {
- item.SchoolOfGraduationTemp = list[i - 1].SchoolOfGraduation;
- item.SchoolType2ShortIDTemp = list[i - 1].SchoolType2ShortID;
- }
- item.Name = item.SchoolShortName;
- }
- }
- else if (param.ScoreType=="1-15志愿") {
- list = _.orderBy(list, ['DistrictID', "SchoolType2ShortID", 'ScoreTotal'], ['asc', 'asc', 'desc']);
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- item.DistrictName = getDistrict(item.DistrictName);
- item.ID = item.SchoolTarget;
- if (i > 0) {
- item.SchoolType2ShortIDTemp = list[i - 1].SchoolType2ShortID;
- }
- else{
- item.SchoolType2ShortIDTemp="";
- }
- item.Name = item.SchoolShortName;
- }
- }
- }
- for(let i=0;i<list.length;i++){
- let item=list[i];
- item.Score1=stringUtils.TrimEndZero(item.Score1);
- item.Score2=stringUtils.TrimEndZero(item.Score2);
- item.Score3=stringUtils.TrimEndZero(item.Score3);
- item.Score4=stringUtils.TrimEndZero(item.Score4);
- item.ScoreTotal=stringUtils.TrimEndZero(item.ScoreTotal);
- item.ScoreTotalDifferenceValue=stringUtils.TrimEndZero(item.ScoreTotalDifferenceValue);
- }
- let obj1={};
- obj1.KeyName=url;
- obj1.ValueString=JSON.stringify(list);
- await BufferMemoryClass.add(obj1);
- }
- else{
- list=list[0].ValueString;
- list=JSON.parse(list);
- }
- ctx.body = {"errcode": 10000,result:list};
- }
- //得到收藏学校分数线(小程序使用)
- export async function GetMPSScoreByCollect(ctx) {
- var param = {
- ScoreYear: ctx.query.ScoreYear || ArrYear[0].Name,
- UserID: ctx.query.UserID || 0,
- DistrictID: ctx.query.DistrictID || 0,
- SchoolType1: ctx.query.SchoolType1 || '高中',
- };
- var sql="";
- if (param.SchoolType1=='高中'){
- sql="select x.ID,f.ScoreType,f.PlanNum,f.ScoreTotal,f.Score1,f.Score2,f.Score3,f.Score4,f.PlanNumDifferenceValue,f.ScoreTotalDifferenceValue,f.DistrictID,f.SchoolTarget,f.SchoolOfGraduation " +
- "from MPS_Score f inner join MPS_School x on f.SchoolTarget=x.ID inner join MPS_UserCollect uc on x.ID=uc.SchoolID " +
- "where f.ScoreYear='"+param.ScoreYear+"' and uc.UserID="+param.UserID+" and (f.PlanNum>0 or f.PlanNum=-999) " +
- "and ((f.ScoreType in ('名额到区','1-15志愿') and f.DistrictID="+param.DistrictID+") or (f.ScoreType in ('自主招生') and f.SchoolTargetRemark='1学科')) " +
- "order by SchoolTarget,f.ScoreType desc,SchoolTargetRemark;";
- }
- else{
- sql="select f.SchoolOfGraduation as 'ID',f.SchoolFullNameJunior as 'SchoolFullName',f.DistrictID,x.SchoolShortName,f.PlanNum,f.ScoreTotal,f.Score1,f.Score2,f.Score3,f.Score4,f.PlanNumDifferenceValue,f.ScoreTotalDifferenceValue " +
- "from MPS_Score f inner join MPS_School x on f.SchoolTarget=x.ID " +
- "inner join MPS_UserCollect uc on f.SchoolOfGraduation=uc.SchoolID " +
- "where f.ScoreYear='"+param.ScoreYear+"' and uc.UserID="+param.UserID+" " +
- "and f.ScoreType in ('名额到校') and (f.PlanNum>0 or f.PlanNum=-999) " +
- "order by SchoolOfGraduation;";
- }
- var list=await commonModel.RunSql({},sql);
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- if (param.SchoolType1=='高中') {
- item.Name = item.ScoreType;
- delete item.ScoreType;
- }
- else {
- item.Name = item.SchoolShortName;
- item.District=getDistrict(item.DistrictID);
- }
- item.Height=93;
- if (!item.ScoreTotal)
- item.ScoreTotal="";
- if (!item.Score1)
- item.Score1="";
- if (!item.Score2)
- item.Score2="";
- if (!item.Score3)
- item.Score3="";
- if (!item.Score4)
- item.Score4="";
- if (i > 0) {
- item.TempID = list[i - 1].ID;
- }
- item.Score1=stringUtils.TrimEndZero(item.Score1);
- item.Score2=stringUtils.TrimEndZero(item.Score2);
- item.Score3=stringUtils.TrimEndZero(item.Score3);
- item.Score4=stringUtils.TrimEndZero(item.Score4);
- item.ScoreTotal=stringUtils.TrimEndZero(item.ScoreTotal);
- item.ScoreTotalDifferenceValue=stringUtils.TrimEndZero(item.ScoreTotalDifferenceValue);
-
- }
- var year=moment().format("YYYY");
- if (ArrYear[0].IsNullScoreLine && param.ScoreYear==year){
- sql=sql.replace(ArrYear[0].Name,ArrYear[1].Name);
- var list2 = await commonModel.RunSql({}, sql);
- for(var i=0;i<list.length;i++){
- if (list[i].Name!="自主招生") {
- for (var j = 0; j < list2.length; j++) {
- var item=list[i];
- if (param.SchoolType1=='高中') {
- if (item.DistrictID == list2[j].DistrictID
- && item.Name == list2[j].ScoreType
- && item.SchoolTarget == list2[j].SchoolTarget
- && list2[j].ScoreTotal>0
- && item.ID == list2[j].ID) {
- item.ScoreTotal = stringUtils.TrimEndZero(list2[j].ScoreTotal);
- item.Score1 = stringUtils.TrimEndZero(list2[j].Score1);
- item.Score2 = stringUtils.TrimEndZero(list2[j].Score2);
- item.Score3 = stringUtils.TrimEndZero(list2[j].Score3);
- item.Score4 = stringUtils.TrimEndZero(list2[j].Score4);
- item.ScoreTotalDifferenceValue = stringUtils.TrimEndZero(list2[j].ScoreTotalDifferenceValue);
-
- break;
- }
- }
- else {
- if (item.DistrictID == list2[j].DistrictID
- && item.Name == list2[j].SchoolShortName
- && list2[j].ScoreTotal>0
- && item.ID == list2[j].ID) {
- item.ScoreTotal = stringUtils.TrimEndZero(list2[j].ScoreTotal);
- item.Score1 = stringUtils.TrimEndZero(list2[j].Score1);
- item.Score2 = stringUtils.TrimEndZero(list2[j].Score2);
- item.Score3 = stringUtils.TrimEndZero(list2[j].Score3);
- item.Score4 = stringUtils.TrimEndZero(list2[j].Score4);
- item.ScoreTotalDifferenceValue = stringUtils.TrimEndZero(list2[j].ScoreTotalDifferenceValue);
- break;
- }
- }
- }
- }
- }
- }
- ctx.body = {"errcode": 10000,result:list};
- }
- //修改分数线
- export async function UpdateMPSScore(ctx) {
- let param = ctx.request.body;
- let sql="update MPS_Score set ? where ID="+param.ID+";";
- if (param.ID==0){
- let sql2 = "select * from MPS_Score where ScoreType='"+param.ScoreType+"' and ScoreYear='"+param.ScoreYear+"'";
- sql2+=" and DistrictID="+param.DistrictID+" ";
- if (!param.SchoolOfGraduation)
- param.SchoolOfGraduation=0;
- sql2+=" and SchoolOfGraduation='"+param.SchoolOfGraduation+"' ";
- sql2+=" and SchoolTarget='"+param.SchoolTarget+"'";
- if (param.SchoolTargetRemark && param.SchoolTargetRemark!="undefined") {
- sql2 += " and SchoolTargetRemark='" + param.SchoolTargetRemark + "';";
- }
- let hasID=await commonModel.RunSql({},sql2);
- if (hasID && hasID.length>0) {
- param.ID=hasID[0].ID;
- sql="update MPS_Score set ? where ID="+param.ID+";";
- }
- else{
- delete param.ID;
- sql = "insert into MPS_Score SET ?";
- }
- }
- let insertID = await commonModel.RunSql(param,sql);
- if (!param.ID || param.ID==0){
- sql="update MPS_Score f,MPS_School x set f.SchoolFullName=x.SchoolFullName where f.SchoolTarget=x.ID;";
- await commonModel.RunSql({},sql);
- sql="update MPS_Score f,MPS_School x set f.SchoolFullNameJunior=x.SchoolFullName where f.SchoolOfGraduation=x.ID;";
- await commonModel.RunSql({},sql);
- param.ID=insertID.insertId;
- }
- ctx.body = {"errcode": 10000,result:param.ID};
- }
- // 得到分数线(Web使用)
- export async function GetMPSScoreWeb(ctx) {
- const param = {
- ScoreYear: ctx.query.ScoreYear || ArrYear[0].Name,
- ScoreType: ctx.query.ScoreType || '1-15志愿',
- DistrictID: ctx.query.DistrictID || 0,
- };
- let sql0 = "SELECT f.ID,x.District as 'DistrictName',f.DistrictID,f.ScoreType,f.SchoolOfGraduation,f.SchoolFullNameJunior,f.SchoolTarget,x.SchoolFullName,x.SchoolShortName,x.SchoolType2Short,x.Accommodation,x.PublicOrPrivate,f.SchoolTargetRemark," +
- "f.PlanNum,f.ScoreTotal,f.Score1,f.Score2,f.Score3,f.Score4,f.SchoolTargetRemark2,f.PlanNumDifferenceValue,f.ScoreTotalDifferenceValue FROM MPS_Score f inner join MPS_School x on f.SchoolTarget=x.ID ";
- if (param.ScoreType === "名额到校") {
- sql0 += " inner join MPS_School c on f.SchoolOfGraduation = c.ID ";
- }
- sql0 += " where f.ScoreType='" + param.ScoreType + "'";
- let sql = sql0;
- let scoreYear = param.ScoreYear;
- sql += " and f.ScoreYear='" + scoreYear + "'";
- if (param.DistrictID !== "全部") {
- sql += " and f.DistrictID=" + param.DistrictID;
- }
- let sqlOrder = "";
- if (param.ScoreType === "名额到校") {
- if (param.DistrictID === 3 || param.DistrictID === 11 || param.DistrictID === 6 || param.DistrictID === 10 || param.DistrictID === 12)
- sqlOrder += " order by c.ID,x.SchoolNumber,f.ID;";
- else
- sqlOrder += " order by c.SchoolNumber,x.SchoolNumber,f.ID;";
- }
- else if (param.ScoreType === "1-15志愿")
- sqlOrder += " order by f.DistrictID,f.OrderID,x.ID;";
- else
- sqlOrder += " order by f.DistrictID,x.DistrictID,x.SchoolNumber,f.SchoolTargetRemark;";
- sql += sqlOrder;
- const list = await commonModel.RunSql({}, sql);
- if (param.ScoreYear === "2022") {
- for (let i = 0; i < list.length; i++) {
- const item = list[i];
- item.ID = 0;
- item.PlanNum = "";
- item.ScoreTotal = "";
- item.Score1 = "";
- item.Score2 = "";
- item.Score3 = "";
- item.Score4 = "";
- item.SchoolTargetRemark2 = "";
- }
- scoreYear = param.ScoreYear;
- sql = sql0;
- sql += " and f.ScoreYear='" + scoreYear + "'";
- if (param.DistrictID !== "全部") {
- sql += " and f.DistrictID='" + param.DistrictID + "'";
- }
- sql += sqlOrder;
- const list2 = await commonModel.RunSql({}, sql);
- for (let i = 0; i < list.length; i++) {
- const item = list[i];
- for (let j = 0; j < list2.length; j++) {
- if (
- item.SchoolOfGraduation === list2[j].SchoolOfGraduation
- && item.SchoolTarget === list2[j].SchoolTarget
- && item.DistrictID === list2[j].DistrictID
- && item.ScoreType === list2[j].ScoreType
- && (item.SchoolTargetRemark === list2[j].SchoolTargetRemark || (!item.SchoolTargetRemark && !list2[j].SchoolTargetRemark))
- ) {
- item.ID = list2[j].ID;
- item.SchoolTargetRemark = list2[j].SchoolTargetRemark;
- item.PlanNum = list2[j].PlanNum;
- item.ScoreTotal = list2[j].ScoreTotal;
- item.Score1 = list2[j].Score1;
- item.Score2 = list2[j].Score2;
- item.Score3 = list2[j].Score3;
- item.Score4 = list2[j].Score4;
- item.SchoolTargetRemark2 = list2[j].SchoolTargetRemark2;
- break;
- }
- }
- }
- }
- ctx.body = { "errcode": 10000, result: list };
- }
|