Ver código fonte

代码修改

LAPTOP-KB9HII50\70708 1 ano atrás
pai
commit
5609bf55aa

+ 33 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceIntegratedController.java

@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@ -64,6 +65,8 @@ public class ResourceIntegratedController extends EnvelopRestEndpoint {
    private ResourceBrowseService resourceBrowseService;
    @Autowired
    private ResourceBrowseMetadataDao resourceBrowseMetadataDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 综合查询档案数据列表树 zuul
@ -131,6 +134,36 @@ public class ResourceIntegratedController extends EnvelopRestEndpoint {
        return ListEnvelop.getSuccess("查询成功",list);
    }
    @GetMapping("findDict")
    @ApiOperation("字典")
    public Envelop findDict(@ApiParam(name = "dictName", value = "字典名称 groupScreeningStatus1分组,town区 org等级医院 hospital社区医院 copdgroup管理状态")
                            @RequestParam(value = "dictName", required = true) String dictName,
                            @ApiParam(name = "type", value = "类型 1具体字典 2分类字典")
                            @RequestParam(value = "type", required = true) String type){
        try {
            String sql = "";
            if("1".equals(type)){
                if("town".equals(dictName)){
                    sql = "SELECT code,name from wlyy.dm_town WHERE city = '350200'";
                }else if ("org".equals(dictName)){
                    sql = "SELECT DISTINCT class_name code,table_name name  from wlyy.copd_followup_dict WHERE dict_name='hospital_community_relation'";
                }else if ("hospital".equals(dictName)){
                    sql = "SELECT DISTINCT code,value name  from wlyy.copd_followup_dict WHERE dict_name='hospital_community_relation' ORDER BY code";
                }else {
                    sql = "SELECT DISTINCT code,`value` name from wlyy.copd_followup_dict WHERE dict_name = '"+dictName+"'";
                }
            }else {
                sql = "SELECT code,`value` name from system_dict WHERE dict_name = '"+dictName+"'";
            }
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return ListEnvelop.getSuccess("获取成功",list);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("获取失败");
        }
    }
    /**
     * 综合查询档案数据检索 zuul
     * @param resourcesCode

+ 17 - 13
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/ResourceBrowseDao.java

@ -803,7 +803,7 @@ public class ResourceBrowseDao {
    }
    //参数处理
    public String transforParam(String paramSql,String tableSql){
    public String transforParam(String paramSql,String tableSql,Map<String,String> dataMap){
        if(StringUtils.isBlank(paramSql)){
            return tableSql;
        }
@ -817,44 +817,48 @@ public class ResourceBrowseDao {
            }else {
                key = str[0];
            }
            tableSql = tableSql.replaceAll(param,getDefaultValue(key));
            tableSql = tableSql.replaceAll(param,getDefaultValue(key,dataMap));
        }
        return tableSql;
    }
    //获取默认值
    public String getDefaultValue(String key){
    public String getDefaultValue(String key,Map<String,String> dataMap){
        if(StringUtils.isBlank(key)){
            return "";
        }
        String defaultStartDate = "2023-06-26";
        String defaultStartDateTime = "2023-06-26 00:00:00";
        String defaultEndDate = DateUtil.getStringDateShort();
        String defaultEndDateTime = DateUtil.getStringDate();
        String result = "";
        switch (key){
            case "dateTimeStart":
                result = "2023-06-26 00:00:00";
                result = defaultStartDateTime;
                break;
            case "dateTimeEnd":
                result = DateUtil.getStringDateShort() +" 23:59:59";
                result = defaultEndDate +" 23:59:59";
                break;
            case "dateTimeStartShort":
                result = "2023-06-26 00:00:00".replaceAll("-","");
                result = defaultStartDateTime.replaceAll("-","");
                break;
            case "dateTimeEndShort":
                result = DateUtil.getStringDate().replaceAll("-","");
                result = defaultEndDateTime.replaceAll("-","");
                break;
            case "dateStart":
                result = "2023-06-26";
                result = defaultStartDate;
                break;
            case "dateEnd":
                result = DateUtil.getStringDateShort();
                result = defaultEndDate;
                break;
            case "dateStartShort":
                result = "2023-06-26".replaceAll("-","");
                result = defaultStartDate.replaceAll("-","");
                break;
            case "dateEndShort":
                result = DateUtil.getStringDateShort().replaceAll("-","");
                result = defaultEndDate.replaceAll("-","");
                break;
            case "year_months":
                result = DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM);
                result = defaultEndDate.substring(0,7);
                break;
            default:
                break;
@ -897,7 +901,7 @@ public class ResourceBrowseDao {
        if (StringUtils.isNoneBlank(sortOrder)){
            sortOrderSql +=" order by "+sortOrder.substring(0,sortOrder.length()-1);
        }
        tableSql = transforParam(paramSql,tableSql);
        tableSql = transforParam(paramSql,tableSql,null);
        //判定是否完整sql语句
        sql = "select T.* from " + tableSql +sortOrderSql;
        //查询总条数

+ 43 - 7
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java

@ -515,9 +515,9 @@ public class ResourceBrowseService extends BaseJpaService {
            if (rsResources == null) {
                throw new ApiException( "无效的资源编码" + code,ErrorCode.BAD_REQUEST.value());
            }
            if(rsResources.getDataSource()==2&&codeList.size()>1){
                throw new ApiException("指标统计,只能选择当个指标");
            }
//            if(rsResources.getDataSource()==2&&codeList.size()>1){
//                throw new ApiException("指标统计,只能选择单个指标");
//            }
            List<RsResourceMetadata> resourceMetadataList = resourceBrowseMetadataDao.findResourceMetadata(code);
            for (RsResourceMetadata metadata:resourceMetadataList){
                filedMap.put(metadata.getMetadataId(),code);
@ -549,10 +549,6 @@ public class ResourceBrowseService extends BaseJpaService {
                    paramSql = param.getParamValue();
                }
            }
            if(!StringUtils.isEmpty(paramSql)){
                tableName = resourceBrowseDao.transforParam(paramSql,tableName);
            }
        }
        String code1 = codeList.get(0);
        int codeLength = codeList.size();
@ -568,6 +564,14 @@ 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);
        }
        StringBuffer stringBuffer = new StringBuffer();
        if (!StringUtils.isEmpty(queryCondition)) {
            stringBuffer = parseCondition1(queryCondition);
@ -580,7 +584,12 @@ public class ResourceBrowseService extends BaseJpaService {
        List<String> customizeList = (List<String>) objectMapper.readValue(metaData, List.class);
        //参数集合
        List<String> paramList = new ArrayList<>(customizeList.size() * 2);
        Map<String,Integer> fieldMap = new HashMap<>();//去除重复的列
        for (String id : customizeList) {
            if(fieldMap.containsKey(id)){
                continue;
            }
            fieldMap.put(id,1);
            String codeTmp = filedMap.get(id);
            if(id.contains("-")){
                String tmp = id.substring(id.lastIndexOf("-")+1);
@ -750,6 +759,33 @@ public class ResourceBrowseService extends BaseJpaService {
        return stringBuffer;
    }
    /**
     * 查询条件转换
     *
     * @param queryCondition
     * @return
     * @throws Exception
     */
    private Map<String,String> parseConditionMap(String queryCondition) throws Exception {
        Map<String,String> map = new HashMap<>();
        ObjectMapper mapper = new ObjectMapper();
        JavaType javaType = mapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, Object>> list = objectMapper.readValue(queryCondition, javaType);
        if (list != null && list.size() > 0) {
            for (Map<String, Object> item : list) {
                String andOr = String.valueOf(item.get("andOr")).trim();
                String field = String.valueOf(item.get("field")).trim();
                if(field.contains("-")){
                    field = field.substring(field.lastIndexOf("-")+1);
                }
                String cond = String.valueOf(item.get("condition")).trim();
                String value = String.valueOf(item.get("value"));
                map.put(field,value);
            }
        }
        return map;
    }
    /**
     * 新增参数
     *