|
@ -1723,26 +1723,20 @@ public class StatisticsService extends BaseService {
|
|
|
|
|
|
/**
|
|
|
* 统计当前团队,签约人数,服务次数,平均满意度
|
|
|
* @param type 0.当前周;1.当前月
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getStatTitleInfo(String doctor,String type){
|
|
|
public JSONArray getStatTitleInfo(String doctor,String startDate,String endDate)throws Exception{
|
|
|
JSONArray rs = new JSONArray();
|
|
|
|
|
|
AdminTeam admin = adminTeamDao.findByLeaderCode(doctor);
|
|
|
Long id = admin.getId();
|
|
|
String startDate = "";
|
|
|
String endDate = "";
|
|
|
if(StringUtils.isNotBlank(type)){
|
|
|
//默认查周
|
|
|
if("0".equals(type)){
|
|
|
startDate = DateUtil.getMondayOfThisWeek()+" 00:00:00";
|
|
|
endDate = DateUtil.getSundayOfThisWeek()+" 23:59:59";
|
|
|
}else {
|
|
|
startDate = DateUtil.getFristDayOfMonth() +" 00:00:00";
|
|
|
endDate = DateUtil.getLastDayOfMonth()+" 23:59:59";
|
|
|
}
|
|
|
if(admin==null){
|
|
|
throw new RuntimeException("未找到团队信息");
|
|
|
}
|
|
|
Long id = admin.getId();
|
|
|
|
|
|
startDate = startDate+" 00:00:00";
|
|
|
endDate = endDate+" 23:59:59";
|
|
|
|
|
|
//1.统计签约数据
|
|
|
//查找团队签约
|
|
|
String sign_sql = "SELECT COUNT(1) signCount FROM wlyy_sign_family t WHERE t.admin_team_code ="+id+" AND t.czrq >='"+startDate+"' AND t.czrq<='"+endDate+"' AND t.status =1 AND t.expenses_status ='1'";
|
|
@ -1801,9 +1795,155 @@ public class StatisticsService extends BaseService {
|
|
|
|
|
|
return rs;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询签约
|
|
|
* @param type 0 按周,1 按月
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getSignCountLineByType(String doctor,String type,String startDate,String endDate){
|
|
|
|
|
|
AdminTeam admin = adminTeamDao.findByLeaderCode(doctor);
|
|
|
if(admin==null){
|
|
|
throw new RuntimeException("未找到团队信息");
|
|
|
}
|
|
|
Long id = admin.getId();
|
|
|
|
|
|
String sql;
|
|
|
//按周
|
|
|
if("0".equals(type)){
|
|
|
sql = "SELECT left(f.apply_date,10) as applyDate,count(1) as signCount " +
|
|
|
" FROM wlyy_sign_family f " +
|
|
|
" where f.apply_date >='"+startDate+" 00:00:00' " +
|
|
|
" AND f.apply_date<='"+endDate+" 00:00:00' " +
|
|
|
" AND f.status >0 " +
|
|
|
" AND f.expenses_status='1' " +
|
|
|
" AND f.admin_team_code="+id+
|
|
|
" GROUP BY left(f.apply_date,10)";
|
|
|
//按月
|
|
|
}else{
|
|
|
sql ="SELECT (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('2017-06-01','%v')+1) as weekOfMonth,count(1) as signCount " +
|
|
|
" FROM wlyy_sign_family f " +
|
|
|
" where f.apply_date >='"+startDate+" 00:00:00' " +
|
|
|
" AND f.apply_date<='"+endDate+" 00:00:00' " +
|
|
|
" AND f.status >0 " +
|
|
|
" AND f.expenses_status='1' " +
|
|
|
" AND f.admin_team_code="+id+
|
|
|
" GROUP BY DATE_FORMAT(f.apply_date,'%m %v')";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
JSONArray rsJs = new JSONArray(rs);
|
|
|
return rsJs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询续签约
|
|
|
* @param type 0 按周,1 按月
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getRenewCountLineByType(String doctor,String type,String startDate,String endDate){
|
|
|
|
|
|
AdminTeam admin = adminTeamDao.findByLeaderCode(doctor);
|
|
|
if(admin==null){
|
|
|
throw new RuntimeException("未找到团队信息");
|
|
|
}
|
|
|
Long id = admin.getId();
|
|
|
|
|
|
String sql;
|
|
|
//按周
|
|
|
if("0".equals(type)){
|
|
|
sql = "SELECT left(f.apply_date,10) as applyDate,count(1) as signCount " +
|
|
|
" FROM wlyy_sign_family_renew f " +
|
|
|
" where f.apply_date >='"+startDate+" 00:00:00' " +
|
|
|
" AND f.apply_date<='"+endDate+" 00:00:00' " +
|
|
|
" AND f.status >0 " +
|
|
|
" AND f.expenses_status='1' " +
|
|
|
" AND f.admin_team_code="+id+
|
|
|
" GROUP BY left(f.apply_date,10)";
|
|
|
//按月
|
|
|
}else{
|
|
|
sql ="SELECT (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('2017-06-01','%v')+1) as weekOfMonth,count(1) as signCount " +
|
|
|
" FROM wlyy_sign_family_renew f " +
|
|
|
" where f.apply_date >='"+startDate+" 00:00:00' " +
|
|
|
" AND f.apply_date<='"+endDate+" 00:00:00' " +
|
|
|
" AND f.status >0 " +
|
|
|
" AND f.expenses_status='1' " +
|
|
|
" AND f.admin_team_code="+id+
|
|
|
" GROUP BY DATE_FORMAT(f.apply_date,'%m %v')";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
JSONArray rsJs = new JSONArray(rs);
|
|
|
return rsJs;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONObject getReyStatbyTeam(String doctor,String startDate,String endDate,String isNow){
|
|
|
AdminTeam admin = adminTeamDao.findByLeaderCode(doctor);
|
|
|
if(admin==null){
|
|
|
throw new RuntimeException("未找到团队信息");
|
|
|
}
|
|
|
Long id = admin.getId();
|
|
|
//查找起始时间咨询未回复总数
|
|
|
String noRelysql = "SELECT q.result FROM wlyy_quota_result q " +
|
|
|
" WHERE q.quato_code ='22' " +
|
|
|
" AND q.level1_type ='1' " +
|
|
|
" AND q.quota_date ='"+startDate+"'" +
|
|
|
" AND q.qkdoctor_code ='"+id+"';";
|
|
|
//查找起始时间咨询总数
|
|
|
String totalsql = "SELECT q.result FROM wlyy_quota_result q " +
|
|
|
" WHERE q.quato_code ='25' " +
|
|
|
" AND q.level1_type ='1' " +
|
|
|
" AND q.quota_date ='"+startDate+"' " +
|
|
|
" AND q.qkdoctor_code ='"+id+"'";
|
|
|
|
|
|
Map<String,Object> noRelyMap = jdbcTemplate.queryForMap(noRelysql);
|
|
|
Map<String,Object> totalMap = jdbcTemplate.queryForMap(noRelysql);
|
|
|
|
|
|
Long noRelystartCount = Long.parseLong((String)noRelyMap.get("result"));
|
|
|
Long totalstartCount = Long.parseLong((String)totalMap.get("result"));
|
|
|
|
|
|
Long noRelyEndCount ;
|
|
|
Long totalEndCount ;
|
|
|
if("1".equals(isNow)){
|
|
|
String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
|
|
|
//当前时间获取未回复咨询总数
|
|
|
String noReyVal = redisTemplate.opsForValue().get("quota:22:1:"+id+":"+timeKey);
|
|
|
JSONObject nr = new JSONObject(noReyVal);
|
|
|
noRelyEndCount = nr.getLong("num");
|
|
|
//获取当前时间咨询总数
|
|
|
String totalVal = redisTemplate.opsForValue().get("quota:25:1:"+id+":"+timeKey);
|
|
|
JSONObject tr = new JSONObject(totalVal);
|
|
|
totalEndCount = tr.getLong("num");
|
|
|
}else{
|
|
|
//查找结束时间未回复总数
|
|
|
String noRelyEndsql = "SELECT q.result FROM wlyy_quota_result q " +
|
|
|
" WHERE q.quato_code ='22' " +
|
|
|
" AND q.level1_type ='1' " +
|
|
|
" AND q.quota_date ='"+endDate+"'" +
|
|
|
" AND q.qkdoctor_code ='"+id+"';";
|
|
|
//查找结束时间咨询总数
|
|
|
String totalEndsql = "SELECT q.result FROM wlyy_quota_result q " +
|
|
|
" WHERE q.quato_code ='25' " +
|
|
|
" AND q.level1_type ='1' " +
|
|
|
" AND q.quota_date ='"+startDate+"' " +
|
|
|
" AND q.qkdoctor_code ='"+id+"'";
|
|
|
Map<String,Object> noRelyEndMap = jdbcTemplate.queryForMap(noRelyEndsql);
|
|
|
Map<String,Object> totalEndMap = jdbcTemplate.queryForMap(totalEndsql);
|
|
|
|
|
|
noRelyEndCount = Long.parseLong((String)noRelyEndMap.get("result"));
|
|
|
totalEndCount = Long.parseLong((String)totalEndMap.get("result"));
|
|
|
}
|
|
|
|
|
|
JSONObject rs = new JSONObject();
|
|
|
rs.put("onReyCount",noRelyEndCount-noRelystartCount);
|
|
|
rs.put("totalCount",totalstartCount-totalEndCount);
|
|
|
return rs;
|
|
|
}
|
|
|
}
|