Bladeren bron

Merge branch 'dev' of trick9191/patient-co-management into dev

trick9191 7 jaren geleden
bovenliggende
commit
35c72413d6

+ 18 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -1908,9 +1908,16 @@ public class ConsultTeamService extends ConsultService {
                String SQL = "SELECT t.id FROM wlyy_sign_family_renew t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+DateUtil.getSignYear()+"' AND t.patient ='"+uid+"' ";
                String SQL2 ="SELECT t.id FROM wlyy_sign_family t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+(DateUtil.getSignYear()-1)+"' AND t.patient ='"+uid+"' AND t.status>0 AND t.expenses_status ='1' ";
                List<Map<String,Object>> isExits = jdbcTemplate.queryForList(SQL);
                if(isExits!=null&&isExits.size()>0){
                    indexs.add(i);
                List<Map<String,Object>> isExitsSign = jdbcTemplate.queryForList(SQL2);
                if(isExitsSign==null){
                    if(isExits!=null&&isExits.size()>0){
                        indexs.add(i);
                    }
                }
            }
            if(indexs!=null&&indexs.size()>0){
@ -1930,9 +1937,16 @@ public class ConsultTeamService extends ConsultService {
                String SQL = "SELECT t.id FROM wlyy_sign_family_renew t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+DateUtil.getSignYear()+"' AND t.patient ='"+uid+"' ";
                String SQL2 ="SELECT t.id FROM wlyy_sign_family t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+(DateUtil.getSignYear()-1)+"' AND t.patient ='"+uid+"' AND t.status>0 AND t.expenses_status ='1' ";
                List<Map<String,Object>> isExits = jdbcTemplate.queryForList(SQL);
                if(isExits!=null&&isExits.size()>0){
                    indexs.add(i);
                List<Map<String,Object>> isExitsSign = jdbcTemplate.queryForList(SQL2);
                if(isExitsSign==null){
                    if(isExits!=null&&isExits.size()>0){
                        indexs.add(i);
                    }
                }
            }
            if(indexs!=null&&indexs.size()>0){

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

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

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

@ -2991,16 +2991,16 @@ public class FamilyContractService extends BaseService {
        }else {
            //如果不一致 查看医生团队
            sf.setRenewFlag("2");
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
            if(ids!=null&&ids.size()>0){
                Integer id =  (Integer)ids.get(0).get("id");
                Long lid = id.longValue();
                sf.setAdminTeamId(lid);
            }else{
                //未找到团队信息
                return -5;
            }
//            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
//            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
//            if(ids!=null&&ids.size()>0){
//                Integer id =  (Integer)ids.get(0).get("id");
//                Long lid = id.longValue();
//                sf.setAdminTeamId(lid);
//            }else{
//                //未找到团队信息
//                return -5;
//            }
            //新建咨询团队组
            DoctorTeam team = new DoctorTeam();
            String code = getCode();
@ -3176,16 +3176,16 @@ public class FamilyContractService extends BaseService {
            sf.setAdminTeamId(c.longValue());
        }else {
            //如果不一致 查看医生团队
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
            if(ids!=null&&ids.size()>0){
                Integer id =  (Integer)ids.get(0).get("id");
                Long lid = id.longValue();
                sf.setAdminTeamId(lid);
            }else{
                //未找到团队信息
                return -5;
            }
//            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
//            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
//            if(ids!=null&&ids.size()>0){
//                Integer id =  (Integer)ids.get(0).get("id");
//                Long lid = id.longValue();
//                sf.setAdminTeamId(lid);
//            }else{
//                //未找到团队信息
//                return -5;
//            }
            //新建咨询团队组
            DoctorTeam team = new DoctorTeam();
            String code = getCode();

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

@ -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;
    }
}

+ 5 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -376,5 +376,9 @@ public class SystemConf {
	}
	/**************************************************************************************/
	/**
	 * 获取IM数据库名
	 * @return
     */
	public String getImDataBaseName(){ return getSystemProperties().getProperty("im_dataBase");}
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -260,7 +260,7 @@ public class SignPatientLabelInfoController extends BaseController {
                return write(200, "查询成功", "data", r);
            }
            if(labelType.equals("1")){
            if(labelType.equals("1")&&teamCode!=0L){
                JSONArray r= patientService.getSignByDoctorCodeGpbyServer(getUID(),teamCode+"");
                return write(200, "查询成功", "data", r);
            }

+ 76 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -840,5 +840,81 @@ public class StatisticsController extends BaseController {
        }
    }
    /**
     * 获取团队月或周咨询未回复和总数折线图
     * @param teamCode 团队id
     * @param startDate
     * @param endDate
     * @param type 0周,1月
     * @return
     */
    @RequestMapping("/getTeamConsultCount")
    @ResponseBody
    public String getTeamConsultCount(String teamCode,String startDate,String endDate,String type){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamConsultCount(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     *  计算团队医生月或周咨询未回复和总数折线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type 0周,1月
     * @param doctor
     * @return
     */
    @RequestMapping("/getTeamDocotorConsultCount")
    @ResponseBody
    public String getTeamDocotorConsultCount(String teamCode,String startDate,String endDate,String type,String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDocotorConsultCount(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队内这成员,未回复数,总数,结束咨询数
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort 0降序,1升序
     * @return
     */
    @RequestMapping("/getMemberConsultList")
    @ResponseBody
    public String getMemberConsultList(String teamCode,String startDate,String endDate,String sort){
        try {
            return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode,startDate,endDate,sort));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取Doctor咨询结果
     * @param doctor
     * @param teamCode
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getDoctorConsultTitle")
    @ResponseBody
    public String getDoctorConsultTitle(String doctor,String teamCode,String startDate,String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getDoctorConsultTitle(doctor,teamCode,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}

+ 3 - 0
patient-co-wlyy/src/main/resources/system.properties

@ -73,6 +73,9 @@ sign_again_job_end=2017-10-1 00:00:00
evaluate_score_job = 0 0 */2 * * ?
#im数据库名
im_dataBase = im_new
#-------------------------开发环境配置-------------------------#
## 服务器基本配置
#server_ip=weixin.xmtyw.cn