|
@@ -7,6 +7,7 @@
|
|
|
* @date
|
|
|
* @version
|
|
|
*/
|
|
|
+const pushOperate = require('../const/spec_3f').pushOperate;
|
|
|
|
|
|
module.exports = app => {
|
|
|
class SpecPull extends app.BaseService {
|
|
@@ -110,6 +111,37 @@ module.exports = app => {
|
|
|
await this.db.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing, extra_info: JSON.stringify(subInfo || {}) });
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async _getOtherMsgBaseData(id, timing) {
|
|
|
+ switch(timing) {
|
|
|
+ case pushOperate.report.change_file:
|
|
|
+ const change = await this.ctx.service.change.getAllDataByCondition({ where: { cid: id } });
|
|
|
+ return change.map(x => { return { cid: x.cid } });
|
|
|
+ case pushOperate.report.change_plan_file:
|
|
|
+ const changePlan = await this.ctx.service.changePlan.getAllDataByCondition({ where: { id } });
|
|
|
+ return changePlan.map(x => { return { c_plan_id: x.id } });
|
|
|
+ case pushOperate.report.change_apply_file:
|
|
|
+ const changeApply = await this.ctx.service.changeApply.getAllDataByCondition({ where: { id } });
|
|
|
+ return changeApply.map(x => { return { c_apply_id: x.id } });
|
|
|
+ default:
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async addOtherReportMsg(transaction, pid, tender, id, timing, subInfo) {
|
|
|
+ const needMsg = await this.tenderNeedMsg(pid, tender.id, timing);
|
|
|
+ if (!needMsg) return;
|
|
|
+
|
|
|
+ const data = await this._getOtherMsgBaseData(id, timing);
|
|
|
+ const insertMsg = data.map(x => {
|
|
|
+ return { pid, tid: tender.id, timing, extra_info: JSON.stringify(subInfo || {}), ...x };
|
|
|
+ });
|
|
|
+ if (transaction) {
|
|
|
+ await transaction.insert(this.tableName, insertMsg);
|
|
|
+ } else {
|
|
|
+ await this.db.insert(this.tableName, insertMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return SpecPull;
|