|
@@ -14,6 +14,7 @@ class SchoolService extends CrudService {
|
|
|
this.model = this.ctx.model.School;
|
|
|
this.smodel = this.ctx.model.Student;
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
+ this.tmodel = this.ctx.model.Trainplan;
|
|
|
}
|
|
|
|
|
|
async stuimport(data) {
|
|
@@ -21,10 +22,16 @@ class SchoolService extends CrudService {
|
|
|
assert(filepath, 'filepath不能为空');
|
|
|
assert(termid, 'termid不能为空');
|
|
|
assert(schid, 'schid不能为空');
|
|
|
+ // 根据termid取得计划信息
|
|
|
+ const plan = await this.tmodel.findOne({ 'termnum._id': ObjectId(termid) });
|
|
|
+ if (!plan) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '计划信息不存在');
|
|
|
+ }
|
|
|
+ const planid = plan.id;
|
|
|
// 取得excle中数据
|
|
|
const _filepath = this.ctx.app.config.baseUrl + filepath;
|
|
|
console.log(_filepath);
|
|
|
- const studatas = await this.getImportXLSXData(_filepath, termid, schid);
|
|
|
+ const studatas = await this.getImportXLSXData(_filepath, termid, schid, planid);
|
|
|
console.log(studatas);
|
|
|
// 将得到的数据校验
|
|
|
const datacheck = await this.datacheck(studatas);
|
|
@@ -44,7 +51,7 @@ class SchoolService extends CrudService {
|
|
|
}
|
|
|
|
|
|
// 获取导入的XLSX文件中的数据
|
|
|
- async getImportXLSXData(filepath, termid, schid) {
|
|
|
+ async getImportXLSXData(filepath, termid, schid, planid) {
|
|
|
console.log(filepath);
|
|
|
const file = await this.ctx.curl(filepath);
|
|
|
const workbook = XLSX.read(file.data);
|
|
@@ -80,6 +87,7 @@ class SchoolService extends CrudService {
|
|
|
have_grant: data[theadRule[15]],
|
|
|
termid,
|
|
|
schid,
|
|
|
+ planid,
|
|
|
});
|
|
|
}
|
|
|
exceldata = [ ...exceldata, ..._datas ];
|