LAPTOP-KB9HII50\70708 1 éve
szülő
commit
ea40798a4c

+ 152 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/ResourceBrowseDao.java

@ -639,7 +639,8 @@ public class ResourceBrowseDao {
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlDataAndCondition(String sql,String queryParam,String sortParam,Integer page, Integer size,List<String> resourcesCodes) throws Exception {
    public Page<Map<String, Object>> getMysqlDataAndCondition(String sql,String queryParam,String sortParam,Integer page,
                                                              Integer size,List<String> resourcesCodes,int dataSource) throws Exception {
        String sortOrder = "";
        String sortOrderSql = "";
        if (StringUtils.isNoneBlank(sortParam)){
@ -661,6 +662,9 @@ public class ResourceBrowseDao {
        if (StringUtils.isNoneBlank(queryParam)){
            queryParam =" where 1=1 "+ queryParam;
        }
        if(dataSource==2){
            queryParam = "";
        }
        //判定是否完整sql语句
        sql =sql+queryParam+sortOrderSql;
        //查询总条数
@ -802,6 +806,152 @@ public class ResourceBrowseDao {
        return new PageImpl<>(list, PageRequest.of(page - 1, size), count);
    }
    public String transforParamValue(String paramValue){
        if(StringUtils.isBlank(paramValue)){
            return paramValue;
        }
        paramValue = paramValue.replaceAll("filterAreaCode","");
        paramValue = paramValue.replaceAll("filterCreateTimeF","");
        paramValue = paramValue.replaceAll("filterCreateTimeR","");
        paramValue = paramValue.replaceAll("filterCreateTime","");
        paramValue = paramValue.replaceAll("filterManagedTimeShort","");
        paramValue = paramValue.replaceAll("filterExitTimeShort","");
        paramValue = paramValue.replaceAll("filterLostVisitTimeShort","");
        paramValue = paramValue.replaceAll("filterUnmanagedTimeShort","");
        paramValue = paramValue.replaceAll("filterEntryTimeShort","");
        paramValue = paramValue.replaceAll("filterAssignTimeShort","");
        paramValue = paramValue.replaceAll("filterEndTime","");
        paramValue = paramValue.replaceAll("filterFollowupDate","");
        paramValue = paramValue.replaceAll("filterExamineTime","");
        paramValue = paramValue.replaceAll("filterCheckTime","");
        paramValue = paramValue.replaceAll("filterDateHH","");
        paramValue = paramValue.replaceAll("filterWatchTime","");
        paramValue = paramValue.replaceAll("filterYesterday","");
        return paramValue;
    }
    /**
     * 参数处理
     * copdgroup	管理状态
     * date	时间
     * groupScreeningStatus1	分组
     * hospital	社区医院
     * org	等级医院
     * town	区
     * @param paramValue
     * @param dataMap
     * @return
     */
    public String transforParamValue(String paramValue,Map<String,String> dataMap){
        if(StringUtils.isBlank(paramValue)){
            return paramValue;
        }
        String filterAreaCode = "";
        String filterCreateTime= "";
        String filterCreateTimeF= "";// f.create_time
        String filterCreateTimeR= "";// r.create_time
        String filterFollowupDate= "";// f.followup_date
        String filterExamineTime= "";// a.examine_time
        String filterCheckTime= "";// a.check_time
        String filterDateHH= "";// hh.date
        String filterWatchTime= "";// a.watch_time
        String filterManagedTimeShort= "";//a.managed_time_short `status`='1'
        String filterExitTimeShort= "";//a.exit_time_short `status`='3'
        String filterLostVisitTimeShort= "";//a.lost_visit_time_short `status`='2'
        String filterUnmanagedTimeShort= "";//a.unmanaged_time_short `status`='4'
        String filterEntryTimeShort= "";//a.entry_time_short
        String filterAssignTimeShort= "";//a.assign_time_short
        String filterEndTime= "";//r.end_time
        String filterYesterday= "";// yesterdayWatchNum
        String startDate = dataMap.get("startDate");//结束时间
        String endDate = dataMap.get("endDate");//开始时间
        String filterCommon = "";
        if(StringUtils.isNotBlank(startDate)){
            String startDateShort = startDate.replaceAll("-","");
            String startDate2 = startDate.replace("-", "/");
            filterCreateTime += " and a.create_time>='"+startDate+"' ";
            filterExamineTime += " and a.examine_time>='"+startDate+"' ";
            filterCheckTime += " and a.check_time>='"+startDate+"' ";
            filterCreateTimeF += " and f.create_time>='"+startDate+"' ";
            filterCreateTimeR += " and r.create_time>='"+startDate+"' ";
            filterFollowupDate += " and f.followup_date>='"+startDate+"' ";
            filterWatchTime += " and a.watch_time>='"+startDate+"' ";
            filterDateHH += " and hh.date>='"+startDate+"' ";
            filterManagedTimeShort += " and a.managed_time_short>='"+startDateShort+"' ";
            filterExitTimeShort += " and a.exit_time_short>='"+startDateShort+"' ";
            filterLostVisitTimeShort += " and a.lost_visit_time_short>='"+startDateShort+"' ";
            filterUnmanagedTimeShort += " and a.unmanaged_time_short>='"+startDateShort+"' ";
            filterEntryTimeShort += " and a.entry_time_short>='"+startDateShort+"' ";
            filterAssignTimeShort += " and a.assign_time_short>='"+startDateShort+"' ";
            filterEndTime += " and r.end_time>='"+startDate2+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            String endDateShort = endDate.replaceAll("-","");
            String endDate2 = endDate.replace("-", "/");
            filterCreateTime += " and a.create_time<='"+endDate+" 23:59:59' ";
            filterExamineTime += " and a.examine_time<='"+endDate+" 23:59:59' ";
            filterCheckTime += " and a.check_time<='"+endDate+" 23:59:59' ";
            filterCreateTimeF += " and f.create_time<='"+endDate+" 23:59:59' ";
            filterCreateTimeR += " and r.create_time<='"+endDate+" 23:59:59' ";
            filterFollowupDate += " and f.followup_date<='"+endDate+" 23:59:59' ";
            filterWatchTime += " and a.watch_time<='"+endDate+" 23:59:59' ";
            filterDateHH += " and hh.date<='"+endDate+" 23:59:59' ";
            filterManagedTimeShort += " and a.managed_time_short<='"+endDateShort+"' ";
            filterExitTimeShort += " and a.exit_time_short<='"+endDateShort+"' ";
            filterLostVisitTimeShort += " and a.lost_visit_time_short<='"+endDateShort+"' ";
            filterUnmanagedTimeShort += " and a.unmanaged_time_short<='"+endDateShort+"' ";
            filterEntryTimeShort += " and a.entry_time_short<='"+endDateShort+"' ";
            filterAssignTimeShort += " and a.assign_time_short<='"+endDateShort+"' ";
            filterEndTime += " and r.end_time<='"+endDate2+"' ";
            filterYesterday = DateUtil.getNextDay(endDate,-1);
        }else {
            filterYesterday = DateUtil.getNextDay(new Date(),-1);
        }
        for (Map.Entry<String,String> entry : dataMap.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            if("copdgroup".equals(key)){
                //管理状态
                filterCommon += " and a.status='"+value+"' ";
            }
            if("groupScreeningStatus1".equals(key)){
                //分组
                filterCommon += " and a.group_screening_status='"+value+"' ";
            }
            if("town".equals(key)){
                //区
                filterAreaCode += " and h.town = '"+value+"' ";
            }
            if("org".equals(key)){
                //等级医院
                filterAreaCode += " and d.class_name = '"+value+"' ";
            }
            if("hospital".equals(key)){
                //社区医院
                filterAreaCode += " and h.code = '"+value+"' ";
            }
        }
        filterCreateTime += filterCommon;
        paramValue = paramValue.replaceAll("filterAreaCode",filterAreaCode);
        paramValue = paramValue.replaceAll("filterCreateTimeF",filterCreateTimeF);
        paramValue = paramValue.replaceAll("filterCreateTimeR",filterCreateTimeR);
        paramValue = paramValue.replaceAll("filterCreateTime",filterCreateTime);
        paramValue = paramValue.replaceAll("filterManagedTimeShort",filterManagedTimeShort);
        paramValue = paramValue.replaceAll("filterExitTimeShort",filterExitTimeShort);
        paramValue = paramValue.replaceAll("filterLostVisitTimeShort",filterLostVisitTimeShort);
        paramValue = paramValue.replaceAll("filterUnmanagedTimeShort",filterUnmanagedTimeShort);
        paramValue = paramValue.replaceAll("filterEntryTimeShort",filterEntryTimeShort);
        paramValue = paramValue.replaceAll("filterAssignTimeShort",filterAssignTimeShort);
        paramValue = paramValue.replaceAll("filterEndTime",filterEndTime);
        paramValue = paramValue.replaceAll("filterFollowupDate",filterFollowupDate);
        paramValue = paramValue.replaceAll("filterExamineTime",filterExamineTime);
        paramValue = paramValue.replaceAll("filterCheckTime",filterCheckTime);
        paramValue = paramValue.replaceAll("filterDateHH",filterDateHH);
        paramValue = paramValue.replaceAll("filterWatchTime",filterWatchTime);
        paramValue = paramValue.replaceAll("filterYesterday",filterYesterday);
        return paramValue;
    }
    //参数处理
    public String transforParam(String paramSql,String tableSql,Map<String,String> dataMap){
        if(StringUtils.isBlank(paramSql)){
@ -901,6 +1051,7 @@ public class ResourceBrowseDao {
        if (StringUtils.isNoneBlank(sortOrder)){
            sortOrderSql +=" order by "+sortOrder.substring(0,sortOrder.length()-1);
        }
        tableSql = transforParamValue(tableSql);
        tableSql = transforParam(paramSql,tableSql,null);
        //判定是否完整sql语句
        sql = "select T.* from " + tableSql +sortOrderSql;

+ 10 - 5
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java

@ -509,12 +509,20 @@ public class ResourceBrowseService extends BaseJpaService {
        String where = "";
        Map<String,Integer> relationMap = new HashMap<>();//多视图关联
        Map<String,String> filedMap = new HashMap<>();//参数加别名
        Map<String,String> dataMap = null;
        if (!StringUtils.isEmpty(queryCondition)) {
            dataMap = parseConditionMap(queryCondition);
        }
        int dataSource = 0;
        //资源判空检查
        for (String code : codeList) {
            RsResource rsResources = rsResourceService.getResourceByCategory(code,"standard");
            if (rsResources == null) {
                throw new ApiException( "无效的资源编码" + code,ErrorCode.BAD_REQUEST.value());
            }
            if(dataSource==0){
                dataSource = rsResources.getDataSource();
            }
//            if(rsResources.getDataSource()==2&&codeList.size()>1){
//                throw new ApiException("指标统计,只能选择单个指标");
//            }
@ -535,6 +543,7 @@ public class ResourceBrowseService extends BaseJpaService {
                        sortOrder ="T."+key+" "+ value+",";
                    }
                }else if ("table".equals(paramKey)){
                    paramValue = resourceBrowseDao.transforParamValue(paramValue,dataMap);
                    tableName += " ("+paramValue+") "+ code +",";
                }else if("relation".equals(paramKey)){
                    String relate[] = paramValue.split(",");
@ -565,10 +574,6 @@ public class ResourceBrowseService extends BaseJpaService {
        tableName = tableName.substring(0,tableName.length()-1);
        Map<String,String> dataMap = null;
        if (!StringUtils.isEmpty(queryCondition)) {
            dataMap = parseConditionMap(queryCondition);
        }
        if(!StringUtils.isEmpty(paramSql)){
            tableName = resourceBrowseDao.transforParam(paramSql,tableName,dataMap);
        }
@ -603,7 +608,7 @@ public class ResourceBrowseService extends BaseJpaService {
        String queryString = org.apache.commons.lang3.StringUtils.join(paramList, ",");
        String sql = " select "+queryString+" from "+tableName;
        String sortParam = "";
        return resourceBrowseDao.getMysqlDataAndCondition(sql, stringBuffer.toString(),sortParam, page, size,codeList);
        return resourceBrowseDao.getMysqlDataAndCondition(sql, stringBuffer.toString(),sortParam, page, size,codeList,dataSource);
    }
    /**