|
@ -1159,4 +1159,91 @@ public class StatisticsService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计回复和未回复
|
|
|
* @param level
|
|
|
* @param code
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getConsultingStatistics(int level ,String code)throws Exception{
|
|
|
|
|
|
//获取总数
|
|
|
String sqlTotal = getConsultingStatisticsSQL(level,code,1);
|
|
|
//获取已经回复
|
|
|
String sqlReply = getConsultingStatisticsSQL(level,code,2);
|
|
|
//获取未回复
|
|
|
String sqlnoReply = getConsultingStatisticsSQL(level,code,3);
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
Long total = jdbcTemplate.queryForObject(sqlTotal,Long.class);
|
|
|
Long reply = jdbcTemplate.queryForObject(sqlReply,Long.class);
|
|
|
Long noReply = jdbcTemplate.queryForObject(sqlnoReply,Long.class);
|
|
|
|
|
|
if(total == null||total == 0){
|
|
|
result.put("total","0");
|
|
|
result.put("replyCount","0");
|
|
|
result.put("noReplyCount","0");
|
|
|
result.put("replyRatio","0.00%");
|
|
|
result.put("noReplyRatio","0.00%");
|
|
|
}else{
|
|
|
double rr = (double)reply/total*100;
|
|
|
double nrr = (double)noReply/total*100;
|
|
|
DecimalFormat df = new DecimalFormat("###.00");
|
|
|
|
|
|
result.put("total",total);
|
|
|
result.put("replyCount",reply);
|
|
|
result.put("noReplyCount",noReply);
|
|
|
if(reply==0){
|
|
|
result.put("replyRatio","0.00%");
|
|
|
}else{
|
|
|
result.put("replyRatio",df.format(rr)+"%");
|
|
|
}
|
|
|
if(noReply==0){
|
|
|
result.put("noReplyRatio","0.00%");
|
|
|
}else{
|
|
|
result.put("noReplyRatio",df.format(nrr)+"%");
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public String getConsultingStatisticsSQL(int level,String code,int type){
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT count(1) " +
|
|
|
"FROM ichat.topics t,ichat.participants p," +
|
|
|
"(SELECT d1. CODE FROM " +
|
|
|
" wlyy_admin_team t1," +
|
|
|
" wlyy_admin_team_member m1," +
|
|
|
" wlyy_doctor d1 " +
|
|
|
" WHERE t1.id = m1.team_id AND d1.CODE = m1.doctor_code ");
|
|
|
if (level == 4) {
|
|
|
// 市级别
|
|
|
sql.append(" AND d1.city = "+code);
|
|
|
} else if (level == 3) {
|
|
|
// 区、城镇级别
|
|
|
sql.append(" AND d1.town = "+code);
|
|
|
} else if (level == 2) {
|
|
|
// 机构级别
|
|
|
sql.append(" AND d1.hospital = "+code);
|
|
|
} else if (level == 1) {
|
|
|
// 机构团队级别
|
|
|
sql.append(" AND t1.id = "+code);
|
|
|
}
|
|
|
sql.append(" GROUP BY T1.`name`,d1. CODE) dt " +
|
|
|
"WHERE p.participant_id = dt.`CODE` AND p.session_id = t.session_id " +
|
|
|
"AND t.create_time >= DATE_SUB(NOW(),INTERVAL -1 DAY) ");
|
|
|
|
|
|
if(type == 1){
|
|
|
//计算总数
|
|
|
}else if(type == 2){
|
|
|
//计算及时回复
|
|
|
sql.append(" AND t.reply = 1 ");
|
|
|
}else if(type == 3 ){
|
|
|
//计算未回复
|
|
|
sql.append(" AND t.reply = 0 ");
|
|
|
}
|
|
|
return sql.toString();
|
|
|
}
|
|
|
}
|