Pārlūkot izejas kodu

医疗云代码

wangzhinan 1 gadu atpakaļ
vecāks
revīzija
312748a347
18 mainītis faili ar 610 papildinājumiem un 324 dzēšanām
  1. 4 12
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsDictionary.java
  2. 2 12
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsDictionaryEntry.java
  3. 9 10
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsMetadata.java
  4. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsResource.java
  5. 10 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/ehr/resource/MRsMetadata.java
  6. 124 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/EnvelopEhr.java
  7. 18 59
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceBrowseController.java
  8. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceConfigurationController.java
  9. 37 61
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceIntegratedController.java
  10. 8 4
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/service/ResourceBrowseControllerService.java
  11. 16 12
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/ResourceBrowseEndPoint.java
  12. 10 10
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsDictionaryEndPoint.java
  13. 31 23
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsDictionaryEntryEndPoint.java
  14. 37 31
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsMetadataEndPoint.java
  15. 116 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/ResourceBrowseDao.java
  16. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/ResourceBrowseMetadataDao.java
  17. 168 80
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java
  18. 5 5
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceIntegratedService.java

+ 4 - 12
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsDictionary.java

@ -1,5 +1,7 @@
package com.yihu.jw.entity.ehr.resource;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.*;
import java.io.Serializable;
@ -10,23 +12,13 @@ import java.io.Serializable;
 */
