Browse Source

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

wangzhinan 10 months ago
parent
commit
988803bffe
14 changed files with 818 additions and 53 deletions
  1. 3 3
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/UserMsgContentService.java
  2. 435 4
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  3. 122 1
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  4. 10 14
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  5. 18 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/statistics/ScreenQvo.java
  6. 18 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/DeviceHealthIndexVO.java
  7. 19 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyPatientDeviceVO.java
  8. 5 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  9. 122 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java
  10. 58 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/CommonItemController.java
  11. 4 4
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/StatisticsController.java
  12. 2 2
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/StatisticsService.java
  13. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceService.java
  14. 1 16
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientDeviceService.java

+ 3 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/UserMsgContentService.java

@ -119,17 +119,17 @@ public class UserMsgContentService extends BaseJpaService<BaseUserMsgContentDO,
        List<Map<String,Object>> resultList= new ArrayList<>();
        Map<String,Object> resultMap = new HashMap<>();
        if(countTmp==0){
            resultMap.put("zjzx","100%");
            resultMap.put("zjzx","100.00%");
        }else {
            resultMap.put("zjzx",df.format(expertMY * 100)+"%");
        }
        if(countOnlineTotalTmp==0){
            resultMap.put("zxfz","100%");
            resultMap.put("zxfz","100.00%");
        }else {
            resultMap.put("zxfz",df.format(inlineMY * 100)+"%");
        }
        if(totalCountTmp==0){
            resultMap.put("totalCount","100%");
            resultMap.put("totalCount","100.00%");
        }else {
            resultMap.put("totalCount",df.format(totalConunt * 100)+"%");
        }

