trick9191 8 年之前
父节点
当前提交
8c829a1b58

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -1110,7 +1110,7 @@ public class FamilyMemberService extends BaseService {
        String result = HttpUtil.sendGet(userInfo_url, params);
        String result = HttpUtil.sendGet(userInfo_url, params);
        JSONObject json = new JSONObject(result);
        JSONObject json = new JSONObject(result);
        if (json.has("subscribe")) {
        if (json.has("subscribe")) {
            return json.get(" ").toString();
            return json.get("subscribe").toString();
        } else {
        } else {
            return null;
            return null;
        }
        }

+ 74 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -3415,4 +3415,78 @@ public class FamilyContractService extends BaseService {
    public SignFamily findOutTimeSigningByPatient(String patient) {
    public SignFamily findOutTimeSigningByPatient(String patient) {
        return signFamilyDao.findOutTimeSigningByPatient(patient);
        return signFamilyDao.findOutTimeSigningByPatient(patient);
    }
    }
    public JSONObject getServerPatientList(Long teamCode){
        String serverSql="SELECT " +
                " d.`code` As labelCode, " +
                " d.`name` AS label " +
                " FROM " +
                " wlyy_sign_dict d " +
                " WHERE " +
                " d.type IN ('1', '2') " +
                " AND d. YEAR = '"+DateUtil.getSignYear()+"' " +
                " AND d.`code` NOT IN ( " +
                " SELECT " +
                "  LEFT ( " +
                "   d. CODE, " +
                "   (INSTR(d. CODE, '-') - 1) " +
                "  ) AS CODE " +
                " FROM " +
                "  wlyy_sign_dict d " +
                " WHERE " +
                "  d. CODE LIKE '%-%' " +
                " GROUP BY " +
                "  CODE " +
                ")";
        String patientSql =" SELECT " +
                " s.patient, " +
                " s.server_type AS serverType, " +
                " s.special_population AS specialPopulation, " +
                " s.sign_year " +
                " FROM " +
                " wlyy_sign_family s " +
                " WHERE " +
                " s.`status` >= 0 " +
                " AND s.server_type IS NOT NULL "+
                " AND s.admin_team_code =" +teamCode+
                " AND s.doctor_health IS NULL";
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(patientSql);
        List<Map<String,Object>> serlist = jdbcTemplate.queryForList(serverSql);
        if(serlist!=null&&serlist.size()>0){
            if(patientList!=null){
                for(Map<String,Object> map :serlist){
                    String labelCode = (String)map.get("labelCode");
                    List<Map<String,String>> codes = new ArrayList<>();
                    Iterator iterator = patientList.iterator();
                    while(iterator.hasNext()){
                        Map<String,Object> p =  ( Map<String,Object>)iterator.next();
                        String serverType = ((String)p.get("serverType"))==null?"":((String)p.get("serverType"));
                        if(labelCode.indexOf("-")==-1){
                            if(labelCode.equals(serverType)){
                                Map<String,String> code = new HashMap<>();
                                code.put("code",serverType);
                                codes.add(code);
                                iterator.remove();
                            }
                        }else{
                            String[] key = labelCode.split("-");
                            if(key[0].equals(serverType)){
                                Map<String,String> code = new HashMap<>();
                                code.put("code",serverType);
                                codes.add(code);
                                iterator.remove();
                            }
                        }
                    }
                    map.put("codes",codes);
                    map.put("number",(codes!=null&&codes.size()>0)?codes.size():0);
                }
            }
        }
        JSONObject rs = new JSONObject();
        rs.put("patients",serlist);
        rs.put("count",(patientList!=null&&patientList.size()>0)?patientList.size():0);
        return rs;
    }
}
}

