|
@@ -260,7 +260,8 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
_getXMatchId(bills) {
|
|
|
- const reg = /-([a-z])-/i;
|
|
|
+ //const reg = /-([a-z])-/i;
|
|
|
+ const reg = /-([a-z])/i;
|
|
|
if (reg.test(bills.match_key)) {
|
|
|
const ruleParts = bills.match_key.split('-');
|
|
|
const charReg = /(^[a-z]+$)/i;
|
|
@@ -347,6 +348,51 @@ module.exports = app => {
|
|
|
delete b.match_key;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ _syncCustomData(data, custom) {
|
|
|
+ if (!custom || custom.length === 0) return;
|
|
|
+
|
|
|
+ for (const d of data) {
|
|
|
+ const c = custom.find(function (x) {return x.name === d.name});
|
|
|
+ d.calc_value = c.calc_value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async reMatchBills(lib, templateId = 1) {
|
|
|
+ const bills = await this.ctx.service.bills.getAllDataByCondition({ where: {lib_id: lib.id} });
|
|
|
+ this._init(bills);
|
|
|
+ for (const b of bills) {
|
|
|
+ b.match_node = null;
|
|
|
+ }
|
|
|
+ // 获取指标模板全部数据
|
|
|
+ await this._getTemplateData(templateId);
|
|
|
+ // 同步全局指标参数
|
|
|
+ this._syncNodeParam(paramConst.globalParamNodeId, paramConst.globalParamNodeId, this.bills[0]);
|
|
|
+ // 遍历模板中所有指标节点,匹配清单
|
|
|
+ for (const node of this.templateNodes) {
|
|
|
+ this._matchNode(node);
|
|
|
+ }
|
|
|
+ // 计算全部指标节点
|
|
|
+ const globalParams = this.params.filter(function (p) {
|
|
|
+ return p.node_id === paramConst.globalParamNodeId;
|
|
|
+ });
|
|
|
+ const ogp = await this.ctx.service.tenderParam.getAllDataByCondition({ where: {lib_id: lib.id} });
|
|
|
+ this._syncCustomData(globalParams, ogp);
|
|
|
+ for (const node of this.nodes) {
|
|
|
+ const nodeParams = this.params.filter(function (n) {
|
|
|
+ return n.node_id === node.node_id;
|
|
|
+ });
|
|
|
+ const onp = await this.ctx.service.tenderParam.getParams(lib.id, node.bills_id);
|
|
|
+ this._syncCustomData(nodeParams, onp);
|
|
|
+ const nodeIndexes = this.indexes.filter(function (i) {
|
|
|
+ return i.node_id === node.node_id;
|
|
|
+ });
|
|
|
+ this.ctx.service.indexCalc.calculate(nodeIndexes, globalParams, nodeParams);
|
|
|
+ }
|
|
|
+ for (const b of this.bills) {
|
|
|
+ delete b.match_key;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return Match;
|