|
@@ -79,7 +79,7 @@ module.exports = app => {
|
|
|
|
|
|
async getLastestAuditor(stageId, times, status) {
|
|
|
const sql =
|
|
|
- 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.audit_type, la.audit_order,' +
|
|
|
+ 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.audit_type, la.audit_order, la.audit_ledger_id,' +
|
|
|
' la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
|
' FROM ' + this.tableName + ' AS la' +
|
|
|
' Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`aid` = pa.`id`' +
|
|
@@ -91,7 +91,7 @@ module.exports = app => {
|
|
|
|
|
|
async getLastestAuditors(stageId, times, status) {
|
|
|
const sql =
|
|
|
- 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.audit_type, la.audit_order,' +
|
|
|
+ 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.audit_type, la.audit_order, la.audit_ledger_id,' +
|
|
|
' la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
|
' FROM ' + this.tableName + ' AS la' +
|
|
|
' Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`aid` = pa.`id`' +
|
|
@@ -112,7 +112,7 @@ module.exports = app => {
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
async getAuditors(stageId, times = 1, order_sort = 'asc') {
|
|
|
- const sql = 'SELECT la.id, la.aid, la.times, la.order, la.status, la.opinion, la.begin_time, la.end_time, la.audit_type, la.audit_order,' +
|
|
|
+ const sql = 'SELECT la.id, la.aid, la.times, la.order, la.status, la.opinion, la.begin_time, la.end_time, la.audit_type, la.audit_order, la.audit_ledger_id,' +
|
|
|
' pa.name, pa.company, pa.role, pa.mobile, pa.telephone, pa.sign_path' +
|
|
|
` FROM ${this.tableName} la LEFT JOIN ${this.ctx.service.projectAccount.tableName} pa ON la.aid = pa.id` +
|
|
|
' WHERE la.sid = ? AND la.times = ?' +
|
|
@@ -160,7 +160,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async getCurAuditor(stageId, times = 1) {
|
|
|
const sql =
|
|
|
- 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, la.audit_type, la.audit_order ' +
|
|
|
+ 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, la.audit_type, la.audit_order, la.audit_ledger_id ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
|
|
|
' WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ?';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditConst.status.checking, times];
|
|
@@ -169,7 +169,7 @@ module.exports = app => {
|
|
|
|
|
|
async getCurAuditors(stageId, times = 1) {
|
|
|
const sql =
|
|
|
- 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, la.audit_type, la.audit_order ' +
|
|
|
+ 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, la.audit_type, la.audit_order, la.audit_ledger_id ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
|
|
|
' WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ?';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditConst.status.checking, times];
|
|
@@ -653,7 +653,7 @@ module.exports = app => {
|
|
|
return {
|
|
|
aid: x.aid, tid: selfAudit.tid, sid: selfAudit.sid,
|
|
|
times: times + 1, order: x.audit_order, status: auditConst.status.uncheck,
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -862,6 +862,7 @@ module.exports = app => {
|
|
|
times: x.times, order: selfAudit.order + 1,
|
|
|
status: auditConst.status.checking, begin_time: time,
|
|
|
audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
// 获取ids值
|
|
@@ -877,6 +878,7 @@ module.exports = app => {
|
|
|
times: x.times, order: selfAudit.order + 2,
|
|
|
status: auditConst.status.uncheck,
|
|
|
audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
await transaction.insert(this.tableName, newFlowAuditors);
|
|
@@ -1018,7 +1020,7 @@ module.exports = app => {
|
|
|
times: x.times, order: x.order + 1,
|
|
|
status: !selfAudit || x.aid === selfAudit.aid ? auditConst.status.checkAgain : auditConst.status.checkSkip,
|
|
|
begin_time: time, end_time: time, opinion: '',
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
audits.forEach(x => {
|
|
@@ -1027,7 +1029,7 @@ module.exports = app => {
|
|
|
times: x.times, order: x.order + 2,
|
|
|
status: auditConst.status.checking,
|
|
|
begin_time: time, end_time: time, opinion: '',
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
await transaction.insert(this.tableName, checkAgainAuditors);
|
|
@@ -1239,7 +1241,7 @@ module.exports = app => {
|
|
|
times: x.times, order: x.order + 1,
|
|
|
status: x.aid === selfAuditor.aid ? auditConst.status.checkCancel : auditConst.status.checkSkip,
|
|
|
begin_time: time, end_time: time, opinion: '',
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
stage.preAuditors.forEach(x => {
|
|
@@ -1248,7 +1250,7 @@ module.exports = app => {
|
|
|
times: x.times, order: x.order + 2,
|
|
|
status: auditConst.status.checking,
|
|
|
begin_time: time, end_time: time, opinion: '',
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
await transaction.insert(this.tableName, [...checkCancelAuditors, ...checkingAuditors]);
|
|
@@ -1338,7 +1340,7 @@ module.exports = app => {
|
|
|
times: x.times, order: x.order + 1,
|
|
|
status: x.aid === selfAuditor.aid ? auditConst.status.checkCancel : auditConst.status.checkSkip,
|
|
|
begin_time: time, end_time: time, opinion: '',
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
await transaction.insert(this.tableName, newAuditors);
|
|
@@ -1429,7 +1431,7 @@ module.exports = app => {
|
|
|
times: x.times, order: x.order + 1,
|
|
|
status: x.aid === selfAuditor.aid ? auditConst.status.checkCancel : auditConst.status.checkSkip,
|
|
|
begin_time: time, end_time: time, opinion: '',
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
stage.preAuditors.forEach(x => {
|
|
@@ -1438,7 +1440,7 @@ module.exports = app => {
|
|
|
times: x.times, order: x.order + 2,
|
|
|
status: auditConst.status.checking,
|
|
|
begin_time: time, end_time: time, opinion: '',
|
|
|
- audit_type: x.audit_type, audit_order: x.audit_order,
|
|
|
+ audit_type: x.audit_type, audit_order: x.audit_order, audit_ledger_id: x.audit_ledger_id,
|
|
|
});
|
|
|
});
|
|
|
await transaction.insert(this.tableName, [...checkCancelAuditors, ...checkingAuditors]);
|
|
@@ -1675,7 +1677,7 @@ module.exports = app => {
|
|
|
// ' WHERE la.`sid` = ? and la.`times` = ? and la.`is_old` = 0 GROUP BY la.`aid` ORDER BY la.`order`';
|
|
|
// const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, times];
|
|
|
const sql =
|
|
|
- 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.`status`, la.audit_type, la.audit_order' +
|
|
|
+ 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.`status`, la.audit_type, la.audit_order, la.audit_ledger_id' +
|
|
|
' FROM (SELECT `aid`, max(`order`) `order` FROM ?? WHERE `sid` = ? and `times` = ? and `is_old` = ? GROUP BY aid) sa' +
|
|
|
' LEFT JOIN ?? la ON sa.`aid` = la.`aid` AND sa.`order` = la.`order`' +
|
|
|
' Left JOIN ?? AS pa On la.`aid` = pa.`id` WHERE la.`sid` = ? and la.`times` = ? and la.`is_old` = ? order BY la.`order`';
|
|
@@ -1724,6 +1726,7 @@ module.exports = app => {
|
|
|
status: auditConst.status.uncheck,
|
|
|
audit_type: a.audit_type,
|
|
|
audit_order: a.audit_order,
|
|
|
+ audit_ledger_id: x.audit_ledger_id,
|
|
|
};
|
|
|
newAuditors.push(na);
|
|
|
}
|
|
@@ -1783,7 +1786,7 @@ module.exports = app => {
|
|
|
cur = await this.db.queryOne(`SELECT * From ${this.tableName} where sid = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`order` DESC', [stageId, times, status]);
|
|
|
if (!cur) return [];
|
|
|
|
|
|
- sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.audit_order, la.audit_type ' +
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.audit_order, la.audit_type, la.audit_ledger_id ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
' WHERE la.`sid` = ? and la.`order` = ? and times = ?';
|
|
|
sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, cur.order, times];
|
|
@@ -1793,7 +1796,7 @@ module.exports = app => {
|
|
|
cur = await this.db.queryOne(`SELECT * From ${this.tableName} where sid = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`order` DESC', [stageId, parseInt(times) - 1, status]);
|
|
|
if (!cur) return [];
|
|
|
|
|
|
- sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.audit_order, la.audit_type ' +
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.audit_order, la.audit_type, la.audit_ledger_id ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
' WHERE la.`sid` = ? and la.`order` = ? and la.`times` = ?';
|
|
|
sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, cur.order, parseInt(times) - 1];
|
|
@@ -1895,7 +1898,7 @@ module.exports = app => {
|
|
|
await this._timesDelete(this.ctx.stage.id, nowTimes, transaction);
|
|
|
}
|
|
|
// 添加上一次审批人
|
|
|
- const sql = 'SELECT `tid`, `sid`, `aid`, `order`, `audit_type`, `audit_order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
|
|
|
+ const sql = 'SELECT `tid`, `sid`, `aid`, `order`, `audit_type`, `audit_order`, `audit_ledger_id` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
|
|
|
const sqlParam = [this.tableName, this.ctx.stage.id, nowTimes - 1];
|
|
|
const auditors = await this.db.query(sql, sqlParam);
|
|
|
let order = 1;
|
|
@@ -1976,7 +1979,8 @@ module.exports = app => {
|
|
|
newAuditors.push({
|
|
|
tid: stage.tid, sid: stage.id, aid: auditor.audit_id,
|
|
|
times: stage.times, order: auditor.audit_order, status: auditConst.status.uncheck,
|
|
|
- audit_type: auditor.audit_type, audit_order: auditor.audit_order, audit_ledger_id: auditor.audit_ledger_id,
|
|
|
+ audit_type: auditor.audit_type, audit_order: auditor.audit_order,
|
|
|
+ audit_ledger_id: auditor.audit_type === auditType.key.union ? auditor.audit_ledger_id : '',
|
|
|
});
|
|
|
}
|
|
|
if(newAuditors.length > 0) await transaction.insert(this.tableName, newAuditors);
|
|
@@ -2026,7 +2030,7 @@ module.exports = app => {
|
|
|
async getFinalAuditGroup(stageId, times) {
|
|
|
const sql =
|
|
|
'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`,' +
|
|
|
- ' la.`times`, la.`sid`, la.`audit_order`, la.`audit_type`, Max(la.`order`) as max_order ' +
|
|
|
+ ' la.`times`, la.`sid`, la.`audit_order`, la.`audit_type`, la.`audit_ledger_id`, Max(la.`order`) as max_order ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
|
|
|
' WHERE la.`sid` = ? and la.`times` = ? GROUP BY la.`aid` ORDER BY la.`order`';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, times];
|
|
@@ -2246,6 +2250,18 @@ module.exports = app => {
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ async cancelLock(stage, uid, transaction) {
|
|
|
+ if (transaction) {
|
|
|
+ await transaction.update(this.tableName, { locked: 0 }, { where: { sid: stage.id, times: stage.times, aid: uid } });
|
|
|
+ } else {
|
|
|
+ await this.db.update(this.tableName, { locked: 0 }, { where: { sid: stage.id, times: stage.times, aid: uid } });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async getLockedId(stage) {
|
|
|
+ return await this.getAllDataByCondition({ where: { sid: stage.id, times: stage.times, audit_locked: 1 } });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return StageAudit;
|