+ 435 - 4
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -4,7 +4,6 @@ package com.yihu.jw.es.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.area.dao.BaseCityDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -71,8 +70,6 @@ public class StatisticsEsService {
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private BaseCityDao cityDao;
    @Autowired
    private BaseEvaluateScoreService baseEvaluateScoreService;
    @Autowired
    private HibenateUtils hibenateUtils;
@ -6658,19 +6655,291 @@ public class StatisticsEsService {
     * 6、同比增长:(本期统计周期数据-去年同期统计周期数据)去年同期统计周期数据× 100%;
     * 7、环比增长:(本期统计周期数据 - 上期统计周期数据)上期统计周期数据× 100%;
     */
    public JSONObject businessSituation(ScreenQvo qvo){
    public JSONObject businessSituation(ScreenQvo qvo) throws Exception{
        JSONObject json = new JSONObject();
        // 计算上一个周期  开始时间period[0] 、结束时间period[1]
        String[] period = calculatePreviousPeriod(qvo.getStartDate(), qvo.getEndDate());
        //计算去年同期时间段 开始时间periodYear[0] 、结束时间periodYear[1]
        String[] periodYear = calculatePreviousYearPeriod(qvo.getStartDate(), qvo.getEndDate());
        //----------------------问诊量--------------------------------------
        List<SaveModel> wz_model01 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, null);//问诊
        //上个周期
        List<SaveModel> wz_model02 = elasticsearchUtil.findListDateQuotaLevel1(period[0], period[1], qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, null);//问诊
        //去年同期时间
        List<SaveModel> wz_model03 = elasticsearchUtil.findListDateQuotaLevel1(periodYear[0], periodYear[1], qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, null);//问诊
        //问诊类型 17	视频咨询        //1	图文咨询        //9	图文复诊        //12	专科协同        //16	视频复诊
        List<SaveModel> wz_model01_17 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "17");
        List<SaveModel> wz_model01_1 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "1");
        List<SaveModel> wz_model01_9 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "9");
        List<SaveModel> wz_model01_12 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "12");
        List<SaveModel> wz_model01_16 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "16");
        json.put("wzType17", countListTotal(wz_model01_17));//问诊类型_视频咨询
        json.put("wzType1", countListTotal(wz_model01_1));//问诊类型_图文咨询
        json.put("wzType9", countListTotal(wz_model01_9));//问诊类型_图文复诊
        json.put("wzType12", countListTotal(wz_model01_12));//问诊类型_专科协同
        json.put("wzType16", countListTotal(wz_model01_16));//问诊类型_视频复诊
        //---------------------【处方量】------------------------------------
        List<SaveModel> cf_model01 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "2", SaveModel.timeLevel_ZL, null, null);//开方量
        //上个周期
        List<SaveModel> cf_model02 = elasticsearchUtil.findListDateQuotaLevel1(period[0], period[1], qvo.getArea(), qvo.getLevel(), "2", SaveModel.timeLevel_ZL, null, null);//开方量
        //去年同期时间
        List<SaveModel> cf_model03 = elasticsearchUtil.findListDateQuotaLevel1(periodYear[0], periodYear[1], qvo.getArea(), qvo.getLevel(), "2", SaveModel.timeLevel_ZL, null, null);//开方量
        //---------------------【接诊量】------------------------------------
        //接诊量-已接诊
        List<SaveModel> jz_model01 = elasticsearchUtil.findListDateQuotaLevel2(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
        //上个周期
        List<SaveModel> jz_model02 = elasticsearchUtil.findListDateQuotaLevel2(period[0], period[1], qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
        //去年同期时间
        List<SaveModel> jz_model03 = elasticsearchUtil.findListDateQuotaLevel2(periodYear[0], periodYear[1], qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
        //接诊量
        int patientVolume = countListTotal(jz_model01);
        int periodPatientVolume = countListTotal(jz_model02);//上个周期
        int periodYearPatientVolume = countListTotal(jz_model03);//去年同期时间
        json.put("wzl_jz", patientVolume);//接诊量
        json.put("wzl_jz_hb", getRange((patientVolume - periodPatientVolume), periodPatientVolume, 0));//接诊量-环比
        json.put("wzl_jz_tb", getRange((patientVolume - periodYearPatientVolume), periodYearPatientVolume, 0));//接诊量-同比
        //问诊
        int wzl = countListTotal(wz_model01);
        //同比和环比
        int wzl_period = countListTotal(wz_model02);//上个周期
        int wzl_periodYear = countListTotal(wz_model03);//去年同周期
        json.put("wzl_total", wzl);//问诊量
        json.put("wzl_jzl", getRange(patientVolume, wzl, 0));//【接诊率】= 接诊量 ÷ 问诊量 ×100%
        json.put("wzl_hb", getRange((wzl - wzl_period), wzl_period, 0));//环比
        json.put("wzl_tb", getRange((wzl - wzl_periodYear), wzl_periodYear, 0));//同比
        //开方 【处方量】
        int kf_total = countListTotal(cf_model01);
        int kf_period = countListTotal(cf_model02);
        //上个周期
        int kf_periodYear = countListTotal(cf_model03);
        //去年同周期
        json.put("kf_total", kf_total);//开方量
        json.put("kf_kfl", getRange(kf_total, patientVolume, 0));//【处方率】= 处方量 ÷ 接诊量 ×100%
        json.put("kf_hb", getRange((kf_total - kf_period), kf_period, 0));//环比
        json.put("kf_tb", getRange((kf_total - kf_periodYear), kf_periodYear, 0));//同比
        //门诊转住院
        String sql = "select COUNT(DISTINCT r.id) from wlyy_outpatient_hospitalization r,base_doctor_hospital bdh,base_doctor bd,dict_hospital_dept hd " +
                "WHERE r.doctor=bdh.doctor_code and bdh.doctor_code = bd.id AND hd.code= bdh.dept_code " +
                "AND bdh.del=1 AND hd.CONSULT_DEPT_FLAG='1' AND bd.job_title_code IN('1201','1301','1401','1101','066','067','061','1310','061','065','1','2','3','4') ";
        //本周期
        String sql01 = sql + " and r.create_time>='"+qvo.getStartDate()+"' and r.create_time<='"+qvo.getEndDate()+" 23:59:59'";
        //上个周期
        String sql02 = sql + " and r.create_time>='"+period[0]+"' and r.create_time<='"+period[1]+" 23:59:59'";
        //去年同期
        String sql03 = sql + " and r.create_time>='"+periodYear[0]+"' and r.create_time<='"+periodYear[1]+" 23:59:59'";
        if("5".equals(qvo.getLevel())){
            //科室
            sql01 += " and hd.code='"+qvo.getArea()+"' ";
            sql02 += " and hd.code='"+qvo.getArea()+"' ";
            sql03 += " and hd.code='"+qvo.getArea()+"' ";
        }
        if("6".equals(qvo.getLevel())){
            //医生
            sql01 += " and r.doctor='"+qvo.getArea()+"' ";
            sql02 += " and r.doctor='"+qvo.getArea()+"' ";
            sql03 += " and r.doctor='"+qvo.getArea()+"' ";
        }
        //已接诊的复诊数
        String sql04 = sql01.replace("wlyy_outpatient_hospitalization","wlyy_outpatient");
        sql04 += " and r.status IN(1,2,3) and r.outpatient_type !='3' ";
        Integer hospitalization01 = jdbcTemplate.queryForObject(sql01,Integer.class);
        Integer hospitalization02 = jdbcTemplate.queryForObject(sql02,Integer.class);
        Integer hospitalization03 = jdbcTemplate.queryForObject(sql03,Integer.class);
        Integer hospitalization04 = jdbcTemplate.queryForObject(sql04,Integer.class);
        json.put("ar_total", hospitalization01);//门诊转住院量
        json.put("ar_kfl", getRange(hospitalization01, hospitalization04, 0));//【转化率】= 门诊转住院量 ÷ 已接诊的复诊数 ×100%
        json.put("ar_hb", getRange((hospitalization01 - hospitalization02), hospitalization02, 0));//环比
        json.put("ar_tb", getRange((hospitalization01 - hospitalization03), hospitalization03, 0));//同比
        return json;
    }
    /**
     * 业务分析
     * 1、【总问诊量】= 用户成功发起的问诊次数,包含取消的订单(同一人发起多次累计多次);
     * 2、图文门诊、图文咨询、视频问诊、视频咨询、社区协诊 = 患者发起的属于该类型的订单次数(同一人发起多次累计多次);
     * 3、【处方量】 = 成功开方且审核通过的数量;
     * 4、【接诊率】 = 接诊量 ÷ 问诊量 × 100%;
     * 5、【问诊转住院】 = 医生登记住院申请的次数;
     * 6、根据页面显示医院总数据或科室数据!
     */
    public JSONObject businessAnalysis(ScreenQvo qvo) throws Exception{
        JSONObject json = new JSONObject();
        //----------------------问诊量--------------------------------------
        List<SaveModel> wz_model01 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, null);//问诊
        //问诊类型 17	视频咨询        //1	图文咨询        //9	图文复诊        //12	专科协同        //16	视频复诊
        List<SaveModel> wz_model01_17 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "17");
        List<SaveModel> wz_model01_1 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "1");
        List<SaveModel> wz_model01_9 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "9");
        List<SaveModel> wz_model01_12 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "12");
        List<SaveModel> wz_model01_16 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, null, "16");
        json.put("wzType17", countListTotal(wz_model01_17));//问诊类型_视频咨询
        json.put("wzType1", countListTotal(wz_model01_1));//问诊类型_图文咨询
        json.put("wzType9", countListTotal(wz_model01_9));//问诊类型_图文复诊
        json.put("wzType12", countListTotal(wz_model01_12));//问诊类型_专科协同
        json.put("wzType16", countListTotal(wz_model01_16));//问诊类型_视频复诊
        //---------------------【处方量】------------------------------------
        List<SaveModel> cf_model01 = elasticsearchUtil.findListDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "2", SaveModel.timeLevel_ZL, null, null);//开方量
        //---------------------【接诊量】------------------------------------
        //接诊量-已接诊
        List<SaveModel> jz_model01 = elasticsearchUtil.findListDateQuotaLevel2(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
        //接诊量
        int patientVolume = countListTotal(jz_model01);
        json.put("wzl_jz", patientVolume);//接诊量
        //问诊
        int wzl = countListTotal(wz_model01);
        json.put("wzl_total", wzl);//问诊量
        json.put("wzl_jzl", getRange(patientVolume, wzl, 0));//【接诊率】= 接诊量 ÷ 问诊量 ×100%
        //开方 【处方量】
        int kf_total = countListTotal(cf_model01);
        //去年同周期
        json.put("kf_total", kf_total);//开方量
        json.put("kf_kfl", getRange(kf_total, patientVolume, 0));//【处方率】= 处方量 ÷ 接诊量 ×100%
        //门诊转住院
        String sql = "select COUNT(DISTINCT r.id) from wlyy_outpatient_hospitalization r,base_doctor_hospital bdh,base_doctor bd,dict_hospital_dept hd " +
                "WHERE r.doctor=bdh.doctor_code and bdh.doctor_code = bd.id AND hd.code= bdh.dept_code " +
                "AND bdh.del=1 AND hd.CONSULT_DEPT_FLAG='1' AND bd.job_title_code IN('1201','1301','1401','1101','066','067','061','1310','061','065','1','2','3','4') ";
        //本周期
        String sql01 = sql + " and r.create_time>='"+qvo.getStartDate()+"' and r.create_time<='"+qvo.getEndDate()+" 23:59:59'";
        if("5".equals(qvo.getLevel())){
            //科室
            sql01 += " and hd.code='"+qvo.getArea()+"' ";
        }
        if("6".equals(qvo.getLevel())){
            //医生
            sql01 += " and r.doctor='"+qvo.getArea()+"' ";
        }
        //已接诊的复诊数
        String sql04 = sql01.replace("wlyy_outpatient_hospitalization","wlyy_outpatient");
        sql04 += " and r.status IN(1,2,3) and r.outpatient_type !='3' ";
        Integer hospitalization01 = jdbcTemplate.queryForObject(sql01,Integer.class);
        Integer hospitalization04 = jdbcTemplate.queryForObject(sql04,Integer.class);
        json.put("ar_total", hospitalization01);//门诊转住院量
        json.put("ar_kfl", getRange(hospitalization01, hospitalization04, 0));//【转化率】= 门诊转住院量 ÷ 已接诊的复诊数 ×100%
        return json;
    }
    /**
     * 业务增长趋势
     * 1、显示展示的时间范围内的收入趋势图,默认按日展示,支持管理员点击区域右上角进行“日、周、月”进行趋势图X轴的切换;
     * 2、支持管理员点击趋势图上的点位时,展示该点位的时间及各类型的订单数量;
     */
    public JSONObject businessNewTrends(ScreenQvo qvo) throws Exception{
        JSONObject json = new JSONObject();
        //问诊类型 17	视频咨询        //1	图文咨询        //9	图文复诊        //12	专科协同        //16	视频复诊
        List<SaveModel> wz_17 = elasticsearchUtil.findLineChartDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, qvo.getInterval(), "17");
        List<SaveModel> wz_1 = elasticsearchUtil.findLineChartDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, qvo.getInterval(), "1");
        List<SaveModel> wz_9 = elasticsearchUtil.findLineChartDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, qvo.getInterval(), "9");
        List<SaveModel> wz_12 = elasticsearchUtil.findLineChartDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, qvo.getInterval(), "12");
        List<SaveModel> wz_16 = elasticsearchUtil.findLineChartDateQuotaLevel1(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "5", SaveModel.timeLevel_ZL, qvo.getInterval(), "16");
        List<JSONObject> list17 = new ArrayList<>();
        List<JSONObject> list1 = new ArrayList<>();
        List<JSONObject> list9 = new ArrayList<>();
        List<JSONObject> list12 = new ArrayList<>();
        List<JSONObject> list16 = new ArrayList<>();
        for (SaveModel saveModel : wz_17) {
            JSONObject range = new JSONObject();
            range.put("range", DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd"));
            range.put("amount", saveModel.getResult1());
            list17.add(range);
        }
        for (SaveModel saveModel : wz_1) {
            JSONObject range = new JSONObject();
            range.put("range", DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd"));
            range.put("amount", saveModel.getResult1());
            list1.add(range);
        }
        for (SaveModel saveModel : wz_9) {
            JSONObject range = new JSONObject();
            range.put("range", DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd"));
            range.put("amount", saveModel.getResult1());
            list9.add(range);
        }
        for (SaveModel saveModel : wz_12) {
            JSONObject range = new JSONObject();
            range.put("range", DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd"));
            range.put("amount", saveModel.getResult1());
            list12.add(range);
        }
        for (SaveModel saveModel : wz_16) {
            JSONObject range = new JSONObject();
            range.put("range", DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd"));
            range.put("amount", saveModel.getResult1());
            list16.add(range);
        }
        json.put("wz_1",list1);
        json.put("wz_9",list9);
        json.put("wz_12",list12);
        json.put("wz_16",list16);
        json.put("wz_17",list17);
        return json;
    }
    /**
     * 接诊排行
     */
    public List<JSONObject> businessRanking(ScreenQvo qvo) throws Exception{
        String level2_type = qvo.getLevel2_type();
        List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel2New(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(),
                "12,14,16", "1", "9,16,12,1,17", "1",null,level2_type);
        List<JSONObject> result = new ArrayList<>();
        for (SaveModel saveModel : saveModels) {
            JSONObject object1 = new JSONObject();
            if (level2_type.equals(SaveModel.deptLevel)) {
                object1.put("dept", saveModel.getDept());
                object1.put("deptName", saveModel.getDeptName());
            } else if (level2_type.equals(SaveModel.doctorLevel)) {
                object1.put("doctor", saveModel.getDoctor());
                object1.put("doctorName", saveModel.getDoctorName());
            } else if (level2_type.equals(SaveModel.OrgLevel)) {
                object1.put("hospital", saveModel.getHospital());
                object1.put("hospitalName", saveModel.getHospitalName());
            }
            object1.put("result1", saveModel.getResult1());
            object1.put("result2", saveModel.getResult2());
            result.add(object1);
        }
        // 排序
        result.sort(new Comparator<JSONObject>() {
            @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 {
                    return 0;
                }
            }
        });
        return result;
    }
    /**
     * 收入情况
     1、【总收入】=药品费+诊查费;
@ -6792,6 +7061,168 @@ public class StatisticsEsService {
        return json;
    }
    /**
     * 收入分析
     1、【总收入】= 药品费+诊查费;
     2、【药品费】= 患者支付的处方费用;
     3、【诊查费】= 图文门诊+图文咨询+视频问诊+视频咨询+社区协诊;
     4、图文门诊、图文咨询、视频问诊、视频咨询、社区协诊 = 患者支付的属于该类型的诊查费;
     5、根据页面显示医院总数据或科室数据!
     */
    public JSONObject incomeAnalysis(ScreenQvo qvo) throws Exception{
        JSONObject json = new JSONObject();
        String lowLevel = "2";
        String index3 = "3";//处方费/药品费
        String index21 = "21";//诊查费
        //图文问诊、图文咨询、视频问诊、视频咨询、社区协诊=患者支付的属于该类型的诊查费
        //药品费
        double ypFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index3, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //诊查费
        double zcFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, null, null, null,lowLevel);
        //总收入
        double totalFee = ypFee+zcFee;
        //图文问诊
        double ppFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "1", null,lowLevel);
        //图文咨询
        double pcFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "1", null,lowLevel);
        //视频问诊
        double vpFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "1", "2", null,lowLevel);
        //视频咨询
        double vcFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "3", "2", null,lowLevel);
        //社区协诊
        double sxFee = findResult1BySaveModelList(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), index21, SaveModel.timeLevel_ZL, "2", null, null,lowLevel);
        json.put("ypFee",ypFee);
        json.put("zcFee",zcFee);
        json.put("totalFee",totalFee);
        json.put("ppFee",ppFee);
        json.put("pcFee",pcFee);
        json.put("vpFee",vpFee);
        json.put("vcFee",vcFee);
        json.put("sxFee",sxFee);
        return json;
    }
    /**
     * 收入新增趋势
     * 1、显示展示的时间范围内的收入趋势图,默认按日展示,支持管理员点击区域右上角进行“日、周、月”进行趋势图X轴的切换;
     * 2、支持管理员点击趋势图上的点位时,展示该点位的时间及收入;
     */
    public List<JSONObject> incomeNewTrends(ScreenQvo qvo) throws Exception{
        //药品费+诊查费=总收入
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel0(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(),
                qvo.getLevel(), "3,21", SaveModel.timeLevel_ZL, qvo.getInterval());
        List<JSONObject> feeList = new ArrayList<>();
        for (SaveModel saveModel : list) {
            JSONObject range = new JSONObject();
            range.put("range", DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd"));
            range.put("amount", saveModel.getResult1());
            feeList.add(range);
        }
        return feeList;
    }
    /**
     * 收入排行
     */
    public List<JSONObject> incomeRanking(ScreenQvo qvo) throws Exception{
        //药品费+诊查费=总收入
        String level2_type = qvo.getLevel2_type();
        List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "3,21", SaveModel.timeLevel_ZL, null, level2_type);
        List<JSONObject> result = new ArrayList<>();
        for (SaveModel saveModel : saveModels) {
            JSONObject object1 = new JSONObject();
            if (level2_type.equals(SaveModel.deptLevel)) {
                object1.put("dept", saveModel.getDept());
                object1.put("deptName", saveModel.getDeptName());
            } else if (level2_type.equals(SaveModel.doctorLevel)) {
                object1.put("doctor", saveModel.getDoctor());
                object1.put("doctorName", saveModel.getDoctorName());
            } else if (level2_type.equals(SaveModel.OrgLevel)) {
                object1.put("hospital", saveModel.getHospital());
                object1.put("hospitalName", saveModel.getHospitalName());
            }
            object1.put("result1", saveModel.getResult1());
            object1.put("result2", saveModel.getResult2());
            result.add(object1);
        }
        // 排序
        result.sort(new Comparator<JSONObject>() {
            @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 {
                    return 0;
                }
            }
        });
        return result;
    }
    /**
     * 全院诊室患者
     */
    public JSONObject orgConsultPatient(String startDate,String endDate){
        JSONObject json = new JSONObject();
        String sql = "SELECT COUNT(if(op.`status`=3,1,null)) status3,COUNT(if(op.`status`=1,1,null)) status2 " +
                ",COUNT(if(op.`status`=0 and op.pay_status=1,1,null)) status1 from  wlyy_outpatient op " +
                "where 1=1 ";
        if(StringUtils.isNotBlank(startDate)){
            sql += " and create_time>='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            sql += " and create_time<'"+endDate+"' ";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list.size()>0){
            Map<String,Object> map = list.get(0);
            json.put("status1",map.get("status1")+"");//候诊中
            json.put("status2",map.get("status2")+"");//就诊中
            json.put("status3",map.get("status3")+"");//已结束
        }else {
            json.put("status1","0");//候诊中
            json.put("status2","0");//就诊中
            json.put("status3","0");//已结束
        }
        return json;
    }
    /**
     * 科室诊室患者
     */
    public List<Map<String,Object>> deptConsultPatient(String startDate,String endDate){
        String sql = "SELECT d.code,d.name,if(t.status1 is null,0,t.status1) status1, " +
                "if(t.status2 is null,0,t.status2) status2,if(t.status3 is null,0,t.status3) status3 " +
                "from dict_hospital_dept d LEFT JOIN ( " +
                "SELECT COUNT(if(op.`status`=3,1,null)) status3,COUNT(if(op.`status`=1,1,null)) status2 " +
                ",COUNT(if(op.`status`=0 and op.pay_status=1,1,null)) status1, op.dept from  wlyy_outpatient op " +
                "where 1=1 ";
        if(StringUtils.isNotBlank(startDate)){
            sql += " and create_time>='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            sql += " and create_time<'"+endDate+"' ";
        }
        sql += " GROUP BY op.dept) t on d.code=t.dept " +
                "WHERE d.consult_dept_flag=1 " +
                "ORDER BY t.status3 desc";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public SaveModel findOneBySaveModelList(String startDate, String endDate, String area, int level, String index, String timeLevel,
                                            String slaveKey1, String slaveKey2, String interval, String lowLevel){

+ 122 - 1
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -10,7 +10,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.elasticsearch.ElasticSearch7Util;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
@ -1613,6 +1612,128 @@ public class ElasticsearchUtil {
        return excuteEs7(sql.toString(), SaveModel.class, "", "");
    }
    /**
     * 二级指标查询列表
     * 获取二级指标的增量、到达量
     * 备注:原接口的三级指标对应现在的二级指标
     *
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @param area      区域code
     * @param level     等级
     * @param index     指标
     * @param timeLevel 1增量 2到达量
     * @param slaveKey1 一级维度code
     * @param slaveKey2 二级维度code
     * @param interval  1日 2周 3月
     * @param lowLevel  下一等级
     * @return
     */
    public List findDateQuotaLevel2New(String startDate, String endDate, String area, int level, String index, String timeLevel, String slaveKey1, String slaveKey2, String interval, String lowLevel) {
        //时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
        if (StringUtils.isNotEmpty(startDate)) {
            if (startDate.length() > 10) {
                startDate = changeTime(startDate);
            } else {
                startDate = changeDate(startDate);
            }
        }
        if (StringUtils.isNotEmpty(endDate)) {
            if (endDate.length() > 10) {
                endDate = changeTime(endDate);
            } else {
                endDate = changeDate(endDate);
            }
        }
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        String low_level = level + "";
        if (StringUtils.isNotEmpty(lowLevel)) {
            low_level = lowLevel;
        }
        StringBuffer condition = new StringBuffer();
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                condition.append(" ,to_char(date_trunc('month',quotaDate),'yyyy-MM-dd') as quotaDate ");
            } else if (SaveModel.interval_week.equals(interval)) {
                condition.append(" ,to_char(date_trunc('week',quotaDate),'yyyy-MM-dd') as quotaDate ");
            } else if (SaveModel.interval_day.equals(interval)) {
                condition.append(" ,to_char(date_trunc('day',quotaDate),'yyyy-MM-dd') as quotaDate ");
            }
        }
        if (SaveModel.doctorLevel.equals(low_level)) {
            groupBy.append("  group by doctor,doctorName");
            sql.append("select doctor as doctor,doctorName as doctorName,sum(result1) as result1,sum(result2) as result2 "+condition+" from " + esIndex + " where ");
        }else if (SaveModel.deptLevel.equals(low_level)) {
            groupBy.append("  group by dept,deptName");
            sql.append("select dept as dept,deptName as deptName,sum(result1) as result1,sum(result2) as result2"+condition+" from " + esIndex + " where ");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital as hospital,hospitalName as hospitalName,sum(result1) as result1,sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(low_level)) {
            groupBy.append("  group by town,townName");
            sql.append("select town as town,townName as townName,sum(result1) as result1,sum(result2) as result2"+condition+" from " + esIndex + " where ");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            groupBy.append("  group by city,cityName");
            sql.append("select city as city,cityName as cityName,sum(result1) as result1,sum(result2) as result2"+condition+" from " + esIndex + " where ");
        }
        if (StringUtils.isNotEmpty(area)) {
            if (SaveModel.doctorLevel.equals(level + "")) {
                sql.append(" doctor='" + area + "'");
            }else if (SaveModel.deptLevel.equals(level + "")) {
                sql.append(" dept='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }
            sql.append(" and ");
        }
        sql.append(" quotaCode in(" + index + ")  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='6'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
        if (StringUtils.isNotEmpty(endDate)) {
            sql.append(" and quotaDate<='" + endDate + "'");
        }
        if (StringUtils.isNotBlank(slaveKey1) && (!commonParams.equals(slaveKey1))) {
            String[] str = slaveKey1.split(",");
            StringBuffer buffer = new StringBuffer();
            for (int i=0;i<str.length;i++){
                buffer.append("'"+str[i]+"',");
            }
            buffer.deleteCharAt(buffer.length()-1);
            sql.append(" and slaveKey1 in (" + buffer + ")");
        }
        if (StringUtils.isNotBlank(slaveKey2) && (!commonParams.equals(slaveKey2))) {
            String[] str = slaveKey2.split(",");
            StringBuffer buffer = new StringBuffer();
            for (int i=0;i<str.length;i++){
                buffer.append("'"+str[i]+"',");
            }
            buffer.deleteCharAt(buffer.length()-1);
            sql.append(" and slaveKey2 in (" + buffer + ")");
        }
        //根据时间维度分组
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                groupBy.append(" ,to_char(date_trunc('month',quotaDate),'yyyy-MM-dd') ");
            } else if (SaveModel.interval_week.equals(interval)) {
                groupBy.append(" ,to_char(date_trunc('week',quotaDate),'yyyy-MM-dd') ");
            } else if (SaveModel.interval_day.equals(interval)) {
                groupBy.append(" ,to_char(date_trunc('day',quotaDate),'yyyy-MM-dd') ");
            }
        }
        sql.append(groupBy);
        logger.info("sql :" + sql.toString());
        return excuteEs7(sql.toString(), SaveModel.class, "", "");
    }
    /**
     * 多维度指标查寻(可控纬度与分组)
     * @param startDate

+ 10 - 14
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -4194,9 +4194,8 @@ public class ImService {
     * @return
     */
    @Transactional(readOnly = true)
    public List<Map<String, Object>> findConsultRecordByDoctorNew(String doctor, String id,
                                                                  String type, Integer status,
                                                                  int page, int pagesize,
    public List<Map<String, Object>> findConsultRecordByDoctorNew(String doctor, String id,String type, Integer status,
                                                                  int page, int pagesize,String dept,
                                                                  String title, String start_time, String end_time, String patient) {
        String sql = "";
        sql = "SELECT " +
@ -4268,6 +4267,9 @@ public class ImService {
        if (org.apache.commons.lang.StringUtils.isNotBlank(patient)) {
            sql += " AND (op.consumer='" + patient + "' or op.patient ='" + patient + "')";
        }
        if(!StringUtils.isEmpty(dept)){
            sql += " AND op.dept='" + dept + "' ";
        }
        if (!StringUtils.isEmpty(title)) {
            title = "%" + title + "%";
@ -4417,7 +4419,8 @@ public class ImService {
     *
     * @return
     */
    public Long countConsultRecordByDoctor2(String doctor, String id, String type, Integer status, String title, String start_time, String end_time) {
    public Long countConsultRecordByDoctor2(String doctor, String id, String type, Integer status, String title,
                                            String start_time, String end_time,String dept) {
        String sql = "";
        sql = "SELECT " +
                " COUNT(1) AS \"total\" " +
@ -4438,7 +4441,9 @@ public class ImService {
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
            sql += " AND op.doctor='" + doctor + "' ";
        }
        if(!StringUtils.isEmpty(dept)){
            sql += " AND op.dept='" + dept + "' ";
        }
        if (!StringUtils.isEmpty(title)) {
            title = "%" + title + "%";
            sql += " and (op.patient_name like '" + title + "' OR op.doctor_name like '" + title + "' OR op.dept_name like '" + title + "' )";
@ -4450,11 +4455,9 @@ public class ImService {
                } else {
                    sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time >= '" + start_time + "'";
            }
        }
        if (!StringUtils.isEmpty(end_time)) {
@ -4464,11 +4467,9 @@ public class ImService {
                } else {
                    sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time <= '" + end_time + "'";
            }
        }
        //咨询类型
@ -4555,11 +4556,9 @@ public class ImService {
                } else {
                    sql += " and a.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and a.create_time >= '" + start_time + "'";
            }
        }
        if (!StringUtils.isEmpty(end_time)) {
@ -4569,11 +4568,9 @@ public class ImService {
                } else {
                    sql += " and a.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and a.create_time <= '" + end_time + "'";
            }
        }
        //咨询类型
@ -4599,7 +4596,6 @@ public class ImService {
        }
        sql = sql + "\tORDER BY a.create_time desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> map : mapList) {
            if (map.get("patientIdcard") != null) {

+ 18 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/statistics/ScreenQvo.java

@ -18,6 +18,8 @@ public class ScreenQvo {
    private String area;//区域code
    private int level;//等级
    private String index;//指标
    private String interval;//1日 2周 3月 (按照日周月聚合)
    private String level2_type;//6医生 5科室 4医院
    private int flag;//1本月 2近半年 3全年
@ -199,4 +201,20 @@ public class ScreenQvo {
   public void setSsc(String ssc) {
      this.ssc = ssc;
   }
    public String getInterval() {
        return interval;
    }
    public void setInterval(String interval) {
        this.interval = interval;
    }
    public String getLevel2_type() {
        return level2_type;
    }
    public void setLevel2_type(String level2_type) {
        this.level2_type = level2_type;
    }
}

+ 18 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/DeviceHealthIndexVO.java

@ -30,6 +30,8 @@ public class DeviceHealthIndexVO {
    private String value7;
    private String healthStandard;
    private String button;
    private String dept;
    private String deptName;
    public DeviceHealthIndexVO() {
    }
@ -204,4 +206,20 @@ public class DeviceHealthIndexVO {
    public void setButton(String button) {
        this.button = button;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
}

+ 19 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyPatientDeviceVO.java

@ -31,7 +31,9 @@ public class WlyyPatientDeviceVO {
	private String iccid;//设备物联卡iccid
	private String imsi;//设备物联卡imsi
	private String manufacturer;//厂家名称
	
	private Integer del;
	private String applyStatus;
	public Integer getId() {
		return id;
	}
@ -200,4 +202,20 @@ public class WlyyPatientDeviceVO {
	public void setManufacturer(String manufacturer) {
		this.manufacturer = manufacturer;
	}
	public Integer getDel() {
		return del;
	}
	public void setDel(Integer del) {
		this.del = del;
	}
	public String getApplyStatus() {
		return applyStatus;
	}
	public void setApplyStatus(String applyStatus) {
		this.applyStatus = applyStatus;
	}
}

+ 5 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -833,6 +833,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "title",required = false) String title,
			@ApiParam(name = "patient", value = "患者id")
			@RequestParam(value = "patient",required = false) String patient,
			@ApiParam(name = "dept", value = "科室编码")
			@RequestParam(value = "dept",required = false) String dept,
			@ApiParam(name = "id", value = "咨询ID")
			@RequestParam(value = "id",required = false) String id,
			@ApiParam(name = "type", value = "咨询类型")
@ -849,7 +851,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "pagesize",required = false) int pagesize
	)throws Exception{
		try {
			List<Map<String,Object>>  data = imService.findConsultRecordByDoctorNew(doctor, id,type,status, page,pagesize, title,start_time,end_time,patient);
			List<Map<String,Object>>  data = imService.findConsultRecordByDoctorNew(doctor, id,type,status, page,pagesize,
					dept, title,start_time,end_time,patient);
			if (data != null) {
				for(Map<String,Object> consult :data){
@ -869,7 +872,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
				}
			}
			Long total = imService.countConsultRecordByDoctor2(doctor, id,type,status,title,start_time,end_time);
			Long total = imService.countConsultRecordByDoctor2(doctor, id,type,status,title,start_time,end_time,dept);
			JSONObject result = new JSONObject();
			result.put("total",total);

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

@ -1770,6 +1770,7 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "title", value = "咨询标题关键字") @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "patient", value = "患者id") @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "dept", value = "科室编码") @RequestParam(value = "dept", required = false) String dept,
            @ApiParam(name = "id", value = "咨询ID") @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "type", value = "咨询类型") @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束") @RequestParam(value = "status", required = true) Integer status,
@ -1779,7 +1780,8 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "pagesize", value = "分页大小") @RequestParam(value = "pagesize", required = false) int pagesize
    ) throws Exception {
        try {
            List<Map<String, Object>> data = imService.findConsultRecordByDoctorNew(doctor, id, type, status, page, pagesize, title, start_time, end_time, patient);
            List<Map<String, Object>> data = imService.findConsultRecordByDoctorNew(doctor, id, type, status, page,
                    pagesize,dept, title, start_time, end_time, patient);
            if (data != null) {
                for (Map<String, Object> consult : data) {
@ -1799,7 +1801,7 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
                }
            }
            Long total = imService.countConsultRecordByDoctor2(doctor, id, type, status, title, start_time, end_time);
            Long total = imService.countConsultRecordByDoctor2(doctor, id, type, status, title, start_time, end_time,dept);
            JSONObject result = new JSONObject();
            result.put("total", total);
@ -1810,6 +1812,34 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "orgConsultPatient")
    @ApiOperation(value = "全院诊室患者")
    public ObjEnvelop orgConsultPatient(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD HH:MM:SS")
                                      @RequestParam(value = "startTime", required = false) String startTime,
                                      @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD HH:MM:SS")
                                      @RequestParam(value = "endTime", required = false) String endTime) {
        try {
            JSONObject result = statisticsEsService.orgConsultPatient(startTime,endTime);
            return ObjEnvelop.getSuccess("查询成功",result);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "deptConsultPatient")
    @ApiOperation(value = "科室诊室患者")
    public ListEnvelop deptConsultPatient(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD HH:MM:SS")
                                        @RequestParam(value = "startTime", required = false) String startTime,
                                        @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD HH:MM:SS")
                                        @RequestParam(value = "endTime", required = false) String endTime) {
        try {
            List<Map<String,Object>> result = statisticsEsService.deptConsultPatient(startTime,endTime);
            return ListEnvelop.getSuccess("查询成功",result);
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    /**
     * 获取i健康的医生信息登录大屏
@ -1901,10 +1931,10 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    }
    /**
     * 收入情况
     * 收入情况说明
     * strJson={"startDate":"2024-01-01","endDate":"2024-05-27","area":"350200","level":2}
     */
    @GetMapping(value = "/incomeSituation")
    @GetMapping(value = "incomeSituation")
    @ApiOperation(value = "收入情况")
    public ObjEnvelop incomeSituation(@RequestParam(required = true) String strJson) {
        try {
@ -1917,6 +1947,93 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    /**
     * 业务情况说明
     * strJson={"startDate":"2024-01-01","endDate":"2024-05-27","area":"350200","level":2}
     */
    @GetMapping(value = "businessSituation")
    @ApiOperation(value = "业务情况说明")
    public ObjEnvelop businessSituation(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            JSONObject json = statisticsEsService.businessSituation(qvo);
            return ObjEnvelop.getSuccess("查询成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "incomeAnalysis")
    @ApiOperation(value = "收入分析")
    public ObjEnvelop incomeAnalysis(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            JSONObject json = statisticsEsService.incomeAnalysis(qvo);
            return ObjEnvelop.getSuccess("查询成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "incomeNewTrends")
    @ApiOperation(value = "收入新增趋势")
    public ListEnvelop incomeNewTrends(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            List<JSONObject> list = statisticsEsService.incomeNewTrends(qvo);
            return ListEnvelop.getSuccess("查询成功",list);
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "incomeRanking")
    @ApiOperation(value = "收入排行")
    public ListEnvelop incomeRanking(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            List<JSONObject> list = statisticsEsService.incomeRanking(qvo);
            return ListEnvelop.getSuccess("查询成功",list);
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "businessAnalysis")
    @ApiOperation(value = "业务分析")
    public ObjEnvelop businessAnalysis(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            JSONObject json = statisticsEsService.businessAnalysis(qvo);
            return ObjEnvelop.getSuccess("查询成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "businessNewTrends")
    @ApiOperation(value = "业务增长趋势")
    public ObjEnvelop businessNewTrends(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            JSONObject json = statisticsEsService.businessNewTrends(qvo);
            return ObjEnvelop.getSuccess("查询成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "businessRanking")
    @ApiOperation(value = "接诊排行")
    public ListEnvelop businessRanking(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            List<JSONObject> list = statisticsEsService.businessRanking(qvo);
            return ListEnvelop.getSuccess("查询成功",list);
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
}

+ 58 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/CommonItemController.java

@ -6,12 +6,21 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
 * Created by yeshijie on 2023/11/3.
@ -21,8 +30,13 @@ import org.springframework.web.bind.annotation.RestController;
@Api(value = "通用项目接口")
public class CommonItemController extends EnvelopRestEndpoint {
    private static Logger logger = LoggerFactory.getLogger(CommonItemController.class);
    @Autowired
    private DoorOrderService doorOrderService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 这个接口没用了
@ -43,4 +57,48 @@ public class CommonItemController extends EnvelopRestEndpoint {
            return Envelop.getError("查询失败",-1);
        }
    }
    @RequestMapping("/open/exportExcel/fileUpload")
    @ApiOperation("文件上传")
    public String handleFileUpload(@RequestParam("file") MultipartFile file
            ,@RequestParam("token") String token) {
        if (file.isEmpty()) {
            return "文件为空";
        }
        if(StringUtils.isBlank(token)){
            return error(-1,"非法请求");
        }
        String sql = "select dict_code from wlyy_hospital_sys_dict where dict_name ='fileUpload_token'  ";
        List<String> urls = jdbcTemplate.queryForList(sql,String.class);
        if(urls.size()==0){
            return error(-1,"非法请求");
        }
        if(!token.equals(urls.get(0))){
            return error(-1,"非法请求");
        }
        // 获取文件名
        String fileName = file.getOriginalFilename();
        logger.info("上传的文件名为:" + fileName);
        // 获取文件的后缀名
        String suffixName = fileName.substring(fileName.lastIndexOf("."));
        logger.info("上传的后缀名为:" + suffixName);
        // 文件上传后的路径
        String filePath = "/data/";
        File dest = new File(filePath + fileName);
        // 检测是否存在目录
        if (!dest.getParentFile().exists()) {
            dest.getParentFile().mkdirs();
        }
        try {
            file.transferTo(dest);
            return "上传成功";
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "上传失败";
    }
}

+ 4 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/StatisticsController.java

@ -65,11 +65,11 @@ public class StatisticsController extends EnvelopRestEndpoint {
    @GetMapping(value = "deviceUseDetail")
    @ApiOperation(value = "设备使用情况明细")
    public ListEnvelop deviceUseDetail(@RequestParam(required = false) String sort,
    public ListEnvelop deviceUseDetail(@RequestParam(required = false) String sorting,
                                       @RequestParam(required = false) String startDate,
                                       @RequestParam(required = false) String endDate) {
        try {
            List<Map<String,Object>> list = statisticsService.deviceUseDetail(sort,startDate,endDate);
            List<Map<String,Object>> list = statisticsService.deviceUseDetail(sorting,startDate,endDate);
            return ListEnvelop.getSuccess("查询成功",list);
        } catch (Exception e) {
            e.printStackTrace();
@ -81,12 +81,12 @@ public class StatisticsController extends EnvelopRestEndpoint {
    //导出设备使用情况明细
    @GetMapping(value="exportExcel/deviceUseDetail")
    public void exportList(
            @RequestParam(required = false) String sort,
            @RequestParam(required = false) String sorting,
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            HttpServletResponse response){
        try {
            List<Map<String,Object>> list = statisticsService.deviceUseDetail(sort,startDate,endDate);
            List<Map<String,Object>> list = statisticsService.deviceUseDetail(sorting,startDate,endDate);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=deviceUseDetail.xls");
            OutputStream os = response.getOutputStream();

+ 2 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/StatisticsService.java

@ -62,7 +62,7 @@ public class StatisticsService {
            if("1".equals(type)){
                devcieXt = Integer.parseInt(map.get("num")+"");
            }
            if("3".equals(type)){
            if("2".equals(type)){
                devcieXy = Integer.parseInt(map.get("num")+"");
            }
        }
@ -81,7 +81,7 @@ public class StatisticsService {
            if("1".equals(type)){
                uploadXt = Integer.parseInt(map.get("num")+"");
            }
            if("3".equals(type)){
            if("2".equals(type)){
                uploadXy = Integer.parseInt(map.get("num")+"");
            }
        }

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceService.java

@ -377,7 +377,7 @@ public class DeviceService {
		List<WlyyPatientDeviceVO> list = new ArrayList<>();
		String sql = "SELECT d.id as id,d.device_id as deviceId,d.user as user,p.name as userName,d.category_code as categoryCode,d.device_name as deviceName," +
				"d.device_sn as deviceSn,d.sim as sim,d.user_type as userType,p.mobile," +
				"CONCAT(LEFT (p.idcard,6),'**********',RIGHT (p.idcard,2)) userIdcard,d.czrq as czrq " +
				"CONCAT(LEFT (p.idcard,6),'**********',RIGHT (p.idcard,2)) userIdcard,d.czrq as czrq,d.del,d.apply_status applyStatus " +
				"FROM wlyy_patient_device d,base_patient p " +
				"WHERE d.`user`=p.id ";
		if(StringUtils.isNotBlank(userName)){

+ 1 - 16
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientDeviceService.java

@ -62,22 +62,6 @@ public class PatientDeviceService  {
    private DeviceDetailService deviceDetailService;
    /**
     * 验证sn码 先调总部接口 未注册才查询本地数据库,如果也没有才不能绑定
     * 屏蔽总部调总部接口,直接本地数据库验证,modify by Hmf on 2020.1.15
     * @param deviceSn
     * @return
     * @throws Exception
     */
    public Boolean checkDeviceSn(String deviceSn) throws Exception{
        Boolean flag = false;
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSn);
        if(deviceDetail != null){
            flag = true;
        }
        return flag;
    }
    /**
     * 保存患者设备
     */
@ -192,6 +176,7 @@ public class PatientDeviceService  {
            //增加筛选条件
            Predicate predicate = criteriaBuilder.conjunction();
            predicate.getExpressions().add(criteriaBuilder.equal(root.get("user"), patientCode));
            predicate.getExpressions().add(criteriaBuilder.equal(root.get("del"), 0));
            predicate.getExpressions().add(criteriaBuilder.ge(root.get("id"), id));
            return predicate;
        };