wsl 2 anni fa
parent
commit
ddd9dc2556

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

@ -859,9 +859,9 @@ public class StatisticsService {
            areaFilter = " and EXISTS ( select 1 from " +
                    "base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
                    " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
                    " and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = a.id and r.team_code='"+area+"') OR ( a.saas_id = '"+area+"')";
                    " and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = a.id and r.team_code='"+area+"') ";
        }
        String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and a.sign_status=1 " +
        String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1  " +
                " and del='1' "+areaFilter+" " + oldFilter + " GROUP BY online";
        List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
        for (Map<String, Object> map : list1) {
@ -3181,7 +3181,7 @@ public class StatisticsService {
        String sql = "";
        switch (type) {
            case 1:
                sql = " SELECT count(DISTINCT p.id) as total FROM " +
                sql = " SELECT SUM(a.total)FROM ( SELECT count(DISTINCT p.id) as total FROM " +
                        " base_patient p,base_service_package_sign_record sr,base_service_package_record r,base_service_package_item i,base_service_package pack,base_team t,base_team_member tm,base_doctor d  " +
                        " WHERE " +
                        " sr.id = r.sign_id  " +
@ -3195,7 +3195,7 @@ public class StatisticsService {
                        " AND tm.team_code = t.id " +
                        " AND p.archive_type = 1 " +nameSql+idcardSql+orgNameSql+
                        " AND d.id = tm.doctor_code <testUserSql>  " +
                        " GROUP BY p.idcard " +
                        " " +
                        " UNION " +
                        " SELECT " +
                        " count(DISTINCT p.id) as total " +
@ -3203,19 +3203,22 @@ public class StatisticsService {
                        " base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user`  " +
                        " WHERE p.sign_status = 0 AND p.del = 1 AND d.del = 0 AND p.archive_type = 1 " + nameSql+idcardSql+orgNameSql2+
                        " <testUserSql>  " +
                        " GROUP BY p.idcard  ";
                        " ) a ";
                break;
            case 2:
                sql =" SELECT count(DISTINCT p.id) as total " +
                        " FROM base_patient p  " +
                        " WHERE p.archive_type = 2 and p.del = 1 "+nameSql+idcardSql+" <testUserSql>";
                sql += "  ORDER BY id ";
                break;
            case 3:
                sql =" SELECT count(DISTINCT p.id) as total FROM base_patient p WHERE  p.del =1 AND p.register = 2"+nameSql+idcardSql;
                sql += "  ORDER BY id ";
                break;
        }
        sql = sql.replace("<testUserSql>",testUserSql);
        sql += "  ORDER BY id ";
        Integer integer  = jdbcTemplate.queryForObject(sql,Integer.class);
        return integer;
    }
@ -3597,7 +3600,7 @@ public class StatisticsService {
        if (StringUtils.isNotBlank(deviceSn)) deviceSnSql = " AND pd.device_sn = '" + deviceSn + "'";
        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' ";
        String sqltmp = " SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' OR dict_name ='jkzl_helper' OR dict_name= 'jkzl_olderRelative' OR dict_name ='jkzl_user') ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
@ -3636,12 +3639,12 @@ public class StatisticsService {
                    " FROM " +
                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
                    " pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
                    " pd.del = 0 " +filter+nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
            totalSql = " SELECT count(DISTINCT pd.id) FROM " +
                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
                    " pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
                    " pd.del = 0 " +filter+nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
        }
        deviceSql += " GROUP BY id LIMIT " + page*size + "," + size + " ";