功能调整

master
tianea 2 years ago
parent 9a12778229
commit 8fb6782f86

@ -12,8 +12,10 @@
"bootstrap": "^5.1.3", "bootstrap": "^5.1.3",
"bootstrap-vue": "^2.21.2", "bootstrap-vue": "^2.21.2",
"echarts": "^5.3.1", "echarts": "^5.3.1",
"file-saver": "^2.0.5",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-router": "^3.0.1" "vue-router": "^3.0.1",
"xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",
@ -190,6 +192,14 @@
"node": ">=0.4.0" "node": ">=0.4.0"
} }
}, },
"node_modules/adler-32": {
"version": "1.3.1",
"resolved": "https://registry.npmmirror.com/adler-32/-/adler-32-1.3.1.tgz",
"integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/ajv": { "node_modules/ajv": {
"version": "5.5.2", "version": "5.5.2",
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-5.5.2.tgz", "resolved": "https://registry.npmmirror.com/ajv/-/ajv-5.5.2.tgz",
@ -1860,6 +1870,18 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/cfb": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/cfb/-/cfb-1.2.2.tgz",
"integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
"dependencies": {
"adler-32": "~1.3.0",
"crc-32": "~1.2.0"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/chalk": { "node_modules/chalk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmmirror.com/chalk/-/chalk-2.4.2.tgz", "resolved": "https://registry.npmmirror.com/chalk/-/chalk-2.4.2.tgz",
@ -2181,6 +2203,14 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/codepage": {
"version": "1.15.0",
"resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz",
"integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/collection-visit": { "node_modules/collection-visit": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmmirror.com/collection-visit/-/collection-visit-1.0.0.tgz", "resolved": "https://registry.npmmirror.com/collection-visit/-/collection-visit-1.0.0.tgz",
@ -2484,6 +2514,17 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/crc-32": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/crc-32/-/crc-32-1.2.2.tgz",
"integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
"bin": {
"crc32": "bin/crc32.njs"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/create-ecdh": { "node_modules/create-ecdh": {
"version": "4.0.4", "version": "4.0.4",
"resolved": "https://registry.npmmirror.com/create-ecdh/-/create-ecdh-4.0.4.tgz", "resolved": "https://registry.npmmirror.com/create-ecdh/-/create-ecdh-4.0.4.tgz",
@ -4691,6 +4732,11 @@
"node": ">= 4" "node": ">= 4"
} }
}, },
"node_modules/file-saver": {
"version": "2.0.5",
"resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"node_modules/file-uri-to-path": { "node_modules/file-uri-to-path": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@ -4812,6 +4858,14 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/frac": {
"version": "1.1.2",
"resolved": "https://registry.npmmirror.com/frac/-/frac-1.1.2.tgz",
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/fragment-cache": { "node_modules/fragment-cache": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmmirror.com/fragment-cache/-/fragment-cache-0.2.1.tgz", "resolved": "https://registry.npmmirror.com/fragment-cache/-/fragment-cache-0.2.1.tgz",
@ -11739,6 +11793,17 @@
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
"dev": true "dev": true
}, },
"node_modules/ssf": {
"version": "0.11.2",
"resolved": "https://registry.npmmirror.com/ssf/-/ssf-0.11.2.tgz",
"integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
"dependencies": {
"frac": "~1.1.2"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/ssri": { "node_modules/ssri": {
"version": "5.3.0", "version": "5.3.0",
"resolved": "https://registry.npmmirror.com/ssri/-/ssri-5.3.0.tgz", "resolved": "https://registry.npmmirror.com/ssri/-/ssri-5.3.0.tgz",
@ -13900,6 +13965,22 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/wmf": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/wmf/-/wmf-1.0.2.tgz",
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/word": {
"version": "0.3.0",
"resolved": "https://registry.npmmirror.com/word/-/word-0.3.0.tgz",
"integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/wordwrap": { "node_modules/wordwrap": {
"version": "0.0.2", "version": "0.0.2",
"resolved": "https://registry.npmmirror.com/wordwrap/-/wordwrap-0.0.2.tgz", "resolved": "https://registry.npmmirror.com/wordwrap/-/wordwrap-0.0.2.tgz",
@ -13973,6 +14054,26 @@
"safe-buffer": "~5.1.0" "safe-buffer": "~5.1.0"
} }
}, },
"node_modules/xlsx": {
"version": "0.18.5",
"resolved": "https://registry.npmmirror.com/xlsx/-/xlsx-0.18.5.tgz",
"integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
"dependencies": {
"adler-32": "~1.3.0",
"cfb": "~1.2.1",
"codepage": "~1.15.0",
"crc-32": "~1.2.1",
"ssf": "~0.11.2",
"wmf": "~1.0.1",
"word": "~0.3.0"
},
"bin": {
"xlsx": "bin/xlsx.njs"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/xtend": { "node_modules/xtend": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz",
@ -14251,6 +14352,11 @@
} }
} }
}, },
"adler-32": {
"version": "1.3.1",
"resolved": "https://registry.npmmirror.com/adler-32/-/adler-32-1.3.1.tgz",
"integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A=="
},
"ajv": { "ajv": {
"version": "5.5.2", "version": "5.5.2",
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-5.5.2.tgz", "resolved": "https://registry.npmmirror.com/ajv/-/ajv-5.5.2.tgz",
@ -15796,6 +15902,15 @@
"lazy-cache": "^1.0.3" "lazy-cache": "^1.0.3"
} }
}, },
"cfb": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/cfb/-/cfb-1.2.2.tgz",
"integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
"requires": {
"adler-32": "~1.3.0",
"crc-32": "~1.2.0"
}
},
"chalk": { "chalk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmmirror.com/chalk/-/chalk-2.4.2.tgz", "resolved": "https://registry.npmmirror.com/chalk/-/chalk-2.4.2.tgz",
@ -16054,6 +16169,11 @@
"integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==", "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==",
"dev": true "dev": true
}, },
"codepage": {
"version": "1.15.0",
"resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz",
"integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA=="
},
"collection-visit": { "collection-visit": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmmirror.com/collection-visit/-/collection-visit-1.0.0.tgz", "resolved": "https://registry.npmmirror.com/collection-visit/-/collection-visit-1.0.0.tgz",
@ -16320,6 +16440,11 @@
"parse-json": "^4.0.0" "parse-json": "^4.0.0"
} }
}, },
"crc-32": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/crc-32/-/crc-32-1.2.2.tgz",
"integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ=="
},
"create-ecdh": { "create-ecdh": {
"version": "4.0.4", "version": "4.0.4",
"resolved": "https://registry.npmmirror.com/create-ecdh/-/create-ecdh-4.0.4.tgz", "resolved": "https://registry.npmmirror.com/create-ecdh/-/create-ecdh-4.0.4.tgz",
@ -18209,6 +18334,11 @@
} }
} }
}, },
"file-saver": {
"version": "2.0.5",
"resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"file-uri-to-path": { "file-uri-to-path": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "resolved": "https://registry.npmmirror.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@ -18300,6 +18430,11 @@
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"dev": true "dev": true
}, },
"frac": {
"version": "1.1.2",
"resolved": "https://registry.npmmirror.com/frac/-/frac-1.1.2.tgz",
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA=="
},
"fragment-cache": { "fragment-cache": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmmirror.com/fragment-cache/-/fragment-cache-0.2.1.tgz", "resolved": "https://registry.npmmirror.com/fragment-cache/-/fragment-cache-0.2.1.tgz",
@ -24040,6 +24175,14 @@
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
"dev": true "dev": true
}, },
"ssf": {
"version": "0.11.2",
"resolved": "https://registry.npmmirror.com/ssf/-/ssf-0.11.2.tgz",
"integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
"requires": {
"frac": "~1.1.2"
}
},
"ssri": { "ssri": {
"version": "5.3.0", "version": "5.3.0",
"resolved": "https://registry.npmmirror.com/ssri/-/ssri-5.3.0.tgz", "resolved": "https://registry.npmmirror.com/ssri/-/ssri-5.3.0.tgz",
@ -25850,6 +25993,16 @@
"integrity": "sha512-1pTPQDKTdd61ozlKGNCjhNRd+KPmgLSGa3mZTHoOliaGcESD8G1PXhh7c1fgiPjVbNVfgy2Faw4BI8/m0cC8Mg==", "integrity": "sha512-1pTPQDKTdd61ozlKGNCjhNRd+KPmgLSGa3mZTHoOliaGcESD8G1PXhh7c1fgiPjVbNVfgy2Faw4BI8/m0cC8Mg==",
"dev": true "dev": true
}, },
"wmf": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/wmf/-/wmf-1.0.2.tgz",
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw=="
},
"word": {
"version": "0.3.0",
"resolved": "https://registry.npmmirror.com/word/-/word-0.3.0.tgz",
"integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA=="
},
"wordwrap": { "wordwrap": {
"version": "0.0.2", "version": "0.0.2",
"resolved": "https://registry.npmmirror.com/wordwrap/-/wordwrap-0.0.2.tgz", "resolved": "https://registry.npmmirror.com/wordwrap/-/wordwrap-0.0.2.tgz",
@ -25913,6 +26066,20 @@
"safe-buffer": "~5.1.0" "safe-buffer": "~5.1.0"
} }
}, },
"xlsx": {
"version": "0.18.5",
"resolved": "https://registry.npmmirror.com/xlsx/-/xlsx-0.18.5.tgz",
"integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
"requires": {
"adler-32": "~1.3.0",
"cfb": "~1.2.1",
"codepage": "~1.15.0",
"crc-32": "~1.2.1",
"ssf": "~0.11.2",
"wmf": "~1.0.1",
"word": "~0.3.0"
}
},
"xtend": { "xtend": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz",

@ -14,8 +14,10 @@
"bootstrap": "^5.1.3", "bootstrap": "^5.1.3",
"bootstrap-vue": "^2.21.2", "bootstrap-vue": "^2.21.2",
"echarts": "^5.3.1", "echarts": "^5.3.1",
"file-saver": "^2.0.5",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-router": "^3.0.1" "vue-router": "^3.0.1",
"xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",

@ -0,0 +1,220 @@
/* eslint-disable */
import { saveAs } from 'file-saver'
import * as XLSX from 'xlsx'
function generateArray(table) {
var out = [];
var rows = table.querySelectorAll('tr');
var ranges = [];
for (var R = 0; R < rows.length; ++R) {
var outRow = [];
var row = rows[R];
var columns = row.querySelectorAll('td');
for (var C = 0; C < columns.length; ++C) {
var cell = columns[C];
var colspan = cell.getAttribute('colspan');
var rowspan = cell.getAttribute('rowspan');
var cellValue = cell.innerText;
if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
//Skip ranges
ranges.forEach(function (range) {
if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
}
});
//Handle Row Span
if (rowspan || colspan) {
rowspan = rowspan || 1;
colspan = colspan || 1;
ranges.push({
s: {
r: R,
c: outRow.length
},
e: {
r: R + rowspan - 1,
c: outRow.length + colspan - 1
}
});
};
//Handle Value
outRow.push(cellValue !== "" ? cellValue : null);
//Handle Colspan
if (colspan)
for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
}
out.push(outRow);
}
return [out, ranges];
};
function datenum(v, date1904) {
if (date1904) v += 1462;
var epoch = Date.parse(v);
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
}
function sheet_from_array_of_arrays(data, opts) {
var ws = {};
var range = {
s: {
c: 10000000,
r: 10000000
},
e: {
c: 0,
r: 0
}
};
for (var R = 0; R != data.length; ++R) {
for (var C = 0; C != data[R].length; ++C) {
if (range.s.r > R) range.s.r = R;
if (range.s.c > C) range.s.c = C;
if (range.e.r < R) range.e.r = R;
if (range.e.c < C) range.e.c = C;
var cell = {
v: data[R][C]
};
if (cell.v == null) continue;
var cell_ref = XLSX.utils.encode_cell({
c: C,
r: R
});
if (typeof cell.v === 'number') cell.t = 'n';
else if (typeof cell.v === 'boolean') cell.t = 'b';
else if (cell.v instanceof Date) {
cell.t = 'n';
cell.z = XLSX.SSF._table[14];
cell.v = datenum(cell.v);
} else cell.t = 's';
ws[cell_ref] = cell;
}
}
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
return ws;
}
function Workbook() {
if (!(this instanceof Workbook)) return new Workbook();
this.SheetNames = [];
this.Sheets = {};
}
function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
export function export_table_to_excel(id) {
var theTable = document.getElementById(id);
var oo = generateArray(theTable);
var ranges = oo[1];
/* original data */
var data = oo[0];
var ws_name = "SheetJS";
var wb = new Workbook(),
ws = sheet_from_array_of_arrays(data);
/* add ranges to worksheet */
// ws['!cols'] = ['apple', 'banan'];
ws['!merges'] = ranges;
/* add worksheet to workbook */
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {
bookType: 'xlsx',
bookSST: false,
type: 'binary'
});
saveAs(new Blob([s2ab(wbout)], {
type: "application/octet-stream"
}), "test.xlsx")
}
export function export_json_to_excel({
multiHeader = [],
header,
data,
filename,
merges = [],
autoWidth = true,
bookType = 'xlsx'
} = {}) {
/* original data */
filename = filename || 'excel-list'
data = [...data]
data.unshift(header);
for (let i = multiHeader.length - 1; i > -1; i--) {
data.unshift(multiHeader[i])
}
var ws_name = "SheetJS";
var wb = new Workbook(),
ws = sheet_from_array_of_arrays(data);
if (merges.length > 0) {
if (!ws['!merges']) ws['!merges'] = [];
merges.forEach(item => {
ws['!merges'].push(XLSX.utils.decode_range(item))
})
}
if (autoWidth) {
/*设置worksheet每列的最大宽度*/
const colWidth = data.map(row => row.map(val => {
/*先判断是否为null/undefined*/
if (val == null) {
return {
'wch': 10
};
}
/*再判断是否为中文*/
else if (val.toString().charCodeAt(0) > 255) {
return {
'wch': val.toString().length * 2
};
} else {
return {
'wch': val.toString().length
};
}
}))
/*以第一行为初始值*/
let result = colWidth[0];
for (let i = 1; i < colWidth.length; i++) {
for (let j = 0; j < colWidth[i].length; j++) {
if (result[j]['wch'] < colWidth[i][j]['wch']) {
result[j]['wch'] = colWidth[i][j]['wch'];
}
}
}
ws['!cols'] = result;
}
/* add worksheet to workbook */
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {
bookType: bookType,
bookSST: false,
type: 'binary'
});
saveAs(new Blob([s2ab(wbout)], {
type: "application/octet-stream"
}), `${filename}.${bookType}`);
}