+ 1013 - 38
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -1816,7 +1816,7 @@ public class StatisticsService extends BaseService {
                   " GROUP BY left(f.apply_date,10)";
                   " GROUP BY left(f.apply_date,10)";
        //按月
        //按月
        }else{
        }else{
            sql ="SELECT (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('2017-06-01','%v')+1) as weekOfMonth,count(1) as signCount " +
            sql ="SELECT (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"','%v')+1) as weekOfMonth,count(1) as signCount " +
                    " FROM wlyy_sign_family f " +
                    " FROM wlyy_sign_family f " +
                    " where f.apply_date >='"+startDate+" 00:00:00' " +
                    " where f.apply_date >='"+startDate+" 00:00:00' " +
                    " AND f.apply_date<='"+endDate+" 00:00:00' " +
                    " AND f.apply_date<='"+endDate+" 00:00:00' " +
@ -1894,14 +1894,21 @@ public class StatisticsService extends BaseService {
                " AND q.quota_date ='"+startDate+"' " +
                " AND q.quota_date ='"+startDate+"' " +
                " AND q.qkdoctor_code ='"+id+"'";
                " 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"));
        List<Map<String,Object>> noRelyList = jdbcTemplate.queryForList(noRelysql);
        Long noRelystartCount =0L;
        Long totalstartCount = 0L;
        if(noRelyList!=null&&noRelyList.size()>0){
            Map<String,Object> noRelyMap =noRelyList.get(0);
            noRelystartCount = Long.parseLong((String)noRelyMap.get("result"));
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalsql);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> totalMap =totalList.get(0);
            totalstartCount = Long.parseLong((String)totalMap.get("result"));
        }
        Long noRelyEndCount ;
        Long totalEndCount ;
        Long noRelyEndCount =0L;
        Long totalEndCount =0L;
        if("1".equals(isNow)){
        if("1".equals(isNow)){
            String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
            String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
            //当前时间获取未回复咨询总数
            //当前时间获取未回复咨询总数
@ -1931,11 +1938,16 @@ public class StatisticsService extends BaseService {
                    " AND q.level1_type ='1' " +
                    " AND q.level1_type ='1' " +
                    " AND q.quota_date ='"+startDate+"' " +
                    " AND q.quota_date ='"+startDate+"' " +
                    " AND q.qkdoctor_code ='"+id+"'";
                    " 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"));
            List<Map<String,Object>> noRelyEndList = jdbcTemplate.queryForList(noRelyEndsql);
            if(noRelyEndList!=null&&noRelyEndList.size()>0){
                Map<String,Object> noRelyEndMap = noRelyEndList.get(0);
                noRelyEndCount = Long.parseLong((String)noRelyEndMap.get("result"));
            }
            List<Map<String,Object>> totalEndList = jdbcTemplate.queryForList(totalEndsql);
            if(totalEndList!=null&&totalEndList.size()>0){
                Map<String,Object> totalEndMap = totalEndList.get(0);
                totalEndCount = Long.parseLong((String)totalEndMap.get("result"));
            }
        }
        }
        JSONObject rs = new JSONObject();
        JSONObject rs = new JSONObject();
