Commit f2ac902f by chenjinjing

no message

parent fe5676ca
......@@ -22,7 +22,7 @@ export async function getData(req, res) {
ret["bsjbxx"] = bsjbxxInfo["基本信息"];
ret["videourl"] = bsjbxxInfo["url"];
let {attackData, defenceData, selfHeat, opponentHeat} = await 右侧数据(mid);
let {attackData, defenceData, selfHeat, opponentHeat} = await 右侧数据(mid, bsjbxxInfo.selfName, bsjbxxInfo.opponentName);
ret["attack"] = attackData;
ret["defence"] = defenceData;
ret["selfheat"] = selfHeat;
......@@ -56,7 +56,7 @@ export async function getbsglxq(req, res) {
ret["bsjbxx"] = bsjbxxInfo["基本信息"];
ret["videourl"] = bsjbxxInfo["url"];
let {attackData, defenceData, selfHeat, opponentHeat} = await 右侧数据(mid);
let {attackData, defenceData, selfHeat, opponentHeat} = await 右侧数据(mid, bsjbxxInfo.selfName, bsjbxxInfo.opponentName);
ret["attack"] = attackData;
ret["defence"] = defenceData;
ret["selfheat"] = selfHeat;
......@@ -92,12 +92,11 @@ export async function get图表数据(req, res) {
async function 近期比赛概览(pid, inTime) {
let time = inTime || new Date();
let 近期比赛概览数据 = await get近期比赛概览(pid, time);
let subTitle = 近期比赛概览数据.length > 0 ? 近期比赛概览数据[0].date : "";
let {dataList, firstDate} = await get近期比赛概览(pid, time);
return {
title:"近期比赛概览",
subTitle,
list:近期比赛概览数据
subTitle:firstDate,
list:dataList
}
}
......@@ -108,7 +107,9 @@ async function 比赛信息(mid) {
return {
"基本信息":[[selfPic, selfName, result ],[selfScore, date, opponentScore ],[opponentPic, opponentName, opponentResult]],
"url":videoUrl
"url":videoUrl,
selfName,
opponentName
}
}
......@@ -147,21 +148,30 @@ enum heatAreaEnum {
}
async function 右侧数据(mid) {
async function 右侧数据(mid, selfName, opponentName) {
let { attackData, defenceData, stationData } = await get右侧数据(mid);
attackData.sort( (a, b) => {return a.area - b.area} );
defenceData.sort( (a, b) => {return a.area - b.area} );
let selfHeat = [];
let opponentHeat = [];
let selfHeatRank = [];
let opponentHeatRank = [];
stationData.forEach( info => {
let {area, self, opponent} = info;
selfHeat.push({key:area, value:self});
opponentHeat.push({key:area, value:opponent});
selfHeatRank.push({key:area, value:self});
opponentHeatRank.push({key:area, value:opponent});
});
selfHeatRank.sort( (a,b) => {return a.key-b.key});
opponentHeatRank.sort( (a,b) => {return b.key-a.key});
let selfHeat = [];
selfHeatRank.forEach(info => {
selfHeat.push({key:selfName, value:info.value});
});
let opponentHeat = [];
opponentHeatRank.forEach(info => {
opponentHeat.push({key:opponentName, value:info.value});
});
selfHeat.sort( (a,b) => {return a.key-b.key});
opponentHeat.sort( (a,b) => {return b.key-a.key});
return {attackData, defenceData, selfHeat, opponentHeat};
}
\ No newline at end of file
......@@ -50,7 +50,6 @@ export async function getData(req, res) {
ret["api12"] = await 基础数据();
res.send(ret);
}
......
......@@ -43,10 +43,12 @@ export async function get近期比赛概览(PID, checkDate) {
let sql = "select * from recent_match where self_pid = Placeholder1 and m_date < Placeholder2";
let selectResult = await selectData(sql, PID, checkDate);
let result = [];
let firstDate = "";
selectResult.forEach(info => {
let selfScore = info.SELF_SCORE || 0;
let opponentScore = info.OPPONENT_SCORE || 0;
let matchResult = selfScore > opponentScore ? "胜" : "负";
firstDate = dataFormatInSubKey(info.M_DATE);
result.push({
selfName:info.SELF_NAME,
selfPic:info.SELF_PIC,
......@@ -60,7 +62,7 @@ export async function get近期比赛概览(PID, checkDate) {
});
});
return result;
return {dataList:result, firstDate};
}
function dataFormat(time) {
......@@ -76,6 +78,13 @@ function dataFormat(time) {
return `${matchStr}/${dayStr} ${hoursStr}:${MinutesStr}`;
}
function dataFormatInSubKey(time) {
let date = new Date(time);
let match = date.getMonth() + 1;
let matchStr = match > 9 ? `${match}` : `0${match}`;
return `${date.getFullYear()}-${matchStr}`;
}
export async function get比赛详情(mid) {
let sql = "select * from match_information where m_id = Placeholder1";
let subSql = "select m_date from recent_match where m_id = Placeholder1 "
......@@ -100,7 +109,7 @@ export async function get比赛详情(mid) {
}
export async function get单前比赛对局时间节点(mid) {
let sql = "select * from match_video where Placeholder1";
let sql = "select * from match_video where m_id = Placeholder1";
let selectInfo = await selectData(sql, mid);
......@@ -111,12 +120,16 @@ export async function get单前比赛对局时间节点(mid) {
rankMap[R_ID][G_ID] = {start:START_T, end:END_T, gName:`第${G_ID}轮`, gId:G_ID};
});
let resultMap = {};
let resultList = []
for (let key in rankMap) {
resultMap[key] = Object.keys(rankMap[key]);
resultList.push({
key:`第${key}局`,
rid:parseInt(key),
value:Object.values(rankMap[key])
});
}
return resultMap;
return resultList;
}
export async function get图表(mid, rid, gid) {
......
......@@ -165,9 +165,9 @@ export async function 基础数据() {
let result = [];//[{... list:[{}, {}, {}] }]
let distinctMap = {};
selectList.forEach(info => {
let {p_id, BIRTH, HABITUAL_HAND, MATCH_COUNT, WIN_COUNT, WIN_RATE, SELF_NAME, SELF_SCORE, OPPONENT_SCORE, OPPONENT_NAME, M_ID, SELF_PIC} = info;
if (!distinctMap[p_id]) {
distinctMap[p_id] = {
let {P_ID, BIRTH, HABITUAL_HAND, MATCH_COUNT, WIN_COUNT, WIN_RATE, SELF_NAME, SELF_SCORE, OPPONENT_SCORE, OPPONENT_NAME, M_ID, SELF_PIC} = info;
if (!distinctMap[P_ID]) {
distinctMap[P_ID] = {
"出生日期": BIRTH,
"惯用手": HABITUAL_HAND,
"比赛场次": MATCH_COUNT,
......@@ -180,7 +180,7 @@ export async function 基础数据() {
list:[]
};
}
distinctMap[p_id].list.push({
distinctMap[P_ID].list.push({
selfName:SELF_NAME,
selfScore:SELF_SCORE,
opponentScore:OPPONENT_SCORE,
......
......@@ -7,7 +7,7 @@ export function getPort() : number {
// sit 测试环境 prod 生产环境 dem 演示环境(测试数据,前端无密码访问)
export function getEnv() : string {
return process.argv[2] || "sit";
}
}5
//mongo数据库连接字符
export const mongoServerConstVal = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment