wushilong 3 лет назад
Родитель
Сommit
c993857eb7

+ 4 - 0
common/common-rest-model/pom.xml

@ -60,5 +60,9 @@
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
    </dependencies>
</project>

+ 16 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -82,6 +82,22 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "patientAnalysis")
    @ApiOperation(value = "居民分析")
    public ObjEnvelop patientAnalysis(@RequestParam(required = true) String endDate,
                                      @RequestParam(required = true) String area,
                                      @RequestParam(required = true) int level,
                                      @ApiParam(name="index",value="42幼儿,37老人",defaultValue = "")@RequestParam(required = true) String index){
        try {
            JSONObject result = statisticsService.patientAnalysisDP(endDate, area, level, index);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    @GetMapping(value = "serviceResources")
    @ApiOperation(value = "服务资源v0.7.0")
    public ObjEnvelop ServiceResources() {

+ 235 - 14
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -136,19 +136,19 @@ public class StatisticsService {
        String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 "+filter;
        Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
        //男 女 性别总数
        /*//男 女 性别总数
        String sexCountSql = "SELECT COUNT(*) ss, CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END AS sex " +
                "FROM wlyy_patient_label lab " +
                "INNER JOIN base_patient p ON p.id = lab.patient AND lab.label_type = '3' AND lab.patient NOT IN ('null') GROUP BY p.sex";
        List<Map<String, Object>> sexCountMap = jdbcTemplate.queryForList(sexCountSql);
        res.put("sexCount",sexCountMap);
        res.put("sexCount",sexCountMap);*/
        //老人-紧急预警
        res.put("index_"+41,emergencyCallNum);
        //老人 安放监护
        res.put("index_"+43,securityMonitoringNum);
        //评估类型
        res.put("capacityAssessment",capacityAssessment(endDate,defalutArea,defalutLevel));
        res.put("capacityAssessment",cloudCareForTheElderly(endDate,defalutArea,defalutLevel));
        //居民健康标签纬度
        res.put("patientLabelStatistic",statisticsOrderServer("47",endDate,2,"2"));
@ -161,20 +161,91 @@ public class StatisticsService {
            res.put("activity_"+tmp.get("type").toString(),num);
        }
        //返回活动曲线图
        sql = "select count(id),DATE_FORMAT(create_time,'%Y-%m-%d') as total from base_child_activity_registration " +
                "GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d')  " +
                "ORDER BY create_time";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        res.put("quxiantu_3",maps);
        //幼儿活动报名总数
        //activity-3 幼儿活动报名-总数
        sql = " select count(id) as total from base_child_activity_registration ";
        Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
        res.put("activity_3",count);
        return res;
    }
    /*曲线*/
    public JSONObject curveTotal(String day,String type){
        JSONObject res = new JSONObject();
        //sql
        //3 幼儿活动
        /*幼儿活动*/
        if("activity_3".equals(type)){
            /*幼儿活动报名 曲线*/
            String sqlActivity = "SELECT count(id),DATE_FORMAT(create_time,'%Y-%m-%d') as total FROM base_child_activity_registration" +
                    " WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= date(create_time)" +
                    " GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time";
            List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlActivity);
            res.put("count",maps);
        }
        return null;
    }
    /*综合总数*/
    public JSONObject combinedTotal(String type ,String endDate) throws Exception {
        JSONObject res = new JSONObject();
        String index = "";
        //es
        // 39 老人-生活照料-服务工单数
        // 44 老人-生活照料-代预约
        // 28 新生儿-在线咨询总数
        // 35 新生儿-上门辅导-服务工单数
        //sql
        // activity-3 幼儿活动
        // activity-1   活动浏览次数
        // activity-2   公艺课程播放
        //41 老人-紧急呼叫
        //43 老人 安放监护
        //type 1 老人 2 幼儿
        if ("1".equals(type)){
             index = "39,44";
            String[] indexes = index.split(",");
            for(String ind:indexes){
                //总量
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
                res.put("index_"+ind,saveModel.getResult2().longValue());
            }
            String emergencyCallSql = "SELECT COUNT(1) FROM base_emergency_assistance_order WHERE status >= 0 ";
            Integer emergencyCallNum = jdbcTemplate.queryForObject(emergencyCallSql,Integer.class);
            String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 ";
            Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
            res.put("index_41",emergencyCallNum);
            res.put("index_43",securityMonitoringNum);
        }else {
            index = "28,35";
            String[] indexes = index.split(",");
            for(String ind:indexes){
                //总量
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
                res.put("index_"+ind,saveModel.getResult2().longValue());
            }
            //   活动浏览次数
            //   公艺课程播放
            String sql = " select type,num from base_child_activity_click where type in(1,2)";
            List<Map<String,Object>> lists = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> tmp:lists){
                Integer num = Integer.parseInt(tmp.get("num").toString());
                res.put("activity_"+tmp.get("type").toString(),num);
            }
            /*幼儿活动报名 总数*/
            String sqlActivity = " select count(id) as total from base_child_activity_registration ";
            Integer count = jdbcTemplate.queryForObject(sqlActivity,Integer.class);
            res.put("activity_3",count);
        }
        return null;
    }
    public JSONObject serviceResources(){
        String orgFilter = "";
        String sqlOrg = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
@ -723,7 +794,6 @@ public class StatisticsService {
            range.put("amount", saveModel.getResult2());
            result.add(range);
        }
        return result;
    }
@ -911,10 +981,10 @@ public class StatisticsService {
        }
        JSONArray jsonArray = new JSONArray();
        String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='3' " +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='1' " +
                  filter+"   \n" +
                ")A on dict.dict_code = A.label_code " +
                "where  dict.dict_name='older_label'  and  dict.dict_code is not null and dict_code <= 7  \n" +
                "where  dict.dict_name='service_type'  and  dict.dict_code is not null and dict_code <> 5  \n" +
                " GROUP BY dict.dict_code; ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
@ -1510,4 +1580,155 @@ public class StatisticsService {
    }
    /*大屏 老人云照护 病人分析 */
    public JSONObject patientAnalysisDP(String endDate, String area, int level,String index) throws Exception{
        JSONObject res = new JSONObject();
        String areaLevel = "6";
        if("42".equals(index)){
            areaLevel = "4";
            //新生儿
            //是否入学
            List<SaveModel> statusList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL,null,null,areaLevel);
            JSONArray statusArray = new JSONArray();
            for(int i=0;i<statusList.size();i++){
                SaveModel saveModel = statusList.get(i);
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                statusArray.add(json);
            }
            res.put("statusList",statusArray);
        }else{
            //老人
            //能力评估 从签约时服务标签取
            res.put("levelList",cloudCareForTheElderly(null,null,null));
            //居民健康标签
            List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate,endDate,area,level,"47",SaveModel.timeLevel_DDL,null,null,"2");
            JSONArray labelArr = new JSONArray();
            Long total = 0l;
            for(int i=0;i<list.size();i++){
                SaveModel saveModel = list.get(i);
                JSONObject json = new JSONObject();
                if (saveModel.getResult2().longValue()==0&&StringUtils.isBlank(saveModel.getSlaveKey1())){
                    continue;
                }
                if ("0".equals(saveModel.getSlaveKey1())){//去除60岁以下老人
                    continue;
                }
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                total+=saveModel.getResult2().longValue();
                labelArr.add(json);
            }
            JSONObject arrTmp = new JSONObject();
            arrTmp.put("patientLabelTotal",total);
            arrTmp.put("patientLabelList",labelArr);
            res.put("patientLabelStatistic",arrTmp);
            //年龄分布 50
//            ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL,null,null,"2");
            List<SaveModel>  ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate,endDate,area,level,"50",SaveModel.timeLevel_DDL,null,null,"2");
            JSONArray ageArray = new JSONArray();
            for(int i=0;i<ageList.size();i++){
                SaveModel saveModel = ageList.get(i);
                if ("0".equals(saveModel.getSlaveKey1())){//去除60岁以下老人
                    continue;
                }
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                ageArray.add(json);
            }
            res.put("ageList",ageArray);
            //居住小区分布
            String filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " not in ('"+orgCodes+"')";
            }
            String  sql = "select count(id) total,residential_area residentialArea  from base_patient where del=1 and id "+filter+"  and archive_type=1 " +
                    "GROUP BY residential_area ORDER BY total desc";
            List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
            Iterator<Map<String, Object>> iterator = result.iterator();
            Map<String, Object> tmp = new HashMap<>();
            while (iterator.hasNext()){
                tmp = iterator.next();
                if (null==tmp.get("residentialArea")){
                    iterator.remove();
                    break;
                }
            }
            result.add(tmp);
            res.put("residentialArea",result);
        }
        //性别分析
        String archiType="";
        if("42".equals(index)){
            archiType="2";
        }
        if("37".equals(index)){
            archiType="1";
        }
        List<SaveModel> sexList = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate,defalutArea, level, "51",SaveModel.timeLevel_DDL,null,archiType,null,null,"2","1");
        JSONArray sexArray = new JSONArray();
        for(int i=0;i<sexList.size();i++){
            SaveModel saveModel = sexList.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            sexArray.add(json);
        }
        res.put("sexList",sexArray);
        return res;
    }
    /*大屏 老人云照护 评估*/
    public JSONArray cloudCareForTheElderly(String endDate, String area, Integer level) throws Exception{
        //评估类型
        String filter = "";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            if (StringUtils.isNotBlank(orgCodes)){
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and lab.patient not in ('"+orgCodes+"')";
            }
        }
        JSONArray jsonArray = new JSONArray();
        String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='3' " +
                filter+"   \n" +
                ")A on dict.dict_code = A.label_code " +
                "where  dict.dict_name='older_label'  and  dict.dict_code is not null and dict_code <= 7  \n" +
                " GROUP BY dict.dict_code; ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String older = " select count(distinct lab.patient) from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='1' "+filter;
        Integer count = jdbcTemplate.queryForObject(older,Integer.class);
        for(Map<String,Object> map:list){
            JSONObject json = new JSONObject();
            DecimalFormat df = new DecimalFormat("0.00");
            json.put("rate", df.format((Integer.parseInt(map.get("total").toString())*1.00) / count * 100));
            json.put("num", map.get("total"));
            json.put("code",map.get("dict_code").toString());
            json.put("name",map.get("dict_value").toString());
            jsonArray.add(json);
        }
        return jsonArray;
    }
}

+ 0 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -1939,8 +1939,6 @@ public class MonitorPlatformService {
        //取药方式获取
        JSONArray shippingTypeArray = jsonObject.getJSONArray("shippingTypeTotal");
        List<Map> shippingTypeList = JSONObject.parseArray(shippingTypeArray.toJSONString(), Map.class);
        //取药列表存放
        resoultMap.put("mediicineorderList", mediicineorderListMap);
        //设备信息存放