|
@@ -22,7 +22,15 @@ module.exports = app => {
|
|
|
this.tableName = 'tender_param';
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 计算指标节点下全部指标
|
|
|
+ * @param transaction - 事务
|
|
|
+ * @param {Object} condition - 计算范围
|
|
|
+ * @param {Array} globalParams - 可用全局参数
|
|
|
+ * @param {Object} newParam - 更新的节点参数
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ * @private
|
|
|
+ */
|
|
|
async _calculateNodeIndex(transaction, condition, globalParams, newParam) {
|
|
|
const nodeParams = await this.ctx.service.tenderParam.getAllDataByCondition({where: condition});
|
|
|
const nodeIndexes = await this.ctx.service.tenderIndex.getAllDataByCondition({where: condition});
|
|
@@ -43,17 +51,27 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算标段内全部指标
|
|
|
+ * @param transaction - 事务
|
|
|
+ * @param {Object} condition - 计算范围
|
|
|
+ * @param {Object} newParam - 更新的全局参数
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ * @private
|
|
|
+ */
|
|
|
async _calculateAllIndex(transaction, condition, newParam) {
|
|
|
const globalParams = await this.ctx.service.tenderParam.getAllDataByCondition({
|
|
|
where: {lib_id: condition.lib_id, node_id: paramConst.globalParamNodeId}
|
|
|
});
|
|
|
- for (const gp of globalParams) {
|
|
|
- if (gp.code === newParam.code) {
|
|
|
- gp.calc_value = newParam.value;
|
|
|
- break;
|
|
|
+ if (newParam) {
|
|
|
+ for (const gp of globalParams) {
|
|
|
+ if (gp.code === newParam.code) {
|
|
|
+ gp.calc_value = newParam.value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- const nodes = await this.ctx.tenderNode.getAllDataByCondition({where: condition});
|
|
|
+ const nodes = await this.ctx.service.tenderNode.getAllDataByCondition({where: condition});
|
|
|
for (const node of nodes) {
|
|
|
condition.node_id = node.node_id;
|
|
|
await this._calculateNodeIndex(transaction, condition, globalParams);
|
|
@@ -76,8 +94,9 @@ module.exports = app => {
|
|
|
if (condition.lib_id < 0 || condition.node_id < 0) {
|
|
|
throw '提交数据错误';
|
|
|
}
|
|
|
+ data.value = parseFloat(data.value);
|
|
|
const updateData = {
|
|
|
- calc_value: parseFloat(data.value),
|
|
|
+ calc_value: (isNaN(data.value) ? null : data.value),
|
|
|
};
|
|
|
await transaction.update(this.tableName, updateData, {where: condition});
|
|
|
if (condition.node_id === paramConst.globalParamNodeId) {
|