Browse Source

bug修改

chenweida 8 years ago
parent
commit
6df5ad36d6

+ 2 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java

@ -56,14 +56,14 @@ public class CachePool {
                    " and a.type =2  " +
                    " and expenses_status=1 " +
                    " and a.expenses_time< '"+date+ Constant.quota_date_last+"' " +
                    " and sf.sign_year ='"+Constant.getNowYearByDateYeaterday(date)+"'  " ;
                    " and a.sign_year ='"+Constant.getNowYearByDateYeaterday(date)+"'  " ;
            String sqlCount="select count(id) from wlyy_sign_family a " +
                    " where  " +
                    " status in(1,2) " +
                    " and a.type =2 " +
                    " and expenses_status=1 " +
                    " and a.expenses_time< '"+date+ Constant.quota_date_last+"'  " +
                    " and sf.sign_year ='"+Constant.getNowYearByDateYeaterday(date)+"'  " ;
                    " and a.sign_year ='"+Constant.getNowYearByDateYeaterday(date)+"'  " ;
            //抽取數據 分页抽取
            List<SignFamily> signFamiliesTemp= SpringUtil.getBean(DBExtract.class).extractByPage(SignFamily.class,sql,sqlCount,true);
            model.setSql(sql);

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

@ -409,10 +409,10 @@ public class StatisticsService extends BaseService {
                        redisNum = "";
                    }
                    if (StringUtils.isEmpty(redisNum)) {
                        if(org.springframework.util.StringUtils.isEmpty(year)){
                            year= Constant.getNowYear();
                        if (org.springframework.util.StringUtils.isEmpty(year)) {
                            year = Constant.getNowYear();
                        }
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(),Integer.valueOf(year));
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf(year));
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
@ -1778,9 +1778,9 @@ public class StatisticsService extends BaseService {
                " wlyy_consult_team c,wlyy_evaluate_score s  " +
                " WHERE " +
                " c.consult = s.consult  " +
                " AND c.czrq >= '"+startDate+"' " +
                " AND c.czrq <= '"+endDate+"' " +
                " AND c.admin_team_code ="+id;
                " AND c.czrq >= '" + startDate + "' " +
                " AND c.czrq <= '" + endDate + "' " +
                " AND c.admin_team_code =" + id;
        //计算签约表记录
        Map<String, Object> signCount = jdbcTemplate.queryForMap(sign_sql);
@ -1889,22 +1889,22 @@ public class StatisticsService extends BaseService {
                    " FROM " +
                    " wlyy_sign_family_renew_log f " +
                    " WHERE " +
                    " f.apply_date >= '"+startDate+"' " +
                    " AND f.apply_date <= '"+endDate+"' " +
                    " AND f.admin_team_id = " +id+
                    " f.apply_date >= '" + startDate + "' " +
                    " AND f.apply_date <= '" + endDate + "' " +
                    " AND f.admin_team_id = " + id +
                    " GROUP BY " +
                    " LEFT (f.apply_date, 10)";
            //按月
        } else {
            sql = "SELECT " +
                    " (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('"+startDate+"','%v')+1) AS weekOfMonth, " +
                    " (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('" + startDate + "','%v')+1) AS weekOfMonth, " +
                    " count(1) AS signCount " +
                    " FROM " +
                    " wlyy_sign_family_renew_log f " +
                    " WHERE " +
                    " f.apply_date >= '"+startDate+"' " +
                    " AND f.apply_date <= '"+endDate+"' " +
                    " AND f.admin_team_id = " +id+
                    " f.apply_date >= '" + startDate + "' " +
                    " AND f.apply_date <= '" + endDate + "' " +
                    " AND f.admin_team_id = " + id +
                    " GROUP BY " +
                    " DATE_FORMAT(f.apply_date, '%m %v')";
        }
@ -1913,7 +1913,8 @@ public class StatisticsService extends BaseService {
        JSONArray rsJs = new JSONArray(rs);
        return rsJs;
    }
    public JSONObject getReyStatbyTeamNow(String doctor, String startDate, String endDate, String isNow){
    public JSONObject getReyStatbyTeamNow(String doctor, String startDate, String endDate, String isNow) {
        AdminTeam admin = adminTeamDao.findByLeaderCode(doctor);
        if (admin == null) {
            throw new RuntimeException("未找到团队信息");
@ -1925,52 +1926,52 @@ public class StatisticsService extends BaseService {
        String totalSql = "SELECT " +
                "  COUNT(1) total " +
                "  FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code =" +id +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
                " AND c.admin_team_code =" + id +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'";
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSql);
        Long totalCount = 0L;
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> total = totalList.get(0);
            totalCount = (Long)total.get("total");
        if (totalList != null && totalList.size() > 0) {
            Map<String, Object> total = totalList.get(0);
            totalCount = (Long) total.get("total");
        }
        String noReySql = "SELECT " +
                "  COUNT(1) noRey " +
                "  FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND t. STATUS <> 10 " +
                " AND t.`reply` = 0 "+
                " AND t.`reply` = 0 " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code =" +id +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
        List<Map<String,Object>> noReyList = jdbcTemplate.queryForList(noReySql);
                " AND c.admin_team_code =" + id +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'";
        List<Map<String, Object>> noReyList = jdbcTemplate.queryForList(noReySql);
        Long noReyCount = 0L;
        if(noReyList!=null&&noReyList.size()>0){
            Map<String,Object> noRey = noReyList.get(0);
            noReyCount = (Long)noRey.get("noRey");
        if (noReyList != null && noReyList.size() > 0) {
            Map<String, Object> noRey = noReyList.get(0);
            noReyCount = (Long) noRey.get("noRey");
        }
        JSONObject rs = new JSONObject();
        rs.put("onReyCount", noReyCount);
        rs.put("totalCount",totalCount);
        rs.put("totalCount", totalCount);
        return rs;
    }
@ -2204,26 +2205,26 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public Map<String, Object> getConsultByteam(Long id, String startDate, String endDate) {
         String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
//        startDate = startDate + " 00:00:00";
//        endDate = endDate + " 23:59:59";
        //咨询量
        String consult_sql = "SELECT " +
                "  COUNT(1) consultCount " +
                "  FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code =" +id+
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
                " AND c.admin_team_code =" + id +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'";
        //获取咨詢數
        Map<String, Object> consultCout = jdbcTemplate.queryForMap(consult_sql);
        if (consultCout.get("consultCount") == null) {
@ -2314,22 +2315,22 @@ public class StatisticsService extends BaseService {
                    " WHERE  " +
                    "  s.consult = t.consult " +
                    " AND  " +
                    " t.czrq <= '"+endDate+"' " +
                    " AND t.czrq >= '"+startDate+"' " +
                    " AND t.admin_team_code = " +id+
                    " t.czrq <= '" + endDate + "' " +
                    " AND t.czrq >= '" + startDate + "' " +
                    " AND t.admin_team_code = " + id +
                    " GROUP BY dateNo";
        } else {
            sql = "SELECT " +
                    " (DATE_FORMAT(t.czrq,'%v')-DATE_FORMAT('"+startDate+"','%v')+1) AS weekNo, " +
                    " (DATE_FORMAT(t.czrq,'%v')-DATE_FORMAT('" + startDate + "','%v')+1) AS weekNo, " +
                    " ifnull(ROUND(AVG(s.score), 1), 0) AS avgCount " +
                    " FROM " +
                    " wlyy_evaluate_score s,wlyy_consult_team t " +
                    " WHERE  " +
                    "  s.consult = t.consult " +
                    " AND  " +
                    " t.czrq <= '"+endDate+"' " +
                    " AND t.czrq >= '"+startDate+"' " +
                    " AND t.admin_team_code = " +id +
                    " t.czrq <= '" + endDate + "' " +
                    " AND t.czrq >= '" + startDate + "' " +
                    " AND t.admin_team_code = " + id +
                    " GROUP BY weekNo";
        }
@ -2366,11 +2367,11 @@ public class StatisticsService extends BaseService {
            sql = "SELECT " +
                    "  left(t.create_time,10) AS dateNo, COUNT(1) AS noRely  " +
                    " FROM " +
                    "  "+ imDataBaseName +".Topics t, " +
                    "  "+ imDataBaseName +".Participants p, " +
                    "  "+ imDataBaseName +".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+ imDataBaseName +".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    " WHERE " +
                    "  d.id = p.participant_id " +
                    " AND c.consult = t.id " +
@ -2378,67 +2379,67 @@ public class StatisticsService extends BaseService {
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND p.session_id = t.session_id " +
                    " AND c.admin_team_code = " +teamCode+
                    " AND t.create_time >= '"+startDate+"' " +
                    " AND t.create_time <= '"+endDate+"' " +
                    " AND c.admin_team_code = " + teamCode +
                    " AND t.create_time >= '" + startDate + "' " +
                    " AND t.create_time <= '" + endDate + "' " +
                    " GROUP BY dateNo";
            totalSql = "SELECT " +
                    "  left(t.create_time,10) AS dateNo, COUNT(1) total " +
                    " FROM " +
                    "  "+ imDataBaseName +".Topics t, " +
                    "  "+ imDataBaseName +".Participants p, " +
                    "  "+ imDataBaseName +".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+ imDataBaseName +".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    " WHERE " +
                    "  d.id = p.participant_id " +
                    " AND c.consult = t.id " +
                    " AND c.patient = s.id " +
                    " AND p.session_id = t.session_id " +
                    " AND c.admin_team_code = " +teamCode+
                    " AND t.create_time >= '"+startDate+"' " +
                    " AND t.create_time <= '"+endDate+"' " +
                    " AND c.admin_team_code = " + teamCode +
                    " AND t.create_time >= '" + startDate + "' " +
                    " AND t.create_time <= '" + endDate + "' " +
                    " GROUP BY dateNo";
        } else {
            //按月统计
            sql ="SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
            sql = "SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('" + startDate + "', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS noRely " +
                    "  FROM " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+imDataBaseName+".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
                    "  AND c.patient = s.id " +
                    "  AND p.session_id = t.session_id " +
                    "  AND c.admin_team_code = " +teamCode+
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND t. STATUS <> 10  " +
                    "  AND t.`reply` = 0  " +
                    "  AND t.create_time >= '"+startDate+"' " +
                    "  AND t.create_time <= '"+endDate+"' " +
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
                    "  GROUP BY weekOfMonth";
            totalSql ="SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
            totalSql = "SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('" + startDate + "', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS total " +
                    "  FROM " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+imDataBaseName+".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
                    "  AND c.patient = s.id " +
                    "  AND p.session_id = t.session_id " +
                    "  AND c.admin_team_code = " +teamCode+
                    "  AND t.create_time >= '"+startDate+"' " +
                    "  AND t.create_time <= '"+endDate+"' " +
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
                    "  GROUP BY weekOfMonth";
        }
@ -2471,11 +2472,11 @@ public class StatisticsService extends BaseService {
            sql = "SELECT " +
                    "  left(t.create_time,10) AS dateNo, COUNT(1) AS noRely " +
                    " FROM " +
                    "  "+ imDataBaseName +".Topics t, " +
                    "  "+ imDataBaseName +".Participants p, " +
                    "  "+ imDataBaseName +".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+ imDataBaseName +".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    " WHERE " +
                    "  d.id = p.participant_id " +
                    " AND c.consult = t.id " +
@ -2483,71 +2484,71 @@ public class StatisticsService extends BaseService {
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND p.session_id = t.session_id " +
                    " AND d.id ='"+doctor +"'"+
                    " AND c.admin_team_code = " +teamCode+
                    " AND t.create_time >= '"+startDate+"' " +
                    " AND t.create_time <= '"+endDate+"' " +
                    " AND d.id ='" + doctor + "'" +
                    " AND c.admin_team_code = " + teamCode +
                    " AND t.create_time >= '" + startDate + "' " +
                    " AND t.create_time <= '" + endDate + "' " +
                    " GROUP BY dateNo";
            totalSql = "SELECT " +
                    "  left(t.create_time,10) AS dateNo, COUNT(1) total " +
                    " FROM " +
                    "  "+ imDataBaseName +".Topics t, " +
                    "  "+ imDataBaseName +".Participants p, " +
                    "  "+ imDataBaseName +".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+ imDataBaseName +".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    " WHERE " +
                    "  d.id = p.participant_id " +
                    " AND c.consult = t.id " +
                    " AND c.patient = s.id " +
                    " AND p.session_id = t.session_id " +
                    " AND d.id ='"+doctor +"'"+
                    " AND c.admin_team_code = " +teamCode+
                    " AND t.create_time >= '"+startDate+"' " +
                    " AND t.create_time <= '"+endDate+"' " +
                    " AND d.id ='" + doctor + "'" +
                    " AND c.admin_team_code = " + teamCode +
                    " AND t.create_time >= '" + startDate + "' " +
                    " AND t.create_time <= '" + endDate + "' " +
                    " GROUP BY dateNo";
        } else {
            //按月统计
            sql ="SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
            sql = "SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('" + startDate + "', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS noRely " +
                    "  FROM " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+imDataBaseName+".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
                    "  AND c.patient = s.id " +
                    "  AND p.session_id = t.session_id " +
                    "  AND c.admin_team_code = " +teamCode+
                    "  AND d.id ='"+doctor +"'"+
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND d.id ='" + doctor + "'" +
                    "  AND t. STATUS <> 10  " +
                    "  AND t.`reply` = 0  " +
                    "  AND t.create_time >= '"+startDate+"' " +
                    "  AND t.create_time <= '"+endDate+"' " +
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
                    "  GROUP BY weekOfMonth";
            totalSql ="SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1) AS weekOfMonth, " +
            totalSql = "SELECT " +
                    "  (DATE_FORMAT(t.create_time, '%v') - DATE_FORMAT('" + startDate + "', '%v') + 1) AS weekOfMonth, " +
                    "  COUNT(1) AS total " +
                    "  FROM " +
                    "  "+imDataBaseName+".Topics t, " +
                    "  "+imDataBaseName+".Participants p, " +
                    "  "+imDataBaseName+".Doctors d, " +
                    "  " + imDataBaseName + ".Topics t, " +
                    "  " + imDataBaseName + ".Participants p, " +
                    "  " + imDataBaseName + ".Doctors d, " +
                    "  Wlyy_Consult_Team c, " +
                    "  "+imDataBaseName+".Patients s " +
                    "  " + imDataBaseName + ".Patients s " +
                    "  WHERE " +
                    "  d.id = p.participant_id " +
                    "  AND c.consult = t.id " +
                    "  AND c.patient = s.id " +
                    "  AND p.session_id = t.session_id " +
                    "  AND d.id ='"+doctor +"'"+
                    "  AND c.admin_team_code = " +teamCode+
                    "  AND t.create_time >= '"+startDate+"' " +
                    "  AND t.create_time <= '"+endDate+"' " +
                    "  AND d.id ='" + doctor + "'" +
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
                    "  GROUP BY weekOfMonth";
        }
@ -2587,27 +2588,27 @@ public class StatisticsService extends BaseService {
                "  d.`name`, " +
                "  d.id " +
                " FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                " WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code = " +teamCode+
                " AND c.admin_team_code = " + teamCode +
                " AND t. STATUS <> 10 " +
                " AND t.`reply` = 0 " +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "' " +
                " GROUP BY " +
                "  id " +
                " ) c ON c.id = m.doctor_code " +
                " WHERE " +
                " m.doctor_code = d.`code` " +
                " AND m.team_id = "+teamCode;
                " AND m.team_id = " + teamCode;
        if ("0".equals(sort)) {
            onReySQL = onReySQL + " ORDER BY noRely DESC";
        } else {
@ -2629,25 +2630,25 @@ public class StatisticsService extends BaseService {
                "  d.`name`, " +
                "  d.id " +
                " FROM " +
                "  "+ imDataBaseName +".Topics t, " +
                "  "+ imDataBaseName +".Participants p, " +
                "  "+ imDataBaseName +".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+ imDataBaseName +".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                " WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code = " +teamCode+
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND c.admin_team_code = " + teamCode +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "' " +
                " GROUP BY " +
                "  id " +
                " ) c ON c.id = m.doctor_code " +
                " WHERE " +
                " m.doctor_code = d.`code` " +
                " AND m.team_id = "+teamCode;
                " AND m.team_id = " + teamCode;
        if ("0".equals(sort)) {
            totalSql = totalSql + " ORDER BY total DESC";
        } else {
@ -2669,26 +2670,26 @@ public class StatisticsService extends BaseService {
                "  d.`name`, " +
                "  d.id " +
                " FROM " +
                "  "+ imDataBaseName +".Topics t, " +
                "  "+ imDataBaseName +".Participants p, " +
                "  "+ imDataBaseName +".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+ imDataBaseName +".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                " WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code = " +teamCode+
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND c.admin_team_code = " + teamCode +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "' " +
                " AND t. STATUS = 10 " +
                " GROUP BY " +
                "  id " +
                " ) c ON c.id = m.doctor_code " +
                " WHERE " +
                " m.doctor_code = d.`code` " +
                " AND m.team_id = "+teamCode;
                " AND m.team_id = " + teamCode;
        if ("0".equals(sort)) {
            endConsultSql = endConsultSql + " ORDER BY endRey DESC";
        } else {
@ -2787,65 +2788,65 @@ public class StatisticsService extends BaseService {
        String couTotalSQL = "SELECT " +
                "  COUNT(1) total " +
                " FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                " WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code ="+teamCode+
                " AND d.id='"+doctor+"'" +
                " AND t.create_time <= '"+endDate+"'";
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " AND t.create_time <= '" + endDate + "'";
        //及时回复数
        String reyTotalSql = "SELECT " +
                "  COUNT(1) total " +
                " FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                " WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND t.`reply`=1 " +
                " AND c.admin_team_code ="+teamCode+
                " AND d.id='"+doctor+"'" +
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " 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 t.create_time <= '" + endDate + "'";
        //本周或月增量
        String addTotalSql = "SELECT " +
                " COUNT(1) total " +
                " FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                " WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code ="+teamCode+
                " AND d.id='"+doctor+"'" +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'";
        //当前未回复咨询数
        String noRelySql = "SELECT " +
                " COUNT(1) total " +
                " FROM " +
                "  "+imDataBaseName+".Topics t, " +
                "  "+imDataBaseName+".Participants p, " +
                "  "+imDataBaseName+".Doctors d, " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  "+imDataBaseName+".Patients s " +
                "  " + imDataBaseName + ".Patients s " +
                " WHERE " +
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
@ -2853,10 +2854,10 @@ public class StatisticsService extends BaseService {
                " AND p.session_id = t.session_id " +
                " AND t. STATUS <> 10  " +
                " AND t.`reply` = 0  " +
                " AND c.admin_team_code ="+teamCode+
                " AND d.id='"+doctor+"'" +
                " AND t.create_time >= '"+startDate+"' " +
                " AND t.create_time <= '"+endDate+"'";
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'";
        JSONObject rs = new JSONObject();
        Long total = 0L;
@ -3525,8 +3526,8 @@ public class StatisticsService extends BaseService {
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code = " + teamCode +
                    " AND w.czrq <= '" +endDate+ "' " +
                    " AND w.czrq >= '" +startDate  + "' " +
                    " AND w.czrq <= '" + endDate + "' " +
                    " AND w.czrq >= '" + startDate + "' " +
                    " GROUP BY dateNo";
        } else {
            //按月统计
@ -3563,7 +3564,7 @@ public class StatisticsService extends BaseService {
                    " w.admin_team_code = " + teamCode +
                    " AND w.doctor ='" + doctor + "'" +
                    " AND w.czrq <= '" + endDate + "' " +
                    " AND w.czrq >= '" +startDate  + "' " +
                    " AND w.czrq >= '" + startDate + "' " +
                    " GROUP BY dateNo";
        } else {
            //按月统计
@ -3714,8 +3715,8 @@ public class StatisticsService extends BaseService {
                " WHERE " +
                " w.admin_team_code =  " + teamCode +
                " AND w.doctor ='" + doctor + "'" +
                " AND w.czrq <= '" +endDate  + "' " +
                " AND w.czrq >= '" +startDate+ "'";
                " AND w.czrq <= '" + endDate + "' " +
                " AND w.czrq >= '" + startDate + "'";
        JSONObject rs = new JSONObject();
        Long guidanceCount = 0L;
        Long addCount = 0L;
@ -4011,6 +4012,7 @@ public class StatisticsService extends BaseService {
        }
        return null;
    }
    public List<WlyyQuotaResult> findQuotaResults(String date, int level, String index, String area) {
        String sql = " select * from wlyy_quota_result w where w.quota_date ='" + date + "' and w.quato_code='" + index + "' and w.level1_type= " + level;
        if (level == 4) {
@ -4030,24 +4032,30 @@ public class StatisticsService extends BaseService {
        return results;
    }
    public JSONObject getRenewPercentAndChangePercent(String level, String code, String year) {
        String renewIndex="";
        String switchIndex="";
        if("2".equals(level)){
            //团队的续签量
            renewIndex="42";
    public JSONObject getRenewPercentAndChangePercent(String renewIndex, String level, String code, String year) {
        String switchIndex = "";
        if ("2".equals(level)) {
            //renewIndex为空的时候用level去算
            if (org.springframework.util.StringUtils.isEmpty(renewIndex)) {
                //团队的续签量
                renewIndex = "42";
            }
            //团队的转签
            switchIndex="35";
        }else if("2".equals(level)){
            //社区的续签量
            renewIndex="43";
            switchIndex = "35";
        } else if ("3".equals(level)) {
            if (org.springframework.util.StringUtils.isEmpty(renewIndex)) {
                //社区的续签量
                renewIndex = "43";
            }
            //社区的转签
            switchIndex="35";
        }else{
            //区和市的续签量
            renewIndex="44";
            switchIndex = "35";
        } else {
            if (org.springframework.util.StringUtils.isEmpty(renewIndex)) {
                //区和市的续签量
                renewIndex = "44";
            }
            //区和市的转签
            switchIndex="35";
            switchIndex = "35";
        }
        JSONObject jo = new JSONObject();
@ -4075,7 +4083,7 @@ public class StatisticsService extends BaseService {
    }
    public JSONObject getRenewAnalysis(String switchIndex,String switchIndexReson,String signIn,String signOut,String level, String code) {
    public JSONObject getRenewAnalysis(String switchIndex, String switchIndexReson, String signIn, String signOut, String level, String code) {
        JSONObject jo = new JSONObject();
        String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
@ -4092,25 +4100,25 @@ public class StatisticsService extends BaseService {
        int changeTeam = getLevel1NumForRedis("31", level, code, timeKey);//夸团队的数目
        int changeHospital = getLevel1NumForRedis("32", level, code, timeKey);//夸社区的数目
        int changeTown = getLevel1NumForRedis("33", level, code, timeKey);//夸社区的数目
        int allChangeCount=changeTeam+changeHospital+changeTown; //跨团队,跨社区 跨区的分母
        int allChangeCount = changeTeam + changeHospital + changeTown; //跨团队,跨社区 跨区的分母
        jo.put("inNum", inNum);//今年的签入量
        jo.put("outNum", outNum);//今年的签出量
        jo.put("thisYearSwithch", switchNum);//今年的转签量
        jo.put("switchHealth", switchJO);//今年的服务分布
        String changeTeamNum=getRangeNoLast(changeTeam, allChangeCount, 2);//跨团队转签率
        String changeHospNum=getRangeNoLast(changeHospital, allChangeCount, 2);//跨社区转签率
        String changeTownNum="";
        String changeTeamNum = getRangeNoLast(changeTeam, allChangeCount, 2);//跨团队转签率
        String changeHospNum = getRangeNoLast(changeHospital, allChangeCount, 2);//跨社区转签率
        String changeTownNum = "";
        if(changeTown==0){
            changeTownNum="0";
        }else{
            changeTownNum=(100-Double.valueOf(changeTeamNum)-Double.valueOf(changeHospNum))+"";//跨区转签率,解决算出来可能不是100%的问题 用扣的
        if (changeTown == 0) {
            changeTownNum = "0";
        } else {
            changeTownNum = (100 - Double.valueOf(changeTeamNum) - Double.valueOf(changeHospNum)) + "";//跨区转签率,解决算出来可能不是100%的问题 用扣的
        }
        jo.put("switchTeam", changeTeamNum+"%");//今年的转签量
        jo.put("switchHospital", changeHospNum+"%");//今年的转签量
        jo.put("switchTown", changeTownNum+"%");//今年的转签量
        jo.put("switchTeam", changeTeamNum + "%");//今年的转签量
        jo.put("switchHospital", changeHospNum + "%");//今年的转签量
        jo.put("switchTown", changeTownNum + "%");//今年的转签量
        return jo;
    }
@ -4156,9 +4164,9 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public String getRange(int first, int second, int i) {
        if(second==0&&first>0){
        if (second == 0 && first > 0) {
            return "100%";
        }else if(second==0&&first==0){
        } else if (second == 0 && first == 0) {
            return "0%";
        }
        float size = (float) (first * 100) / second;
@ -4168,15 +4176,15 @@ public class StatisticsService extends BaseService {
    }
    public String getRangeNoLast(int first, int second, int i) {
        if(second==0&&first>0){
        if (second == 0 && first > 0) {
            return "100";
        }else if(second==0&&first==0){
        } else if (second == 0 && first == 0) {
            return "0";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize ;
        return filesize;
    }
    public JSONObject getConsultingTitleAll(Integer level, String area, String year) {
@ -4280,9 +4288,9 @@ public class StatisticsService extends BaseService {
    public JSONObject getCoutListByTimeYear(String level, String area, String year) {
        JSONObject result = new JSONObject();
        List<WlyyQuotaResult> wlyyQuotaResult = findQuotaResults((Integer.valueOf(year) + 1) + "-06-30", Integer.valueOf(level), "24", area);
        JSONArray jo=new JSONArray();
        if (wlyyQuotaResult != null&&wlyyQuotaResult.size()>0) {
            wlyyQuotaResult.stream().forEach(one->{
        JSONArray jo = new JSONArray();
        if (wlyyQuotaResult != null && wlyyQuotaResult.size() > 0) {
            wlyyQuotaResult.stream().forEach(one -> {
                JSONObject temp1 = new JSONObject();
                temp1.put("name", one.getLevel2TypeName());
                temp1.put("code", getCodeByLevel(one, Integer.valueOf(level)));
@ -4428,21 +4436,21 @@ public class StatisticsService extends BaseService {
    public JSONObject getConsultingStatisticsListYear(Integer level, String area, String lowlevel, String year) {
        JSONObject result = new JSONObject();
        Integer coutYear = Integer.parseInt(year)+1;
        Integer coutYear = Integer.parseInt(year) + 1;
        //及时回复数
         JSONArray rely = getQuotaList(level,lowlevel,area,coutYear,23);
        if(rely==null){
        JSONArray rely = getQuotaList(level, lowlevel, area, coutYear, 23);
        if (rely == null) {
            return null;
        }
        //咨询总数
        JSONArray total = getQuotaList(level,lowlevel,area,coutYear,25);
        if(total==null){
        JSONArray total = getQuotaList(level, lowlevel, area, coutYear, 25);
        if (total == null) {
            return null;
        }
        //未回复数
        JSONArray onRely =getQuotaList(level,lowlevel,area,coutYear,22);
        if(total==null){
        JSONArray onRely = getQuotaList(level, lowlevel, area, coutYear, 22);
        if (total == null) {
            return null;
        }
        result.put("resultList", getCoutList(rely, total, onRely));
@ -4574,6 +4582,7 @@ public class StatisticsService extends BaseService {
     * 2.市级-机构
     * 3.区级-机构
     * 4.机构-团队
     *
     * @param level
     * @param lovlevel
     * @param area
@ -4581,35 +4590,35 @@ public class StatisticsService extends BaseService {
     * @param index
     * @return
     */
    public JSONArray getQuotaList(Integer level, String lovlevel, String area, Integer year, Integer index){
        String sql ;
        if(level==4){
            if(StringUtils.isBlank(lovlevel)){
    public JSONArray getQuotaList(Integer level, String lovlevel, String area, Integer year, Integer index) {
        String sql;
        if (level == 4) {
            if (StringUtils.isBlank(lovlevel)) {
                //市 区
                sql =" SELECT t.result As num,t.town_name AS name,t.town AS code,t.create_time AS date" +
                sql = " SELECT t.result As num,t.town_name AS name,t.town AS code,t.create_time AS date" +
                        " FROM wlyy_quota_result t " +
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='3'AND t.quota_date='"+year+"-06-30'";
            }else{
                        " WHERE t.city ='" + area + "' AND t.quato_code ='" + index + "' AND t.level1_type ='3'AND t.quota_date='" + year + "-06-30'";
            } else {
                //市 机构
                sql = "SELECT t.result As num,t.org_name AS name,t.org_code AS code,t.create_time AS date" +
                        " FROM wlyy_quota_result t " +
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND t.quota_date='"+year+"-06-30'";
                        " WHERE t.city ='" + area + "' AND t.quato_code ='" + index + "' AND t.level1_type ='2' AND t.quota_date='" + year + "-06-30'";
            }
        }else if (level ==3){
        } else if (level == 3) {
            //区 机构
            sql = "SELECT t.result As num,t.org_name AS name,t.org_code AS code,t.create_time AS date " +
                    "FROM wlyy_quota_result t " +
                    "WHERE t.town ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND t.quota_date='"+year+"-06-30'";
        }else{
                    "WHERE t.town ='" + area + "' AND t.quato_code ='" + index + "' AND t.level1_type ='2' AND t.quota_date='" + year + "-06-30'";
        } else {
            //机构 团队
            sql ="SELECT t.result As num,t.qkdoctor_name AS name,t.qkdoctor_code AS code,t.create_time AS date " +
            sql = "SELECT t.result As num,t.qkdoctor_name AS name,t.qkdoctor_code AS code,t.create_time AS date " +
                    " FROM wlyy_quota_result t " +
                    " WHERE t.org_code ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='1' AND t.quota_date='"+year+"-06-30'";
                    " WHERE t.org_code ='" + area + "' AND t.quato_code ='" + index + "' AND t.level1_type ='1' AND t.quota_date='" + year + "-06-30'";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list != null && list.size() > 0) {
            return new JSONArray(list);
        }else{
        } else {
            return null;
        }

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

@ -371,7 +371,7 @@ public class StatisticsController extends BaseController {
            if (StringUtils.isEmpty(lowCode)) {
                long sign = statisticsAllService.getIndexTotal(endDate, area, level, "13");
                long weiJf = statisticsAllService.getWeiJiaoFei(endDate, area, level);
               JSONObject jo = statisticsService.getRenewPercentAndChangePercent(level + "", area, Constant.getNowYear());
               JSONObject jo = statisticsService.getRenewPercentAndChangePercent(null,level + "", area, Constant.getNowYear());
                JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level);
                JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level);
@ -1392,6 +1392,7 @@ public class StatisticsController extends BaseController {
     * 获取转签率和续签率
     * 前端:续签进展
     *
     * @param index 42,43,44
     * @param level 等级  4 市  3区  2社区 1团队
     * @param code  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code
     * @param year  年份 非比传
@ -1400,12 +1401,13 @@ public class StatisticsController extends BaseController {
    @RequestMapping(value = "/getRenewPercentAndChangePercent", method = RequestMethod.GET)
    @ResponseBody
    public String getRenewPercentAndChangePercent(
            @RequestParam(required = true) String index,//续签index
            @RequestParam(required = true) String level,
            @RequestParam(required = true) String code,
            @RequestParam(required = false) String year) {
        try {
            return write(200, "查询成功", "data", statisticsService.getRenewPercentAndChangePercent(level, code, year));
            return write(200, "查询成功", "data", statisticsService.getRenewPercentAndChangePercent(index,level, code, year));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");