|
|
@@ -57,6 +57,42 @@ module.exports = app => {
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
+ async getAuditorsByStatus(qiId, status, times = 1) {
|
|
|
+ let auditor = [];
|
|
|
+ let sql = '';
|
|
|
+ let sqlParam = '';
|
|
|
+ let cur;
|
|
|
+ switch (status) {
|
|
|
+ case auditConst.status.checking :
|
|
|
+ case auditConst.status.checked :
|
|
|
+ case auditConst.status.checkNoPre :
|
|
|
+ case auditConst.status.rectification :
|
|
|
+ cur = await this.db.queryOne('SELECT * From ?? where qiid = ? AND times = ? AND status = ? ORDER By times DESC, `order` DESC', [this.tableName, qiId, times, status]);
|
|
|
+ if (!cur) return [];
|
|
|
+
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`qiid`, la.`order`, la.`status`, la.`audit_order`, la.`audit_type` ' +
|
|
|
+ ' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
+ ' WHERE la.`qiid` = ? and la.`order` = ? and times = ?';
|
|
|
+ sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, qiId, cur.order, times];
|
|
|
+ auditor = await this.db.query(sql, sqlParam);
|
|
|
+ break;
|
|
|
+ case auditConst.status.checkNo :
|
|
|
+ cur = await this.db.queryOne('SELECT * From ?? where qiid = ? AND times = ? AND status = ? ORDER By times DESC, `order` DESC', [this.tableName, qiId, parseInt(times) - 1, status]);
|
|
|
+ if (!cur) return [];
|
|
|
+
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`qiid`, la.`order`, la.`status`, la.`audit_order`, la.`audit_type` ' +
|
|
|
+ ' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
+ ' WHERE la.`qiid` = ? and la.`order` = ? and la.`times` = ?';
|
|
|
+ sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, qiId, cur.order, parseInt(times) - 1];
|
|
|
+ auditor = await this.db.query(sql, sqlParam);
|
|
|
+ break;
|
|
|
+ case auditConst.status.uncheck:
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return auditor;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取 最新审核顺序
|
|
|
*
|
|
|
@@ -102,7 +138,7 @@ module.exports = app => {
|
|
|
if (!addAid) {
|
|
|
const insert_members = [{
|
|
|
uid: auditorId,
|
|
|
- inspection: ['1'],
|
|
|
+ safe_inspection: ['1'],
|
|
|
}];
|
|
|
await this.ctx.service.tenderPermission.saveOnePermission(this.ctx.tender.id, [auditorId], insert_members, ['safe_inspection'], transaction);
|
|
|
}
|
|
|
@@ -684,9 +720,9 @@ module.exports = app => {
|
|
|
if (!addAid) {
|
|
|
const insert_members = [{
|
|
|
uid: checkData.rectification_uid,
|
|
|
- inspection: ['1'],
|
|
|
+ safe_inspection: ['1'],
|
|
|
}];
|
|
|
- await this.ctx.service.tenderPermission.saveOnePermission(inspection.tid, [checkData.rectification_uid], insert_members, ['inspection'], transaction);
|
|
|
+ await this.ctx.service.tenderPermission.saveOnePermission(inspection.tid, [checkData.rectification_uid], insert_members, ['safe_inspection'], transaction);
|
|
|
}
|
|
|
await transaction.update(this.ctx.service.safeInspection.tableName, {
|
|
|
id: inspection.id, status: auditConst.status.rectification, rectification_uid: checkData.rectification_uid,
|