Procházet zdrojové kódy

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

yeshijie před 7 roky
rodič
revize
4dc885ccf6

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

@ -3089,29 +3089,27 @@ public class StatisticsService extends BaseService {
        if ("0".equals(type)) {
            //按周
            totalSQL = "SELECT " +
                    " left(w.create_time,10) AS dateNo,COUNT(1) AS followupCount " +
                    " left('?0',10) AS dateNo,COUNT(1) AS followupCount " +
                    " FROM " +
                    " wlyy_followup w " +
                    " WHERE " +
                    " w.admin_team_code =" + teamCode +
                    " AND w.doctor_code ='" + doctor + "'" +
                    " AND w.create_time >= '" + startDateStr + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " GROUP BY dateNo";
                    " AND w.create_time >= '?1' " +
                    " AND w.create_time <= '?2' ";
            planSQL = "SELECT " +
                    " left(w.create_time,10) AS dateNo,COUNT(1) AS planCount " +
                    " left('?0',10) AS dateNo,COUNT(1) AS planCount " +
                    " FROM " +
                    " wlyy_followup w " +
                    " WHERE " +
                    " w.admin_team_code =" + teamCode +
                    " AND w.doctor_code ='" + doctor + "'" +
                    " AND w.create_time >= '" + startDateStr + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " GROUP BY dateNo";
            totalList = jdbcTemplate.queryForList(totalSQL);
             planList = jdbcTemplate.queryForList(planSQL);
                    " AND w.create_time >= '?1' " +
                    " AND w.create_time <= '?2' " +
                    " AND w.status ='2'";
             totalList = getGZBGDataWeekLineForEs(startDate,endDate,totalSQL);
             planList = getGZBGDataWeekLineForEs(startDate,endDate,planSQL);
        } else {
            //按月
            totalSQL = "SELECT " +
@ -3512,16 +3510,15 @@ public class StatisticsService extends BaseService {
        if ("0".equals(type)) {
            //查周
            totalSql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS reservationCount " +
                    " left('?0',10) AS dateNo,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " + teamCode +
                    " AND w.doctor = '" + doctor + "'" +
                    " AND w.czrq <= '" + endDate + "' " +
                    " AND w.czrq >= '" + startDateStr + "' " +
                    " GROUP BY dateNo";
            resultList = jdbcTemplate.queryForList(totalSql);
                    " AND w.czrq >= '?1' " +
                    " AND w.czrq <= '?2' " ;
            resultList = getGZBGDataWeekLineForEs(startDate,endDate,totalSql);
        } else {
            //查月份
            totalSql = "SELECT " +
@ -3731,42 +3728,28 @@ public class StatisticsService extends BaseService {
    }
    public JSONArray getTeamDoctorGuidLine(String teamCode, String startDate, String endDate, String type, String doctor) {
        //如果开始时间是当月的最后一天,则到当天的下午五点
        String endStr = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        if (endStr.equals(endDate)){
            endDate = endDate + " 17:00:00";
        }else{
            endDate = endDate + " 23:59:59";
        }
        //如果是本月第一天则开始时间为上个月最后一天的下午五点
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        boolean flag = DateUtil.checkFristDayOfDateMonth(cal);
        if (flag){
            startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        }else{
            startDate = startDate + " 00:00:00";
        }
        String startDateStr = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        endDate = endDate + " 17:00:00";
        List<Map<String, Object>> totalList = new ArrayList<>();
        String SQL;
        if ("0".equals(type)) {
            //按周统计
            SQL = "SELECT " +
                    " left(w.create_time,10) AS dateNo, " +
                    " left('?0',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.create_time <= '" + endDate + "' " +
                    " AND w.create_time >= '" + startDate + "' " +
                    " GROUP BY dateNo";
                    " AND w.create_time >= '?1' " +
                    " AND w.create_time <= '?2' ";
            totalList = getGZBGDataWeekLineForEs(startDate,endDate,SQL);
        } else {
            //按月统计
            SQL = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDate + "', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDateStr + "', '%v') + 1 " +
                    " ) AS weekOfMonth, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
@ -3774,31 +3757,16 @@ public class StatisticsService extends BaseService {
                    " WHERE " +
                    " w.admin_team_code =" + teamCode +
                    " AND w.doctor ='" + doctor + "'" +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.create_time >= '" + startDate + "' " +
                    " GROUP BY weekOfMonth";
                    " AND w.create_time >= '?1' " +
                    " AND w.create_time <= '?2' " ;
            totalList = getGZBGDataMonthLineForEs(startDate,endDate,startDateStr,SQL);
        }
        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) {
        //如果开始时间是当月的最后一天,则到当天的下午五点
        String endStr = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        if (endStr.equals(endDate)){
            endDate = endDate + " 17:00:00";
        }else{
            endDate = endDate + " 23:59:59";
        }
        //如果是本月第一天则开始时间为上个月最后一天的下午五点
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        boolean flag = DateUtil.checkFristDayOfDateMonth(cal);
        if (flag){
            startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        }else{
            startDate = startDate + " 00:00:00";
        }
        startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        endDate = endDate + " 17:00:00";
        String totalSql = "SELECT " +
                " IFNULL(c.guidanceCount,0) AS guidanceCount, " +
@ -3908,22 +3876,8 @@ public class StatisticsService extends BaseService {
    }
    public JSONObject getTeamDoctorGuiTitle(String teamCode, String doctor, String startDate, String endDate) {
        //如果开始时间是当月的最后一天,则到当天的下午五点
        String endStr = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        if (endStr.equals(endDate)){
            endDate = endDate + " 17:00:00";
        }else{
            endDate = endDate + " 23:59:59";
        }
        //如果是本月第一天则开始时间为上个月最后一天的下午五点
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        boolean flag = DateUtil.checkFristDayOfDateMonth(cal);
        if (flag){
            startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        }else{
            startDate = startDate + " 00:00:00";
        }
        startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        endDate = endDate + " 17:00:00";
        String totalSQL = "SELECT " +
                " COUNT(1) AS guidanceCount " +
@ -3967,7 +3921,6 @@ public class StatisticsService extends BaseService {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 00:00:00";
        String sql;
        if ("0".equals(type)) {
            //按周统计
            sql = "SELECT " +
@ -3997,72 +3950,44 @@ public class StatisticsService extends BaseService {
    }
    public JSONArray getTeamDoctorEduLine(String teamCode, String startDate, String endDate, String type, String doctor) {
        //如果开始时间是当月的最后一天,则到当天的下午五点
        String endStr = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        if (endStr.equals(endDate)){
            endDate = endDate + " 17:00:00";
        }else{
            endDate = endDate + " 23:59:59";
        }
        //如果是本月第一天则开始时间为上个月最后一天的下午五点
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        boolean flag = DateUtil.checkFristDayOfDateMonth(cal);
        if (flag){
            startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        }else{
            startDate = startDate + " 00:00:00";
        }
        String startDateStr = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        endDate = endDate + " 17:00:00";
        List<Map<String, Object>> list = new ArrayList<>();
        String sql;
        if ("0".equals(type)) {
            //按周统计
            sql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchCount " +
                    " left('?0',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";
                    " AND w.czrq >= '?1' " +
                    " AND w.czrq <= '?2' ";
            list = getGZBGDataWeekLineForEs(startDate,endDate,sql);
        } else {
            sql = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('" + startDate + "', '%v') + 1 " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('" + startDateStr + "', '%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";
                    " AND w.czrq >= '?1' " +
                    " AND w.czrq <= '?2' ";
            list = getGZBGDataMonthLineForEs(startDate,endDate,startDateStr,sql);
        }
        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) {
        //如果开始时间是当月的最后一天,则到当天的下午五点
        String endStr = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        if (endStr.equals(endDate)){
            endDate = endDate + " 17:00:00";
        }else{
            endDate = endDate + " 23:59:59";
        }
        //如果是本月第一天则开始时间为上个月最后一天的下午五点
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        boolean flag = DateUtil.checkFristDayOfDateMonth(cal);
        if (flag){
           startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        }else{
            startDate = startDate + " 00:00:00";
        }
        startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        endDate = endDate + " 17:00:00";
        String totalSql = "SELECT " +
                " IFNULL(c.articleCount,0) AS articleCount, " +
@ -4199,22 +4124,8 @@ public class StatisticsService extends BaseService {
    }
    public JSONObject getTeamDoctorEduTitle(String teamCode, String startDate, String endDate, String doctor) {
        //如果开始时间是当月的最后一天,则到当天的下午五点
        String endStr = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        if (endStr.equals(endDate)){
            endDate = endDate + " 17:00:00";
        }else{
            endDate = endDate + " 23:59:59";
        }
        //如果是本月第一天则开始时间为上个月最后一天的下午五点
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(startDate,"yyyy-MM-dd"));
        boolean flag = DateUtil.checkFristDayOfDateMonth(cal);
        if (flag){
            startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        }else{
            startDate = startDate + " 00:00:00";
        }
        startDate = DateUtil.getNextDay(startDate,-1)+" 17:00:00";
        endDate = endDate + " 17:00:00";
        String totalSql = "SELECT " +
                " COUNT(1) AS articleCount, " +
@ -6957,7 +6868,7 @@ public class StatisticsService extends BaseService {
    }
    /**
     * 工作报告医生个人详情折线图--按照月份的公用方法(为了解决与es的数据冲突).
     * 工作报告医生个人详情折线图--按照月份的公用方法(为了解决与es的数据冲突)
     * @param startDate
     * @param endDate
     * @param startDateStr
@ -7000,5 +6911,40 @@ public class StatisticsService extends BaseService {
        }
        return resultList;
    }
    /**
     * 工作报告医生个人详情折线图--按照周的公用方法(为了解决与es的数据冲突)
     * @param startDate
     * @param endDate
     * @param sql
     * @return
     */
    public List<Map<String,Object>> getGZBGDataWeekLineForEs(String startDate,String endDate,String sql){
        List<Map<String, Object>> resultList  = new ArrayList<>();
        List<Map<String,Object>> dateList = DateUtil.findDates(DateUtil.strToDate(startDate),DateUtil.strToDate(endDate));
        //以每天的17:00:00为时间的边界设置每天的起始时间和结束时间查询数据库
        if (dateList!=null && dateList.size()>0) {
            for (Map<String, Object> map : dateList) {
                String resultSql = sql;
                String endTime = String.valueOf(map.get("date"))+" 17:00:00";
                String startTime = DateUtil.getNextDay(DateUtil.strToDate(endTime),-1)+" 17:00:00";
                resultSql = resultSql.replace("?0",endTime);
                resultSql = resultSql.replace("?1",startTime);
                resultSql = resultSql.replace("?2",endTime);
                List<Map<String, Object>> list = jdbcTemplate.queryForList(resultSql);
                //放入结果集
                if (list!=null && list.size()>0){
                    for(Map<String,Object> reMap : list){
                        if (reMap.get("dateNo")!=null){
                            resultList.add(reMap);
                        }
                    }
                }
            }
        }
        return resultList;
    }
}

+ 10 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -89,8 +89,14 @@ public class EsStatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            if (index != null) {
                for (String idx : indexes) {
                    result.put("index_" + idx, statisticsESService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx, level2_type));
//                    result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, Integer.parseInt(interval), area, level, idx, level2_type));
                    if ("4".equals(idx)){
                        //2017-12-20 修改总体分析里的随访量为到达量
                        String year = Constant.getNowYear();
                        result.put("index_" + idx, statisticsESService.getDateTotal(startDate, endDate, Integer.valueOf(interval), area, level, idx, level2_type, year));
                    }else{
                        result.put("index_" + idx, statisticsESService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx, level2_type));
//                      result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, Integer.parseInt(interval), area, level, idx, level2_type));
                    }
                }
            }
@ -164,8 +170,9 @@ public class EsStatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                if("3".equals(idx)){
                if("3".equals(idx) || "4".equals(idx)){
                    //为了确保之前是咨询量是准确的 所以咨询量用到达量不用增量累加
                    //2017-12-20 修改总体分析里的随访量为到达量
                    result.put("index_" + idx, statisticsESService.getTotalAmount3(startDate, endDate, area, level, idx, level2_type));
                }else{
                    result.put("index_" + idx, statisticsESService.getTotalAmount(startDate, endDate, area, level, idx, level2_type));