@ -42,6 +42,7 @@
<div class="tz-table-container" v-if="rankingSubType == 1"> <div class="tz-table-container" v-if="rankingSubType == 1">
<div class="tz-table-filter"> <div class="tz-table-filter">
<span>检索</span><b-input v-model="queryData.kw" class="tz-filter-input" placeholder="团队名称/指导老师/院校" /> <b-button class="tz-table-button" @click="searchRank"></b-button> <span>检索</span><b-input v-model="queryData.kw" class="tz-filter-input" placeholder="团队名称/指导老师/院校" /> <b-button class="tz-table-button" @click="searchRank"></b-button>
<b-button class="tz-table-button" @click="exportTeamRank"></b-button>
<!-- <b-button class="tz-table-button">导出</b-button> --> <!-- <b-button class="tz-table-button">导出</b-button> -->
</div> </div>
<b-container class="tz-rank"> <b-container class="tz-rank">
@ -62,7 +63,7 @@
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList4_20x20.png" /> <b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList4_20x20.png" />
指导老师 指导老师
</b-col> </b-col>
<b-col v-if="selectStage.enableExam" sm=""> <!-- <b-col v-if="selectStage.enableExam" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList5_20x20.png" /> <b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList5_20x20.png" />
投资者教育得分 投资者教育得分
</b-col> </b-col>
@ -70,14 +71,51 @@
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList6_20x20.png" /> <b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList6_20x20.png" />
证券投资得分 证券投资得分
</b-col> </b-col>
<b-col sm=""> <b-col v-if="selectStage.enableExam&&rankingId==2" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList5_20x20.png" />
投资者教育得分
</b-col>
<b-col v-if="selectStage.enableFinance&&rankingId==3" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList6_20x20.png" />
证券投资得分
</b-col> -->
<b-col v-if="selectStage.enableExam&&rankingId==2" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList5_20x20.png" />
投资者教育得分
</b-col>
<b-col v-if="selectStage.enableFinance&&rankingId==3" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList6_20x20.png" />
证券投资得分
</b-col>
<b-col v-if="rankingId == 1" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" /> <b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
综合平均分 综合平均分
</b-col> </b-col>
<b-col sm=""> <b-col v-if="rankingId == 1" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" /> <b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
综合总分 综合总分
</b-col> </b-col>
<b-col v-if="rankingId ==2 " sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
平均用时
</b-col>
<b-col v-if="rankingId == 3" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
平均累计收益率
</b-col>
<b-col v-if="rankingId == 3" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
平均年化收益率
</b-col>
<!-- <b-col sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
综合平均分
</b-col>
<b-col sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
综合总分
</b-col> -->
<b-col sm> <b-col sm>
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList10_20x20.png" /> <b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList10_20x20.png" />
备注 备注
@ -102,7 +140,28 @@
<b-col sm=""> <b-col sm="">
{{item.teacher}} {{item.teacher}}
</b-col> </b-col>
<b-col v-if="selectStage.enableExam" sm=""> <b-col v-if="selectStage.enableExam&&rankingId==2" sm="">
{{numberFixed(item.examScore)}}
</b-col>
<b-col v-if="selectStage.enableFinance&&rankingId==3" sm="">
{{numberFixed(item.financeScore)}}
</b-col>
<b-col v-if="rankingId == 1" sm="">
{{numberFixed(item.combineScore)}}
</b-col>
<b-col v-if="rankingId == 1" sm>
{{numberFixed(item.totalScore)}}
</b-col>
<b-col v-if="rankingId ==2" sm="">
{{toSecond(item.examCostTime)}}
</b-col>
<b-col v-if="rankingId ==3" sm="">
{{numberFixed(item.currentRatio)}}
</b-col>
<b-col v-if="rankingId ==3" sm="">
{{numberFixed(item.yearRatio)}}
</b-col>
<!-- <b-col v-if="selectStage.enableExam" sm="">
{{numberFixed(item.examScore)}} {{numberFixed(item.examScore)}}
</b-col> </b-col>
<b-col v-if="selectStage.enableFinance" sm=""> <b-col v-if="selectStage.enableFinance" sm="">
@ -113,7 +172,7 @@
</b-col> </b-col>
<b-col sm> <b-col sm>
{{numberFixed(item.totalScore)}} {{numberFixed(item.totalScore)}}
</b-col> </b-col> -->
<b-col sm @click="showMemberScore(item)"> <b-col sm @click="showMemberScore(item)">
<span> <span>
查看 查看
@ -126,6 +185,7 @@
<div class="tz-table-filter"> <div class="tz-table-filter">
<span>检索</span><b-input v-model="queryData.kw" class="tz-filter-input" placeholder="姓名/学校/指导老师" /> <b-button class="tz-table-button" @click="searchRank"></b-button> <span>检索</span><b-input v-model="queryData.kw" class="tz-filter-input" placeholder="姓名/学校/指导老师" /> <b-button class="tz-table-button" @click="searchRank"></b-button>
<!-- <b-button class="tz-table-button">导出</b-button> --> <!-- <b-button class="tz-table-button">导出</b-button> -->
<b-button class="tz-table-button" @click="exportPersonalRank"></b-button>
</div> </div>
<b-container class="tz-rank"> <b-container class="tz-rank">
<b-row class="table-header"> <b-row class="table-header">
@ -145,7 +205,7 @@
<b-img src="/static/image/icon_rankList4_20x20.png" /> <b-img src="/static/image/icon_rankList4_20x20.png" />
指导老师 指导老师
</b-col> </b-col>
<b-col v-if="selectStage.enableExam" sm=""> <!-- <b-col v-if="selectStage.enableExam" sm="">
<b-img src="/static/image/icon_rankList5_20x20.png" /> <b-img src="/static/image/icon_rankList5_20x20.png" />
投资者教育得分 投资者教育得分
</b-col> </b-col>
@ -156,8 +216,33 @@
<b-col sm=""> <b-col sm="">
<b-img src="/static/image/icon_rankList7_20x20.png" /> <b-img src="/static/image/icon_rankList7_20x20.png" />
综合得分 综合得分
</b-col> -->
<b-col v-if="selectStage.enableExam&&rankingId == 2" sm="">
<b-img src="/static/image/icon_rankList5_20x20.png" />
投资者教育得分
</b-col>
<b-col v-if="selectStage.enableFinance&&rankingId == 3" sm="">
<b-img src="/static/image/icon_rankList6_20x20.png" />
证券投资得分
</b-col>
<b-col v-if="rankingId == 1" sm="">
<b-img src="/static/image/icon_rankList7_20x20.png" />
综合得分
</b-col>
<b-col v-if="rankingId == 2" sm="">
<b-img src="/static/image/icon_rankList7_20x20.png" />
用时
</b-col>
<b-col v-if="rankingId == 3" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
累计收益率
</b-col>
<b-col v-if="rankingId == 3" sm="">
<b-img v-if="!isMobilePlatform" src="/static/image/icon_rankList7_20x20.png" />
年化收益率
</b-col> </b-col>
<!-- <b-col sm> <!-- <b-col sm>
<b-img src="/static/image/icon_rankList10_20x20.png" /> <b-img src="/static/image/icon_rankList10_20x20.png" />
备注 备注
@ -182,7 +267,25 @@
<b-col sm> <b-col sm>
{{item.teacher}} {{item.teacher}}
</b-col> </b-col>
<b-col v-if="selectStage.enableExam" sm> <b-col v-if="selectStage.enableExam&&rankingId == 2" sm>
{{numberFixed(item.examScore)}}
</b-col>
<b-col v-if="selectStage.enableFinance&&rankingId == 3" sm>
{{numberFixed(item.financeScore)}}
</b-col>
<b-col v-if="rankingId == 1" sm>
{{ numberFixed(item.combineScore)}}
</b-col>
<b-col v-if="rankingId == 2" sm>
{{toSecond(item.examCostTime)}}
</b-col>
<b-col v-if="rankingId ==3" sm="">
{{numberFixed(item.currentRatio)}}
</b-col>
<b-col v-if="rankingId ==3" sm="">
{{numberFixed(item.yearRatio)}}
</b-col>
<!-- <b-col v-if="selectStage.enableExam" sm>
{{numberFixed(item.examScore)}} {{numberFixed(item.examScore)}}
</b-col> </b-col>
<b-col v-if="selectStage.enableFinance" sm> <b-col v-if="selectStage.enableFinance" sm>
@ -190,7 +293,7 @@
</b-col> </b-col>
<b-col sm> <b-col sm>
{{ numberFixed(item.combineScore)}} {{ numberFixed(item.combineScore)}}
</b-col> </b-col> -->
<!-- <b-col sm> <!-- <b-col sm>
{{item.examCostTime}} {{item.examCostTime}}
</b-col> --> </b-col> -->
@ -485,6 +588,45 @@ export default {
} }
}, },
methods:{ methods:{
formatJson(filterVal,jsonData){
return jsonData.map(v => filterVal.map(j => {
if(j=== 'financeScore'||j == 'combineScore'){
return this.numberFixed(v[j])
}
return v[j]
}))
},
exportTeamRank(){
import('@/vendor/Export2Excel').then(excel=>{
const tHeader = [ '排名','团队名','所属院校','指导老师','证券投资得分','综合平均分','综合总分']
const filterVal = ['rank','name','school','teacher','financeScore','combineScore','totalScore']
const list = this.teamRankList
const data = this.formatJson(filterVal, list)
excel.export_json_to_excel({
header: tHeader,
data,
filename: 'team_rank',
autoWidth: true,
bookType: 'xlsx'
})
})
},
exportPersonalRank(){
import('@/vendor/Export2Excel').then(excel=>{
const tHeader = [ '排名','姓名','所属院校','指导老师','证券投资得分','综合总分']
const filterVal = ['personalRank','name','school','teacher','financeScore','combineScore']
const list = this.rankList
const data = this.formatJson(filterVal, list)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '个人排行',
autoWidth: true,
bookType: 'xlsx'
})
})
},
isMobile() { isMobile() {
let flag = !!navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) let flag = !!navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
return flag; return flag;
@ -502,6 +644,9 @@ export default {
this.tempTeamInfo = item this.tempTeamInfo = item
this.dialogVisibale = true this.dialogVisibale = true
}, },
toSecond(ms){
return (ms/1000).toFixed();
},
page(step,type){ page(step,type){
if(type ==1){ if(type ==1){
let pn = parseInt(this.queryData.pageNo)+parseInt(step); let pn = parseInt(this.queryData.pageNo)+parseInt(step);
@ -533,7 +678,7 @@ export default {
if(typeof(num) == 'number'){ if(typeof(num) == 'number'){
return num.toFixed(2) return num.toFixed(2)
} }
return num return 0
}, },
changeType2(t){ changeType2(t){
this.rankingSubType = t this.rankingSubType = t
@ -649,16 +794,41 @@ export default {
let examScore = 0 let examScore = 0
let financeScore = 0 let financeScore = 0
let combineScore = 0 let combineScore = 0
let currentRatio = 0
let yearRatio = 0
let examCostTime = 0
memberList.forEach(m=>{ memberList.forEach(m=>{
if(m.examScore){ if(m.examScore){
examScore+=m.examScore if(typeof m.examScore === 'number'){
examScore+= m.examScore
}
} }
if(m.financeScore){ if(m.financeScore){
if(typeof m.financeScore === 'number'){
financeScore+=m.financeScore financeScore+=m.financeScore
} }
}
if(m.combineScore){ if(m.combineScore){
if(typeof m.combineScore === 'number'){
combineScore += m.combineScore combineScore += m.combineScore
} }
}
if(m.currentRatio){
if(typeof m.currentRatio === 'number'){
currentRatio += m.currentRatio
}
}
if(m.yearRatio){
if(typeof m.yearRatio === 'number'){
yearRatio +=m.yearRatio
}
}
if(m.examCostTime){
if(typeof m.examCostTime === 'number'){
examCostTime +=m.examCostTime
}
}
}) })
let tr = 0 let tr = 0
if(!!this.queryData.kw&&this.queryData.kw.length>0){ if(!!this.queryData.kw&&this.queryData.kw.length>0){
@ -676,6 +846,9 @@ export default {
examScore: examScore/teamCount, examScore: examScore/teamCount,
financeScore: financeScore/teamCount, financeScore: financeScore/teamCount,
combineScore: combineScore/teamCount, combineScore: combineScore/teamCount,
currentRatio: currentRatio/teamCount,
yearRatio: yearRatio/teamCount,
examCostTime: examCostTime/teamCount,
totalScore: combineScore, totalScore: combineScore,
memberList: memberList memberList: memberList
} }

@ -37,6 +37,7 @@ export default {
}, },
methods:{ methods:{
login(){ login(){
if(this.user.username.length == 0){ if(this.user.username.length == 0){
this.msg = "用户名不能为空" this.msg = "用户名不能为空"
return return
@ -57,7 +58,6 @@ export default {
}) })
} }
} }
} }
</script> </script>
<style scoped> <style scoped>

@ -1,5 +1,5 @@
<template> <template>
<div onbeforeunload="beforeClose"> <div>
<div class="tz-exam-header"> <div class="tz-exam-header">
<div class="tz-exam-header-line"> <div class="tz-exam-header-line">
<div> <div>
@ -184,6 +184,7 @@ export default {
sumScore: 0 sumScore: 0
}, },
singleQuestion: [], singleQuestion: [],
isSubmit: false,
multiQuestion: [], multiQuestion: [],
judgeQuestion: [], judgeQuestion: [],
anliQuestion:[], anliQuestion:[],
@ -211,7 +212,7 @@ export default {
}, },
methods:{ methods:{
beforeClose(){ beforeClose(){
alert("sb")
}, },
getStatus(id){ getStatus(id){
let c = ""; let c = "";
@ -250,8 +251,8 @@ export default {
qList=qList.concat(this.getQList(this.judgeQuestion)) qList=qList.concat(this.getQList(this.judgeQuestion))
qList=qList.concat(this.getQList(this.anliQuestion)) qList=qList.concat(this.getQList(this.anliQuestion))
examApi.submit(this.compId,this.stageId,qList).then(res=>{ examApi.submit(this.compId,this.stageId,qList).then(res=>{
console.log(res)
if(res.code == 200){ if(res.code == 200){
this.isSubmit = true
alert("考试得分"+res.data.score) alert("考试得分"+res.data.score)
}else{ }else{
alert(res.msg) alert(res.msg)
@ -375,7 +376,6 @@ export default {
this.loadQuestion() this.loadQuestion()
}else{ }else{
alert(res.msg) alert(res.msg)
} }
}) })
}, },
@ -392,7 +392,6 @@ export default {
this.multiInfo.score = this.multiInfo.sumScore/this.multiInfo.size this.multiInfo.score = this.multiInfo.sumScore/this.multiInfo.size
this.anliInfo.sumScore = this.sumAnliScore(this.anliQuestion) this.anliInfo.sumScore = this.sumAnliScore(this.anliQuestion)
this.anliInfo.score = this.anliInfo.sumScore/this.anliInfo.size this.anliInfo.score = this.anliInfo.sumScore/this.anliInfo.size
}, },
sumScore(qList){ sumScore(qList){
let score = 0 let score = 0
@ -415,6 +414,9 @@ export default {
}) })
} }
return score return score
},
isNumber(obj){
return typeof obj === 'number'&&!isNaN(obj)
} }
}, },
created(){ created(){
@ -432,7 +434,7 @@ export default {
memberApi.getMemberInfo(this.compId,this.stageId).then(res=>{ memberApi.getMemberInfo(this.compId,this.stageId).then(res=>{
if(res.code == 200){ if(res.code == 200){
this.memberInfo = res.data this.memberInfo = res.data
if(!!this.memberInfo.examScore&&this.memberInfo.examScore>=0){ if( this.isNumber(this.memberInfo.examScore)&&this.memberInfo.examScore>=0){
this.$router.push({ this.$router.push({
path: '/examrs', path: '/examrs',
query: { query: {
@ -446,11 +448,25 @@ export default {
} }
this.userInfo = getInfo() this.userInfo = getInfo()
// this.loadQuestion() // this.loadQuestion()
},
mounted(){
}, },
watch:{ watch:{
confirm(val){ confirm(val){
if(val){ if(val){
this.startExam() this.startExam()
// let that = this
// window.onbeforeunload = function(e){
// that.handle()
// e = e||window.event
// if(e){
// e.returnvalue="";
// }
// return "";
// }
}else{
} }
} }
}, },

@ -301,7 +301,6 @@ export default {
qList=qList.concat(this.getQList(this.judgeQuestion)) qList=qList.concat(this.getQList(this.judgeQuestion))
qList=qList.concat(this.getQList(this.anliQuestion)) qList=qList.concat(this.getQList(this.anliQuestion))
examApi.submit(this.compId,this.stageId,qList).then(res=>{ examApi.submit(this.compId,this.stageId,qList).then(res=>{
if(res.code == 200){ if(res.code == 200){
alert("考试得分"+res.data.score) alert("考试得分"+res.data.score)
}else{ }else{
@ -419,9 +418,7 @@ export default {
}) })
}, },
getMyAnswer(id,subId){ getMyAnswer(id,subId){
if(this.myAnwserlist){ if(this.myAnwserlist){
let answer = this.myAnwserlist.filter(item=>{ let answer = this.myAnwserlist.filter(item=>{
return item.id == id &&item.subId == subId return item.id == id &&item.subId == subId
}) })

@ -303,10 +303,20 @@ export default {
return flag; return flag;
}, },
sim(){ sim(){
if(!this.memberInfo.accountPwd){ if(!this.memberInfo.accountPwd){
alert("无交易系统权限"); alert("无交易系统权限");
return return
} }
let current = new Date().getTime()
if(new Date(this.taskInof.operationStartTime).getTime()>current){
alert("比赛未开始")
return
}
if(new Date(this.taskInof.operationEndTime).getTime()<current){
alert("比赛已结束")
return
}
let url = 'https://sim.sztzjy.com/user/login?token='+this.memberInfo.accountPwd+'&redirect=https://sim.sztzjy.com/sim?acc='+this.memberInfo.accountId let url = 'https://sim.sztzjy.com/user/login?token='+this.memberInfo.accountPwd+'&redirect=https://sim.sztzjy.com/sim?acc='+this.memberInfo.accountId
window.open(url,"onlywin",'toolbar=no, location=no,directoryies=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, height=600, width=1100, left=180, top=100') window.open(url,"onlywin",'toolbar=no, location=no,directoryies=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, height=600, width=1100, left=180, top=100')
}, },

@ -95,6 +95,12 @@ public class CompetitionIndexControll extends BaseController {
return Result.success("success"); return Result.success("success");
} }
@GetMapping(value = "reRank")
public Result<String> reRank(@RequestParam("compId") Long compId,@RequestParam("stageId") Integer stageId,@RequestParam("count") Integer count){
newFixedThreadPool(1).execute(()-> rankingBiz.computeMemberRank(compId,stageId,count));
return Result.success("success");
}
@GetMapping(value = "time") @GetMapping(value = "time")
public Result<String> time(){ public Result<String> time(){
return Result.success(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")); return Result.success(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));

@ -65,7 +65,6 @@ public class CompetitionMemberBiz {
return initSystem(compId,stageId,userNo); return initSystem(compId,stageId,userNo);
} }
CompetitionMemberDTO dto= BeanUtils.copyProperties(member,CompetitionMemberDTO.class); CompetitionMemberDTO dto= BeanUtils.copyProperties(member,CompetitionMemberDTO.class);
return Result.success(dto); return Result.success(dto);
} }

@ -19,4 +19,6 @@ public class MemberRankingDTO implements Serializable {
private Double examCostTime; private Double examCostTime;
private Integer regionId; private Integer regionId;
private Integer provinceId; private Integer provinceId;
private Double yearRatio;
private Double currentRatio;
} }

@ -45,6 +45,7 @@ public class RankingBiz {
private ReportInfoDao reportInfoDao; private ReportInfoDao reportInfoDao;
public void fetchRanking(){ public void fetchRanking(){
JueJinToken jueJinToken = jueJinTokenDao.getById(1); JueJinToken jueJinToken = jueJinTokenDao.getById(1);
if(jueJinToken == null) {return;} if(jueJinToken == null) {return;}
@ -101,6 +102,9 @@ public class RankingBiz {
private void doRank(Stage ss,JueJinApi jueJinApi,String endTime,Competition competition,String now,List<String> accountIdList ){ private void doRank(Stage ss,JueJinApi jueJinApi,String endTime,Competition competition,String now,List<String> accountIdList ){
CompetitionTask currentTask = taskDao.getByCompetitionIdAndStageId(competition.getId(), ss.getId()); CompetitionTask currentTask = taskDao.getByCompetitionIdAndStageId(competition.getId(), ss.getId());
if(currentTask.getOperationEndTime().getTime()<System.currentTimeMillis()){
return;
}
Date date = currentTask.getOperationStartTime(); Date date = currentTask.getOperationStartTime();
String startTime = DateUtil.format( DateUtil.offsetMonth(date,-1)); String startTime = DateUtil.format( DateUtil.offsetMonth(date,-1));
Double baseRatio = jueJinApi.getBaseRatio(startTime, endTime); Double baseRatio = jueJinApi.getBaseRatio(startTime, endTime);
@ -231,8 +235,27 @@ public class RankingBiz {
}); });
computeScore(rankingList,currentTask,competition,baseRatio); computeScore(rankingList,currentTask,competition,baseRatio);
computeRanking(rankingList,currentTask,competition.getTeamMaxCount(),now); computeRanking(rankingList,currentTask,competition.getTeamMaxCount(),now);
computeMemberRank(currentTask.getCompetitionId(),currentTask.getStageId(),competition.getTeamMaxCount());
competition.setUpdateRankDate(now); competition.setUpdateRankDate(now);
competitionDao.save(competition); competitionDao.save(competition);
}
public void computeMemberRank(Long compId,Integer stageId,Integer memberCount){
List<CompetitionMember> memberList = memberDao.findAllByCompetitionIdAndStageId(compId,stageId);
CompetitionTask task = taskDao.getByCompetitionIdAndStageId(compId,stageId);
memberList.forEach(member->{
Double combineScore = computeCombineScore(task,member.getExamScore(),member.getFinanceScore());
member.setCombineScore(combineScore);
memberDao.updateComineScore(combineScore,member.getId());
});
memberList.sort(Comparator.comparing(CompetitionMember::getCombineScore).reversed());
for(int i = 0;i<memberList.size();i++){
int rank = i + 1;
CompetitionMember member = memberList.get(i);
member.setPersonalRank(rank);
memberDao.updatePersonalRank(member.getUserId(),stageId,compId,rank);
}
memberDao.updateTeamRank(task.getStageId(),task.getCompetitionId(),memberCount);
} }
private void computeScore(List<Ranking> rankingList, CompetitionTask currentTask,Competition competition,Double baseRatio){ private void computeScore(List<Ranking> rankingList, CompetitionTask currentTask,Competition competition,Double baseRatio){
@ -259,7 +282,7 @@ public class RankingBiz {
} }
} }
} }
memberDao.updateRankingMemberData(ranking.getReportId(),financeScore,combineScore,baseRatio,ranking.getAvailable(), memberDao.updateRankingMemberData(ranking.getReportId(),maxPnlRaito,financeScore,combineScore,baseRatio,ranking.getAvailable(),
ranking.getNav(),ranking.getCloseCount(),ranking.getOpenCount(),ranking.getCumCommission(),ranking.getPnlRatio(), ranking.getNav(),ranking.getCloseCount(),ranking.getOpenCount(),ranking.getCumCommission(),ranking.getPnlRatio(),
ranking.getCalmarRatio(),ranking.getSharpRatio(),ranking.getPnlRatioAnnual(),ranking.getProfitLoss(),ranking.getMaxDrawdown(), ranking.getCalmarRatio(),ranking.getSharpRatio(),ranking.getPnlRatioAnnual(),ranking.getProfitLoss(),ranking.getMaxDrawdown(),
ranking.getMarketValue(),ranking.getUserNo(),ranking.getCompId(),ranking.getStageId()); ranking.getMarketValue(),ranking.getUserNo(),ranking.getCompId(),ranking.getStageId());
@ -369,15 +392,13 @@ public class RankingBiz {
}); });
}); });
// rankingList.sort(Comparator.comparing(Ranking::getFinanceScore).reversed());
//// for(int i = 0;i<rankingList.size();i++){
rankingList.sort(Comparator.comparing(Ranking::getFinanceScore).reversed()); //// int rank = i + 1;
for(int i = 0;i<rankingList.size();i++){ //// Ranking ranking = rankingList.get(i);
int rank = i + 1; //// ranking.setPersonalRank(rank);
Ranking ranking = rankingList.get(i); //// memberDao.updatePersonalRank(ranking.getUserNo(),ranking.getStageId(),ranking.getCompId(),rank);
ranking.setPersonalRank(rank); //// }
memberDao.updatePersonalRank(ranking.getUserNo(),ranking.getStageId(),ranking.getCompId(),rank);
}
// try { // try {
// Map<Integer, Double> tcrMap = sortMapByValues(teamCombineRank); // Map<Integer, Double> tcrMap = sortMapByValues(teamCombineRank);
// AtomicInteger rank = new AtomicInteger(0); // AtomicInteger rank = new AtomicInteger(0);
@ -392,7 +413,7 @@ public class RankingBiz {
// //
// } // }
rankingDao.saveAll(rankingList); rankingDao.saveAll(rankingList);
memberDao.updateTeamRank(task.getStageId(),task.getCompetitionId(),memberCount);
memberDao.updateTeamRank2(now); memberDao.updateTeamRank2(now);
} }
@ -438,7 +459,8 @@ public class RankingBiz {
* @return * @return
*/ */
private double computeFinaceScore(CompetitionTask task,double userRatio,double baseRatio,double maxUserRatio){ private double computeFinaceScore(CompetitionTask task,double userRatio,double baseRatio,double maxUserRatio){
double score = task.getFinanceBasePower() + ((userRatio - baseRatio) /(maxUserRatio -baseRatio))* task.getFinanceProfitPower(); // double score = task.getFinanceBasePower() + ((userRatio - baseRatio) /(maxUserRatio - baseRatio))* task.getFinanceProfitPower();
double score = task.getFinanceProfitPower() + ((userRatio - baseRatio) /(maxUserRatio - baseRatio))* task.getFinanceBasePower();
return score; return score;
} }
} }

@ -223,6 +223,9 @@ public class JueJinApi {
String start = "2022-04-01"; String start = "2022-04-01";
String end = "2022-05-05"; String end = "2022-05-05";
AccountInfo info = api.createAccount("test",20000L,4);
System.out.println(info.getAccount_id());
// AccountInfo info = api.createAccount("测试账号",1000000L,1); // AccountInfo info = api.createAccount("测试账号",1000000L,1);
// System.out.println(info.getAccount_id()); // System.out.println(info.getAccount_id());
// api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0"); // api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0");
@ -232,8 +235,8 @@ public class JueJinApi {
// api.createReport(accountId,"report"+ System.currentTimeMillis()); // api.createReport(accountId,"report"+ System.currentTimeMillis());
// api.getTenPosition("9d7f4856-cc11-11ec-9cd0-00163e0e6ad0"); // api.getTenPosition("9d7f4856-cc11-11ec-9cd0-00163e0e6ad0");
// api.getCashInfo("cbee8129-cae7-11ec-a4f7-00163e0e6ad0"); // api.getCashInfo("cbee8129-cae7-11ec-a4f7-00163e0e6ad0");
String content = api.getReport("57240003"); // String content = api.getReport("57240003");
System.out.println(content); // System.out.println(content);
// String reportDetail = api.reportDetail("55910953"); // String reportDetail = api.reportDetail("55910953");
// System.out.println(content); // System.out.println(content);
// api.getStockInfo("SHSE.600547,SHSE.603160"); // api.getStockInfo("SHSE.600547,SHSE.603160");

@ -62,6 +62,10 @@ public interface CompetitionMemberDao extends JpaRepository<CompetitionMember,In
@Query(value = "update competition_member set highest_ratio=:ratio where user_id=:userNo and stage_id=:stageId and competition_id=:compId",nativeQuery = true) @Query(value = "update competition_member set highest_ratio=:ratio where user_id=:userNo and stage_id=:stageId and competition_id=:compId",nativeQuery = true)
int updateHighestRatio(@Param("userNo") Long userNo,@Param("stageId") Integer stageId,@Param("compId") Long comId, @Param("ratio") Double ratio); int updateHighestRatio(@Param("userNo") Long userNo,@Param("stageId") Integer stageId,@Param("compId") Long comId, @Param("ratio") Double ratio);
@Modifying
@Query(value = "update competition_member set combine_score=:combineScore where id=:id",nativeQuery = true)
int updateComineScore(@Param("combineScore") Double combineScore,@Param("id") Integer id);
@Transactional @Transactional
@Modifying @Modifying
@ -119,11 +123,12 @@ public interface CompetitionMemberDao extends JpaRepository<CompetitionMember,In
@Transactional @Transactional
@Modifying @Modifying
@Query(value = "update competition_member set report_id=:reportId,finance_score=:financeScore,combine_score=:combineScore,\n"+ @Query(value = "update competition_member set report_id=:reportId,highest_ratio=:highestRatio,finance_score=:financeScore,combine_score=:combineScore,\n"+
"base_ratio=:baseRatio,available_founds=:availableFounds,total_founds=:totalFounds,close_count=:closeCount,open_count=:opentCount,\n"+ "base_ratio=:baseRatio,available_founds=:availableFounds,total_founds=:totalFounds,close_count=:closeCount,open_count=:opentCount,\n"+
"commission=:commision,current_ratio=:pnlRatio,kamma_ratio=:kamma,sharp_ratio=:sharpRatio,year_ratio=:yearRatio,over_ratio=:overRatio,\n"+ "commission=:commision,current_ratio=:pnlRatio,kamma_ratio=:kamma,sharp_ratio=:sharpRatio,year_ratio=:yearRatio,over_ratio=:overRatio,\n"+
"max_draw_down=:maxDrawDown,market_value=:marketValue where user_id=:userId and competition_id=:compId and stage_id=:stageId",nativeQuery = true) "max_draw_down=:maxDrawDown,market_value=:marketValue where user_id=:userId and competition_id=:compId and stage_id=:stageId",nativeQuery = true)
int updateRankingMemberData(@Param("reportId") Integer reportId, int updateRankingMemberData(@Param("reportId") Integer reportId,
@Param("highestRatio") Double highestRatio,
@Param("financeScore") Double financeScore, @Param("financeScore") Double financeScore,
@Param("combineScore") Double combineScore, @Param("combineScore") Double combineScore,
@Param("baseRatio") Double baseRatio, @Param("baseRatio") Double baseRatio,

@ -56,6 +56,9 @@ public class PCQuestionBiz {
Question question = new Question(); Question question = new Question();
BeanUtils.copyProperties(questionVO,question); BeanUtils.copyProperties(questionVO,question);
ExampleMatcher exampleMatcher = ExampleMatcher.matching().withIgnoreNullValues(); ExampleMatcher exampleMatcher = ExampleMatcher.matching().withIgnoreNullValues();
if(question.getScore()!=null&&question.getScore() == 0){
question.setScore(null);
}
if(StringUtils.isEmpty(questionVO.getStem())){ if(StringUtils.isEmpty(questionVO.getStem())){
exampleMatcher = exampleMatcher.withIgnorePaths("stem"); exampleMatcher = exampleMatcher.withIgnorePaths("stem");
} }

Loading…
Cancel
Save