|
@@ -52,6 +52,7 @@ class ReportMemoryMaterial {
|
|
|
calc: function (p) {
|
|
|
p.pre_gather_qty = helper.add(p.pre_contract_qty, p.pre_qc_qty);
|
|
|
p.gather_qty = helper.add(p.contract_qty, p.qc_qty);
|
|
|
+ p.gather_minus_qty = helper.add(p.gather_qty, p.qc_minus_qty);
|
|
|
p.end_contract_qty = helper.add(p.pre_contract_qty, p.contract_qty);
|
|
|
p.end_qc_qty = helper.add(p.pre_qc_qty, p.qc_qty);
|
|
|
p.end_gather_qty = helper.add(p.pre_gather_qty, p.gather_qty);
|
|
@@ -73,6 +74,7 @@ class ReportMemoryMaterial {
|
|
|
if (node.children && node.children.length === 0) {
|
|
|
node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
|
node.gather_qty = helper.add(node.contract_qty, node.qc_qty);
|
|
|
+ node.gather_minus_qty = helper.add(node.gather_qty, node.qc_minus_qty);
|
|
|
node.end_contract_qty = helper.add(node.pre_contract_qty, node.contract_qty);
|
|
|
node.end_qc_qty = helper.add(node.pre_qc_qty, node.qc_qty);
|
|
|
node.end_gather_qty = helper.add(node.pre_gather_qty, node.gather_qty);
|
|
@@ -246,7 +248,7 @@ class ReportMemoryMaterial {
|
|
|
if (this._checkFieldsExist(fields, billsFields.stage)) {
|
|
|
const curStage = await this.ctx.service.stageBills.getStagesData(tender_id, material.stage_id);
|
|
|
this.ctx.helper.assignRelaData(billsData, [
|
|
|
- {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'}
|
|
|
+ {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'lid'}
|
|
|
]);
|
|
|
}
|
|
|
|
|
@@ -270,7 +272,7 @@ class ReportMemoryMaterial {
|
|
|
if (this._checkFieldsExist(fields, posFields.stage)) {
|
|
|
const curPosStage = await this.ctx.service.stagePos.getStagesData(tender_id, material.stage_id);
|
|
|
this.ctx.helper.assignRelaData(posData, [
|
|
|
- {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'}
|
|
|
+ {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'}
|
|
|
]);
|
|
|
}
|
|
|
const pos = this._getNewPos();
|
|
@@ -284,18 +286,32 @@ class ReportMemoryMaterial {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ getMaterialCalcQty(qtySource, info, is_join) {
|
|
|
+ let qty = 0;
|
|
|
+ switch(qtySource) {
|
|
|
+ case materialConst.qty_source_value.gather_qty: qty = info.gather_qty; break;
|
|
|
+ case materialConst.qty_source_value.contract_qty: qty = info.contract_qty; break;
|
|
|
+ case materialConst.qty_source_value.gather_minus_qty: qty = info.gather_minus_qty; break;
|
|
|
+ default: throw '未配置计量来源';
|
|
|
+ }
|
|
|
+ if (qtySource !== materialConst.qty_source_value.contract_qty && is_join === 2) {
|
|
|
+ qty = info.contract_qty;
|
|
|
+ }
|
|
|
+ return qty;
|
|
|
+ }
|
|
|
+
|
|
|
async _getMaterialStageGatherBills(tender_id, stage_id, stage_order, stageSelf, stageIndex = 0) {
|
|
|
const decimal = this.materialGatherBase.decimal;
|
|
|
//const billsData = this.ctx.helper.clone(this.materialGatherBase.billsData);
|
|
|
const billsData = this.materialGatherBase.billsData;
|
|
|
billsData.forEach(x => {
|
|
|
- for (const prop of ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp']) {
|
|
|
+ for (const prop of ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty']) {
|
|
|
x[prop] = undefined;
|
|
|
}
|
|
|
});
|
|
|
const curStageBills = await this.ctx.service.stageBills.getStagesData(tender_id, stage_id);
|
|
|
this.ctx.helper.assignRelaData(billsData, [
|
|
|
- { data: curStageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
|
|
|
+ { data: curStageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty'], prefix: '', relaId: 'lid' },
|
|
|
]);
|
|
|
const billsTree = this._getNewBillsTree();
|
|
|
billsTree.loadDatas(billsData);
|
|
@@ -304,13 +320,13 @@ class ReportMemoryMaterial {
|
|
|
//const posData = this.ctx.helper.clone(this.materialGatherBase.posData);
|
|
|
const posData = this.materialGatherBase.posData;
|
|
|
posData.forEach(x => {
|
|
|
- for (const prop of ['contract_qty', 'qc_qty']) {
|
|
|
+ for (const prop of ['contract_qty', 'qc_qty', 'qc_minus_qty']) {
|
|
|
x[prop] = undefined;
|
|
|
}
|
|
|
});
|
|
|
const curStage = await this.ctx.service.stagePos.getStagesData(tender_id, stage_id);
|
|
|
this.ctx.helper.assignRelaData(posData, [
|
|
|
- { data: curStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid' },
|
|
|
+ { data: curStage, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'], prefix: '', relaId: 'pid' },
|
|
|
]);
|
|
|
const pos = this._getNewPos();
|
|
|
pos.loadDatas(posData);
|
|
@@ -325,16 +341,17 @@ class ReportMemoryMaterial {
|
|
|
: this.materialGatherBase.materialGl;
|
|
|
if (stageIndex) materialGl.forEach(x => { x.s_index = stageIndex });
|
|
|
const materialNotJoin = this.materialGatherBase.materialNotJoin;
|
|
|
+ const materialNotChange = this.materialGatherBase.materialNotChange;
|
|
|
|
|
|
const helper = this.ctx.helper;
|
|
|
|
|
|
- console.time('calcMaterialBills');
|
|
|
for (const g of gatherUtil.gclList) {
|
|
|
- if (!g.contract_qty && !g.qc_qty) continue;
|
|
|
+ if (!g.contract_qty && !g.qc_qty && !g.qc_minus_qty) continue;
|
|
|
g.sid = stage_id;
|
|
|
g.sorder = stage_order;
|
|
|
g.s_index = stageIndex;
|
|
|
g.jiacha = 0;
|
|
|
+ g.jiacha_qty = 0;
|
|
|
for (const x of g.leafXmjs) {
|
|
|
x.sid = stage_id;
|
|
|
x.sorder = stage_order;
|
|
@@ -344,21 +361,25 @@ class ReportMemoryMaterial {
|
|
|
return m.gcl_id === x.org_gcl_id && m.xmj_id === x.id && (x.mx_id && x.mx_id !== x.id ? x.mx_id === m.mx_id : true);
|
|
|
});
|
|
|
x.is_join = !mnj;
|
|
|
+ const mnc = materialNotChange.find(m => {
|
|
|
+ return m.gcl_id === x.org_gcl_id && m.xmj_id === x.id && (x.mx_id && x.mx_id !== x.id ? x.mx_id === m.mx_id : true);
|
|
|
+ });
|
|
|
+ x.is_change = mnc ? 2 : 1;
|
|
|
const list = materialGl.filter(gl => {
|
|
|
return gl.gcl_id === x.org_gcl_id && gl.xmj_id === x.id && (x.mx_id && x.mx_id !== x.id ? x.mx_id === gl.mx_id : true);
|
|
|
});
|
|
|
list.forEach(l => { l.gather_gcl_id = x.gcl_id});
|
|
|
|
|
|
if (mnj) continue;
|
|
|
+ x.jiacha_qty = this.getMaterialCalcQty(this.materialGatherBase.qtySource, x, x.is_change);
|
|
|
for (const l of list) {
|
|
|
- x.jiacha = helper.add(x.jiacha, helper.mul(helper.mul(x.gather_qty, l.quantity), l.m_spread));
|
|
|
+ x.jiacha = helper.add(x.jiacha, helper.mul(helper.mul(x.jiacha_qty, l.quantity), l.m_spread));
|
|
|
}
|
|
|
x.jiacha = helper.round(x.jiacha, decimal.tp);
|
|
|
g.jiacha = helper.add(g.jiacha, x.jiacha);
|
|
|
- g.jiacha_qty = helper.add(g.jiacha_qty, x.gather_qty);
|
|
|
+ g.jiacha_qty = helper.add(g.jiacha_qty, x.jiacha_qty);
|
|
|
}
|
|
|
}
|
|
|
- console.timeEnd('calcMaterialBills');
|
|
|
return [gatherUtil.gclList, gatherUtil.leafXmjs];
|
|
|
}
|
|
|
|
|
@@ -371,6 +392,7 @@ class ReportMemoryMaterial {
|
|
|
|
|
|
const material = await this.ctx.service.material.getDataByCondition({ tid: tender_id, order: material_order });
|
|
|
this.materialGatherBase = {};
|
|
|
+ this.materialGatherBase.qtySource = material.qty_source;
|
|
|
this.materialGatherBase.decimal = material.decimal ? JSON.parse(material.decimal) : materialConst.decimal;
|
|
|
try {
|
|
|
// 获取基础数据
|
|
@@ -385,7 +407,8 @@ class ReportMemoryMaterial {
|
|
|
? await this.ctx.service.materialList.getMaterialData(tender_id, material.id)
|
|
|
: await this.ctx.service.materialList.getPreMaterialData(tender_id, material.id);
|
|
|
}
|
|
|
- this.materialGatherBase.materialNotJoin = await this.ctx.service.materialListNotjoin.getAllDataByCondition({ where: { mid: material.id } });
|
|
|
+ this.materialGatherBase.materialNotJoin = await this.ctx.service.materialListNotjoin.getAllDataByCondition({ where: { mid: material.id, type: 1 } });
|
|
|
+ this.materialGatherBase.materialNotChange = await this.ctx.service.materialListNotjoin.getAllDataByCondition({ where: { mid: material.id, type: 2 } });
|
|
|
|
|
|
const mem_material_gather_bills = [], mem_material_gather_xmj = [];
|
|
|
if (material.is_stage_self) {
|