Commit 22c80d0c by 任晓松

需求统计

parent 438a9472
...@@ -45,6 +45,12 @@ class IcAPI extends APIBase { ...@@ -45,6 +45,12 @@ class IcAPI extends APIBase {
case "getStatisticsByUappId": case "getStatisticsByUappId":
opResult = await this.opNeedInfoSve.getStatisticsByUappId(pobj); opResult = await this.opNeedInfoSve.getStatisticsByUappId(pobj);
break; break;
case "getStatisticsByProduct":
opResult = await this.opNeedInfoSve.getStatisticsByProduct(pobj);
break;
case "getNeedFunnelStatistics":
opResult = await this.opNeedInfoSve.getNeedFunnelStatistics(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -167,6 +167,63 @@ class NeedinfoService extends ServiceBase { ...@@ -167,6 +167,63 @@ class NeedinfoService extends ServiceBase {
let result = await this.customQuery(sql,whereParam); let result = await this.customQuery(sql,whereParam);
return system.getResultSuccess(result); return system.getResultSuccess(result);
} }
/**
* 需求统计漏斗图
* @param pobj
* @returns {Promise<void>}
*/
async getNeedFunnelStatistics(pobj){
let ac = pobj.actionBody;
let sql = `select count(*) count from n_need_info where deleted_at is null `;
let sql2 = `select count(DISTINCT(a.needNo)) count from n_need_solution a left join n_need_info b on a.needNo = b.needNo where a.deleted_at is null`;
let whereParams = {};
if (ac.start&&ac.end){
sql += ` AND created_at >= :start and created_at <= :end`;
sql2 += ` AND b.created_at >= :start and b.created_at <= :end`;
whereParams.start = ac.start;
whereParams.end = ac.end;
}
if(ac.uapp_id){
sql += ` and uapp_id = :uapp_id`;
sql2 += ` and b.uapp_id = :uapp_id`;
whereParams.uapp_id = ac.uapp_id;
}
if(ac.type_code){
sql += ` and typeCode = :type_code`;
sql2 += ` and b.typeCode = :type_code`;
whereParams.type_code = ac.type_code;
}
let total = await this.customQuery(sql,whereParams);
let middle = await this.customQuery(sql2,whereParams);
let sql3 = sql2 + ` and b.status = 'ycd'`
let finish = await this.customQuery(sql3,whereParams);
let result = {
total:total[0].count,
middle:middle[0].count,
finish:finish[0].count
}
return system.getResult(result);
}
/**
* 需求统计(产品维度)
* @param pobj
* @returns {Promise<void>}
*/
async getStatisticsByProduct(pobj){
let ac = pobj.actionBody;
let sql = `select typeCode,status,count(*) count from n_need_info where typeCode is not null `;
let whereParams = {};
if(ac.start&&ac.end){
sql += ` and created_at >= :start and created_at <= :end `;
whereParams.start = ac.start;
whereParams.end = ac.end;
}
sql += ` GROUP BY typeCode,status`;
let result = await this.customQuery(sql,whereParams);
return system.getResultSuccess(result);
}
} }
module.exports = NeedinfoService; module.exports = NeedinfoService;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment