| 
					
				 | 
			
			
				@ -14,6 +14,7 @@ import com.yihu.wlyy.service.BaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.team.AdminTeamService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.MapListUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.SystemConf; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2206,4 +2207,645 @@ public class StatisticsService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取团队月或周咨询未回复和总数折线图 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param teamCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param startDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param endDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type 0周,1月 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getTeamConsultCount(String teamCode,String startDate,String endDate,String type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String imDataBaseName = SystemConf.getInstance().getImDataBaseName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("0".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //按周统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " left(a.czrq,10) AS dateNo,count(1) AS noRely " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code ="+teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t. STATUS <> 10 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.`reply` = 0 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY left(a.czrq,10)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " left(a.czrq,10) AS dateNo,count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code ="+teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY left(a.czrq,10)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //按月统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ) AS weekOfMonth, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "  COUNT(1) AS noRely" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t. STATUS <> 10 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.`reply` = 0 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%m %v')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ) AS weekOfMonth, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "  COUNT(1) AS total" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%m %v')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> noReyList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("noReyList",noReyList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("totalList",totalList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *  计算团队医生月或周咨询未回复和总数折线图 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param teamCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param startDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param endDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctor 医生code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getTeamDocotorConsultCount(String teamCode,String startDate,String endDate,String type,String doctor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String imDataBaseName = SystemConf.getInstance().getImDataBaseName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("0".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //按周统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " left(a.czrq,10) AS dateNo,count(1) AS noRely " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code ="+teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t. STATUS <> 10 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.`reply` = 0 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND d.id = '"+doctor+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY left(a.czrq,10)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " left(a.czrq,10) AS dateNo,count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code ="+teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND d.id = '"+doctor+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY left(a.czrq,10)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //按月统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ) AS weekOfMonth, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "  COUNT(1) AS noRely" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t. STATUS <> 10 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.`reply` = 0 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND d.id = '"+doctor+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%m %v')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ) AS weekOfMonth, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "  COUNT(1) AS total" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_consult_team a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.czrq <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.czrq >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.consult IN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " t.id consultId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".topics t," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".participants p," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time <= '"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.create_time >= '"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND d.id = '"+doctor+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " DATE_FORMAT(a.czrq, '%m %v')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> noReyList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("noReyList",noReyList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("totalList",totalList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取团队咨询情况列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param teamCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param startDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param endDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param sort 0降序 1升续 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray getMemberConsultList(String teamCode,String startDate,String endDate,String sort){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String imDataBaseName = SystemConf.getInstance().getImDataBaseName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 未回复咨询总量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String onReySQL = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor_code AS doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.`name`, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " IFNULL(r.noRely,0) AS noRely " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_admin_team_member t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  count(1) AS noRely " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_consult_team a," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.id consultId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t. STATUS <> 10 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.`reply` = 0 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) c" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.consultId = a.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND a.admin_team_code = " +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) r ON r.doctorCode = t.doctor_code, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_doctor d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor_code = d.`code` " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.available = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.team_id = "+teamCode ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("0".equals(sort)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onReySQL = onReySQL+ " ORDER BY noRely DESC"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onReySQL = onReySQL+ " ORDER BY noRely ASC"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //总咨询量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor_code AS doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.`name`, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " IFNULL(r.total,0) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_admin_team_member t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy__team a, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.id consultId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " tp.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) c " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.consultId = a.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND a.admin_team_code = " +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ") r ON r.doctorCode = t.doctor_code, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_doctor d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor_code = d.`code` " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND t.available = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND t.team_id =  "+teamCode ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //结束咨询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endConsultSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor_code doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.`name`, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " IFNULL(r.endRey,0) AS endRey " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_admin_team_member t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  count(1) AS endRey " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  wlyy_consult_team a, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.id consultId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t. STATUS = 10 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) c " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.consultId = a.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ") r ON r.doctorCode = t.doctor_code, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_doctor d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor_code = d.`code` " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.available = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.team_id = "+teamCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> onReyList = jdbcTemplate.queryForList(onReySQL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> totalMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //将List转换为Map降低循环层级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(totalList!=null&&totalList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> list :totalList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String code = (String)list.get("doctorCode"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalMap.put(code,list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> endConsultList = jdbcTemplate.queryForList(endConsultSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //将List转换为Map降低循环层级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> endConsultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //将List转换为Map降低循环层级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(endConsultList!=null&&endConsultList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> list :endConsultList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String code = (String)list.get("doctorCode"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                endConsultMap.put(code,list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //合并结果集 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(onReyList!=null&&onReyList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> map :onReyList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String code = (String)map.get("doctorCode"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> t = ( Map<String,Object>)totalMap.get(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Long totalCout = (Long)t.get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("total",totalCout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> e =( Map<String,Object>)endConsultMap.get(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Long endCout = (Long)e.get("endRey"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("endRey",endCout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return new JSONArray(onReyList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getDoctorConsultTitle(String doctor,String teamCode,String startDate,String endDate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String imDataBaseName = SystemConf.getInstance().getImDataBaseName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取咨询总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String couTotalSQL = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_consult_team a, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.id consultId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND d.id='"+doctor+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) c " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.consultId = a.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND a.admin_team_code = " +teamCode + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //及时回复数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String reyTotalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_consult_team a, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.id consultId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND s.business_type=2  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.`reply`=1  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND TIMESTAMPDIFF(SECOND ,t.create_time ,t.reply_time) <86400 AND TIMESTAMPDIFF(SECOND ,t.create_time,t.reply_time) >0 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND d.id='"+doctor+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) c " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.consultId = a.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.doctorCode"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //本周或月增量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String addTotalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  wlyy_consult_team a, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.id consultId," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND s.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.create_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.create_time >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND d.id='"+doctor+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ) c " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.consultId = a.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.doctorCode"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //当前未回复咨询数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String noRelySql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.doctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  wlyy_consult_team a, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.id consultId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    d.id doctorCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    "+imDataBaseName+".sessions s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    p.participant_id = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.session_id = p.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.session_id = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND s.type = 1  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t. STATUS <> 10  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.`reply` = 0  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.create_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND t.create_time >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   AND d.id='"+doctor+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  ) c " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.consultId = a.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  AND a.admin_team_code =" +teamCode+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  c.doctorCode"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject rs = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long total =0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long relyOnTime =0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long addNumber = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long noRelyNumber =0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> couTotal = jdbcTemplate.queryForList(couTotalSQL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(couTotal!=null&&couTotal.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> couTotalMap = couTotal.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            total = (Long) couTotalMap.get("total")==null?0L:(Long) couTotalMap.get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("total",total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> reyTotal = jdbcTemplate.queryForList(reyTotalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(reyTotal!=null&&reyTotal.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> reyTotalMap = reyTotal.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            relyOnTime = (Long) reyTotalMap.get("total")==null?0L:(Long) reyTotalMap.get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(total!=0L&&relyOnTime!=0L){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            double rr = (double)relyOnTime/total*100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            double nrr = (double)relyOnTime/total*100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DecimalFormat df  = new DecimalFormat("###.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("relyOnTimeRate",df.format(nrr)+"%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("relyOnTimeRate","0.00%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> addTotal = jdbcTemplate.queryForList(addTotalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(addTotal!=null&&addTotal.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> addTotalMap = addTotal.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            addNumber = (Long) addTotalMap.get("total")==null?0L:(Long) addTotalMap.get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //本周或月增量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("addNumber",addNumber); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> noRelyTotal = jdbcTemplate.queryForList(noRelySql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(noRelyTotal!=null&&noRelyTotal.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> noRelyTotalMap = noRelyTotal.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            noRelyNumber = (Long) noRelyTotalMap.get("total")==null?0L:(Long) noRelyTotalMap.get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("noRelyNumber",noRelyNumber); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |