wangzhinan пре 5 година
родитељ
комит
02a6df8a24

+ 527 - 10
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -1,15 +1,28 @@
package com.yihu.jw.es.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.google.common.annotations.VisibleForTesting;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import jdk.management.resource.internal.inst.FileOutputStreamRMHooks;
import org.apache.commons.lang3.StringUtils;
import org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParametersFactory;
import org.omg.CORBA.OBJ_ADAPTER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -29,6 +42,10 @@ public class StatisticsEsService {
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    /**
@ -98,6 +115,93 @@ public class StatisticsEsService {
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
        }
        if (StringUtils.isNoneBlank(level2_type)){
            //问诊量表格
            //专家咨询数量
            List<SaveModel> specialistSaveModels = elasticsearchUtil.findDateQuotaLevel0(endDate, endDate, area, level, "4", SaveModel.timeLevel_DDL,null,level2_type);
            //协同门诊
            List<SaveModel> syngySaveModels = elasticsearchUtil.findDateQuotaLevel1(endDate, endDate, area, level, "1", SaveModel.timeLevel_DDL,"2",null,level2_type);
            //图文复诊
            List<SaveModel> topicSaveModels = elasticsearchUtil.findDateQuotaLevel2(endDate, endDate, area, level, "1", SaveModel.timeLevel_DDL,"1","1",null,level2_type);
            ///视频复诊
            List<SaveModel> vedioSaveModels = elasticsearchUtil.findDateQuotaLevel2(endDate, endDate, area, level, "1", SaveModel.timeLevel_DDL,"1","2",null,level2_type);
            JSONArray array = new JSONArray();
            List<String> list = new ArrayList<>();
            for (SaveModel saveModel:specialistSaveModels){
                if (level2_type.equals(SaveModel.deptLevel)){
                    list.add(saveModel.getDept());
                }else if (level2_type.equals(SaveModel.doctorLevel)){
                    list.add(saveModel.getDoctor());
                }
            }
            for (int i=0;i<list.size();i++){
                String code = list.get(i);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("code",code);
                for (SaveModel saveModel:specialistSaveModels){
                    if (level2_type.equals(SaveModel.deptLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("specialist",saveModel.getResult1());
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.doctorLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDoctor())){
                            jsonObject.put("name",saveModel.getDoctorName());
                            jsonObject.put("specialist",saveModel.getResult1());
                            break;
                        }
                    }
                }
                for (SaveModel saveModel:syngySaveModels){
                    if (level2_type.equals(SaveModel.deptLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("synegy",saveModel.getResult1());
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.doctorLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDoctor())){
                            jsonObject.put("name",saveModel.getDoctorName());
                            jsonObject.put("synegy",saveModel.getResult1());
                            break;
                        }
                    }
                }
                for (SaveModel saveModel:topicSaveModels){
                    if (level2_type.equals(SaveModel.deptLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("topic",saveModel.getResult1());
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.doctorLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDoctor())){
                            jsonObject.put("name",saveModel.getDoctorName());
                            jsonObject.put("topic",saveModel.getResult1());
                            break;
                        }
                    }
                }
                for (SaveModel saveModel:vedioSaveModels){
                    if (level2_type.equals(SaveModel.deptLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDept())){
                            jsonObject.put("name",saveModel.getDeptName());
                            jsonObject.put("vedio",saveModel.getResult1());
                            break;
                        }
                    }else if (level2_type.equals(SaveModel.doctorLevel)){
                        if (code.equalsIgnoreCase(saveModel.getDoctor())){
                            jsonObject.put("name",saveModel.getDoctorName());
                            jsonObject.put("vedio",saveModel.getResult1());
                            break;
                        }
                    }
                }
                array.add(jsonObject);
            }
            object.put("excelData",array);
        }
        return object;
    }
@ -140,13 +244,13 @@ public class StatisticsEsService {
        int videoCount = saveModel3.getResult2().intValue();//视频复诊数量
        int total = specialistCount+synergyCount+topicCount+videoCount;//总量
        object.put("specialistCount",specialistCount);//专家咨询数
        object.put("specialistRate",getRange(specialistCount,total,2));
        object.put("specialistRate",getRange(specialistCount,total,0));
        object.put("synergyCount",synergyCount);//专家咨询数
        object.put("synergyRate",getRange(synergyCount,total,2));
        object.put("synergyRate",getRange(synergyCount,total,0));
        object.put("topicCount",topicCount);//图文复诊数量
        object.put("topicRate",getRange(topicCount,total,2));
        object.put("topicRate",getRange(topicCount,total,0));
        object.put("videoCount",videoCount);//视频复诊数量
        object.put("videoRate",getRange(videoCount,total,2));
        object.put("videoRate",getRange(videoCount,total,0));
        object.put("total",total);
        return object;
    }
@ -166,6 +270,12 @@ public class StatisticsEsService {
    public JSONObject getOutPatientGrade(String startDate, String endDate, String area, int level, String index, String level2_type) throws Exception {
        JSONObject object = new JSONObject();
        //问诊总量
        SaveModel saveModel1 = null;
        saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL);
        int total = saveModel1.getResult1().intValue();
        List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(endDate,endDate,area,level,index,SaveModel.timeLevel_DDL,null,level2_type);
        List<JSONObject> result = new ArrayList<>();
@ -182,6 +292,7 @@ public class StatisticsEsService {
                object1.put("hospitalName",saveModel.getHospitalName());
            }
            object1.put("result1",saveModel.getResult1());
            object1.put("rate",getRange(saveModel.getResult1().intValue(),total,0));
            object1.put("result2",saveModel.getResult2());
            result.add(object1);
        }
@ -190,9 +301,9 @@ public class StatisticsEsService {
            @Override
            public int compare(JSONObject o1, JSONObject o2) {
                if (o1.getString("result1").compareTo(o2.getString("result1")) > 0) {
                    return 1;
                } else if (o1.getString("result1").compareTo(o2.getString("result1")) < 0) {
                    return -1;
                } else if (o1.getString("result1").compareTo(o2.getString("result1")) < 0) {
                    return 1;
                } else {
                    return 0;
                }
@ -235,7 +346,413 @@ public class StatisticsEsService {
    }
    public JSONObject getDoctorStatistics(String startDate, String endDate, String area, int level, String index, String level2_type,Integer flag) throws Exception {
        String sql = null;
        JSONObject object1= new JSONObject();
        if (flag==1){
            sql="SELECT dhd.CODE AS dept_code, dhd. NAME AS dept_name, CASE WHEN c. COUNT IS NOT NULL THEN " +
                    "c. COUNT ELSE 0 END AS COUNT FROM DICT_HOSPITAL_DEPT dhd " +
                    "LEFT JOIN ( SELECT dh.DEPT_CODE, hd. NAME AS dept_name, " +
                    "COUNT(dh.DOCTOR_CODE) AS COUNT FROM BASE_DOCTOR bd " +
                    "LEFT JOIN BASE_DOCTOR_HOSPITAL dh ON bd. ID = dh.DOCTOR_CODE " +
                    "RIGHT JOIN DICT_HOSPITAL_DEPT hd ON hd.CODE = dh.DEPT_CODE " +
                    "WHERE bd.DEL = 1 AND bd.OUTPATIENT_TYPE IS NOT NULL GROUP BY dh.DEPT_CODE, hd. NAME " +
                    "ORDER BY COUNT DESC ) c ON dhd.CODE = c.DEPT_CODE " +
                    "WHERE dhd.CONSULT_DEPT_FLAG='1' " +
                    "ORDER BY count desc";
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
            JSONArray array = new JSONArray();
            for (Map<String,Object> map:mapList){
                JSONObject object = new JSONObject();
                if (array!=null&&array.size()!=0){
                    JSONObject jsonObject = array.getJSONObject(array.size()-1);
                    object.put("deptCode",map.get("dept_code"));
                    object.put("deptName",map.get("dept_name"));
                    object.put("count",map.get("count"));
                    if (jsonObject.getInteger("count")==Integer.parseInt(map.get("count").toString())){
                        object.put("rank",jsonObject.getInteger("rank"));
                    }else if (jsonObject.getInteger("count")>Integer.parseInt(map.get("count").toString())){
                        object.put("rank",jsonObject.getInteger("rank")+1);
                    }
                }else {
                    object.put("deptCode",map.get("dept_code"));
                    object.put("deptName",map.get("dept_name"));
                    object.put("count",map.get("count"));
                    object.put("rank",1);
                }
                array.add(object);
            }
            object1.put("data",array);//排名
        }else if (flag ==2) {
            List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, null, "6");
            String deptSql = "select hd.CODE,hd.NAME from DICT_HOSPITAL_DEPT hd where hd.ORG_CODE ='" + area + "' and CONSULT_DEPT_FLAG=1";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(deptSql);
            List<JSONObject> result = new ArrayList<>();
            for (SaveModel saveModel : saveModels) {
                List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = doctorHospitalDao.findByDoctorCode(saveModel.getDoctor());
                if (baseDoctorHospitalDOS != null && baseDoctorHospitalDOS.size() != 0) {
                    saveModel.setDept(baseDoctorHospitalDOS.get(0).getDeptCode());
                    saveModel.setDeptName(baseDoctorHospitalDOS.get(0).getDeptName());
                }
            }
            for (Map<String, Object> map : mapList) {
                JSONObject object = new JSONObject();
                String code = map.get("code").toString();
                object.put("deptCode", map.get("code"));
                object.put("deptName", map.get("name"));
                Integer count = 0;
                for (SaveModel saveModel : saveModels) {
                    if (saveModel.getDept().equalsIgnoreCase(code)) {
                        if (saveModel.getResult1() > 0) {
                            count += 1;
                        }
                    }
                }
                object.put("count", count);
                result.add(object);
            }
            // 排序
            result.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("count").compareTo(o2.getString("count")) > 0) {
                        return -1;
                    } else if (o1.getString("count").compareTo(o2.getString("count")) < 0) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
            });
            JSONArray array = new JSONArray();
            for (JSONObject map:result){
                JSONObject object = new JSONObject();
                if (array!=null&&array.size()!=0){
                    JSONObject jsonObject = array.getJSONObject(array.size()-1);
                    object.put("deptCode",map.getString("deptCode"));
                    object.put("deptName",map.getString("deptName"));
                    object.put("count",map.getInteger("count"));
                    if (jsonObject.getInteger("count")==map.getInteger("count")){
                        object.put("rank",jsonObject.getInteger("rank"));
                    }else if (jsonObject.getInteger("count")>map.getInteger("count")){
                        object.put("rank",jsonObject.getInteger("rank")+1);
                    }
                }else {
                    object.put("deptCode",map.get("deptCode"));
                    object.put("deptName",map.get("deptName"));
                    object.put("count",map.get("count"));
                    object.put("rank",1);
                }
                array.add(object);
            }
            object1.put("data", array);
        }
        return object1;
    }
    public JSONObject getDoctorTotal(String startDate, String endDate, String area, int level, String index, String level2_type,Integer flag) throws Exception {
        JSONObject object = new JSONObject();
        if (flag==1){
            String sql = "SELECT bd.JOB_TITLE_CODE, bd.JOB_TITLE_NAME, COUNT(bd.ID) as count FROM " +
                    "BASE_DOCTOR bd, BASE_DOCTOR_HOSPITAL bdh,DICT_HOSPITAL_DEPT dhd  WHERE bd.ID = bdh.DOCTOR_CODE AND dhd.code = bdh.DEPT_CODE AND bd.DEL = 1 " +
                    " AND bdh.DEL = 1 AND bd.OUTPATIENT_TYPE IS NOT NULL " ;
            String sqlCount = "SELECT COUNT(bd.ID) as total FROM " +
                    "BASE_DOCTOR bd, BASE_DOCTOR_HOSPITAL bdh,DICT_HOSPITAL_DEPT dhd WHERE bd.ID = bdh.DOCTOR_CODE AND dhd.code = bdh.DEPT_CODE AND bd.DEL = 1 " +
                    " AND bdh.DEL = 1 AND bd.OUTPATIENT_TYPE IS NOT NULL AND dhd.CONSULT_DEPT_FLAG='1' ";
            if (level==4){
                sql+=" AND dhd.ORG_CODE = '"+area+"'";
                sqlCount+=" AND dhd.ORG_CODE = '"+area+"'";
            }else if (level==5){
                sql+=" AND bdh.DEPT_CODE = '"+area+"'";
                sqlCount+=" AND bdh.DEPT_CODE = '"+area+"'";
            }
            sql += " AND dhd.CONSULT_DEPT_FLAG='1' GROUP BY bd.JOB_TITLE_CODE,bd.JOB_TITLE_NAME";
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);//各职称人数
            List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlCount);//总人数
            Long total = 0L;
            if(rstotal!=null&&rstotal.size()>0){
                total = (Long) rstotal.get(0).get("total");
            }
            for (Map<String,Object> map:mapList){
                Integer count = Integer.parseInt(map.get("count").toString());
                map.put("rate",getRange(count,total.intValue(),0));//百分比
            }
            object.put("total",total);//总量
            object.put("data",mapList);//各职称人数
        }else if (flag==2){
            List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, null, "6");
            StringBuffer buffer = new StringBuffer();
            int total = 0;
            for(SaveModel saveModel:saveModels){
                if (saveModel.getResult1()>0){
                    total+=1;
                    buffer.append("'"+saveModel.getDoctor()+"',");
                }
            }
            if (buffer.length()>0){
                buffer.deleteCharAt(buffer.length()-1);
            }
            if (buffer.length()>0){
                String sql ="SELECT bd.JOB_TITLE_CODE, bd.JOB_TITLE_NAME,COUNT(bd.ID) AS total FROM BASE_DOCTOR bd WHERE  bd.DEL = 1";
                sql +="  AND bd.ID IN("+buffer+")";
                sql +="  GROUP BY bd.JOB_TITLE_CODE,bd.JOB_TITLE_NAME";
                List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);//各职称人数
                for (Map<String,Object> map:mapList){
                    Integer count = Integer.parseInt(map.get("total").toString());
                    map.put("rate",getRange(count,total,0));//百分比
                }
                object.put("total",total);//总量
                object.put("data",mapList);//各职称人数
            }
        }
        return object;
    }
    public JSONObject getDoctorStatisticsExcel(String startDate, String endDate, String area, int level, String index, String level2_type,Integer flag) throws Exception {
        JSONObject object = new JSONObject();
        if (flag==1){//开通医生
            String sql ="SELECT bd.ID, bd.NAME, bd.OUTPATIENT_TYPE, " +
                    "dhd.code AS dept_code, dhd.name AS dept_name,bd.JOB_TITLE_NAME  FROM " +
                    "BASE_DOCTOR bd, BASE_DOCTOR_HOSPITAL bdh, " +
                    "DICT_HOSPITAL_DEPT dhd WHERE bd.ID = bdh.DOCTOR_CODE " +
                    "AND dhd.code = bdh.DEPT_CODE " +
                    "AND bd.DEL = 1 " +
                    "AND bdh.DEL = 1 " +
                    "AND bd.OUTPATIENT_TYPE IS NOT NULL " +
                    " AND dhd.CONSULT_DEPT_FLAG='1'";
            String deptSql = "select hd.CODE,hd.NAME from DICT_HOSPITAL_DEPT hd where CONSULT_DEPT_FLAG=1";
            if (level==4){//科室
                sql+=" AND dhd.ORG_CODE = '"+area+"'";
                deptSql+=" AND hd.ORG_CODE ='" + area + "'";
            }else if (level==5){//医生
                sql+=" AND bdh.DEPT_CODE = '"+area+"'";
                deptSql+=" AND hd.CODE ='" + area + "'";
            }
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
            List<Map<String, Object>> mapList1 = jdbcTemplate.queryForList(deptSql);
            JSONArray array =new JSONArray();
            if (level==4){
                for (Map<String,Object> map1:mapList1){
                    JSONObject object1 = new JSONObject();
                    object1.put("deptCode",map1.get("code"));
                    object1.put("deptName",map1.get("name"));
                    Long topic = 0L;
                    Long vedio =0L;
                    Long synegy = 0L;
                    Long specialist =0L;
                    Long other =0L;
                    for (Map<String,Object> map:mapList){
                        if (map.get("dept_code").toString().equalsIgnoreCase(map1.get("code").toString())){
                            String outpatientType = map.get("outpatient_type").toString();
                            String str[]=outpatientType.split(",");
                            for (int i=0;i<str.length;i++){
                                if (str[i].contains("1")){
                                    topic+=1;
                                }else if (str[i].contains("2")){
                                    vedio+=1;
                                }else if (str[i].contains("xt")){
                                    synegy+=1;
                                }else if (str[i].contains("zj")){
                                    specialist+=1;
                                }else {
                                    other+=1;
                                }
                            }
                        }
                    }
                    object1.put("topic",topic);//图文
                    object1.put("vedio",vedio);//视频
                    object1.put("synegy",synegy);//协同
                    object1.put("specialist",specialist);//专家
                    object1.put("other",other);//其他
                    object1.put("doctorName","-");//医生名字
                    object1.put("doctorJob","-");//医生职称
                    array.add(object1);
                }
            }else if (level==5){
                for (Map<String,Object> map:mapList){
                    JSONObject object1 = new JSONObject();
                    object1.put("deptCode","-");
                    object1.put("deptName","-");
                    Long topic = 0L;
                    Long vedio =0L;
                    Long synegy = 0L;
                    Long specialist =0L;
                    Long other =0L;
                    String outpatientType = map.get("outpatient_type").toString();
                    String str[]=outpatientType.split(",");
                    for (int i=0;i<str.length;i++){
                        if (str[i].contains("1")){
                            topic+=1;
                        }else if (str[i].contains("2")){
                            vedio+=1;
                        }else if (str[i].contains("xt")){
                            synegy+=1;
                        }else if (str[i].contains("zj")){
                            specialist+=1;
                        }else {
                            other+=1;
                        }
                    }
                    object1.put("topic",topic);//图文
                    object1.put("vedio",vedio);//视频
                    object1.put("synegy",synegy);//协同
                    object1.put("specialist",specialist);//专家
                    object1.put("other",other);//其他
                    object1.put("doctorName",map.get("name"));//医生名字
                    object1.put("doctorJob",map.get("job_title_name"));//医生职称
                    array.add(object1);
                }
            }
            object.put("data",array);
        }else if (flag==2){//活跃医生
            //图文
            List<SaveModel> topicModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1","1",null, "6");
            //视频
            List<SaveModel> vedioModels = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1","2",null, "6");
            //协同
            List<SaveModel> synegyModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "2",null, "6");
            //专科
            List<SaveModel> specialistModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level,"4", SaveModel.timeLevel_ZL,null, "6");
            String deptSql = "select hd.CODE,hd.NAME from DICT_HOSPITAL_DEPT hd where CONSULT_DEPT_FLAG=1";
            if (level==4){//科室
                deptSql+=" AND hd.ORG_CODE ='" + area + "'";
            }else if (level==5){//医生
                deptSql+=" AND hd.CODE ='" + area + "'";
            }
            List<Map<String, Object>> mapList1 = jdbcTemplate.queryForList(deptSql);
            JSONArray array =new JSONArray();
            if (level==4){
                for (Map<String,Object> map:mapList1){
                    Long topic = 0L;
                    Long vedio =0L;
                    Long synegy = 0L;
                    Long specialist =0L;
                    Long other =0L;
                    JSONObject jsonObject = new JSONObject();
                    for(SaveModel saveModel:topicModels){
                        if (saveModel.getResult1()>0){
                            List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(saveModel.getDoctor());
                            if (doctorHospitalDOs!=null&&doctorHospitalDOs.size()!=0){
                                saveModel.setDept(doctorHospitalDOs.get(0).getDeptCode());
                                saveModel.setDeptName(doctorHospitalDOs.get(0).getDeptName());
                            }
                            if(map.get("code").toString().equalsIgnoreCase(saveModel.getDept())) {
                                topic += 1;
                            }
                        }
                    }
                    for(SaveModel saveModel:vedioModels){
                        if (saveModel.getResult1()>0){
                            List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(saveModel.getDoctor());
                            if (doctorHospitalDOs!=null&&doctorHospitalDOs.size()!=0){
                                saveModel.setDept(doctorHospitalDOs.get(0).getDeptCode());
                                saveModel.setDeptName(doctorHospitalDOs.get(0).getDeptName());
                            }
                            if(map.get("code").toString().equalsIgnoreCase(saveModel.getDept())){
                                vedio+=1;
                            }
                        }
                    }
                    for(SaveModel saveModel:synegyModels){
                        if (saveModel.getResult1()>0){
                            List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(saveModel.getDoctor());
                            if (doctorHospitalDOs!=null&&doctorHospitalDOs.size()!=0){
                                saveModel.setDept(doctorHospitalDOs.get(0).getDeptCode());
                                saveModel.setDeptName(doctorHospitalDOs.get(0).getDeptName());
                            }
                            if(map.get("code").toString().equalsIgnoreCase(saveModel.getDept())){
                                    synegy+=1;
                            }
                        }
                    }
                    for(SaveModel saveModel:specialistModels){
                        if (saveModel.getResult1()>0){
                            List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(saveModel.getDoctor());
                            if (doctorHospitalDOs!=null&&doctorHospitalDOs.size()!=0){
                                saveModel.setDept(doctorHospitalDOs.get(0).getDeptCode());
                                saveModel.setDeptName(doctorHospitalDOs.get(0).getDeptName());
                            }
                            if(map.get("code").toString().equalsIgnoreCase(saveModel.getDept())){
                                    specialist+=1;
                            }
                        }
                    }
                    jsonObject.put("topic",topic);//图文
                    jsonObject.put("vedio",vedio);//视频
                    jsonObject.put("synegy",synegy);//协同
                    jsonObject.put("specialist",specialist);//专家
                    jsonObject.put("other",other);//其他
                    jsonObject.put("doctorName","-");//医生名字
                    jsonObject.put("doctorJob","-");//医生职称
                    jsonObject.put("deptCode",map.get("code"));
                    jsonObject.put("deptName",map.get("name"));
                    array.add(jsonObject);
                }
            }else if (level==5){
                Set<JSONObject> set = new HashSet<>();
                for(SaveModel saveModel:topicModels){
                    BaseDoctorDO doctorDO = doctorDao.findById(saveModel.getDoctor());
                    JSONObject object1 = new JSONObject();
                    object1.put("doctorName",doctorDO.getName());//
                    object1.put("doctorJob",doctorDO.getJobTitleName());//
                    object1.put("doctor",doctorDO.getId());
                    object1.put("deptCode","-");
                    object1.put("deptName","-");
                    set.add(object1);
                }
                for (JSONObject jsonObject:set){
                    Long topic = 0L;
                    Long vedio =0L;
                    Long synegy = 0L;
                    Long specialist =0L;
                    Long other =0L;
                    for(SaveModel saveModel:topicModels){
                        if(jsonObject.getString("doctor").equalsIgnoreCase(saveModel.getDoctor())){
                            if (saveModel.getResult1()>0){
                                topic+=1;
                            }
                        }
                    }
                    for(SaveModel saveModel:vedioModels){
                        if(jsonObject.getString("doctor").equalsIgnoreCase(saveModel.getDoctor())){
                            if (saveModel.getResult1()>0){
                                vedio+=1;
                            }
                        }
                    }
                    for(SaveModel saveModel:synegyModels){
                        if(jsonObject.getString("doctor").equalsIgnoreCase(saveModel.getDoctor())){
                            if (saveModel.getResult1()>0){
                                synegy+=1;
                            }
                        }
                    }
                    for(SaveModel saveModel:specialistModels) {
                        if (jsonObject.getString("doctor").equalsIgnoreCase(saveModel.getDoctor())) {
                            if (saveModel.getResult1()>0){
                                specialist+=1;
                            }
                        }
                    }
                    jsonObject.put("topic",topic);//图文
                    jsonObject.put("vedio",vedio);//视频
                    jsonObject.put("synegy",synegy);//协同
                    jsonObject.put("specialist",specialist);//专家
                    jsonObject.put("other",other);//其他
                    array.add(jsonObject);
                }
            }
            object.put("data",array);
        }
        return object;
    }
    /**
@ -253,7 +770,7 @@ public class StatisticsEsService {
            return "0%";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        DecimalFormat df = new DecimalFormat("0");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize + "%";
    }
@ -580,10 +1097,10 @@ public class StatisticsEsService {
            if (k == 0) {
                next.add(Calendar.MONTH, 1);
            } else {
                next.add(Calendar.MONTH, 2);
                next.add(Calendar.MONTH, 1);
            }
            next.set(Calendar.DAY_OF_MONTH, 1);
            next.add(Calendar.DAY_OF_MONTH, -1);
            /*next.set(Calendar.DAY_OF_MONTH, 1);
            next.add(Calendar.DAY_OF_MONTH, -1);*/
            if (next.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))) {
                days.add(next);

+ 3 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -636,5 +636,8 @@ public class BaseHospitalRequestMapping {
        public static final String outPatientCircular="/outPatientCircular";
        public static final String outPatientGrade = "/outPatientGrade";
        public static final String outPatientTypeLine= "/outPatientTypeLine";
        public static final String doctorStatictis = "/doctorStatictis";
        public static final String doctorTotal = "/doctorTotal";
        public static final String doctorStatictisExcel = "/doctorStatictisExcel";
    }
}

