|
@@ -42,9 +42,8 @@ module.exports = app => {
|
|
|
async getAuditor(stageId, auditorId, 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` ' +
|
|
|
- 'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`sid` = ? and la.`aid` = ? and la.`times` = ?' +
|
|
|
- ' and la.`aid` = pa.`id`';
|
|
|
+ 'FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
|
|
|
+ 'WHERE la.`sid` = ? and la.`aid` = ? and la.`times` = ?';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditorId, times];
|
|
|
return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
@@ -117,11 +116,8 @@ module.exports = app => {
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
async getStatusName(stageId) {
|
|
|
- const sql =
|
|
|
- 'SELECT pa.`name` ' +
|
|
|
- 'FROM ?? AS sa, ?? AS pa ' +
|
|
|
- 'WHERE sa.`sid` = ?' +
|
|
|
- ' and sa.`aid` = pa.`id` and sa.`status` != ? ORDER BY sa.`times` DESC, sa.`order` DESC';
|
|
|
+ const sql = 'SELECT pa.`name` FROM ?? AS sa Left Join ?? AS pa On sa.`aid` = pa.`id`' +
|
|
|
+ ' WHERE sa.`sid` = ? and sa.`status` != ? ORDER BY sa.`times` DESC, sa.`order` DESC';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditConst.status.uncheck];
|
|
|
return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
@@ -136,9 +132,8 @@ 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` ' +
|
|
|
- 'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ?' +
|
|
|
- ' and la.`aid` = pa.`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];
|
|
|
return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
@@ -996,9 +991,11 @@ module.exports = app => {
|
|
|
'SELECT sa.`aid`, sa.`times`, sa.`order`, sa.`begin_time`, sa.`end_time`, sa.`tid`, sa.`sid`,' +
|
|
|
' s.`order` As `sorder`, s.`status` As `sstatus`,' +
|
|
|
' t.`name`, t.`project_id`, t.`type`, t.`user_id` ' +
|
|
|
- ' FROM ?? AS sa, ?? AS s, ?? As t ' +
|
|
|
+ ' FROM ?? AS sa ' +
|
|
|
+ ' Left Join ?? AS s On sa.`sid` = s.`id` ' +
|
|
|
+ ' Left Join ?? As t ON sa.`tid` = t.`id`' +
|
|
|
' WHERE ((sa.`aid` = ? and sa.`status` = ?) OR (s.`user_id` = ? and sa.`status` = ? and s.`status` = ? and sa.`times` = (s.`times`-1)))' +
|
|
|
- ' and sa.`sid` = s.`id` and sa.`tid` = t.`id` ORDER BY sa.`begin_time` DESC';
|
|
|
+ ' ORDER BY sa.`begin_time` DESC';
|
|
|
const sqlParam = [
|
|
|
this.tableName,
|
|
|
this.ctx.service.stage.tableName,
|
|
@@ -1020,20 +1017,6 @@ module.exports = app => {
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
async getNoticeStage(pid, uid, time) {
|
|
|
- // const sql = 'SELECT * FROM (SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
|
|
|
- // ' s.`order` As `s_order`, s.`status` As `s_status`, ' +
|
|
|
- // ' sa.`aid`, sa.`times`, sa.`order`, sa.`end_time`, sa.`tid`, sa.`sid`, sa.`status`, ' +
|
|
|
- // ' pa.`name` As `su_name`, pa.role As `su_role`, pa.company As `su_company`' +
|
|
|
- // ' FROM (SELECT * FROM ?? WHERE `user_id` = ? OR `id` in (SELECT `tid` FROM ?? WHERE `aid` = ? GROUP BY `tid`)) As t' +
|
|
|
- // ' LEFT JOIN ?? As s On t.`id` = s.`tid`' +
|
|
|
- // ' LEFT JOIN ?? As sa ON s.`id` = sa.`sid`' +
|
|
|
- // ' LEFT JOIN ?? As pa ON sa.`aid` = pa.`id`' +
|
|
|
- // ' WHERE sa.`end_time` > ? and t.`project_id` = ?' +
|
|
|
- // ' ORDER By sa.`end_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`tid`' +
|
|
|
- // ' ORDER By new_t.`end_time`';
|
|
|
- // const sqlParam = [this.ctx.service.tender.tableName, uid, this.tableName, uid, this.ctx.service.stage.tableName, this.tableName,
|
|
|
- // this.ctx.service.projectAccount.tableName, time, pid];
|
|
|
- // return await this.db.query(sql, sqlParam);
|
|
|
let notice = await this.db.select('zh_notice', {
|
|
|
where: { pid, type: pushType.stage, uid },
|
|
|
orders: [['create_time', 'desc']],
|
|
@@ -1077,13 +1060,10 @@ module.exports = app => {
|
|
|
async getAuditGroupByList(stageId, times) {
|
|
|
const sql =
|
|
|
'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`aid`, la.`order` ' +
|
|
|
- 'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`sid` = ? and la.`times` = ? and la.`aid` = pa.`id` GROUP BY la.`aid` ORDER BY la.`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];
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
- // const sql = 'SELECT `tid`, `sid`, `aid`, `order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid`';
|
|
|
- // const sqlParam = [this.tableName, stageId, times];
|
|
|
- // return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1096,12 +1076,8 @@ module.exports = app => {
|
|
|
const result = await this.getAuditGroupByList(stageId, times);
|
|
|
const sql =
|
|
|
'SELECT pa.`id` As aid, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As sid, 0 As `order`' +
|
|
|
- ' FROM ' +
|
|
|
- this.ctx.service.stage.tableName +
|
|
|
- ' As s' +
|
|
|
- ' LEFT JOIN ' +
|
|
|
- this.ctx.service.projectAccount.tableName +
|
|
|
- ' As pa' +
|
|
|
+ ' FROM ' + this.ctx.service.stage.tableName + ' As s' +
|
|
|
+ ' LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa' +
|
|
|
' ON s.user_id = pa.id' +
|
|
|
' WHERE s.id = ?';
|
|
|
const sqlParam = [times, stageId, stageId];
|
|
@@ -1152,18 +1128,16 @@ module.exports = app => {
|
|
|
case auditConst.status.checking:
|
|
|
case auditConst.status.checked:
|
|
|
case auditConst.status.checkNoPre:
|
|
|
- sql =
|
|
|
- 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order` ' +
|
|
|
- 'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`sid` = ? and la.`status` = ? and la.`aid` = pa.`id` order by la.`times` desc, la.`order` desc';
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order` ' +
|
|
|
+ ' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
+ ' WHERE la.`sid` = ? and la.`status` = ? order by la.`times` desc, la.`order` desc';
|
|
|
sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, status];
|
|
|
auditor = await this.db.queryOne(sql, sqlParam);
|
|
|
break;
|
|
|
case auditConst.status.checkNo:
|
|
|
- sql =
|
|
|
- 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order` ' +
|
|
|
- 'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ? and la.`aid` = pa.`id` order by la.`times` desc, la.`order` desc';
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order` ' +
|
|
|
+ ' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
+ ' WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ? order by la.`times` desc, la.`order` desc';
|
|
|
sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditConst.status.checkNo, parseInt(times) - 1];
|
|
|
auditor = await this.db.queryOne(sql, sqlParam);
|
|
|
break;
|
|
@@ -1201,9 +1175,11 @@ module.exports = app => {
|
|
|
' s.*,' +
|
|
|
' t.`name`, t.`project_id`, t.`type`, t.`user_id`,' +
|
|
|
' ti.`deal_info` ' +
|
|
|
- ' FROM ?? AS sa, ?? AS s, ?? As t, ?? AS ti ' +
|
|
|
- ' WHERE sa.`aid` = ? and sa.`status` = ?' +
|
|
|
- ' and sa.`sid` = s.`id` and sa.`tid` = t.`id` and ti.`tid` = t.`id`';
|
|
|
+ ' FROM ?? AS sa' +
|
|
|
+ ' Left Join ?? AS s On sa.`sid` = s.`id`' +
|
|
|
+ ' Left Join ?? As t On sa.`tid` = t.`id`' +
|
|
|
+ ' Left Join ?? AS ti ON ti.`tid` = t.`id`' +
|
|
|
+ ' WHERE sa.`aid` = ? and sa.`status` = ?';
|
|
|
const sqlParam = [
|
|
|
this.tableName,
|
|
|
this.ctx.service.stage.tableName,
|
|
@@ -1379,8 +1355,8 @@ 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`, Max(la.`order`) as max_order ' +
|
|
|
- 'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`sid` = ? and la.`times` = ? and la.`aid` = pa.`id` GROUP BY la.`aid` ORDER BY la.`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];
|
|
|
const result = await this.db.query(sql, sqlParam);
|
|
|
for (const r of result) {
|