|
@@ -40,7 +40,9 @@ class TrainplanService extends CrudService {
|
|
|
for (const sch of schoolList) {
|
|
|
const { code } = sch;
|
|
|
const obj = { schid: code, year, planid };
|
|
|
- const schtimeres = await this.schmodel.create(obj);
|
|
|
+ let schtimeres;
|
|
|
+ schtimeres = await this.schmodel.findOne(obj);
|
|
|
+ if (!schtimeres)schtimeres = await this.schmodel.create(obj);
|
|
|
if (schtimeres) schtimeArr.push(schtimeres);
|
|
|
}
|
|
|
if (!schtimeArr.every(e => e)) { throw new BusinessError(ErrorCode.DATA_INVALID, '学校计划生成失败'); } else return res;
|