+ 2 - 2
gateway/ag-basic/src/main/resources/application.yml

@ -66,7 +66,7 @@ zuul:
      serviceId: svr-base
    svr-authentication:
      path: /cityihealth/auth/**
      serviceId: svr-authentication
      serviceId: svr-authentication-wangzhinan
    svr-healthy-house:
      path: /cityihealth/healthyHouse/**
      serviceId: svr-healthy-house
@ -75,7 +75,7 @@ zuul:
      serviceId: svr-patient
    svr-internet-hospital:
      path: /hospital/**
      serviceId: svr-internet-hospital
      serviceId: svr-internet-hospital-wangzhinan
    svr-internet-hospital-entrance:
      path: /hospitalEntrance/**
      serviceId: svr-internet-hospital-entrance

+ 1 - 1
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: ag-basic
    name: ag-basic-wangzhinan
  cloud:
    config:
      failFast: true

+ 1 - 1
server/svr-authentication/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-authentication-lyx
    name: svr-authentication-wangzhinan
  cloud:
    config:
      failFast: true

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

@ -175,4 +175,62 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        return success(result);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.doctorStatictis)
    @ApiOperation(value = "人员统计")
    public ObjEnvelop getDoctorStatistics(@RequestParam(required = true) String startDate,
                                          @RequestParam(required = true) String endDate,
                                          @RequestParam(required = true) String area,
                                          @RequestParam(required = true) int level,
                                          @RequestParam(required = true) String index,
                                          @RequestParam(required = false) String level2_type,
                                          @RequestParam(required = true) Integer flag) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.getDoctorStatistics(startDate,endDate,area,level,index,level2_type,flag);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.doctorTotal)
    @ApiOperation(value = "各职称人数统计")
    public ObjEnvelop getDoctorTotal(@RequestParam(required = true) String startDate,
                                     @RequestParam(required = true) String endDate,
                                     @RequestParam(required = true) String area,
                                     @RequestParam(required = true) int level,
                                     @RequestParam(required = true) String index,
                                     @RequestParam(required = false) String level2_type,
                                     @RequestParam(required = true) Integer flag) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.getDoctorTotal(startDate,endDate,area,level,index,level2_type,flag);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.doctorStatictisExcel)
    @ApiOperation(value = "人数统计-excel表")
    public ObjEnvelop getDoctorStatisticsExcel(@RequestParam(required = true) String startDate,
                                     @RequestParam(required = true) String endDate,
                                     @RequestParam(required = true) String area,
                                     @RequestParam(required = true) int level,
                                     @RequestParam(required = true) String index,
                                     @RequestParam(required = false) String level2_type,
                                     @RequestParam(required = true) Integer flag) {
        //新版与旧版统计适配
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.getDoctorStatisticsExcel(startDate,endDate,area,level,index,level2_type,flag);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
}

+ 1 - 1
svr/svr-internet-hospital/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name:  svr-internet-hospital
    name:  svr-internet-hospital-wangzhinan
  cloud:
    config:
      failFast: true