|
@@ -130,7 +130,7 @@ module.exports = app => {
|
|
|
|
|
|
async add(tenderId, userId, code, plan_code, name, delimit = 100) {
|
|
|
const sql = 'SELECT COUNT(*) as count FROM ?? WHERE `tid` = ? AND ((`code` = ? AND `status` != ?) OR (`p_code` = ? AND `status` = ?))';
|
|
|
- const sqlParam = [this.tableName, tenderId, code, audit.flow.status.checked, code, audit.flow.status.checked];
|
|
|
+ const sqlParam = [this.tableName, tenderId, code, audit.change.status.checked, code, audit.change.status.checked];
|
|
|
const codeCount = await this.db.queryOne(sql, sqlParam);
|
|
|
const count = codeCount.count;
|
|
|
if (count > 0) {
|
|
@@ -146,7 +146,7 @@ module.exports = app => {
|
|
|
cid,
|
|
|
tid: tenderId,
|
|
|
uid: userId,
|
|
|
- status: audit.flow.status.uncheck,
|
|
|
+ status: audit.change.status.uncheck,
|
|
|
times: 1,
|
|
|
valid: true,
|
|
|
in_time: new Date(),
|
|
@@ -252,7 +252,7 @@ module.exports = app => {
|
|
|
return await this.getAllDataByCondition({
|
|
|
tid: tenderId,
|
|
|
uid: userId,
|
|
|
- status: audit.flow.status.checking,
|
|
|
+ status: audit.change.status.checking,
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -260,7 +260,7 @@ module.exports = app => {
|
|
|
return await this.getAllDataByCondition({
|
|
|
tid: tenderId,
|
|
|
uid: userId,
|
|
|
- status: audit.flow.status.uncheck,
|
|
|
+ status: audit.change.status.uncheck,
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -268,7 +268,7 @@ module.exports = app => {
|
|
|
return await this.getAllDataByCondition({
|
|
|
tid: tenderId,
|
|
|
uid: userId,
|
|
|
- status: audit.flow.status.checking,
|
|
|
+ status: audit.change.status.checking,
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -276,7 +276,7 @@ module.exports = app => {
|
|
|
return await this.getAllDataByCondition({
|
|
|
tid: tenderId,
|
|
|
uid: userId,
|
|
|
- status: audit.flow.status.checked,
|
|
|
+ status: audit.change.status.checked,
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -284,7 +284,7 @@ module.exports = app => {
|
|
|
return await this.getAllDataByCondition({
|
|
|
tid: tenderId,
|
|
|
uid: userId,
|
|
|
- status: audit.flow.status.checkNo,
|
|
|
+ status: audit.change.status.checkNo,
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -292,7 +292,7 @@ module.exports = app => {
|
|
|
return await this.count({
|
|
|
tid: tenderId,
|
|
|
uid: userId,
|
|
|
- status: audit.flow.status.checkNo,
|
|
|
+ status: audit.change.status.checkNo,
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -322,18 +322,18 @@ module.exports = app => {
|
|
|
this.tableName,
|
|
|
tenderId,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.uncheck,
|
|
|
+ audit.change.status.uncheck,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.back,
|
|
|
+ audit.change.status.checkNo,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.checked,
|
|
|
+ audit.change.status.checked,
|
|
|
];
|
|
|
break;
|
|
|
case 1: // 待处理(你的)
|
|
|
sql = 'SELECT a.* FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)' + stateSql;
|
|
|
- sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.flow.auditStatus.checking];
|
|
|
+ sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.change.status.checking];
|
|
|
break;
|
|
|
case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
|
|
|
sql =
|
|
@@ -344,15 +344,15 @@ module.exports = app => {
|
|
|
' AND (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql;
|
|
|
sqlParam = [
|
|
|
this.tableName,
|
|
|
- audit.flow.status.uncheck,
|
|
|
+ audit.change.status.uncheck,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.back,
|
|
|
+ audit.change.status.checkNo,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.uncheck,
|
|
|
- audit.flow.status.back,
|
|
|
- audit.flow.status.revise,
|
|
|
+ audit.change.status.uncheck,
|
|
|
+ audit.change.status.checkNo,
|
|
|
+ audit.change.status.revise,
|
|
|
tenderId,
|
|
|
];
|
|
|
break;
|
|
@@ -416,13 +416,13 @@ module.exports = app => {
|
|
|
this.tableName,
|
|
|
tenderId,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.uncheck,
|
|
|
+ audit.change.status.uncheck,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.back,
|
|
|
+ audit.change.status.checkNo,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.checked,
|
|
|
+ audit.change.status.checked,
|
|
|
];
|
|
|
const result = await this.db.query(sql, sqlParam);
|
|
|
return result[0].count;
|
|
@@ -433,7 +433,7 @@ module.exports = app => {
|
|
|
// status: 2,
|
|
|
// });
|
|
|
const sql6 = 'SELECT count(*) AS count FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)' + stateSql;
|
|
|
- const sqlParam6 = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.flow.auditStatus.checking];
|
|
|
+ const sqlParam6 = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.change.status.checking];
|
|
|
const result6 = await this.db.query(sql6, sqlParam6);
|
|
|
return result6[0].count;
|
|
|
case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
|
|
@@ -445,15 +445,15 @@ module.exports = app => {
|
|
|
' AND (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql;
|
|
|
const sqlParam2 = [
|
|
|
this.tableName,
|
|
|
- audit.flow.status.uncheck,
|
|
|
+ audit.change.status.uncheck,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.back,
|
|
|
+ audit.change.status.checkNo,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.uncheck,
|
|
|
- audit.flow.status.back,
|
|
|
- audit.flow.status.revise,
|
|
|
+ audit.change.status.uncheck,
|
|
|
+ audit.change.status.checkNo,
|
|
|
+ audit.change.status.revise,
|
|
|
tenderId,
|
|
|
];
|
|
|
const result2 = await this.db.query(sql2, sqlParam2);
|
|
@@ -494,19 +494,19 @@ module.exports = app => {
|
|
|
this.tableName,
|
|
|
tenderId,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.uncheck,
|
|
|
+ audit.change.status.uncheck,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.back,
|
|
|
+ audit.change.status.checkNo,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.checked,
|
|
|
+ audit.change.status.checked,
|
|
|
];
|
|
|
const result = await this.db.query(sql, sqlParam);
|
|
|
return result[0].total_price ? result[0].total_price : 0;
|
|
|
case 1: // 待处理(你的)
|
|
|
const sql6 = 'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)';
|
|
|
- const sqlParam6 = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.flow.auditStatus.checking];
|
|
|
+ const sqlParam6 = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.change.status.checking];
|
|
|
const result6 = await this.db.query(sql6, sqlParam6);
|
|
|
return result6[0].total_price ? result6[0].total_price : 0;
|
|
|
case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
|
|
@@ -518,15 +518,15 @@ module.exports = app => {
|
|
|
' AND (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?';
|
|
|
const sqlParam2 = [
|
|
|
this.tableName,
|
|
|
- audit.flow.status.uncheck,
|
|
|
+ audit.change.status.uncheck,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.back,
|
|
|
+ audit.change.status.checkNo,
|
|
|
this.ctx.service.changeAudit.tableName,
|
|
|
this.ctx.session.sessionUser.accountId,
|
|
|
- audit.flow.status.uncheck,
|
|
|
- audit.flow.status.back,
|
|
|
- audit.flow.status.revise,
|
|
|
+ audit.change.status.uncheck,
|
|
|
+ audit.change.status.checkNo,
|
|
|
+ audit.change.status.revise,
|
|
|
tenderId,
|
|
|
];
|
|
|
const result2 = await this.db.query(sql2, sqlParam2);
|
|
@@ -566,16 +566,16 @@ module.exports = app => {
|
|
|
* @return {void}
|
|
|
*/
|
|
|
async getCountByStatus2(tenderId, status) {
|
|
|
- if (status === audit.filter.status.uncheck) {
|
|
|
+ if (status === audit.change.status.uncheck) {
|
|
|
const sql =
|
|
|
'SELECT count(*) AS count FROM ?? WHERE ' +
|
|
|
'tid = ? AND (status = ? OR status = ? OR status = ?)';
|
|
|
const sqlParam = [
|
|
|
this.tableName,
|
|
|
tenderId,
|
|
|
- audit.flow.status.uncheck,
|
|
|
- audit.flow.status.back,
|
|
|
- audit.flow.status.revise,
|
|
|
+ audit.change.status.uncheck,
|
|
|
+ audit.change.status.checkNo,
|
|
|
+ audit.change.status.revise,
|
|
|
];
|
|
|
const result = await this.db.queryOne(sql, sqlParam);
|
|
|
return result ? result.count : 0;
|
|
@@ -607,7 +607,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async getChangeTp(tenderId) {
|
|
|
const sql = 'SELECT SUM(`total_price`) AS tp, SUM(`positive_tp`) AS p_tp, SUM(`negative_tp`) AS n_tp FROM ?? WHERE tid = ? AND status = ?';
|
|
|
- const sqlParam = [this.tableName, tenderId, audit.flow.status.checked];
|
|
|
+ const sqlParam = [this.tableName, tenderId, audit.change.status.checked];
|
|
|
const result = await this.db.queryOne(sql, sqlParam);
|
|
|
return result ? [result.tp, result.p_tp, result.n_tp] : [0, 0, 0];
|
|
|
}
|
|
@@ -637,7 +637,7 @@ module.exports = app => {
|
|
|
// 更新原报人审批状态
|
|
|
await this.transaction.update(this.ctx.service.changeAudit.tableName, {
|
|
|
id: lastUser.id,
|
|
|
- status: audit.flow.auditStatus.checked,
|
|
|
+ status: audit.change.status.checked,
|
|
|
sin_time: new Date(),
|
|
|
});
|
|
|
}
|
|
@@ -649,7 +649,7 @@ module.exports = app => {
|
|
|
let uSort = parseInt(lastUser.usort) + 1;
|
|
|
for (const [index, ca] of changeAudit.entries()) {
|
|
|
const auditInfo = ca.split('/%/');
|
|
|
- const uStatus = change_status && index === 0 ? audit.flow.auditStatus.checking : audit.flow.auditStatus.uncheck;
|
|
|
+ const uStatus = change_status && index === 0 ? audit.change.status.checking : audit.change.status.uncheck;
|
|
|
const sin_time = change_status && index === 0 ? new Date() : null;
|
|
|
const caArray = {
|
|
|
tid: tenderId,
|
|
@@ -762,7 +762,7 @@ module.exports = app => {
|
|
|
if (change_status) {
|
|
|
cArray.tp_decimal = this.ctx.tender.info.decimal.tp;
|
|
|
cArray.up_decimal = this.ctx.tender.info.decimal.up;
|
|
|
- cArray.status = audit.flow.status.checking;
|
|
|
+ cArray.status = audit.change.status.checking;
|
|
|
cArray.cin_time = Date.parse(new Date()) / 1000;
|
|
|
}
|
|
|
await this.transaction.update(this.tableName, cArray, options);
|
|
@@ -1151,7 +1151,7 @@ module.exports = app => {
|
|
|
pid,
|
|
|
type: pushType.change,
|
|
|
uid: auditor.uid,
|
|
|
- status: audit.flow.status.backnew,
|
|
|
+ status: audit.change.status.checkNoPre,
|
|
|
content: noticeContent,
|
|
|
});
|
|
|
});
|
|
@@ -1412,7 +1412,7 @@ module.exports = app => {
|
|
|
' ) As scb ON cb.id = scb.cbid' +
|
|
|
' WHERE c.tid = ? And c.status = ? And c.valid And ' + filter +
|
|
|
' ORDER BY c.in_time';
|
|
|
- const sqlParam = [tender.id, stage.order, tender.id, audit.flow.status.checked];
|
|
|
+ const sqlParam = [tender.id, stage.order, tender.id, audit.change.status.checked];
|
|
|
let changes = await this.db.query(sql, sqlParam);
|
|
|
if (noValue) {
|
|
|
if (data.noValue) {
|
|
@@ -1504,7 +1504,7 @@ module.exports = app => {
|
|
|
' ORDER By in_time';
|
|
|
// 舍入步长
|
|
|
const step = parseFloat('0.' + '0000000'.substr(0, this.ctx.tender.info.decimal.tp) + '5');
|
|
|
- const sqlParam = [step, this.ctx.tender.info.decimal.tp, step, this.ctx.tender.info.decimal.tp, tid, tid, audit.flow.status.checked];
|
|
|
+ const sqlParam = [step, this.ctx.tender.info.decimal.tp, step, this.ctx.tender.info.decimal.tp, tid, tid, audit.change.status.checked];
|
|
|
const data = await this.db.query(sql, sqlParam);
|
|
|
return data;
|
|
|
}
|
|
@@ -1569,7 +1569,7 @@ module.exports = app => {
|
|
|
pid,
|
|
|
type: pushType.change,
|
|
|
uid: auditor.uid,
|
|
|
- status: audit.flow.status.revise,
|
|
|
+ status: audit.change.status.revise,
|
|
|
content: noticeContent,
|
|
|
});
|
|
|
});
|
|
@@ -1853,14 +1853,14 @@ module.exports = app => {
|
|
|
*/
|
|
|
async isRepeat(cid, code, tid) {
|
|
|
const sql = 'SELECT COUNT(*) as count FROM ?? WHERE ((`code` = ? AND `status` != ?) OR (`p_code` = ? AND `status` = ?)) AND `cid` != ? AND `tid` = ?';
|
|
|
- const sqlParam = [this.tableName, code, audit.flow.status.checked, code, audit.flow.status.checked, cid, tid];
|
|
|
+ const sqlParam = [this.tableName, code, audit.change.status.checked, code, audit.change.status.checked, cid, tid];
|
|
|
const result = await this.db.queryOne(sql, sqlParam);
|
|
|
return result.count !== 0;
|
|
|
}
|
|
|
|
|
|
async getAllCheckedChanges(tid) {
|
|
|
return await this.getAllDataByCondition({
|
|
|
- where: { tid, status: audit.flow.status.checked },
|
|
|
+ where: { tid, status: audit.change.status.checked },
|
|
|
orders: [['in_time', 'desc']],
|
|
|
});
|
|
|
}
|
|
@@ -1959,7 +1959,7 @@ module.exports = app => {
|
|
|
async getListByBudgetInfo(tenders) {
|
|
|
if (tenders) {
|
|
|
const sql = 'SELECT * FROM ?? WHERE `status` = ? AND `tid` in (' + this.ctx.helper.getInArrStrSqlFilter(tenders.split(',')) + ') ORDER BY `total_price` DESC LIMIT 0, 10';
|
|
|
- const params = [this.tableName, audit.flow.status.checked];
|
|
|
+ const params = [this.tableName, audit.change.status.checked];
|
|
|
return await this.db.query(sql, params);
|
|
|
}
|
|
|
return [];
|
|
@@ -1968,7 +1968,7 @@ module.exports = app => {
|
|
|
async getTotalTpByBudgetInfo(tenders) {
|
|
|
if (tenders) {
|
|
|
const sql = 'SELECT SUM(`total_price`) AS tp FROM ?? WHERE `status` = ? AND `tid` in (' + this.ctx.helper.getInArrStrSqlFilter(tenders.split(',')) + ')';
|
|
|
- const sqlParam = [this.tableName, audit.flow.status.checked];
|
|
|
+ const sqlParam = [this.tableName, audit.change.status.checked];
|
|
|
const result = await this.db.queryOne(sql, sqlParam);
|
|
|
return result && result.tp ? result.tp : 0;
|
|
|
}
|