LAPTOP-KB9HII50\70708 10 mesiacov pred
rodič
commit
02e16d3300

+ 456 - 59
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -42,11 +42,13 @@ import java.text.SimpleDateFormat;
import java.time.*;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.time.format.TextStyle;
import java.time.temporal.WeekFields;
import java.util.*;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
/**
/**
 * Created by wangzhinan on 2019/12/3.
 * Created by wangzhinan on 2019/12/3.
@ -8578,23 +8580,28 @@ public class StatisticsEsService {
     * @param startDate
     * @param startDate
     * @param endDate
     * @param endDate
     * @param flag
     * @param flag
     * @param area
     * @return
     * @return
     */
     */
    public JSONObject getFollowUpHeaderTotal(String startDate,String endDate,Integer flag) {
    public JSONObject getFollowUpHeaderTotal(String startDate,String endDate,Integer flag,String deptCode) {
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        if (flag == 1) {
            startDate = DateUtil.getFirstMonthDay() + " 00:00:00";
            endDate = DateUtil.getLastMonthDay() + " 23:59:59";
        } else if (flag == 2) {
            startDate = DateUtil.getMonthDate(new Date(), -6) + " 00:00:00";
            endDate = DateUtil.getStringDateShort() + " 23:59:59";
        } else if (flag == 3) {
            startDate = DateUtil.getCurrentYearStartTime() + " 00:00:00";
            endDate = DateUtil.getCurrentYearEndTime() + " 23:59:59";
        }
        if(StringUtils.isBlank(startDate)){
            if (flag == 1) {
                startDate = DateUtil.getFirstMonthDay();
                endDate = DateUtil.getLastMonthDay();
            } else if (flag == 2) {
                startDate = DateUtil.getMonthDate(new Date(), -6) ;
                endDate = DateUtil.getStringDateShort();
            } else if (flag == 3) {
                startDate = DateUtil.getCurrentYearStartTime() ;
                endDate = DateUtil.getCurrentYearEndTime();
            }
        }
        endDate = endDate +" 23:59:59";
        //开通详情
        //开通详情
        String sql = "select dept_name,diagnosis_name from base_disease_hospital where status=1 and create_time>='"+startDate+"' and create_time <='"+endDate+"'";
        String sql = "select dept_name,diagnosis_name from base_disease_hospital where status=1 and create_time>='"+startDate+"' and create_time <='"+endDate+"'";
        if(StringUtils.isNotBlank(deptCode)){
            sql += " and dept like '%"+deptCode+"%'";
        }
        List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(sql);
        Set<String> deptSet = new HashSet<>();
        Set<String> deptSet = new HashSet<>();
        Set<String> diagnosisSet = new HashSet<>();
        Set<String> diagnosisSet = new HashSet<>();
@ -8614,28 +8621,25 @@ public class StatisticsEsService {
        jsonObject.put("diagnosisName",diagnosisSet);//开通的疾病
        jsonObject.put("diagnosisName",diagnosisSet);//开通的疾病
        //下转次数:
        //下转次数:
        String turnSql = "select count(1) as total  from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
        String turnSql = "select count(1) as total  from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
        if(StringUtils.isNotBlank(deptCode)){
            turnSql += " and dept = '"+deptCode+"' ";
        }
        String turnTotal = "0";
        String turnTotal = "0";
        String shoudongTurnTotal = "0";
        String shoudongTurnTotal = "0";
        String zidongTurnTotal = "0";
        String zidongTurnTotal = "0";
        Map<String,Object> turnMap = jdbcTemplate.queryForMap(turnSql);
        Map<String,Object> turnMap = jdbcTemplate.queryForMap(turnSql);
        if (turnMap!=null){
            if (turnMap.get("total")!=null){
                turnTotal = turnMap.get("total").toString();
            }
        if (turnMap.get("total")!=null){
            turnTotal = turnMap.get("total").toString();
        }
        }
        String zidongTurnSql = turnSql+" and from_source =2 ";
        String zidongTurnSql = turnSql+" and from_source =2 ";
        Map<String,Object> zidongTurnMap = jdbcTemplate.queryForMap(zidongTurnSql);
        Map<String,Object> zidongTurnMap = jdbcTemplate.queryForMap(zidongTurnSql);
        if (zidongTurnMap!=null){
            if (zidongTurnMap.get("total")!=null){
                zidongTurnTotal = zidongTurnMap.get("total").toString();
            }
        if (zidongTurnMap.get("total")!=null){
            zidongTurnTotal = zidongTurnMap.get("total").toString();
        }
        }
        String shoudongTurnSql = turnSql+ " and from_source=1 ";
        String shoudongTurnSql = turnSql+ " and from_source=1 ";
        Map<String,Object> shoudongTurnMap = jdbcTemplate.queryForMap(shoudongTurnSql);
        Map<String,Object> shoudongTurnMap = jdbcTemplate.queryForMap(shoudongTurnSql);
        if (shoudongTurnMap!=null){
            if (shoudongTurnMap.get("total")!=null){
                shoudongTurnTotal = shoudongTurnMap.get("total").toString();
            }
        if (shoudongTurnMap.get("total")!=null){
            shoudongTurnTotal = shoudongTurnMap.get("total").toString();
        }
        }
        jsonObject.put("zidongTurnTotal",zidongTurnTotal);//自动下转
        jsonObject.put("zidongTurnTotal",zidongTurnTotal);//自动下转
        jsonObject.put("shoudongTurnTotal",shoudongTurnTotal);//手动下转
        jsonObject.put("shoudongTurnTotal",shoudongTurnTotal);//手动下转
@ -8644,57 +8648,450 @@ public class StatisticsEsService {
        //下转人数
        //下转人数
        String turnPersonTotal = "0";
        String turnPersonTotal = "0";
        String turnPersonSql = "select count(DISTINCT patient) as total  from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
        String turnPersonSql = "select count(DISTINCT patient) as total  from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
        if(StringUtils.isNotBlank(deptCode)){
            turnPersonSql += " and dept = '"+deptCode+"' ";
        }
        Map<String,Object> turnPersonMap = jdbcTemplate.queryForMap(turnPersonSql);
        Map<String,Object> turnPersonMap = jdbcTemplate.queryForMap(turnPersonSql);
        if (turnPersonMap!=null){
            if (turnPersonMap.get("total")!=null){
                turnPersonTotal = turnPersonMap.get("total").toString();
            }
        if (turnPersonMap.get("total")!=null){
            turnPersonTotal = turnPersonMap.get("total").toString();
        }
        }
        //下转人数性别
        //下转人数性别
        String turnSexSql = "SELECT\n" +
                "\tcount(DISTINCT patient) AS total,\n" +
                "\tsex\n" +
                "FROM\n" +
                "\twlyy_rehabilitation_patient_info\n" +
                "WHERE\n" +
                "\tcreate_time >= '"+startDate+"'\n" +
                "AND create_time <= '"+endDate+"'\n" +
                "GROUP BY\n" +
                "\tsex";
        String turnSexSql = "SELECT count(DISTINCT patient) AS total, sex " +
                " FROM wlyy_rehabilitation_patient_info " +
                " WHERE create_time >= '"+startDate+"' " +
                "AND create_time <= '"+endDate+"' ";
        if(StringUtils.isNotBlank(deptCode)){
            turnSexSql += " and dept = '"+deptCode+"' ";
        }
        turnSexSql += " GROUP BY sex";
        List<Map<String,Object>> sexMapList = jdbcTemplate.queryForList(turnSexSql);
        List<Map<String,Object>> sexMapList = jdbcTemplate.queryForList(turnSexSql);
        for (Map<String,Object> map:sexMapList){
        for (Map<String,Object> map:sexMapList){
            if (map.get("sex")!=null){
                if (map.get("sex").toString().equalsIgnoreCase("1")){
                    map.put("sexName","男");
                }else if (map.get("sex").toString().equalsIgnoreCase("2")){
                    map.put("sexName","女");
                }else {
                    map.put("sexName","未知");
                }
            String sex = map.get("sex")+"";
            if("1".equals(sex)){
                map.put("sexName","男");
            }else if("2".equals(sex)){
                map.put("sexName","女");
            }else {
                map.put("sexName","未知");
            }
            }
        }
        }
        jsonObject.put("turnPersonTotal",turnPersonTotal);//下转人数
        jsonObject.put("turnPersonTotal",turnPersonTotal);//下转人数
        jsonObject.put("sexMapList",sexMapList);//性别分布
        jsonObject.put("sexMapList",sexMapList);//性别分布
        //随访次数
        //随访次数
        String followUpTotal = "0";//随访总次数
        String followUpTotal = "0";//随访总次数
        String followupSql = "select COUNT(1) total from wlyy_followup where followup_date >='"+startDate+"' and followup_date <='"+endDate+"'";
        Map<String,Object> followupMap = jdbcTemplate.queryForMap(followupSql);
        if (followupMap!=null){
            if (followupMap.get("total")!=null){
                followUpTotal = followupMap.get("total").toString();
            }
        }
        String followupCompleteTotal = "0";
        String followupCompleteTotal = "0";
        String followupCompleteSql = followupSql + " and status = 1 ";
        Map<String,Object> followupCompleteMap = jdbcTemplate.queryForMap(followupCompleteSql);
        if (followupCompleteMap!=null){
            if (followupCompleteMap.get("total")!=null){
                followupCompleteTotal = followupCompleteMap.get("total").toString();
            }
        String followupSql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum from wlyy_followup f" +
                " where f.followup_date >='"+startDate+"' and f.followup_date <='"+endDate+"' ";
        if(StringUtils.isNotBlank(deptCode)){
            followupSql += "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum from wlyy_followup f,base_doctor_hospital h " +
                    " where f.doctor_code=h.doctor_code and h.del=1 and h.dept_code='"+deptCode+"' " +
                    " and f.followup_date >='"+startDate+"' and f.followup_date <='"+endDate+"' ";
        }
        }
        Map<String,Object> followupMap = jdbcTemplate.queryForMap(followupSql);
        followUpTotal = followupMap.get("planNum").toString();
        followupCompleteTotal = followupMap.get("finishNum").toString();
        String rate = getTwoRange(Integer.parseInt(followupCompleteTotal),Integer.parseInt(followUpTotal),0);
        String rate = getTwoRange(Integer.parseInt(followupCompleteTotal),Integer.parseInt(followUpTotal),0);
        jsonObject.put("followupCompleteRate",rate);
        jsonObject.put("followupCompleteRate",rate);
        jsonObject.put("followupTotal",followUpTotal);
        jsonObject.put("followupTotal",followUpTotal);
        return jsonObject;
        return jsonObject;
    }
    }
    /**
     * 诊后康复服务分析
     *
     * @param startDate
     * @param endDate
     * @param flag 1本月 2半年 3年
     * @param timeType 1日 2周 3月
     */
    public List<Map<String,Object>> rehabilitationAnalysis(String startDate,String endDate,Integer flag,String timeType,String dept){
        List<Map<String,Object>> result = new ArrayList<>();
        if(StringUtils.isBlank(startDate)){
            if (flag == 1) {
                startDate = DateUtil.getFirstMonthDay();
                endDate = DateUtil.getLastMonthDay();
            } else if (flag == 2) {
                startDate = DateUtil.getMonthDate(new Date(), -6) ;
                endDate = DateUtil.getStringDateShort();
            } else if (flag == 3) {
                startDate = DateUtil.getCurrentYearStartTime() ;
                endDate = DateUtil.getCurrentYearEndTime();
            }
        }
        String endDateTmp = endDate;
        endDate = endDate +" 23:59:59";
        String dateColumn = "DATE_FORMAT(p.complete_time,'%Y-%m-%d')";
        String dateColumn2 = "DATE_FORMAT(i.czrq,'%Y-%m-%d')";
        if("2".equals(timeType)){
            dateColumn = "DATE_FORMAT(p.complete_time,'%Y-%u')";
            dateColumn2 = "DATE_FORMAT(i.czrq,'%Y-%u')";
        }else if("3".equals(timeType)){
            dateColumn = "DATE_FORMAT(p.complete_time,'%Y-%m')";
            dateColumn2 = "DATE_FORMAT(i.czrq,'%Y-%m')";
        }
        String sql = "select "+dateColumn+" date,COUNT(if(p.relation_type=1,1,null)) callNum " +
                ",COUNT(if(p.relation_type=2,1,null)) consultNum " +
                ",COUNT(if(p.relation_type=4,1,null)) doorNum ,COUNT(if(p.relation_type=5,1,null)) guidanceNum  " +
                ",COUNT(if(p.relation_type=6,1,null)) followupNum ,COUNT(if(p.relation_type=7,1,null)) visitNum  " +
                " from base_service_item_plan p where p.status=1 "+
                " and p.complete_time>='"+startDate+"' and p.complete_time<='"+endDate+"' GROUP BY date";
        if(StringUtils.isNotBlank(dept)){
            sql = "select "+dateColumn+" date,COUNT(if(p.relation_type=1,1,null)) callNum " +
                    ",COUNT(if(p.relation_type=2,1,null)) consultNum " +
                    ",COUNT(if(p.relation_type=4,1,null)) doorNum ,COUNT(if(p.relation_type=5,1,null)) guidanceNum  " +
                    ",COUNT(if(p.relation_type=6,1,null)) followupNum ,COUNT(if(p.relation_type=7,1,null)) visitNum  " +
                    " from base_service_item_plan p,base_doctor_hospital h where p.status=1 and p.doctor=h.doctor_code and h.del=1 and h.dept_code='"+dept+"' "+
                    " and p.complete_time>='"+startDate+"' and p.complete_time<='"+endDate+"' GROUP BY date";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Map<String,Object>> dateMap = list.stream().collect(Collectors.toMap(e -> e.get("date").toString(), v -> v, (p1, p2) -> p1));
        String sql2 = "SELECT COUNT(DISTINCT i.id) num,"+dateColumn2+" date " +
                " from wlyy_patient_health_index i,wlyy_patient_rehabilitation_plan p " +
                "WHERE i.`user`=p.patient and i.czrq>='"+startDate+"' and i.czrq<='"+endDate+"' " +
                "GROUP BY date";
        if(StringUtils.isNotBlank(dept)){
            sql2 = "SELECT COUNT(DISTINCT i.id) num,"+dateColumn2+" date " +
                    " from wlyy_patient_health_index i,wlyy_patient_rehabilitation_plan p,base_doctor_hospital h " +
                    "WHERE i.`user`=p.patient and p.plan_doctor=h.doctor_code and h.del=1 and h.dept_code='"+dept+"' " +
                    " and i.czrq>='"+startDate+"' and i.czrq<='"+endDate+"' GROUP BY date";
        }
        List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
        Map<String, String> healthMap = list2.stream().collect(Collectors.toMap(e -> e.get("date").toString(), e -> e.get("num").toString()));
        if("1".equals(timeType)){
            LocalDate startLocal = LocalDate.parse(startDate);
            LocalDate endLocal = LocalDate.parse(endDateTmp);
            while (!startLocal.isAfter(endLocal)) {
                String month = startLocal.toString();
                Map<String,Object> map = dateMap.get(month);
                String healthNum = healthMap.get(month);
                if(map == null){
                    map = new HashMap<>();
                    map.put("date",month);
                    map.put("callNum","0");
                    map.put("consultNum","0");
                    map.put("doorNum","0");
                    map.put("guidanceNum","0");
                    map.put("followupNum","0");
                    map.put("visitNum","0");
                }
                if(StringUtils.isBlank(healthNum)){
                    healthNum = "0";
                }
                map.put("healthNum",healthNum);
                result.add(map);
                startLocal = startLocal.plusDays(1);
            }
        }else if("2".equals(timeType)){
            String startWeek = getWeek(startDate,0);
            String endWeek = getWeek(endDateTmp,0);
            String currentWeek = getWeek(startDate,0);
            int i = 1;
            while (currentWeek.compareTo(endWeek)<=0) {
                Map<String,Object> map = dateMap.get(currentWeek);
                String healthNum = healthMap.get(currentWeek);
                if(map == null){
                    map = new HashMap<>();
                    map.put("date",currentWeek);
                    map.put("callNum","0");
                    map.put("consultNum","0");
                    map.put("doorNum","0");
                    map.put("guidanceNum","0");
                    map.put("followupNum","0");
                    map.put("visitNum","0");
                }
                if(StringUtils.isBlank(healthNum)){
                    healthNum = "0";
                }
                map.put("healthNum",healthNum);
                result.add(map);
                currentWeek = getWeek(startDate,i);
                i++;
            }
        }else {
            YearMonth startYearMonth = YearMonth.from(LocalDate.parse(startDate));
            YearMonth endYearMonth = YearMonth.from(LocalDate.parse(endDateTmp));
            YearMonth currentYearMonth = startYearMonth;
            while (!currentYearMonth.isAfter(endYearMonth)) {
                String month = currentYearMonth.toString();
                Map<String,Object> map = dateMap.get(month);
                String healthNum = healthMap.get(month);
                if(map == null){
                    map = new HashMap<>();
                    map.put("date",month);
                    map.put("callNum","0");
                    map.put("consultNum","0");
                    map.put("doorNum","0");
                    map.put("guidanceNum","0");
                    map.put("followupNum","0");
                    map.put("visitNum","0");
                }
                if(StringUtils.isBlank(healthNum)){
                    healthNum = "0";
                }
                map.put("healthNum",healthNum);
                result.add(map);
                currentYearMonth = currentYearMonth.plusMonths(1);
            }
        }
        return result;
    }
    public static String getWeek(String date,int addWeek) {
        LocalDate now = LocalDate.parse(date);
        if(addWeek>0){
            now = now.plusWeeks(addWeek);
        }
        String week = Integer.toString(now.get(WeekFields.ISO.weekOfYear()));
        if (week.length() == 1){
            week = "0" + week;
        }
        String year = Integer.toString(now.getYear());
        return year + week;
    }
    //诊后随访明细
    public List<Map<String,Object>> followupDetail(String startDate,String endDate,Integer flag,String sort){
        if(StringUtils.isBlank(sort)){
            sort = "complete";
        }
        if(StringUtils.isBlank(startDate)){
            if (flag == 1) {
                startDate = DateUtil.getFirstMonthDay();
                endDate = DateUtil.getLastMonthDay();
            } else if (flag == 2) {
                startDate = DateUtil.getMonthDate(new Date(), -6) ;
                endDate = DateUtil.getStringDateShort();
            } else if (flag == 3) {
                startDate = DateUtil.getCurrentYearStartTime() ;
                endDate = DateUtil.getCurrentYearEndTime();
            }
        }
        endDate = endDate +" 23:59:59";
        String sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum, " +
                "COUNT(if(f.`status`=1,if(f.followup_date<f.followup_plan_date,1,null ),null)) ontimeNum, " +
                "if(f.followup_date>=f.followup_plan_date,1,null ) overTimeNum,count(DISTINCT f.patient_code) patientNum " +
                ",f.doctor_name doctorName,h.dept_name deptName" +
                " from wlyy_followup f,base_doctor_hospital h " +
                "WHERE f.doctor_code=h.doctor_code and h.del=1 " +
                " and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' " +
                "GROUP BY f.doctor_name,h.dept_name ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        final String sortTmp = sort;
        Map<String, List<Map<String, Object>>> resList = list.stream().collect(Collectors.groupingBy(e -> e.get("deptName").toString()));
        List<Map<String,Object>> result = new ArrayList<>();
        for (Map.Entry<String, List<Map<String,Object>>> entry:resList.entrySet()){
            String key = entry.getKey();
            int planNumDept = 0;
            int finishNumDept = 0;
            int ontimeNumDept = 0;
            int overTimeNumDept = 0;
            int patientNumDept = 0;
            Map<String,Object> deptTmp = new HashMap<>();
            List<Map<String,Object>> value = entry.getValue();
            String dept = "";
            for (Map<String,Object> map:value){
                dept = map.get("dept")+"";
                int planNum = Integer.parseInt(map.get("planNum")+"");
                int finishNum = Integer.parseInt(map.get("finishNum")+"");
                int ontimeNum = Integer.parseInt(map.get("ontimeNum")+"");
                int overTimeNum = Integer.parseInt(map.get("overTimeNum")+"");
                int patientNum = Integer.parseInt(map.get("patientNum")+"");
                map.put("completeRate",getRange(finishNum, planNum,0));
                map.put("complete",getDoubleRange((double) finishNum, (double) planNum,0));
                planNumDept += planNum;
                finishNumDept += finishNum;
                ontimeNumDept += ontimeNum;
                overTimeNumDept += overTimeNum;
                patientNumDept += patientNum;
            }
            deptTmp.put("doctorName","-");
            deptTmp.put("deptName",key);
            deptTmp.put("planNum",planNumDept);
            deptTmp.put("finishNum",finishNumDept);
            deptTmp.put("ontimeNum",ontimeNumDept);
            deptTmp.put("overTimeNum",overTimeNumDept);
            deptTmp.put("patientNum",patientNumDept);
            deptTmp.put("completeRate",getRange(finishNumDept, planNumDept,0));
            deptTmp.put("complete",getDoubleRange((double) finishNumDept, (double) planNumDept,0));
            value.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
            deptTmp.put("list",value);
            deptTmp.put("hasChildren",false);
            if(value.size()>0){
                deptTmp.put("hasChildren",true);
            }
            result.add(deptTmp);
        }
        result.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
        return result;
    }
    public List<Map<String,Object>> exportFollowupDetail(String startDate,String endDate,Integer flag,String sort){
        if(StringUtils.isBlank(sort)){
            sort = "complete";
        }
        if(StringUtils.isBlank(startDate)){
            if (flag == 1) {
                startDate = DateUtil.getFirstMonthDay();
                endDate = DateUtil.getLastMonthDay();
            } else if (flag == 2) {
                startDate = DateUtil.getMonthDate(new Date(), -6) ;
                endDate = DateUtil.getStringDateShort();
            } else if (flag == 3) {
                startDate = DateUtil.getCurrentYearStartTime() ;
                endDate = DateUtil.getCurrentYearEndTime();
            }
        }
        endDate = endDate +" 23:59:59";
        String sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum, " +
                "COUNT(if(f.`status`=1,if(f.followup_date<f.followup_plan_date,1,null ),null)) ontimeNum, " +
                "if(f.followup_date>=f.followup_plan_date,1,null ) overTimeNum,count(DISTINCT f.patient_code) patientNum " +
                ",f.doctor_name doctorName,h.dept_name deptName" +
                " from wlyy_followup f,base_doctor_hospital h " +
                "WHERE f.doctor_code=h.doctor_code and h.del=1 " +
                " and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' " +
                "GROUP BY f.doctor_name,h.dept_name ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        final String sortTmp = sort;
        Map<String, List<Map<String, Object>>> resList = list.stream().collect(Collectors.groupingBy(e -> e.get("deptName").toString()));
        List<Map<String,Object>> tmpList = new ArrayList<>();
        List<Map<String,Object>> result = new ArrayList<>();
        for (Map.Entry<String, List<Map<String,Object>>> entry:resList.entrySet()){
            String key = entry.getKey();
            int planNumDept = 0;
            int finishNumDept = 0;
            int ontimeNumDept = 0;
            int overTimeNumDept = 0;
            int patientNumDept = 0;
            Map<String,Object> deptTmp = new HashMap<>();
            List<Map<String,Object>> value = entry.getValue();
            for (Map<String,Object> map:value){
                int planNum = Integer.parseInt(map.get("planNum")+"");
                int finishNum = Integer.parseInt(map.get("finishNum")+"");
                int ontimeNum = Integer.parseInt(map.get("ontimeNum")+"");
                int overTimeNum = Integer.parseInt(map.get("overTimeNum")+"");
                int patientNum = Integer.parseInt(map.get("patientNum")+"");
                map.put("completeRate",getRange(finishNum, planNum,0));
                map.put("complete",getDoubleRange((double) finishNum, (double) planNum,0));
                planNumDept += planNum;
                finishNumDept += finishNum;
                ontimeNumDept += ontimeNum;
                overTimeNumDept += overTimeNum;
                patientNumDept += patientNum;
            }
            deptTmp.put("doctorName","-");
            deptTmp.put("deptName",key);
            deptTmp.put("planNum",planNumDept);
            deptTmp.put("finishNum",finishNumDept);
            deptTmp.put("ontimeNum",ontimeNumDept);
            deptTmp.put("overTimeNum",overTimeNumDept);
            deptTmp.put("patientNum",patientNumDept);
            deptTmp.put("completeRate",getRange(finishNumDept, planNumDept,0));
            deptTmp.put("complete",getDoubleRange((double) finishNumDept, (double) planNumDept,0));
            value.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
            tmpList.add(deptTmp);
        }
        tmpList.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
        for (Map<String,Object> map:tmpList){
            result.add(map);
            String key = map.get("deptName")+"";
            List<Map<String,Object>> value = resList.get(key);
            if(value!=null){
                result.addAll(value);
            }
        }
        return result;
    }
    /**
     * 科室下转排行、诊断下转排行
     * @param startDate
     * @param endDate
     * @param flag
     * @param type 1科室 2诊断
     */
    public List<Map<String,Object>> tuanDownRanking(String startDate,String endDate,Integer flag,String type,String dept){
        if(StringUtils.isBlank(startDate)){
            if (flag == 1) {
                startDate = DateUtil.getFirstMonthDay();
                endDate = DateUtil.getLastMonthDay();
            } else if (flag == 2) {
                startDate = DateUtil.getMonthDate(new Date(), -6) ;
                endDate = DateUtil.getStringDateShort();
            } else if (flag == 3) {
                startDate = DateUtil.getCurrentYearStartTime() ;
                endDate = DateUtil.getCurrentYearEndTime();
            }
        }
        endDate = endDate +" 23:59:59";
        String column1 = "dept code,dept_name name";
        String column2 = "dept";
        if("2".equals(type)){
            column1 = "diagnosis code,diagnosis_name name";
            column2 = "diagnosis";
        }
        String sql = "SELECT "+column1+",COUNT(*) num from wlyy_rehabilitation_patient_info " +
                "WHERE `status` in (1,7)  and create_time>='"+startDate+"' and create_time<='"+endDate+"' ";
        if(StringUtils.isNotBlank(dept)){
            sql += " and dept = '"+ dept +"'";
        }
        sql += "  GROUP BY "+column2+" ORDER BY num  ";
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 科室随访排行、医生随访排行
     * @param startDate
     * @param endDate
     * @param flag
     * @param type 1科室 2医生
     */
    public List<Map<String,Object>> followupRanking(String startDate,String endDate,Integer flag,String type,String dept){
        if(StringUtils.isBlank(startDate)){
            if (flag == 1) {
                startDate = DateUtil.getFirstMonthDay();
                endDate = DateUtil.getLastMonthDay();
            } else if (flag == 2) {
                startDate = DateUtil.getMonthDate(new Date(), -6) ;
                endDate = DateUtil.getStringDateShort();
            } else if (flag == 3) {
                startDate = DateUtil.getCurrentYearStartTime() ;
                endDate = DateUtil.getCurrentYearEndTime();
            }
        }
        endDate = endDate +" 23:59:59";
        String sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum,h.dept_name name " +
                " from wlyy_followup f,base_doctor_hospital h " +
                "WHERE f.doctor_code=h.doctor_code and h.del=1 and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' ";
        if(StringUtils.isNotBlank(dept)){
            sql += " and h.dept_code = '"+ dept +"'";
        }
        sql += " GROUP BY h.dept_name ";
        if("2".equals(type)){
            sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum,f.doctor_name name " +
                    " from wlyy_followup f WHERE 1=1 and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"'" +
                    " GROUP BY f.doctor_name";
            if(StringUtils.isNotBlank(dept)){
                sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum,f.doctor_name name " +
                        " from wlyy_followup f,base_doctor_hospital h " +
                        "WHERE f.doctor_code=h.doctor_code and h.del=1 and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' "+
                        " and h.dept_code = '"+ dept +"' GROUP BY f.doctor_name";
            }
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            int planNum = Integer.parseInt(map.get("planNum")+"");
            int finishNum = Integer.parseInt(map.get("finishNum")+"");
            map.put("completeRate",getRange(finishNum, planNum,0));
            map.put("complete",getDoubleRange((double) finishNum, (double) planNum,0));
        }
        list.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get("complete")+"")));
        return list;
    }
}
}