@ -2200,12 +2212,12 @@ public class StatisticsService extends BaseService {
        return js;
        return js;
    }
    }
    public int checkDoctorIsTeamleader(String doctor){
    public JSONObject checkDoctorIsTeamleader(String doctor){
        AdminTeam team = adminTeamDao.findByLeaderCode(doctor);
        AdminTeam team = adminTeamDao.findByLeaderCode(doctor);
        if(team!=null){
        if(team!=null){
            return 1;
            return new JSONObject(team);
        }
        }
        return 0;
        return null;
    }
    }
    /**
    /**
@ -2503,7 +2515,7 @@ public class StatisticsService extends BaseService {
     * @param sort 0降序 1升续
     * @param sort 0降序 1升续
     * @return
     * @return
     */
     */
    public JSONArray getMemberConsultList(String teamCode,String startDate,String endDate,String sort){
    public JSONArray getMemberConsultList(String teamCode,String startDate,String endDate,String sort,String sortType){
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        startDate = startDate+" 00:00:00";
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        endDate = endDate+" 23:59:59";
@ -2597,6 +2609,11 @@ public class StatisticsService extends BaseService {
                " t.doctor_code = d.`code` " +
                " t.doctor_code = d.`code` " +
                "AND t.available = 1 " +
                "AND t.available = 1 " +
                "AND t.team_id =  "+teamCode ;
                "AND t.team_id =  "+teamCode ;
        if("0".equals(sort)){
            totalSql = totalSql+ " ORDER BY total DESC";
        }else{
            totalSql = totalSql+ " ORDER BY total ASC";
        }
        //结束咨询
        //结束咨询
        String endConsultSql ="SELECT " +
        String endConsultSql ="SELECT " +
@ -2640,9 +2657,21 @@ public class StatisticsService extends BaseService {
                " t.doctor_code = d.`code` " +
                " t.doctor_code = d.`code` " +
                " AND t.available = 1 " +
                " AND t.available = 1 " +
                " AND t.team_id = "+teamCode;
                " AND t.team_id = "+teamCode;
        if("0".equals(sort)){
            endConsultSql = endConsultSql+ " ORDER BY endRey DESC";
        }else{
            endConsultSql = endConsultSql+ " ORDER BY endRey ASC";
        }
        List<Map<String,Object>> onReyList = jdbcTemplate.queryForList(onReySQL);
        List<Map<String,Object>> onReyList = jdbcTemplate.queryForList(onReySQL);
        Map<String,Object> onReyMap = new HashMap<>();
        //将List转换为Map降低循环层级
        if(onReyList!=null&&onReyList.size()>0){
            for(Map<String,Object> list :onReyList){
                String code = (String)list.get("doctorCode");
                onReyMap.put(code,list);
            }
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        Map<String,Object> totalMap = new HashMap<>();
@ -2664,23 +2693,58 @@ public class StatisticsService extends BaseService {
                endConsultMap.put(code,list);
                endConsultMap.put(code,list);
            }
            }
        }
        }
        if("0".equals(sortType)){
            //未回复数
            //合并结果集
            if(onReyList!=null&&onReyList.size()>0){
                for(Map<String,Object> map :onReyList){
                    String code = (String)map.get("doctorCode");
        //合并结果集
        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);
        }else if("1".equals(sortType)){
            //总数
            //合并结果集
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map :totalList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> t = ( Map<String,Object>)onReyMap.get(code);
                    Long noRely = (Long)t.get("noRely");
                    map.put("noRely",noRely);
                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(totalList);
        }else{
            //结束咨询数
            //合并结果集
            if(endConsultList!=null&&endConsultList.size()>0){
                for(Map<String,Object> map :endConsultList){
                    String code = (String)map.get("doctorCode");
                Map<String,Object> e =( Map<String,Object>)endConsultMap.get(code);
                Long endCout = (Long)e.get("endRey");
                map.put("endRey",endCout);
                    Map<String,Object> t = ( Map<String,Object>)totalMap.get(code);
                    Long totalCout = (Long)t.get("total");
                    map.put("total",totalCout);
                    Map<String,Object> r = ( Map<String,Object>)onReyMap.get(code);
                    Long noRely = (Long)r.get("noRely");
                    map.put("noRely",noRely);
                }
            }
            }
            return new JSONArray(endConsultList);
        }
        }
        return new JSONArray(onReyList);
    }
    }
    public JSONObject getDoctorConsultTitle(String doctor,String teamCode,String startDate,String endDate){
    public JSONObject getDoctorConsultTitle(String doctor,String teamCode,String startDate,String endDate){
@ -2870,7 +2934,7 @@ public class StatisticsService extends BaseService {
            planSQL ="SELECT " +
            planSQL ="SELECT " +
                    " ( " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS planCount " +
                    " ) AS weekOfMonth,COUNT(1) AS planCount " +
                    "FROM " +
                    "FROM " +
                    " wlyy_followup w " +
                    " wlyy_followup w " +
@ -2886,7 +2950,7 @@ public class StatisticsService extends BaseService {
            //按月
            //按月
            totalSQL ="SELECT " +
            totalSQL ="SELECT " +
                    " ( " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " FROM " +
                    " wlyy_followup w " +
                    " wlyy_followup w " +
@ -2899,7 +2963,7 @@ public class StatisticsService extends BaseService {
                    " GROUP BY weekOfMonth";
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
            planSQL = "SELECT " +
                    " ( " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " FROM " +
                    " wlyy_followup w " +
                    " wlyy_followup w " +
@ -2940,7 +3004,7 @@ public class StatisticsService extends BaseService {
            planSQL ="SELECT " +
            planSQL ="SELECT " +
                    " ( " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS planCount " +
                    " ) AS weekOfMonth,COUNT(1) AS planCount " +
                    "FROM " +
                    "FROM " +
                    " wlyy_followup w " +
                    " wlyy_followup w " +
@ -2955,7 +3019,7 @@ public class StatisticsService extends BaseService {
            //按月
            //按月
            totalSQL ="SELECT " +
            totalSQL ="SELECT " +
                    " ( " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " FROM " +
                    " wlyy_followup w " +
                    " wlyy_followup w " +
@ -2967,7 +3031,7 @@ public class StatisticsService extends BaseService {
                    " GROUP BY weekOfMonth";
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
            planSQL = "SELECT " +
                    " ( " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " FROM " +
                    " wlyy_followup w " +
                    " wlyy_followup w " +
@ -3005,7 +3069,6 @@ public class StatisticsService extends BaseService {
                "  wlyy_followup w " +
                "  wlyy_followup w " +
                " WHERE " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " w.admin_team_code =" +teamCode+
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                " GROUP BY " +
@ -3021,6 +3084,918 @@ public class StatisticsService extends BaseService {
        }else{
        }else{
            totalSQL =totalSQL+" ORDER BY followupCount ASC";
            totalSQL =totalSQL+" ORDER BY followupCount ASC";
        }
        }
        return null;
        String addSQL = "SELECT " +
                " IFNULL(c.followupCount,0) AS addCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  w.doctor_code, " +
                "  w.doctor_name, " +
                "  COUNT(1) AS followupCount " +
                " FROM " +
                "  wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =" +teamCode ;
        if("0".equals(sort)){
            addSQL =addSQL+" ORDER BY addCount DESC";
        }else{
            addSQL =addSQL+" ORDER BY addCount ASC";
        }
        String planSQL = "SELECT " +
                " IFNULL(c.followupCount,0) AS planCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  w.doctor_code, " +
                "  w.doctor_name, " +
                "  COUNT(1) AS followupCount " +
                " FROM " +
                "  wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.status ='2'"+
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =" +teamCode ;
        if("0".equals(sort)){
            planSQL =planSQL+" ORDER BY planCount DESC";
        }else{
            planSQL =planSQL+" ORDER BY planCount ASC";
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSQL);
        //降低循环层级
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map:totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList= jdbcTemplate.queryForList(addSQL);
        //降低循环层级
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map:addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        List<Map<String,Object>> planList = jdbcTemplate.queryForList(planSQL);
        //降低循环层级
        Map<String,Object> planMap = new HashMap<>();
        if(planList!=null&&planList.size()>0){
            for(Map<String,Object> map:planList){
                String code = (String)map.get("doctorCode");
                planMap.put(code,map);
            }
        }
        if("0".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                //以总数为基准,合并结果集
                for(Map<String ,Object> map : totalList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> m =(Map<String,Object>)addMap.get(code);
                    if(m!=null){
                        Long addCount = (Long)m.get("addCount");
                        map.put("addCount",addCount==null?0L:addCount);
                    }else{
                        map.put("addCount",0L);
                    }
                    Map<String,Object> m2 =(Map<String,Object>)planMap.get(code);
                    if(m2!=null){
                        Long planCount = (Long)m2.get("planCount");
                        map.put("planCount",planCount);
                    }else{
                        map.put("planCount",0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else if("1".equals(sortType)){
            //按增量排序
            if(addList!=null&&addList.size()>0){
                //以增量为基准,合并结果集
                for(Map<String ,Object> map : totalList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> m =(Map<String,Object>)planMap.get(code);
                    if(m!=null){
                        Long planCount = (Long)m.get("planCount");
                        map.put("planCount",planCount);
                    }else{
                        map.put("planCount",0L);
                    }
                    Map<String,Object> m2 =(Map<String,Object>)planMap.get(code);
                    if(m2!=null){
                        Long followupCount = (Long)m2.get("followupCount");
                        map.put("followupCount",followupCount);
                    }else{
                        map.put("followupCount",0L);
                    }
                }
            }
            return new JSONArray(addList);
        }else{
            //按计划量排序
            if(planList!=null&&planList.size()>0){
                //以增量为基准,合并结果集
                for(Map<String ,Object> map : planList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> m =(Map<String,Object>)planMap.get(code);
                    if(m!=null){
                        Long followupCount = (Long)m.get("followupCount");
                        map.put("followupCount",followupCount);
                    }else{
                        map.put("followupCount",0L);
                    }
                    Map<String,Object> m2 =(Map<String,Object>)addMap.get(code);
                    if(m2!=null){
                        Long addCount = (Long)m2.get("addCount");
                        map.put("addCount",addCount==null?0L:addCount);
                    }else{
                        map.put("addCount",0L);
                    }
                }
            }
            return new JSONArray(planList);
        }
    }
    public JSONObject getTeamDoctorFolTitle(String teamCode,String doctor,String startDate,String endDate){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql = "SELECT " +
                " COUNT(1) AS followupCount " +
                " FROM " +
                " wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL";
        String addSql = "SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
                " wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL";
        String planSql = "SELECT " +
                " COUNT(1) AS planCount " +
                " FROM " +
                " wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.status ='2'"+
                " AND w.followup_class IS NOT NULL";
        JSONObject rs = new JSONObject();
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> map = totalList.get(0);
            Long followupCount = (Long)map.get("followupCount");
            rs.put("followupCount",followupCount!=null?followupCount:0L);
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        if(addList!=null&&addList.size()>0){
            Map<String,Object> map = addList.get(0);
            Long addCount = (Long)map.get("addCount");
            rs.put("addCount",addCount!=null?addCount:0L);
        }
        List<Map<String,Object>> planList = jdbcTemplate.queryForList(planSql);
        if(planList!=null&&planList.size()>0){
            Map<String,Object> map = planList.get(0);
            Long planCount = (Long)map.get("planCount");
            rs.put("planCount",planCount!=null?planCount:0L);
        }
        return rs;
    }
    public JSONArray getTeamResLine(String teamCode,String startDate,String endDate,String type){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ;
        if("0".equals(type)){
            //查周
            totalSql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //查月
            //查周
            totalSql = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(totalSql);
        return new JSONArray(list);
    }
    public JSONArray getTeamDoctorResLine(String teamCode,String startDate,String endDate,String type,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ;
        if("0".equals(type)){
            //查周
            totalSql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.doctor_code = '"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //查月
            totalSql = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.doctor_code = '"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(totalSql);
        return new JSONArray(list);
    }
    public JSONArray getTeamDoctorResList(String teamCode,String startDate,String endDate,String sort,String sortType){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql = "SELECT " +
                " IFNULL(c.reservationCount,0) AS reservationCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS reservationCount, " +
                " w.doctor_code AS doctorCode, " +
                " w.doctor AS name " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code = " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " GROUP BY doctorCode  " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            totalSql = totalSql+  " ORDER BY reservationCount DESC";
        }else{
            totalSql = totalSql+  " ORDER BY reservationCount ASC";
        }
        String addSql = "SELECT " +
                " IFNULL(c.reservationCount,0) AS addCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS reservationCount, " +
                " w.doctor_code AS doctorCode, " +
                " w.doctor AS name " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code = " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY doctorCode  " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            addSql = addSql+  " ORDER BY addCount DESC";
        }else{
            addSql = addSql+  " ORDER BY addCount ASC";
        }
        List<Map<String,Object>> totalList =jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map :totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map :addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        if("0".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map:totalList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) addMap.get(code);
                    if (m != null) {
                        Long addCount = (Long) m.get("addCount");
                        map.put("addCount", addCount != null ? addCount : 0L);
                    } else {
                        map.put("addCount", 0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else{
            //按增量排序
            if(addList!=null&&addList.size()>0){
                for(Map<String,Object> map:addList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) totalMap.get(code);
                    if (m != null) {
                        Long reservationCount = (Long) m.get("reservationCount");
                        map.put("reservationCount", reservationCount != null ? reservationCount : 0L);
                    } else {
                        map.put("reservationCount", 0L);
                    }
                }
            }
            return new JSONArray(addList);
        }
    }
    public JSONObject getTeamDoctorResTitle(String teamCode,String doctor,String startDate,String endDate){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSQL ="SELECT " +
                " COUNT(1) AS reservationCount " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.czrq <= '"+endDate+"' ";
        String addSQL ="SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"'";
        JSONObject rs = new JSONObject();
        Long reservationCount =0L;
        Long addCount = 0L;
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSQL);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> map =totalList.get(0);
            reservationCount = (Long)map.get("reservationCount");
        }
        rs.put("reservationCount",reservationCount);
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSQL);
        if(addList!=null&&addList.size()>0){
            Map<String,Object> map =addList.get(0);
            addCount = (Long)map.get("addCount");
        }
        rs.put("addCount",addCount);
        return rs;
    }
    public JSONArray getTeamGuidLine(String teamCode,String startDate,String endDate,String type){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String SQL ;
        if("0".equals(type)){
            //按周统计
            SQL ="SELECT " +
                    " left(w.create_time,10) AS dateNo, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode+
                    " AND w.czrq <= '"+startDate+"' " +
                    " AND w.czrq >= '"+endDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //按月统计
            SQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(SQL);
        return new JSONArray(totalList);
    }
    public JSONArray getTeamDoctorGuidLine(String teamCode,String startDate,String endDate,String type,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String SQL ;
        if("0".equals(type)){
            //按周统计
            SQL ="SELECT " +
                    " left(w.create_time,10) AS dateNo, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+startDate+"' " +
                    " AND w.czrq >= '"+endDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //按月统计
            SQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(SQL);
        return new JSONArray(totalList);
    }
    public JSONArray getTeamGuidList(String teamCode,String startDate,String endDate,String sort,String sortType){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ="SELECT " +
                " IFNULL(c.guidanceCount,0) AS guidanceCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " w.doctor, " +
                " COUNT(1) AS guidanceCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY w.doctor " +
                " ) c ON c.doctor = m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            totalSql = totalSql+   " ORDER BY guidanceCount DESC";
        }else{
            totalSql = totalSql+   " ORDER BY guidanceCount ASC";
        }
        String addSql ="SELECT " +
                " IFNULL(c.guidanceCount,0) AS addCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " w.doctor, " +
                " COUNT(1) AS guidanceCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY w.doctor " +
                " ) c ON c.doctor = m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            addSql = addSql+   " ORDER BY addCount DESC";
        }else{
            addSql = addSql+   " ORDER BY addCount ASC";
        }
        List<Map<String,Object>> totalList =jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map :totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map :addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        if("0".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map:totalList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) addMap.get(code);
                    if (m != null) {
                        Long addCount = (Long) m.get("addCount");
                        map.put("addCount", addCount != null ? addCount : 0L);
                    } else {
                        map.put("addCount", 0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else{
            //按增量排序
            if(addList!=null&&addList.size()>0){
                for(Map<String,Object> map:addList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) totalMap.get(code);
                    if (m != null) {
                        Long guidanceCount = (Long) m.get("guidanceCount");
                        map.put("guidanceCount", guidanceCount != null ? guidanceCount : 0L);
                    } else {
                        map.put("guidanceCount", 0L);
                    }
                }
            }
            return new JSONArray(addList);
        }
    }
    public JSONObject getTeamDoctorGuiTitle(String teamCode,String doctor,String startDate,String endDate){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSQL ="SELECT " +
                " COUNT(1) AS guidanceCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq >= '"+endDate+"'";
        String addSQL ="SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq <= '"+startDate+"' " +
                " AND w.czrq >= '"+endDate+"'";
        JSONObject rs = new JSONObject();
        Long guidanceCount =0L;
        Long addCount = 0L;
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSQL);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> map =totalList.get(0);
            guidanceCount = (Long)map.get("guidanceCount");
        }
        rs.put("guidanceCount",guidanceCount);
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSQL);
        if(addList!=null&&addList.size()>0){
            Map<String,Object> map =addList.get(0);
            addCount = (Long)map.get("addCount");
        }
        rs.put("addCount",addCount);
        return rs;
    }
    public JSONArray getTeamEduLine(String teamCode,String startDate,String endDate,String type){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String sql;
        if("0".equals(type)){
            //按周统计
            sql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchCount " +
                    " FROM " +
                    " wlyy_health_edu_article_patient w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            sql ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchno " +
                    "FROM " +
                    " wlyy_health_edu_article_patient w " +
                    "WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    "GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return new JSONArray(list);
    }
    public JSONArray getTeamDoctorEduLine(String teamCode,String startDate,String endDate,String type,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String sql;
        if("0".equals(type)){
            //按周统计
            sql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchCount " +
                    " FROM " +
                    " wlyy_health_edu_article_patient w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            sql ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchno " +
                    "FROM " +
                    " wlyy_health_edu_article_patient w " +
                    "WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    "GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return new JSONArray(list);
    }
    public JSONArray getTeamEduList(String teamCode,String startDate,String endDate,String sort,String sortType){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ="SELECT " +
                " IFNULL(c.articleCount,0) AS articleCount, " +
                " IFNULL(c.batchno,0) AS batchno, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS articleCount, " +
                " COUNT(DISTINCT w.batch_no) batchno, " +
                " w.doctor AS doctorCode " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " GROUP BY doctorCode " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode;
        if("0".equals(sort)){
            //降序
            if("0".equals(sortType)){
                //总人次
                totalSql = totalSql+ " ORDER BY articleCount DESC";
            }else if("2".equals(sortType)){
                //总批次
                totalSql = totalSql+ " ORDER BY batchno DESC";
            }
        }else{
            if("0".equals(sortType)){
                totalSql = totalSql+ " ORDER BY articleCount ASC";
            }else if("2".equals(sortType)){
                totalSql = totalSql+ " ORDER BY batchno ASC";
            }
        }
        String addSql ="SELECT " +
                " IFNULL(c.articleCount,0) AS addCount, " +
                " IFNULL(c.batchno,0) AS addBatchno, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS articleCount, " +
                " COUNT(DISTINCT w.batch_no) batchno, " +
                " w.doctor AS doctorCode " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY doctorCode " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode;
        if("0".equals(sort)){
            if("1".equals(sortType)){
                addSql = addSql+ " ORDER BY addCount DESC";
            }else if("3".equals(sortType)){
                addSql = addSql+ " ORDER BY addBatchno DESC";
            }
        }else{
            if("1".equals(sortType)){
                addSql = addSql+ " ORDER BY addCount ASC";
            }else if("3".equals(sortType)){
                addSql = addSql+ " ORDER BY addBatchno ASC";
            }
        }
        List<Map<String,Object>> totalList =jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map :totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map :addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        if("0".equals(sortType)||"2".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map:totalList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) addMap.get(code);
                    if (m != null) {
                        Long addCount = (Long) m.get("addCount");
                        Long addBatchno = (Long) m.get("addBatchno");
                        map.put("addCount", addCount != null ? addCount : 0L);
                        map.put("addBatchno", addBatchno != null ? addBatchno : 0L);
                    } else {
                        map.put("addCount", 0L);
                        map.put("addBatchno", 0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else{
            //按增量排序
            if(addList!=null&&addList.size()>0){
                for(Map<String,Object> map:addList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) totalMap.get(code);
                    if (m != null) {
                        Long articleCount = (Long) m.get("articleCount");
                        map.put("articleCount", articleCount != null ? articleCount : 0L);
                        Long batchno = (Long) m.get("batchno");
                        map.put("batchno", batchno != null ? batchno : 0L);
                    } else {
                        map.put("articleCount", 0L);
                        map.put("batchno", 0L);
                    }
                }
            }
            return new JSONArray(addList);
        }
    }
    public JSONObject getTeamDoctorEduTitle(String teamCode,String startDate,String endDate,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ="SELECT " +
                " COUNT(1) AS articleCount, " +
                " COUNT(DISTINCT w.batch_no) batchno " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq <= '"+endDate+"' ";
        String addSql ="SELECT " +
                " COUNT(1) AS addCount, " +
                " COUNT(DISTINCT w.batch_no) addBatchno " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"'";
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        List<Map<String,Object>> addList =jdbcTemplate.queryForList(addSql);
        JSONObject rs = new JSONObject();
        rs.put("totalList",totalList);
        rs.put("addList",addList);
        return rs;
    }
    }
}
}

+ 8 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -1133,10 +1133,16 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    @RequestMapping(value = "/findNoHealthSignFamilyHealthNum")
    @RequestMapping(value = "/findNoHealthSignFamilyHealthNum")
    @ResponseBody
    @ResponseBody
    public String findNoHealthSignFamilyHealthNum(
    public String findNoHealthSignFamilyHealthNum(
            String labelType,
            @RequestParam(required = false)String labelType,
            @RequestParam(required = false) String patientName,
            @RequestParam(required = false) String patientName,
            Long teamCode) {
            @RequestParam(required = false)Long teamCode) {
        try {
        try {
            //修改年度服务类型1.3.4需求
            if("1".equals(labelType)){
                JSONObject  rs =  familyContractService.getServerPatientList(teamCode);
                return write(200, "查询成功!", "data", rs);
            }
            List listNum = new ArrayList();
            List listNum = new ArrayList();
            Map patients = new HashMap();
            Map patients = new HashMap();
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);

+ 317 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -899,9 +899,10 @@ public class StatisticsController extends BaseController {
    public String getMemberConsultList(@RequestParam(required = true)String teamCode,
    public String getMemberConsultList(@RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String sort){
                                       @RequestParam(required = true)String sort,
                                       @RequestParam(required = true)String sortType){
        try {
        try {
            return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode,startDate,endDate,sort));
            return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
@ -967,4 +968,318 @@ public class StatisticsController extends BaseController {
        }
        }
    }
    }
    /**
     * 根据团队获取团队底下用户列表
     * @param sort 0为降序,1为升序
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sortType 0为总数排序,1为增量排序,2为计划中排序
     * @return
     */
    @RequestMapping("/getDoctorTeamFolList")
    @ResponseBody
    public String getDoctorTeamFolList(@RequestParam(required = true)String sort,
                                       @RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getDoctorTeamFolList(startDate,endDate,teamCode,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生随访头信息
     * @param teamCode
     * @param doctor
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamDoctorFolTitle")
    @ResponseBody
    public String getTeamDoctorFolTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String doctor,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorFolTitle(teamCode,doctor,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取待预约量团队统计则线图
     * @param teamCode
     * @param type
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamResLine")
    @ResponseBody
    public String getTeamResLine(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String type,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamResLine(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生预约量团队统计则线图
     * @param teamCode
     * @param type
     * @param startDate
     * @param endDate
     * @param doctor
     * @return
     */
    @RequestMapping("/getTeamDoctorResLine")
    @ResponseBody
    public String getTeamDoctorResLine(@RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String type,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorResLine(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队待预约量医生列表信息
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort 0为降序,1为升序
     * @param sortType 0为按总数,1为按增数
     * @return
     */
    @RequestMapping("/getTeamDoctorResList")
    @ResponseBody
    public String getTeamDoctorResList(@RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String sort,
                                       @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorResList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生待预信息
     * @param teamCode
     * @param doctor
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamDoctorResTitle")
    @ResponseBody
    public String getTeamDoctorResTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String doctor,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorResTitle(teamCode,doctor,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康指导折线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type 0周,1月
     * @return
     */
    @RequestMapping("/getTeamGuidLine")
    @ResponseBody
    public String getTeamGuidLine(@RequestParam(required = true)String teamCode,
                                  @RequestParam(required = true)String startDate,
                                  @RequestParam(required = true)String endDate,
                                  @RequestParam(required = true)String type){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamGuidLine(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     *  获取团队医生则线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type
     * @param doctor
     * @return
     */
    @RequestMapping("/getTeamDoctorGuidLine")
    @ResponseBody
    public String getTeamDoctorGuidLine(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate,
                                        @RequestParam(required = true)String type,
                                        @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuidLine(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队指导总数List
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort
     * @param sortType
     * @return
     */
    @RequestMapping("/getTeamGuidList")
    @ResponseBody
    public String getTeamGuidList(@RequestParam(required = true)String teamCode,
                                  @RequestParam(required = true)String startDate,
                                  @RequestParam(required = true)String endDate,
                                  @RequestParam(required = true)String sort,
                                  @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamGuidList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生健康指导头部信息
     * @param teamCode
     * @param doctor
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamDoctorGuiTitle")
    @ResponseBody
    public String getTeamDoctorGuiTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String doctor,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuiTitle(teamCode,doctor,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康教育折线统计
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type 0按周 1按月
     * @return
     */
    @RequestMapping("/getTeamEduLine")
    @ResponseBody
    public String getTeamEduLine(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate,
                                 @RequestParam(required = true)String type){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamEduLine(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type
     * @return
     */
    @RequestMapping("/getTeamDoctorEduLine")
    @ResponseBody
    public String getTeamDoctorEduLine(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate,
                                 @RequestParam(required = true)String type,
                                 @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduLine(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队成员健康教育列表
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort
     * @param sortType
     * @return
     */
    @RequestMapping("/getTeamEduList")
    @ResponseBody
    public String getTeamEduList(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate,
                                 @RequestParam(required = true)String sort,
                                 @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamEduList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamDoctorEduTitle")
    @ResponseBody
    public String getTeamDoctorEduTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate,
                                        @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduTitle(teamCode,startDate,endDate,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}
}