|
@@ -33,23 +33,28 @@ module.exports = app => {
|
|
|
* @returns {Promise<void>}
|
|
|
* @private
|
|
|
*/
|
|
|
- async _calculateNodeIndex(transaction, condition, globalParams, newParam) {
|
|
|
+ async _calculateNodeIndex(transaction, condition, globalParams, newParam, gRelaParam) {
|
|
|
const nodeParams = await this.ctx.service.tenderParam.getAllDataByCondition({where: condition});
|
|
|
const nodeIndexes = await this.ctx.service.tenderIndex.getAllDataByCondition({where: condition});
|
|
|
+ let relaParam;
|
|
|
if (newParam) {
|
|
|
for (const np of nodeParams) {
|
|
|
if (np.code === newParam.code) {
|
|
|
np.calc_value = newParam.value;
|
|
|
+ relaParam = np;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ relaParam = gRelaParam;
|
|
|
}
|
|
|
- this.ctx.service.indexCalc.calculate(nodeIndexes, globalParams, nodeParams);
|
|
|
+ this.ctx.service.indexCalc.calculate(nodeIndexes, globalParams, nodeParams, relaParam);
|
|
|
for (const u of this.ctx.service.indexCalc.updateArr) {
|
|
|
- await transaction.update(this.ctx.service.tenderIndex.tableName,
|
|
|
- { eval_rule: u.eval_rule, value: u.value },
|
|
|
- { where: { lib_id: u.lib_id, index_id: u.index_id } },
|
|
|
- );
|
|
|
+ await transaction.update(this.ctx.service.tenderIndex.tableName, {
|
|
|
+ id: u.id,
|
|
|
+ eval_rule: u.eval_rule,
|
|
|
+ value: u.value,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -65,18 +70,34 @@ module.exports = app => {
|
|
|
const globalParams = await this.ctx.service.tenderParam.getAllDataByCondition({
|
|
|
where: {lib_id: condition.lib_id, node_id: paramConst.globalParamNodeId}
|
|
|
});
|
|
|
+ let relaParam;
|
|
|
if (newParam) {
|
|
|
for (const gp of globalParams) {
|
|
|
if (gp.code === newParam.code) {
|
|
|
gp.calc_value = newParam.value;
|
|
|
+ relaParam = gp;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
const nodes = await this.ctx.service.tenderNode.getAllDataByCondition({where: condition});
|
|
|
+ const indexes = await this.ctx.service.tenderIndex.getAllDataByCondition({where: condition});
|
|
|
+ const params = await this.ctx.service.tenderParam.getAllDataByCondition({where: condition});
|
|
|
for (const node of nodes) {
|
|
|
- condition.node_id = node.node_id;
|
|
|
- await this._calculateNodeIndex(transaction, condition, globalParams);
|
|
|
+ node.indexes = indexes.filter(function (a) {
|
|
|
+ return a.node_id === node.node_id;
|
|
|
+ });
|
|
|
+ node.params = params.filter(function (a) {
|
|
|
+ return a.node_id === node.node_id;
|
|
|
+ });
|
|
|
+ this.ctx.service.indexCalc.calculate(node.indexes, globalParams, node.params, relaParam);
|
|
|
+ for (const u of this.ctx.service.indexCalc.updateArr) {
|
|
|
+ await transaction.update(this.ctx.service.tenderIndex.tableName, {
|
|
|
+ id: u.id,
|
|
|
+ eval_rule: u.eval_rule,
|
|
|
+ value: u.value,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|