+ 9 - 6
common/common-entity/src/db/2024.sql

@ -446,23 +446,26 @@ CREATE TABLE `wlyy_survey_third` (
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('surveyRecordStatus1', NULL, 'surveyRecordStatus', '0', '待接待', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
    ('surveyRecordStatus1', NULL, 'surveyRecordStatus', '0', '待接待', NULL, '1', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('surveyRecordStatus2', NULL, 'surveyRecordStatus', '1', '已接待', NULL, '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
    ('surveyRecordStatus2', NULL, 'surveyRecordStatus', '1', '已接待', NULL, '2', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('surveyRecordStatus3', NULL, 'surveyRecordStatus', '2', '患者拒诊', NULL, '3', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
    ('surveyRecordStatus3', NULL, 'surveyRecordStatus', '2', '患者拒诊', NULL, '3', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '疾病筛查接待状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('followup_status1', NULL, 'followup_status', '1', '已完成', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访状态');
    ('followup_status1', NULL, 'followup_status', '1', '已完成', NULL, '1', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('followup_status2', NULL, 'followup_status', '2', '未完成', NULL, '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访状态');
    ('followup_status2', NULL, 'followup_status', '2', '未完成', NULL, '2', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访状态');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`,
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
                                      `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES
    ('followup_businessSource', NULL, 'followup_businessSource', '1', '诊后康复', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访业务来源');
    ('followup_businessSource', NULL, 'followup_businessSource', '1', '诊后康复', NULL, '1', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访业务来源');

+ 144 - 5
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -15,9 +15,12 @@ import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.excel.ExportUtl;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -26,6 +29,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
import java.util.List;
@ -37,7 +41,6 @@ import java.util.Map;
 */
 */
@RestController
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Statistics.PREFIX)
@RequestMapping(value = BaseHospitalRequestMapping.Statistics.PREFIX)
//@RequestMapping("/open/statistics")
@Api(value = "统计分析", description = "统计分析", tags = {"统计分析"})
@Api(value = "统计分析", description = "统计分析", tags = {"统计分析"})
class EsStatisticsEndpoint extends EnvelopRestEndpoint {
class EsStatisticsEndpoint extends EnvelopRestEndpoint {
@ -54,6 +57,8 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ExportUtl exportUtl;
    @GetMapping(value = "findDeptWorkList")
    @GetMapping(value = "findDeptWorkList")
    @ApiOperation(value = "科室排班统计")
    @ApiOperation(value = "科室排班统计")
@ -2091,17 +2096,151 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getFollowUpHeaderTotal")
    @GetMapping(value = "getFollowUpHeaderTotal")
    @ApiOperation(value = "诊后随访统计--头部")
    @ApiOperation(value = "诊后随访统计--头部")
    public ObjEnvelop getFollowUpHeaderTotal(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD HH:MM:SS")
    public ObjEnvelop getFollowUpHeaderTotal(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD")
                                           @RequestParam(value = "startTime", required = false) String startTime,
                                           @RequestParam(value = "startTime", required = false) String startTime,
                                       @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD HH:MM:SS")
                                       @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD")
                                           @RequestParam(value = "endTime", required = false) String endTime,
                                           @RequestParam(value = "endTime", required = false) String endTime,
                                          @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义")
                                          @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义")
                                              @RequestParam(value = "flag", required = false) Integer flag) {
                                              @RequestParam(value = "flag", required = false) Integer flag,
                                             @ApiParam(name = "dept", value = "科室编码")
                                                 @RequestParam(value = "dept", required = false) String dept) {
        try {
        try {
            return ObjEnvelop.getSuccess("查询成功",statisticsEsService.getFollowUpHeaderTotal(startTime,endTime,flag));
            return ObjEnvelop.getSuccess("查询成功",statisticsEsService.getFollowUpHeaderTotal(startTime,endTime,flag,dept));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
            return ObjEnvelop.getError("查询失败");
        }
        }
    }
    }
    @GetMapping(value = "rehabilitationAnalysis")
    @ApiOperation(value = "诊后康复服务分析")
    public ListEnvelop rehabilitationAnalysis(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD")
                                             @RequestParam(value = "startTime", required = false) String startTime,
                                             @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD")
                                             @RequestParam(value = "endTime", required = false) String endTime,
                                             @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义")
                                             @RequestParam(value = "flag", required = false) Integer flag,
                                             @ApiParam(name = "timeType", value = "时间类型 1日 2周 3月")
                                                 @RequestParam(value = "timeType", required = false) String timeType,
                                             @ApiParam(name = "dept", value = "科室编码")
                                             @RequestParam(value = "dept", required = false) String dept) {
        try {
            return ListEnvelop.getSuccess("查询成功",statisticsEsService.rehabilitationAnalysis(startTime,endTime,flag,timeType,dept));
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "followupDetail")
    @ApiOperation(value = "诊后随访明细")
    public ListEnvelop followupDetail(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD")
                                             @RequestParam(value = "startTime", required = false) String startTime,
                                             @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD")
                                             @RequestParam(value = "endTime", required = false) String endTime,
                                             @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义")
                                             @RequestParam(value = "flag", required = false) Integer flag,
                                             @ApiParam(name = "sort", value = "排序 ")
                                             @RequestParam(value = "sort", required = false) String sort) {
        try {
            return ListEnvelop.getSuccess("查询成功",statisticsEsService.followupDetail(startTime,endTime,flag,sort));
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "exportFollowupDetail")
    @ApiOperation(value = " 导出诊后随访明细")
    public void exportFollowupList(
            @ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD") @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD") @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义") @RequestParam(value = "flag", required = false) Integer flag,
            @ApiParam(name = "sort", value = "排序 ") @RequestParam(value = "sort", required = false) String sort,
            HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = statisticsEsService.exportFollowupDetail(startTime,endTime,flag,sort);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("followupDetail.xls"));
            OutputStream os = response.getOutputStream();
            pushTotalExcel(os, list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void pushTotalExcel(OutputStream os, List<Map<String, Object>> list) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"科室", "医生", "计划随访数", "已随访数", "按时随访数", "逾期随访数", "随访完成率","随访人数"};
            int k = 0;
            for (String h : header) {
                exportUtl.addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            int i = 1;
            for (Map<String, Object> m : list) {
                exportUtl.addCell(ws, i, 0, m.get("deptName"));
                exportUtl.addCell(ws, i, 1, m.get("doctorName"));
                exportUtl.addCell(ws, i, 2, m.get("planNum"));
                exportUtl.addCell(ws, i, 3, m.get("finishNum"));
                exportUtl.addCell(ws, i, 4, m.get("ontimeNum"));
                exportUtl.addCell(ws, i, 5, m.get("overTimeNum"));
                exportUtl.addCell(ws, i, 6, m.get("completeRate"));
                exportUtl.addCell(ws, i, 7, m.get("patientNum"));
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    @GetMapping(value = "tuanDownRanking")
    @ApiOperation(value = "科室下转排行、诊断下转排行")
    public ListEnvelop tuanDownRanking(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD")
                                             @RequestParam(value = "startTime", required = false) String startTime,
                                             @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD")
                                             @RequestParam(value = "endTime", required = false) String endTime,
                                             @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义")
                                             @RequestParam(value = "flag", required = false) Integer flag,
                                       @ApiParam(name = "type", value = "1科室 2诊断")
                                           @RequestParam(value = "type", required = false) String type,
                                             @ApiParam(name = "dept", value = "科室编码")
                                             @RequestParam(value = "dept", required = false) String dept) {
        try {
            return ListEnvelop.getSuccess("查询成功",statisticsEsService.tuanDownRanking(startTime,endTime,flag,type,dept));
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "followupRanking")
    @ApiOperation(value = "科室随访排行、医生随访排行")
    public ListEnvelop followupRanking(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD")
                                             @RequestParam(value = "startTime", required = false) String startTime,
                                             @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD")
                                             @RequestParam(value = "endTime", required = false) String endTime,
                                             @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义")
                                             @RequestParam(value = "flag", required = false) Integer flag,
                                       @ApiParam(name = "type", value = "1科室 2医生")
                                           @RequestParam(value = "type", required = false) String type,
                                             @ApiParam(name = "dept", value = "科室编码")
                                             @RequestParam(value = "dept", required = false) String dept) {
        try {
            return ListEnvelop.getSuccess("查询成功",statisticsEsService.followupRanking(startTime,endTime,flag,type,dept));
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
}
}

+ 3 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowUpController.java

@ -62,6 +62,7 @@ public class DoctorFollowUpController extends BaseController {
            @ApiParam(value = "业务类型,全部及存在数据的专病名称") @RequestParam(value = "businessType", required = false) String businessType,
            @ApiParam(value = "业务类型,全部及存在数据的专病名称") @RequestParam(value = "businessType", required = false) String businessType,
            @ApiParam(value = "业务来源的选项为:全部来源、诊后康复(其余选项待后期新增)") @RequestParam(value = "businessSource", required = false) String businessSource,
            @ApiParam(value = "业务来源的选项为:全部来源、诊后康复(其余选项待后期新增)") @RequestParam(value = "businessSource", required = false) String businessSource,
            @ApiParam(value = "居民姓名") @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(value = "居民姓名") @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(value = "居民姓名或者医生姓名") @RequestParam(value = "keyName", required = false) String keyName,
            @ApiParam(value = "当前页") @RequestParam(value = "page") Integer page,
            @ApiParam(value = "当前页") @RequestParam(value = "page") Integer page,
            @ApiParam(value = "显示记录数") @RequestParam(value = "size") Integer size,
            @ApiParam(value = "显示记录数") @RequestParam(value = "size") Integer size,
            @ApiParam(value = "随访状态:全部状态、2未完成、1已完成") @RequestParam(value = "followupStatus", required = false) String followupStatus,
            @ApiParam(value = "随访状态:全部状态、2未完成、1已完成") @RequestParam(value = "followupStatus", required = false) String followupStatus,
@ -69,7 +70,7 @@ public class DoctorFollowUpController extends BaseController {
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate) {
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate) {
        try {
        try {
            return followUpService.followupPage(businessType, businessSource, startDate, endDate, patientName,
            return followUpService.followupPage(businessType, businessSource, startDate, endDate, patientName,keyName,
                    followupStatus,doctorName, page, size);
                    followupStatus,doctorName, page, size);
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
@ -93,7 +94,7 @@ public class DoctorFollowUpController extends BaseController {
            List<Map<String, Object>> list = followUpService.followupList(businessType, businessSource, startDate, endDate, patientName,
            List<Map<String, Object>> list = followUpService.followupList(businessType, businessSource, startDate, endDate, patientName,
                    followupStatus,doctorName);
                    followupStatus,doctorName);
            response.setContentType("octets/stream");
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("surveyRecordExcel.xls"));
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("followupPage.xls"));
            OutputStream os = response.getOutputStream();
            OutputStream os = response.getOutputStream();
            pushTotalExcel(os, list);
            pushTotalExcel(os, list);
        } catch (Exception e) {
        } catch (Exception e) {

+ 6 - 3
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowUpService.java

@ -90,8 +90,8 @@ public class FollowUpService {
    //随访记录列表
    //随访记录列表
    public PageEnvelop followupPage(String businessType, String businessSource, String startDate, String endDate, String patientName,
    public PageEnvelop followupPage(String businessType, String businessSource, String startDate, String endDate, String patientName,
                                    String followupStatus,String doctorName, Integer page, Integer size){
        String sql = "SELECT DISTINCT f.id,f.patient_name patientName,f.patient_code patientCode,p.idcard,p.birthday,p.sex,p.mobile, " +
                                    String keyName,String followupStatus,String doctorName, Integer page, Integer size){
        String sql = "SELECT DISTINCT f.id,f.patient_name patientName,f.patient_code patientCode,p.photo,p.idcard,p.birthday,p.sex,p.mobile, " +
                "f.doctor_code doctorCode,f.doctor_name doctorName,pl.disease_name businessTypeName,pl.disease businessType, " +
                "f.doctor_code doctorCode,f.doctor_name doctorName,pl.disease_name businessTypeName,pl.disease businessType, " +
                "h.dept_code deptCode,h.dept_name deptName,f.`status`,date_format(f.followup_date, '%Y-%m-%d %H:%i:%s') followupDate,'诊后康复' businessSource," +
                "h.dept_code deptCode,h.dept_name deptName,f.`status`,date_format(f.followup_date, '%Y-%m-%d %H:%i:%s') followupDate,'诊后康复' businessSource," +
                "date_format(f.followup_plan_date, '%Y-%m-%d %H:%i:%s') followupPlanDate,date_format(pl.create_time, '%Y-%m-%d %H:%i:%s') turnDownDate," +
                "date_format(f.followup_plan_date, '%Y-%m-%d %H:%i:%s') followupPlanDate,date_format(pl.create_time, '%Y-%m-%d %H:%i:%s') turnDownDate," +
@ -118,7 +118,10 @@ public class FollowUpService {
            filter += " and f.status='"+followupStatus+"' ";
            filter += " and f.status='"+followupStatus+"' ";
        }
        }
        if(StringUtils.isNotBlank(doctorName)){
        if(StringUtils.isNotBlank(doctorName)){
            sql += " and f.doctor_name like '%"+doctorName+"%' ";
            filter += " and f.doctor_name like '%"+doctorName+"%' ";
        }
        if(StringUtils.isNotBlank(keyName)){
            filter += " and (f.doctor_name like '%"+keyName+"%' or f.patient_name like '%" + keyName + "%') ";
        }
        }
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
            filter += " and f.followup_date>='"+startDate+"' ";
            filter += " and f.followup_date>='"+startDate+"' ";