|
@@ -30,6 +30,16 @@ module.exports = app => {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ async getSumTotalPriceFilter(stage, operate, filter) {
|
|
|
+ const sql = 'SELECT Sum(`contract_pc_tp`) As `contract_pc_tp`, Sum(`qc_pc_tp`) As `qc_pc_tp`, Sum(`pc_tp`) As `pc_tp`, Sum(`positive_qc_pc_tp`) As `positive_qc_pc_tp`, Sum(`negative_qc_pc_tp`) As `negative_qc_pc_tp`' +
|
|
|
+ ' FROM ' + this.tableName + ' As Bills' +
|
|
|
+ ' INNER JOIN ' + this.ctx.service.ledger.departTableName(stage.tid) + ' As Ledger ON Bills.lid = Ledger.id' +
|
|
|
+ ' WHERE Bills.sid = ? And Ledger.b_code ' + operate + ' ?';
|
|
|
+ const sqlParam = [stage.id, filter];
|
|
|
+ const result = await this.db.queryOne(sql, sqlParam);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
async getSumTotalPriceByMaterial(stage_list) {
|
|
|
let contract_pc_tp = 0;
|
|
|
let qc_pc_tp = 0;
|
|
@@ -45,6 +55,28 @@ module.exports = app => {
|
|
|
return { contract_pc_tp, qc_pc_tp, pc_tp };
|
|
|
}
|
|
|
|
|
|
+ async getSumTotalPriceGclByMaterial(stage_list, regText) {
|
|
|
+ let contract_pc_tp = 0;
|
|
|
+ let qc_pc_tp = 0;
|
|
|
+ let pc_tp = 0;
|
|
|
+ for (const stage of stage_list) {
|
|
|
+ const result = await this.getSumTotalPriceGcl(stage, regText);
|
|
|
+ if (result) {
|
|
|
+ contract_pc_tp = this.ctx.helper.add(contract_pc_tp, result.contract_pc_tp);
|
|
|
+ qc_pc_tp = this.ctx.helper.add(qc_pc_tp, result.qc_pc_tp);
|
|
|
+ pc_tp = this.ctx.helper.add(pc_tp, result.pc_tp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return { contract_pc_tp, qc_pc_tp, pc_tp };
|
|
|
+ }
|
|
|
+
|
|
|
+ async getSumTotalPriceGcl(stage, regText) {
|
|
|
+ if (regText) {
|
|
|
+ return await this.getSumTotalPriceFilter(stage, 'REGEXP', regText);
|
|
|
+ }
|
|
|
+ return await this.getSumTotalPriceFilter(stage, '<>', this.db.escape(''));
|
|
|
+ }
|
|
|
+
|
|
|
async getEndStageData(stage) {
|
|
|
const sql = 'SELECT lid, SUM(contract_pc_tp) AS end_contract_pc_tp, SUM(qc_pc_tp) AS end_qc_pc_tp,' +
|
|
|
' SUM(pc_tp) AS end_pc_tp, Sum(`positive_qc_pc_tp`) As `positive_qc_pc_tp`, Sum(`negative_qc_pc_tp`) As `negative_qc_pc_tp`,' +
|