|
@@ -101,6 +101,12 @@ class SchoolService extends CrudService {
|
|
if (errorcode === '1') {
|
|
if (errorcode === '1') {
|
|
return checkRes;
|
|
return checkRes;
|
|
}
|
|
}
|
|
|
|
+ // 2021-05-26 添加与数据库的对比,如果数据库里已经有这个身份证号,就需要提示
|
|
|
|
+ const countStudent = await this.countStudent(studentList, planid);
|
|
|
|
+ const { errorcode: csec } = countStudent;
|
|
|
|
+ if (csec === '1') {
|
|
|
|
+ return countStudent;
|
|
|
|
+ }
|
|
// 整理数据
|
|
// 整理数据
|
|
studentList = this.lastSetData(studentList, {
|
|
studentList = this.lastSetData(studentList, {
|
|
planyearid,
|
|
planyearid,
|
|
@@ -161,6 +167,33 @@ class SchoolService extends CrudService {
|
|
return 'ok';
|
|
return 'ok';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 检查学生是否参加过这个计划以外的计划,参加过就不让来了
|
|
|
|
+ * @param {Array} studentList 学生列表
|
|
|
|
+ * @param {String} planid 计划id
|
|
|
|
+ */
|
|
|
|
+ async countStudent(studentList, planid) {
|
|
|
|
+ let errorcode = '0';
|
|
|
|
+ const errormsg = [];
|
|
|
|
+ for (const stu of studentList) {
|
|
|
|
+ const { name, id_number } = stu;
|
|
|
|
+ let error = false;
|
|
|
|
+ let msg = '';
|
|
|
|
+ const count = await this.smodel.count({ id_number, planid: { $ne: planid } });
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ error = true;
|
|
|
|
+ msg = `${msg}${name}已经参加过培训`;
|
|
|
|
+ }
|
|
|
|
+ if (error) {
|
|
|
|
+ errorcode = '1';
|
|
|
|
+ stu.msg = msg;
|
|
|
|
+ errormsg.push(stu);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return { errorcode, errormsg };
|
|
|
|
+ }
|
|
|
|
+
|
|
// 取得学校预计人数
|
|
// 取得学校预计人数
|
|
async getschnum(plan, schid, batchid) {
|
|
async getschnum(plan, schid, batchid) {
|
|
const schtime = await this.schmodel.findOne({ schid, planid: plan.id });
|
|
const schtime = await this.schmodel.findOne({ schid, planid: plan.id });
|