@Entity
@Table(name="rs_dictionary")
public class RsDictionary implements Serializable {
    private int id;
public class RsDictionary extends IntegerIdentityEntity {
    private String code;
    private String name;
    private String description;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    @Column(name = "code",nullable = false)
    public String getCode()
    {

+ 2 - 12
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsDictionaryEntry.java

@ -1,5 +1,6 @@
package com.yihu.jw.entity.ehr.resource;
import com.yihu.jw.entity.IntegerIdentityEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
@ -12,8 +13,7 @@ import java.io.Serializable;
 */
@Entity
@Table(name = "rs_dictionary_entry")
public class RsDictionaryEntry implements Serializable {
    private int id;
public class RsDictionaryEntry extends IntegerIdentityEntity {
    private int dictId;
    private String dictCode;
    private String code;
@ -21,16 +21,6 @@ public class RsDictionaryEntry implements Serializable {
    private String description;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "increment")
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    @Column(name = "dict_id",nullable = false)
    public Integer getDictId() {

+ 9 - 10
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsMetadata.java

@ -1,5 +1,6 @@
package com.yihu.jw.entity.ehr.resource;
import com.yihu.jw.entity.UuidIdentityEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
@ -10,9 +11,8 @@ import java.io.Serializable;
 */
@Entity
@Table(name="rs_metadata")
public class RsMetadata implements Serializable {
public class RsMetadata extends UuidIdentityEntity {
    private String id;
    private String domain;
    private String name;
    private String stdCode;
@ -24,16 +24,15 @@ public class RsMetadata implements Serializable {
    private String valid;
    private int dictId;
    private Integer dataSource;
    private String ehrId;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "assigned")
    @Column(name = "id", unique = true, nullable = false)
    public String getId() {
        return id;
    @Column(name = "ehr_id")
    public String getEhrId() {
        return ehrId;
    }
    public void setId(String id) {
        this.id = id;
    public void setEhrId(String ehrId) {
        this.ehrId = ehrId;
    }
    @Column(name = "dict_id")

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsResource.java

@ -43,6 +43,17 @@ public class RsResource extends BaseAssignedEntity {
    //分类名称
    private String categoryName;
    private String tableName;
    @Column(name="table_name")
    public String getTableName() {
        return tableName;
    }
    public void setTableName(String tableName) {
        this.tableName = tableName;
    }
    @Column(name="code",nullable = false)
    public String getCode() {
        return code;

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/ehr/resource/MRsMetadata.java

@ -17,6 +17,16 @@ public class MRsMetadata {
    private int dictId;
    private Integer dataSource;
    private String ehrId;
    public String getEhrId() {
        return ehrId;
    }
    public void setEhrId(String ehrId) {
        this.ehrId = ehrId;
    }
    public String getId() {
        return id;
    }

+ 124 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/EnvelopEhr.java

@ -0,0 +1,124 @@
package com.yihu.jw.restmodel.web;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
 * 信封对象,封装REST接口的返回值内容。包括:
 * - 页码
 * - 页大小
 * - 错误消息
 * - 错误代码
 * - 对象模型
 *
 * 信封对象的返回场景:
 * - API使用者确实无法访问返回头,即一些语言库无法处理HTTP的响应消息,这时候需要以这种形式提供返回值。
 * - API需要支持交叉域请求(通过JSONP)。
 *
 * @author llh
 */
public class EnvelopEhr<T, J> implements Serializable{
    private static final long serialVersionUID = 2076324875575488461L;
    private boolean successFlg;
    private int pageSize = 15;
    private int currPage = 1;
    private int totalPage = 0;
    private int totalCount;
    private List<T> detailModelList = new ArrayList<>();
    private J obj = (J) new HashMap<>(0);
    private String errorMsg;
    private int errorCode;
    public boolean isSuccessFlg() {
        return successFlg;
    }
    public void setSuccessFlg(boolean successFlg) {
        this.successFlg = successFlg;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getCurrPage() {
        return currPage;
    }
    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }
    public int getTotalPage() {
        if (0 == pageSize){
            pageSize = 15;
        }
        if (totalCount % pageSize > 0) {
            totalPage = totalCount / pageSize + 1;
        } else {
            totalPage = totalCount / pageSize;
        }
        return totalPage;
    }
    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
    public int getTotalCount() {
        return totalCount;
    }
    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
    public List<T> getDetailModelList() {
        return detailModelList;
    }
    public void setDetailModelList(List<T> detailModelList) {
        this.detailModelList = detailModelList;
    }
    public J getObj() {
        return obj;
    }
    public void setObj(J obj) {
        this.obj = obj;
    }
    public String getErrorMsg() {
        return errorMsg;
    }
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    public int getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }
}

+ 18 - 59
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceBrowseController.java

@ -1,18 +1,19 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.basic.agadmin.service.ResourceBrowseControllerService;
import com.yihu.jw.basic.resource.service.ResourceBrowseService;
import com.yihu.jw.basic.resource.service.RsResourceService;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.LinkedCaseInsensitiveMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -111,64 +112,22 @@ public class ResourceBrowseController extends EnvelopRestEndpoint {
     * 档案资源浏览
     */
    @GetMapping("/searchResourceData")
    public Envelop searchResourceData(String resourcesCode, String searchParams, int page, int rows, HttpServletRequest request) throws Exception {
        String url = "/resources/ResourceBrowses/getResourceData";
        Map<String, Object> params = new HashMap<>();
        params.put("resourcesCode", resourcesCode);
        params.put("roleId", "*");
        params.put("orgCode", "*");
        params.put("areaCode", "*");
        String queryCondition = "";
        if(!StringUtils.isEmpty(searchParams)){
            Pattern pattern = Pattern.compile("\\[.+?\\]");
            Matcher matcher = pattern.matcher(searchParams);
            if (matcher.find()) {
                if (searchParams.contains("{") || searchParams.contains("}")) {
                    queryCondition = searchParams;
                }
            }
        }
        Envelop envelop = resourceBrowseControllerService.getResourceData(resourcesCode,"*","*","*",queryCondition,page,rows,null);
    public PageEnvelop searchResourceData(String resourcesCode, String searchParams, int page, int rows, HttpServletRequest request) throws Exception {
        PageEnvelop pageEnvelop = new PageEnvelop();
        ObjEnvelop envelop = resourceBrowseControllerService.getResourceData(resourcesCode,"*","*","*",searchParams,page,rows,null);
        if (envelop.getStatus()==200) {
            PageEnvelop listEnvelop = new PageEnvelop();
            List<Map<String, Object>> envelopList = listEnvelop.getDetailModelList();
            List<Map<String, Object>> middleList = new ArrayList<>();
            for (Map<String, Object> envelopMap : envelopList) {
                Map<String, Object> resultMap = new HashMap<>();
                for (String key : envelopMap.keySet()) {
                    String value = envelopMap.get(key) == null? "" : String.valueOf(envelopMap.get(key));
                    if (key.equals("event_type")) {
                        String eventType = envelopMap.get(key).toString();
                        switch (eventType) {
                            case "0":
                                resultMap.put(key, "门诊");
                                break;
                            case "1":
                                resultMap.put(key, "住院");
                                break;
                            case "2":
                                resultMap.put(key, "体检");
                                break;
                            default:
                                resultMap.put(key, "未知");
                                break;
                        }
                    } else if (value.contains("T") && value.contains("Z")) {
                        String newDateStr = value.replace("T", " ").replace("Z", "");
                        resultMap.put(key, newDateStr);
                    } else {
                        resultMap.put(key, value);
                    }
                }
                middleList.add(resultMap);
            }
            List<Map<String, Object>> finalList = resourceIntegratedController.changeIdCardNo(middleList, request);
            return ListEnvelop.getSuccess("查询成功",finalList);
            net.sf.json.JSONObject object = net.sf.json.JSONObject.fromObject(envelop.getObj());
            JSONArray array = JSONArray.parseArray(object.getString("content"));
            System.out.println(object+"======="+array);
            pageEnvelop.setPageSize(rows);
            pageEnvelop.setCurrPage(page);
            pageEnvelop.setMessage("查询成功");
            pageEnvelop.setTotalCount(object.getInt("totalElements"));
            pageEnvelop.setTotalPage(object.getInt("totalPages"));
            pageEnvelop.setDetailModelList(array);
            return pageEnvelop;
        }
        return envelop;
        return pageEnvelop;
    }
    /**

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceConfigurationController.java

@ -116,12 +116,12 @@ public class ResourceConfigurationController extends EnvelopRestEndpoint {
    public List<RsResourceMetadata> getRsMetadata(List<RsResourceMetadata> rsMetadatas,String filters,int page,int size) throws Exception{
        String fs = null;
        for (RsResourceMetadata rsMetadataModel : rsMetadatas){
            fs = "id=" + rsMetadataModel.getMetadataId()+" g2;"+filters;
            fs = "ehrId=" + rsMetadataModel.getMetadataId()+" g2;"+filters;
            List<RsMetadata> metadata = metadataService.search("",fs,"",page,size);
            if (metadata.size()>0) {
                rsMetadataModel.setName(metadata.get(0).getName());
                rsMetadataModel.setColumnType(metadata.get(0).getColumnType());
                rsMetadataModel.setStdCode(metadata.get(0).getId());
                rsMetadataModel.setStdCode(metadata.get(0).getEhrId());
            }
        }
        return rsMetadatas;

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

@ -2,6 +2,7 @@ package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.resource.service.ResourceBrowseService;
import com.yihu.jw.basic.resource.service.ResourceIntegratedService;
import com.yihu.jw.basic.resource.service.RsResourceDefaultParamService;
import com.yihu.jw.basic.resource.service.RsResourceService;
@ -15,7 +16,10 @@ import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.NumberUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import jxl.Cell;
import jxl.Workbook;
import jxl.write.Label;
@ -24,11 +28,9 @@ import jxl.write.WritableWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -58,6 +60,8 @@ public class ResourceIntegratedController extends EnvelopRestEndpoint {
    private RsResourceDefaultParamService resourceDefaultParamService;
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    private ResourceBrowseService resourceBrowseService;
    /**
     * 综合查询档案数据列表树 zuul
@ -112,65 +116,37 @@ public class ResourceIntegratedController extends EnvelopRestEndpoint {
     * @param searchParams
     * @param page
     * @param rows
     * @param request
     * @return
     */
//    @RequestMapping("/searchMetadataData")
//    public Envelop searchMetadataData(String resourcesCode, String metaData, String searchParams, int page, int rows, HttpServletRequest request) throws Exception {
//        Envelop envelop = new Envelop();
//        String url = "/resource/api/v1.0/resources/integrated/metadata_data";
//        if (resourcesCode == null || resourcesCode.equals("")) {
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("资源编码不能为空");
//            return envelop;
//        }
//        Map<String, Object> params = new HashMap<>();
//        params.put("resourcesCode", resourcesCode);
//        params.put("metaData", metaData);
//        params.put("orgCode", "*");
//        params.put("areaCode", "*");
//        params.put("queryCondition", searchParams);
//        params.put("page", page);
//        params.put("size", rows);
//        HttpResponse response = HttpUtils.doGet(adminInnerUrl + url, params);
//        if (response.isSuccessFlg()) {
//            envelop = toModel(response.getContent(), Envelop.class);
//            if (envelop.isSuccessFlg()) {
//                List<Map<String, Object>> envelopList = envelop.getDetailModelList();
//                List<Map<String, Object>> middleList = new ArrayList<Map<String, Object>>();
//                for (Map<String, Object> envelopMap : envelopList) {
//                    Map<String, Object> resultMap = new HashMap<String, Object>();
//                    for (String key : envelopMap.keySet()) {
//                        String value = envelopMap.get(key) == null? "" : String.valueOf(envelopMap.get(key));
//                        if (key.equals("event_type")) {
//                            String eventType = envelopMap.get(key).toString();
//                            if (eventType.equals("0")) {
//                                resultMap.put(key, "门诊");
//                            } else if (eventType.equals("1")) {
//                                resultMap.put(key, "住院");
//                            } else if (eventType.equals("2")) {
//                                resultMap.put(key, "体检");
//                            } else {
//                                resultMap.put(key, "未知");
//                            }
//                        } else if (value.contains("T") && value.contains("Z")) {
//                            String newDateStr = value.replace("T", " ").replace("Z", "");
//                            resultMap.put(key, newDateStr);
//                        } else {
//                            resultMap.put(key, value);
//                        }
//                    }
//                    middleList.add(resultMap);
//                }
//                List<Map<String, Object>> finalList = changeIdCardNo(middleList, request);
//                envelop.setDetailModelList(finalList);
//                envelop.setSuccessFlg(true);
//                return envelop;
//            }
//            return envelop;
//        }
//        return toModel(response.getContent(), Envelop.class);
//    }
    @RequestMapping("/searchMetadataData")
    public Envelop searchMetadataData(
            @ApiParam(name = "resourcesCode", value = "资源code")
            @RequestParam(value = "resourcesCode", required = true) String resourcesCode,
            @ApiParam(name = "metaData", value = "数据元")
            @RequestParam(value = "metaData", required = false) String metaData,
            @ApiParam(name = "searchParams", value = "查询条件")
            @RequestParam(value = "searchParams", required = false) String searchParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "rows", value = "分页大小")
            @RequestParam(value = "rows", required = false) Integer rows) throws Exception {
        Envelop envelop = new Envelop();
        if (resourcesCode == null || resourcesCode.equals("")) {
            envelop.setStatus(500);
            envelop.setMessage("资源编码不能为空");
            return envelop;
        }
        Map<String, Object> params = new HashMap<>();
        params.put("resourcesCode", resourcesCode);
        params.put("metaData", metaData);
        params.put("orgCode", "*");
        params.put("areaCode", "*");
        params.put("queryCondition", searchParams);
        params.put("page", page);
        params.put("size", rows);
        Page<Map<String, Object>> result = resourceBrowseService.getCustomizeDataMysql(resourcesCode,metaData,searchParams,page, rows);
        return PageEnvelop.getSuccessListWithPage("",result.getContent(),result.getNumber(),result.getSize(),result.getTotalElements());
    }
    /**
     * 综合查询指标统计列表树 zuul

+ 8 - 4
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/service/ResourceBrowseControllerService.java

@ -12,6 +12,7 @@ import com.yihu.jw.entity.ehr.resource.RsResourceQuota;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -77,11 +78,13 @@ public class ResourceBrowseControllerService {
//    @ApiOperation("档案资源浏览")
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseResourceData, method = RequestMethod.GET)
    public Envelop getResourceData(String resourcesCode,String roleId,String orgCode,String areaCode,
                                   String queryCondition,Integer page,Integer size,String top) throws Exception {
    public ObjEnvelop getResourceData(String resourcesCode, String roleId, String orgCode, String areaCode,
                                      String queryCondition, Integer page, Integer size, String top) throws Exception {
        RsResource rsResource = rsResourceService.getResourceByCode(resourcesCode);
        ObjEnvelop objEnvelop = new ObjEnvelop();
        if (!rsResource.getRsInterface().equals("getQuotaData")){//接口 来自接口统计
            return resourceBrowseService.getResourceData(resourcesCode, roleId, orgCode, areaCode, queryCondition, page, size);
            objEnvelop.setObj(resourceBrowseService.getResourceData(resourcesCode, roleId, orgCode, areaCode, queryCondition, page, size));
            return objEnvelop;
        } else {
            String quotaCodeStr = "";
            List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + rsResource.getId());
@ -91,7 +94,8 @@ public class ResourceBrowseControllerService {
                }
            }
            List<Map<String, Object>> resultList = quotaService.getQuotaReportTwoDimensionalTable(quotaCodeStr,null,rsResource.getDimension(),top);
            return ListEnvelop.getSuccess("",resultList);
            objEnvelop.setObj(resultList);
            return objEnvelop;
        }
    }

+ 16 - 12
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/ResourceBrowseEndPoint.java

@ -3,11 +3,10 @@ package com.yihu.jw.basic.resource.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.basic.resource.service.ResourceBrowseService;
import com.yihu.jw.basic.resource.service.ResourcesTransformService;
import com.yihu.jw.restmodel.web.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -55,7 +54,7 @@ public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
//    @ApiOperation("资源浏览")
    @RequestMapping(value = ServiceApi.Resources.ResourceViewData, method = RequestMethod.GET)
    public Envelop getResourceData(
    public ObjEnvelop getResourceData(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色id [\"roleId\"]")
@ -70,7 +69,9 @@ public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "每页几条", required = true)
            @RequestParam(value = "size") Integer size) throws Exception{
        return resourceBrowseService.getResourceData(resourcesCode, roleId, orgCode, areaCode, queryCondition, page, size);
        ObjEnvelop objEnvelop = new ObjEnvelop();
        objEnvelop.setObj(resourceBrowseService.getResourceData(resourcesCode, roleId, orgCode, areaCode, queryCondition, page, size));
        return objEnvelop;
    }
//    @ApiOperation("档案资源浏览细表数据")
@ -91,7 +92,7 @@ public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
     */
    @ApiOperation("获取资源数据")
    @RequestMapping(value = ServiceApi.Resources.ResourceQuery, method = RequestMethod.POST)
    public Envelop getResources(
    public ObjEnvelop getResources(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
            @ApiParam(name = "orgCode", value = "机构编码")
@ -104,7 +105,9 @@ public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "每页几条")
            @RequestParam(value = "size", required = false) Integer size) throws Exception {
        return resourceBrowseService.getResultData(resourcesCode, "*", orgCode, areaCode, queryParams, page, size);
        ObjEnvelop objEnvelop = new ObjEnvelop();
        objEnvelop.setObj(resourceBrowseService.getResultData(resourcesCode, "*", orgCode, areaCode, queryParams, page, size));
        return objEnvelop;
    }
@ -113,7 +116,7 @@ public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
     */
    @ApiOperation("获取资源数据(转译)")
    @RequestMapping(value = ServiceApi.Resources.ResourceQueryTransform, method = RequestMethod.POST)
    public Envelop getResourcesTransform(
    public ListEnvelop getResourcesTransform(
            @ApiParam(name = "resourcesCode", value = "资源代码")
            @RequestParam(value = "resourcesCode") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色ID")
@ -130,11 +133,12 @@ public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "version", value = "版本号")
            @RequestParam(value = "version", required = false) String version) throws Exception {
        PageEnvelop result = resourceBrowseService.getResultData(resourcesCode, roleId , orgCode, areaCode, queryParams, page, size);
        if (version != null && version.length() > 0) {
            result.setDetailModelList(resourcesTransformService.displayCodeConvert(result.getDetailModelList(), version, resourcesCode));
        }
        return result;
        Object result = resourceBrowseService.getResultData(resourcesCode, roleId , orgCode, areaCode, queryParams, page, size);
        ListEnvelop objEnvelop = new ListEnvelop();
      /*  if (version != null && version.length() > 0) {
            objEnvelop.setDetailModelList(resourcesTransformService.displayCodeConvert(List<Map<String,Object>>result, version, resourcesCode));
        }*/
        return objEnvelop;
    }
//    @ApiOperation("Hbase主表")

+ 10 - 10
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsDictionaryEndPoint.java

@ -31,7 +31,7 @@ import java.util.List;
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0 + "/dictionaries")
@RequestMapping(value = "" + "/dictionaries")
@Api(value = "RsDictionaryEndPoint", description = "标准字典", tags = {"资源服务-标准字典"})
public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
@ -44,7 +44,7 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取标准字典列表", notes = "根据查询条件获取标准字典列表")
    public Envelop searchRsDictionaries(
    public PageEnvelop searchRsDictionaries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
@ -63,11 +63,11 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
    }
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.POST)
    @ApiOperation(value = "创建标准字典", notes = "创建标准字典")
    public Envelop createRsDictionary(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
            @ApiParam(name = "jsonData", value = "", defaultValue = "")
            @RequestParam(value = "jsonData", required = true)String jsonData) throws Exception {
        RsDictionary rsDictionary = toEntity(jsonData, RsDictionary.class);
        String code = rsDictionary.getCode();
        if (isExistence(code)) {
@ -78,11 +78,11 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
        return ObjEnvelop.getSuccess("创建成功",mRsDictionary);
    }
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.PUT)
    @ApiOperation(value = "修改标准字典", notes = "修改标准字典")
    public Envelop updateRsDictionary(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
            @ApiParam(name = "jsonData", value = "")
            @RequestParam(value = "jsonData", required = true)String jsonData) throws Exception {
        RsDictionary dictionary = toEntity(jsonData, RsDictionary.class);
        dictionaryService.save(dictionary);
        MRsDictionary mRsDictionary = convertToModel(dictionary,MRsDictionary.class);
@ -125,7 +125,7 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
        return ObjEnvelop.getSuccess("获取成功",mRsDictionary);
    }
    @RequestMapping(value = ServiceApi.Resources.DictBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping(value = ServiceApi.Resources.DictBatch, method = RequestMethod.POST)
    @ApiOperation(value = "批量创建标准字典", notes = "批量创建标准字典")
    public Envelop createRsDictionaries(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
@ -145,7 +145,7 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
        return ObjEnvelop.getSuccess("获取成功",ls != null && ls.size() > 0);
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntryBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping(value = ServiceApi.Resources.DictEntryBatch, method = RequestMethod.POST)
    @ApiOperation(value = "批量创建标准字典以及字典项", notes = "批量创建标准字典以及字典项")
    public Envelop createDictAndEntries(
            @RequestBody String jsonData) throws Exception {

+ 31 - 23
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsDictionaryEntryEndPoint.java

@ -4,6 +4,10 @@ import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.basic.resource.dao.RsDictionaryEntryDao;
import com.yihu.jw.restmodel.ehr.resource.MRsDictionaryEntry;
import com.yihu.jw.restmodel.ehr.resource.MRsMetadata;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.entity.ehr.resource.RsDictionaryEntry;
import com.yihu.jw.basic.resource.service.RsDictionaryEntryService;
@ -24,7 +28,7 @@ import java.util.List;
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@RequestMapping(value = "")
@Api(value = "RsDictionaryEntry", description = "标准字典项", tags = {"资源服务-标准字典项"})
public class RsDictionaryEntryEndPoint extends EnvelopRestEndpoint {
    @Autowired
@ -34,7 +38,7 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.DictEntries, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取标准字典项列表", notes = "根据查询条件获取标准字典项列表")
    public List<MRsDictionaryEntry> searchRsDictionaryEntries(
    public PageEnvelop searchRsDictionaryEntries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
@ -48,17 +52,21 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndpoint {
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, rsDictionaryEntryService.getCount(filters), page, size);
        return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<MRsDictionaryEntry>(dictionaryEntries.size()), MRsDictionaryEntry.class, fields);
        PageEnvelop pageEnvelop = new PageEnvelop();
        pageEnvelop.setTotalCount(Integer.parseInt(rsDictionaryEntryService.getCount(filters)+""));
        pageEnvelop.setCurrPage(page);
        pageEnvelop.setPageSize(size);
        pageEnvelop.setDetailModelList((List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<MRsDictionaryEntry>(dictionaryEntries.size()), MRsDictionaryEntry.class, fields));
        return pageEnvelop;
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntries, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping(value = ServiceApi.Resources.DictEntries, method = RequestMethod.POST)
    @ApiOperation(value = "创建标准字典项", notes = "创建标准字典项")
    public MRsDictionaryEntry createRsDictionaryEntry(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
    public Envelop createRsDictionaryEntry(
            @ApiParam(name = "jsonData", value = "", defaultValue = "")
            @RequestParam(value = "jsonData", required = true)String jsonData) throws Exception {
        RsDictionaryEntry dictionaryEntry = toEntity(jsonData, RsDictionaryEntry.class);
        String code = dictionaryEntry.getCode();
@ -67,15 +75,15 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndpoint {
            throw new Exception("字典项代码不能重复");
        }
        rsDictionaryEntryService.insert(dictionaryEntry);
        return convertToModel(dictionaryEntry, MRsDictionaryEntry.class, null);
        return success(convertToModel(dictionaryEntry, MRsDictionaryEntry.class, null));
    }
    @RequestMapping(value =ServiceApi.Resources.DictEntries, method = RequestMethod.PUT)
    @ApiOperation(value = "修改标准字典项", notes = "修改标准字典项")
    public MRsDictionaryEntry updateRsDictionaryEntry(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
    public Envelop updateRsDictionaryEntry(
            @ApiParam(name = "jsonData", value = "")
            @RequestParam(value = "jsonData", required = true)String jsonData) throws Exception {
        RsDictionaryEntry dictionaryEntry = toEntity(jsonData, RsDictionaryEntry.class);
        RsDictionaryEntry d = rsDictionaryEntryService.findById(dictionaryEntry.getId());
@ -85,45 +93,45 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndpoint {
            throw new Exception("字典代码不可修改");
        }
        rsDictionaryEntryService.save(dictionaryEntry);
        return convertToModel(dictionaryEntry, MRsDictionaryEntry.class, null);
        return success(convertToModel(dictionaryEntry, MRsDictionaryEntry.class, null));
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntry, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除标准字典项", notes = "删除标准字典项")
    public boolean deleteRsDictionaryEntry(
    public Envelop deleteRsDictionaryEntry(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") int id) throws Exception {
        dictionaryEntryDao.deleteById(id);
        return true;
        return success(true);
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntry, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取标准字典")
    public MRsDictionaryEntry getRsDictionaryEntryById(
    public Envelop getRsDictionaryEntryById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @PathVariable(value = "id") int id) {
        RsDictionaryEntry dictionaryEntry = rsDictionaryEntryService.findById(id);
        return convertToModel(dictionaryEntry, MRsDictionaryEntry.class);
        return success(convertToModel(dictionaryEntry, MRsDictionaryEntry.class));
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntriesByDictCode, method = RequestMethod.GET)
    @ApiOperation(value = "根据dict_code获取获取标准字典")
    public List<MRsDictionaryEntry>  getRsDictionaryEntryByDictCode(
    public ListEnvelop  getRsDictionaryEntryByDictCode(
            @ApiParam(name = "dict_code", value = "", defaultValue = "")
            @RequestParam(value = "dict_code") String dict_code)
    {
        List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.findByDictCode(dict_code);
        return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class,null);
        return success((List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class,null));
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntriesExistence,method = RequestMethod.GET)
    @ApiOperation("根据过滤条件判断是否存在")
    public boolean isExistence(
    public Envelop isExistence(
            @ApiParam(name="filters",value="filters",defaultValue = "")
            @RequestParam(value="filters") String filters) throws Exception {
        List ls = rsDictionaryEntryService.search("",filters,"", 1, 1);
        return ls!=null && ls.size()>0;
        return success(ls!=null && ls.size()>0);
    }
    public boolean isExistence(String dictCode,String code) {
@ -133,10 +141,10 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.NoPageDictEntries, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取标准字典项列表_不分页", notes = "根据查询条件获取标准字典项列表_不分页")
    public List<MRsDictionaryEntry> searchNoPageRsDictEntries(
    public ListEnvelop searchNoPageRsDictEntries(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.search(filters);
        return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class, "");
        return success((List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class, ""));
    }
}

+ 37 - 31
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsMetadataEndPoint.java

@ -6,6 +6,10 @@ import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.entity.ehr.resource.RsMetadata;
import com.yihu.jw.basic.resource.service.RsMetadataService;
import com.yihu.jw.restmodel.ehr.resource.MRsMetadata;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.entity.ehr.id.BizObject;
import io.swagger.annotations.Api;
@ -29,109 +33,108 @@ import java.util.List;
 * Created by lyr on 2016/5/16.
 */
@RestController
@RequestMapping(value= ApiVersion.Version1_0)
@RequestMapping(value= "")
@Api(value = "RsMetadataEndPoint", description = "数据元", tags = {"资源服务-数据元"})
public class RsMetadataEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private RsMetadataService metadataService;
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.POST)
    @ApiOperation("创建数据元")
    public MRsMetadata createMetadata(
    public Envelop createMetadata(
        @ApiParam(name="metadata",value="数据元JSON",defaultValue = "")
        @RequestBody String metadata) throws Exception
        @RequestParam(value = "metadata", required = true)String metadata) throws Exception
    {
        RsMetadata rsMetadata = toEntity(metadata,RsMetadata.class);
        rsMetadata.setId(getObjectId(BizObject.RsMetadata));
        rsMetadata = metadataService.save(rsMetadata);
        return convertToModel(rsMetadata,MRsMetadata.class);
        return success(convertToModel(rsMetadata,MRsMetadata.class));
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataBatch,method = RequestMethod.POST)
    @ApiOperation("批量创建数据元")
    public boolean createMetadataPatch(
    public Envelop createMetadataPatch(
            @ApiParam(name="metadatas",value="数据元JSON",defaultValue = "")
            @RequestBody String metadatas) throws Exception
            @RequestParam(value = "metadatas", required = true)String metadatas) throws Exception
    {
        List models = objectMapper.readValue(metadatas, new TypeReference<List>() {});
        metadataService.addMetaBatch(models);
        return true;
        return success(true);
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.PUT)
    @ApiOperation("更新数据元")
    public MRsMetadata updateMetadata(
    public Envelop updateMetadata(
            @ApiParam(name="metadata",value="数据元JSON",defaultValue = "")
            @RequestBody String metadata) throws Exception
            @RequestParam(value = "metadata", required = true)String metadata) throws Exception
    {
        RsMetadata rsMetadata = toEntity(metadata,RsMetadata.class);
        rsMetadata = metadataService.save(rsMetadata);
        return convertToModel(rsMetadata,MRsMetadata.class);
        return success(convertToModel(rsMetadata,MRsMetadata.class));
    }
    @RequestMapping(value = ServiceApi.Resources.Metadata,method = RequestMethod.DELETE)
    @ApiOperation("删除数据元")
    public boolean deleteMetadata(
    public Envelop deleteMetadata(
            @ApiParam(name="id",value="数据元ID",defaultValue = "")
            @PathVariable(value="id")String id) throws Exception
    {
        metadataService.deleteMetadata(id);
        return true;
        return success(true);
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.DELETE)
    @ApiOperation("批量删除数据元")
    public boolean deleteMetadataBatch(
    public Envelop deleteMetadataBatch(
            @ApiParam(name="ids",value="数据元ID",defaultValue = "")
            @RequestParam(name="ids") String ids) throws Exception
    {
        metadataService.deleteMetadata(ids);
        return true;
        return success(true);
    }
    @RequestMapping(value = ServiceApi.Resources.Metadata,method = RequestMethod.GET)
    @ApiOperation("根据ID获取数据元")
    public MRsMetadata getMetadataById(
    public Envelop getMetadataById(
            @ApiParam(name="id",value="id",defaultValue = "")
            @PathVariable(value="id") String id) throws Exception
    {
        return convertToModel(metadataService.getMetadataById(id),MRsMetadata.class);
        return success(convertToModel(metadataService.getMetadataById(id),MRsMetadata.class));
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataExistence,method = RequestMethod.GET)
    @ApiOperation("根据过滤条件判断是否存在")
    public boolean isExistence(
    public Envelop isExistence(
            @ApiParam(name="filters",value="filters",defaultValue = "")
            @RequestParam(value="filters") String filters) throws Exception {
        List<RsMetadata> metadata = metadataService.search("",filters,"", 1, 1);
        return metadata!=null && metadata.size()>0;
        return success(metadata!=null && metadata.size()>0);
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataStdCodeExistence,method = RequestMethod.GET)
    @ApiOperation("获取已存在内部编码")
    public List stdCodeExistence(
    public ListEnvelop stdCodeExistence(
            @ApiParam(name="std_codes",value="std_codes",defaultValue = "")
            @RequestParam(value="std_codes") String stdCodes) throws Exception {
        List existCodes = metadataService.stdCodeExist(stdCodes);
        return existCodes;
        return success(existCodes);
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataIdExistence,method = RequestMethod.POST)
    @ApiOperation("获取已存在资源标准编码")
    public List idExistence(
    public ListEnvelop idExistence(
            @ApiParam(name="ids",value="ids",defaultValue = "")
            @RequestBody String ids) throws Exception {
        List existIds = metadataService.idExist(toEntity(ids, String[].class));
        return existIds;
        return success(existIds);
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.GET)
    @ApiOperation("查询数据元")
    public List<MRsMetadata> getMetadata(
    public PageEnvelop getMetadata(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(name="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
@ -161,16 +164,19 @@ public class RsMetadataEndPoint extends EnvelopRestEndpoint {
            total = metadataService.getCount(filters);
            metaList = convertToModels(metadata,new ArrayList<>(metadata.size()),MRsMetadata.class,fields);
        }
        pagedResponse(request,response,total,page,size);
        return (List<MRsMetadata>)metaList;
        PageEnvelop pageEnvelop = new PageEnvelop();
        pageEnvelop.setTotalCount(Integer.parseInt(total+""));
        pageEnvelop.setCurrPage(page);
        pageEnvelop.setPageSize(size);
        pageEnvelop.setDetailModelList((List<MRsMetadata>)metaList);
        return pageEnvelop;
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataMaxId,method = RequestMethod.GET)
    @ApiOperation("获取资源标准编码的最大编号")
    public int getMaxIdNumber( ){
        return  metadataService.getMaxIdNumber();
    public Envelop getMaxIdNumber( ){
        return  success(metadataService.getMaxIdNumber());
    }
}

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

@ -1,6 +1,7 @@
package com.yihu.jw.basic.resource.dao;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.redis.schema.AdapterMetaDataKeySchema;
@ -633,6 +634,120 @@ public class ResourceBrowseDao {
//        return envelop;
//    }
    /**
     * 综合查询
     * @param sql
     * @param queryParam
     * @param sortParam
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlDataAndCondition(String sql,String queryParam,String sortParam,Integer page, Integer size) throws Exception {
        String sortOrder = "";
        String sortOrderSql = "";
        if (StringUtils.isNoneBlank(sortParam)){
            //通过资源代码获取默认参数
            JSONArray array = JSONArray.parseArray(sortParam);
            for (int i=0;i<array.size();i++){
                Map<String, String> temp = objectMapper.readValue(array.getJSONObject(i).toJSONString(), Map.class);
                for (Map.Entry<String, String> entry:temp.entrySet()){
                    String key = entry.getKey();
                    String value = entry.getValue();
                    sortOrder =" "+key+" "+ value+",";
                }
            }
            if (StringUtils.isNoneBlank(sortOrder)){
                sortOrderSql +=" order by "+sortOrder.substring(0,sortOrder.length()-1);
            }
        }
        if (StringUtils.isNoneBlank(queryParam)){
            queryParam =" where 1=1 "+ queryParam;
        }
        //判定是否完整sql语句
        sql =sql+queryParam+sortOrderSql;
        //查询总条数
        ParserSql parser = ParserFactory.getParserSql();
        String sqlCount = parser.getCountSql(sql);
        long count = jdbcTemplate.queryForObject(sqlCount, Long.class);
        //默认第一页
        if (page == null) {
            page = defaultPage;
        }
        //默认行数
        if (size == null) {
            size = defaultSize;
        }
        //分页查询
        List<Map<String, Object>> list;
        if (count > size) {
            String sqlList = parser.getPageSql(sql, page, size);
            list = jdbcTemplate.queryForList(sqlList);
        } else {
            list = jdbcTemplate.queryForList(sql);
        }
        return new PageImpl<>(list, PageRequest.of(page - 1, size), count);
    }
    /**
     * 获取Mysql配置库数据
     *
     * @param resourcesCode
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlData(String resourcesCode, Integer page, Integer size) throws Exception {
        String sql ="";
        String sortOrder = "";
        String sortOrderSql = "";
        String tableSql = "";
        //通过资源代码获取默认参数
        List<RsResourceDefaultParam> paramsList = resourceDefaultParamDao.findByResourcesCode(resourcesCode);
        for (RsResourceDefaultParam param : paramsList) {
            if (param.getParamKey().equals("sort")) {
                Map<String, String> temp = objectMapper.readValue(param.getParamValue(), Map.class);
                for (Map.Entry<String, String> entry:temp.entrySet()){
                    String key = entry.getKey();
                    String value = entry.getValue();
                    sortOrder ="T."+key+" "+ value+",";
                }
            }else if (param.getParamKey().equals("table")){
                tableSql = "("+param.getParamValue()+") T ";
            }
        }
        if (StringUtils.isNoneBlank(sortOrder)){
            sortOrderSql +=" order by "+sortOrder.substring(0,sortOrder.length()-1);
        }
        //判定是否完整sql语句
        sql = "select T.* from " + tableSql +sortOrderSql;
        //查询总条数
        ParserSql parser = ParserFactory.getParserSql();
        String sqlCount = parser.getCountSql(sql);
        long count = jdbcTemplate.queryForObject(sqlCount, Long.class);
        //默认第一页
        if (page == null) {
            page = defaultPage;
        }
        //默认行数
        if (size == null) {
            size = defaultSize;
        }
        //分页查询
        List<Map<String, Object>> list;
        if (count > size) {
            String sqlList = parser.getPageSql(sql, page, size);
            list = jdbcTemplate.queryForList(sqlList);
        } else {
            list = jdbcTemplate.queryForList(sql);
        }
        return new PageImpl<>(list, PageRequest.of(page - 1, size), count);
    }
    /**
     * 获取Mysql配置库数据
     *
@ -642,7 +757,7 @@ public class ResourceBrowseDao {
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlData(String queryParams, Integer page, Integer size) throws Exception {
    public Page<Map<String, Object>> getMysqlData1(String queryParams, Integer page, Integer size) throws Exception {
        String sql = queryParams;
        //判定是否完整sql语句

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/ResourceBrowseMetadataDao.java

@ -25,10 +25,10 @@ public class ResourceBrowseMetadataDao {
     * 获取某资源所有数据元
     */
    public List<DtoResourceMetadata> getAllResourceMetadata(String resourcesCode) throws Exception {
        String sql = "SELECT m.id, m.domain, m.name, m.std_code, m.display_code, m.column_type, m.null_able, m.dict_code, m.description, m.valid, a.group_type, a.group_data " +
        String sql = "SELECT m.id,m.ehr_id, m.domain, m.name, m.std_code, m.display_code, m.column_type, m.null_able, m.dict_code, m.description, m.valid, a.group_type, a.group_data " +
                "FROM rs_resource_metadata a, rs_resource b, rs_metadata m " +
                "WHERE a.resources_id = b.id " +
                "AND a.metadata_id = m.id " +
                "AND a.metadata_id = m.ehr_id " +
                "AND b.code = '" + resourcesCode + "'";
        RowMapper rowMapper = BeanPropertyRowMapper.newInstance(DtoResourceMetadata.class);
        return jdbcTemplate.query(sql, rowMapper);

+ 168 - 80
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java

@ -3,19 +3,22 @@ package com.yihu.jw.basic.resource.service;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.resource.dao.RsResourceDefaultParamDao;
import com.yihu.jw.constants.ErrorCode;
import com.yihu.jw.basic.resource.dao.ResourceBrowseDao;
import com.yihu.jw.entity.ehr.resource.RsResourceDefaultParam;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.mysql.enums.Operation;
import com.yihu.jw.mysql.model.QueryCondition;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.profile.ProfileType;
import com.yihu.jw.profile.family.ResourceCells;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.basic.resource.dao.ResourceBrowseMetadataDao;
import com.yihu.jw.basic.resource.dao.RsResourceDao;
import com.yihu.jw.entity.ehr.resource.DtoResourceMetadata;
import com.yihu.jw.entity.ehr.resource.RsResource;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
@ -48,6 +51,11 @@ public class ResourceBrowseService extends BaseJpaService {
    private RsResourceService rsResourceService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private RsResourceDefaultParamDao resourceDefaultParamDao;
    /**
     * 资源浏览 -- 资源数据元结构
     *
@ -79,9 +87,9 @@ public class ResourceBrowseService extends BaseJpaService {
                if (!isOtherVersion) {
                    mRsColumnsModel.setValue(r.getName());
                    if (!StringUtils.isEmpty(r.getDictCode())) {
                        mRsColumnsModel.setCode(r.getId() + "_VALUE");
                        mRsColumnsModel.setCode(r.getEhrId());
                    } else {
                        mRsColumnsModel.setCode(r.getId());
                        mRsColumnsModel.setCode(r.getEhrId());
                    }
                    mRsColumnsModel.setType(r.getColumnType());
                    mRsColumnsModel.setDict(r.getDictCode());
@ -117,7 +125,7 @@ public class ResourceBrowseService extends BaseJpaService {
     * @return
     * @throws Exception
     */
    public Envelop getResourceData(String resourcesCode, String roleId, String orgCode, String areaCode, String queryCondition, Integer page, Integer size) throws Exception {
    public Object getResourceData(String resourcesCode, String roleId, String orgCode, String areaCode, String queryCondition, Integer page, Integer size) throws Exception {
        String queryParams = "";
        //获取资源信息
        List<QueryCondition> ql = new ArrayList<>();
@ -305,7 +313,7 @@ public class ResourceBrowseService extends BaseJpaService {
     * @return
     * @throws Exception
     */
    public PageEnvelop getResultData(String resourcesCode, String roleId, String orgCode, String areaCode, String queryParams, Integer page, Integer size) throws Exception {
    public Object getResultData(String resourcesCode, String roleId, String orgCode, String areaCode, String queryParams, Integer page, Integer size) throws Exception {
        RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
        if (rsResources != null) {
            StringBuilder saas = new StringBuilder();
@ -343,11 +351,11 @@ public class ResourceBrowseService extends BaseJpaService {
            if(method.equalsIgnoreCase("getMysqlData")){
                Method _method = clazz.getMethod(method, new Class[]{ String.class, Integer.class, Integer.class});
                _method.setAccessible(true);
                return (PageEnvelop) _method.invoke(resourceBrowseDao, queryParams, page, size);
                return _method.invoke(resourceBrowseDao, rsResources.getCode(), page, size);
            }{
                Method _method = clazz.getMethod(method, new Class[]{String.class, String.class, String.class, String.class, Integer.class, Integer.class});
                _method.setAccessible(true);
                return (PageEnvelop) _method.invoke(resourceBrowseDao, resourcesCode, roleId, saas.toString(), queryParams, page, size);
                return _method.invoke(resourceBrowseDao, resourcesCode, roleId, saas.toString(), queryParams, page, size);
            }
        }
@ -423,78 +431,133 @@ public class ResourceBrowseService extends BaseJpaService {
     * @return
     * @throws Exception
     */
//    public Envelop getCustomizeData(String resourcesCodes, String metaData, String orgCode, String areaCode, String queryCondition, Integer page, Integer size) throws Exception {
//        //获取资源编码列表
//        List<String> codeList = (List<String>) objectMapper.readValue(resourcesCodes, List.class);
//        //资源判空检查
//        for (String code : codeList) {
//            RsResource rsResources = rsResourceService.getResourceByCategory(code,"standard");
//
//            if (rsResources == null) {
//                throw new ApiException( "无效的资源编码" + code,ErrorCode.BAD_REQUEST.value());
//            }
//        }
//        StringBuilder saas = new StringBuilder();
//        if ("*".equals(orgCode) && "*".equals(areaCode)) {
//            saas.append("*");
//        } else {
//            List<String> orgCodeList = objectMapper.readValue(orgCode, List.class);
//            List<String> areaCodeList = objectMapper.readValue(areaCode, List.class);
//            if (orgCodeList != null && orgCodeList.size() > 0) {
//                orgCodeList.forEach(item -> {
//                    if (saas.length() <= 0) {
//                        saas.append("(org_code:" + item);
//                    } else {
//                        saas.append(" OR org_code:" + item);
//                    }
//                });
//            }
//            if (areaCodeList != null && areaCodeList.size() > 0) {
//                areaCodeList.forEach(item -> {
//                    if (saas.length() <= 0) {
//                        saas.append("(org_area:" + item);
//                    } else {
//                        saas.append(" OR org_area:" + item);
//                    }
//                });
//            }
//            if (saas.length() > 0) {
//                saas.append(")");
//            } else {
//                throw new ApiException(ErrorCode.FORBIDDEN, "无SAAS权限访问资源");
//            }
//        }
//        List<QueryCondition> ql = new ArrayList<>();
//        if (!StringUtils.isEmpty(queryCondition)) {
//            ql = parseCondition(queryCondition);
//        }
//        String queryParams = "";
//        if (ql.size() > 0) {
//            if (solrQuery.conditionToString(ql).contains(":")) {
//                queryParams = addParams(queryParams, "q", solrQuery.conditionToString(ql));
//            } else {
//                queryParams = addParams(queryParams, "q", "*:*");
//            }
//        } else {
//            queryParams = addParams(queryParams, "q", "*:*");
//        }
//        queryParams = addParams(queryParams, "sort", "{\"create_date\":\"desc\"}");
//        //基础数据字段
//        queryParams = addParams(queryParams, "basicFl", org.apache.commons.lang3.StringUtils.join(ResourceCells.getMasterBasicCell(ProfileType.Standard), ","));
//        //数据元信息字段
//        List<String> customizeList = (List<String>) objectMapper.readValue(metaData, List.class);
//        //参数集合
//        List<String> paramList = new ArrayList<>(customizeList.size() * 2);
//        for (String id : customizeList) {
//            paramList.add(id);
//            String dictCode = redisService.getRsMetadataDict(id);
//            if (!StringUtils.isEmpty(dictCode)) {
//                paramList.add(id + "_VALUE");
//            }
//        }
//        queryParams = addParams(queryParams, "dFl", org.apache.commons.lang3.StringUtils.join(paramList, ","));
//        return resourceBrowseDao.getEhrCenter(null, "*", saas.toString(), queryParams, page, size);
//    }
    public Envelop getCustomizeData(String resourcesCodes, String metaData, String orgCode, String areaCode, String queryCondition, Integer page, Integer size) throws Exception {
        //获取资源编码列表
        List<String> codeList = (List<String>) objectMapper.readValue(resourcesCodes, List.class);
        //资源判空检查
        for (String code : codeList) {
            RsResource rsResources = rsResourceService.getResourceByCategory(code,"standard");
            if (rsResources == null) {
                throw new ApiException( "无效的资源编码" + code,ErrorCode.BAD_REQUEST.value());
            }
        }
        StringBuilder saas = new StringBuilder();
        if ("*".equals(orgCode) && "*".equals(areaCode)) {
            saas.append("*");
        } else {
            List<String> orgCodeList = objectMapper.readValue(orgCode, List.class);
            List<String> areaCodeList = objectMapper.readValue(areaCode, List.class);
            if (orgCodeList != null && orgCodeList.size() > 0) {
                orgCodeList.forEach(item -> {
                    if (saas.length() <= 0) {
                        saas.append("(org_code:" + item);
                    } else {
                        saas.append(" OR org_code:" + item);
                    }
                });
            }
            if (areaCodeList != null && areaCodeList.size() > 0) {
                areaCodeList.forEach(item -> {
                    if (saas.length() <= 0) {
                        saas.append("(org_area:" + item);
                    } else {
                        saas.append(" OR org_area:" + item);
                    }
                });
            }
            if (saas.length() > 0) {
                saas.append(")");
            } else {
                throw new ApiException("无SAAS权限访问资源");
            }
        }
        List<QueryCondition> ql = new ArrayList<>();
        if (!StringUtils.isEmpty(queryCondition)) {
            ql = parseCondition(queryCondition);
        }
        String queryParams = "";
        if (ql.size() > 0) {
           /* if (solrQuery.conditionToString(ql).contains(":")) {
                queryParams = addParams(queryParams, "q", solrQuery.conditionToString(ql));
            } else {
                queryParams = addParams(queryParams, "q", "*:*");
            }*/
        } else {
            queryParams = addParams(queryParams, "q", "*:*");
        }
        queryParams = addParams(queryParams, "sort", "{\"create_date\":\"desc\"}");
        //基础数据字段
        queryParams = addParams(queryParams, "basicFl", org.apache.commons.lang3.StringUtils.join(ResourceCells.getMasterBasicCell(ProfileType.Standard), ","));
        //数据元信息字段
        List<String> customizeList = (List<String>) objectMapper.readValue(metaData, List.class);
        //参数集合
        List<String> paramList = new ArrayList<>(customizeList.size() * 2);
        for (String id : customizeList) {
            paramList.add(id);
            String dictCode = redisService.getRsMetadataDict(id);
            if (!StringUtils.isEmpty(dictCode)) {
                paramList.add(id + "_VALUE");
            }
        }
        String queryString = org.apache.commons.lang3.StringUtils.join(paramList, ",");
        queryParams = addParams(queryParams, "dFl", org.apache.commons.lang3.StringUtils.join(paramList, ","));
        return resourceBrowseDao.getEhrCenter(null, "*", saas.toString(), queryParams, page, size);
    }
    /**
     * 综合查询档案数据检索
     *
     * @param resourcesCodes
     * @param metaData
     * @param queryCondition
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getCustomizeDataMysql(String resourcesCodes, String metaData, String queryCondition, Integer page, Integer size) throws Exception {
        //获取资源编码列表
        List<String> codeList = (List<String>) objectMapper.readValue(resourcesCodes, List.class);
        String tableName = "";
        //资源判空检查
        for (String code : codeList) {
            RsResource rsResources = rsResourceService.getResourceByCategory(code,"standard");
            if (rsResources == null) {
                throw new ApiException( "无效的资源编码" + code,ErrorCode.BAD_REQUEST.value());
            }
            String sortOrder = "";
            List<RsResourceDefaultParam> paramsList = resourceDefaultParamDao.findByResourcesCode(code);
            for (RsResourceDefaultParam param : paramsList) {
                if (param.getParamKey().equals("sort")) {
                    Map<String, String> temp = objectMapper.readValue(param.getParamValue(), Map.class);
                    for (Map.Entry<String, String> entry:temp.entrySet()){
                        String key = entry.getKey();
                        String value = entry.getValue();
                        sortOrder ="T."+key+" "+ value+",";
                    }
                }else if (param.getParamKey().equals("table")){
                    tableName += " ("+param.getParamValue()+") "+ code;
                }
            }
        }
        StringBuffer stringBuffer = new StringBuffer();
        if (!StringUtils.isEmpty(queryCondition)) {
            stringBuffer = parseCondition1(queryCondition);
        }
        //数据元信息字段
        List<String> customizeList = (List<String>) objectMapper.readValue(metaData, List.class);
        //参数集合
        List<String> paramList = new ArrayList<>(customizeList.size() * 2);
        for (String id : customizeList) {
            paramList.add(id);
        }
        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);
    }
    /**
     * 获取主表数据
@ -578,7 +641,7 @@ public class ResourceBrowseService extends BaseJpaService {
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlData(String queryParams, Integer page, Integer size) throws Exception {
        return resourceBrowseDao.getMysqlData(queryParams, page, size);
        return resourceBrowseDao.getMysqlData1(queryParams, page, size);
    }
    /**
@ -620,6 +683,31 @@ public class ResourceBrowseService extends BaseJpaService {
        return ql;
    }
    /**
     * 查询条件转换
     *
     * @param queryCondition
     * @return
     * @throws Exception
     */
    private StringBuffer parseCondition1(String queryCondition) throws Exception {
        StringBuffer stringBuffer = new StringBuffer();
        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();
                String cond = String.valueOf(item.get("condition")).trim();
                String value = String.valueOf(item.get("value"));
                stringBuffer.append(" "+andOr+" "+field+cond+"'"+value+"' ");
            }
        }
        return stringBuffer;
    }
    /**
     * 新增参数
     *

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

@ -89,14 +89,14 @@ public class ResourceIntegratedService extends BaseJpaService {
                sql = "SELECT rr.id, rr.code, rr.name, rr.category_id, rr.rs_interface, rr.grant_type FROM rs_resource rr ,rs_resource_category rrc  WHERE" +
                        " rr.category_id=rrc.ID AND rrc. CODE = '" + categoryCode + "' " +
                        "AND rr.category_id = '" + categoryId + "' " +
                        "AND rr.rs_interface = 'getEhrCenter' " +
                        "AND rr.rs_interface = 'getMysqlData' " +
                        "AND (rr.id IN (" + ids + ")) " + "OR rr.grant_type = '0') " +
                        "AND rr.name like " + "'%" + filters + "%'";
            } else {
                sql = "SELECT rr.id, rr.code, rr.name, rr.category_id, rr.rs_interface, rr.grant_type FROM rs_resource rr ,rs_resource_category rrc   WHERE" +
                        " rr.category_id=rrc.ID AND rrc. CODE = '" + categoryCode + "' " +
                        "AND rr.category_id = '" + categoryId + "'" +
                        "AND rr.rs_interface = 'getEhrCenter' " +
                        "AND rr.rs_interface = 'getMysqlData' " +
                        "AND rr.name like " + "'%" + filters + "%'";
            }
        } else {
@ -104,13 +104,13 @@ public class ResourceIntegratedService extends BaseJpaService {
                sql = "SELECT rr.id, rr.code, rr.name, rr.category_id, rr.rs_interface, rr.grant_type FROM rs_resource rr ,rs_resource_category rrc   WHERE" +
                        " rr.category_id=rrc.ID AND rrc. CODE = '" + categoryCode + "' " +
                        "AND rr.category_id = '" + categoryId + "'" +
                        "AND rr.rs_interface = 'getEhrCenter' " +
                        "AND rr.rs_interface = 'getMysqlData' " +
                        "AND rr.id IN (" + ids + ")) " + "OR rr.grant_type = '0') ";
            } else {
                sql = "SELECT rr.id, rr.code, rr.name, rr.category_id, rr.rs_interface, rr.grant_type FROM rs_resource rr ,rs_resource_category rrc   WHERE" +
                        " rr.category_id=rrc.ID AND rrc. CODE = '" + categoryCode + "' " +
                        "AND rr.category_id = '" + categoryId + "'" +
                        "AND rr.rs_interface = 'getEhrCenter'";
                        "AND rr.rs_interface = 'getMysqlData'";
            }
        }
        RowMapper rowMapper = BeanPropertyRowMapper.newInstance(RsResource.class);
@ -417,7 +417,7 @@ public class ResourceIntegratedService extends BaseJpaService {
                    for (RsMetadata rsMetadata : rmList) {
                        Map<String, Object> metadataMap = new HashMap<String, Object>();
                        metadataMap.put("level", "3");
                        metadataMap.put("code", rsMetadata.getId());
                        metadataMap.put("code", rsMetadata.getEhrId());
                        metadataMap.put("name", rsMetadata.getName());
                        metadataMap.put("id", UUID.randomUUID().toString());
                        String dictCode = rsMetadata.getDictCode();