LAPTOP-KB9HII50\70708 2 سال پیش
والد
کامیت
88bf583250
55فایلهای تغییر یافته به همراه7782 افزوده شده و 1636 حذف شده
  1. 63 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/DictController.java
  2. 325 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/MetaController.java
  3. 44 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportCategoryAppRelationController.java
  4. 274 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportCategoryController.java
  5. 914 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportController.java
  6. 685 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceBrowseController.java
  7. 503 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceCenterController.java
  8. 144 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceConfigurationController.java
  9. 141 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceDefaultParamController.java
  10. 697 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceIntegratedController.java
  11. 154 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceInterfaceController.java
  12. 568 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceManageController.java
  13. 137 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceMonitorTypeReportController.java
  14. 150 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceViewController.java
  15. 269 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourcesStatisticsController.java
  16. 270 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/RsResourceCategoryController.java
  17. 171 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptController.java
  18. 107 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDataSetController.java
  19. 85 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDictController.java
  20. 412 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/service/ResourceBrowseControllerService.java
  21. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDataSaveEndPoint.java
  22. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDataSourceEndPoint.java
  23. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDimensionMainEndPoint.java
  24. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDimensionSlaveEndPoint.java
  25. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaCategoryEndPoint.java
  26. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaChartEndPoint.java
  27. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDataSaveEndPoint.java
  28. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDataSourceEndPoint.java
  29. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDimensionMainEndPoint.java
  30. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDimensionSlaveEndPoint.java
  31. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaEndPoint.java
  32. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaLogEndPoint.java
  33. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaSynthesizeQueryEndPoint.java
  34. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaWarnEndPoint.java
  35. 52 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterMetaDataKeySchema.java
  36. 0 175
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/HbaseDataEndPoint.java
  37. 199 209
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/ResourceBrowseEndPoint.java
  38. 10 6
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/ResourceTransformEndPoint.java
  39. 36 47
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsAdapterDictionaryEndPoint.java
  40. 22 22
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsAdapterMetaDataEndPoint.java
  41. 19 15
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsAdapterSchemeEndPoint.java
  42. 26 21
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsDictionaryEndPoint.java
  43. 3 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportCategoryAppEndPoint.java
  44. 4 4
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportCategoryEndPoint.java
  45. 18 18
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportEndPoint.java
  46. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsResourceDefaultParamsEndPoint.java
  47. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsResourceEndPoint.java
  48. 614 613
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/ResourceBrowseDao.java
  49. 1 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/RsResourceDao.java
  50. 626 465
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java
  51. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/StdCdaTypeController.java
  52. 1 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/StdRedisEndPoint.java
  53. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/DictController.java
  54. 1 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/FlowController.java
  55. 1 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/ParamController.java

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

@ -0,0 +1,63 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.resource.service.RsDictionaryService;
import com.yihu.jw.entity.ehr.resource.RsDictionary;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
 * @author lincl
 * @version 1.0
 * @created 2016/5/20
 */
@RestController("resource-dict")
@RequestMapping("/resource/dict")
public class DictController extends EnvelopRestEndpoint {
    @Autowired
    private RsDictionaryService dictionaryService;
    final String parentFile = "dict";
    Map<String, Integer> dictExcel;
    Map<String, Integer> dictEntryExcel;
    Map<Integer, String> headerMap ;
    public DictController() {
        dictExcel = new HashMap<>();
        dictExcel.put("code", 0);
        dictExcel.put("name", 1);
        dictExcel.put("description", 2);
        dictEntryExcel = new HashMap<>();
        dictEntryExcel.put("code", 3);
        dictEntryExcel.put("name", 4);
        dictEntryExcel.put("description", 5);
        headerMap = new HashMap<>();
        headerMap.put(0, "代码");
        headerMap.put(1, "名称");
        headerMap.put(2, "说明");
    }
    @RequestMapping("/searchCombo")
    @ResponseBody
    public Envelop comboSearch(String searchParm, int page, int rows){
        try{
            String filters =  "code?"+searchParm+" g1;name?"+searchParm+";";
            List<RsDictionary> dictionaries = dictionaryService.search(null, filters, null, page, rows);
            return PageEnvelop.getSuccessListWithPage("查询成功",dictionaries,page,rows,dictionaryService.getCount(filters));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
}

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

@ -0,0 +1,325 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//import com.fasterxml.jackson.core.type.TypeReference;
//
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.util.excel.poi.AExcelReader;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.MultiValueMap;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.File;
//import java.io.IOException;
//import java.io.OutputStream;
//import java.util.*;
//
///**
// * @author lincl
// * @version 1.0
// * @created 2016/5/19
// */
//@RestController
//@RequestMapping("/resource/meta")
//public class MetaController extends ExtendController<MetaService> {
//    static final String parentFile = "meta";
//
//    public MetaController() {
//        this.init(
//                "/resource/meta/grid",        //列表页面url
//                "/resource/meta/dialog"      //编辑页面url
//        );
//        comboKv = new HashMap<>();
//        comboKv.put("code", "id");
//        comboKv.put("value", "name");
//        comboKv.put("domainName", "domainName");
//        comboKv.put("domain", "domain");
//    }
//
//    @RequestMapping("dataInitial")
//    public String gridInitial(Model model) {
//        model.addAttribute("contentPage","/resource/meta/grid");
//        return "pageView";
//    }
//
//    @RequestMapping("/gotoImportLs")
//    public String gotoImportLs(EnvelopRestEndpointString result){
//        try {
//            model.addAttribute("domainData", service.searchSysDictEntries(31));
//            model.addAttribute("columnTypeData", service.searchSysDictEntries(30));
//            model.addAttribute("ynData", service.searchSysDictEntries(18));
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        model.addAttribute("files", result);
//        model.addAttribute("contentPage", "/resource/meta/impGrid");
//        return "pageView";
//    }
//
//    @RequestMapping("/downLoadErrInfo")
//    public void downLoadErrInfo(String f, String datePath,  HttpServletResponse response) throws IOException {
//
//        OutputStream toClient = response.getOutputStream();
//        try{
//            f = datePath + TemPath.separator + f;
//            File file = new File( TemPath.getFullPath(f, parentFile) );
//            response.reset();
//            response.setContentType("octets/stream");
//            response.addHeader("Content-Disposition", "attachment; filename="
//                    + new String((f.substring(0, f.length()-4)+".xls").getBytes("gb2312"), "ISO8859-1"));
//
////            toClient = new BufferedOutputStream(response.getOutputStream());
//            new RsMetaMsgModelWriter().write(toClient, (List) ObjectFileRW.read(file));
//            toClient.flush();
//            toClient.close();
//        } catch (Exception e) {
//            e.printStackTrace();
////            if(toClient!=null) toClient.close();
//        }
//    }
//
//    @RequestMapping("/batchSave")
//    @ResponseBody
//    public Object batchSave(String metas, String eFile, String tFile, String datePath){
//
//        try{
//            eFile = datePath + TemPath.separator + eFile;
//            File file = new File(TemPath.getFullPath(eFile, parentFile));
//            List<RsMetaMsgModel> all = (List<RsMetaMsgModel>) ObjectFileRW.read(file);
//            List<RsMetaMsgModel> rsMetaMsgModels = objectMapper.readValue(metas, new TypeReference<List<RsMetaMsgModel>>() {});
//
//
//            Map<String, Set> repeat = new HashMap<>();
//            repeat.put("id", new HashSet<String>());
//            repeat.put("dictCode", new HashSet<String>());
//            for(RsMetaMsgModel model : rsMetaMsgModels){
//                model.validate(repeat);
//            }
//
//            Set<String> existIds = findExistId(toJson(repeat.get("id")));
//            String domains = getSysDictEntries(31);
//            String columnTypes = getSysDictEntries(30);
//            String nullAbles = "[0,1]";
//
//            RsMetaMsgModel model;
//            List saveLs = new ArrayList<>();
//            for(int i=0; i<rsMetaMsgModels.size(); i++){
//                model = rsMetaMsgModels.get(i);
//                if(validate(model, existIds, domains, columnTypes, null, nullAbles, 0)==0
//                        || model.errorMsg.size()>0)
//                    all.set(all.indexOf(model), model);
//                else{
//                    saveLs.add(model);
//                    all.remove(model);
//                }
//
//            }
//            saveMeta(toJson(saveLs));
//            ObjectFileRW.write(file, all);
//
//            return success("");
//        } catch (Exception e) {
//            e.printStackTrace();
//            return systemError();
//        }
//    }
//
//    @RequestMapping("/importLs")
//    @ResponseBody
//    public Object importLs(int page, int rows, String filenName, String datePath){
//        try{
//            File file = new File( TemPath.getFullPath(datePath + TemPath.separator + filenName, parentFile) );
//            List ls = (List) ObjectFileRW.read(file);
//
//            int start = (page-1) * rows;
//            int total = ls.size();
//            int end = start + rows;
//            end = end > total ? total : end;
//
//            List g = new ArrayList<>();
//            for(int i=start; i<end; i++){
//                g.add( ls.get(i) );
//            }
//
//            Envelop envelop = new Envelop();
//            envelop.setDetailModelList(g);
//            envelop.setTotalCount(total);
//            envelop.setSuccessFlg(true);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return systemError();
//        }
//    }
//
//    @RequestMapping(value = "import")
//    @ResponseBody
//    public void importMeta(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException {
//
//        UsersModel user = getCurrentUserRedis(request);
//        try {
//            writerResponse(response, 1+"", "l_upd_progress");
//            request.setCharacterEncoding("UTF-8");
//            AExcelReader excelReader = new RsMetaMsgModelReader();
//            excelReader.read(file.getInputStream());
//            List<RsMetaMsgModel> errorLs = excelReader.getErrorLs();
//            List<RsMetaMsgModel> correctLs = excelReader.getCorrectLs();
//            writerResponse(response, 20+"", "l_upd_progress");
//
//            Set<String> dictCodeSet = excelReader.getRepeat().get("dictCode");
//            String dictCodes = "";
//            for(String code :dictCodeSet){
//                dictCodes += "," + code;
//            }
//            List saveLs = new ArrayList<>();
//
//            Set<String> ids = findExistId(toJson(excelReader.getRepeat().get("id")));
//            String domains = getSysDictEntries(31);
//            String columnTypes = getSysDictEntries(30);
//            String nullAbles = "[0,1]";
//            Map dictIds = null;
//            if(dictCodes.length()>0)
//                dictIds = getDictIds(dictCodes.substring(1));
//            writerResponse(response, 35+"", "l_upd_progress");
//            RsMetaMsgModel model;
//            for(int i=0; i<correctLs.size(); i++){
//                model = correctLs.get(i);
//                if(validate(model, ids, domains, columnTypes, dictIds, nullAbles, 1)==0)
//                    errorLs.add(model);
//                else
//                    saveLs.add(model);
//            }
//            for(int i=0; i<errorLs.size(); i++){
//                model = errorLs.get(i);
//                validate(model, ids, domains, columnTypes, dictIds, nullAbles, 1);
//            }
//            writerResponse(response, 55+"", "l_upd_progress");
//
//            Map rs = new HashMap<>();
//            if(errorLs.size()>0){
//                String eFile = TemPath.createFileName(user.getLoginCode(), "e", parentFile, ".dat");
//                ObjectFileRW.write(new File(TemPath.getFullPath(eFile, parentFile)),errorLs);
//                rs.put("eFile", new String[]{eFile.substring(0, 10), eFile.substring(11, eFile.length())});
//                writerResponse(response, 75 + "", "l_upd_progress");
//            }
//            if(saveLs.size()>0)
//                saveMeta(toJson(saveLs));
//
//            if(rs.size()>0)
//                writerResponse(response, 100 + ",'" + toJson(rs) + "'", "l_upd_progress");
//            else
//                writerResponse(response, 100 + "", "l_upd_progress");
//        } catch (Exception e) {
//            e.printStackTrace();
//            writerResponse(response, "-1", "l_upd_progress");
//        }
//    }
//
//    @RequestMapping("/active")
//    @ResponseBody
//    public Object delete(String ids){
//
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("id", nullToSpace(ids));
//            String rs = service.doPut(service.comUrl+ "/resources/metadata/active", params);
//            return rs;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return systemError();
//        }
//    }
//
//
//    private int validate(RsMetaMsgModel model, Set<String> ids, String domains,
//                         String columnTypes, Map dictIds, String nullAbles, int type){
//        int rs = 1;
//        if(ids.contains(model.getId())){
//            model.addErrorMsg("id", "该资源标准编码已存在!");
//            rs = 0;
//        }
//        int i = 0;
//        if((i=domains.indexOf(model.getDomain()))==0 || i==-1){
//            model.addErrorMsg("domain", "只能是"+ domains +"里的值!");
//            rs = 0;
//        }
//
//        if( (i=columnTypes.indexOf(model.getColumnType()))==0 || i==-1 ){
//            model.addErrorMsg("columnType", "只能是"+ columnTypes +"里的值!");
//            rs = 0;
//        }
//
//        if( (i=nullAbles.indexOf(model.getNullAble()))==0 || i==-1 ){
//            model.addErrorMsg("nullAble", "只能是"+ nullAbles +"里的值!");
//            rs = 0;
//        }
//
//        if(type==1 && !StringUtils.isEmpty(model.getDictCode())){
//            if(dictIds==null){
//                model.addErrorMsg("dictCode", "该字典代码不存在!");
//                rs = 0;
//            }else {
//                Integer dictId = (Integer) dictIds.get(model.getDictCode());
//                if(dictId==null || dictId==0){
//                    model.addErrorMsg("dictCode", "该字典代码不存在!");
//                    rs = 0;
//                }else
//                    model.setDictId(dictId);
//            }
//        }
//        return rs;
//    }
//
//    private Map getDictIds( String dictCodes) throws Exception {
//        PageParms pageParms = new PageParms(5000,1)
//                .addGroupNotNull("code", dictCodes, "g1")
//                .setFields("id,code");
//        Envelop rs = getEnvelop(service.search("/resources/dict", pageParms));
//        if(rs.isSuccessFlg()){
//            Map dictIds = new HashMap<>();
//            List<Map> maps = rs.getDetailModelList();
//            for (Map map : maps){
//                dictIds.put(map.get("code"), map.get("id"));
//            }
//            return dictIds;
//        }
//        throw new Exception("获取字典数据出错");
//    }
//
//
//    private String getSysDictEntries(int dictId) throws Exception {
//        Envelop envelop = getEnvelop(service.searchSysDictEntries(dictId));
//        if(!envelop.isSuccessFlg())
//            throw new Exception("预加载字典失败!");
//        String str = "[";
//        for(Map map: (List<Map>)envelop.getDetailModelList()){
//            str += String.valueOf(map.get("code")) +",";
//        }
//        return str.substring(0, str.length()-1) + "]";
//    }
//
//    private List saveMeta(String metas) throws Exception {
//        Map map = new HashMap<>();
//        map.put("metadatas", metas);
//        EnvelopExt<RsMetaMsgModel> envelop = getEnvelopExt(service.doPost(service.comUrl + "/resources/metadata/batch", map), RsMetaMsgModel.class);
//        if(envelop.isSuccessFlg())
//            return envelop.getDetailModelList();
//        throw new Exception("保存失败!");
//    }
//
//    private Set<String> findExistId(String ids) throws Exception {
//        MultiValueMap<String,String> conditionMap = new LinkedMultiValueMap<String, String>();
//        conditionMap.add("ids", ids);
//
//        RestTemplates template = new RestTemplates();
//        String rs = template.doPost(service.comUrl + "/resources/metadata/id/existence", conditionMap);
//
//        return objectMapper.readValue(rs, new TypeReference<Set<String>>() {});
//    }
//}

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

@ -0,0 +1,44 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.resource.service.RsReportCategoryAppService;
import com.yihu.jw.entity.ehr.report.ReportCategoryAppRelation;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by wxw on 2017/11/24.
 */
@RestController
@RequestMapping("/resource/reportCategoryApp")
public class ReportCategoryAppRelationController extends EnvelopRestEndpoint {
    @Autowired
    private RsReportCategoryAppService rsReportCategoryAppService;
    @RequestMapping("/saveInfo")
    public Envelop save(String categoryId, String appId) {
        try {
            ReportCategoryAppRelation reportCategoryAppRelation = rsReportCategoryAppService.saveInfo(categoryId, appId);
            return ObjEnvelop.getSuccess("保存成功",reportCategoryAppRelation);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("保存失败");
        }
    }
    @RequestMapping("/deleteInfo")
    public Envelop delete(String categoryId, String appId) {
        try {
            rsReportCategoryAppService.deleteByCategoryIdAndAppId(categoryId, appId);
            return success("");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("删除失败");
        }
    }
}

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

@ -0,0 +1,274 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.apps.service.AppService;
import com.yihu.jw.basic.resource.service.RsReportCategoryAppService;
import com.yihu.jw.basic.resource.service.RsReportCategoryService;
import com.yihu.jw.entity.ehr.apps.App;
import com.yihu.jw.entity.ehr.resource.RsReportCategory;
import com.yihu.jw.restmodel.ehr.app.MApp;
import com.yihu.jw.restmodel.ehr.resource.MRsReportCategory;
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.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 资源报表分类 controller
 *
 * @author 张进军
 * @date 2017/8/8 13:53
 */
@RestController
@RequestMapping("/resource/reportCategory")
public class ReportCategoryController extends EnvelopRestEndpoint {
    @Autowired
    private RsReportCategoryAppService rsReportCategoryAppService;
    @Autowired
    private RsReportCategoryService rsReportCategoryService;
    @Autowired
    private AppService appService;
    @RequestMapping("/configDialog")
    public Envelop configDialog(String id) {
        try {
            String appIds = rsReportCategoryAppService.getAppIdByCategory(id);
            return ObjEnvelop.getSuccess("获取成功",appIds);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("获取成功");
        }
    }
    @RequestMapping("/appConfig")
    public Envelop appConfig(String id, String dialogType, Model model) {
        try {
            String appIds = rsReportCategoryAppService.getAppIdByCategory(id);
            return ObjEnvelop.getSuccess("获取成功",appIds);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("获取成功");
        }
    }
    @RequestMapping(value = "detail")
    public Envelop detail(Integer id) {
        try {
            if (id != null) {
                return ObjEnvelop.getSuccess("查询成功",rsReportCategoryService.getById(id));
            }
            return success("查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 根据条件,获取资源报表分类(树形结构)
     */
    @RequestMapping("/getTreeData")
    public Envelop getTreeData(String codeName) {
        try {
            List<MRsReportCategory> resultList = new ArrayList<>();
            // 获取最顶层的资源报表分类集合
            List<RsReportCategory> topNodeList = rsReportCategoryService.getChildrenByPid(0);
            if (topNodeList.size() == 0) {
                return success("查询成功");
            }
            // 暂存最顶层资源报表分类中,满足条件的集合
            List<RsReportCategory> topNodeListIn = new ArrayList<>();
            // 暂存最顶层资源报表分类中,不满足条件的集合
            List<RsReportCategory> topNodeListOut = new ArrayList<>();
            if (StringUtils.isEmpty(codeName)) {
                List<RsReportCategory> treeList = rsReportCategoryService.getTreeByParents(topNodeList);
                return ListEnvelop.getSuccess("查询成功",convertToModels(treeList, resultList, MRsReportCategory.class, ""));
            }
            for (RsReportCategory reportCategory : topNodeList) {
                if (reportCategory.getCode().contains(codeName) || reportCategory.getName().contains(codeName)) {
                    topNodeListIn.add(reportCategory);
                    continue;
                }
                topNodeListOut.add(reportCategory);
            }
            if (topNodeListIn.size() != 0) {
                List<RsReportCategory> inList = rsReportCategoryService.getTreeByParents(topNodeListIn);
                resultList.addAll(convertToModels(inList, new ArrayList<>(), MRsReportCategory.class, ""));
            }
            List<RsReportCategory> outList = rsReportCategoryService.getTreeByParentsAndCodeName(topNodeListOut, codeName);
            resultList.addAll(convertToModels(outList, new ArrayList<>(), MRsReportCategory.class, ""));
            return ListEnvelop.getSuccess("查询成功",resultList);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 获取资源报表分类下拉框数据
     */
    @RequestMapping("/getComboTreeData")
    public Envelop getComboTreeData() {
        try {
            List<RsReportCategory> list = rsReportCategoryService.getAllTreeData();
            return ListEnvelop.getSuccess ("查询成功",convertToModels(list, new ArrayList<>(list.size()), MRsReportCategory.class, ""));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 保存
     */
    @RequestMapping("/save")
    public Envelop save(String data) {
        Envelop envelop = new Envelop();
        Map<String, Object> params = new HashMap<>();
        try {
            String rsReportCategory = data;
            RsReportCategory newRsReportCategory = toEntity(rsReportCategory, RsReportCategory.class);
            if (StringUtils.isEmpty(newRsReportCategory.getCode())) {
                return failed("编码不能为空!");
            }
            if (StringUtils.isEmpty(newRsReportCategory.getName())) {
                return failed("名称不能为空!");
            }
            if (newRsReportCategory.getId() == null) {
                // 新增
                if (null == newRsReportCategory.getPid()) {
                    newRsReportCategory.setPid(0);
                }
                if (null == newRsReportCategory.getSortNo()) {
                    newRsReportCategory.setSortNo(99);
                }
                if(newRsReportCategory.getId()==null){
                    //新增判断名称和code 是否唯一
                    if(!rsReportCategoryService.isUniqueName(0, newRsReportCategory.getName())){
                        return ObjEnvelop.getError("名称已存在",-1);
                    }
                    if(!rsReportCategoryService.isUniqueCode(0, newRsReportCategory.getCode())){
                        return ObjEnvelop.getError("编码已存在",-1);
                    }
                }else{
                    //修改 如果有修改name和code要判断是否唯一
                    RsReportCategory oldRsReportCategory = rsReportCategoryService.getById(newRsReportCategory.getId());
                    if(!oldRsReportCategory.getName().equals(newRsReportCategory.getName())){
                        if(!rsReportCategoryService.isUniqueName(newRsReportCategory.getId(), newRsReportCategory.getName())){
                            return ObjEnvelop.getError("名称已存在",-1);
                        }
                    }
                    if(!oldRsReportCategory.getCode().equals(newRsReportCategory.getCode())){
                        if(!rsReportCategoryService.isUniqueCode(newRsReportCategory.getId(), newRsReportCategory.getCode())){
                            return ObjEnvelop.getError("编码已存在",-1);
                        }
                    }
                }
                newRsReportCategory = rsReportCategoryService.save(newRsReportCategory);
                MRsReportCategory mRsReportCategory = convertToModel(newRsReportCategory, MRsReportCategory.class);
                return ObjEnvelop.getSuccess("操作成功",mRsReportCategory);
            } else {
                // 修改
                RsReportCategory updateModel = rsReportCategoryService.getById(newRsReportCategory.getId());
                updateModel.setCode(newRsReportCategory.getCode());
                updateModel.setName(newRsReportCategory.getName());
                updateModel.setPid(newRsReportCategory.getPid());
                updateModel.setSortNo(null == newRsReportCategory.getSortNo() ? 99 : newRsReportCategory.getSortNo());
                updateModel.setRemark(newRsReportCategory.getRemark());
                params.put("rsReportCategory", objectMapper.writeValueAsString(updateModel));
                newRsReportCategory = rsReportCategoryService.save(updateModel);
                MRsReportCategory mRsReportCategory = convertToModel(newRsReportCategory, MRsReportCategory.class);
                return ObjEnvelop.getSuccess("操作成功",mRsReportCategory);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed("操作失败");
        }
    }
    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Envelop delete(String id) {
        try {
            rsReportCategoryService.delete(id);
            return success("删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("删除失败");
        }
    }
    /**
     * 验证资源报表分类编码是否唯一
     */
    @RequestMapping("/isUniqueCode")
    public Envelop isUniqueCode(@RequestParam Integer id, @RequestParam String code) {
        try {
            return ObjEnvelop.getSuccess("查询成功",rsReportCategoryService.isUniqueCode(id, code));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 验证资源报表分类名称是否唯一
     */
    @RequestMapping("/isUniqueName")
    public Envelop isUniqueName(@RequestParam Integer id, @RequestParam String name) {
        try {
            return ObjEnvelop.getSuccess("查询成功",rsReportCategoryService.isUniqueName(id, name));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    @RequestMapping("/selectAppList")
    public Envelop getSelectAppList(String searchNm,int page,int rows){
        if(StringUtils.isEmpty(searchNm)){
            return failed("id不能为空");
        }
        try {
            String filters = "id="+searchNm;
            List<App> appList = appService.search(null, filters, null, page, rows);
            return PageEnvelop.getSuccessListWithPage("",appList,page,rows,appService.getCount(filters));
        } catch (Exception e){
            e.printStackTrace();
            return failed("查询失败");
        }
    }
}

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

@ -0,0 +1,914 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.yihu.ehr.constants.ErrorCode;
//import com.yihu.ehr.constants.ServiceApi;
//
//import com.yihu.fastdfs.FastDFSUtil;
//import com.yihu.jw.basic.quota.service.TjDimensionMainService;
//import com.yihu.jw.basic.quota.service.TjDimensionSlaveService;
//import com.yihu.jw.basic.quota.service.TjQuotaDimensionMainService;
//import com.yihu.jw.basic.quota.service.TjQuotaDimensionSlaveService;
//import com.yihu.jw.basic.resource.model.RsCategoryTypeTreeModel;
//import com.yihu.jw.basic.resource.model.RsResourcesModel;
//import com.yihu.jw.basic.resource.service.*;
//import com.yihu.jw.entity.ehr.quota.TjDimensionMain;
//import com.yihu.jw.entity.ehr.quota.TjDimensionSlave;
//import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionMain;
//import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionSlave;
//import com.yihu.jw.entity.ehr.resource.*;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.ehr.resource.MChartInfoModel;
//import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
//import com.yihu.jw.restmodel.ehr.resource.MRsReport;
//import com.yihu.jw.restmodel.ehr.resource.MRsResources;
//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.util.common.LogService;
//import com.yihu.jw.util.date.DateTimeUtil;
//import com.yihu.jw.util.http.HttpClientUtil;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.text.ParseException;
//import java.util.*;
//
//
///**
// * 资源报表管理 controller
// *
// * @author 张进军
// * @created 2017.8.15 19:18
// */
//@RestController("RsReportController")
//@RequestMapping("/resource/report")
//public class ReportController extends EnvelopRestEndpoint {
//
//    @Autowired
//    private RsResourceService rsResourceService;
//    @Autowired
//    private RsReportService rsReportService;
//    @Autowired
//    private RsResourceCategoryService rsCategoryService;
//    @Autowired
//    private RsReportViewService rsReportViewService;
//    @Autowired
//    private FastDFSUtil fastDFSUtil;
//    @Autowired
//    private RsResourceDefaultParamService resourceDefaultParamService;
//    @Autowired
//    private ResourceBrowseService resourceBrowseService;
//    @Autowired
//    private RsResourceQuotaService resourceQuotaService;
//    @Autowired
//    private TjQuotaDimensionMainService tjQuotaDimensionMainService;
//    @Autowired
//    private TjQuotaDimensionSlaveService tjQuotaDimensionSlaveService;
//    @Autowired
//    private TjDimensionMainService tjDimensionMainService;
//    @Autowired
//    private TjDimensionSlaveService tjDimensionSlaveService;
//
//    /**
//     * 展示明细
//     */
//    @RequestMapping(value = "detail")
//    public Envelop detail(Integer id) {
//        try {
//            if (id != null) {
//                RsReport rsReport = rsReportService.getById(id);
//                return ObjEnvelop.getSuccess("查询成功",rsReport);
//            }
//            return success("查询成功");
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 分页查询
//     */
//    @RequestMapping("/search")
//    public Envelop search(String codeName, String reportCategoryId, int page, int rows) {
//        Map<String, Object> params = new HashMap<>();
//        StringBuffer filters = new StringBuffer();
//
//        if (!StringUtils.isEmpty(codeName)) {
//            filters.append("code?" + codeName + " g1;name?" + codeName + " g1;");
//        }
//        if (!StringUtils.isEmpty(reportCategoryId)) {
//            filters.append("reportCategoryId=" + reportCategoryId + ";");
//        } else {
//            return success("查询成功");
//        }
//
//        try {
//            List<RsReport> rsReports = rsReportService.search(null, filters.toString(), null, page, rows);
//            return PageEnvelop.getSuccessListWithPage("",rsReports,page,rows,rsReportService.getCount(filters.toString()));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 根据条件,获取视图树形数据(视图类别树下展示视图)
//     */
//    @RequestMapping("/getViewsTreeData")
//    public Envelop getViewsTreeData(String codeName, Integer reportId, HttpServletRequest request) {
//        try {
//            ListEnvelop envelop = new ListEnvelop();
//            //获取到的顶级cda类别集合
//            List<RsResourceCategory> categoryList = rsCategoryService.getRsCategoryByPid("");
//            //顶级类别中符合条件的类别集合
//            List<RsResourceCategory> mRsCategoriesSome = new ArrayList<>();
//            //顶级类别中不符合条件的类别集合
//            List<RsResourceCategory> mRsCategoriesOthers = new ArrayList<>();
//            if (categoryList == null || categoryList.size() == 0){
//                envelop.setStatus(-1);
//                envelop.setMessage("没有匹配条件的资源类别!");
//                return envelop;
//            }
//            List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
//            if(StringUtils.isEmpty(codeName)){
//                treeList = getRsCategoryTreeModelChild(categoryList);
//                envelop.setDetailModelList(treeList);
//                return envelop;
//            }
//            for(RsResourceCategory mRsCategory : categoryList){
//                if(mRsCategory.getName().contains(codeName)){
//                    mRsCategoriesSome.add(mRsCategory);
//                    continue;
//                }
//                mRsCategoriesOthers.add(mRsCategory);
//            }
//            if (mRsCategoriesSome.size() != 0){
//                treeList.addAll(getRsCategoryTreeModelChild(mRsCategoriesSome));
//            }
//            treeList .addAll(getRsCategoryTreeModelByName(mRsCategoriesOthers, codeName));
//            this.setRsCategoryViews(treeList, reportId);
//
//            envelop.setDetailModelList(treeList);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            LogService.getLogger(ReportController.class).error(e.getMessage());
//            return failed("查询失败");
//        }
//    }
//
//    // 设置视图类别拥有的视图
//    private void setRsCategoryViews(List<RsCategoryTypeTreeModel> rsCategoryTypeTreeModelList, Integer reportId) throws Exception {
//        RsCategoryTypeTreeModel rsCategoryTypeTreeModel;
//        for (RsCategoryTypeTreeModel rsCategory : rsCategoryTypeTreeModelList) {
//            List<RsResource> rsResourcesModelList = rsResourceService.search("categoryId=" + rsCategory.getId());
//            for (RsResource rsResources : rsResourcesModelList) {
//                if ((rsResources.getGrantType().equals("0"))) {
//                    rsCategoryTypeTreeModel = new RsCategoryTypeTreeModel();
//                    rsCategoryTypeTreeModel.setId(rsResources.getId());
//                    rsCategoryTypeTreeModel.setName(rsResources.getName());
//                    rsCategoryTypeTreeModel.setPid(rsCategory.getId());
//                    RsReportView rsReportView = rsReportViewService.findByReportIdAndResourceId(reportId, rsResources.getId());
//                    rsCategoryTypeTreeModel.setIschecked(rsReportView!=null);
//                    rsCategory.getChildren().add(rsCategoryTypeTreeModel);
//                }
//            }
//            if (rsCategory.getChildren() != null && rsCategory.getChildren().size() != 0) {
//                setRsCategoryViews(rsCategory.getChildren(), reportId);
//            }
//        }
//    }
//
//    /**
//     * 获取选择的报表视图
//     */
//    @RequestMapping("/getSelectedViews")
//    public Envelop getSelectedViews(Integer reportId) {
//        Map<String, Object> params = new HashMap<>();
//        params.put("reportId", reportId);
//        try {
//            List<RsReportView> rsReportViews = rsReportViewService.findByReportId(reportId);
//            return ListEnvelop.getSuccess("查询成功",rsReportViews);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 保存
//     */
//    @RequestMapping("/save")
//    public Envelop save(String data) {
//        try {
//            RsReport newRsReport = toEntity(data, RsReport.class);
//            if (StringUtils.isEmpty(newRsReport.getCode())) {
//                return failed("编码不能为空!");
//            }
//            if (StringUtils.isEmpty(newRsReport.getName())) {
//                return failed("名称不能为空!");
//            }
//
//            if (newRsReport.getId() == null) {
//                // 新增
//                newRsReport = rsReportService.save(newRsReport);
//                return ObjEnvelop.getSuccess("保存成功",newRsReport);
//            } else {
//                // 修改
//                RsReport updateModel = rsReportService.getById(newRsReport.getId());
//                updateModel.setCode(newRsReport.getCode());
//                updateModel.setName(newRsReport.getName());
//                updateModel.setReportCategoryId(newRsReport.getReportCategoryId());
//                updateModel.setStatus(newRsReport.getStatus());
//                updateModel.setRemark(newRsReport.getRemark());
//                updateModel.setTemplatePath(newRsReport.getTemplatePath());
//                updateModel.setShowType(newRsReport.getShowType());
//
//                return ObjEnvelop.getSuccess("保存成功",updateModel);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("保存失败");
//        }
//    }
//
//    /**
//     * 删除
//     */
//    @RequestMapping("/delete")
//    public Envelop delete(String id) {
//        try {
//            rsReportService.delete(id);
//            return success("删除成功");
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("删除失败");
//        }
//    }
//
//    /**
//     * 验证资源报表编码是否唯一
//     */
//    @RequestMapping("/isUniqueCode")
//    public Envelop isUniqueCode(@RequestParam Integer id, @RequestParam String code) {
//        try {
//            return ObjEnvelop.getSuccess("查询成功",rsReportService.isUniqueCode(id, code));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 验证资源报表名称是否唯一
//     */
//    @RequestMapping("/isUniqueName")
//    public Envelop isUniqueName(@RequestParam Integer id, @RequestParam String name) {
//        try {
//            return ObjEnvelop.getSuccess("查询成功",rsReportService.isUniqueName(id, name));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 列表:模版导入
//     */
////    @RequestMapping("upload")
////    public Envelop upload(Integer id, String name, HttpServletRequest request) {
////        try {
////            Envelop result = new Envelop();
////
////            Map<String, Object> uploadFileParams = FileUploadUtil.getParams(request.getInputStream(), name);
////            String storagePath = uploadFileParams.size() == 0 ? "" : HttpClientUtil.doPost(comUrl + "/filesReturnUrl", uploadFileParams, username, password);
////
////            String urlGet = comUrl + ServiceApi.Resources.RsReportPrefix + id;
////            String envelopGetStr = HttpClientUtil.doGet(urlGet, username, password);
////            Envelop envelopGet = objectMapper.readValue(envelopGetStr, Envelop.class);
////            RsReportModel updateModel = getEnvelopModel(envelopGet.getObj(), RsReportModel.class);
////            updateModel.setTemplatePath(storagePath);
////
////            Map<String, Object> params = new HashMap<>();
////            params.put("rsReport", objectMapper.writeValueAsString(updateModel));
////            String envelopUpdateStr = HttpClientUtil.doPut(comUrl + ServiceApi.Resources.RsReportSave, params, username, password);
////
////            Envelop envelopUpdate = objectMapper.readValue(envelopUpdateStr, Envelop.class);
////            if (envelopUpdate.isSuccessFlg()) {
////                result.setSuccessFlg(true);
////                result.setObj(storagePath);
////            } else {
////                result.setSuccessFlg(false);
////                result.setErrorMsg("文件保存失败!");
////            }
////            return result;
////        } catch (Exception e) {
////            e.printStackTrace();
////            return failed("导入模版发生异常");
////        }
////    }
//
//    /**
//     * 保存资源配置
//     */
//    @RequestMapping("saveSetting")
//    public Envelop saveSetting(@RequestParam Integer reportId, @RequestParam String data) {
//        try {
//            List<RsReportView> rsReportViewList = objectMapper.readValue(data, new TypeReference<List<RsReportView>>(){});
//            rsReportViewService.save(reportId, rsReportViewList);
//            return success("保存成功");
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("保存发生异常");
//        }
//    }
//
//    /**
//     * 获取报表模版内容及其各个图形数据
//     */
//    @RequestMapping("getTemplateData")
//    public Envelop getTemplateData(@RequestParam String reportCode, HttpServletRequest request) {
//        Envelop envelop = new Envelop();
//        Map<String, Object> resultMap = new HashMap<>();
//        List<Map<String, Object>> viewInfos = new ArrayList<>();
//        try {
//            // 获取报表模版内容
//            RsReport rsReport = rsReportService.getByCode(reportCode);
//            if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
//                return failed("模版未找到");
//            }
//            String[] paths = rsReport.getTemplatePath().split(":");
//            byte[] bytes = fastDFSUtil.download(paths[0], paths[1]);
//            String templateContent = new String(bytes, "UTF-8");
//            resultMap.put("templateContent", templateContent);
//
//            // 获取报表视图
//            RsReport report = rsReportService.getByCode(reportCode);
//            List<RsReportView> rsReportViews = rsReportViewService.findByReportId(report.getId());
//
//            // 获取图形配置
//            for (RsReportView view : rsReportViews) {
//                RsResource rsResource = rsResourceService.getResourceById(view.getResourceId());
//                if (rsResource.getEchartType().equals("twoDimensional")){//特殊二维表报表
//                    //数据另外查询
//                } else {
//                    List<RsResourceDefaultParam> rsDefaultParams = resourceDefaultParamService.search("resourcesId=" + view.getResourceId() + ";paramKey=q");
//                    Map<String, Object> conditions = translateViewCondition(rsResource.getDataSource(), rsDefaultParams);
//                    Map<String, Object> viewInfo = new HashMap<>();
//                    viewInfo.put("conditions", conditions); // 视图数据过滤条件。
//                    List<Map<String, Object>> options = new ArrayList<>();
//                    if (rsResource.getDataSource() == 1) {
//                        // 档案视图场合
//                        viewInfo.put("type", "record");
//                        viewInfo.put("resourceCode", rsResource.getCode());
//                        viewInfo.put("searchParams", rsDefaultParams.size() > 0 ? rsDefaultParams.get(0).getParamValue() : "[]");
//                        // 获取展示的列名
//                        List<MRsColumnsModel>  mRsColumnsModelList = resourceBrowseService.getResourceMetadata(rsResource.getCode(), "*");
//                        if (mRsColumnsModelList != null&&mRsColumnsModelList.size()>0) {
//                            viewInfo.put("columns", mRsColumnsModelList);
//                        }
//                        viewInfos.add(viewInfo);
//                    } else if (rsResource.getDataSource() == 2) {
//                        // 指标视图场合
//                        viewInfo.put("type", "quota");
//                        viewInfo.put("resourceId", view.getResourceId());
//                        String quotaFilter = "";
//                        String dimension = "";
//
//                        List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + rsResource.getId());
//                        if(list != null && list.size() > 0){
//                            String quotaCodestr  = "";
//                            String quotaIdstr  = "";
//                            String charstr = "";
//                            int charTypeNum = 0;
//                            boolean lineOrBarFlag = true;
//                            boolean pieFlag = true;
//                            for (RsResourceQuota m : list) {
//                                quotaCodestr = quotaCodestr + m.getQuotaCode() +",";
//                                quotaIdstr = quotaIdstr + m.getQuotaId() +",";
//                                charstr = charstr + m.getQuotaChart() +",";
//                                if(lineOrBarFlag && (m.getQuotaChart() == 1 || m.getQuotaChart() == 2)){
//                                    charTypeNum ++;
//                                    lineOrBarFlag = false;
//                                }else if(pieFlag && m.getQuotaChart() == 3) {
//                                    charTypeNum ++;
//                                    pieFlag = false;
//                                }
//                            }
//
//                            List<Map<String, String>> synthesiseDimensionMap = getTjQuotaSynthesiseDimension(quotaCodestr);
//                            Map<String, String> dimensionMap = new LinkedHashMap<>();
//                            String firstDimension = "";
//                            boolean firstFlag = true;
//                            for(Map<String, String> map :synthesiseDimensionMap){
//                                String name = "";
//                                String code = "";
//                                for(String key :map.keySet()){
//                                    if(key.equals("name")){
//                                        name = map.get(key);
//                                    }else{
//                                        code = map.get(key);
//                                    }
//                                }
//                                dimensionMap.put(code,name);
//                                if(firstFlag){
//                                    firstDimension = code;
//                                    firstFlag =  false;
//                                }
//                            }
//                            if(StringUtils.isEmpty(dimension) || dimension.equals(" ")){
//                                String defaultDimension = rsResource.getDimension();
//                                if (!org.apache.commons.lang.StringUtils.isEmpty(defaultDimension)) {
//                                    dimension = rsResource.getDimension();
//                                } else {
//                                    dimension = firstDimension;
//                                }
//                            }
//
//                            if(charTypeNum > 1){
//                                return failed("视图由多个指标组成时,预览图形支持 多指标都属于同一类型,混合型目前支持‘柱状+柱状’,请确认图表展示类型!");
//                            }else {
//                                if(StringUtils.isNotEmpty(rsResource.getEchartType()) && rsResource.getEchartType().equals("radar")){
//                                    chartInfoModel = getQuotaRadarGraphicReports(quotaIdstr, filter, dimension, rsResource.getName());
//                                }else if(StringUtils.isNotEmpty(rsResource.getEchartType()) && rsResource.getEchartType().equals("nestedPie")){
//                                    chartInfoModel = tjQuotaJobClient.getQuotaNestedPieGraphicReports(resourceId, quotaIdstr, filter, dimension, rsResource.getName());
//                                }else {
//                                    //修改后
//                                    String chart = "";
//                                    if(org.apache.commons.lang.StringUtils.isNotEmpty(rsResource.getEchartType())){
//                                        chart = rsResource.getEchartType();
//                                        if(chart.equals("bar")){
//                                            chart ="1";
//                                        }else if(chart.equals("line")){
//                                            chart ="2";
//                                        }else if(chart.equals("pie")){
//                                            chart ="3";
//                                        } else if ("mixed".equals(chart)) {
//                                            chart = charstr;
//                                        }
//                                    }else{
//                                        chart = charstr;
//                                    }
//                                    if(org.apache.commons.lang.StringUtils.isEmpty(dimension) && org.apache.commons.lang.StringUtils.isNotEmpty(rsResource.getDimension())){
//                                        dimension = rsResource.getDimension();
//                                    }else if (org.apache.commons.lang.StringUtils.isEmpty(dimension)) {
//                                        dimension =  firstDimension;
//                                    }
//                                    chartInfoModel = tjQuotaJobClient.getMoreQuotaGraphicReportPreviews(quotaIdstr, chart, filter, dimension , mRsResources.getName(), top, objectMapper.writeValueAsString(mRsResources));
//                                }
//                                if(chartInfoModel != null){
//                                    chartInfoModel.setResourceId(resourceId);
//                                    chartInfoModel.setDimensionMap(dimensionMap);
//                                    chartInfoModel.setFirstDimension(firstDimension);
//                                    envelop.setObj(chartInfoModel);
//                                    envelop.setSuccessFlg(true);
//                                }else {
//                                    envelop.setSuccessFlg(false);
//                                    envelop.setErrorMsg("视图数据查询错误");
//                                }
//                            }
//                        }else{
//                            envelop.setErrorMsg("视图中无指标,请确认!");
//                        }
//                        Map<String, Object> option = new HashMap<>();
//                        option.put("resourceCode", chartInfoModel.getResourceCode());
//                        option.put("resourceId", chartInfoModel.getResourceId());
//                        option.put("dimensionList", chartInfoModel.getDimensionMap());
//                        option.put("option", chartInfoModel.getOption());
//                        options.add(option);
//                        viewInfo.put("options", options); // 视图包含的指标echart图形的option。
//                        viewInfos.add(viewInfo);
//                    }
//                }
//            }
//            resultMap.put("viewInfos", viewInfos);
//            envelop.setObj(resultMap);
//            envelop.setSuccessFlg(true);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("获取报表数据发生异常");
//        }
//    }
//
//    public Envelop getQuotaRadarGraphicReports(String resourceId,String quotaFilter,String dimension,
//            @ApiParam(name = "title", value = "名称", defaultValue = "")String title) {
//        String filter = filterHandle(quotaFilter);
//        Envelop envelop = new Envelop();
//        MChartInfoModel chartInfoModel = new MChartInfoModel();
//        chartInfoModel.setResourceId(resourceId);
//        try {
//            RsResource rsResource = rsResourceService.getResourceById(resourceId);
//            if(rsResource==null){
//                return failed("视图不存在,请确认!");
//            }
//            List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + rsResource.getId());
//            String quotaIdStr = "";
//            if (null != list && list.size() > 0) {
//                for (RsResourceQuota rsResourceQuota : list) {
//                    quotaIdStr += rsResourceQuota.getQuotaId() + ",";
//                }
//            }
//            chartInfoModel = tjQuotaJobClient.getQuotaRadarGraphicReports(quotaIdStr, filter, dimension, title);
//            chartInfoModel.setFirstDimension(dimension);
//            chartInfoModel.setResourceId(resourceId);
//            envelop.setObj(chartInfoModel);
//            envelop.setSuccessFlg(true);
//        } catch (Exception e) {
//            envelop.setErrorMsg("获取图表出错!");
//        }
//        return envelop;
//    }
//
//    public Envelop getQuotaNestedPieGraphicReports(String resourceId, String filter,String dimension,String title) {
//        Envelop envelop = new Envelop();
//        MChartInfoModel chartInfoModel = new MChartInfoModel();
//        chartInfoModel.setResourceId(resourceId);
//        envelop.setObj(chartInfoModel);
//        envelop.setSuccessFlg(false);
//        String filters = filterHandle(filter);
//        try {
//            RsResource rsResource = rsResourceService.getResourceById(resourceId);
//            if(rsResource==null){
//                return failed("视图不存在,请确认!");
//            }
//            List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + resourceId);
//            String quotaIdStr = "";
//            if (null != list && list.size() > 0) {
//                for (RsResourceQuota ResourceQuota : list) {
//                    quotaIdStr += ResourceQuota.getQuotaId() + ",";
//                }
//            }
//            chartInfoModel = tjQuotaJobClient.getQuotaNestedPieGraphicReports(resourceId, quotaIdStr, filters, dimension, title);
//            chartInfoModel.setFirstDimension(dimension);
//            chartInfoModel.setResourceId(resourceId);
//            envelop.setObj(chartInfoModel);
//            envelop.setSuccessFlg(true);
//        } catch (Exception e) {
//            envelop.setErrorMsg("获取图表出错!");
//        }
//        return envelop;
//    }
//
//    private String filterHandle(String quotaFilter) {
//        String filter = "";
//        if(org.apache.commons.lang.StringUtils.isNotEmpty(quotaFilter)){
//            String [] quotaFilters = quotaFilter.split(";");
//            for(int i = 0;i < quotaFilters.length; i++){
//                String [] keyVal = quotaFilters[i].split("=");
//                if(keyVal[i].length()>1){
//                    if(i==0){
//                        filter = keyVal[0] + "='" + keyVal[1] +"' ";
//                    }else {
//                        filter = filter + " and "  + keyVal[0] + "='" + keyVal[1] +"' ";
//                    }
//                }
//            }
//        }
//        return filter;
//    }
//
//    private List<Map<String,String>>  getTjQuotaSynthesiseDimension(String quotaCodes) {
//        List<TjQuotaDimensionMain> tjQuotaDimensionMains = null;
//        List<TjQuotaDimensionSlave> tjQuotaDimensionSlaves = null;
//        //保存指标的 ID 和 所有维度的集合
//        Map<String,Map<String,String>> dimensionMap = new LinkedHashMap();
//        String [] quotaCode = quotaCodes.split(",");
//        for(int i=0 ; i < quotaCode.length ;i++){
//            Map<String,String> map = new LinkedHashMap<>();
//            tjQuotaDimensionMains = tjQuotaDimensionMainService.getTjQuotaDimensionMainByCode(quotaCode[i]);
////            int main = 1;
//            for(TjQuotaDimensionMain tjQuotaDimensionMain : tjQuotaDimensionMains){
//                TjDimensionMain tjDimensionMain = tjDimensionMainService.getTjDimensionMainByCode(tjQuotaDimensionMain.getMainCode());
//                if(tjDimensionMain !=null){
//                    map.put(tjDimensionMain.getCode(),tjDimensionMain.getName() + "-" + tjDimensionMain.getCode());
//                }
////                main ++;
//            }
//            tjQuotaDimensionSlaves = tjQuotaDimensionSlaveService.getTjQuotaDimensionSlaveByCode(quotaCode[i]);
//
//            int slave = 1;
//            for(TjQuotaDimensionSlave tjQuotaDimensionSlave : tjQuotaDimensionSlaves){
//                TjDimensionSlave tjDimensionSlave =  tjDimensionSlaveService.getTjDimensionSlaveByCode(tjQuotaDimensionSlave.getSlaveCode());
//                if(tjDimensionSlave != null){
//                    map.put(tjDimensionSlave.getCode(), tjDimensionSlave.getName()+"-slaveKey" + slave);//第几个维度
//                }
//                slave ++;
//            }
//            dimensionMap.put(quotaCode[i],map);
//        }
//
//        //取出第一个指标的所有维度
//        Map<String,String> tempMap = new LinkedHashMap();
//        for(String quotaCodeKey:dimensionMap.keySet() ){
//            Map<String,String> codeMap = dimensionMap.get(quotaCodeKey);
//            for(String dimenCode: codeMap.keySet()){
//                tempMap.put(dimenCode, codeMap.get(dimenCode));
//            }
//            break;
//        }
//
//        //用于保存共同交集的指标 key 保存交集的维度code
//        //value 保存 此维度在每个指标统计的结果集中对应的字段名称
//        Map<String,Map<String,String>> synthesiseMap = new LinkedHashMap<>();
//
//        Map<String,String> saveModelMap = new LinkedHashMap();
//        //其他指标与第一个指标维度对比,如果在第一个指标中都存在 交集维度
//        for(String tempDimenCode:tempMap.keySet() ){
//            int num = 0;
//            String quotaCodeStr = "";
//            for(String keyCode:dimensionMap.keySet() ){
//                quotaCodeStr = keyCode;
//                Map<String,String> codeMap = dimensionMap.get(keyCode);
//                for(String code: codeMap.keySet()){
//                    if( code.equals(tempDimenCode) &&  tempMap.get(tempDimenCode).equals(codeMap.get(code))){
//                        saveModelMap.put(quotaCodeStr + "-"+ tempDimenCode ,  tempMap.get(tempDimenCode) );
//                        //指标code + 维度编码 ->  科室-slaveKey2
//                        num ++;
//                    }
//                }
//            }
//            if(num == dimensionMap.size()){
//                Map<String,String> modelCloumnMap = new LinkedHashMap();
//                modelCloumnMap.put("name",tempMap.get(tempDimenCode).split("-")[0]);
//                for(String keyCode:dimensionMap.keySet() ){
//                    if(saveModelMap.containsKey(keyCode+"-"+ tempDimenCode)) {
//                        String str = keyCode+"-"+ tempDimenCode;
//                        if(saveModelMap.get(str).contains(tempDimenCode)){
//                            modelCloumnMap.put(keyCode,tempDimenCode);
//                        }
//                        if(saveModelMap.get(str).contains("slaveKey")){
//                            modelCloumnMap.put(keyCode,saveModelMap.get(str).split("-")[1]);
//                        }
//                    }
//                }
//                synthesiseMap.put(tempDimenCode,modelCloumnMap);
//            }
//        }
//
//        List<Map<String,String>> resultList = new ArrayList<>();
//        for(String key : synthesiseMap.keySet()){
//            resultList.add(synthesiseMap.get(key));
//        }
//        return  resultList;
//    }
//
//    @RequestMapping("getRsQuotaPreview")
//    public Envelop getRsQuotaPreview(@RequestParam String resourceId, HttpServletRequest request) {
//        Envelop envelop = new Envelop();
//        List<Map<String, Object>> options = new ArrayList<>();
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.clear();
//            params.put("resourceId", resourceId);
//            List<String> userOrgList  = getUserOrgSaasListRedis(request);
//            params.put("userOrgList", userOrgList);
//            params.put("quotaFilter", "");
//            String chartInfoStr = HttpClientUtil.doGet(comUrl + ServiceApi.Resources.GetRsQuotaPreview, params, username, password);
//            Envelop envelop1 = objectMapper.readValue(chartInfoStr, Envelop.class);
//            String s = objectMapper.writeValueAsString((HashMap<String,String>)envelop1.getObj());
//            MChartInfoModel chartInfoModel = objectMapper.readValue(s,MChartInfoModel.class);
//
//            Map<String, Object> option = new HashMap<>();
//            option.put("resourceCode", chartInfoModel.getResourceCode());
//            option.put("resourceId", chartInfoModel.getResourceId());
//            option.put("option", chartInfoModel.getOption());
//            options.add(option);
//            envelop.setSuccessFlg(true);
//            envelop.setDetailModelList(options);
//        }catch (Exception e){
//            e.printStackTrace();
//            return failed("获取报表数据发生异常");
//        }
//        return envelop;
//    }
//
//    /**
//     * 获取报表 联动图形数据
//     * @param reportCode 报表code
//     * @param linkageResourceIdStr 联动视图Id串,多个用;拼接    改为只用于一个视图查询
//     * @param linkageFilter  联动视图条件,多个用;拼接 town=361102;quotaDate >= '2018-03-01' and quotaDate <= '2018-03-31'
//     * @param linkageDimension  联动维度
//     */
//    @RequestMapping("/getLinkageTemplateData")
//    public Envelop getLinkageTemplateData(@RequestParam(name="reportCode",required=false) String reportCode,
//                                         @RequestParam(name="linkageResourceIdStr",required=true) String linkageResourceIdStr,
//                                         @RequestParam(name="linkageFilter",required=false) String linkageFilter,
//                                         @RequestParam(name="linkageDimension",required=false)String linkageDimension,
//                                         @RequestParam(name="limitCondition",required=false)String limitCondition) {
//        String filter = "";
//
//        if(StringUtils.isNotEmpty(linkageFilter)){
//            String [] quotaFilters = linkageFilter.split(";");
//            for(int i = 0;i < quotaFilters.length; i++){
//                if(i == 0){
//                    filter = quotaFilters[0];
//                }else{
//                    filter += " and " + quotaFilters[i];
//                }
//            }
//        }
//        return reportService.getTemplateData(reportCode,linkageResourceIdStr,filter,linkageDimension, limitCondition);
//    }
//
//    /**
//     * 转换视图数据筛选条件
//     */
//    private Map<String, Object> translateViewCondition(Integer type, List<RsResourceDefaultParam> queryList) throws IOException, ParseException {
//        Map<String, Object> conditions = new HashMap<>();
//        if (type == 1) {
//            // 档案视图场合
//            for (int i = 0; i < queryList.size(); i++) {
//                List<Map<String, String>> paramList = objectMapper.readValue(queryList.get(i).getParamValue(), List.class);
//                for (Map<String, String> filter : paramList) {
//                    String field = filter.get("field").toString();
//                    String condition = filter.get("condition").toString();
//                    String value = filter.get("value").toString();
//                    if ("event_date".equals(field)) {
//                        // 期间
//                        String date = DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(value));
//                        if (condition.contains(">")) {
//                            conditions.put("startDate", date);
//                        } else if (condition.contains("<")) {
//                            conditions.put("endDate", date);
//                        }
//                    }
//                    if ("EHR_000241".equals(field)) {
//                        // 地区
//                        conditions.put("area", value);
//                    }
//                }
//            }
//        } else if (type == 2) {
//            // 指标视图场合
//            for (int i = 0; i < queryList.size(); i ++) {
//                Map<String, String> filter = objectMapper.readValue(queryList.get(i).getParamValue(), Map.class);
//                if (filter.get("startTime") != null) {
//                    // 起始日期
//                    String date = filter.get("startTime").toString();
//                    conditions.put("startDate", DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(date)));
//                }
//                if (filter.get("endTime") != null) {
//                    // 终止日期
//                    String date = filter.get("endTime").toString();
//                    conditions.put("endDate", DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(date)));
//                }
//                // 地区
//                String area = "";
//                if (filter.get("province") != null) {
//                    area += filter.get("province").toString();
//                }
//                if (filter.get("city") != null) {
//                    area += filter.get("city").toString();
//                }
//                if (filter.get("town") != null) {
//                    area += filter.get("town").toString();
//                }
//                conditions.put("area", area);
//            }
//        }
//        return conditions;
//    }
//
//    /**
//     * 生成模板
//     * @param id
//     * @param content
//     * @return
//     */
//    @RequestMapping("/uploadTemplate")
//    public Envelop uploadTemplate(Integer id, String content, String reportData, String position) {
//        try {
//            saveSetting(id, reportData);
//            Envelop result = new Envelop();
//            String filePath = this.getClass().getResource("/").getPath() + "temp/";
//            String fileName = System.currentTimeMillis() + "template.js";
//            // 生成模板
//            FileUploadUtil.createFile(filePath, fileName, content);
//            FileInputStream inputStream = new FileInputStream(filePath + fileName);
//            Map<String, Object> uploadFileParams = FileUploadUtil.getParams(inputStream, fileName);
//            String storagePath = uploadFileParams.size() == 0 ? "" : HttpClientUtil.doPost(comUrl + "/filesReturnUrl", uploadFileParams, username, password);
//
//            String urlGet = comUrl + ServiceApi.Resources.RsReportPrefix + id;
//            String envelopGetStr = HttpClientUtil.doGet(urlGet, username, password);
//            Envelop envelopGet = objectMapper.readValue(envelopGetStr, Envelop.class);
//            RsReportModel updateModel = getEnvelopModel(envelopGet.getObj(), RsReportModel.class);
//            updateModel.setTemplatePath(storagePath);
//            // 设置报表中视图和位置的关系
//            updateModel.setPosition(position);
//
//            Map<String, Object> params = new HashMap<>();
//            params.put("rsReport", objectMapper.writeValueAsString(updateModel));
//            String envelopUpdateStr = HttpClientUtil.doPut(comUrl + ServiceApi.Resources.RsReportSave, params, username, password);
//            // 删除临时文件
//            FileUploadUtil.delDir(filePath);
//
//            Envelop envelopUpdate = objectMapper.readValue(envelopUpdateStr, Envelop.class);
//            if (envelopUpdate.isSuccessFlg()) {
//                result.setSuccessFlg(true);
//                result.setObj(storagePath);
//            } else {
//                result.setSuccessFlg(false);
//                result.setErrorMsg("保存失败!");
//            }
//            return result;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("生成模版发生异常");
//        }
//    }
//
//    @RequestMapping("/getPositionMapByCode")
//    public Envelop getPositionByCode(String code) throws Exception {
//        Map<String, Object> params = new HashMap<>();
//        params.put("code", code);
//        String chartInfoStr = HttpClientUtil.doGet(comUrl + "/resources/report/getPositionMapByCode", params, username, password);
//        return chartInfoStr;
//    }
//
//    @RequestMapping("/getTemplateContent")
//    public Envelop getTemplateContent(String reportCode) {
//        Map<String, Object> params = new HashMap<>();
//        try {
//            // 获取报表模版内容
//            params.put("reportCode", reportCode);
//            String templateContent = HttpClientUtil.doGet(comUrl + ServiceApi.Resources.RsReportTemplateContent, params, username, password);
//            return templateContent ;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return "";
//        }
//    }
//
//
//    /**
//     *
//     * 根据父级信息获取全部的子级信息(树形model)
//     * @param info 父级信息
//     * @return 全部子级信息
//     */
//    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelChild(List<RsResourceCategory> info) {
//        List<RsCategoryTypeTreeModel> treeInfo = new ArrayList<>();
//        for (int i = 0; i < info.size(); i++) {
//            RsResourceCategory typeInfo = info.get(i);
//            RsCategoryTypeTreeModel tree = convertToModel(typeInfo, RsCategoryTypeTreeModel.class);
//            List<RsResourceCategory> categoryListChild = rsCategoryService.getRsCategoryByPid(typeInfo.getId());
//            List<RsCategoryTypeTreeModel> listChildTree = getRsCategoryTreeModelChild(categoryListChild);
//            tree.setChildren(listChildTree);
//            treeInfo.add(tree);
//        }
//        return treeInfo;
//    }
//
//    /**
//     * 递归不满足的父级类别集合的子集中满足条件TreeModel集合的方法
//     * @param mRsCategories 不符合的父级类别的集合
//     * @param name
//     * @return
//     */
//    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelByName(List<RsResourceCategory> mRsCategories, String name) throws ParseException {
//        //结构:treeList 包含treeModel,treeModel包含listOfParent
//        List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
//        for(RsResourceCategory mRsCategory:mRsCategories){
//            List<RsCategoryTypeTreeModel> childList = new ArrayList<>();
//            RsCategoryTypeTreeModel treeModel = convertToModel(mRsCategory,RsCategoryTypeTreeModel.class);
//            String pid = mRsCategory.getId();
//            //获取所有下一级cda类别
//            List<RsResourceCategory> listAll = rsCategoryService.getRsCategoryByPid(pid);
//            if(listAll.size() == 0){
//                continue;
//            }
//            //获取所有下一级符合要求的资源类别
//            String filters ="pid="+pid+";name?"+name;
//
//            //modify by cws
//            List<RsResourceCategory> listSome = rsCategoryService.search(filters);
//            //List<MRsCategory> listSome = (List<MRsCategory>)responseEntity.getBody();
//            if(listSome.size()!=0){
//                childList.addAll(getRsCategoryTreeModelChild(listSome));
//            }
//            //取剩下不符合要求的进行递归
//            listAll.removeAll(listSome);
//            if(listAll.size() != 0){
//                childList.addAll(getRsCategoryTreeModelByName(listAll, name));
//            }
//            if(childList.size() != 0){
//                treeModel.setChildren(childList);
//                treeList.add(treeModel);
//            }
//        }
//        return treeList;
//    }
//}

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

@ -0,0 +1,685 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.http.HttpClientUtil;
//import com.yihu.jw.util.network.HttpResponse;
//import com.yihu.jw.util.network.HttpUtils;
//import jxl.Cell;
//import jxl.Workbook;
//import jxl.write.Label;
//import jxl.write.WritableSheet;
//import jxl.write.WritableWorkbook;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.ui.Model;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.OutputStream;
//import java.util.*;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//
///**
// * 资源浏览服务控制器
// * Created by wq on 2016/5/17.
// */
//@RestController
//@RequestMapping("/resourceBrowse")
//public class ResourceBrowseController extends EnvelopRestEndpoint {
//
//    private static final Logger logger = LoggerFactory.getLogger(ResourceBrowseController.class);
//    private static final Integer SINGLE_REQUEST_SIZE = 5000; //导出Excel时的单次请求量
//    private static final Integer SINGLE_EXCEL_SIZE = 50000; //导出Excel时的单个文件数据量
//
//
//
//    @RequestMapping("/searchResourceList")
//    @ResponseBody
//    public Object searchResourceList() throws Exception {
//        Map<String, Object> params = new HashMap<>();
//        String url = "/resources/categories/all";
//        String resultStr = "";
//        resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        Envelop envelop = toModel(resultStr, Envelop.class);
//        return envelop;
//    }
//
//    @RequestMapping("/searchResource")
//    @ResponseBody
//    public Object searchResource(String ids) {
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        String url = "/resources/ResourceBrowses/categories";
//        String resultStr = "";
//        params.put("id", ids);
//        try {
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop.getDetailModelList();
//    }
//
//    /**
//     * 动态获取GRID的列名
//     * @param dictId 资源编码
//     * @param request
//     * @return
//     */
//    @RequestMapping("/getGridCloumnNames")
//    @ResponseBody
//    public List<MRsColumnsModel> getGridColumnNames(String dictId, HttpServletRequest request) throws Exception {
//        return getColumns(dictId, request);
//    }
//
//    /**
//     * zuul
//     * @param resourceCode
//     * @param request
//     * @return
//     * @throws Exception
//     */
//    public  List<MRsColumnsModel> getColumns(String resourceCode, HttpServletRequest request) throws Exception {
//        List<MRsColumnsModel> result = new ArrayList<>();
//        //从Session中获取用户的角色信息作为查询参数
//        boolean isAccessAll = getIsAccessAllRedis(request);
//        List<String> userRoleList  = getUserRolesListRedis(request);
//        // 获取资源拥着信息
//        String urlGet = "/resource/api/v1.0/resources/byCode";
//        Map<String, Object> getParams = new HashMap<>();
//        getParams.put("code", resourceCode);
//        HttpResponse response = HttpUtils.doGet(adminInnerUrl + urlGet, getParams);
//        if (!response.isSuccessFlg()) {
//            return result;
//        }
//        Map<String, Object> rsObj = objectMapper.readValue(response.getContent(), Map.class);
//        String url = "/resource/api/v1.0/resources/query/getResourceMetadata";
//        Map<String, Object> params = new HashMap<>();
//        String userId = String.valueOf(request.getSession().getAttribute("userId"));
//        String creator = String.valueOf(rsObj.get("creator"));
//        if (isAccessAll || userId.equals(creator)) {
//            params.put("roleId", "*");
//        } else {
//            params.put("roleId", objectMapper.writeValueAsString(userRoleList));
//        }
//        params.put("resourcesCode", resourceCode);
//        response = HttpUtils.doGet(adminInnerUrl + url, params);
//        return toModel(response.getContent(), List.class);
//    }
//
//    /**
//     * 获取字典值
//     * @param dictId
//     * @return
//     */
//    @RequestMapping("/getRsDictEntryList")
//    @ResponseBody
//    public Object getRsDictEntryList(String dictId) throws Exception {
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        String resultStr = "";
//        String dictEntryUrl = "/resources/noPageDictEntries";
//        params.put("filters", "dictCode=" + dictId + " g0");
//        if (!StringUtils.isEmpty(dictId)) {
//            resultStr = HttpClientUtil.doGet(comUrl + dictEntryUrl, params, username, password);
//            return resultStr;
//        }
//        return envelop;
//    }
//
//    /**
//     * 档案资源浏览
//     * @param resourcesCode
//     * @param searchParams
//     * @param page
//     * @param rows
//     * @param request
//     * @return
//     */
//    @RequestMapping("/searchResourceData")
//    @ResponseBody
//    public Object searchResourceData(String resourcesCode, String searchParams, int page, int rows, HttpServletRequest request) throws Exception {
//        Envelop envelop = new Envelop();
//        String url = "/resources/ResourceBrowses/getResourceData";
//        //从Session中获取用户的角色信息和授权视图列表作为查询参数
//        List<String> userRolesList  = getUserRolesListRedis(request);
//        List<String> userOrgSaasList  = getUserOrgSaasListRedis(request);
//        List<String> userAreaSaasList  = getUserAreaSaasListRedis(request);
//        boolean isAccessAll = getIsAccessAllRedis(request);
//        if (!isAccessAll) {
//            if ((null == userOrgSaasList || userOrgSaasList.size() <= 0) && (null == userAreaSaasList || userAreaSaasList.size() <= 0)) {
//                envelop.setSuccessFlg(false);
//                envelop.setErrorMsg("无权访问");
//                return envelop;
//            }
//        }
//        Map<String, Object> params = new HashMap<>();
//        params.put("resourcesCode", resourcesCode);
//        if (isAccessAll) {
//            params.put("roleId", "*");
//            params.put("orgCode", "*");
//            params.put("areaCode", "*");
//        } else {
//            // 获取资源拥着信息
//            String urlGet = "/resources/byCode";
//            Map<String, Object> getParams = new HashMap<>();
//            getParams.put("code", resourcesCode);
//            String result1 = HttpClientUtil.doGet(comUrl + urlGet, getParams, username, password);
//            Envelop getEnvelop = objectMapper.readValue(result1, Envelop.class);
//            if (!getEnvelop.isSuccessFlg()) {
//                envelop.setSuccessFlg(false);
//                envelop.setErrorMsg("原资源信息获取失败!");
//                return envelop;
//            }
//            Map<String, Object> rsObj = (Map<String, Object>) getEnvelop.getObj();
//            String userId = String.valueOf(request.getSession().getAttribute("userId"));
//            String creator = String.valueOf(rsObj.get("creator"));
//            // 判断视图是否由用户生成
//            if (userId.equals(creator)) {
//                params.put("roleId", "*");
//            } else {
//                params.put("roleId", objectMapper.writeValueAsString(userRolesList));
//            }
//            params.put("orgCode", objectMapper.writeValueAsString(userOrgSaasList));
//            params.put("areaCode", objectMapper.writeValueAsString(userAreaSaasList));
//        }
//        Pattern pattern = Pattern.compile("\\[.+?\\]");
//        Matcher matcher = pattern.matcher(searchParams);
//        if (matcher.find()) {
//            if (searchParams.contains("{") || searchParams.contains("}")) {
//                params.put("queryCondition", searchParams);
//            } else {
//                params.put("queryCondition", "");
//            }
//        } else {
//            params.put("queryCondition", "");
//        }
//        params.put("page", page);
//        params.put("size", rows);
//        HttpResponse response = HttpUtils.doGet(comUrl + 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<>();
//                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 = resourceIntegratedController.changeIdCardNo(middleList, request);
//                envelop.setDetailModelList(finalList);
//                envelop.setSuccessFlg(true);
//                return envelop;
//            } else {
//                return envelop;
//            }
//        }
//        return toModel(response.getContent(), Envelop.class);
//    }
//
//    /**
//     * 档案资源浏览细表数据 zuul
//     * @param rowKey
//     * @param version
//     * @return
//     */
//    @RequestMapping("/searchResourceSubData")
//    @ResponseBody
//    public Object getRsDictEntryList(String rowKey, String version) throws Exception {
//        Envelop envelop = new Envelop();
//        if (rowKey.contains("$")) {
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("该列数据已为详细数据");
//            return envelop;
//        }
//        String url = "/resource/api/v1.0/resources/query/getResourceSubData";
//        Map<String, Object> params = new HashMap<>();
//        params.put("rowKey", rowKey);
//        params.put("version", version);
//        String resultStr = HttpClientUtil.doGet(adminInnerUrl + url, params, username, password);
//        envelop = toModel(resultStr, Envelop.class);
//        return envelop;
//    }
//
//    /**
//     * 指标资源检索条件获取
//     * @param resourcesId
//     * @return
//     */
//    @RequestMapping("/searchQuotaResourceParam")
//    @ResponseBody
//    public Envelop searchQuotaDataParam(String resourcesId) throws Exception {
//        String url = "/resources/ResourceBrowses/getQuotaResourceParam";
//        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("resourcesId", resourcesId);
//        String resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        Envelop envelop = toModel(resultStr, Envelop.class);
//        return envelop;
//    }
//
//    /**
//     * 指标资源浏览
//     * @param resourcesId
//     * @param searchParams
//     * @param page
//     * @param rows
//     * @param request
//     * @return
//     */
//    @RequestMapping("/searchQuotaResourceData")
//    @ResponseBody
//    public Object searchQuotaResourceData(String resourcesId, String searchParams, int page, int rows, HttpServletRequest request) throws Exception {
//        Map<String, Object> params = new HashMap<>();
//        String resultStr = "";
//        String url = "/resources/ResourceBrowses/getQuotaResourceData";
//        List<String> userOrgList  = getUserOrgSaasListRedis(request);
//        params.put("userOrgList", userOrgList);
//        params.put("resourcesId", resourcesId);
//        if(searchParams != null) {
//            if (searchParams.contains("{") || searchParams.contains("}")) {
//                params.put("queryCondition", searchParams);
//            } else {
//                params.put("queryCondition", "");
//            }
//        }
//        params.put("page", page);
//        params.put("size", rows);
//        resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        return resultStr;
//    }
//
//    /**
//     * 档案资源数据导出
//     * @param response
//     * @param request
//     * @param resourcesCode
//     * @param searchParams
//     * @param size
//     */
//    @RequestMapping("/outExcel")
//    public void outExcel(HttpServletResponse response, HttpServletRequest request, String resourcesCode, String searchParams, Integer size) throws Exception {
//        //权限控制
//        List<String> userRolesList  = getUserRolesListRedis(request);
//        List<String> userOrgSaasList  = getUserOrgSaasListRedis(request);
//        List<String> userAreaSaasList  = getUserAreaSaasListRedis(request);
//        boolean isAccessAll = getIsAccessAllRedis(request);
//        if (!isAccessAll) {
//            if ((null == userOrgSaasList || userOrgSaasList.size() <= 0) && (null == userAreaSaasList || userAreaSaasList.size() <= 0)) {
//                logger.warn("无权访问");
//                response.setStatus(403);
//                return;
//            }
//        }
//        //基本设置
//        response.setContentType("application/vnd.ms-excel");
//        String fileName = "档案资源数据";
//        Long current = System.currentTimeMillis();
//        response.setHeader("Content-Disposition", "attachment; filename="
//                + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + current.toString() + ".xls");
//        OutputStream os = response.getOutputStream();
//        Map<String, Object> params = new HashMap<>();
//        //基本参数
//        String url = "/resources/ResourceBrowses/getResourceData";
//        params.put("resourcesCode", resourcesCode);
//        if (isAccessAll) {
//            params.put("roleId", "*");
//            params.put("orgCode", "*");
//            params.put("areaCode", "*");
//        } else {
//            // 获取资源拥着信息
//            String urlGet = "/resources/byCode";
//            Map<String, Object> getParams = new HashMap<>();
//            getParams.put("code", resourcesCode);
//            String result1 = HttpClientUtil.doGet(comUrl + urlGet, getParams, username, password);
//            Envelop getEnvelop = objectMapper.readValue(result1, Envelop.class);
//            if (!getEnvelop.isSuccessFlg()) {
//                logger.warn("原资源信息获取失败");
//                return;
//            }
//            Map<String, Object> rsObj = (Map<String, Object>) getEnvelop.getObj();
//            String userId = String.valueOf(request.getSession().getAttribute("userId"));
//            String creator = String.valueOf(rsObj.get("creator"));
//            // 判断视图是否由用户生成
//            if (userId.equals(creator)) {
//                params.put("roleId", "*");
//            } else {
//                params.put("roleId", objectMapper.writeValueAsString(userRolesList));
//            }
//            params.put("roleId", objectMapper.writeValueAsString(userRolesList));
//            params.put("orgCode", objectMapper.writeValueAsString(userOrgSaasList));
//            params.put("areaCode", objectMapper.writeValueAsString(userAreaSaasList));
//        }
//        params.put("queryCondition", searchParams);
//        params.put("size", SINGLE_REQUEST_SIZE);
//        List<MRsColumnsModel> mRsColumnsModels = getColumns(resourcesCode, request);
//        if (size < SINGLE_EXCEL_SIZE) {
//            WritableWorkbook book = Workbook.createWorkbook(os);
//            WritableSheet sheet = book.createSheet("page1", 0);
//            //初始化表格基础数据
//            sheet = resourceIntegratedController.initBaseInfo(sheet);
//            for (int i = 0; i < mRsColumnsModels.size(); i++) {
//                sheet.addCell(new Label(i + 6, 0, mRsColumnsModels.get(i).getCode()));
//                sheet.addCell(new Label(i + 6, 1, mRsColumnsModels.get(i).getValue()));
//            }
//            //循环获取数据
//            int totalPage;
//            if (size % SINGLE_REQUEST_SIZE > 0) {
//                totalPage = size / SINGLE_REQUEST_SIZE + 1;
//            } else {
//                totalPage = size / SINGLE_REQUEST_SIZE;
//            }
//            for (int page = 1; page <= totalPage; page ++) {
//                params.put("page", page);
//                String httpResponse = HttpClientUtil.doGet(comUrl + url, params);
//                Envelop envelop = toModel(httpResponse, Envelop.class);
//                List<Object> dataList = envelop.getDetailModelList();
//                Cell[] cells = sheet.getRow(0);
//                //填充数据
//                sheet = inputData(sheet, dataList, cells, sheet.getRows());
//            }
//            sheet.mergeCells(0, 2, 0, sheet.getRows() - 1);
//            sheet.addCell(new Label(0, 2, "值"));
//            sheet.removeRow(0);
//            book.write();
//            book.close();
//        } else {
//            int fileCount;
//            if (size % SINGLE_EXCEL_SIZE > 0) {
//                fileCount = size / SINGLE_EXCEL_SIZE + 1;
//            } else {
//                fileCount = size / SINGLE_EXCEL_SIZE;
//            }
//            int totalPage;
//            if (size % SINGLE_REQUEST_SIZE > 0) {
//                totalPage = size / SINGLE_REQUEST_SIZE + 1;
//            } else {
//                totalPage = size / SINGLE_REQUEST_SIZE;
//            }
//            WritableWorkbook book = Workbook.createWorkbook(os);
//            for (int fileIndex = 1; fileIndex <= fileCount; fileIndex ++) {
//                WritableSheet sheet = book.createSheet("page" + fileIndex, fileIndex - 1);
//                //初始化表格基础数据
//                sheet = resourceIntegratedController.initBaseInfo(sheet);
//                for (int i = 0; i < mRsColumnsModels.size(); i++) {
//                    sheet.addCell(new Label(i + 6, 0, mRsColumnsModels.get(i).getCode()));
//                    sheet.addCell(new Label(i + 6, 1, mRsColumnsModels.get(i).getValue()));
//                }
//                //循环获取数据
//                int currentPage = (fileIndex - 1) * (SINGLE_EXCEL_SIZE / SINGLE_REQUEST_SIZE) + 1;
//                int cycPage;
//                if (fileIndex == fileCount) {
//                    int beforePage = (fileIndex - 1) * (SINGLE_EXCEL_SIZE / SINGLE_REQUEST_SIZE);
//                    int lastPage = totalPage - beforePage;
//                    cycPage = beforePage + lastPage;
//                } else {
//                    cycPage = fileIndex * (SINGLE_EXCEL_SIZE / SINGLE_REQUEST_SIZE);
//                }
//                for (int page = currentPage; page <= cycPage; page ++) {
//                    params.put("page", page);
//                    String httpResponse = HttpClientUtil.doGet(comUrl + url, params);
//                    Envelop envelop = toModel(httpResponse, Envelop.class);
//                    List<Object> dataList = envelop.getDetailModelList();
//                    Cell[] cells = sheet.getRow(0);
//                    //填充数据
//                    sheet = inputData(sheet, dataList, cells, sheet.getRows());
//                }
//                sheet.mergeCells(0, 2, 0, sheet.getRows() - 1);
//                sheet.addCell(new Label(0, 2, "值"));
//                sheet.removeRow(0);
//            }
//            book.write();
//            book.close();
//        }
//        os.flush();
//        os.close();
//    }
//
//    /**
//     * 指标资源数据导出
//     * @param response
//     * @param request
//     * @param resourcesId
//     * @param searchParams
//     * @throws Exception
//     */
//    @RequestMapping("/outQuotaExcel")
//    public void outQuotaExcel(HttpServletResponse response, HttpServletRequest request, String resourcesId, String searchParams) throws Exception {
//        //基本数据
//        response.setContentType("application/vnd.ms-excel");
//        String fileName = "指标资源数据";
//        Long current = System.currentTimeMillis();
//        response.setHeader("Content-Disposition", "attachment; filename="
//                + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + current.toString() + ".xls");
//        OutputStream os = response.getOutputStream();
//        //请求数据
//        String url = "/resources/ResourceBrowses/getQuotaResourceData";
//        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("resourcesId", resourcesId);
//        params.put("queryCondition", searchParams);
//        List<String> userOrgList  = getUserOrgSaasListRedis(request);
//        params.put("userOrgList", userOrgList);
//        String resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        Envelop envelop = toModel(resultStr, Envelop.class);
//        //处理Excel
//        WritableWorkbook book = Workbook.createWorkbook(os);
//        WritableSheet sheet = book.createSheet("page1", 0);
//        sheet.addCell(new Label(0, 0, "代码"));
//        sheet.addCell(new Label(0, 1, "名称"));
//        List<Map<String, String>> objList = (List<Map<String, String>>)envelop.getObj();
//        for(int i = 0; i< objList.size(); i ++) {
//            Map<String, String> objMap = objList.get(i);
//            sheet.addCell(new Label(i + 1, 0, String.valueOf(objMap.get("key"))));
//            sheet.addCell(new Label(i + 1, 1, String.valueOf(objMap.get("name"))));
//        }
//        Cell [] cells = sheet.getRow(0);
//        sheet = inputData(sheet, envelop.getDetailModelList(), cells, sheet.getRows());
//        sheet.mergeCells(0, 2, 0, sheet.getRows() - 1);
//        sheet.addCell(new Label(0, 2, "值"));
//        sheet.removeRow(0);
//        book.write();
//        book.close();
//        os.flush();
//        os.close();
//    }
//
//    /**
//     * 填充数据
//     * @param sheet
//     * @param dataList
//     * @param cells
//     * @return
//     * @throws Exception
//     */
//    public WritableSheet inputData(WritableSheet sheet, List<Object> dataList, Cell[] cells, int rowNum) throws Exception{
//        for (int i = 0; i < dataList.size(); i++) {
//            Map<String, String> map = toModel(toJson(dataList.get(i)), Map.class);
//            for (String key : map.keySet()) {
//                for (Cell cell : cells) {
//                    if (cell.getContents().equals(key)) {
//                        sheet.addCell(new Label(cell.getColumn(), i + rowNum, String.valueOf(map.get(key))));
//                    }
//                }
//            }
//        }
//        return sheet;
//    }
//
//    @RequestMapping("/searchDictEntryList")
//    @ResponseBody
//    public Object getDictEntryList(String dictId, String conditions) throws Exception {
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        List<RsBrowseModel> rsBrowseModelList = new ArrayList<>();
//        String resultStr = "";
//        String url = "";
//        if (!StringUtils.isEmpty(dictId)) {
//            switch (dictId) {
//                case "34":
//                    params.put("filters", "dictId=" + dictId);
//                    params.put("page", 1);
//                    params.put("size", 500);
//                    params.put("fields", "");
//                    params.put("sorts", "");
//                    String con = changeConditions(conditions);
//                    if (!StringUtils.isEmpty(con)) {
//                        params.put("filters", "dictId=" + dictId + " g0;value=" + con + " g1");
//                    }
//                    url = "/dictionaries/entries";
//                    resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//                    break;
//                case "andOr":
//                    rsBrowseModelList.add(new RsBrowseModel("AND", "并且"));
//                    rsBrowseModelList.add(new RsBrowseModel("OR", "或者"));
//                    envelop.setDetailModelList(rsBrowseModelList);
//                    return envelop;
//                default:
//                    url = "/resources/ResourceBrowses";
//                    params.put("category_id", dictId);
//                    resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//                    break;
//            }
//        }
//        return resultStr;
//    }
//
//    @RequestMapping("/browseBefore")
//    public String resourceBrowseBefore(Model model) {
//        Envelop envelop = new Envelop();
//        String resultStr = "";
//        List<RsCategoryModel> list=new ArrayList<RsCategoryModel>();
//        try {
//            RsCategoryModel rsModel=new RsCategoryModel();
//            rsModel.setId("0dae002159535497b3865e129433e933");
//            rsModel.setName("全员人口个案库");
//            list.add(rsModel);
//            rsModel=new RsCategoryModel();
//            rsModel.setId("0dae0021595354a8b3865e129433e934");
//            rsModel.setName("医疗资源库");
//            list.add(rsModel);
//            rsModel=new RsCategoryModel();
//            rsModel.setId("0dae0021595354c4b3865e129433e935");
//            rsModel.setName("健康档案库");
//            list.add(rsModel);
//            rsModel=new RsCategoryModel();
//            rsModel.setId("0dae0021595354cfb3865e129433e936");
//            rsModel.setName("电子病历库");
//            list.add(rsModel);
//            rsModel=new RsCategoryModel();
//            rsModel.setId("0dae0021595354d6b3865e129433e937");
//            rsModel.setName("生命体征库");
//            list.add(rsModel);
//            envelop.setDetailModelList(list);
//            envelop.setSuccessFlg(true);
//            resultStr =  toJson(envelop);
//            model.addAttribute("list",list);
//            model.addAttribute("resultStr",resultStr);
//            model.addAttribute("contentPage", "/resource/browse/resourceBrowseBefore");
//
//            return "pageView";
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("字典查询失败");
//        }
//        model.addAttribute("contentPage", "/resource/browse/resourceBrowseBefore");
//        return "pageView";
//    }
//
//    //获取所有平台应用下的角色组用于下拉框
//    @RequestMapping("/resourceBrowseTree")
//    @ResponseBody
//    public Object getResourceBrowseTree(){
//        try {
//            String url = "/resourceBrowseTree";
//            Map<String,Object> params = new HashMap<>();
//            String envelopStr = HttpClientUtil.doGet(comUrl+url,params,username,password);
//            //Envelop envelop = objectMapper.readValue(envelopStr,Envelop.class);
//            return envelopStr;
//        } catch (Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//    //根据视图分类的id-CategoryId获取数据集
//    @RequestMapping("/getResourceByCategoryId")
//    @ResponseBody
//    public Object getResourceByCategoryId(String categoryId){
//        try {
//            String url = "/getResourceByCategoryId";
//            Map<String,Object> params = new HashMap<>();
//            params.put("categoryId",categoryId);
//            String envelopStr = HttpClientUtil.doGet(comUrl+url,params,username,password);
//            return envelopStr;
//        } catch (Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//    public String changeConditions(String conditions) {
//        String value = "";
//        if (StringUtils.isEmpty(conditions)) {
//            return value;
//        }
//        Map<String, Object> params = new HashMap<>();
//        String condition = "";
//        String conditionAll = "";
//        String url = "/dictionaries/entries";
//        params.put("filters", "dictId=30 g0;code=" + conditions + " g1");
//        params.put("page", 1);
//        params.put("size", 999);
//        params.put("fields", "");
//        params.put("sorts", "");
//        try {
//            condition = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            params.put("filters", "dictId=34");
//            conditionAll = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            SystemDictEntryModel systemDictEntryModel = toModel(toJson(toModel(condition, Envelop.class).getDetailModelList().get(0)), SystemDictEntryModel.class);
//            List<SystemDictEntryModel> systemDictEntryModelAll = toModel(conditionAll, Envelop.class).getDetailModelList();
//            String[] cs = systemDictEntryModel.getCatalog().split(",");
//            for (int i = 0; i < systemDictEntryModelAll.size(); i++) {
//                SystemDictEntryModel sde = toModel(toJson(systemDictEntryModelAll.get(i)), SystemDictEntryModel.class);
//                if (Arrays.asList(cs).contains(sde.getCode())) {
//                    value += sde.getValue() + ",";
//                }
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return value;
//    }
//
//}

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

@ -0,0 +1,503 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.http.HttpClientUtil;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * Controller - 资源中心首页
// * Created by progr1mmer on 2018/1/9.
// */
//
//@RestController
//@RequestMapping("/resourceCenter")
//public class ResourceCenterController extends EnvelopRestEndpoint {
//
//    // ------------------------------- 统计相关 start ------------------------------------
//    /**
//     * 顶部栏 - 居民建档数
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getPatientArchiveCount")
//    public Envelop getPatientArchiveCount() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getPatientArchiveCount";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 顶部栏 - 医疗资源建档数
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getMedicalResourcesCount")
//    public Envelop getMedicalResourcesCount() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getMedicalResourcesCount";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 顶部栏 - 健康档案建档数
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getHealthArchiveCount")
//    public Envelop getHealthArchiveCount() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getHealthArchiveCount";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 顶部栏 - 电子病例建档数
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getElectronicCasesCount")
//    public Envelop getElectronicCasesCount() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getElectronicCasesCount";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 全员人口个案库 - 健康卡绑定量
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getHealthCardBindingAmount")
//    public Envelop getHealthCardBindingAmount() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getHealthCardBindingAmount";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 全员人口个案库 - 信息分布
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getInfoDistribution")
//    public Envelop getInfoDistribution() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getInfoDistribution";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 全员人口个案库 - 新增情况
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getNewSituation")
//    public Envelop getNewSituation() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getNewSituation";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 医疗资源库 - 医疗机构建档分布
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getOrgArchives")
//    public Envelop getOrgArchives() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getOrgArchives";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 医疗资源库 - 医疗人员分布
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getMedicalStaffDistribution")
//    public Envelop getMedicalStaffDistribution() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getMedicalStaffDistribution";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 医疗资源库 - 医护人员比例
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getMedicalStaffRatio")
//    public Envelop getMedicalStaffRatio() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getMedicalStaffRatio";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 健康档案 - 累计整合档案数
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getCumulativeIntegration")
//    public Envelop getCumulativeIntegration() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getCumulativeIntegration";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 健康档案 - 累计待整合档案数
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/gteTotallyToBeIntegrated")
//    public Envelop gteTotallyToBeIntegrated() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/gteTotallyToBeIntegrated";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 健康档案 - 档案来源分布情况
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getArchiveSource")
//    public Envelop getArchiveSource() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getArchiveSource";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 健康档案 - 健康档案分布情况
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getArchiveDistribution")
//    public Envelop getArchiveDistribution() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getArchiveDistribution";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 健康档案 - 健康档案入库情况分析
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getStorageAnalysis")
//    public Envelop getStorageAnalysis() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getStorageAnalysis";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 电子病例 - 电子病例来源分布情况
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getElectronicMedicalSource")
//    public Envelop getElectronicMedicalSource() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getElectronicMedicalSource";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 电子病例 - 电子病历采集医院分布
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getElectronicMedicalOrgDistributed")
//    public Envelop getElectronicMedicalOrgDistributed() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getElectronicMedicalOrgDistributed";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 电子病例 - 电子病历采集科室分布
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getElectronicMedicalDeptDistributed")
//    public Envelop getElectronicMedicalDeptDistributed() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getElectronicMedicalDeptDistributed";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        }catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 电子病例 - 电子病历采集采集情况
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/getElectronicMedicalAcquisitionSituation")
//    public Envelop getElectronicMedicalAcquisitionSituation() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/center/getElectronicMedicalAcquisitionSituation";
//        try {
//            String resultStr = HttpClientUtil.doGet(comUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//    // ------------------------------- 统计相关 end ------------------------------------
//
//    // ------------------------------- 大数据展示相关 start ------------------------------------
//    /**
//     * 成果展示
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/achievements")
//    public Envelop achievements() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/api/v1.0/resource/center/achievements";
//        try {
//            String resultStr = HttpClientUtil.doGet(adminInnerUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 可视化
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/visualization")
//    public Envelop visualization() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/api/v1.0/resource/center/visualization";
//        try {
//            String resultStr = HttpClientUtil.doGet(adminInnerUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 数据分析
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/dataAnalysis")
//    public Envelop dataAnalysis() {
//        Envelop envelop = new Envelop();
//        String url = "/resource/api/v1.0/resource/center/dataAnalysis";
//        try {
//            String resultStr = HttpClientUtil.doGet(adminInnerUrl + url, username, password);
//            envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg(e.getMessage());
//        }
//        return envelop;
//    }
//
//    /**
//     * 分级管理
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/hierarchicalManagement")
//    public Envelop hierarchicalManagement() {
//        String url = "/resource/api/v1.0/resource/center/hierarchicalManagement";
//        try {
//            String resultStr = HttpClientUtil.doGet(adminInnerUrl + url, username, password);
//            Envelop envelop = toModel(resultStr, Envelop.class);
//            return envelop;
//        } catch (Exception e) {
//            return failed(e.getMessage());
//        }
//    }
//
//    // ------------------------------- 大数据展示相关 end ------------------------------------
//
//}

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

@ -0,0 +1,144 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.resource.service.RsMetadataService;
import com.yihu.jw.basic.resource.service.RsResourceMetadataService;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.resource.RsMetadata;
import com.yihu.jw.entity.ehr.resource.RsResourceMetadata;
import com.yihu.jw.restmodel.ehr.resource.MRsMetadata;
import com.yihu.jw.restmodel.ehr.resource.MRsResourceMetadata;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
 * 资源配置服务控制器
 * Created by wq on 2016/5/23.
 */
@RestController
@RequestMapping("/resourceConfiguration")
public class ResourceConfigurationController extends EnvelopRestEndpoint {
    @Autowired
    private RsResourceMetadataService rsMetadataService;
    @Autowired
    private RsMetadataService metadataService;
    @RequestMapping("searchResourceConfiguration")
    public Object searchResourceConfiguration(String searchNm, int page, int rows) {
        Map<String, Object> params = new HashMap<>();
        String metaDataUrl = "/resources/metadata";
        String resultStr = "";
        params.put("filters", "");
        String filters ="valid=1";
        if (!StringUtils.isEmpty(searchNm)){
            filters += ";name?" + searchNm + " g1;id?" + searchNm + " g1";
        }
        params.put("filters",filters);
        params.put("page", page);
        params.put("size", rows);
        params.put("fields", "");
        params.put("sorts", "");
        try {
            long total = 0;
            List<MRsMetadata> metaList;
            //过滤条件为空
            if(StringUtils.isEmpty(filters))
            {
                Page<RsMetadata> metadataPage = metadataService.getMetadata(null,reducePage(page),rows);
                total = metadataPage.getTotalElements();
                return PageEnvelop.getSuccessListWithPage("查询成功",metadataPage.toList(),page,rows,total);
            }
            else
            {
                List<RsMetadata> metadata = metadataService.search(null,filters,null,page,rows);
                total = metadataService.getCount(filters);
                return PageEnvelop.getSuccessListWithPage("查询成功",metadata,page,rows,total);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return failed("查询失败");
    }
    @RequestMapping("searchSelResourceConfiguration")
    public Object searchSelResourceConfiguration(String searchNm, String resourcesId, int page, int rows) {
        Map<String, Object> params = new HashMap<>();
        String ResourceMetadataUrl = "/resources/rs_metadata";
        String selResourceMetadataListUrl = "/resources/" + resourcesId + "/metadata_list";
        String resultStr = "";
        try {
            if (searchNm.equals("selAll")) {
//                resultStr = HttpClientUtil.doGet(comUrl + selResourceMetadataListUrl, params, username, password);
            } else {
                String filters = "";
                params.put("filters", "");
                if (!StringUtils.isEmpty(searchNm)) {
                    filters = "name?" + searchNm + " g1;id?" + searchNm + " g1";
                }
                params.put("resources_id", "");
                if (!StringUtils.isEmpty(resourcesId)) {
                    params.put("resources_id", resourcesId);
                }
                params.put("page", page);
                params.put("size", rows);
                params.put("fields", "");
                params.put("sorts", "");
                long total = 0;
                //过滤条件为空
                if (StringUtils.isEmpty(filters)) {
                    Page<RsResourceMetadata> dimensions = rsMetadataService.getResourceMetadata(null, reducePage(page), rows);
                    total = dimensions.getTotalElements();
                    return PageEnvelop.getSuccessListWithPage("查询成功",dimensions.toList(),page,rows,total);
                } else {
                    List<RsResourceMetadata> dimensions = rsMetadataService.search(null, filters, null, page, rows);
                    total = rsMetadataService.getCount(filters);
                    return PageEnvelop.getSuccessListWithPage("查询成功",dimensions,page,rows,total);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resultStr;
    }
    @RequestMapping("/saveResourcConfiguration")
    public Envelop saveResourceConfiguration(String addRowDatas, String delRowDatas) {
        Map<String, Object> params = new HashMap<>();
        String resultStr = "";
        String metaDataUrl = "/resources/rs_metadata/batch";
        try {
            if (!StringUtils.isEmpty(delRowDatas)) {
                //执行删除操作
                rsMetadataService.delete(delRowDatas);
                return success("删除成功");
            }
            if (!StringUtils.isEmpty(addRowDatas)) {
                //执行新增操作
                RsResourceMetadata[] rsMetadata = toEntity(addRowDatas, RsResourceMetadata[].class);
                for (RsResourceMetadata metadata : rsMetadata) {
                    metadata.setId(getObjectId(BizObject.ResourceMetadata));
                }
                List<RsResourceMetadata> metadataList = rsMetadataService.saveMetadataBatch(rsMetadata);
                return success("新增成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return failed("操作失败");
    }
}

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

@ -0,0 +1,141 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.service.RsResourceDefaultParamService;
import com.yihu.jw.entity.ehr.resource.RsResourceDefaultParam;
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.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yww on 2016/7/20.
 */
@RestController
@RequestMapping("/resource/rsDefaultParam")
public class ResourceDefaultParamController extends EnvelopRestEndpoint {
    @Autowired
    private RsResourceDefaultParamService resourceDefaultParamService;
    @RequestMapping("/infoInitial")
    public Envelop rsDefaultParamInfoInitial(String id,String resourcesId,String resourcesCode,String mode,String rowIndex){
        Envelop envelop = new Envelop();
        try {
            if(StringUtils.equals(mode,"new")){
                return success();
            }
            String url = "/resources/param/"+id;
            RsResourceDefaultParam resourceDefaultParam = resourceDefaultParamService.findById(id);
            return ObjEnvelop.getSuccess("",resourceDefaultParam);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return failed("查询失败");
    }
    //新增、修改
    @RequestMapping("/update")
    public Envelop addOrUpdate(String dataJson,String mode){
        if(StringUtils.isEmpty(mode)){
            return failed("操作类别不能为空!");
        }
        if(StringUtils.isEmpty(dataJson)){
            return failed("空数据!");
        }
        try{
            RsResourceDefaultParam model = toEntity(dataJson, RsResourceDefaultParam.class);
            if(StringUtils.isEmpty(model.getResourcesId())){
                return failed("资源id不能为空!");
            }
            if(StringUtils.isEmpty(model.getResourcesCode())){
                return failed("资源编码不能为空!");
            }
            if(StringUtils.isEmpty(model.getParamKey())){
                return failed("默认参数名不能为空!");
            }
            if(StringUtils.isEmpty(model.getParamValue())){
                return failed("默认参数值不能为空!");
            }
            String url = ServiceApi.Resources.Param;
            Map<String,Object> params = new HashMap<>();
            params.put("json_data",dataJson);
            if(StringUtils.equalsIgnoreCase(mode,"new")){
                RsResourceDefaultParam resourceDefaultParamNew = resourceDefaultParamService.save(model);
                return ObjEnvelop.getSuccess("新增成功",resourceDefaultParamNew);
            }
            RsResourceDefaultParam resourceDefaultParamNew = resourceDefaultParamService.save(model);
            return ObjEnvelop.getSuccess("操作成功",resourceDefaultParamNew);
        }catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    //删除
    @RequestMapping("/delete")
    public Envelop delete(String id){
        try{
            if(id == null){
                return failed("id不能为空!");
            }
            resourceDefaultParamService.delete(id);
            return success();
        }catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    //查看不分页
    @RequestMapping("/searchList")
    public Envelop searchList(String resourcesId){
        try{
            if(StringUtils.isEmpty(resourcesId)){
                return failed("资源id不能为空!");
            }
            String filters = "resourcesId="+resourcesId;
            String url = ServiceApi.Resources.ParamsNoPage;
            List<RsResourceDefaultParam> rsDefaultParams = resourceDefaultParamService.search(filters);
            return ListEnvelop.getSuccess("查询成功",rsDefaultParams);
        }catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    //参数值唯一性验证
    @RequestMapping("/isKeyValueExistence")
    public Envelop isExistenceRsParamKeyValue(String resourcesId,String paramKey,String paramValue){
        try{
            String url = ServiceApi.Resources.ParamKeyValueExistence;
            Map<String,Object> params = new HashMap<>();
            params.put("resources_id",resourcesId);
            params.put("param_key",paramKey);
            params.put("param_value",paramValue);
            String[] fields = {"resourcesId","paramKey","paramValue"};
            String[] values = {resourcesId,paramKey,paramValue};
            List<RsResourceDefaultParam> list = resourceDefaultParamService.findByFields(fields, values);
            if(list != null && list.size()>0){
                return ObjEnvelop.getSuccess("查询成功",true);
            }
            return ObjEnvelop.getSuccess("查询成功",false);
        }catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
}

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

@ -0,0 +1,697 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.resource.service.ResourceIntegratedService;
import com.yihu.jw.basic.resource.service.RsResourceDefaultParamService;
import com.yihu.jw.basic.resource.service.RsResourceService;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.resource.RsResource;
import com.yihu.jw.entity.ehr.resource.RsResourceDefaultParam;
import com.yihu.jw.entity.ehr.resource.RsResourceMetadata;
import com.yihu.jw.entity.ehr.resource.RsResourceQuota;
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.util.common.NumberUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
import jxl.Cell;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
/**
 * Controller - 资源综合查询服务控制器
 * Created by Progr1mmer on 2017/08/01.
 */
@RestController
@RequestMapping("/resourceIntegrated")
public class ResourceIntegratedController extends EnvelopRestEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(ResourceIntegratedController.class);
    private static final Integer SINGLE_REQUEST_SIZE = 5000; //导出Excel时的单次请求量
    private static final Integer SINGLE_EXCEL_SIZE = 50000; //导出Excel时的单个文件数据量
    @Autowired
    private ResourceIntegratedService resourcesIntegratedService;
    @Autowired
    private RsResourceService rsService;
    @Autowired
    private RsResourceDefaultParamService resourceDefaultParamService;
    @Autowired
    private RsResourceService rsResourceService;
    /**
     * 综合查询档案数据列表树 zuul
     * @param filters
     * @return
     */
    @RequestMapping("/getMetadataList")
    public Envelop getMetadataList(String filters, HttpServletRequest request) throws Exception {
        String url = "/resource/api/v1.0/resources/integrated/metadata_list";
        //标准分类
        List list = resourcesIntegratedService.getMetadataList("*", "*", "standard", filters);
        return ListEnvelop.getSuccess("查询成功",list);
    }
    /**
     * 综合查询档案数据分类列表 zuul
     * @param filters
     * @return
     */
    /**
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("/category")
    public Envelop getCategory() throws Exception {
        String url = "/resource/api/v1.0/resources/integrated/category";
        Map<String, Object> params = new HashMap<>();
        //标准分类
        params.put("categoryCode", "standard");
        List<Map<String, Object>> list = resourcesIntegratedService.intCategory("standard");
        return ListEnvelop.getSuccess("查询成功",list);
    }
    /**
     * 综合查询档案数据资源列表 zuul
     * @param filters
     * @return
     */
    @RequestMapping("/metadata")
    public Envelop getMetadataList(String categoryId, String filters, HttpServletRequest request) throws Exception {
        String url = "/resource/api/v1.0/resources/integrated/metadata";
        //标准分类
        List<Map<String, Object>> list = resourcesIntegratedService.intMetadata(categoryId, "*", "*", "standard", filters);
        return ListEnvelop.getSuccess("查询成功",list);
    }
    /**
     * 综合查询档案数据检索 zuul
     * @param resourcesCode
     * @param metaData
     * @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);
//    }
    /**
     * 综合查询指标统计列表树 zuul
     * @param filters
     * @return
     */
    @RequestMapping("/getQuotaList")
    public Envelop getQuotaList(String filters) throws Exception {
        String url = "/resource/api/v1.0/resources/integrated/quota_list";
        List<Map<String, Object>> list = resourcesIntegratedService.getQuotaList(filters);
        return ListEnvelop.getSuccess("查询成功",list);
    }
    /**
     * 综合查询指标统计数据检索
     * @param tjQuotaIds
     * @param tjQuotaCodes
     * @param searchParams
     * @return
     */
//    @RequestMapping("/searchQuotaData")
//    public Envelop searchQuotaData(String tjQuotaIds, String tjQuotaCodes, String searchParams,HttpServletRequest request) throws Exception {
//        String url = "/resources/integrated/quota_data";
//        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("quotaIds", tjQuotaIds);
//        params.put("quotaCodes", tjQuotaCodes);
//        params.put("queryCondition", searchParams);
//        List<String> userOrgList  = getUserOrgSaasListRedis(request);
//        params.put("userOrgList", userOrgList);
//        String resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        Envelop envelop = toModel(resultStr, Envelop.class);
//        return envelop;
//    }
//
//    /**
//     * 综合查询指标统计数据检索条件
//     * @param tjQuotaCodes
//     * @return
//     */
//    @RequestMapping("/searchQuotaParam")
//    public Envelop searchQuotaDataParam(String tjQuotaCodes) throws Exception {
//        String url = "/resources/integrated/quota_param";
//        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("quotaCodes", tjQuotaCodes);
//        String resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        Envelop envelop = toModel(resultStr, Envelop.class);
//        return envelop;
//    }
    /**
     * 综合查询视图保存 zuul
     * @param dataJson
     * @return
     */
    @RequestMapping(value = "/updateResource", method = RequestMethod.POST)
    public Envelop updateResource(String dataJson, HttpServletRequest request) throws Exception {
        Map<String, Object> params = new HashMap<>();
        String url = "/resource/api/v1.0/resources/integrated/resource_update";
        HttpSession session = request.getSession();
        // 转换参数
        Map<String, Object> dataMap = objectMapper.readValue(dataJson, Map.class);
        // 获取资源字符串
        String resource = objectMapper.writeValueAsString(dataMap.get("resource"));
        // 获取资源Map映射
        Map<String, Object> rsObj = objectMapper.readValue(resource, Map.class);
        // 设置创建者
        rsObj.put("creator", session.getAttribute("userId"));
        // 更新参数
        dataMap.put("resource", rsObj);
        // 设置请求参数
        params.put("dataJson", objectMapper.writeValueAsString(dataMap));
        RsResource newResources;
        Map<String, Object> paraMap = objectMapper.readValue(dataJson, Map.class);
        if (!paraMap.containsKey("resource")) {
            return failed("resource不能为空");
        }
        //处理资源视图
        RsResource rsResources = toEntity(resource, RsResource.class);
        if (rsService.findByField("name", rsResources.getName()).size() > 0) {
            return failed("资源名称重复");
        }
        if (rsService.getResourceByCode(rsResources.getCode()) != null) {
            return failed("资源编码重复");
        }
        /**
         * 资源ID
         */
        String reId = getObjectId(BizObject.Resources);
        rsResources.setId(reId);
        /**
         * 根据资源数据类型保存相关数据元和搜索条件
         */
        if (rsResources.getDataSource() == 1) { //档案数据
            //处理关联档案数据元
            if (!paraMap.containsKey("metadatas")) {
                return failed("档案数据元不能为空");
            }
            String rsMetadatasStr = objectMapper.writeValueAsString(paraMap.get("metadatas"));
            RsResourceMetadata[] rsMetadatas = toEntity(rsMetadatasStr, RsResourceMetadata[].class);
            if (rsMetadatas == null || rsMetadatas.length <= 0) {
                //档案数据元为空,删除资源
                return failed("档案数据元不能为空");
            }
            for (RsResourceMetadata rsMetadata : rsMetadatas) {
                rsMetadata.setResourcesId(reId);
                rsMetadata.setId(getObjectId(BizObject.ResourceMetadata));
            }
            //处理默认搜索条件
            RsResourceDefaultParam rsResourceDefaultParam = null;
            if (paraMap.get("queryCondition") != null) {
                List<Map<String, String>> queryList = (List<Map<String, String>>) paraMap.get("queryCondition");
                if (!queryList.isEmpty()) {
                    String queryCondition = objectMapper.writeValueAsString(queryList);
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(reId);
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            }
            newResources = resourcesIntegratedService.profileCompleteSave(rsResources, Arrays.asList(rsMetadatas), rsResourceDefaultParam);
            return success(newResources.getId());
        } else if (rsResources.getDataSource() == 2) { //统计指标
            //处理关联指标数据元
            if (!paraMap.containsKey("quotas")) {
                return failed("指标数据元不能为空");
            }
            String rsQuotasStr = objectMapper.writeValueAsString(paraMap.get("quotas"));
            RsResourceQuota[] rsQuotas = toEntity(rsQuotasStr, RsResourceQuota[].class);
            if (rsQuotas == null || rsQuotas.length <= 0) {
                return failed("指标数据元不能为空");
            }
            for (RsResourceQuota resourceQuota : rsQuotas) {
                resourceQuota.setResourceId(reId);
            }
            //处理默认搜索条件
            RsResourceDefaultParam rsResourceDefaultParam = null;
            if (paraMap.get("queryCondition") != null) {
                Map<String, Object> queryMap = (Map<String, Object>) paraMap.get("queryCondition");
                if (!queryMap.isEmpty()) {
                    String queryCondition = objectMapper.writeValueAsString(queryMap);
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(reId);
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            }
            newResources = resourcesIntegratedService.quotaCompleteSave(rsResources, Arrays.asList(rsQuotas), rsResourceDefaultParam);
            return success(newResources.getId());
        } else {
            return failed("资源类型有误");
        }
    }
    /**
     * 综合查询搜索条件更新 zuul
     * @param dataJson
     * @return
     */
    @RequestMapping(value = "/updateResourceQuery", method = RequestMethod.POST)
    public Envelop updateResourceQuery(String dataJson) throws Exception {
        Map<String, Object> paraMap = objectMapper.readValue(dataJson, Map.class);
        if (!paraMap.containsKey("resourceId") || !paraMap.containsKey("queryCondition")) {
            return failed("参数不完整,缺少resourceId或者queryCondition");
        }
        String resourceId = (String) paraMap.get("resourceId");
        RsResource rsResources = rsService.getResourceById(resourceId);
        if (rsResources != null) {
            RsResourceDefaultParam rsResourceDefaultParam = null;
            String queryCondition = (String) paraMap.get("queryCondition");
            if (rsResources.getDataSource() == 1) {
                if (!queryCondition.equals("[]")) {
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(rsResources.getId());
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            } else {
                if (!queryCondition.equals("{}")) {
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(rsResources.getId());
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            }
            if (rsResourceDefaultParam != null) {
                RsResourceDefaultParam resourceDefaultParam = resourceDefaultParamService.saveWithDel(rsResourceDefaultParam);
                return success(resourceDefaultParam);
            }
            return failed("条件不能为空");
        } else {
            return failed("资源不存在");
        }
    }
    /**
     *  获取视图列表(不区分数据源)
     *
     * @param page
     * @param size
     * @param request
     * @return
     */
    @RequestMapping("/getResourceList")
    public Envelop getResourceList(int page, int size, HttpServletRequest request) throws Exception {
        String url = "/resources/page";
        //从Session中获取用户的角色和和授权视图列表作为查询参数
        HttpSession session = request.getSession();
        Map<String, Object> params = new HashMap<>();
        String userId = session.getAttribute("userId").toString();
        params.put("page", page);
        params.put("size", size);
        params.put("userId", userId);
        List<RsResource> resultList = rsResourceService.getResourcePage("*", userId, page, size);
        PageEnvelop envelop = new PageEnvelop();
        envelop.setStatus(200);
        envelop.setCurrPage(page);
        envelop.setPageSize(size);
        envelop.setTotalCount(rsResourceService.getResourceCount("*", userId));
        envelop.setDetailModelList(resultList);
        return envelop;
    }
    /**
     * 综合查询档案数据导出
     * @param request
     * @param response
     * @param resourcesCode
     * @param searchParams
     * @param metaData
     * @param size
     * @throws Exception
     */
//    @RequestMapping(value = "/outFileExcel")
//    public void outExcel(HttpServletRequest request, HttpServletResponse response, String resourcesCode, String searchParams, String metaData, Integer size) throws Exception {
//
//        //基本设置
//        response.setContentType("application/vnd.ms-excel");
//        String fileName = "综合查询档案资源数据";
//        Long current = System.currentTimeMillis();
//        response.setHeader("Content-Disposition", "attachment; filename="
//                + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + current.toString() + ".xls");
//        OutputStream os = response.getOutputStream();
//        Map<String, Object> params = new HashMap<>();
//        //基本参数
//        String url = "/resource/api/v1.0/resources/integrated/metadata_data";
//        params.put("resourcesCode", resourcesCode);
//        params.put("orgCode", "*");
//        params.put("areaCode", "*");
//        params.put("queryCondition", searchParams);
//        params.put("size", SINGLE_REQUEST_SIZE);
//        if (size <= SINGLE_EXCEL_SIZE) {
//            WritableWorkbook book = Workbook.createWorkbook(os);
//            WritableSheet sheet = book.createSheet("page1", 0);
//            //初始化表格基础数据
//            sheet = initBaseInfo(sheet);
//            List<Map<String, String>> metaDataSrcList = objectMapper.readValue(metaData, List.class);
//            List<String> metaDataList = new ArrayList<String>();
//            for(int i = 0; i < metaDataSrcList.size(); i ++) {
//                Map<String, String> temp = metaDataSrcList.get(i);
//                sheet.addCell(new Label(i + 6, 0, String.valueOf(temp.get("code"))));
//                sheet.addCell(new Label(i + 6, 1, String.valueOf(temp.get("name"))));
//                metaDataList.add(String.valueOf(temp.get("code")));
//            }
//            params.put("metaData", objectMapper.writeValueAsString(metaDataList));
//            //循环获取数据
//            int totalPage;
//            if (size % SINGLE_REQUEST_SIZE > 0) {
//                totalPage = size / SINGLE_REQUEST_SIZE + 1;
//            } else {
//                totalPage = size / SINGLE_REQUEST_SIZE;
//            }
//            for (int page = 1; page <= totalPage; page ++) {
//                params.put("page", page);
//                HttpResponse httpResponse = HttpUtils.doGet(adminInnerUrl + url, params);
//                Envelop envelop = toModel(httpResponse.getContent(), Envelop.class);
//                List<Object> dataList = envelop.getDetailModelList();
//                Cell[] cells = sheet.getRow(0);
//                //填充数据
//                sheet = inputData(sheet, dataList, cells, sheet.getRows());
//            }
//            sheet.mergeCells(0, 2, 0, sheet.getRows() - 1);
//            sheet.addCell(new Label(0, 2, "值"));
//            sheet.removeRow(0);
//            book.write();
//            book.close();
//        } else {
//            int fileCount;
//            if (size % SINGLE_EXCEL_SIZE > 0) {
//                fileCount = size / SINGLE_EXCEL_SIZE + 1;
//            } else {
//                fileCount = size / SINGLE_EXCEL_SIZE;
//            }
//            int totalPage;
//            if (size % SINGLE_REQUEST_SIZE > 0) {
//                totalPage = size / SINGLE_REQUEST_SIZE + 1;
//            } else {
//                totalPage = size / SINGLE_REQUEST_SIZE;
//            }
//            WritableWorkbook book = Workbook.createWorkbook(os);
//            for (int fileIndex = 1; fileIndex <= fileCount; fileIndex ++) {
//                WritableSheet sheet = book.createSheet("page" + fileIndex, fileIndex - 1);
//                //初始化表格基础数据
//                sheet = initBaseInfo(sheet);
//                List<Map<String, String>> metaDataSrcList = objectMapper.readValue(metaData, List.class);
//                List<String> metaDataList = new ArrayList<String>();
//                for (int i = 0; i < metaDataSrcList.size(); i++) {
//                    Map<String, String> temp = metaDataSrcList.get(i);
//                    sheet.addCell(new Label(i + 6, 0, String.valueOf(temp.get("code"))));
//                    sheet.addCell(new Label(i + 6, 1, String.valueOf(temp.get("name"))));
//                    metaDataList.add(String.valueOf(temp.get("code")));
//                }
//                params.put("metaData", objectMapper.writeValueAsString(metaDataList));
//                //循环获取数据
//                int currentPage = (fileIndex - 1) * (SINGLE_EXCEL_SIZE / SINGLE_REQUEST_SIZE) + 1;
//                int cycPage;
//                if (fileIndex == fileCount) {
//                    int beforePage = (fileIndex - 1) * (SINGLE_EXCEL_SIZE / SINGLE_REQUEST_SIZE);
//                    int lastPage = totalPage - beforePage;
//                    cycPage = beforePage + lastPage;
//                } else {
//                    cycPage = fileIndex * (SINGLE_EXCEL_SIZE / SINGLE_REQUEST_SIZE);
//                }
//                for (int page = currentPage; page <= cycPage; page ++) {
//                    params.put("page", page);
//                    String httpResponse = HttpClientUtil.doGet(adminInnerUrl + url, params);
//                    Envelop envelop = toModel(httpResponse, Envelop.class);
//                    List<Object> dataList = envelop.getDetailModelList();
//                    Cell[] cells = sheet.getRow(0);
//                    //填充数据
//                    sheet = inputData(sheet, dataList, cells, sheet.getRows());
//                }
//                sheet.mergeCells(0, 2, 0, sheet.getRows() - 1);
//                sheet.addCell(new Label(0, 2, "值"));
//                sheet.removeRow(0);
//            }
//            book.write();
//            book.close();
//        }
//        os.flush();
//        os.close();
//    }
    /**
     * 综合查询指标数据导出
     * @param response
     * @param tjQuotaIds
     * @param tjQuotaCodes
     * @param searchParams
     */
//    @RequestMapping("/outQuotaExcel")
//    public void outQuotaExcel(HttpServletResponse response, HttpServletRequest request, String tjQuotaIds, String tjQuotaCodes, String searchParams) throws Exception {
        //基本设置
//        response.setContentType("application/vnd.ms-excel");
//        String fileName = "综合查询指标资源数据";
//        Long current = System.currentTimeMillis();
//        response.setHeader("Content-Disposition", "attachment; filename="
//                + new String(fileName.getBytes("UTF-8"), "ISO8859-1") + current.toString() + ".xls");
//        OutputStream os = response.getOutputStream();
//        //请求数据
//        String url = "/resources/integrated/quota_data";
//        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("quotaIds", tjQuotaIds);
//        params.put("quotaCodes", tjQuotaCodes);
//        params.put("queryCondition", searchParams);
//        List<String> userOrgList  = getUserOrgSaasListRedis(request);
//        params.put("userOrgList", userOrgList);
//        String resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        Envelop envelop = toModel(resultStr, Envelop.class);
//        //处理Excel
//        WritableWorkbook book = Workbook.createWorkbook(os);
//        WritableSheet sheet = book.createSheet("page1", 0);
//        sheet.addCell(new Label(0, 0, "代码"));
//        sheet.addCell(new Label(0, 1, "名称"));
//        List<Map<String, String>> objList = (List<Map<String, String>>)envelop.getObj();
//        for(int i = 0; i< objList.size(); i ++) {
//            Map<String, String> objMap = objList.get(i);
//            sheet.addCell(new Label(i + 1, 0, String.valueOf(objMap.get("key"))));
//            sheet.addCell(new Label(i + 1, 1, String.valueOf(objMap.get("name"))));
//        }
//        Cell [] cells = sheet.getRow(0);
//        sheet = inputData(sheet, envelop.getDetailModelList(), cells, sheet.getRows());
//        sheet.mergeCells(0, 2, 0, sheet.getRows() - 1);
//        sheet.addCell(new Label(0, 2, "值"));
//        sheet.removeRow(0);
//        book.write();
//        book.close();
//        os.flush();
//        os.close();
//
//    }
    /**
     * 综合查询档案数据已选数据导出
     * @param response
     * @param selectData
     * @param metaData
     */
//    @RequestMapping(value = "/outSelectExcel", method = RequestMethod.GET)
//    public void outSelectExcel(HttpServletResponse response, String selectData, String metaData) throws Exception {
//        //基本设置
//        response.setContentType("application/vnd.ms-excel");
//        String fileName = "综合查询档案数据资源已选数据";
//        Long current = System.currentTimeMillis();
//        response.setHeader("Content-Disposition", "attachment; filename="
//                + new String(fileName.getBytes("gb2312"), "ISO8859-1") + current.toString() + ".xls");
//        OutputStream os = response.getOutputStream();
//        WritableWorkbook book = Workbook.createWorkbook(os);
//        WritableSheet sheet = book.createSheet("page1", 0);
//        //初始化基础数据
//        sheet = initBaseInfo(sheet);
//        List<Map<String, String>> metaDataSrcList = objectMapper.readValue(metaData, List.class);
//        for(int i = 0; i < metaDataSrcList.size(); i ++) {
//            Map<String, String> temp = metaDataSrcList.get(i);
//            sheet.addCell(new Label(i + 6, 0, String.valueOf(temp.get("code"))));
//            sheet.addCell(new Label(i + 6, 1, String.valueOf(temp.get("name"))));
//        }
//        List<Object> selectDataList = objectMapper.readValue(selectData, List.class);
//        Cell[] cells = sheet.getRow(0);
//        /**
//         * 填充数据
//         */
//        sheet = inputData(sheet, selectDataList, cells, sheet.getRows());
//        sheet.mergeCells(0, 2, 0, sheet.getRows() - 1);
//        sheet.addCell(new Label(0, 2, "值"));
//        book.write();
//        book.close();
//        os.flush();
//        os.close();
//
//    }
    /**
     * 档案数据基础信息初始化
     * @param sheet
     * @return
     * @throws Exception
     */
    public static WritableSheet initBaseInfo(WritableSheet sheet) throws Exception{
        sheet.addCell(new Label(0, 0, "代码"));
        sheet.addCell(new Label(0, 1, "名称"));
        sheet.addCell(new Label(1, 0, "event_date"));
        sheet.addCell(new Label(1, 1, "时间"));
        sheet.addCell(new Label(2, 0, "org_name"));
        sheet.addCell(new Label(2, 1, "机构名称"));
        sheet.addCell(new Label(3, 0, "org_code"));
        sheet.addCell(new Label(3, 1, "机构编号"));
        sheet.addCell(new Label(4, 0, "patient_name"));
        sheet.addCell(new Label(4, 1, "病人姓名"));
        sheet.addCell(new Label(5, 0, "demographic_id"));
        sheet.addCell(new Label(5, 1, "病人身份证号码"));
        return sheet;
    }
    /**
     * 填充数据
     * @param sheet
     * @param dataList
     * @param cells
     * @return
     * @throws Exception
     */
    public WritableSheet inputData(WritableSheet sheet, List<Object> dataList, Cell[] cells, int rowNum) throws Exception{
        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> map = toModel(toJson(dataList.get(i)), Map.class);
            for (String key : map.keySet()) {
                for (Cell cell : cells) {
                    if (cell.getContents().equals(key)) {
                        sheet.addCell(new Label(cell.getColumn(), i + rowNum, String.valueOf(map.get(key))));
                    }
                }
            }
        }
        return sheet;
    }
    public List<Map<String, Object>> changeIdCardNo(List<Map<String, Object>> resultList, HttpServletRequest request) throws Exception {
        List<Map<String, Object>> finalList = new ArrayList<Map<String, Object>>();
        boolean flag = false;
        if (!flag) {
            //没有权限,对身份证号进行部分*展示
            for (Map<String, Object> map : resultList) {
                if (!StringUtils.isEmpty(map.get("demographic_id"))) {
                    map.put("demographic_id", NumberUtil.changeIdCardNo(map.get("demographic_id").toString()));
                }
                //身份证件号码
                if (!StringUtils.isEmpty(map.get("EHR_000017"))) {
                    map.put("EHR_000017", NumberUtil.changeIdCardNo(map.get("EHR_000017").toString()));
                }
                //户主证件号码
                if (!StringUtils.isEmpty(map.get("EHR_000027"))) {
                    map.put("EHR_000027", NumberUtil.changeIdCardNo(map.get("EHR_000027").toString()));
                }
                //医疗保险号
                if (!StringUtils.isEmpty(map.get("EHR_000232"))) {
                    map.put("EHR_000232", NumberUtil.changeIdCardNo(map.get("EHR_000232").toString()));
                }
                //身份证件号码(体检)
                if (!StringUtils.isEmpty(map.get("EHR_000776"))) {
                    map.put("EHR_000776", NumberUtil.changeIdCardNo(map.get("EHR_000776").toString()));
                }
                //母亲身份证件号码
                if (!StringUtils.isEmpty(map.get("EHR_001264"))) {
                    map.put("EHR_001264", NumberUtil.changeIdCardNo(map.get("EHR_001264").toString()));
                }
                //父亲身份证件号码
                if (!StringUtils.isEmpty(map.get("EHR_001266"))) {
                    map.put("EHR_001266", NumberUtil.changeIdCardNo(map.get("EHR_001266").toString()));
                }
                finalList.add(map);
            }
        } else {
            finalList.addAll(resultList);
        }
        return finalList;
    }
}

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

@ -0,0 +1,154 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.resource.service.RsInterfaceService;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.resource.RsInterface;
import com.yihu.jw.restmodel.web.Envelop;
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.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yww on 2016/5/24.
 */
@RestController
@RequestMapping("/resource/resourceInterface")
public class ResourceInterfaceController extends EnvelopRestEndpoint {
    @Autowired
    private RsInterfaceService interfaceService;
    @RequestMapping("/infoInitial")
    public Envelop resourceInterfaceInfoInitial(String id,String mode){
        Envelop envelop = new Envelop();
        String envelopStr = "";
        try{
            if (!StringUtils.isEmpty(id)) {
                RsInterface rsInterface = interfaceService.retrieve(id);
                return ObjEnvelop.getSuccess("查询成功",rsInterface);
            }
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return failed("失败");
        }
    }
    @RequestMapping("/searchRsInterfaces")
    public Envelop searchRsInterfaces(String searchNm, int page, int rows) {
        Envelop envelop = new Envelop();
        String envelopStr = "";
        String filters = "";
        try{
            if(!StringUtils.isEmpty(searchNm)){
                filters += "name?"+searchNm+" g1;resourceInterface?"+searchNm+" g1;";
            }
            List<RsInterface> interfaces = interfaceService.search(null, filters, null, page, rows);
            return PageEnvelop.getSuccessListWithPage("查询成功",interfaces,page,rows,interfaceService.getCount(filters));
        } catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    @RequestMapping("/getResourceInterface")
    public Envelop getResourceInterface(String id){
        Envelop envelop = new Envelop();
        try{
            RsInterface rsInterface = interfaceService.retrieve(id);
            return ObjEnvelop.getSuccess("查询成功",rsInterface);
        } catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    @RequestMapping("/findByResourceInterface")
    public Envelop findByResourceInterface(String resourceInterface){
        Envelop envelop = new Envelop();
        try{
            String url = "/resources/interface";
            Map<String,Object> params = new HashMap<>();
            params.put("resource_interface",resourceInterface);
            RsInterface  rsInterface =  interfaceService.findByResourceInterface(resourceInterface);
            return ObjEnvelop.getSuccess("查询成功",rsInterface);
        } catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    //新增、修改
    @RequestMapping("/update")
    public Envelop updateResourceInterface(String dataJson,String mode){
        Envelop envelop = new Envelop();
        String url = "/resources/interfaces";
        try{
            RsInterface rsInterface = toEntity(dataJson, RsInterface.class);
            if(StringUtils.isEmpty(rsInterface.getName())){
                return failed("资源接口名称不能为空");
            }
            if("new".equals(mode)){
                rsInterface.setId(getObjectId(BizObject.RsInterface));
                interfaceService.save(rsInterface);
                return ObjEnvelop.getSuccess("新增成功",rsInterface);
            } else if("modify".equals(mode)){
                RsInterface updateModel = interfaceService.retrieve(rsInterface.getId());
                if (updateModel==null){
                    return failed("原资源接口信息获取失败");
                }
                updateModel.setName(rsInterface.getName());
                updateModel.setResourceInterface(rsInterface.getResourceInterface());
                updateModel.setParamDescription(rsInterface.getParamDescription());
                updateModel.setResultDescription(rsInterface.getResultDescription());
                updateModel.setDescription(rsInterface.getDescription());
                interfaceService.save(updateModel);
                return ObjEnvelop.getSuccess("新增成功",updateModel);
            }
        }catch(Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
        return envelop;
    }
    //删除
    @RequestMapping("/delete")
    public Envelop deleteRsInterface(String id){
        Envelop envelop = new Envelop();
        try{
            interfaceService.delete(id);
            return success();
        } catch(Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    @RequestMapping("/isNameExist")
    public Envelop isNameExist(String name){
        Envelop envelop = new Envelop();
        try{
            String url = "/resources/existence/name";
            return ObjEnvelop.getSuccess("查询成功",interfaceService.isNameExist(name));
        } catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
}

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

@ -0,0 +1,568 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.dao.RsResourceDao;
import com.yihu.jw.basic.resource.model.ResourceQuotaJson;
import com.yihu.jw.basic.resource.service.*;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.quota.TjQuota;
import com.yihu.jw.entity.ehr.resource.*;
import com.yihu.jw.restmodel.ehr.resource.MChartInfoModel;
import com.yihu.jw.restmodel.ehr.resource.MRsCategory;
import com.yihu.jw.restmodel.ehr.resource.MRsResources;
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.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestClientException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Controller - 视图管理控制器
 * Created by yww on 2016/5/27.
 */
@RestController
@RequestMapping("/resource/resourceManage")
public class ResourceManageController extends EnvelopRestEndpoint {
    @Autowired
    private RsResourceCategoryService rsCategoryService;
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    private RsAppResourceService rsAppResourceService;
    @Autowired
    private RsResourceDao rsResourceDao;
    @Autowired
    private RsResourceQuotaService resourceQuotaService;
    @Autowired
    private RsResourceGrantService rsGrantService;
    @Autowired
    private RsReportViewService rsReportViewService;
    @RequestMapping("/infoInitial")
    public Envelop resourceInterfaceInfoInitial(String id,String mode,String categoryId, String name, String dataSource){
        Envelop envelop = new Envelop();
        String envelopStr = "";
        String categoryName = "";
        try{
            if(!StringUtils.isEmpty(categoryId)) {
                RsResourceCategory rsResourceCategory = rsCategoryService.getRsCategoryById(categoryId);
                if(rsResourceCategory!=null){
                    categoryName = rsResourceCategory.getName();
                }
            }
            RsResource rsResource;
            if (!StringUtils.isEmpty(id)) {
                rsResource = rsResourceService.getResourceById(id);
            } else {
                rsResource = new RsResource();
            }
            rsResource.setCategoryName(categoryName);
            return ObjEnvelop.getSuccess("查询成功",rsResource);
        }catch (Exception e){
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    @RequestMapping(value = "/resourceInfo", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
    public Envelop getResourceInfo(String id) throws Exception {
        RsResource  rsResource = rsResourceService.getResourceById(id);
        return ObjEnvelop.getSuccess("查询成功",rsResource);
    }
    /**
     * 配置授权浏览页面跳转
     * @param resourceId
     * @return
     */
    @RequestMapping("/switch")
    public Envelop switchToPage(String resourceId){
        Envelop envelop = new Envelop();
        String envelopStr = "";
        try{
            if (!StringUtils.isEmpty(resourceId)) {
                RsResource  rsResource = rsResourceService.getResourceById(resourceId);
                return ObjEnvelop.getSuccess("查询成功",rsResource);
            }
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 资源分页查询 -- 弃用
     * @param searchNm
     * @param categoryId
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/resources")
    public Envelop searchResources(String searchNm, String categoryId, String rolesId, String appId, Integer dataSource, int page, int rows){
        String url = "/resources";
        String resultStr = "";
        Envelop envelop = new Envelop();
        Map<String, Object> params = new HashMap<>();
        StringBuffer stringBuffer = new StringBuffer();
        if (!StringUtils.isEmpty(searchNm)) {
            stringBuffer.append("code?" + searchNm + " g1;name?" + searchNm + " g1;");
        }
        if(dataSource != null && dataSource != 0) {
            stringBuffer.append("dataSource=" + dataSource + ";");
        }
        if(!StringUtils.isEmpty(categoryId)){
            stringBuffer.append("categoryId=" + categoryId);
        }else {
            return envelop;
        }
        params.put("filters", "");
        String filters = stringBuffer.toString();
        if (!StringUtils.isEmpty(filters)) {
            params.put("filters", filters);
        }
        if (!StringUtils.isEmpty(rolesId)) {
            params.put("rolesId", rolesId);
        }
        if (!StringUtils.isEmpty(appId)) {
            params.put("appId", appId);
        }
        params.put("page", page);
        params.put("size", rows);
        try {
            long total = 0;
            List<MRsResources> rsList;
            //过滤条件为空
            if(StringUtils.isEmpty(filters)) {
                Page<RsResource> resources = rsResourceService.getResources(null,reducePage(page),rows);
                total = resources.getTotalElements();
                return PageEnvelop.getSuccessListWithPage("查询成功",resources.toList(),page,rows,total);
            } else {
                if (!StringUtils.isEmpty(rolesId) && !StringUtils.isEmpty(appId)) {
                    String resourceIds = rsAppResourceService.getResourceIdByAppId(appId);
                    if (!StringUtils.isEmpty(resourceIds)) {
                        filters += ";id=" + resourceIds + ";" ;
                    } else {
                        filters += ";id=0000;" ;
                    }
                }
                List<RsResource> resources = rsResourceService.search(null,filters,null,page,rows);
                total = rsResourceService.getCount(filters);
                return PageEnvelop.getSuccessListWithPage("查询成功",resources,page,rows,total);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 视图资源列表树
     * @param filters 过滤查询条件
     * @param dataSource 1 档案视图 2 指标视图
     * @return
     */
    @RequestMapping("/resources/tree")
    public Envelop getResourceTree(String filters, Integer dataSource, HttpServletRequest request) throws Exception {
        String url = "/resource/api/v1.0/resources/tree";
        //从Session中获取用户的角色和和授权视图列表作为查询参数
        Map<String, Object> params = new HashMap<>();
        if (!StringUtils.isEmpty(filters)) {
            params.put("filters", filters);
        }
        if(dataSource != null && dataSource != 0) {
            params.put("dataSource", dataSource);
        }
        List<Map<String, Object>> resultList = rsResourceService.getResourceTree(dataSource, "*", filters);
        return ListEnvelop.getSuccess("查询成功",resultList);
    }
    /**
     * 创建或更新资源
     * @param dataJson
     * @param mode
     * @return
     */
    @RequestMapping("/update")
    public Envelop updateResource(String dataJson, String mode, HttpServletRequest request){
        Envelop envelop = new Envelop();
        String url = "/resources";
        try{
            //RsResourcesModel model = objectMapper.readValue(dataJson, RsResourcesModel.class);
            Map<String, Object> resourceMap = objectMapper.readValue(dataJson, Map.class);
            if(resourceMap != null) {
                if (StringUtils.isEmpty(resourceMap.get("code"))) {
                    return failed("资源编码不能为空");
                }
                if (StringUtils.isEmpty(resourceMap.get("name"))) {
                    return failed("资源名称不能为空");
                }
                // 新增
                if ("new".equals(mode)) {
                    RsResource rs = toEntity(objectMapper.writeValueAsString(resourceMap), RsResource.class);
                    rs.setId(getObjectId(BizObject.Resources));
                    RsResource newRsResource =  rsResourceService.saveResource(rs);
                    return ObjEnvelop.getSuccess("新增成功",newRsResource);
                } else if ("modify".equals(mode)) {
                    String urlGet = "/resources/" + resourceMap.get("id");
                    RsResource rsResource = rsResourceService.getResourceById(resourceMap.get("id")+"");
                    if (rsResource==null) {
                        return failed("原资源信息获取失败");
                    }
                    resourceMap.put("creator", rsResource.getCreator());
                    Map<String, Object> params = new HashMap<>();
                    params.put("resource", objectMapper.writeValueAsString(resourceMap));
                    RsResource rs = toEntity(objectMapper.writeValueAsString(resourceMap),RsResource.class);
                    RsResource newRsResource =  rsResourceService.saveResource(rs);
                    return ObjEnvelop.getSuccess("更新成功",newRsResource);
                }
            }else {
                return failed("参数有误");
            }
        }catch (Exception e){
            LogService.getLogger(ResourceManageController.class).error(e.getMessage());
        }
        return failed("操作失败");
    }
    /**
     * 删除资源
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    public Envelop deleteResource(String id) {
        String url = "/resources/" + id;
        String resultStr = "";
        Envelop result = new Envelop();
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        try {
            if (isRsInUse(id)){
                return failed("已授权资源不能删除");
            }
            if(isRsReportInUse(id)){
                return failed("已关联报表资源不能删除");
            }
            if (isSetReport(id)){
                return failed("已配置报表不能删除");
            }
            rsResourceService.deleteResource(id);
            return success("删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("删除失败");
        }
    }
    /**
     * 资源编码唯一性验证
     * @param code
     * @return
     */
    @RequestMapping("/isExistCode")
    public Envelop isExistCode(String code){
        Envelop envelop = new Envelop();
        String url = "/resources/isExistCode/"+code;
        try{
            RsResource rsResource = rsResourceDao.findByCode(code);
            return ObjEnvelop.getSuccess("查询成功",rsResource!=null);
        } catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 资源名称唯一性验证
     * @param name
     * @return
     */
    @RequestMapping("/isExistName")
    public Envelop isExistName(String name){
        Envelop envelop = new Envelop();
        String url = "/resources/isExistName";
        try{
            RsResource rsResource = rsResourceDao.findByName(name);
            return ObjEnvelop.getSuccess("查询成功",rsResource!=null);
        } catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 资源分类树-页面初始化时
     * @return
     */
    @RequestMapping("/categories")
    public Envelop getCategories(){
        try{
            String filters = "";
            String envelopStr = "";
            String url = "/resources/categories/all";
            List<RsResourceCategory> resources = rsCategoryService.search(filters);
            return ListEnvelop.getSuccess("查询成功",resources);
        } catch (Exception e){
            e.printStackTrace();
        }
        return failed("查询失败");
    }
    /**
     * 带检索分页的查找资源分类方法,新增资源时
     * @param searchParm
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/rsCategory")
    public Envelop searchRsCategory(String searchParm, HttpServletRequest request, int page, int rows){
        Envelop envelop = new Envelop();
        String url = "/resources/categories/search";
        String envelopStrGet = "";
        try {
            Map<String, Object> params = new HashMap<>();
            StringBuffer stringBuffer = new StringBuffer();
            if (!StringUtils.isEmpty(searchParm)) {
                stringBuffer.append("name?" + searchParm +";");
            }
            params.put("filters", "");
            String filters = stringBuffer.toString();
            if (!StringUtils.isEmpty(filters)) {
                params.put("filters", filters);
            }
            long total = 0;
            if (StringUtils.isEmpty(filters)) {
                Page<RsResourceCategory> rsCatePage = null;
                rsCatePage = rsCategoryService.getRsCategories(null, reducePage(page), rows);
                total = rsCatePage.getTotalElements();
                return PageEnvelop.getSuccessListWithPage("查询成功",rsCatePage.toList(),page,rows,total);
            } else {
                List<RsResourceCategory> rsCateList = null;
                    rsCateList = rsCategoryService.search(null, filters, null, page, rows);
                total = rsCateList.size();
                return PageEnvelop.getSuccessListWithPage("查询成功",rsCateList,page,rows,total);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询成功");
        }
    }
//    @RequestMapping("/getResourceQuotaInfo")
//    public Envelop getResourceQuotaInfo(String resourceId, String nameOrCode, int page, int rows){
//        String url = "/resources/getQuotaList";
//        String resultStr = "";
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        if (!StringUtils.isEmpty(resourceId)) {
//            params.put("filters", "resourceId=" + resourceId);
//        }
//        if (!StringUtils.isEmpty(nameOrCode)) {
//            params.put("quotaNameOrCode", nameOrCode);
//        }
//        params.put("page", page);
//        params.put("pageSize", rows);
//        try {
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return resultStr;
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
    @RequestMapping(value = "/addResourceQuota", produces = "text/html;charset=UTF-8")
    public Envelop addResourceQuota(String resourceId, String jsonModel, HttpServletRequest request) throws IOException {
        String url = "/resourceQuota/batchAddResourceQuota";
        String resultStr = "";
        Envelop result = new Envelop();
        if (!StringUtils.isEmpty(resourceId)) {
            resourceQuotaService.deleteByResourceId(resourceId);
            return success("删除成功");
        }
        try {
            List<RsResourceQuota> list = objectMapper.readValue(jsonModel, new TypeReference<List<RsResourceQuota>>(){});
            //先删除表中resourceId=XX的数据
            if (list != null && list.size() > 0) {
                resourceQuotaService.deleteByResourceId(list.get(0).getResourceId());
            }
            for (int i=0; i<list.size(); i++) {
                resourceQuotaService.save(list.get(i));
            }
            return ListEnvelop.getSuccess("操作成功",list);
        } catch (RestClientException e) {
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 指标上卷下钻预览
     * @param id
     * @param model
     * @param dimension  维度
     * @param quotaFilter 过滤条件 多个;拼接 如:org=123;city=001
     * @return
     */
//    @RequestMapping("/resourceShow")
//    public Envelop resourceShow(String id ,Model model ,String dimension,String quotaFilter,HttpServletRequest request) throws JsonProcessingException{
//        MChartInfoModel chartInfoModel = new MChartInfoModel();
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("resourceId", id);
//            params.put("dimension", dimension);
//            Map<String, Object> quotaFilterMap = new HashMap<>();
//           if( !StringUtils.isEmpty(quotaFilter) ){
//               params.put("quotaFilter", quotaFilter);
//           }
//            resultStr = HttpClientUtil.doGet(comUrl + ServiceApi.Resources.GetRsQuotaPreview, params, username, password);
//            Envelop envelop = objectMapper.readValue(resultStr, Envelop.class);
//            String s = objectMapper.writeValueAsString((HashMap<String,String>)envelop.getObj());
//            chartInfoModel = objectMapper.readValue(s,MChartInfoModel.class);
//        } catch (Exception e) {
//            e.printStackTrace();
//         }
//        model.addAttribute("id", id);
//        model.addAttribute("chartInfoModel", objectMapper.writeValueAsString(chartInfoModel));
//        model.addAttribute("contentPage","/resource/resourcemanage/resoureShowCharts");
//        return "generalView";
//    }
    /**
     * 指标预览 包含上卷 下钻
     * @param id
     * @param dimension  维度
     * @param quotaFilter 过滤条件 多个;拼接 如:org=123;city=001
     * @return
     */
//    @RequestMapping("/resourceUpDown")
//    public MChartInfoModel getResourceUpDown(String id, String dimension,String quotaFilter ,HttpServletRequest request){
//        MChartInfoModel chartInfoModel = new MChartInfoModel();
//        try {
//            Envelop result = new Envelop();
//            String resultStr = "";
//            Map<String, Object> params = new HashMap<>();
//            params.put("resourceId", id);
//            params.put("dimension", dimension);
//            List<String> userOrgList  = getUserOrgSaasListRedis(request);
//            params.put("userOrgList", userOrgList);
//            Map<String, Object> quotaFilterMap = new HashMap<>();
//            if( !StringUtils.isEmpty(quotaFilter) ){
//                params.put("quotaFilter", quotaFilter);
//            }
//            resultStr = HttpClientUtil.doGet(comUrl + ServiceApi.Resources.GetRsQuotaPreview, params, username, password);
//            Envelop envelop = objectMapper.readValue(resultStr, Envelop.class);
//            String s = objectMapper.writeValueAsString((HashMap<String,String>)envelop.getObj());
//            chartInfoModel = objectMapper.readValue(s,MChartInfoModel.class);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return chartInfoModel;
//    }
    /**
     * 判断资源是否已被授权
     * @param resourceId
     * @return
     * @throws Exception
     */
    public boolean isRsInUse(String resourceId) throws Exception{
        String url = "/resources/grants/no_paging";
        Map<String,Object> params = new HashMap<>();
        params.put("filters","resourceId=" + resourceId);
        List<RsAppResource> rsGrant = rsGrantService.search("resourceId=" + resourceId);
        if (rsGrant!=null&&rsGrant.size()>0) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * 判断资源报表是否关联相关资源
     * @param resourceId
     * @return
     * @throws Exception
     */
    public boolean isRsReportInUse(String resourceId) throws Exception {
        String url = "/resources/reportView/existByResourceId";
        List<RsReportView> rsReportViewList = rsReportViewService.findByResourceId(resourceId);
        if (rsReportViewList == null || rsReportViewList.size() <= 0) {
            return false;
        }else {
            return true;
        }
    }
    public Boolean isSetReport(String resourceId) throws Exception{
        List<RsReportView> list = rsReportViewService.findByResourceId(resourceId);
        if (list != null && list.size() > 0) {
            return true;
        }
        return false;
    }
    @RequestMapping(value = "/getQuotaByResourceId", produces = "text/html;charset=UTF-8")
    public Envelop getQuotaByResourceId(String resourceId){
        Envelop envelop = new Envelop();
        String url = "/resourceQuota/getQuotaByResourceId";
        Map<String,Object> params = new HashMap<>();
        params.put("resourceId",resourceId);
        try{
            List<TjQuota> quotaList = resourceQuotaService.getQuotaByResourceId(resourceId);
            return ListEnvelop.getSuccess("查询成功",quotaList);
        }catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    @RequestMapping(value = "/updateResourceQuota", produces = "text/html;charset=UTF-8")
    public Envelop updateResourceQuota(String jsonModel){
        Envelop envelop = new Envelop();
        String url = "/resourceQuota/updateResourceQuota";
        try{
            List<ResourceQuotaJson> list = objectMapper.readValue(jsonModel, new TypeReference<List<ResourceQuotaJson>>() {
            });
            resourceQuotaService.updateResourceQuota(list);
            return ListEnvelop.getSuccess("查询成功",list);
        }catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
}

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

@ -0,0 +1,137 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.service.RsReportService;
import com.yihu.jw.entity.ehr.resource.RsReport;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by janseny on 2017/11/8.
 */
@RestController
@RequestMapping("/resource/monitorTypeReport")
public class ResourceMonitorTypeReportController extends EnvelopRestEndpoint {
    @Autowired
    private RsReportService rsReportService;
    /**
     * 报表分页查询
     */
    @RequestMapping("/search")
    public Envelop search(String searchNm, int page, int rows) {
        StringBuffer filters = new StringBuffer();
        if (!org.apache.commons.lang3.StringUtils.isEmpty(searchNm)) {
            filters.append("code?" + searchNm + " g1;name?" + searchNm + " g1;");
        }
        try {
            List<RsReport> rsReports = rsReportService.search(null, filters.toString(), null, page, rows);
            return PageEnvelop.getSuccessListWithPage("查询成功",rsReports,page,rows,rsReportService.getCount(filters.toString()));
        } catch (Exception e) {
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    //监测类型添加报表
//    @RequestMapping("/reportCreate")
//    public Envelop reportCreate(String reportId,String monitorTypeId) {
//        if(StringUtils.isEmpty(reportId)){
//            return failed("报表不能为空!");
//        }
//        if(StringUtils.isEmpty(monitorTypeId)){
//            return failed("监测类型id不能为空!");
//        }
//        RsMonitorTypeReportModel model = new RsMonitorTypeReportModel();
//        model.setReportId(Integer.valueOf(reportId));
//        model.setRsReoportMonitorTypeId(Integer.valueOf(monitorTypeId));
//        try{
//            String url = ServiceApi.Resources.RsMonitorTypeReport;
//            Map<String,Object> params = new HashMap<>();
//            params.put("data_json",objectMapper.writeValueAsString(model));
//            String envelopStr = HttpClientUtil.doPost(comUrl+url,params,username,password);
//            return envelopStr;
//        }catch (Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//    //监测类型删除报表
//    @RequestMapping("/reportDelete")
//    public Envelop reportDelete(String reportId,String monitorTypeId) {
//        if(org.apache.commons.lang.StringUtils.isEmpty(reportId)){
//            return failed("报表不能为空!");
//        }
//        if(org.apache.commons.lang.StringUtils.isEmpty(monitorTypeId)){
//            return failed("监测类型id不能为空!");
//        }
//        try{
//            Map<String,Object> params = new HashMap<>();
//            params.put("reportId",reportId);
//            params.put("monitorTypeId",monitorTypeId);
//            String url = ServiceApi.Resources.RsMonitorTypeReport;
//            String envelopStr = HttpClientUtil.doDelete(comUrl+url,params,username,password);
//            return envelopStr;
//        }catch (Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//    //监测类型配置报表列表查询
//    @RequestMapping("/monitorTypeReportList")
//    public Envelop getMonitorTypeReportList(String searchNm,int page,int rows){
//        if(org.apache.commons.lang.StringUtils.isEmpty(searchNm)){
//            return failed("监测类型id不能为空!");
//        }
//        try{
//            String url = ServiceApi.Resources.RsMonitorTypeReports;
//            Map<String,Object> params = new HashMap<>();
//            params.put("fields","");
//            params.put("filters","rsReoportMonitorTypeId="+searchNm);
//            params.put("page",page);
//            params.put("size",rows);
//            String envelopStr = HttpClientUtil.doGet(comUrl+url,params,username,password);
//            return envelopStr;
//        }catch (Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//    //获取监测类型配置的所有 报表
//    @RequestMapping("/monitorTypeReportByMonitorTypeId")
//    public Envelop getMonitorTypeReportByMonitorTypeId(String monitorTypeId){
//        if(org.apache.commons.lang.StringUtils.isEmpty(monitorTypeId)){
//            return failed("监测类型id不能为空!");
//        }
//        try{
//            String url = ServiceApi.Resources.RsMonitorTypeReportsNoPage;
//            Map<String,Object> params = new HashMap<>();
//            params.put("filters","rsReoportMonitorTypeId="+monitorTypeId);
//            String envelopStr = HttpClientUtil.doGet(comUrl+url,params,username,password);
//            return envelopStr;
//        }catch (Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
}

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

@ -0,0 +1,150 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.agadmin.service.ResourceBrowseControllerService;
import com.yihu.jw.basic.dict.service.SystemDictEntryService;
import com.yihu.jw.entity.ehr.dict.SystemDictEntry;
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.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by wq on 2016/6/7.
 */
@RestController
@RequestMapping("/resourceView")
public class ResourceViewController extends EnvelopRestEndpoint {
    @Autowired
    private ResourceBrowseControllerService resourceBrowseControllerService;
    @Autowired
    private SystemDictEntryService systemDictEntryService;
    @RequestMapping("/searchResource")
    public Envelop searchResource(String ids) {
        return resourceBrowseControllerService.getCategories(ids);
    }
    /**
     * 动态获取GRID的列名
     *
     * @param dictId
     * @return
     */
    @RequestMapping("/getGridCloumnNames")
    public Envelop getGridCloumnNames(String dictId) {
        Envelop envelop = new Envelop();
        Map<String, Object> params = new HashMap<>();
        String url = "/resources/ResourceBrowses/getResourceMetadata";
        String resultStr = "";
        params.put("resourcesCode", dictId);
        try {
            List<MRsColumnsModel> rsBrowseModelList = resourceBrowseControllerService.getResourceMetadata(dictId,"");
            return ListEnvelop.getSuccess("查询成功",rsBrowseModelList);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    @RequestMapping("/searchDictEntryList")
    public Envelop getDictEntryList(String dictId) {
        List<MRsColumnsModel> rsBrowseModelList = new ArrayList<>();
        try {
            if (!StringUtils.isEmpty(dictId)) {
                if ("34".equals(dictId)) {
                    List<SystemDictEntry> systemDictEntryList = systemDictEntryService.search("","dictId=" + dictId,"",1,500);
                    return ListEnvelop.getSuccess("查询成功",systemDictEntryList);
                }else if("andOr".equals(dictId)){
                    rsBrowseModelList.add(new MRsColumnsModel("AND", "并且"));
                    rsBrowseModelList.add(new MRsColumnsModel("OR", "或者"));
                    return ListEnvelop.getSuccess("查询成功",rsBrowseModelList);
                }else {
//                    url = "/resources/ResourceBrowses";
//                    params.put("category_id", dictId);
//
//                    resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//                    envelop = toModel(resultStr, Envelop.class);
//                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return failed("查询失败");
    }
    //数据导出方法
//    @RequestMapping("outExcel")
//    public Envelop outExcel(String rowData, String resourceCategoryName) {
//
//        Envelop envelop = new Envelop();
//        resourceCategoryName = resourceCategoryName.replaceAll("/", "") + "_" + System.currentTimeMillis();
//        //标题行
//        List<Object> dataAllList = toModel(rowData, List.class);
//
//        List<String> titleList = new ArrayList<>();
//        List<List> dataList = new ArrayList<>();
//        List<String> rowContext = new ArrayList<>();
//
//        Map<String, String> map = new HashMap<>();
//
//        for (int i = 0; i < dataAllList.size(); i++) {
//            map = toModel(toJson(dataAllList.get(i)), Map.class);
//            for (String key : map.keySet()) {
//
//                if (!titleList.contains(key)) {
//                    titleList.add(key);
//                }
//                rowContext.add(String.valueOf(map.get(key)));
//            }
//            dataList.add(rowContext);
//            rowContext = new ArrayList<>();
//        }
//
//        try {
//            //resourceCategoryName.xls为要新建的文件名
//            WritableWorkbook book = Workbook.createWorkbook(new File("F:\\excel\\" + resourceCategoryName + ".xls"));
//            //生成名为“resourceCategoryName”的工作表,参数0表示这是第一页
//            WritableSheet sheet = book.createSheet(resourceCategoryName, 0);
//            //title
//            for (int i = 0; i < titleList.size(); i++) {
//                sheet.addCell(new Label(i, 0, titleList.get(i)));
//            }
//            //context
//            for (int i = 0; i < dataList.size(); i++) {
//                for (int j = 0; j < dataList.get(i).size(); j++) {
//                    sheet.addCell(new Label(j, i + 1, String.valueOf(dataList.get(i).get(j))));
//                }
//            }
//            book.write();
//            book.close();
//        } catch (Exception e) {
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("数据导出失败");
//        }
//        envelop.setSuccessFlg(true);
//        return envelop;
//    }
}

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

@ -0,0 +1,269 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.common.LogService;
//import com.yihu.jw.util.http.HttpClientUtil;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * Created by wxw on 2017/9/12.
// */
//@RequestMapping("/resourcesStatistics")
//@RestController
////资源中心首页统计  控制入口
//public class ResourcesStatisticsController extends EnvelopRestEndpoint {
//
//
//    @RequestMapping(value = "/stasticReport/getArchiveReportInfo", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "获取健康档案图表", notes = "获取健康档案图表")
//    public Result getArchiveReportInfo(String requestType) {
//        String url = "/stasticReport/getArchiveReportInfo";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("requestType", requestType);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getStatisticsElectronicMedicalCount", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "电子病历-最近七天采集总数统计,门诊住院数", notes = "电子病历-最近七天采集总数统计,门诊住院数")
//    public Result getStatisticsElectronicMedicalCount( ) {
//        String url = "/stasticReport/getStatisticsElectronicMedicalCount";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getStatisticsMedicalEventTypeCount", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "电子病历 - 今天 门诊住院数统计", notes = "电子病历 - 今天 门诊住院数统计")
//    public Result getStatisticsMedicalEventTypeCount( ) {
//        String url = "/stasticReport/getStatisticsMedicalEventTypeCount";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getStatisticsDemographicsAgeCount", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "全员人口个案库 - 年龄段人数统计", notes = "全员人口个案库 - 年龄段人数统计")
//    public Result getStatisticsDemographicsAgeCount( ) {
//        String url = "/stasticReport/getStatisticsDemographicsAgeCount";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getStatisticsUserCards", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "获取健康卡绑定量", notes = "获取健康卡绑定量")
//    public Result getStatisticsUserCards( ) {
//        String url = "/tj/getStatisticsUserCards";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getStatisticsDoctorByRoleType", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "按机构医生、护士、床位的统计", notes = "按机构医生、护士、床位的统计")
//    public Result getStatisticsDoctorByRoleType( ) {
//        String url = "/tj/getStatisticsDoctorByRoleType";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getStatisticsCityDoctorByRoleType", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "全市医生、护士、床位的统计", notes = "全市医生、护士、床位的统计")
//    public Result getStatisticsCityDoctorByRoleType( ) {
//        String url = "/tj/getStatisticsCityDoctorByRoleType";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//
//    @RequestMapping(value = "/stasticReport/getArchiveReportAll", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "获取一段时间内数据解析情况", notes = "获取一段时间内数据解析情况")
//    public Result getArchiveReport1(String startDate,String endDate,String orgCode) {
//        String url = "/stasticReport/getArchiveReportAll";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("startDate", startDate);
//            params.put("endDate", endDate);
//            params.put("orgCode", orgCode);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getRecieveOrgCount", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "根据接收日期统计各个医院的数据解析情况", notes = "根据接收日期统计各个医院的数据解析情况")
//    public Result getRecieveOrgCount(String date) {
//        String url = "/stasticReport/getRecieveOrgCount";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("date", date);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getArchivesInc", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "获取某天数据新增情况", notes = "获取某天数据新增情况")
//    public Result getArchivesInc(String date, String orgCode) {
//        String url = "/stasticReport/getArchivesInc";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("date", date);
//            params.put("orgCode", orgCode);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getArchivesFull", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "完整性", notes = "完整性")
//    public Result getArchivesFull(String startDate, String endDate, String orgCode) {
//        String url = "/stasticReport/getArchivesFull";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("startDate", startDate);
//            params.put("endDate", endDate);
//            params.put("orgCode", orgCode);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getArchivesTime", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "及时性", notes = "及时性")
//    public Result getArchivesTime(String startDate, String endDate, String orgCode) {
//        String url = "/stasticReport/getArchivesTime";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("startDate", startDate);
//            params.put("endDate", endDate);
//            params.put("orgCode", orgCode);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getDataSetCount", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "获取数据集数量", notes = "获取数据集数量")
//    public Result getDataSetCount(String date, String orgCode) {
//        String url = "/stasticReport/getDataSetCount";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("date", date);
//            params.put("orgCode", orgCode);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "/stasticReport/getArchivesRight", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "准确性", notes = "准确性")
//    public Result getArchivesRight(String startDate, String endDate, String orgCode) {
//        String url = "/stasticReport/getArchivesRight";
//        String resultStr = "";
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.put("startDate", startDate);
//            params.put("endDate", endDate);
//            params.put("orgCode", orgCode);
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return toModel(resultStr, ListResult.class);
//        } catch (Exception e) {
//            LogService.getLogger(com.yihu.ehr.resource.controller.ResourceInterfaceController.class).error(e.getMessage());
//        }
//        return null;
//    }
//}

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

@ -0,0 +1,270 @@
package com.yihu.jw.basic.agadmin.controller.resource;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.resource.model.RsCategoryTypeTreeModel;
import com.yihu.jw.basic.resource.service.RsResourceCategoryService;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.resource.RsResourceCategory;
import com.yihu.jw.restmodel.ehr.resource.MRsCategory;
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.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 视图分类控制器
 * Created by AndyCai on 2015/12/14.
 */
@RequestMapping("/rscategory")
@RestController
public class RsResourceCategoryController extends EnvelopRestEndpoint {
    @Autowired
    private RsResourceCategoryService rsCategoryService;
    //获取TreeData 用于初始页面显示嵌套model
    @RequestMapping("/getTreeGridData")
    public Envelop getTreeGridData(String codeName) throws Exception{
        ListEnvelop envelop = new ListEnvelop();
        //获取到的顶级cda类别集合
        String userResource = "*";
        String name = codeName;
        List<RsResourceCategory> categoryList;
        if(userResource.equals("*")) {
            categoryList = rsCategoryService.getRsCategoryByPid("");
        }else {
            categoryList = rsCategoryService.findByCodeAndPid("derived", "");
        }
        //顶级类别中符合条件的类别集合
        List<RsResourceCategory> mRsCategoriesSome = new ArrayList<>();
        //顶级类别中不符合条件的类别集合
        List<RsResourceCategory> mRsCategoriesOthers = new ArrayList<>();
        if (categoryList == null || categoryList.size() == 0){
            envelop.setStatus(-1);
            envelop.setMessage("没有匹配条件的资源类别!");
            return envelop;
        }
        List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
        if(StringUtils.isEmpty(name)){
            treeList = getRsCategoryTreeModelChild(categoryList);
            envelop.setDetailModelList(treeList);
            return envelop;
        }
        for(RsResourceCategory mRsCategory : categoryList){
            if(mRsCategory.getName().contains(name)){
                mRsCategoriesSome.add(mRsCategory);
                continue;
            }
            mRsCategoriesOthers.add(mRsCategory);
        }
        if (mRsCategoriesSome.size() != 0){
            treeList.addAll(getRsCategoryTreeModelChild(mRsCategoriesSome));
        }
        treeList .addAll(getRsCategoryTreeModelByName(mRsCategoriesOthers, name));
        envelop.setDetailModelList(treeList);
        return envelop;
    }
    /**
     *
     * 根据父级信息获取全部的子级信息(树形model)
     * @param info 父级信息
     * @return 全部子级信息
     */
    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelChild(List<RsResourceCategory> info) {
        List<RsCategoryTypeTreeModel> treeInfo = new ArrayList<>();
        for (int i = 0; i < info.size(); i++) {
            RsResourceCategory typeInfo = info.get(i);
            RsCategoryTypeTreeModel tree = convertToModel(typeInfo, RsCategoryTypeTreeModel.class);
            List<RsResourceCategory> categoryListChild = rsCategoryService.getRsCategoryByPid(typeInfo.getId());
            List<RsCategoryTypeTreeModel> listChildTree = getRsCategoryTreeModelChild(categoryListChild);
            tree.setChildren(listChildTree);
            treeInfo.add(tree);
        }
        return treeInfo;
    }
    /**
     * 递归不满足的父级类别集合的子集中满足条件TreeModel集合的方法
     * @param mRsCategories 不符合的父级类别的集合
     * @param name
     * @return
     */
    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelByName(List<RsResourceCategory> mRsCategories, String name) throws ParseException {
        //结构:treeList 包含treeModel,treeModel包含listOfParent
        List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
        for(RsResourceCategory mRsCategory:mRsCategories){
            List<RsCategoryTypeTreeModel> childList = new ArrayList<>();
            RsCategoryTypeTreeModel treeModel = convertToModel(mRsCategory,RsCategoryTypeTreeModel.class);
            String pid = mRsCategory.getId();
            //获取所有下一级cda类别
            List<RsResourceCategory> listAll = rsCategoryService.getRsCategoryByPid(pid);
            if(listAll.size() == 0){
                continue;
            }
            //获取所有下一级符合要求的资源类别
            String filters ="pid="+pid+";name?"+name;
            //modify by cws
            List<RsResourceCategory> listSome = rsCategoryService.search(filters);
            //List<MRsCategory> listSome = (List<MRsCategory>)responseEntity.getBody();
            if(listSome.size()!=0){
                childList.addAll(getRsCategoryTreeModelChild(listSome));
            }
            //取剩下不符合要求的进行递归
            listAll.removeAll(listSome);
            if(listAll.size() != 0){
                childList.addAll(getRsCategoryTreeModelByName(listAll, name));
            }
            if(childList.size() != 0){
                treeModel.setChildren(childList);
                treeList.add(treeModel);
            }
        }
        return treeList;
    }
    /**
     * 新增或者更新
     * @param dataJson
     * @return
     */
    @RequestMapping("/saveCateType")
    public Envelop SaveCdaType(String dataJson) {
        Map<String,Object> params = new HashMap<>();
        String url = "/resources/category/update";
        try {
            RsResourceCategory rsCategory = toEntity(dataJson, RsResourceCategory.class);
            if(StringUtils.isEmpty(rsCategory.getName())){
                return failed("类别名称不能为空!");
            }
            params.put("resourceCategory",dataJson);
            if(StringUtils.isNotBlank(rsCategory.getId())) {
                rsCategoryService.createOrUpdRsCategory(rsCategory);
            }else{
                rsCategory.setId(getObjectId(BizObject.ResourceCategory));
                rsCategoryService.createOrUpdRsCategory(rsCategory);
            }
            return ObjEnvelop.getSuccess("新增成功",rsCategory);
        } catch (Exception ex){
            ex.printStackTrace();
            return failed("操作失败");
        }
    }
    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping("/delteCateTypeInfo")
    public Envelop delteCdaTypeInfo(String id) {
        Envelop result = new Envelop();
        if (StringUtils.isEmpty(id)){
            return failed("请选择要删除的数据");
        }
        try{
            String url = "/resources/category/" + id;
            rsCategoryService.deleteRsCategory(id);
            return success("删除成功");
        }catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 删除辅助接口,如有下级分类,前端给出不可删除警告
     * @param id
     * @return
     */
    @RequestMapping("/getCateTypeByPid")
    public Envelop getCateTypeByPid(String id) {
        Envelop envelop = new Envelop();
        ObjectMapper mapper = new ObjectMapper();
        Map<String,Object> params = new HashMap<>();
        String url = "/resources/categories/pid/";
        try {
            List<RsResourceCategory> categoryList = rsCategoryService.getRsCategoryByPid(id);
            return ListEnvelop.getSuccess("查询成功",categoryList);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 根据ID查找分类信息
     * @param strIds
     * @return
     */
    @RequestMapping("/getCateTypeById")
    public Envelop getCdaTypeById(String strIds) {
        Envelop envelop = new Envelop();
        String url = "/resources/category/" + strIds;
        try{
            RsResourceCategory rsResourceCategory = rsCategoryService.getRsCategoryById(strIds);
            return ObjEnvelop.getSuccess("查询成功",rsResourceCategory);
        } catch (Exception e){
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 获取可以作为父类别的cate类别列表
     * @param strId
     * @return
     */
    @RequestMapping("/getCateTypeExcludeSelfAndChildren")
    public Envelop getCdaTypeExcludeSelfAndChildren(String strId) {
        //页面新增修改访问的是同个接口
        Envelop envelop = new Envelop();
        try {
            String urlGetAll =  "/resources/categories/all";
            Map<String,Object> params = new HashMap<>();
            List<RsResourceCategory> resources;
            if(!StringUtils.isEmpty(strId)){
                List<RsResourceCategory> parentTypes = rsCategoryService.getRsCategoryByPid(strId);
                String childrenIds = getChildIncludeSelfByParentsAndChildrenIds(parentTypes,strId+",");   //递归获取
                resources = rsCategoryService.getCateTypeExcludeSelfAndChildren(childrenIds);
            }else {
                resources = rsCategoryService.search("");
            }
            return ListEnvelop.getSuccess("查询成功",resources);
        } catch (Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    private String getChildIncludeSelfByParentsAndChildrenIds(List<RsResourceCategory> parentTypes,String childrenIds) {
        for (int i = 0; i < parentTypes.size(); i++) {
            RsResourceCategory typeInfo = parentTypes.get(i);
            childrenIds+=typeInfo.getId()+",";
            List<RsResourceCategory> listChild = rsCategoryService.getRsCategoryByPid(typeInfo.getId());
            if(listChild.size()>0){
                childrenIds = getChildIncludeSelfByParentsAndChildrenIds(listChild,childrenIds);
            }
        }
        return childrenIds;
    }
}

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

@ -0,0 +1,171 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.yihu.ehr.constants.ServiceApi;
//
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * Created by linz on 2016/5/23.
// */
//
//@RestController
//@RequestMapping("/schemeAdapt")
//public class SchemeAdaptController extends EnvelopRestEndpoint {
//
//
//    @Value("${service-gateway.username}")
//    private String username;
//    @Value("${service-gateway.password}")
//    private String password;
//    @Value("${service-gateway.url}")
//    private String comUrl;
//
//    @Autowired
//    private ObjectMapper objectMapper;
//
//    public static final String SCHEME_PLATFORM="1";//平台类型
//    public static final String SCHEME_TP="2";//第三方
//
//
//    @RequestMapping("/initial")
//    public String resourceSchemeInitial(Model model){
//        model.addAttribute("contentPage","/resource/adaptview/schemeAdapt");
//        return "pageView";
//    }
//
//    @RequestMapping("/list")
//    @ResponseBody
//    public Object searchAdaptSchemes(String searchNm, String type, int page, int rows){
//        Map<String, Object> params = new HashMap<String, Object>();
//        StringBuffer stringBuffer = new StringBuffer();
//        if (!StringUtils.isEmpty(searchNm)) {
//            stringBuffer.append("code?").append(searchNm).append(" g1;").append("name?").append(searchNm).append(" g1;");
//        }
//        if (!StringUtils.isEmpty(type)) {
//            stringBuffer.append("type=").append(type).append(";");
//        }
//        params.put("filters", "");
//        params.put("page", page);
//        params.put("size", rows);
//        String filters = stringBuffer.toString();
//        if(filters.lastIndexOf(";")>0){
//            filters = filters.substring(0,filters.lastIndexOf(";"));
//        }
//        if (!StringUtils.isEmpty(filters)) {
//            params.put("filters", filters);
//        }
//        String url = ServiceApi.Adaptions.Schemes;
//        String result="";
//        try {
//            result = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return result;
//        } catch (Exception e){
//            e.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param mode
//     * @return
//     */
//    @RequestMapping("gotoModify")
//    public Object adapterSchemeTemplate(EnvelopRestEndpointString id,String mode) {
//        String resultStr = "";
//        Envelop result = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        params.put("id",id);
//        try {
//            if(mode.equals("view") || mode.equals("modify")) {
//                String url = "/adaptions/schemas/"+id;
//                resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//                model.addAttribute("rs", "success");
//            }
//            model.addAttribute("info", StringUtils.isEmpty(resultStr)?toJson(result):resultStr);
//            model.addAttribute("mode",mode);
//            model.addAttribute("contentPage","/resource/adaptview/schemeAdaptDialog");
//            return "emptyView";
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param dataJson
//     * @return
//     */
//    @RequestMapping("save")
//    @ResponseBody
//    public Object updateSchemeAdpat(Model model,String dataJson) {
//        Envelop result = new Envelop();
//        String resultStr = "";
//        Map<String, Object> params = new HashMap<>();
//        try{
//        MRsAdapterSchema mRsAdapterSchema = objectMapper.readValue(dataJson,MRsAdapterSchema.class);
//        if (StringUtils.isEmpty(mRsAdapterSchema.getType())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("方案类别不能为空!");
//            return result;
//        }
//        if (StringUtils.isEmpty(mRsAdapterSchema.getName())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("方案名称不能为空!");
//            return result;
//        }
//        if (StringUtils.isEmpty(mRsAdapterSchema.getCode())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("方案编码不能为空!");
//            return result;
//        }
//        if (StringUtils.isEmpty(mRsAdapterSchema.getAdapterVersion())&&this.SCHEME_PLATFORM.equals(mRsAdapterSchema.getType())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("版本号不能为空!");
//            return result;
//        }
//        if(StringUtils.isEmpty(mRsAdapterSchema.getAdapterVersion())&&this.SCHEME_TP.equals(mRsAdapterSchema.getType())){
//            result.setSuccessFlg(false);
//            result.setErrorMsg("标准名称不能为空!");
//            return result;
//        }
//        params.put("adapterSchema",toJson(mRsAdapterSchema));
//        String url = ServiceApi.Adaptions.Schemes;
//        if(StringUtils.isNotBlank(mRsAdapterSchema.getId())){
//            resultStr = HttpClientUtil.doPut(comUrl + url, params, username, password);
//        }else{
//            resultStr = HttpClientUtil.doPost(comUrl + url, params, username, password);
//        }
//        return resultStr;
//        } catch(Exception ex){
//            ex.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//
//    @RequestMapping("delete")
//    @ResponseBody
//    public Object deleteScheme(String schemeId) {
//        Envelop result = new Envelop();
//        Map<String, Object> params = new HashMap<String, Object>();
//        String url = "/adaptions/schemas/"+schemeId;
//        try{
//           String resultStr =  HttpClientUtil.doDelete(comUrl+url,params,username,password);
//           return resultStr;
//        } catch(Exception ex){
//            ex.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//}

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

@ -0,0 +1,107 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.yihu.ehr.constants.ServiceApi;
//
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.common.LogService;
//import com.yihu.jw.util.http.HttpClientUtil;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * 资源适配管理方案适配管理
// * Created by linz on 2015/11/1.
// */
//
//@RequestMapping("/schemeAdaptDataSet")
//@RestController
//public class SchemeAdaptDataSetController extends EnvelopRestEndpoint {
//
//    @RequestMapping("/initial")
//    public String gotoList(Model model,String dataModel,String version){
//        model.addAttribute("dataModel",dataModel);
//        model.addAttribute("version",version);
//        String url = "/adaptions/schemas/"+dataModel;
//        String resultStr = "";
//        Envelop result = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        try {
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        }catch (Exception e){
//            LogService.getLogger(SchemeAdaptDataSetController.class).error(e.getMessage());
//            model.addAttribute("rs", "error");
//        }
//        model.addAttribute("adapterScheme",resultStr);
//        model.addAttribute("contentPage","/resource/adaptview/dataSet/grid");
//        return "pageView";
//    }
//
//    @RequestMapping("/metaDataList")
//    @ResponseBody
//    public Object searchmetaData(String adapterSchemeId, String code, int page, int rows) {
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<String, Object>();
//        StringBuffer stringBuffer = new StringBuffer();
//        if(StringUtils.isNotBlank(adapterSchemeId)){
//            stringBuffer.append("schemeId=").append(adapterSchemeId).append(";");
//        }else{
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("请选择资源适配方案");
//        }
//        if(StringUtils.isNotBlank(code)){
//            stringBuffer.append("srcDatasetCode=").append(code).append(";");
//        }
//        params.put("filters", "");
//        params.put("page", page);
//        params.put("size", rows);
//        String filters = stringBuffer.toString();
//        if(filters.lastIndexOf(";")>0){
//            filters = filters.substring(0,filters.lastIndexOf(";"));
//        }
//        if (!StringUtils.isEmpty(filters)) {
//            params.put("filters", filters);
//        }
//        try {
//            String resultStr ="";
//            String url = ServiceApi.Adaptions.SchemaMetadataList;
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return resultStr;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param dataJson
//     * @return
//     */
//    @RequestMapping("save")
//    @ResponseBody
//    public Object updatesSchemeAdpatDataset(Model model,String dataJson) {
//        Envelop result = new Envelop();
//        String resultStr = "";
//        Map<String, Object> params = new HashMap<>();
//        try{
//            params.put("adapterMetadata",dataJson);
//            String url = ServiceApi.Adaptions.SchemaMetadataList;
//            resultStr = HttpClientUtil.doPut(comUrl + url, params, username, password);
//            return resultStr;
//        }catch(Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//      }
//    }

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

@ -0,0 +1,85 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.http.HttpClientUtil;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * 资源适配管理方案适配管理
// * Created by linz on 2015/11/1.
// */
//
//@RequestMapping("/schemeAdaptDict")
//@RestController
//public class SchemeAdaptDictController extends EnvelopRestEndpoint {
//
//    @RequestMapping("/dictlist")
//    @ResponseBody
//    public Object searchmetaData(String adapterSchemeId, String code, int page, int rows) {
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<String, Object>();
//        StringBuffer stringBuffer = new StringBuffer();
//        if(StringUtils.isNotBlank(adapterSchemeId)){
//            stringBuffer.append("schemeId=").append(adapterSchemeId).append(";");
//        }else{
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("请选择资源适配方案");
//            return envelop;
//        }
//        if(StringUtils.isNotBlank(code)){
//            stringBuffer.append("srcDictCode=").append(code).append(" g1").append(";");
//        }
//        params.put("filters", "");
//        params.put("page", page);
//        params.put("size", rows);
//        String filters = stringBuffer.toString();
//        if(filters.lastIndexOf(";")>0){
//            filters = filters.substring(0,filters.lastIndexOf(";"));
//        }
//        if (!StringUtils.isEmpty(filters)) {
//            params.put("filters", filters);
//        }
//        try {
//            String resultStr ="";
//            String url = "/adaptions/adapter/dictionaries";
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return resultStr;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param dataJson
//     * @return
//     */
//    @RequestMapping("/save")
//    @ResponseBody
//    public Object updatesSchemeAdpatDict(Model model,String dataJson) {
//        Envelop result = new Envelop();
//        String resultStr = "";
//        Map<String, Object> params = new HashMap<>();
//        try{
//            params.put("jsonData",dataJson);
//            String url = "/adaptions/adapter/dictionaries";
//            resultStr = HttpClientUtil.doPut(comUrl + url, params, username, password);
//            return resultStr;
//        } catch(Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//}

+ 412 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/service/ResourceBrowseControllerService.java

@ -0,0 +1,412 @@
package com.yihu.jw.basic.agadmin.service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.model.RsCategoryTypeTreeModel;
import com.yihu.jw.basic.resource.model.RsResourcesModel;
import com.yihu.jw.basic.resource.service.ResourceBrowseService;
import com.yihu.jw.basic.resource.service.RsResourceCategoryService;
import com.yihu.jw.basic.resource.service.RsResourceService;
import com.yihu.jw.entity.ehr.resource.RsResource;
import com.yihu.jw.entity.ehr.resource.RsResourceCategory;
import com.yihu.jw.restmodel.ehr.resource.MRsCategory;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.ehr.resource.MRsResources;
import com.yihu.jw.restmodel.ehr.tj.MTjQuotaModel;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.*;
/**
 * Created by wq on 2016/5/30.
 */
@Service
public class ResourceBrowseControllerService {
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    private RsResourceCategoryService rsCategoryService;
    @Autowired
    private ResourceBrowseService resourceBrowseService;
//    @ApiOperation("获取档案资源分类")
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseCategories, method = RequestMethod.GET)
    public Envelop getCategories(String id){
        List<RsCategoryTypeTreeModel> rsCategoryTypeTreeModelList = new ArrayList<>();
        try {
            //查询资源分类
            List<RsResourceCategory> resources = rsCategoryService.search("");
            for (RsResourceCategory mRsCategory:resources){
                RsCategoryTypeTreeModel rsCategoryModel = new RsCategoryTypeTreeModel();
                rsCategoryModel.setId(mRsCategory.getId());
                rsCategoryModel.setPid(mRsCategory.getPid());
                rsCategoryModel.setName(mRsCategory.getName());
                rsCategoryTypeTreeModelList.add(rsCategoryModel);
                List<RsResource> resourcesModelList = rsResourceService.search(null,"categoryId=" + mRsCategory.getId(),null,1,999);
                if (resourcesModelList.size() > 0) {
                    for (RsResource resourcesModel : resourcesModelList) {
                        RsCategoryTypeTreeModel rsCategoryTypeModel = new RsCategoryTypeTreeModel();
                        rsCategoryTypeModel.setId(resourcesModel.getId());
                        rsCategoryTypeModel.setPid(mRsCategory.getId());
                        rsCategoryTypeModel.setResourceIds(resourcesModel.getId());
                        rsCategoryTypeModel.setName(resourcesModel.getName());
                        rsCategoryTypeModel.setResourceCode(resourcesModel.getCode());
                        rsCategoryTypeTreeModelList.add(rsCategoryTypeModel);
                    }
                }
            }
            return ListEnvelop.getSuccess("",rsCategoryTypeTreeModelList);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("获取档案资源分类失败");
        }
    }
//    @ApiOperation("档案资源数据元结构")
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseResourceMetadata, method = RequestMethod.GET)
    public List<MRsColumnsModel> getResourceMetadata(String resourcesCode,String roleId) throws Exception {
        List<MRsColumnsModel> rsBrowseModelList = resourceBrowseService.getResourceMetadata(resourcesCode, roleId);
        return rsBrowseModelList;
    }
//    @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 {
//        RsResource rsResource = rsResourceService.getResourceByCode(resourcesCode);
//        if (!rsResource.getRsInterface().equals("getQuotaData")){//接口 来自接口统计
//            return resourceBrowseClient.getResourceData(resourcesCode, roleId, orgCode, areaCode, queryCondition, page, size);
//        } else {
//            String quotaCodeStr = "";
//            List<ResourceQuotaModel> list = resourceQuotaClient.getByResourceId(rsResourcesModel.getId());
//            if (list != null && list.size() > 0) {
//                for (ResourceQuotaModel resourceQuotaModel : list) {
//                    quotaCodeStr = quotaCodeStr + resourceQuotaModel.getQuotaCode() + ",";
//                }
//            }
//            List<Map<String, Object>> resultList = rsResourceStatisticsClient.getQuotaReportTwoDimensionalTable(quotaCodeStr, null, rsResourcesModel.getDimension(), top);
//            envelop.setDetailModelList(resultList);
//            envelop.setSuccessFlg(true);
//            return  envelop;
//        }
//    }
//    @ApiOperation("档案资源浏览细表数据")
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseResourceSubData, method = RequestMethod.GET)
//    public Envelop findSubDateByRowKey(
//            @ApiParam(name = "rowKey", value = "主表rowKey", required = true)
//            @RequestParam(value = "rowKey") String rowKey,
//            @ApiParam(name = "version", value = "版本", required = true)
//            @RequestParam(value = "version") String version){
//        return  resourceBrowseClient.findSubDateByRowKey(rowKey, version);
//    }
//    @ApiOperation("指标视图查询列表浏览")
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseQuotaResourceData, method = RequestMethod.GET)
//    public Envelop getQuotaResourceData(
//            @ApiParam("资源Id")
//            @RequestParam String resourcesId,
//            @ApiParam("机构代码(预留参数)")
//            @RequestParam(required = false) String orgCode,
//            @ApiParam("查询条件")
//            @RequestParam(required = false) String queryCondition,
//            @ApiParam(name = "userOrgList" ,value = "用户拥有机构权限" )
//            @RequestParam(value = "userOrgList" , required = false) List<String> userOrgList) throws Exception {
//        Envelop envelop = new Envelop();
//        String [] quotaCodeArr = null;
//        //获取资源关联指标
//        List<ResourceQuotaModel> rqmList = resourceQuotaClient.getByResourceId(resourcesId);
//        if (rqmList == null || rqmList.size() <= 0) {
//            envelop.setErrorMsg("关联指标为空");
//            return envelop;
//        }
//        //获取资源默认查询条件
//        String query = rsResourceDefaultQueryClient.getByResourceId(resourcesId);
//        //拼接指标code字符串作为维度交集查询参数
//        String quotaCodes = "";
//        quotaCodeArr = new String [rqmList.size()];
//        List<Map<String, String>> objList = new ArrayList<Map<String, String>>();
//        for (int i = 0; i< rqmList.size(); i ++) {
//            ResourceQuotaModel resourceQuotaModel = rqmList.get(i);
//            MTjQuotaModel tjQuotaModel = tjQuotaClient.getById((long) resourceQuotaModel.getQuotaId());
//            quotaCodeArr[i] = tjQuotaModel.getCode();
//            quotaCodes += tjQuotaModel.getCode() + ",";
//        }
//        //拼接交集维度字符串作为查询参数
//        String dimension = "";
//        if (StringUtils.isEmpty(quotaCodes)) {
//            envelop.setErrorMsg("指标编码有误");
//            return envelop;
//        }
//        //查询多个指标交集维度
//        List<Map<String, String>> qsdList = tjQuotaSynthesizeQueryClient.getTjQuotaSynthesiseDimension(quotaCodes.substring(0, quotaCodes.length() - 1));
//        if (qsdList == null || qsdList.size() <= 0) {
//            envelop.setSuccessFlg(true);
//            return envelop;
//        }
//        for (Map<String, String> temp : qsdList) {
//            for (String codeStr : temp.keySet()) {
//                if (quotaCodes.contains(codeStr)) {
//                    //添加键值对应列表
//                    Map<String, String> objMap = new HashMap<String, String>();
//                    objMap.put("key", temp.get(codeStr));
//                    objMap.put("name", temp.get("name"));
//                    objList.add(objMap);
//                    //结果总量参数
//                    dimension += temp.get(codeStr) + ";";
//                    break;
//                }
//            }
//        }
//        for (int i = 0; i< rqmList.size(); i ++) {
//            ResourceQuotaModel resourceQuotaModel = rqmList.get(i);
//            MTjQuotaModel tjQuotaModel = tjQuotaClient.getById((long) resourceQuotaModel.getQuotaId());
//            Map<String, String> objMap = new HashMap<String, String>();
//            objMap.put("key", tjQuotaModel.getCode());
//            objMap.put("name", tjQuotaModel.getName());
//            objList.add(objMap);
//        }
//        //依次获取指标统计不同维度结果总量
//        List<Envelop> envelopList = new ArrayList<Envelop>();
//        for (ResourceQuotaModel resourceQuotaModel : rqmList) {
//            Envelop envelop1;
//            //-----------------用户数据权限 start
//            String org = "";
//            if (userOrgList != null ){
//                if(!(userOrgList.size()==1 && userOrgList.get(0).equals("null")) ) {
//                    org = StringUtils.strip(String.join(",", userOrgList), "[]");
//                }
//            }
//            //-----------------用户数据权限 end
//            //判断是否启用默认查询条件
//            Map<String, Object> params  = new HashMap<>();
//            if (queryCondition == null || queryCondition.equals("{}")) {
//                boolean orgFlag = false;
//                for(Map<String, String> map:objList){
//                    for(String key :map.keySet()){
//                        if(map.get(key).equals("org")){
//                            orgFlag = true;
//                        }
//                    }
//                }
//                if(org.length()>0 && orgFlag){
//                    if( !StringUtils.isEmpty(query)){
//                        params  = objectMapper.readValue(query, new TypeReference<Map>() {});
//                    }
//                    params.put("org",org);
//                    query = objectMapper.writeValueAsString(params);
//                }
//                //获取指标统计不同维度结果数据
//                envelop1 = tjQuotaJobClient.getQuotaTotalCount(resourceQuotaModel.getQuotaId(), query, dimension.substring(0, dimension.length() - 1));
//                envelopList.add(envelop1);
//            } else {
//                if(org.length()>0){
//                    params  = objectMapper.readValue(queryCondition, new TypeReference<Map>() {});
//                    params.put("org",org);
//                    queryCondition = objectMapper.writeValueAsString(params);
//                }
//                envelop1 = tjQuotaJobClient.getQuotaTotalCount(resourceQuotaModel.getQuotaId(), queryCondition, dimension.substring(0, dimension.length() - 1));
//                envelopList.add(envelop1);
//            }
//        }
//        List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
//        //遍历数据集,拼装结果集
//        for (int i = 0; i < envelopList.size(); i ++ ) {
//            Envelop envelop1 = envelopList.get(i);
//            if (envelop1.getDetailModelList() != null) {
//                //遍历当前数据
//                for (Map<String, Object> tempMap1 : (List<Map<String, Object>>) envelop1.getDetailModelList()) {
//                    //判断是否已记录数据
//                    boolean isRecode = false;
//                    for (Map<String, Object> resultMap : resultList) {
//                        if (Arrays.equals(((List<String>) tempMap1.get("cloumns")).toArray(), ((List<String>) resultMap.get("cloumns")).toArray())) {
//                            isRecode = true;
//                        }
//                    }
//                    //未记录的数据
//                    if (!isRecode) {
//                        Map<String, Object> newMap = new HashMap<String, Object>();
//                        //初始化基本列名
//                        newMap.put("cloumns", tempMap1.get("cloumns"));
//                        //初始化为空数据
//                        for (int p = 0; p < i; p++) {
//                            newMap.put(quotaCodeArr[p], 0);
//                        }
//                        //当数据为最后一个数据集中的一个时
//                        if ((envelopList.size() - 1) == i) {
//                            newMap.put(quotaCodeArr[i], tempMap1.get("value"));
//                        } else {
//                            //与其他数据集进行对比
//                            for (int j = i + 1; j < envelopList.size(); j++) {
//                                //判断是否匹配
//                                boolean isMatch = false;
//                                Envelop envelop2 = envelopList.get(j);
//                                if (null != envelop2.getDetailModelList() && envelop2.getDetailModelList().size() > 0) {
//                                    for (Map<String, Object> tempMap2 : (List<Map<String, Object>>) envelop2.getDetailModelList()) {
//                                        if (Arrays.equals(((List<String>) tempMap1.get("cloumns")).toArray(), ((List<String>) tempMap2.get("cloumns")).toArray())) {
//                                            newMap.put(quotaCodeArr[i], tempMap1.get("value"));
//                                            newMap.put(quotaCodeArr[j], tempMap2.get("value"));
//                                            isMatch = true;
//                                        }
//                                    }
//                                }
//                                //未匹配到数据
//                                if (!isMatch) {
//                                    newMap.put(quotaCodeArr[i], tempMap1.get("value"));
//                                    newMap.put(quotaCodeArr[j], 0);
//                                }
//                            }
//                        }
//                        resultList.add(newMap);
//                    }
//                }
//            }
//
//        }
//        List<Map<String, Object>> finalList = new ArrayList<Map<String, Object>>();
//        String [] dimensionArr = dimension.split(";");
//        for (Map<String, Object> tempMap : resultList) {
//            List<String> colList = (List<String>)tempMap.get("cloumns");
//            Map<String, Object> finalMap = new HashMap<String, Object>();
//            for (int i = 0; i < colList.size(); i++) {
//                finalMap.put(dimensionArr[i], colList.get(i));
//            }
//            for (String key : tempMap.keySet()) {
//                if (!key.equals("cloumns")) {
//                    finalMap.put(key, tempMap.get(key));
//                }
//            }
//            finalList.add(finalMap);
//        }
//        envelop.setSuccessFlg(true);
//        envelop.setDetailModelList(finalList);
//        envelop.setObj(objList);
//        if (resultList != null) {
//            envelop.setTotalCount(resultList.size());
//        }
//        return envelop;
//    }
//
//    @ApiOperation("指标资源浏览数据检索条件获取")
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseQuotaResourceParam, method = RequestMethod.GET)
//    public Envelop getStatisticsParam(
//            @ApiParam("资源Id")
//            @RequestParam String resourcesId){
//        Envelop envelop = new Envelop();
//        String [] quotaCodeArr = null;
//        //获取资源关联指标
//        List<ResourceQuotaModel> rqmList = resourceQuotaClient.getByResourceId(resourcesId);
//        if(rqmList == null || rqmList.size() <= 0) {
//            envelop.setErrorMsg("关联指标为空");
//            return envelop;
//        }
//        //拼接指标code字符串作为维度交集查询参数
//        String quotaCodes = "";
//        quotaCodeArr = new String [rqmList.size()];
//        List<Map<String, String>> objList = new ArrayList<Map<String, String>>();
//        for (int i = 0; i< rqmList.size(); i ++) {
//            ResourceQuotaModel resourceQuotaModel = rqmList.get(i);
//            MTjQuotaModel tjQuotaModel = tjQuotaClient.getById((long) resourceQuotaModel.getQuotaId());
//            quotaCodeArr[i] = tjQuotaModel.getCode();
//            quotaCodes += tjQuotaModel.getCode() + ",";
//        }
//        //拼接交集维度字符串作为查询参数
//        String dimensions = "";
//        if(StringUtils.isEmpty(quotaCodes)) {
//            envelop.setErrorMsg("指标编码有误");
//            return envelop;
//        }
//        List<Map<String, String>> qsdList = tjQuotaSynthesizeQueryClient.getTjQuotaSynthesiseDimension(quotaCodes.substring(0, quotaCodes.length() - 1));
//        if(qsdList == null || qsdList.size() <= 0) {
//            envelop.setSuccessFlg(true);
//            return envelop;
//        }
//        for(Map<String, String> temp : qsdList) {
//            for(String codeStr : temp.keySet()){
//                if(quotaCodes.contains(codeStr)) {
//                    //交集维度参数
//                    dimensions += temp.get(codeStr) + ",";
//                    break;
//                }
//            }
//        }
//        Map<String, Map<String, Object>> dataMap = tjQuotaSynthesizeQueryClient.getTjQuotaSynthesiseDimensionKeyVal(quotaCodeArr[0], dimensions);
//        if (dataMap != null) {
//            envelop.setSuccessFlg(true);
//            envelop.setObj(dataMap);
//        }
//        return envelop;
//    }
//
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseTree, method = RequestMethod.GET)
//    @ApiOperation(value = "获取视图类别-数据集列表树")
//    public Envelop getResourceBrowseTree() {
//        Envelop envelop = new Envelop();
//        List<MRsResources> rsResources = new ArrayList<>();
//        List<RsCategoryTypeTreeModel> rsCategoryTypeTreeModelList=new ArrayList<>();
//        Map<String,String> map=new HashedMap();
//        //限定五大库
//        map.put("0dae002159535497b3865e129433e933","0dae002159535497b3865e129433e933");
//        map.put("0dae0021595354a8b3865e129433e934","0dae0021595354a8b3865e129433e934");
//        map.put("0dae0021595354c4b3865e129433e935","0dae0021595354c4b3865e129433e935");
//        map.put("0dae0021595354cfb3865e129433e936","0dae0021595354cfb3865e129433e936");
//        map.put("0dae0021595354d6b3865e129433e937","0dae0021595354d6b3865e129433e937");
//        //查询资源分类
//        List<MRsCategory> resources = resourcesCategoryClient.getAllCategories("");
//        RsCategoryTypeTreeModel rsCategoryModel;
//        for (MRsCategory mRsCategory:resources){
//            if(null!=map.get(mRsCategory.getId().toString())){
//                rsCategoryModel = new RsCategoryTypeTreeModel();
//                rsCategoryModel.setId(mRsCategory.getId());
//                rsCategoryModel.setPid(mRsCategory.getPid());
//                rsCategoryModel.setName(mRsCategory.getName());
//                //查询资源-数据集
//                ResponseEntity<List<MRsResources>> categoryResponseEntity = resourcesClient.queryResources("", "categoryId=" + mRsCategory.getId(), "", 1, 999, null, null);// TODO: 2016/5/30 测试数据15(无不分页查询)
//                rsResources = categoryResponseEntity.getBody();
//                if (rsResources.size() > 0) {
//                    List<RsResourcesModel> resourcesModelList = (List<RsResourcesModel>) convertToModels(rsResources, new ArrayList<RsResourcesModel>(rsResources.size()), RsResourcesModel.class, null);
//                    rsCategoryModel.setRsResourceslist(resourcesModelList);
//                }
//                rsCategoryTypeTreeModelList.add(rsCategoryModel);
//            }
//        }
//        //平台应用-角色组对象模型列表
//        envelop.setSuccessFlg(true);
//        envelop.setDetailModelList(rsCategoryTypeTreeModelList);
//        return envelop;
//    }
//
//    @RequestMapping(value = ServiceApi.Resources.ResourceBrowseGetRsByCategoryId, method = RequestMethod.GET)
//    @ApiOperation(value = "根据视图分类的CategoryId获取数据集")
//    public Envelop getResourceByCategoryId (
//            @ApiParam("categoryId")
//            @RequestParam(value = "categoryId", required = true) String categoryId) {
//        //查询资源-数据集
//        String filters="";
//        if(null!=categoryId&&!"".equals(categoryId)){
//            filters="categoryId=" + categoryId;
//        }
//
//        ResponseEntity<List<MRsResources>> categoryResponseEntity = resourcesClient.queryResources("", filters, "", 1, 999, null, null);
//        List<MRsResources>  rsResources = categoryResponseEntity.getBody();
//        Integer totalCount = getTotalCount(categoryResponseEntity);
//        return getResult(rsResources, totalCount, 1, 999);
//    }
}

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDataSaveEndPoint.java

@ -7,8 +7,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDataSourceEndPoint.java

@ -7,8 +7,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDimensionMainEndPoint.java

@ -7,8 +7,8 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjDimensionSlaveEndPoint.java

@ -7,8 +7,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaCategoryEndPoint.java

@ -7,9 +7,9 @@ import com.yihu.jw.restmodel.ehr.tj.MQuotaCategory;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.svrBasic.ApiVersion;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.jw.rm.svrBasic.ErrorCode;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaChartEndPoint.java

@ -8,8 +8,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDataSaveEndPoint.java

@ -7,8 +7,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDataSourceEndPoint.java

@ -7,8 +7,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDimensionMainEndPoint.java

@ -8,8 +8,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaDimensionSlaveEndPoint.java

@ -8,8 +8,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaEndPoint.java

@ -13,8 +13,8 @@ import com.yihu.jw.restmodel.web.Envelop;
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.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaLogEndPoint.java

@ -12,8 +12,8 @@ import com.yihu.jw.entity.ehr.quota.TjQuotaLog;
import com.yihu.jw.restmodel.ehr.tj.MTjQuotaLog;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.util.date.DateTimeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaSynthesizeQueryEndPoint.java

@ -11,8 +11,8 @@ import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionSlave;
import com.yihu.jw.restmodel.ehr.tj.DictModel;
import com.yihu.jw.restmodel.ehr.tj.SaveModel;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/TjQuotaWarnEndPoint.java

@ -7,8 +7,8 @@ import com.yihu.jw.entity.ehr.quota.TjQuota;
import com.yihu.jw.entity.ehr.quota.TjQuotaWarn;
import com.yihu.jw.restmodel.ehr.tj.MTjQuotaWarn;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.svrBasic.ApiVersion;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

+ 52 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterMetaDataKeySchema.java

@ -0,0 +1,52 @@
package com.yihu.jw.basic.redis.schema;
import com.yihu.jw.redis.schema.KeySchema;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
/**
 *  Created by hzp on 2017.04.25
 */
@Component
public class AdapterMetaDataKeySchema extends KeySchema {
    private String AdapterMetaDataCode = "adapter_metadata_code";
    private String AdapterMetaDataName = "adapter_metadata_name";
    private String StdMetaDataName = "std_metadata_name";
    public void delete(String tableName) {
        redisClient.delete(makeKey(tableName , "*", "*"));
    }
    public void setAdapterMetaDataCode(String tableName, String stddataSetCode, String stdMetadataCode,String value) {
        if (StringUtils.isNotEmpty(value)) {
            redisClient.set(makeKey(tableName, stddataSetCode + "." + stdMetadataCode, AdapterMetaDataCode), value);
        }
    }
    public String getAdapterMetaDataCode(String tableName, String stdDatasetCode, String stdMetadataCode) {
        return redisClient.get(makeKey(tableName, stdDatasetCode + "." + stdMetadataCode, AdapterMetaDataCode));
    }
    public void setAdapterMetaDataName(String tableName, String stddataSetCode, String stdMetadataCode, String value) {
        if (StringUtils.isNotEmpty(value)) {
            redisClient.set(makeKey(tableName, stddataSetCode + "." + stdMetadataCode, AdapterMetaDataName), value);
        }
    }
    public String getAdapterMetaDataName(String tableName, String stdDatasetCode, String stdMetadataCode) {
        return redisClient.get(makeKey(tableName, stdDatasetCode + "." + stdMetadataCode, AdapterMetaDataName));
    }
    public void setStdMetaDataName(String tableName, String stddataSetCode, String stdMetadataCode, String value) {
        if (StringUtils.isNotEmpty(value)) {
            redisClient.set(makeKey(tableName, stddataSetCode + "." + stdMetadataCode, StdMetaDataName), value);
        }
    }
    public String getStdMetaDataName(String tableName, String stdDatasetCode, String stdMetadataCode) {
        return redisClient.get(makeKey(tableName, stdDatasetCode + "." + stdMetadataCode, StdMetaDataName));
    }
}

+ 0 - 175
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/HbaseDataEndPoint.java

@ -1,175 +0,0 @@
//package com.yihu.jw.basic.resource.controller;
//
//import com.yihu.ehr.constants.ApiVersion;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.ehr.hbase.HBaseAdmin;
//import com.yihu.ehr.hbase.HBaseDao;
//import com.yihu.ehr.solr.SolrAdmin;
//import com.yihu.ehr.solr.SolrUtil;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//import springfox.documentation.annotations.ApiIgnore;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by hzp on 2017/1/11.
// */
//
//@RestController
//@RequestMapping(value = ApiVersion.Version1_0)
//@Api(value = "HbaseDataEndPoint", description = "Hbase数据", tags = {"资源服务-Hbase数据"})
//public class HbaseDataEndPoint extends EnvelopRestEndpoint {
//
//    @Autowired
//    private HBaseAdmin hbaseAdmin;
//    @Autowired
//    private HBaseDao hbaseDao;
//    @Autowired
//    private SolrAdmin solrAdmin;
//    @Autowired
//    private SolrUtil solrUtil;
//
//    @ApiOperation("模糊匹配表")
//    @RequestMapping(value = "getTableList", method = RequestMethod.GET)
//    public String getTableList(
//            @ApiParam(name = "regex", value = "模糊匹配", required = true)
//            @RequestParam(value = "regex") String regex) throws Exception {
//        String re = "data:[";
//        List<String> list = hbaseAdmin.getTableList(regex, true);
//        if (list != null && list.size() > 0) {
//            for (String item : list) {
//                re += item + "; ";
//            }
//        }
//        re += "]";
//        return re;
//    }
//
//    @ApiOperation("Solr总条数")
//    @RequestMapping(value = "countSolr", method = RequestMethod.GET)
//    public String countSolr(
//            @ApiParam(name = "tableName", value = "表名", defaultValue = "HealthProfile", required = true)
//            @RequestParam(value = "tableName") String tableName) throws Exception {
//        long count = solrUtil.count(tableName,"*:*");
//
//        //通过org_code分组统计
//        /*Map<String,Long> map = solrUtil.groupCount(tableName,null,null,"org_code",0,1000);
//        Long orgCount = new Long(0);
//        for(String key : map.keySet())
//        {
//            orgCount += map.get(key);
//        }*/
//        return "count:"+count;
//
//    }
//
//    @ApiOperation("Hbase总条数")
//    @RequestMapping(value = "countHbase", method = RequestMethod.GET)
//    public String countHbase(
//            @ApiParam(name = "tableName", value="表名",defaultValue = "HealthProfile")
//            @RequestParam(value = "tableName") String tableName) throws Exception {
//        Integer count = hbaseDao.count(tableName);
//        return "count:"+count;
//
//    }
//
//    @ApiOperation("判断表是否存在")
//    @RequestMapping(value = "isTableExists", method = RequestMethod.GET)
//    public String isTableExists(
//            @ApiParam(name = "tableName", value="表名", defaultValue = "HealthProfile")
//            @RequestParam(value = "tableName") String tableName) throws Exception {
//        if (hbaseAdmin.isTableExists(tableName)) {
//            return "true";
//        }
//        return "false";
//    }
//
//    @ApiOperation("创建表")
//    @RequestMapping(value = "createTable", method = RequestMethod.POST)
//    public String createTable(
//            @ApiParam(name = "tableName", value="表名", defaultValue = "HH")
//            @RequestParam(value = "tableName") String tableName,
//            @ApiParam(name = "columnFamilies", value = "列族,逗号分隔", defaultValue = "HH_F1,HH_F2")
//            @RequestParam(value = "columnFamilies") String columnFamilies) throws Exception {
//        String[] cols = columnFamilies.split(",");
//        hbaseAdmin.createTable(tableName,cols);
//        return "Success create table "+tableName+".";
//    }
//
//    @ApiOperation("清空表")
//    @RequestMapping(value = "truncateTable", method = RequestMethod.POST)
//    public String dropTable(
//            @ApiParam(name = "tableName", value = "表名", defaultValue = "HealthArchives")
//            @RequestParam(value = "tableName") String tableName) throws Exception {
//        List<String> list = new ArrayList<>();
//        list.add(tableName);
//        hbaseAdmin.cleanTable(list);
//        //清空索引
//        solrAdmin.delete(tableName,"rowkey:*");
//
//        return "Success drop table "+tableName+".";
//    }
//
//
//    @ApiOperation("测试插入数据")
//    @RequestMapping(value = "insertRecord", method = RequestMethod.POST)
//    public String insertRecord(
//            @ApiParam(name = "tableName", value = "表名", defaultValue = "HealthArchives")
//            @RequestParam(value = "tableName") String tableName,
//            @ApiParam(name = "rowKey", value = "主键", defaultValue = "1")
//            @RequestParam(value = "rowKey") String rowKey,
//            @ApiParam(name = "family", value = "列族", defaultValue = "basic")
//            @RequestParam(value = "family") String family,
//            @ApiParam(name = "columns", value = "列", defaultValue = "demographic_id")
//            @RequestParam(value = "columns") String columns,
//            @ApiParam(name = "values", value = "值", defaultValue = "1234567")
//            @RequestParam(value = "values") String values) throws Exception {
//        Object[] cols = columns.split(",");
//        Object[] vals = values.split(",");
//        hbaseDao.add(tableName,rowKey,family,cols, vals);
//        return "Success insert record For "+tableName+".";
//
//    }
//
//    @ApiOperation("获取单条数据")
//    @RequestMapping(value = "getOneResult", method = RequestMethod.POST)
//    public String getOneResult(
//            @ApiParam(name = "tableName", value="表名", defaultValue = "HealthProfile")
//            @RequestParam(value = "tableName") String tableName,
//            @ApiParam(name = "rowKey", value="主键", defaultValue = "1")
//            @RequestParam(value = "rowKey") String rowKey) throws Exception {
//        Map<String, Object> re = hbaseDao.getResultMap(tableName,rowKey);
//        return objectMapper.writeValueAsString(re);
//    }
//
//
//   @ApiOperation("删除单条Hbase")
//   @RequestMapping(value = "deleteHbase", method = RequestMethod.POST)
//   public String deleteHbase(
//           @ApiParam(name = "core", value = "core", defaultValue = "HealthProfile")
//           @RequestParam(value = "core") String core,
//           @ApiParam(name = "key", value = "key")
//           @RequestParam(value = "key") String key) {
//       hbaseDao.delete(core,key);
//       return "删除单条Hbase成功!";
//   }
//
//    @ApiOperation("删除Solr")
//    @RequestMapping(value = "deleteSolr", method = RequestMethod.POST)
//    @ApiIgnore
//    public String deleteSolr(
//            @ApiParam(name = "core", value = "core", defaultValue = "HealthProfile")
//            @RequestParam(value = "core") String core,
//            @ApiParam(name = "key", value = "key")
//            @RequestParam(value = "key") String key) throws Exception  {
//        solrAdmin.delete(core, key);
//        return "删除Solr成功!";
//    }
//
//}

+ 199 - 209
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/ResourceBrowseEndPoint.java

@ -1,83 +1,78 @@
//package com.yihu.jw.basic.resource.controller;
//
//import com.yihu.ehr.constants.ApiVersion;
//import com.yihu.ehr.constants.ServiceApi;
//import com.yihu.jw.profile.queue.RedisCollection;
//import com.yihu.jw.restmodel.ehr.packs.EsSimplePackage;
//import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
//import com.yihu.jw.restmodel.web.ListEnvelop;
//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.ehr.util.datetime.DateUtil;
//import com.yihu.jw.restmodel.web.Envelop;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Page;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.Serializable;
//import java.util.*;
//
///**
// * Created by hzp on 2016/4/13.
// */
//
//@RestController
//@RequestMapping(value = ApiVersion.Version1_0)
//@Api(value = "ResourceBrowseEndPoint", description = "数据浏览查询", tags = {"资源服务-数据浏览查询"})
//public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
//
//    private static final long PAGE_SIZE_SOLR = 50000;
//
package com.yihu.jw.basic.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.web.PageEnvelop;
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
 * Created by hzp on 2016/4/13.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "ResourceBrowseEndPoint", description = "数据浏览查询", tags = {"资源服务-数据浏览查询"})
public class ResourceBrowseEndPoint extends EnvelopRestEndpoint {
    private static final long PAGE_SIZE_SOLR = 50000;
    @Autowired
    private ResourceBrowseService resourceBrowseService;
    @Autowired
    private ResourcesTransformService resourcesTransformService;
//    @Autowired
//    private ResourceBrowseService resourceBrowseService;
//    private SolrQuery solrQuery;
//    @Autowired
//    private ResourcesTransformService resourcesTransformService;
////    @Autowired
////    private SolrQuery solrQuery;
////    @Autowired
////    private RedisTemplate<String, Serializable> redisTemplate;
//
//
//    // ---------------------------------------------- 基础信息管理 Start---------------------------------
//
//    @ApiOperation("资源数据源结构")
//    @RequestMapping(value = ServiceApi.Resources.ResourceViewMetadata, method = RequestMethod.GET)
//    public List<MRsColumnsModel> getResourceMetadata(
//            @ApiParam(name = "resourcesCode", value = "资源编码")
//            @RequestParam(value = "resourcesCode") String resourcesCode,
//            @ApiParam(name = "roleId", value = "角色id")
//            @RequestParam(value = "roleId") String roleId) throws Exception {
//        return resourceBrowseService.getResourceMetadata(resourcesCode, roleId);
//    }
//
//    private RedisTemplate<String, Serializable> redisTemplate;
    // ---------------------------------------------- 基础信息管理 Start---------------------------------
    @ApiOperation("资源数据源结构")
    @RequestMapping(value = ServiceApi.Resources.ResourceViewMetadata, method = RequestMethod.GET)
    public List<MRsColumnsModel> getResourceMetadata(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色id")
            @RequestParam(value = "roleId") String roleId) throws Exception {
        return resourceBrowseService.getResourceMetadata(resourcesCode, roleId);
    }
//    @ApiOperation("资源浏览")
//    @RequestMapping(value = ServiceApi.Resources.ResourceViewData, method = RequestMethod.GET)
//    public Envelop getResourceData(
//            @ApiParam(name = "resourcesCode", value = "资源编码")
//            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
//            @ApiParam(name = "roleId", value = "角色id [\"roleId\"]")
//            @RequestParam(value = "roleId") String roleId,
//            @ApiParam(name = "orgCode", value = "机构编码 [\"49229004X\"]")
//            @RequestParam(value = "orgCode") String orgCode,
//            @ApiParam(name= "areaCode", value = "地区编码 [\"361121\"]")
//            @RequestParam(value = "areaCode") String areaCode,
//            @ApiParam(name = "queryCondition", value = "查询条件 [{\"andOr\":\"OR\",\"condition\":\"=\",\"field\":\"event_type\",\"value\":\"0\"}]")
//            @RequestParam(value = "queryCondition", required = false) String queryCondition,
//            @ApiParam(name = "page", value = "第几页", required = true)
//            @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);
//    }
//
    @RequestMapping(value = ServiceApi.Resources.ResourceViewData, method = RequestMethod.GET)
    public Envelop getResourceData(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色id [\"roleId\"]")
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "orgCode", value = "机构编码 [\"49229004X\"]")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name= "areaCode", value = "地区编码 [\"361121\"]")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "queryCondition", value = "查询条件 [{\"andOr\":\"OR\",\"condition\":\"=\",\"field\":\"event_type\",\"value\":\"0\"}]")
            @RequestParam(value = "queryCondition", required = false) String queryCondition,
            @ApiParam(name = "page", value = "第几页", required = true)
            @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);
    }
//    @ApiOperation("档案资源浏览细表数据")
//    @RequestMapping(value = ServiceApi.Resources.ResourceViewSubData, method = RequestMethod.GET)
//    public ListEnvelop findSubDateByRowKey(
@ -88,60 +83,60 @@
//        List<Object> resultList = resourceBrowseService.getSubDateByRowkey(rowKey, version);
//        return success(resultList);
//    }
//
//    // ---------------------------------------------- 基础信息管理 End---------------------------------
//
//    /**
//     * 获取资源数据
//     */
//    @ApiOperation("获取资源数据")
//    @RequestMapping(value = ServiceApi.Resources.ResourceQuery, method = RequestMethod.POST)
//    public Envelop getResources(
//            @ApiParam(name = "resourcesCode", value = "资源编码")
//            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
//            @ApiParam(name = "orgCode", value = "机构编码")
//            @RequestParam(value = "orgCode") String orgCode,
//            @ApiParam(name= "areaCode", value = "地区编码")
//            @RequestParam(value = "areaCode") String areaCode,
//            @ApiParam(name = "queryParams", value = "json查询条件,{\"q\":\"*:*\"}")
//            @RequestParam(value = "queryParams", required = false) String queryParams,
//            @ApiParam(name = "page", value = "第几页")
//            @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);
//    }
//
//
//    /**
//     * 获取资源数据(转译)
//     */
//    @ApiOperation("获取资源数据(转译)")
//    @RequestMapping(value = ServiceApi.Resources.ResourceQueryTransform, method = RequestMethod.POST)
//    public Envelop getResourcesTransform(
//            @ApiParam(name = "resourcesCode", value = "资源代码")
//            @RequestParam(value = "resourcesCode") String resourcesCode,
//            @ApiParam(name = "roleId", value = "角色ID")
//            @RequestParam(value = "roleId") String roleId,
//            @ApiParam(name = "orgCode", value = "机构编码")
//            @RequestParam(value = "orgCode") String orgCode,
//            @ApiParam(name = "areaCode", value = "地区编码")
//            @RequestParam(value = "areaCode") String areaCode,
//            @ApiParam(name = "queryParams", value = "json查询条件,{\"q\":\"*:*\"}")
//            @RequestParam(value = "queryParams", required = false) String queryParams,
//            @ApiParam(name = "page", value = "第几页")
//            @RequestParam(value = "page", required = false) Integer page,
//            @ApiParam(name = "size", value = "每页几条")
//            @RequestParam(value = "size", required = false) Integer size,
//            @ApiParam(name = "version", value = "版本号")
//            @RequestParam(value = "version", required = false) String version) throws Exception {
//        Envelop 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;
//    }
//
    // ---------------------------------------------- 基础信息管理 End---------------------------------
    /**
     * 获取资源数据
     */
    @ApiOperation("获取资源数据")
    @RequestMapping(value = ServiceApi.Resources.ResourceQuery, method = RequestMethod.POST)
    public Envelop getResources(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name= "areaCode", value = "地区编码")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "queryParams", value = "json查询条件,{\"q\":\"*:*\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "第几页")
            @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);
    }
    /**
     * 获取资源数据(转译)
     */
    @ApiOperation("获取资源数据(转译)")
    @RequestMapping(value = ServiceApi.Resources.ResourceQueryTransform, method = RequestMethod.POST)
    public Envelop getResourcesTransform(
            @ApiParam(name = "resourcesCode", value = "资源代码")
            @RequestParam(value = "resourcesCode") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色ID")
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name = "areaCode", value = "地区编码")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "queryParams", value = "json查询条件,{\"q\":\"*:*\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "第几页")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "每页几条")
            @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;
    }
//    @ApiOperation("Hbase主表")
//    @RequestMapping(value = ServiceApi.Resources.ResourceMasterData, method = RequestMethod.GET)
//    public Envelop getEhrCenter(
@ -215,7 +210,7 @@
//        envelop.setDetailModelList(result.getContent());
//        return envelop;
//    }
//
//    @ApiOperation("获取非结构化数据")
//    @RequestMapping(value = ServiceApi.Resources.ResourceHealthFile, method = RequestMethod.GET)
//    public Envelop healthFile(
@ -230,26 +225,21 @@
//        Envelop envelop = resourceBrowseService.getEhrFile(filters, sorts, page, size);
//        return envelop;
//    }
//
//    @ApiOperation("Mysql查询")
//    @RequestMapping(value = ServiceApi.Resources.ResourceMysql, method = RequestMethod.GET)
//    public Envelop getMysqlData(
//            @ApiParam(name = "queryParams", value = "检索条件")
//            @RequestParam(value = "queryParams", required = false) String queryParams,
//            @ApiParam(name = "page", value = "页数")
//            @RequestParam(value = "page", required = false) Integer page,
//            @ApiParam(name = "size", value = "分页大小")
//            @RequestParam(value = "size", required = false) Integer size) throws Exception {
//        Page<Map<String, Object>> result = resourceBrowseService.getMysqlData(queryParams, page, size);
//        Envelop envelop = new Envelop();
//        envelop.setStatus(200);
//        envelop.setCurrPage(result.getNumber());
//        envelop.setPageSize(result.getSize());
//        envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
//        envelop.setDetailModelList(result.getContent());
//        return envelop;
//    }
//
    @ApiOperation("Mysql查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceMysql, method = RequestMethod.GET)
    public Envelop getMysqlData(
            @ApiParam(name = "queryParams", value = "检索条件")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "分页大小")
            @RequestParam(value = "size", required = false) Integer size) throws Exception {
        Page<Map<String, Object>> result = resourceBrowseService.getMysqlData(queryParams, page, size);
        Envelop envelop = new Envelop();
        return PageEnvelop.getSuccessListWithPage("",result.getContent(),result.getNumber(),result.getSize(),result.getTotalElements());
    }
//    @ApiOperation("获取solr索引列表")
//    @RequestMapping(value = ServiceApi.Resources.SolrIndexData, method = RequestMethod.GET)
//    public Envelop getSolrIndex(
@ -270,10 +260,10 @@
//        envelop.setDetailModelList(result.getContent());
//        return envelop;
//    }
//
//    /**
//     * 获取资源数据(转译)
//     */
    /**
     * 获取资源数据(转译)
     */
//    @ApiOperation("获取资源数据,返回档案包中包含的数据集(转译)")
//    @RequestMapping(value = ServiceApi.Resources.ResourceQueryAllTransform, method = RequestMethod.POST)
//    public Envelop getAllResourcesTransform(
@ -297,11 +287,11 @@
//        }
//        return result;
//    }
//
//
//    /**
//     * 获取资源数据(转译)
//     */
    /**
     * 获取资源数据(转译)
     */
//    @ApiOperation("获取资源数据,通过数据集列表对应的数据(转译)")
//    @RequestMapping(value = ServiceApi.Resources.ResourceQueryByDataSets, method = RequestMethod.POST)
//    public Envelop getResourceByDataSets(
@ -324,55 +314,55 @@
//        }
//        return result;
//    }
//    //TODO  由于vpn问题不好调测,临时放在此处,后面统一放到svr-pack-mgr
//    @RequestMapping(value = "/addProvincialQueue", method = RequestMethod.POST)
//    @ApiOperation(value = "添加省平台上传队列", notes = "通过条件查询从solr查询数据添加到省平台队列")
//    public String addProvincialQueue(
//            @ApiParam(value = "core 表名,如 HealthProfile")
//            @RequestParam(value = "core", required = true) String core,
//            @ApiParam(name = "q", value = "查询条件solr语法,eg:event_date:[\"2017-12-18T09:49:02Z\" TO \"2017-12-18T09:50:30Z\"]")
//            @RequestParam(name = "q",required = true) String q,
//            @ApiParam(name = "fl", value = "展示字段 多个用  , 拼接 如 org_code,org_name,rowkey,demographic_id,event_type,event_date,patient_name,patient_id,event_no")
//            @RequestParam(name = "fl",required = false,defaultValue = "org_code,org_name,rowkey,demographic_id,event_type,event_date,patient_name,patient_id,event_no") String fl){
//        long count = 0;
//        List<Map<String, Object>> list = new ArrayList<>();
//        try {
//            if(org.apache.commons.lang.StringUtils.isEmpty(fl)){
//                return  "展示字段参数fl 不能为空";
//            }
//
//            String [] fields = fl.split(",");
//            count = solrQuery.count(core,q,null);
//            long page = count / PAGE_SIZE_SOLR +1;
//            for (int i = 0; i < page; i++) {
//                list = solrQuery.queryReturnFieldList(core, q, null, null, i * PAGE_SIZE_SOLR, PAGE_SIZE_SOLR, fields);
//                for (Map<String, Object> item : list) {
//                    EsSimplePackage esSimplePackage = new EsSimplePackage();
//                    esSimplePackage.setRowkey(String.valueOf(item.get("rowkey")));
//                    esSimplePackage.setPatient_id(String.valueOf(item.get("patient_id")));
//                    esSimplePackage.setEvent_date(DateUtil.toStringLong((Date)item.get("event_date")));
//                    esSimplePackage.setEvent_no(String.valueOf(item.get("event_no")));
//                    esSimplePackage.setEvent_type( Integer.valueOf(item.get("event_type").toString()));
//                    esSimplePackage.setOrg_code(String.valueOf(item.get("org_code")));
//                    esSimplePackage.setIdcard_no(String.valueOf(item.get("demographic_id")));
//                    esSimplePackage.setPatient_name(String.valueOf(item.get("patient_name")));
//                    esSimplePackage.setOrg_name(String.valueOf(item.get("org_name")));
//                    esSimplePackage.setOrg_area(String.valueOf(item.get("org_area")));
//                    //存入省平台上传队列
//                    redisTemplate.opsForList().leftPush(RedisCollection.PROVINCIAL_PLATFORM_QUEUE_SUPPLEMENT, objectMapper.writeValueAsString(esSimplePackage));
//                }
//            }
//
////    //TODO  由于vpn问题不好调测,临时放在此处,后面统一放到svr-pack-mgr
////    @RequestMapping(value = "/addProvincialQueue", method = RequestMethod.POST)
////    @ApiOperation(value = "添加省平台上传队列", notes = "通过条件查询从solr查询数据添加到省平台队列")
////    public String addProvincialQueue(
////            @ApiParam(value = "core 表名,如 HealthProfile")
////            @RequestParam(value = "core", required = true) String core,
////            @ApiParam(name = "q", value = "查询条件solr语法,eg:event_date:[\"2017-12-18T09:49:02Z\" TO \"2017-12-18T09:50:30Z\"]")
////            @RequestParam(name = "q",required = true) String q,
////            @ApiParam(name = "fl", value = "展示字段 多个用  , 拼接 如 org_code,org_name,rowkey,demographic_id,event_type,event_date,patient_name,patient_id,event_no")
////            @RequestParam(name = "fl",required = false,defaultValue = "org_code,org_name,rowkey,demographic_id,event_type,event_date,patient_name,patient_id,event_no") String fl){
////        long count = 0;
////        List<Map<String, Object>> list = new ArrayList<>();
////        try {
////            if(org.apache.commons.lang.StringUtils.isEmpty(fl)){
////                return  "展示字段参数fl 不能为空";
////            }
////
////            String [] fields = fl.split(",");
////            count = solrQuery.count(core,q,null);
////            long page = count / PAGE_SIZE_SOLR +1;
////            for (int i = 0; i < page; i++) {
////                list = solrQuery.queryReturnFieldList(core, q, null, null, i * PAGE_SIZE_SOLR, PAGE_SIZE_SOLR, fields);
////                for (Map<String, Object> item : list) {
////                    EsSimplePackage esSimplePackage = new EsSimplePackage();
////                    esSimplePackage.setRowkey(String.valueOf(item.get("rowkey")));
////                    esSimplePackage.setPatient_id(String.valueOf(item.get("patient_id")));
////                    esSimplePackage.setEvent_date(DateUtil.toStringLong((Date)item.get("event_date")));
////                    esSimplePackage.setEvent_no(String.valueOf(item.get("event_no")));
////                    esSimplePackage.setEvent_type( Integer.valueOf(item.get("event_type").toString()));
////                    esSimplePackage.setOrg_code(String.valueOf(item.get("org_code")));
////                    esSimplePackage.setIdcard_no(String.valueOf(item.get("demographic_id")));
////                    esSimplePackage.setPatient_name(String.valueOf(item.get("patient_name")));
////                    esSimplePackage.setOrg_name(String.valueOf(item.get("org_name")));
////                    esSimplePackage.setOrg_area(String.valueOf(item.get("org_area")));
////                    //存入省平台上传队列
////                    redisTemplate.opsForList().leftPush(RedisCollection.PROVINCIAL_PLATFORM_QUEUE_SUPPLEMENT, objectMapper.writeValueAsString(esSimplePackage));
////                }
////            }
////
////            return "操作成功,数量:"+count;
////
////        } catch (Exception e) {
////            e.printStackTrace();
////            return "操作成功异常:"+ e.getMessage();
////        }
////
////    }
//            return "操作成功,数量:"+count;
//
//        } catch (Exception e) {
//            e.printStackTrace();
//            return "操作成功异常:"+ e.getMessage();
//        }
//
//}
//    }
}

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

@ -5,6 +5,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.jw.basic.resource.service.ResourcesTransformService;
import com.yihu.jw.restmodel.ehr.resource.MStdTransformDto;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -31,7 +34,7 @@ public class ResourceTransformEndPoint {
    @ApiOperation("EHR内部标准转国家标准")
    @RequestMapping(value="/rs/transform/stdTransformList",method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<Map<String,Object>> stdTransformList(
    public Envelop stdTransformList(
            @ApiParam(name="stdTransformDtoJson",value="资源数据模型",required = true)
            @RequestBody String stdTransformDtoJson) throws Exception {
        MStdTransformDto stdTransformDto = objectMapper.readValue(stdTransformDtoJson,MStdTransformDto.class);
@ -41,12 +44,13 @@ public class ResourceTransformEndPoint {
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, Object>> list = objectMapper.readValue(resource, javaType);
        return resourcesTransformService.displayCodeConvert(list, version,dataset);
        List<Map<String,Object>> list1 = resourcesTransformService.displayCodeConvert(list, version,dataset);
        return ListEnvelop.getSuccess("转换成功",list1);
    }
    @ApiOperation("EHR内部标准转国家标准(单条记录)")
    @RequestMapping(value="/rs/transform/stdTransform",method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String,Object> stdTransform(
    public Envelop stdTransform(
            @ApiParam(name="stdTransformDtoJson",value="资源数据模型",required = true)
            @RequestBody String stdTransformDtoJson) throws Exception {
        MStdTransformDto stdTransformDto = objectMapper.readValue(stdTransformDtoJson,MStdTransformDto.class);
@ -56,14 +60,14 @@ public class ResourceTransformEndPoint {
        Map<String, Object> map = objectMapper.readValue(resource, Map.class);
        return resourcesTransformService.displayCodeConvert(map,version,dataset);
        return ObjEnvelop.getSuccess("转换成功",resourcesTransformService.displayCodeConvert(map,version,dataset));
    }
    @ApiOperation("EHR主表数据分解")
    @RequestMapping(value = "/rs/transform/stdMasterTransform", method = RequestMethod.POST)
    public Map<String,Object> stdMasterTransform(
    public Envelop stdMasterTransform(
            @ApiParam(name="stdTransformDtoJson",value="资源数据模型",required = true)
            @RequestBody String stdTransformDtoJson) throws Exception {
        MStdTransformDto stdTransformDto = objectMapper.readValue(stdTransformDtoJson,MStdTransformDto.class);
@ -72,7 +76,7 @@ public class ResourceTransformEndPoint {
        String dataset = stdTransformDto.getDataset();
        Map<String, Object> map = objectMapper.readValue(resource, Map.class);
        return resourcesTransformService.stdMasterTransform(map, dataset, version);
        return ObjEnvelop.getSuccess("分解成功",resourcesTransformService.stdMasterTransform(map, dataset, version));
    }
}

+ 36 - 47
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsAdapterDictionaryEndPoint.java

@ -5,6 +5,9 @@ import com.yihu.ehr.constants.ApiVersion;
import com.yihu.jw.entity.ehr.resource.RsAdapterDictionary;
import com.yihu.jw.basic.resource.service.RsAdapterDictionaryService;
import com.yihu.jw.restmodel.ehr.resource.MRsAdapterDictionary;
import com.yihu.jw.restmodel.web.Envelop;
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;
@ -33,7 +36,7 @@ public class RsAdapterDictionaryEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.AdapterDicts, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取适配字典列表")
    public List<MRsAdapterDictionary> searchRsAdapterDictionaries(
    public Envelop searchRsAdapterDictionaries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
@ -43,30 +46,18 @@ public class RsAdapterDictionaryEndPoint extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
            @RequestParam(value = "size", required = false) int size) throws Exception {
        List<RsAdapterDictionary> adapterDictionaries = adapterDictionaryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, adapterDictionaryService.getCount(filters), page, size);
        return (List<MRsAdapterDictionary>) convertToModels(adapterDictionaries, new ArrayList<MRsAdapterDictionary>(adapterDictionaries.size()), MRsAdapterDictionary.class, fields);
        List<MRsAdapterDictionary> list = convertToModels(adapterDictionaries, new ArrayList<>(adapterDictionaries.size()), MRsAdapterDictionary.class, fields);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,adapterDictionaryService.getCount(filters));
    }
    /**
     * 貌似重复的方法
     * @param fields
     * @param filters
     * @param sorts
     * @param page
     * @param size
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionaries, method = RequestMethod.GET)
    @ApiOperation("查询适配字典")
    public List<MRsAdapterDictionary> getDictionaries(
    public Envelop getDictionaries(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(value="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
@ -76,25 +67,23 @@ public class RsAdapterDictionaryEndPoint extends EnvelopRestEndpoint {
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(value="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(value="size",required = false)int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
            @RequestParam(value="size",required = false)int size) throws Exception {
        List<RsAdapterDictionary> adapterDictionaries = adapterDictionaryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, adapterDictionaryService.getCount(filters), page, size);
        return (List<MRsAdapterDictionary>) convertToModels(adapterDictionaries, new ArrayList<MRsAdapterDictionary>(adapterDictionaries.size()), MRsAdapterDictionary.class, fields);
        List<MRsAdapterDictionary> list = convertToModels(adapterDictionaries, new ArrayList<>(adapterDictionaries.size()), MRsAdapterDictionary.class, fields);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,adapterDictionaryService.getCount(filters));
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDicts, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建适配字典")
    public MRsAdapterDictionary createRsAdapterDictionary(
    public Envelop createRsAdapterDictionary(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionary.setId(getObjectId(BizObject.RsAdapterDictionary));
        adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        MRsAdapterDictionary mRsAdapterDictionary = convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        return ObjEnvelop.getSuccess("创建成功",mRsAdapterDictionary);
    }
@ -106,23 +95,25 @@ public class RsAdapterDictionaryEndPoint extends EnvelopRestEndpoint {
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionaries, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("创建适配字典")
    public MRsAdapterDictionary createDictionaries(
    public Envelop createDictionaries(
            @ApiParam(name = "json_data", value = "适配字典JSON", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionary.setId(getObjectId(BizObject.RsAdapterDictionary));
        adapterDictionary = adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class);
        MRsAdapterDictionary mRsAdapterDictionary = convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        return ObjEnvelop.getSuccess("创建成功",mRsAdapterDictionary);
    }
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionaries, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新适配字典")
    public MRsAdapterDictionary updateDictionary(
    public Envelop updateDictionary(
            @ApiParam(name = "json_data", value = "适配字典JSON", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionary = adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class);
        MRsAdapterDictionary mRsAdapterDictionary = convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        return ObjEnvelop.getSuccess("更新成功",mRsAdapterDictionary);
    }
    /**
@ -133,70 +124,68 @@ public class RsAdapterDictionaryEndPoint extends EnvelopRestEndpoint {
     */
    @RequestMapping(value = ServiceApi.Resources.AdapterDicts, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改适配字典")
    public MRsAdapterDictionary updateRsAdapterDictionary(
    public Envelop updateRsAdapterDictionary(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        MRsAdapterDictionary mRsAdapterDictionary = convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        return ObjEnvelop.getSuccess("更新成功",mRsAdapterDictionary);
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDict, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除适配字典")
    public boolean deleteRsAdapterDictionary(
    public Envelop deleteRsAdapterDictionary(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        adapterDictionaryService.delete(id);
        return true;
        return success("删除成功");
    }
    /**
     * 貌似重复的方法
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionary, method = RequestMethod.DELETE)
    @ApiOperation("删除适配字典")
    public boolean deleteDictionary(
    public Envelop deleteDictionary(
            @ApiParam(name = "id", value = "适配字典ID", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        adapterDictionaryService.delete(id);
        return true;
        return success("删除成功");
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDict, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取适配字典")
    public MRsAdapterDictionary getRsAdapterDictionaryById(
    public Envelop getRsAdapterDictionaryById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @RequestParam(value = "id") String id) {
        RsAdapterDictionary adapterDictionary = adapterDictionaryService.findById(id);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class);
        MRsAdapterDictionary mRsAdapterDictionary = convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        return ObjEnvelop.getSuccess("获取成功",mRsAdapterDictionary);
    }
    /**
     * 貌似重复的方法
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionary, method = RequestMethod.GET)
    @ApiOperation("根据ID获取适配字典")
    public MRsAdapterDictionary getDictionaryById(
    public Envelop getDictionaryById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(adapterDictionaryService.findById(id), MRsAdapterDictionary.class);
        RsAdapterDictionary adapterDictionary = adapterDictionaryService.findById(id);
        MRsAdapterDictionary mRsAdapterDictionary = convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
        return ObjEnvelop.getSuccess("获取成功",mRsAdapterDictionary);
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDictsBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建适配字典")
    public boolean createRsAdapterDictionaries(
    public Envelop createRsAdapterDictionaries(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        List<RsAdapterDictionary> dictionaries = toEntity(jsonData,List.class);
        adapterDictionaryService.batchInsert(dictionaries);
        return true;
        return success("创建成功");
    }

+ 22 - 22
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsAdapterMetaDataEndPoint.java

@ -5,6 +5,9 @@ import com.yihu.ehr.constants.ApiVersion;
import com.yihu.jw.entity.ehr.resource.RsAdapterMetadata;
import com.yihu.jw.basic.resource.service.RsAdapterMetadataService;
import com.yihu.jw.restmodel.ehr.resource.MRsAdapterMetadata;
import com.yihu.jw.restmodel.web.Envelop;
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;
@ -37,60 +40,63 @@ public class RsAdapterMetaDataEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("创建适配数据元")
    public MRsAdapterMetadata createMetadata(
    public Envelop createMetadata(
            @ApiParam(name="adapterMetadata",value="数据元JSON",defaultValue = "")
            @RequestBody String adapterMetadata) throws Exception
    {
        RsAdapterMetadata metadata = toEntity(adapterMetadata,RsAdapterMetadata.class);
        metadata.setId(getObjectId(BizObject.RsAdapterMetadata));
        metadata = metadataService.saveAdapterMetadata(metadata);
        return convertToModel(metadata,MRsAdapterMetadata.class);
        MRsAdapterMetadata mRsAdapterMetadata =  convertToModel(metadata,MRsAdapterMetadata.class);
        return ObjEnvelop.getSuccess("创建成功",mRsAdapterMetadata);
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新适配数据元")
    public MRsAdapterMetadata updateMetadata(
    public Envelop updateMetadata(
            @ApiParam(name="adapterMetadata",value="数据元JSON",defaultValue = "")
            @RequestBody String adapterMetadata) throws Exception
    {
        RsAdapterMetadata metadata = toEntity(adapterMetadata,RsAdapterMetadata.class);
        metadata = metadataService.saveAdapterMetadata(metadata);
        return convertToModel(metadata,MRsAdapterMetadata.class);
        MRsAdapterMetadata mRsAdapterMetadata =  convertToModel(metadata,MRsAdapterMetadata.class);
        return ObjEnvelop.getSuccess("更新成功",mRsAdapterMetadata);
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadata,method = RequestMethod.DELETE)
    @ApiOperation("删除适配数据元")
    public boolean deleteMetadata(
    public Envelop deleteMetadata(
            @ApiParam(name="id",value="数据元ID",defaultValue = "")
            @PathVariable(value="id")String id) throws Exception
    {
        metadataService.deleteAdapterMetadata(id);
        return true;
        return success("删除成功");
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.DELETE)
    @ApiOperation("批量删除适配数据元")
    public boolean deleteMetadataBatch(
    public Envelop deleteMetadataBatch(
            @ApiParam(name="ids",value="数据元ID",defaultValue = "")
            @RequestParam(value="ids") String ids) throws Exception
    {
        metadataService.deleteAdapterMetadata(ids);
        return true;
        return success("删除成功");
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadata,method = RequestMethod.GET)
    @ApiOperation("根据ID获取适配数据元")
    public MRsAdapterMetadata getMetadataById(
    public Envelop getMetadataById(
            @ApiParam(name="id",value="id",defaultValue = "")
            @PathVariable(value="id") String id) throws Exception
    {
         return convertToModel(metadataService.getAdapterMetadataById(id),MRsAdapterMetadata.class);
        MRsAdapterMetadata mRsAdapterMetadata = convertToModel(metadataService.getAdapterMetadataById(id),MRsAdapterMetadata.class);
        return ObjEnvelop.getSuccess("更新成功",mRsAdapterMetadata);
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.GET)
    @ApiOperation("查询适配数据元")
    public List<MRsAdapterMetadata> getMetadata(
    public Envelop getMetadata(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(value="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
@ -100,12 +106,9 @@ public class RsAdapterMetaDataEndPoint extends EnvelopRestEndpoint {
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(value="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(value="size",required = false)int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
            @RequestParam(value="size",required = false)int size) throws Exception {
        long total = 0;
        Collection<MRsAdapterMetadata> metaList;
        List<MRsAdapterMetadata> metaList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsAdapterMetadata> metadataPage = metadataService.getAdapterMetadata(sorts, reducePage(page), size);
@ -116,19 +119,16 @@ public class RsAdapterMetaDataEndPoint extends EnvelopRestEndpoint {
            total = metadataService.getCount(filters);
            metaList = convertToModels(metadata, new ArrayList<>(metadata.size()), MRsAdapterMetadata.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsAdapterMetadata>)metaList;
        return PageEnvelop.getSuccessListWithPage("查询成功",metaList,page,size,total);
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建适配数据元", notes = "批量创建适配数据元")
    public boolean createRsMetaDataBatch(
    public Envelop createRsMetaDataBatch(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        List<RsAdapterMetadata> adapterMetadata = toEntity(jsonData,List.class);
        metadataService.batchInsert(adapterMetadata);
        return true;
        return success("创建成功");
    }
}

+ 19 - 15
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsAdapterSchemeEndPoint.java

@ -5,6 +5,9 @@ import com.yihu.ehr.constants.ApiVersion;
import com.yihu.jw.entity.ehr.resource.RsAdapterScheme;
import com.yihu.jw.basic.resource.service.RsAdapterSchemeService;
import com.yihu.jw.restmodel.ehr.resource.MRsAdapterSchema;
import com.yihu.jw.restmodel.web.Envelop;
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;
@ -37,54 +40,57 @@ public class RsAdapterSchemeEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("创建适配方案")
    public MRsAdapterSchema createSchema(
    public Envelop createSchema(
            @ApiParam(name = "adapterSchema", value = "数据元JSON", defaultValue = "")
            @RequestBody String adapterSchema) throws Exception {
        RsAdapterScheme schema = toEntity(adapterSchema, RsAdapterScheme.class);
        schema.setId(getObjectId(BizObject.RsAdapterSchema));
        schema = schemaService.saveAdapterScheme(schema);
        return convertToModel(schema, MRsAdapterSchema.class);
        MRsAdapterSchema mRsAdapterSchema = convertToModel(schema, MRsAdapterSchema.class);
        return ObjEnvelop.getSuccess("创建成功",mRsAdapterSchema);
    }
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新适配方案")
    public MRsAdapterSchema updateSchema(
    public Envelop updateSchema(
            @ApiParam(name = "adapterScheme", value = "数据元JSON", defaultValue = "")
            @RequestBody String adapterSchema) throws Exception {
        RsAdapterScheme schema = toEntity(adapterSchema, RsAdapterScheme.class);
        schema = schemaService.save(schema);
        return convertToModel(schema, MRsAdapterSchema.class);
        MRsAdapterSchema mRsAdapterSchema = convertToModel(schema, MRsAdapterSchema.class);
        return ObjEnvelop.getSuccess("更新成功",mRsAdapterSchema);
    }
    @RequestMapping(value = ServiceApi.Adaptions.Scheme, method = RequestMethod.DELETE)
    @ApiOperation("删除适配方案")
    public boolean deleteSchema(
    public Envelop deleteSchema(
            @ApiParam(name = "id", value = "方案id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        schemaService.deleteById(id);
        return true;
        return success("删除成功");
    }
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.DELETE)
    @ApiOperation("批量删除适配方案")
    public boolean deleteSchemaBatch(
    public Envelop deleteSchemaBatch(
            @ApiParam(name = "ids", value = "ids", defaultValue = "")
            @RequestParam(value = "ids") String ids) throws Exception {
        schemaService.deleteAdapterScheme(ids);
        return true;
        return success("删除成功");
    }
    @RequestMapping(value = ServiceApi.Adaptions.Scheme, method = RequestMethod.GET)
    @ApiOperation("根据ID获取适配方案")
    public MRsAdapterSchema getAdapterSchemaById(
    public Envelop getAdapterSchemaById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(schemaService.getAdapterSchemeById(id), MRsAdapterSchema.class);
        MRsAdapterSchema mRsAdapterSchema = convertToModel(schemaService.getAdapterSchemeById(id), MRsAdapterSchema.class);
        return ObjEnvelop.getSuccess("获取成功",mRsAdapterSchema);
    }
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.GET)
    @ApiOperation("查询适配方案")
    public List<MRsAdapterSchema> getSchema(
    public Envelop getSchema(
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
@ -98,7 +104,7 @@ public class RsAdapterSchemeEndPoint extends EnvelopRestEndpoint {
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsAdapterSchema> metaList;
        List<MRsAdapterSchema> metaList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
@ -110,8 +116,6 @@ public class RsAdapterSchemeEndPoint extends EnvelopRestEndpoint {
            total = schemaService.getCount(filters);
            metaList = convertToModels(metadata, new ArrayList<>(metadata.size()), MRsAdapterSchema.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsAdapterSchema>) metaList;
        return PageEnvelop.getSuccessListWithPage("查询成功",metaList,page,size,total);
    }
}

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

@ -3,8 +3,12 @@ package com.yihu.jw.basic.resource.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.restmodel.ehr.resource.MRsAdapterMetadata;
import com.yihu.jw.restmodel.ehr.resource.MRsDictionary;
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.resource.RsDictionary;
import com.yihu.jw.basic.resource.service.RsDictionaryEntryService;
@ -39,7 +43,7 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取标准字典列表", notes = "根据查询条件获取标准字典列表")
    public List<MRsDictionary> searchRsDictionaries(
    public Envelop searchRsDictionaries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
@ -53,15 +57,14 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsDictionary> dictionaries = dictionaryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, dictionaryService.getCount(filters), page, size);
        return (List<MRsDictionary>) convertToModels(dictionaries, new ArrayList<MRsDictionary>(dictionaries.size()), MRsDictionary.class, fields);
        List<MRsDictionary> mRsDictionaryList = convertToModels(dictionaries, new ArrayList<>(dictionaries.size()), MRsDictionary.class, fields);
        return PageEnvelop.getSuccessListWithPage("查询成功",mRsDictionaryList,page,size,dictionaryService.getCount(filters));
    }
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建标准字典", notes = "创建标准字典")
    public MRsDictionary createRsDictionary(
    public Envelop createRsDictionary(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsDictionary rsDictionary = toEntity(jsonData, RsDictionary.class);
@ -70,18 +73,19 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
            throw new Exception("字典代码不能重复");
        }
        dictionaryService.insert(rsDictionary);
        return convertToModel(rsDictionary, MRsDictionary.class, null);
        MRsDictionary mRsDictionary = convertToModel(rsDictionary,MRsDictionary.class);
        return ObjEnvelop.getSuccess("创建成功",mRsDictionary);
    }
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改标准字典", notes = "修改标准字典")
    public MRsDictionary updateRsDictionary(
    public Envelop updateRsDictionary(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsDictionary dictionary = toEntity(jsonData, RsDictionary.class);
        dictionaryService.save(dictionary);
        return convertToModel(dictionary, MRsDictionary.class, null);
        MRsDictionary mRsDictionary = convertToModel(dictionary,MRsDictionary.class);
        return ObjEnvelop.getSuccess("修改成功",mRsDictionary);
    }
@ -111,62 +115,63 @@ public class RsDictionaryEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.Dict, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取标准字典")
    public MRsDictionary getRsDictionaryById(
    public Envelop getRsDictionaryById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @PathVariable(value = "id") int id) throws UnsupportedEncodingException {
        RsDictionary dictionary = dictionaryService.findById(id);
        return convertToModel(dictionary, MRsDictionary.class);
        MRsDictionary mRsDictionary = convertToModel(dictionary,MRsDictionary.class);
        return ObjEnvelop.getSuccess("获取成功",mRsDictionary);
    }
    @RequestMapping(value = ServiceApi.Resources.DictBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建标准字典", notes = "批量创建标准字典")
    public boolean createRsDictionaries(
    public Envelop createRsDictionaries(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        List<RsDictionary> dictionaries = toEntity(jsonData, List.class);
        dictionaryService.batchInsert(dictionaries);
        return true;
        return success("创建成功");
    }
    @RequestMapping(value = ServiceApi.Resources.DictExistence, method = RequestMethod.GET)
    @ApiOperation("根据过滤条件判断是否存在")
    public boolean isExistenceFilters(
    public Envelop isExistenceFilters(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters") String filters) throws Exception {
        List ls = dictionaryService.search("", filters, "", 1, 1);
        return ls != null && ls.size() > 0;
        return ObjEnvelop.getSuccess("获取成功",ls != null && ls.size() > 0);
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntryBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建标准字典以及字典项", notes = "批量创建标准字典以及字典项")
    public boolean createDictAndEntries(
    public Envelop createDictAndEntries(
            @RequestBody String jsonData) throws Exception {
        List models = objectMapper.readValue(jsonData, new TypeReference<List>() {
        });
        dictionaryService.batchInsertDictsAndEntry(models);
        return true;
        return success("创建成功");
    }
    @RequestMapping(value = ServiceApi.Resources.DictCodesExistence, method = RequestMethod.POST)
    @ApiOperation("获取已存在字典编码")
    public List codeExistence(
    public Envelop codeExistence(
            @RequestBody String codes) throws Exception {
        List existCodes = dictionaryService.codeExist(toEntity(codes, String[].class));
        return existCodes;
        return ListEnvelop.getSuccess("获取成功",existCodes);
    }
    @RequestMapping(value = ServiceApi.Resources.DictCode, method = RequestMethod.GET)
    @ApiOperation(value = "根据code获取获取标准字典")
    public MRsDictionary getRsDictionaryByCode(
    public Envelop getRsDictionaryByCode(
            @ApiParam(name = "code", value = "", defaultValue = "")
            @RequestParam(value = "code") String code) throws Exception {
        List<RsDictionary> ls = dictionaryService.findByField("code", code);
        return ls.size() > 0 ? convertToModel(ls.get(0), MRsDictionary.class) : null;
        return ObjEnvelop.getSuccess("获取成功",ls.size() > 0 ? convertToModel(ls.get(0), MRsDictionary.class) : null);
    }

+ 3 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportCategoryAppEndPoint.java

@ -4,6 +4,7 @@ import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.entity.ehr.report.ReportCategoryAppRelation;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.basic.resource.service.RsReportCategoryAppService;
import io.swagger.annotations.Api;
@ -66,10 +67,10 @@ public class RsReportCategoryAppEndPoint extends EnvelopRestEndpoint {
    @ApiOperation("根据报表分类编码获取应用编码")
    @RequestMapping(value = ServiceApi.Resources.GetRsReportCategoryApps, method = RequestMethod.GET)
    public String getAppIdByCategory(
    public Envelop getAppIdByCategory(
            @ApiParam(name = "reportCategoryId", value = "报表分类编码")
            @RequestParam(value = "reportCategoryId")String reportCategoryId) {
        String appIds = rsReportCategoryAppService.getAppIdByCategory(reportCategoryId);
        return appIds;
        return ObjEnvelop.getSuccess("获取成功",appIds);
    }
}

+ 4 - 4
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportCategoryEndPoint.java

@ -50,7 +50,7 @@ public class RsReportCategoryEndPoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "根据条件获取资源报表分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategories, method = RequestMethod.GET)
    List<MRsReportCategory> search(
    public List<MRsReportCategory> search(
            @ApiParam(name = "codeName", value = "资源分类编码或名称")
            @RequestParam(value = "codeName", required = false) String codeName) throws ParseException {
        List<MRsReportCategory> resultList = new ArrayList<>();
@ -80,10 +80,10 @@ public class RsReportCategoryEndPoint extends EnvelopRestEndpoint {
        }
        if (topNodeListIn.size() != 0) {
            List<RsReportCategory> inList = rsReportCategoryService.getTreeByParents(topNodeListIn);
            resultList.addAll(convertToModels(inList, new ArrayList<MRsReportCategory>(), MRsReportCategory.class, ""));
            resultList.addAll(convertToModels(inList, new ArrayList<>(), MRsReportCategory.class, ""));
        }
        List<RsReportCategory> outList = rsReportCategoryService.getTreeByParentsAndCodeName(topNodeListOut, codeName);
        resultList.addAll(convertToModels(outList, new ArrayList<MRsReportCategory>(), MRsReportCategory.class, ""));
        resultList.addAll(convertToModels(outList, new ArrayList<>(), MRsReportCategory.class, ""));
        return resultList;
    }
@ -92,7 +92,7 @@ public class RsReportCategoryEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryComboTree, method = RequestMethod.GET)
    public List<MRsReportCategory> getComboTreeData() throws Exception {
        List<RsReportCategory> list = rsReportCategoryService.getAllTreeData();
        return (List<MRsReportCategory>) convertToModels(list, new ArrayList<MRsReportCategory>(list.size()), MRsReportCategory.class, "");
        return (List<MRsReportCategory>) convertToModels(list, new ArrayList<>(list.size()), MRsReportCategory.class, "");
    }
    @ApiOperation("新增资源报表分类")

+ 18 - 18
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportEndPoint.java

@ -40,8 +40,8 @@ public class RsReportEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private RsReportService rsReportService;
//    @Autowired
//    private FastDFSUtil fastDFSUtil;
    @Autowired
    private FastDFSUtil fastDFSUtil;
    @Autowired
    private RsReportCategoryService rsReportCategoryService;
@ -78,7 +78,7 @@ public class RsReportEndPoint extends EnvelopRestEndpoint {
            HttpServletResponse response) throws Exception {
        List<RsReport> rsReports = rsReportService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, rsReportService.getCount(filters), page, size);
        return (List<MRsReport>) convertToModels(rsReports, new ArrayList<MRsReport>(), MRsReport.class, fields);
        return (List<MRsReport>) convertToModels(rsReports, new ArrayList<>(), MRsReport.class, fields);
    }
    @ApiOperation("新增资源报表")
@ -138,21 +138,21 @@ public class RsReportEndPoint extends EnvelopRestEndpoint {
        return (List<MRsReport>) convertToModels(list, new ArrayList<>(list.size()), MRsReport.class, null);
    }
//    @ApiOperation("获取报表模版内容")
//    @RequestMapping(value = ServiceApi.Resources.RsReportTemplateContent, method = RequestMethod.GET)
//    public String getTemplateContent(
//            @ApiParam(name = "reportCode", value = "资源报表Code", required = true)
//            @RequestParam(value = "reportCode") String reportCode,
//            HttpServletResponse response) throws Exception {
//        RsReport rsReport = rsReportService.getByCode(reportCode);
//        if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
//            throw new ApiException(ErrorCode.NOT_FOUND, "模版未找到");
//        }
//        String[] paths = rsReport.getTemplatePath().split(":");
//        byte[] bytes = fastDFSUtil.download(paths[0], paths[1]);
//        String templateContent = new String(bytes, "UTF-8");
//        return templateContent;
//    }
    @ApiOperation("获取报表模版内容")
    @RequestMapping(value = ServiceApi.Resources.RsReportTemplateContent, method = RequestMethod.GET)
    public Envelop getTemplateContent(
            @ApiParam(name = "reportCode", value = "资源报表Code", required = true)
            @RequestParam(value = "reportCode") String reportCode,
            HttpServletResponse response) throws Exception {
        RsReport rsReport = rsReportService.getByCode(reportCode);
        if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
            return failed("模版未找到");
        }
        String[] paths = rsReport.getTemplatePath().split(":");
        byte[] bytes = fastDFSUtil.download(paths[0], paths[1]);
        String templateContent = new String(bytes, "UTF-8");
        return ObjEnvelop.getSuccess("查询成功",templateContent);
    }
    @ApiOperation("判断资源报表分类是否被使用")
    @RequestMapping(value = ServiceApi.Resources.RsReportIsCategoryApplied, method = RequestMethod.GET)

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

@ -90,7 +90,7 @@ public class RsResourceDefaultParamsEndPoint extends EnvelopRestEndpoint {
            HttpServletResponse response) throws Exception {
        List<RsResourceDefaultParam>  rsDefaultParams = resourceDefaultParamService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, resourceDefaultParamService.getCount(filters), page, size);
        return (List<MResourceDefaultParam>) convertToModels(rsDefaultParams, new ArrayList<MResourceDefaultParam>(rsDefaultParams.size()), MResourceDefaultParam.class, fields);
        return (List<MResourceDefaultParam>) convertToModels(rsDefaultParams, new ArrayList<>(rsDefaultParams.size()), MResourceDefaultParam.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.ParamsNoPage, method = RequestMethod.GET)
@ -99,7 +99,7 @@ public class RsResourceDefaultParamsEndPoint extends EnvelopRestEndpoint {
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsResourceDefaultParam> rsDefaultParams = resourceDefaultParamService.search(filters);
        return convertToModels(rsDefaultParams, new ArrayList<MResourceDefaultParam>(rsDefaultParams.size()), MResourceDefaultParam.class,null);
        return convertToModels(rsDefaultParams, new ArrayList<>(rsDefaultParams.size()), MResourceDefaultParam.class,null);
    }
    @RequestMapping(value = ServiceApi.Resources.ParamKeyValueExistence, method = RequestMethod.GET)

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

@ -164,7 +164,7 @@ public class RsResourceEndPoint extends EnvelopRestEndpoint {
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsResources> rsList;
        List<MRsResources> rsList;
        //过滤条件为空
        if(StringUtils.isEmpty(filters)) {
            Page<RsResource> resources = rsResourceService.getResources(sorts,reducePage(page),size);
@ -184,7 +184,7 @@ public class RsResourceEndPoint extends EnvelopRestEndpoint {
            rsList = convertToModels(resources,new ArrayList<>(resources.size()),MRsResources.class,fields);
        }
        pagedResponse(request,response,total,page,size);
        return (List<MRsResources>)rsList;
        return rsList;
    }
    @ApiOperation("资源查询_不分页")

+ 614 - 613
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/ResourceBrowseDao.java

@ -1,497 +1,498 @@
//package com.yihu.jw.basic.resource.dao;
//
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//import com.yihu.jw.es.util.ElasticsearchUtil;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.profile.ProfileType;
//import com.yihu.jw.profile.core.ResourceCore;
//import com.yihu.jw.profile.family.ResourceCells;
//import com.yihu.jw.basic.resource.service.RedisService;
//import com.yihu.jw.basic.resource.service.RsResourceService;
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.entity.ehr.resource.*;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.PageImpl;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Repository;
//
//import java.io.IOException;
//import java.util.*;
//import java.util.stream.Collectors;
//
//
///**
// * Created by hzp on 2016/4/22.
// * 资源查询底层接口
// */
//@Repository
//public class ResourceBrowseDao {
//
//    private Integer defaultPage = 1;
//    private Integer defaultSize = 1000;
//    private String mainJoinCore = ResourceCore.MasterTable + "_shard1_replica1";
//    private String subJoinCore = ResourceCore.SubTable + "_shard1_replica1";
//    private static final String INDEX = "archive_relation";
//    private static final String TYPE = "info";
//
//    @Autowired
//    private JdbcTemplate jdbcTemplate;
////    @Autowired
////    private HbaseQuery hbaseQuery;
////    @Autowired
////    private SolrQuery solr;
//    @Autowired
//    private ObjectMapper objectMapper;
//    @Autowired
//    private RsResourceDao rsResourceDao;
//    @Autowired
//    private ResourceBrowseMetadataDao resourceBrowseMetadataDao;
package com.yihu.jw.basic.resource.dao;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.redis.schema.AdapterMetaDataKeySchema;
import com.yihu.jw.basic.standard.service.redis.StdRedisService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.mysql.model.QueryCondition;
import com.yihu.jw.mysql.sqlparser.ParserFactory;
import com.yihu.jw.mysql.sqlparser.ParserSql;
import com.yihu.jw.profile.ProfileType;
import com.yihu.jw.profile.core.ResourceCore;
import com.yihu.jw.profile.family.ResourceCells;
import com.yihu.jw.basic.resource.service.RedisService;
import com.yihu.jw.basic.resource.service.RsResourceService;
import com.yihu.jw.redis.schema.StdDataSetKeySchema;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.entity.ehr.resource.*;
import com.yihu.jw.restmodel.web.ListEnvelop;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by hzp on 2016/4/22.
 * 资源查询底层接口
 */
@Repository
public class ResourceBrowseDao {
    private Integer defaultPage = 1;
    private Integer defaultSize = 1000;
    private String mainJoinCore = ResourceCore.MasterTable + "_shard1_replica1";
    private String subJoinCore = ResourceCore.SubTable + "_shard1_replica1";
    private static final String INDEX = "archive_relation";
    private static final String TYPE = "info";
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private RsResourceDao rsResourceDao;
    @Autowired
    private ResourceBrowseMetadataDao resourceBrowseMetadataDao;
    @Autowired
    private RsResourceDefaultParamDao resourceDefaultParamDao;
    @Autowired
    private RedisService redisService;
    @Autowired
    private RsRolesResourceMetadataDao rsRolesResourceMetadataDao;
    @Autowired
    private RsRolesResourceDao rsRolesResourceDao;
    @Autowired
    private RsResourceQuotaDao rsResourceQuotaDao;
//    @Autowired
//    private RsResourceDefaultParamDao resourceDefaultParamDao;
//    @Autowired
//    private RedisService redisService;
//    @Autowired
//    private RsRolesResourceMetadataDao rsRolesResourceMetadataDao;
////    @Autowired
////    private StdTransformClient stdTransformClient;
//    @Autowired
//    private RsRolesResourceDao rsRolesResourceDao;
//    @Autowired
//    private RsResourceQuotaDao rsResourceQuotaDao;
////    @Autowired
////    private QuotaStatisticsClient quotaStatisticsClient;
////    @Autowired
////    private HBaseDao hbaseDao;
//    private QuotaStatisticsClient quotaStatisticsClient;
//    @Autowired
//    private ElasticsearchUtil elasticSearchUtil;
////    @Autowired
////    private SolrQuery solrQuery;
//    @Autowired
//    private RsResourceService rsResourceService;
//
//    /**
//     * 获取资源授权数据元列表
//     *
//     * @param rsResource 资源
//     * @param roleId 角色ID列表
//     * @return
//     * @throws Exception
//     */
////    public List<DtoResourceMetadata> getAccessMetadata(RsResource rsResource, String roleId, Map<String, String> correspondMap) throws Exception {
////        Set<String> rsMetadataIdSet = new HashSet<>();
////        String grantType = rsResource.getGrantType();
////        boolean isOtherVersion = false;
////        if (rsResource.getCode().split("\\$").length > 1) {
////            isOtherVersion = true;
////        }
////        if (isOtherVersion) {
////            String version = rsResource.getCode().split("\\$")[1];
////            String code = rsResource.getCode().split("\\$")[0];
////            String otherStdMetadataStr = stdTransformClient.stdMetadataCodes(version, code); //省平台临时数据处理
////            if (null == otherStdMetadataStr) {
////                throw new ApiException("省平台数据缓存为空");
////            }
////            String[] otherStdMetadataArr = otherStdMetadataStr.split(",");
////            List<String> transformEhrMetadataList = new ArrayList<>(); // 此list存储其他标准数据集底下的数据元转换成的平台的数据元的id (EHR_XXXXX)
////            for (String otherStdMetadata : otherStdMetadataArr) {
////                String dataSetAndMetadata = stdTransformClient.adapterMetadataCode("5a6951bff0bb", code, otherStdMetadata); //适配版本号
////                if (!StringUtils.isEmpty(dataSetAndMetadata) && dataSetAndMetadata.split("\\.").length > 1) {
////                    String[] dataSetAndMetadataArr = dataSetAndMetadata.split("\\.");
////                    String ehrMetadata = redisService.getRsAdapterMetaData("59083976eebd", dataSetAndMetadataArr[0], dataSetAndMetadataArr[1]);
////                    if (!StringUtils.isEmpty(ehrMetadata)) {
////                        transformEhrMetadataList.add(ehrMetadata);
////                        correspondMap.put(ehrMetadata, otherStdMetadata);
////                    }
////                }
////            }
////            if (grantType.equals("1") && !roleId.equals("*")) {
////                List<String> roleIdList = objectMapper.readValue(roleId, List.class);
////                for (String id : roleIdList) {
////                    RsRolesResource rsRolesResource = rsRolesResourceDao.findByResourceIdAndRolesId(rsResource.getId(), id);
////                    if (rsRolesResource != null) {
////                        List<RsRolesResourceMetadata> rsRolesResourceMetadataList = rsRolesResourceMetadataDao.findByRolesResourceIdAndValid(rsRolesResource.getId(), "1");
////                        if (rsRolesResourceMetadataList != null) {
////                            for (RsRolesResourceMetadata rsRolesResourceMetadata : rsRolesResourceMetadataList) {
////                                if (transformEhrMetadataList.contains(rsRolesResourceMetadata.getResourceMetadataId())) { // 如果其他标准数据集包含该数据元
////                                    rsMetadataIdSet.add(rsRolesResourceMetadata.getResourceMetadataId());
////                                }
////                            }
////                        }
////                    }
////                }
////                if (rsMetadataIdSet.size() > 0) {
////                    StringBuilder rsMetadataIds = new StringBuilder();
////                    for (String id : rsMetadataIdSet) {
////                        rsMetadataIds.append("'");
////                        rsMetadataIds.append(id);
////                        rsMetadataIds.append("',");
////                    }
////                    if (rsMetadataIds.length() <= 0) {
////                        return null;
////                    }
////                    return resourceBrowseMetadataDao.getAuthResourceMetadata(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
////                } else {
////                    return null;
////                }
////            } else {
////                StringBuilder rsMetadataIds = new StringBuilder();
////                for (String id : transformEhrMetadataList) {
////                    rsMetadataIds.append("'");
////                    rsMetadataIds.append(id);
////                    rsMetadataIds.append("',");
////                }
////                if (rsMetadataIds.length() <= 0) {
////                    return null;
////                }
////                return resourceBrowseMetadataDao.getRsMetadataByIds(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
////            }
////        } else { //EHR所用标准
////            if (grantType.equals("1") && !roleId.equals("*")) {
////                List<String> roleIdList = objectMapper.readValue(roleId, List.class);
////                for (String id : roleIdList) {
////                    RsRolesResource rsRolesResource = rsRolesResourceDao.findByResourceIdAndRolesId(rsResource.getId(), id);
////                    if (rsRolesResource != null) {
////                        List<RsRolesResourceMetadata> rsRolesResourceMetadataList = rsRolesResourceMetadataDao.findByRolesResourceIdAndValid(rsRolesResource.getId(), "1");
////                        if (rsRolesResourceMetadataList != null) {
////                            for (RsRolesResourceMetadata rsRolesResourceMetadata : rsRolesResourceMetadataList) {
////                                rsMetadataIdSet.add(rsRolesResourceMetadata.getResourceMetadataId());
////                            }
////                        }
////                    }
////                }
////                if (rsMetadataIdSet.size() > 0) {
////                    StringBuilder rsMetadataIds = new StringBuilder();
////                    for (String id : rsMetadataIdSet) {
////                        rsMetadataIds.append("'");
////                        rsMetadataIds.append(id);
////                        rsMetadataIds.append("',");
////                    }
////                    return resourceBrowseMetadataDao.getAuthResourceMetadata(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
////                } else {
////                    return null;
////                }
////            } else {
////                //返回所有数据元
////                return resourceBrowseMetadataDao.getAllResourceMetadata(rsResource.getCode());
////            }
////        }
////    }
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    private StdDataSetKeySchema stdDataSetKeySchema;
    @Autowired
    private AdapterMetaDataKeySchema adapterMetaDataKeySchema;
    /**
     * 获取资源授权数据元列表
     *
     * @param rsResource 资源
     * @param roleId 角色ID列表
     * @return
     * @throws Exception
     */
    public List<DtoResourceMetadata> getAccessMetadata(RsResource rsResource, String roleId, Map<String, String> correspondMap) throws Exception {
        Set<String> rsMetadataIdSet = new HashSet<>();
        String grantType = rsResource.getGrantType();
        boolean isOtherVersion = false;
        if (rsResource.getCode().split("\\$").length > 1) {
            isOtherVersion = true;
        }
        if (isOtherVersion) {
            String version = rsResource.getCode().split("\\$")[1];
            String code = rsResource.getCode().split("\\$")[0];
            String otherStdMetadataStr = stdDataSetKeySchema.metadataCodes(version, code); //省平台临时数据处理
            if (null == otherStdMetadataStr) {
                throw new ApiException("省平台数据缓存为空");
            }
            String[] otherStdMetadataArr = otherStdMetadataStr.split(",");
            List<String> transformEhrMetadataList = new ArrayList<>(); // 此list存储其他标准数据集底下的数据元转换成的平台的数据元的id (EHR_XXXXX)
            for (String otherStdMetadata : otherStdMetadataArr) {
                String dataSetAndMetadata = adapterMetaDataKeySchema.getAdapterMetaDataCode("5a6951bff0bb", code, otherStdMetadata); //适配版本号
                if (!StringUtils.isEmpty(dataSetAndMetadata) && dataSetAndMetadata.split("\\.").length > 1) {
                    String[] dataSetAndMetadataArr = dataSetAndMetadata.split("\\.");
                    String ehrMetadata = redisService.getRsAdapterMetaData("59083976eebd", dataSetAndMetadataArr[0], dataSetAndMetadataArr[1]);
                    if (!StringUtils.isEmpty(ehrMetadata)) {
                        transformEhrMetadataList.add(ehrMetadata);
                        correspondMap.put(ehrMetadata, otherStdMetadata);
                    }
                }
            }
            if (grantType.equals("1") && !roleId.equals("*")) {
                List<String> roleIdList = objectMapper.readValue(roleId, List.class);
                for (String id : roleIdList) {
                    RsRolesResource rsRolesResource = rsRolesResourceDao.findByResourceIdAndRolesId(rsResource.getId(), id);
                    if (rsRolesResource != null) {
                        List<RsRolesResourceMetadata> rsRolesResourceMetadataList = rsRolesResourceMetadataDao.findByRolesResourceIdAndValid(rsRolesResource.getId(), "1");
                        if (rsRolesResourceMetadataList != null) {
                            for (RsRolesResourceMetadata rsRolesResourceMetadata : rsRolesResourceMetadataList) {
                                if (transformEhrMetadataList.contains(rsRolesResourceMetadata.getResourceMetadataId())) { // 如果其他标准数据集包含该数据元
                                    rsMetadataIdSet.add(rsRolesResourceMetadata.getResourceMetadataId());
                                }
                            }
                        }
                    }
                }
                if (rsMetadataIdSet.size() > 0) {
                    StringBuilder rsMetadataIds = new StringBuilder();
                    for (String id : rsMetadataIdSet) {
                        rsMetadataIds.append("'");
                        rsMetadataIds.append(id);
                        rsMetadataIds.append("',");
                    }
                    if (rsMetadataIds.length() <= 0) {
                        return null;
                    }
                    return resourceBrowseMetadataDao.getAuthResourceMetadata(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
                } else {
                    return null;
                }
            } else {
                StringBuilder rsMetadataIds = new StringBuilder();
                for (String id : transformEhrMetadataList) {
                    rsMetadataIds.append("'");
                    rsMetadataIds.append(id);
                    rsMetadataIds.append("',");
                }
                if (rsMetadataIds.length() <= 0) {
                    return null;
                }
                return resourceBrowseMetadataDao.getRsMetadataByIds(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
            }
        } else { //EHR所用标准
            if (grantType.equals("1") && !roleId.equals("*")) {
                List<String> roleIdList = objectMapper.readValue(roleId, List.class);
                for (String id : roleIdList) {
                    RsRolesResource rsRolesResource = rsRolesResourceDao.findByResourceIdAndRolesId(rsResource.getId(), id);
                    if (rsRolesResource != null) {
                        List<RsRolesResourceMetadata> rsRolesResourceMetadataList = rsRolesResourceMetadataDao.findByRolesResourceIdAndValid(rsRolesResource.getId(), "1");
                        if (rsRolesResourceMetadataList != null) {
                            for (RsRolesResourceMetadata rsRolesResourceMetadata : rsRolesResourceMetadataList) {
                                rsMetadataIdSet.add(rsRolesResourceMetadata.getResourceMetadataId());
                            }
                        }
                    }
                }
                if (rsMetadataIdSet.size() > 0) {
                    StringBuilder rsMetadataIds = new StringBuilder();
                    for (String id : rsMetadataIdSet) {
                        rsMetadataIds.append("'");
                        rsMetadataIds.append(id);
                        rsMetadataIds.append("',");
                    }
                    return resourceBrowseMetadataDao.getAuthResourceMetadata(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
                } else {
                    return null;
                }
            } else {
                //返回所有数据元
                return resourceBrowseMetadataDao.getAllResourceMetadata(rsResource.getCode());
            }
        }
    }
    /**
     * @param resourcesCode 资源编码
     * @param roleId        角色ID列表
     * @param saas          权限
     * @param queryParams   查询条件 {"q":"*:*","fq":"*:*","basicFl":"","dFl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}"}
     * @param page          页码
     * @param size          页数
     * @return
     * @throws Exception
     */
//    public Envelop getEhrCenter (String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
//        //获取Saas权限
//        StringBuilder q = new StringBuilder();
//        if (saas != null && !"*".equals(saas)) {
//            q.append(saas);
//        }
//        String fq = "";
//        final Map<String, String> sort = new HashMap<>();
//        Map<String, String> query = new HashMap<>();
//        if (queryParams != null) {
//            query = objectMapper.readValue(queryParams, Map.class);
//            if (query.containsKey("q") && !query.get("q").trim().equals("*:*")) {
//                if (q.length() > 0) {
//                    q.append(" AND (");
//                    q.append(query.get("q"));
//                    q.append(")");
//                } else {
//                    q.append(query.get("q"));
//                }
//            }
//            if (query.containsKey("fq")) {
//                fq = query.get("fq");
//            }
//            if (query.containsKey("sort")) {
//                Map<String, String> temp = objectMapper.readValue((String) query.get("sort"), Map.class);
//                temp.forEach((key, value) -> {
//                    sort.put(key, value);
//                });
//            }
//        }
//        //通过资源代码获取默认参数
//        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);
//                temp.forEach((key, value) -> {
//                    sort.put(key, value);
//                });
//            }
//            if (param.getParamKey().equals("q")) {
//                List<QueryCondition> ql = parseCondition(param.getParamValue());
//                if (q.length() > 0) {
//                    q.append(" AND ");
//                    q.append(solrQuery.conditionToString(ql));
//                } else {
//                    q.append(solrQuery.conditionToString(ql));
//                }
//            }
//        }
//        if (resourcesCode != null) {
//            RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
//            //获取资源结构权限,该部分新增其他标准数据集的判断
//            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
//            if (metadataList != null && metadataList.size() > 0) {
//                //数据元信息字段
//                List<String> metadataIdList = new ArrayList<>();
//                for (DtoResourceMetadata metadata : metadataList) {
//                    String id = metadata.getId();
//                    metadataIdList.add(id);
//                    String dictCode = metadata.getDictCode();
//                    if (!StringUtils.isEmpty(dictCode)) {
//                        metadataIdList.add(id + "_VALUE");
//                    }
//                }
//                Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.MasterTable, q.toString(), objectMapper.writeValueAsString(sort), fq, StringUtils.join(ResourceCells.getMasterBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ","), page, size);
//                Envelop envelop = new Envelop();
//                envelop.setStatus(200);
//                envelop.setCurrPage(result.getNumber());
//                envelop.setPageSize(result.getSize());
//                envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
//                envelop.setDetailModelList(result.getContent());
//                return envelop;
//            }
//        } else {
//            String basicFl = "";
//            String dFl = "";
//            if (query.containsKey("basicFl")) {
//                basicFl = query.get("basicFl");
//            }
//            if (query.containsKey("dFl")) {
//                dFl = query.get("dFl");
//            }
//            Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.MasterTable, q.toString(), objectMapper.writeValueAsString(sort), fq, basicFl, dFl, page, size);
//            Envelop envelop = new Envelop();
//            envelop.setStatus(200);
//            envelop.setCurrPage(result.getNumber());
//            envelop.setPageSize(result.getSize());
//            envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
//            envelop.setDetailModelList(result.getContent());
//            return envelop;
//        }
//        throw new ApiException("资源无相关数据元");
//    }
    /**
     * @param resourcesCode 资源编码
     * @param roleId        角色ID列表
     * @param saas          权限
     * @param queryParams   查询条件 {"q":"*:*","fq":"*:*","basicFl":"","dFl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}"}
     * @param page          页码
     * @param size          页数
     * @return
     * @throws Exception
     */
//    public Envelop getEhrCenterSub (String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
//        //获取Saas权限
//        StringBuilder q = new StringBuilder();
//        if (saas != null && !"*".equals(saas)) {
//            q.append(saas);
//        }
//        String fq = "";
//        final Map<String, String> sort = new HashMap<>();
//        Map<String, String> query = new HashMap<>();
//        if (queryParams != null) {
//            query = objectMapper.readValue(queryParams, Map.class);
//            if (query.containsKey("q") && !query.get("q").trim().equals("*:*")) {
//                if (q.length() > 0) {
//                    q.append(" AND (");
//                    q.append(query.get("q"));
//                    q.append(")");
//                } else {
//                    q.append(query.get("q"));
//                }
//            }
//            if (query.containsKey("fq")) {
//                fq = query.get("fq");
//            }
//            if (query.containsKey("sort")) {
//                Map<String, String> temp = objectMapper.readValue((String) query.get("sort"), Map.class);
//                temp.forEach((key, value) -> {
//                    sort.put(key, value);
//                });
//            }
//        }
//        //通过资源代码获取默认参数
//        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);
//                temp.forEach((key, value) -> {
//                    sort.put(key, value);
//                });
//            }
//            if (param.getParamKey().equals("table")) {
//                if (q.length() > 0) {
//                    q.append(" AND (rowkey:*$" + param.getParamValue() + "$*)");
//                } else {
//                    q.append("rowkey:*$" + param.getParamValue() + "$*");
//                }
//            }
//            if (param.getParamKey().equals("q")) {
//                List<QueryCondition> ql = parseCondition(param.getParamValue());
//                if (q.length() > 0) {
//                    q.append(" AND ");
//                    q.append(solrQuery.conditionToString(ql));
//                } else {
//                    q.append(solrQuery.conditionToString(ql));
//                }
//            }
//        }
//        if (resourcesCode != null) {
//            RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
//            //获取资源结构权限,该部分新增其他标准数据集的判断
//            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
//            if (metadataList != null && metadataList.size() > 0) {
//                //数据元信息字段
//                List<String> metadataIdList = new ArrayList<>();
//                for (DtoResourceMetadata metadata : metadataList) {
//                    String id = metadata.getId();
//                    metadataIdList.add(id);
//                    String dictCode = metadata.getDictCode();
//                    if (!StringUtils.isEmpty(dictCode)) {
//                        metadataIdList.add(id + "_VALUE");
//                    }
//                }
//                Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.SubTable, q.toString(), objectMapper.writeValueAsString(sort), fq, StringUtils.join(ResourceCells.getSubBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ","), page, size);
//                Envelop envelop = new Envelop();
//                envelop.setStatus(200);
//                envelop.setCurrPage(result.getNumber());
//                envelop.setPageSize(result.getSize());
//                envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
//                envelop.setDetailModelList(result.getContent());
//                return envelop;
//            }
//        } else {
//            String basicFl = "";
//            String dFl = "";
//            if (query.containsKey("basicFl")) {
//                basicFl = query.get("basicFl");
//            }
//            if (query.containsKey("dFl")) {
//                dFl = query.get("dFl");
//            }
//            Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.SubTable, q.toString(), objectMapper.writeValueAsString(sort), fq, basicFl, dFl, page, size);
//            Envelop envelop = new Envelop();
//            envelop.setStatus(200);
//            envelop.setCurrPage(result.getNumber());
//            envelop.setPageSize(result.getSize());
//            envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
//            envelop.setDetailModelList(result.getContent());
//            return envelop;
//        }
//        throw new ApiException("资源无相关数据元");
//    }
    /**
     * habse主表的solr分组统计
     * {"q":"*:*","groupFields":"key1,key2","statsFields":"key3,key4","customGroup":[{"groupField":"lastUpdateTime","groupCondition":{"3Month":"last_update_time:[2016-02-16 TO *]","6Month":"last_update_time:[2015-11-10 TO *]"}}]}
     *
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Page<Map<String, Object>> countEhrCenter(String queryParams, Integer page, Integer size) throws Exception {
//        String core = ResourceCore.MasterTable;
//        ObjectMapper objectMapper = new ObjectMapper();
//        Map<String, Object> params = objectMapper.readValue(queryParams, Map.class);
//        String q = "";
//        String fq = "";
//        String groupFields = "";
//        String statsFields = "";
//        List<SolrGroupEntity> customGroup = new ArrayList<>();
//        if (params.containsKey("q")) {
//            fq = params.get("q").toString();
//            if (params.containsKey("saas") && !params.get("saas").equals("*")) {
//                fq += " AND (" + params.get("saas") + ")";
//            }
//        } else {
//            if (params.containsKey("saas") && !params.get("saas").equals("*")) {
//                fq = params.get("saas").toString();
//            }
//        }
//
//    /**
//     * @param resourcesCode 资源编码
//     * @param roleId        角色ID列表
//     * @param saas          权限
//     * @param queryParams   查询条件 {"q":"*:*","fq":"*:*","basicFl":"","dFl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}"}
//     * @param page          页码
//     * @param size          页数
//     * @return
//     * @throws Exception
//     */
////    public Envelop getEhrCenter (String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
////        //获取Saas权限
////        StringBuilder q = new StringBuilder();
////        if (saas != null && !"*".equals(saas)) {
////            q.append(saas);
////        }
////        String fq = "";
////        final Map<String, String> sort = new HashMap<>();
////        Map<String, String> query = new HashMap<>();
////        if (queryParams != null) {
////            query = objectMapper.readValue(queryParams, Map.class);
////            if (query.containsKey("q") && !query.get("q").trim().equals("*:*")) {
////                if (q.length() > 0) {
////                    q.append(" AND (");
////                    q.append(query.get("q"));
////                    q.append(")");
////                } else {
////                    q.append(query.get("q"));
////                }
////            }
////            if (query.containsKey("fq")) {
////                fq = query.get("fq");
////            }
////            if (query.containsKey("sort")) {
////                Map<String, String> temp = objectMapper.readValue((String) query.get("sort"), Map.class);
////                temp.forEach((key, value) -> {
////                    sort.put(key, value);
////                });
////            }
////        }
////        //通过资源代码获取默认参数
////        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);
////                temp.forEach((key, value) -> {
////                    sort.put(key, value);
////                });
////            }
////            if (param.getParamKey().equals("q")) {
////                List<QueryCondition> ql = parseCondition(param.getParamValue());
////                if (q.length() > 0) {
////                    q.append(" AND ");
////                    q.append(solrQuery.conditionToString(ql));
////                } else {
////                    q.append(solrQuery.conditionToString(ql));
////                }
////            }
////        }
////        if (resourcesCode != null) {
////            RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
////            //获取资源结构权限,该部分新增其他标准数据集的判断
////            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
////            if (metadataList != null && metadataList.size() > 0) {
////                //数据元信息字段
////                List<String> metadataIdList = new ArrayList<>();
////                for (DtoResourceMetadata metadata : metadataList) {
////                    String id = metadata.getId();
////                    metadataIdList.add(id);
////                    String dictCode = metadata.getDictCode();
////                    if (!StringUtils.isEmpty(dictCode)) {
////                        metadataIdList.add(id + "_VALUE");
////                    }
////                }
////                Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.MasterTable, q.toString(), objectMapper.writeValueAsString(sort), fq, StringUtils.join(ResourceCells.getMasterBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ","), page, size);
////                Envelop envelop = new Envelop();
////                envelop.setStatus(200);
////                envelop.setCurrPage(result.getNumber());
////                envelop.setPageSize(result.getSize());
////                envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
////                envelop.setDetailModelList(result.getContent());
////                return envelop;
////            }
////        } else {
////            String basicFl = "";
////            String dFl = "";
////            if (query.containsKey("basicFl")) {
////                basicFl = query.get("basicFl");
////            }
////            if (query.containsKey("dFl")) {
////                dFl = query.get("dFl");
////            }
////            Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.MasterTable, q.toString(), objectMapper.writeValueAsString(sort), fq, basicFl, dFl, page, size);
////            Envelop envelop = new Envelop();
////            envelop.setStatus(200);
////            envelop.setCurrPage(result.getNumber());
////            envelop.setPageSize(result.getSize());
////            envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
////            envelop.setDetailModelList(result.getContent());
////            return envelop;
////        }
////        throw new ApiException("资源无相关数据元");
////    }
//        if (params.containsKey("groupFields")) {
//            groupFields = params.get("groupFields").toString();
//        }
//        if (params.containsKey("statsFields")) {
//            statsFields = params.get("statsFields").toString();
//        }
//        if (params.containsKey("customGroup")) {
//            ArrayList listGroup = ((ArrayList) params.get("customGroup"));
//            if (listGroup != null && listGroup.size() > 0) {
//                for (int i = 0; i < listGroup.size(); i++) {
//                    String groupField = ((LinkedHashMap) listGroup.get(i)).get("groupField").toString();
//                    Map<String, String> groupCondition = (Map) ((LinkedHashMap) listGroup.get(i)).get("groupCondition");
//
//                    customGroup.add(new SolrGroupEntity(groupField, groupCondition));
//                }
//            }
//        }
//        //join操作
//        if (params.containsKey("join")) {
//            String join = params.get("join").toString();
//            q = "{!join fromIndex=" + subJoinCore + " from=profile_id to=rowkey}" + join;
//        }
//
//    /**
//     * @param resourcesCode 资源编码
//     * @param roleId        角色ID列表
//     * @param saas          权限
//     * @param queryParams   查询条件 {"q":"*:*","fq":"*:*","basicFl":"","dFl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}"}
//     * @param page          页码
//     * @param size          页数
//     * @return
//     * @throws Exception
//     */
////    public Envelop getEhrCenterSub (String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
////        //获取Saas权限
////        StringBuilder q = new StringBuilder();
////        if (saas != null && !"*".equals(saas)) {
////            q.append(saas);
////        }
////        String fq = "";
////        final Map<String, String> sort = new HashMap<>();
////        Map<String, String> query = new HashMap<>();
////        if (queryParams != null) {
////            query = objectMapper.readValue(queryParams, Map.class);
////            if (query.containsKey("q") && !query.get("q").trim().equals("*:*")) {
////                if (q.length() > 0) {
////                    q.append(" AND (");
////                    q.append(query.get("q"));
////                    q.append(")");
////                } else {
////                    q.append(query.get("q"));
////                }
////            }
////            if (query.containsKey("fq")) {
////                fq = query.get("fq");
////            }
////            if (query.containsKey("sort")) {
////                Map<String, String> temp = objectMapper.readValue((String) query.get("sort"), Map.class);
////                temp.forEach((key, value) -> {
////                    sort.put(key, value);
////                });
////            }
////        }
////        //通过资源代码获取默认参数
////        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);
////                temp.forEach((key, value) -> {
////                    sort.put(key, value);
////                });
////            }
////            if (param.getParamKey().equals("table")) {
////                if (q.length() > 0) {
////                    q.append(" AND (rowkey:*$" + param.getParamValue() + "$*)");
////                } else {
////                    q.append("rowkey:*$" + param.getParamValue() + "$*");
////                }
////            }
////            if (param.getParamKey().equals("q")) {
////                List<QueryCondition> ql = parseCondition(param.getParamValue());
////                if (q.length() > 0) {
////                    q.append(" AND ");
////                    q.append(solrQuery.conditionToString(ql));
////                } else {
////                    q.append(solrQuery.conditionToString(ql));
////                }
////            }
////        }
////        if (resourcesCode != null) {
////            RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
////            //获取资源结构权限,该部分新增其他标准数据集的判断
////            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
////            if (metadataList != null && metadataList.size() > 0) {
////                //数据元信息字段
////                List<String> metadataIdList = new ArrayList<>();
////                for (DtoResourceMetadata metadata : metadataList) {
////                    String id = metadata.getId();
////                    metadataIdList.add(id);
////                    String dictCode = metadata.getDictCode();
////                    if (!StringUtils.isEmpty(dictCode)) {
////                        metadataIdList.add(id + "_VALUE");
////                    }
////                }
////                Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.SubTable, q.toString(), objectMapper.writeValueAsString(sort), fq, StringUtils.join(ResourceCells.getSubBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ","), page, size);
////                Envelop envelop = new Envelop();
////                envelop.setStatus(200);
////                envelop.setCurrPage(result.getNumber());
////                envelop.setPageSize(result.getSize());
////                envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
////                envelop.setDetailModelList(result.getContent());
////                return envelop;
////            }
////        } else {
////            String basicFl = "";
////            String dFl = "";
////            if (query.containsKey("basicFl")) {
////                basicFl = query.get("basicFl");
////            }
////            if (query.containsKey("dFl")) {
////                dFl = query.get("dFl");
////            }
////            Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.SubTable, q.toString(), objectMapper.writeValueAsString(sort), fq, basicFl, dFl, page, size);
////            Envelop envelop = new Envelop();
////            envelop.setStatus(200);
////            envelop.setCurrPage(result.getNumber());
////            envelop.setPageSize(result.getSize());
////            envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
////            envelop.setDetailModelList(result.getContent());
////            return envelop;
////        }
////        throw new ApiException("资源无相关数据元");
////    }
//        if (groupFields.length() == 0 && customGroup.size() == 0) {
//            throw new Exception("缺少分组条件!");
//        }
//        //数值统计
//        if (statsFields != null && statsFields.length() > 0) {
//            return solr.getStats(core, groupFields, statsFields, q, fq, customGroup);
//        }
//        //总数统计
//        else {
//            if (customGroup.size() == 0) {
//                //默认第一页
//                if (page == null) {
//                    page = defaultPage;
//                }
//                //默认行数
//                if (size == null) {
//                    size = defaultSize;
//                }
//
//    /**
//     * habse主表的solr分组统计
//     * {"q":"*:*","groupFields":"key1,key2","statsFields":"key3,key4","customGroup":[{"groupField":"lastUpdateTime","groupCondition":{"3Month":"last_update_time:[2016-02-16 TO *]","6Month":"last_update_time:[2015-11-10 TO *]"}}]}
//     *
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
////    public Page<Map<String, Object>> countEhrCenter(String queryParams, Integer page, Integer size) throws Exception {
////        String core = ResourceCore.MasterTable;
////        ObjectMapper objectMapper = new ObjectMapper();
////        Map<String, Object> params = objectMapper.readValue(queryParams, Map.class);
////        String q = "";
////        String fq = "";
////        String groupFields = "";
////        String statsFields = "";
////        List<SolrGroupEntity> customGroup = new ArrayList<>();
////        if (params.containsKey("q")) {
////            fq = params.get("q").toString();
////            if (params.containsKey("saas") && !params.get("saas").equals("*")) {
////                fq += " AND (" + params.get("saas") + ")";
////            }
////        } else {
////            if (params.containsKey("saas") && !params.get("saas").equals("*")) {
////                fq = params.get("saas").toString();
////            }
////        }
////
////        if (params.containsKey("groupFields")) {
////            groupFields = params.get("groupFields").toString();
////        }
////        if (params.containsKey("statsFields")) {
////            statsFields = params.get("statsFields").toString();
////        }
////        if (params.containsKey("customGroup")) {
////            ArrayList listGroup = ((ArrayList) params.get("customGroup"));
////            if (listGroup != null && listGroup.size() > 0) {
////                for (int i = 0; i < listGroup.size(); i++) {
////                    String groupField = ((LinkedHashMap) listGroup.get(i)).get("groupField").toString();
////                    Map<String, String> groupCondition = (Map) ((LinkedHashMap) listGroup.get(i)).get("groupCondition");
////
////                    customGroup.add(new SolrGroupEntity(groupField, groupCondition));
////                }
////            }
////        }
////        //join操作
////        if (params.containsKey("join")) {
////            String join = params.get("join").toString();
////            q = "{!join fromIndex=" + subJoinCore + " from=profile_id to=rowkey}" + join;
////        }
////
////        if (groupFields.length() == 0 && customGroup.size() == 0) {
////            throw new Exception("缺少分组条件!");
////        }
////        //数值统计
////        if (statsFields != null && statsFields.length() > 0) {
////            return solr.getStats(core, groupFields, statsFields, q, fq, customGroup);
////        }
////        //总数统计
////        else {
////            if (customGroup.size() == 0) {
////                //默认第一页
////                if (page == null) {
////                    page = defaultPage;
////                }
////                //默认行数
////                if (size == null) {
////                    size = defaultSize;
////                }
////
////                //多分组
////                if (groupFields.contains(",")) {
////                    return solr.getGroupMult(core, groupFields, q, fq, page, size);
////                } else {
////                    return solr.getGroupCount(core, groupFields, q, fq, page, size);
////                }
////            } else {
////                return solr.getGroupMult(core, groupFields, customGroup, q, fq);
////            }
////        }
////
////    }
//                //多分组
//                if (groupFields.contains(",")) {
//                    return solr.getGroupMult(core, groupFields, q, fq, page, size);
//                } else {
//                    return solr.getGroupCount(core, groupFields, q, fq, page, size);
//                }
//            } else {
//                return solr.getGroupMult(core, groupFields, customGroup, q, fq);
//            }
//        }
//
//    /**
//     * habse细表的solr分组统计
//     *
//     * @param queryParams {"table":"HDSD00_08","q":"*:*","groupFields":"key1,key2","statsFields":"key3,key4",customGroup:""}
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
//    }
    /**
     * habse细表的solr分组统计
     *
     * @param queryParams {"table":"HDSD00_08","q":"*:*","groupFields":"key1,key2","statsFields":"key3,key4",customGroup:""}
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Page<Map<String, Object>> countEhrCenterSub (String queryParams, Integer page, Integer size) throws Exception {
//        String core = ResourceCore.SubTable;
//        ObjectMapper objectMapper = new ObjectMapper();
@ -554,17 +555,17 @@
//        }
//
//    }
//
//    /**
//     * 获取指标数据
//     * @param resourcesCode
//     * @param roleId
//     * @param saas
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     */
    /**
     * 获取指标数据
     * @param resourcesCode
     * @param roleId
     * @param saas
     * @param queryParams
     * @param page
     * @param size
     * @return
     */
//    public Envelop getQuotaData(String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws IOException {
//        RsResource rsResource = rsResourceService.getResourceByCategory(resourcesCode,"standard");
//        if (rsResource.getDimension() != null && "orgHealthCategoryCode".equals(rsResource.getDimension())) {
@ -574,24 +575,24 @@
//                quotaCodeStr.append(item.getQuotaCode()).append(",");
//            });
//            List<Map<String, Object>> resultList = quotaStatisticsClient.getQuotaReportTwoDimensionalTable(quotaCodeStr.toString(), null, rsResource.getDimension(), null);
//            Envelop envelop = new Envelop();
//            ListEnvelop envelop = new ListEnvelop();
//            envelop.setStatus(200);
//            envelop.setDetailModelList(resultList);
//            return envelop;
//        }
//        return null;
//    }
//
//    /**
//     * 获取非结构化资源
//     *
//     * @param filters key1=val1;key2>val2;key3<>val3
//     * @param sorts
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
    /**
     * 获取非结构化资源
     *
     * @param filters key1=val1;key2>val2;key3<>val3
     * @param sorts
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Envelop getEhrFile(String filters, String sorts, Integer page, Integer size) throws Exception {
//        Page<Map<String, Object>> esList = elasticSearchUtil.page(INDEX, TYPE, filters, sorts, page, size);
//        List<String> rowkeys = new ArrayList<>();
@ -626,51 +627,51 @@
//        envelop.setDetailModelList(hbaseList);
//        return envelop;
//    }
//
//    /**
//     * 获取Mysql配置库数据
//     *
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
//    public Page<Map<String, Object>> getMysqlData(String queryParams, Integer page, Integer size) throws Exception {
//        String sql = queryParams;
//
//        //判定是否完整sql语句
//        if (sql.toLowerCase().indexOf(" from ") <= 0) {
//            sql = "select * from " + queryParams;
//        }
//        //查询总条数
//        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);
//    }
//
//    /**
//     * 获取solr索引列表
//     * queryParams可为solr表达式,也可为json例:{"q":"*:*","saas":"*","join":"*:*","fl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}""}
//     * 有join参数做join操作
//     */
    /**
     * 获取Mysql配置库数据
     *
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlData(String queryParams, Integer page, Integer size) throws Exception {
        String sql = queryParams;
        //判定是否完整sql语句
        if (sql.toLowerCase().indexOf(" from ") <= 0) {
            sql = "select * from " + queryParams;
        }
        //查询总条数
        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);
    }
    /**
     * 获取solr索引列表
     * queryParams可为solr表达式,也可为json例:{"q":"*:*","saas":"*","join":"*:*","fl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}""}
     * 有join参数做join操作
     */
//    public Page<String> getSolrIndexs(String queryParams, Integer page, Integer size) throws Exception {
//        String core = ResourceCore.MasterTable;
//        String q = "";
@ -722,15 +723,15 @@
//        }
//        return hbaseQuery.queryIndexBySolr(core, q, sort, fq, basicFl, dFl, page, size);
//    }
//
//    /**
//     * @param resourcesCode 资源编码
//     * @param roleId        角色ID列表
//     * @param saas          权限
//     * @param rowKey        主键
//     * @return
//     * @throws Exception
//     */
    /**
     * @param resourcesCode 资源编码
     * @param roleId        角色ID列表
     * @param saas          权限
     * @param rowKey        主键
     * @return
     * @throws Exception
     */
//    public List<Map<String, Object>> getEhrCenterByScan (String resourcesCode, String roleId, String saas, String rowKey) throws Exception {
//        Map<String, Object> query = new HashMap<>();
//        if (resourcesCode != null) {
@ -789,15 +790,15 @@
//        }
//        throw new ApiException("资源无相关数据元");
//    }
//
//    /**
//     * @param dataSetCode 数据集编码
//     * @param roleId      角色ID列表
//     * @param saas        权限
//     * @param rowKey
//     * @return
//     * @throws Exception
//     */
    /**
     * @param dataSetCode 数据集编码
     * @param roleId      角色ID列表
     * @param saas        权限
     * @param rowKey
     * @return
     * @throws Exception
     */
//    public List<Map<String, Object>> getEhrCenterSubByScan (String dataSetCode, String roleId, String saas, String rowKey) throws Exception {
//        Map<String, Object> query = new HashMap<>();
//        if (dataSetCode != null) {
@ -862,18 +863,18 @@
//        }
//        throw new ApiException("资源无相关数据元");
//    }
//
//
//    /**
//     * 通过数据集编码集合,获取对应rowkey 下的资源数据
//     *
//     * @param dataSetCodes 数据集编码集合
//     * @param roleId       角色ID列表
//     * @param saas         权限
//     * @param rowKey
//     * @return
//     * @throws Exception
//     */
    /**
     * 通过数据集编码集合,获取对应rowkey 下的资源数据
     *
     * @param dataSetCodes 数据集编码集合
     * @param roleId       角色ID列表
     * @param saas         权限
     * @param rowKey
     * @return
     * @throws Exception
     */
//    public Map<String, Object> getEhrCenterSubMapByScan (List<String> dataSetCodes, String roleId, String saas, String rowKey) throws Exception {
//        Map<String, Object> resultMap = new HashMap<>();
//        Map<String, List<String>> rowKeyMap = new HashMap<>();
@ -977,31 +978,31 @@
//        return resultMap;
//
//    }
//
//    /**
//     * 查询条件转换
//     *
//     * @param queryCondition
//     * @return
//     * @throws Exception
//     */
//    private List<QueryCondition> parseCondition(String queryCondition) throws Exception {
//        List<QueryCondition> ql = new ArrayList<QueryCondition>();
//        List<Map<String, Object>> list = objectMapper.readValue(queryCondition, List.class);
//        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"));
//                if (value.indexOf(",") > 0) {
//                    ql.add(new QueryCondition(andOr, cond, field, value.split(",")));
//                } else {
//                    ql.add(new QueryCondition(andOr, cond, field, value));
//                }
//            }
//        }
//        return ql;
//    }
//
//}
    /**
     * 查询条件转换
     *
     * @param queryCondition
     * @return
     * @throws Exception
     */
    private List<QueryCondition> parseCondition(String queryCondition) throws Exception {
        List<QueryCondition> ql = new ArrayList<QueryCondition>();
        List<Map<String, Object>> list = objectMapper.readValue(queryCondition, List.class);
        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"));
                if (value.indexOf(",") > 0) {
                    ql.add(new QueryCondition(andOr, cond, field, value.split(",")));
                } else {
                    ql.add(new QueryCondition(andOr, cond, field, value));
                }
            }
        }
        return ql;
    }
}

+ 1 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/dao/RsResourceDao.java

@ -14,6 +14,7 @@ import java.util.List;
public interface RsResourceDao extends JpaRepository<RsResource, String> {
    RsResource findByCode(String code);
    RsResource findByName(String name);
    long countByCategoryId(String categoryId);
    List<RsResource> findByCategoryId(String categoryId);

+ 626 - 465
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java

@ -1,197 +1,358 @@
//package com.yihu.jw.basic.resource.service;
//
//
//import com.fasterxml.jackson.databind.JavaType;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.yihu.ehr.constants.ErrorCode;
//import com.yihu.jw.es.util.ElasticsearchUtil;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.profile.ProfileType;
//import com.yihu.jw.profile.family.ResourceCells;
//import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
//import com.yihu.mysql.query.BaseJpaService;
//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 org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Page;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//
//import java.lang.reflect.Method;
//import java.util.*;
//
//
///**
// * Created by hzp on 2016/4/13.
// */
//@Service
//public class ResourceBrowseService extends BaseJpaService {
//
///*    @Autowired
//    private SolrQuery solrQuery;*/
//    @Autowired
//    private RsResourceDao rsResourceDao;
//    @Autowired
//    private ResourceBrowseMetadataDao resourceBrowseMetadataDao;
////    @Autowired
////    private ResourceBrowseDao resourceBrowseDao;
///*    @Autowired
//    private StdTransformClient stdTransformClient;*/
//    @Autowired
//    private RedisService redisService;
package com.yihu.jw.basic.resource.service;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.ErrorCode;
import com.yihu.jw.basic.resource.dao.ResourceBrowseDao;
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.ObjEnvelop;
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;
import org.springframework.util.StringUtils;
import java.lang.reflect.Method;
import java.util.*;
/**
 * Created by hzp on 2016/4/13.
 */
@Service
public class ResourceBrowseService extends BaseJpaService {
    @Autowired
    private RsResourceDao rsResourceDao;
    @Autowired
    private ResourceBrowseMetadataDao resourceBrowseMetadataDao;
    @Autowired
    private ResourceBrowseDao resourceBrowseDao;
/*    @Autowired
    private StdTransformClient stdTransformClient;*/
    @Autowired
    private RedisService redisService;
//    @Autowired
//    private ElasticsearchUtil elasticSearchUtil;
//    @Autowired
//    private RsResourceService rsResourceService;
//    @Autowired
//    private ObjectMapper objectMapper;
//    /**
//     * 资源浏览 -- 资源数据元结构
//     *
//     * @param resourcesCode
//     * @param roleId
//     * @return
//     * @throws Exception
//     */
//    public List<MRsColumnsModel> getResourceMetadata(String resourcesCode, String roleId) throws Exception {
//        RsResource rsResource = rsResourceService.getResourceByCategory(resourcesCode,"standard");
//        if (rsResource == null) {
//            return null;
//        }
//        Map<String, String> correspondMap = new HashMap<>();
//        boolean isOtherVersion = false;
//        String version = "";
//        String code = "";
//        if (resourcesCode.split("\\$").length > 1) {
//            isOtherVersion = true;
//            version = resourcesCode.split("\\$")[1];
//            code = resourcesCode.split("\\$")[0];
//        }
//        List<DtoResourceMetadata> metadataList = resourceBrowseDao.getAccessMetadata(rsResource, roleId, correspondMap);
//        //资源结构
//        List<MRsColumnsModel> mRsColumnsModels = new ArrayList<>();
//        if (metadataList != null) {
//            for (DtoResourceMetadata r : metadataList) {
//                MRsColumnsModel mRsColumnsModel = new MRsColumnsModel();
//                if (!isOtherVersion) {
//                    mRsColumnsModel.setValue(r.getName());
//                    if (!StringUtils.isEmpty(r.getDictCode())) {
//                        mRsColumnsModel.setCode(r.getId() + "_VALUE");
//                    } else {
//                        mRsColumnsModel.setCode(r.getId());
//                    }
//                    mRsColumnsModel.setType(r.getColumnType());
//                    mRsColumnsModel.setDict(r.getDictCode());
//                } else {
////                    String name = stdTransformClient.stdMetadataName(version, code, correspondMap.get(r.getId()));
////                    if (!StringUtils.isEmpty(name)) {
////                        mRsColumnsModel.setValue(name);
////                        if (!StringUtils.isEmpty(r.getDictCode())) {
////                            mRsColumnsModel.setCode(r.getId() + "_VALUE");
////                        } else {
////                            mRsColumnsModel.setCode(r.getId());
////                        }
////                        mRsColumnsModel.setType(r.getColumnType());
////                        mRsColumnsModel.setDict(r.getDictCode());
////                    }
//                }
//                mRsColumnsModels.add(mRsColumnsModel);
//            }
//        }
//        return mRsColumnsModels;
//    }
//
//    /**
//     * 资源浏览 - 资源数据
//     *
//     * @param resourcesCode
//     * @param roleId
//     * @param orgCode
//     * @param areaCode
//     * @param queryCondition
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
////    public Envelop getResourceData(String resourcesCode, String roleId, String orgCode, String areaCode, String queryCondition, Integer page, Integer size) throws Exception {
////        String queryParams = "";
////        //获取资源信息
////        List<QueryCondition> ql = new ArrayList<>();
////        //设置参数
////        if (!StringUtils.isEmpty(queryCondition)) {
////            ql = parseCondition(queryCondition);
////        }
////        queryParams = addParams(queryParams, "q", solrQuery.conditionToString(ql));
////        return getResultData(resourcesCode, roleId, orgCode, areaCode, queryParams, page, size);
////    }
//
//    /**
//     * 获取结果集
//     *
//     * @param resourcesCode
//     * @param roleId
//     * @param orgCode
//     * @param areaCode
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
//    public Envelop 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();
//            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);
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * 资源浏览 -- 资源数据元结构
     *
     * @param resourcesCode
     * @param roleId
     * @return
     * @throws Exception
     */
    public List<MRsColumnsModel> getResourceMetadata(String resourcesCode, String roleId) throws Exception {
        RsResource rsResource = rsResourceService.getResourceByCategory(resourcesCode,"standard");
        if (rsResource == null) {
            return null;
        }
        Map<String, String> correspondMap = new HashMap<>();
        boolean isOtherVersion = false;
        String version = "";
        String code = "";
        if (resourcesCode.split("\\$").length > 1) {
            isOtherVersion = true;
            version = resourcesCode.split("\\$")[1];
            code = resourcesCode.split("\\$")[0];
        }
        List<DtoResourceMetadata> metadataList = resourceBrowseDao.getAccessMetadata(rsResource, roleId, correspondMap);
        //资源结构
        List<MRsColumnsModel> mRsColumnsModels = new ArrayList<>();
        if (metadataList != null) {
            for (DtoResourceMetadata r : metadataList) {
                MRsColumnsModel mRsColumnsModel = new MRsColumnsModel();
                if (!isOtherVersion) {
                    mRsColumnsModel.setValue(r.getName());
                    if (!StringUtils.isEmpty(r.getDictCode())) {
                        mRsColumnsModel.setCode(r.getId() + "_VALUE");
                    } else {
                        mRsColumnsModel.setCode(r.getId());
                    }
                    mRsColumnsModel.setType(r.getColumnType());
                    mRsColumnsModel.setDict(r.getDictCode());
                } else {
//                    String name = stdTransformClient.stdMetadataName(version, code, correspondMap.get(r.getId()));
//                    if (!StringUtils.isEmpty(name)) {
//                        mRsColumnsModel.setValue(name);
//                        if (!StringUtils.isEmpty(r.getDictCode())) {
//                            mRsColumnsModel.setCode(r.getId() + "_VALUE");
//                        } else {
//                            saas.append(" OR org_area:" + item);
//                            mRsColumnsModel.setCode(r.getId());
//                        }
//                    });
//                }
//                if (saas.length() > 0) {
//                    saas.append(")");
//                } else {
//                    throw new ApiException( "无SAAS权限访问资源",ErrorCode.FORBIDDEN.value());
//                }
//            }
//            String method = rsResources.getRsInterface();
//            Class clazz = resourceBrowseDao.getClass();
//            Method _method = clazz.getMethod(method, new Class[]{String.class, String.class, String.class, String.class, Integer.class, Integer.class});
//            _method.setAccessible(true);
//            return (Envelop) _method.invoke(resourceBrowseDao, resourcesCode, roleId, saas.toString(), queryParams, page, size);
//        }
//        throw new ApiException( "无相关资源",ErrorCode.OBJECT_NOT_FOUND.value());
//    }
//
//    /**
//     * 获取hbase细表数据
//     *
//     * @param rowKey
//     * @param version
//     * @return
//     * @throws Exception
//     */
//                        mRsColumnsModel.setType(r.getColumnType());
//                        mRsColumnsModel.setDict(r.getDictCode());
//                    }
                }
                mRsColumnsModels.add(mRsColumnsModel);
            }
        }
        return mRsColumnsModels;
    }
    /**
     * 资源浏览 - 资源数据
     *
     * @param resourcesCode
     * @param roleId
     * @param orgCode
     * @param areaCode
     * @param queryCondition
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Envelop getResourceData(String resourcesCode, String roleId, String orgCode, String areaCode, String queryCondition, Integer page, Integer size) throws Exception {
        String queryParams = "";
        //获取资源信息
        List<QueryCondition> ql = new ArrayList<>();
        //设置参数
        if (!StringUtils.isEmpty(queryCondition)) {
            ql = parseCondition(queryCondition);
        }
        queryParams = addParams(queryParams, "q", conditionToString(ql));
        return getResultData(resourcesCode, roleId, orgCode, areaCode, queryParams, page, size);
    }
    public String conditionToString(List<QueryCondition> conditions) {
        String re = "";
        String NOT = "";
        if (conditions != null && conditions.size() > 0) {
            Iterator var4 = conditions.iterator();
            while(true) {
                while(var4.hasNext()) {
                    QueryCondition condition = (QueryCondition)var4.next();
                    if (re.equals("") && NOT.equals("")) {
                        re = re + this.conditionToString(condition);
                        if (this.conditionToString(condition).indexOf("NOT") == 0) {
                            NOT = "NOT(" + re.substring(3);
                            re = "";
                        }
                    } else {
                        String var6 = condition.getLogical();
                        byte var7 = -1;
                        switch(var6.hashCode()) {
                            case 2531:
                                if (var6.equals("OR")) {
                                    var7 = 1;
                                }
                                break;
                            case 64951:
                                if (var6.equals("AND")) {
                                    var7 = 0;
                                }
                                break;
                            case 77491:
                                if (var6.equals("NOT")) {
                                    var7 = 2;
                                }
                        }
                        switch(var7) {
                            case 0:
                                re = re + " AND ";
                                break;
                            case 1:
                                re = re + " OR  ";
                                break;
                            case 2:
                                re = re + " NOT ";
                        }
                        if (this.conditionToString(condition).indexOf("NOT") == 0) {
                            if (NOT.equals("")) {
                                NOT = " NOT(" + this.conditionToString(condition).substring(3);
                                re = re.substring(0, re.length() - 5);
                            } else {
                                NOT = NOT + re.substring(re.length() - 5) + this.conditionToString(condition).substring(3, this.conditionToString(condition).length());
                                re = re.substring(0, re.length() - 5);
                            }
                        } else {
                            re = re + this.conditionToString(condition);
                            re = "(" + re + ")";
                        }
                    }
                }
                return NOT.equals("") ? re : re + NOT + ")";
            }
        } else {
            re = "*:* ";
            return NOT.equals("") ? re : re + NOT + ")";
        }
    }
    /**
     * solr语法转换
     */
    public String conditionToString(QueryCondition condition) {
        String s = "";
        String operation = condition.getOperation();
        String field = condition.getField();
        Object keyword = condition.getKeyword();
        Object[] keywords = condition.getKeywords();
        switch (operation) {
            case Operation.LIKE:
                s = field + ":*" + keyword + "*";
                break;
            case Operation.LEFTLIKE:
                s = field + ":*" + keyword + "";
                break;
            case Operation.RIGHTLIKE:
                s = field + ":" + keyword + "*";
                break;
            case Operation.RANGE: {
                if (keywords.length >= 2) {
                    s = field + ":[" + keywords[0] + " TO " + keywords[1] + "]";
                }
                break;
            }
            case Operation.NOTRANGE: {
                if (keywords.length >= 2) {
                    s = "NOT " + field + ":[" + keywords[0] + " TO " + keywords[1] + "]";
                }
                break;
            }
            case Operation.NE: {
                s = "NOT(" + field + ":" + keyword + ")";
                break;
            }
            case Operation.IN: {
                String in = "";
                if (keywords != null && keywords.length > 0) {
                    for (Object key : keywords) {
                        if (in != null && in.length() > 0) {
                            in += " OR " + field + ":" + key;
                        } else {
                            in = field + ":" + key;
                        }
                    }
                } else if (keyword != null) {
                    in = field + ":" + keyword;
                }
                s = "( " + in + " )";
                break;
            }
            case Operation.NIN: {
                String in = "";
                if (keywords != null && keywords.length > 0) {
                    for (Object key : keywords) {
                        if (in != null && in.length() > 0) {
                            in += " OR " + field + ":" + key;
                        } else {
                            in = field + ":" + key;
                        }
                    }
                } else if (keyword != null) {
                    in = field + ":" + keyword;
                }
                s = "NOT (" + in + ")";
                break;
            }
            case Operation.GT: {
                s = field + ":{" + keyword + " TO *}";
                break;
            }
            case Operation.GTE: {
                s = field + ":[" + keyword + " TO * ]";
                break;
            }
            case Operation.LT: {
                s = field + ":" + "{* TO " + keyword + "}";
                break;
            }
            case Operation.LTE: {
                s = field + ":" + "[* TO " + keyword + "]";
                break;
            }
            case Operation.EQ: {
                s = field + ":" + keyword;
                break;
            }
            default:
                s = "unknown operation";
        }
        return s;
    }
    /**
     * 获取结果集
     *
     * @param resourcesCode
     * @param roleId
     * @param orgCode
     * @param areaCode
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public PageEnvelop 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();
            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权限访问资源",ErrorCode.FORBIDDEN.value());
                }
            }
            String method = rsResources.getRsInterface();
            Class clazz = resourceBrowseDao.getClass();
            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);
        }
        throw new ApiException( "无相关资源",ErrorCode.OBJECT_NOT_FOUND.value());
    }
    /**
     * 获取hbase细表数据
     */
//    public List<Object> getSubDateByRowkey (String rowKey, String version) throws Exception {
//        //查询出所有细表的rowKey
//        List<Object> resultList = new ArrayList<>();
@ -244,282 +405,282 @@
//        resultList.addAll(resultMap.entrySet());
//        return resultList;
//    }
//
//    /**
//     * 综合查询档案数据检索
//     *
//     * @param resourcesCodes
//     * @param metaData
//     * @param orgCode
//     * @param areaCode
//     * @param queryCondition
//     * @param page
//     * @param size
//     * @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);
////    }
//
//    /**
//     * 获取主表数据
//     *
//     * @param resourcesCode
//     * @param roleId
//     * @param saas
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
    /**
     * 综合查询档案数据检索
     *
     * @param resourcesCodes
     * @param metaData
     * @param orgCode
     * @param areaCode
     * @param queryCondition
     * @param page
     * @param size
     * @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);
//    }
    /**
     * 获取主表数据
     *
     * @param resourcesCode
     * @param roleId
     * @param saas
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Envelop getEhrCenter(String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
//        return resourceBrowseDao.getEhrCenter(resourcesCode, roleId, saas, queryParams, page, size);
//    }
//
//    /**
//     * 获取细表数据
//     *
//     * @param resourcesCode
//     * @param roleId
//     * @param saas
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
    /**
     * 获取细表数据
     *
     * @param resourcesCode
     * @param roleId
     * @param saas
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Envelop getEhrCenterSub(String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
//        return resourceBrowseDao.getEhrCenterSub(resourcesCode, roleId, saas, queryParams, page, size);
//    }
//
//    /**
//     * 主表统计
//     *
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
    /**
     * 主表统计
     *
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Page<Map<String, Object>> countEhrCenter(String queryParams, Integer page, Integer size) throws Exception {
//        return resourceBrowseDao.countEhrCenter(queryParams, page, size);
//    }
//
//    /**
//     * 细表统计
//     *
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
    /**
     * 细表统计
     *
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Page<Map<String, Object>> countEhrCenterSub(String queryParams, Integer page, Integer size) throws Exception {
//        return resourceBrowseDao.countEhrCenterSub(queryParams, page, size);
//    }
//
//    /**
//     * 获取非结构化资源
//     *
//     * @param filters
//     * @param sorts
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
    /**
     * 获取非结构化资源
     *
     * @param filters
     * @param sorts
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Envelop getEhrFile(String filters, String sorts, Integer page, Integer size) throws Exception {
//        return resourceBrowseDao.getEhrFile(filters, sorts, page, size);
//    }
//
//    /**
//     * Mysql数据
//     *
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
//    public Page<Map<String, Object>> getMysqlData(String queryParams, Integer page, Integer size) throws Exception {
//        return resourceBrowseDao.getMysqlData(queryParams, page, size);
//    }
//
//    /**
//     * @param queryParams
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
    /**
     * Mysql数据
     *
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlData(String queryParams, Integer page, Integer size) throws Exception {
        return resourceBrowseDao.getMysqlData(queryParams, page, size);
    }
    /**
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
//    public Page<String> getSolrIndexs(String queryParams, Integer page, Integer size) throws Exception {
//        return resourceBrowseDao.getSolrIndexs(queryParams, page, size);
//    }
//
//    /**
//     * 查询条件转换
//     *
//     * @param queryCondition
//     * @return
//     * @throws Exception
//     */
////    private List<QueryCondition> parseCondition(String queryCondition) throws Exception {
////        List<QueryCondition> ql = new ArrayList<QueryCondition>();
////        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"));
////                if (value.indexOf(",") > 0) {
////                    ql.add(new QueryCondition(andOr, cond, field, value.split(",")));
////                } else {
////                    ql.add(new QueryCondition(andOr, cond, field, value));
////                }
////            }
////        }
////        return ql;
////    }
//
//    /**
//     * 新增参数
//     *
//     * @param oldParams
//     * @param key
//     * @param value
//     * @return
//     */
//    private String addParams(String oldParams, String key, String value) {
//        String newParam;
//        if (value.startsWith("[") && value.endsWith("]")) {
//            newParam = "\"" + key + "\":" + value;
//        } else {
//            newParam = "\"" + key + "\":\"" + value.replace("\"", "\\\"") + "\"";
    /**
     * 查询条件转换
     *
     * @param queryCondition
     * @return
     * @throws Exception
     */
    private List<QueryCondition> parseCondition(String queryCondition) throws Exception {
        List<QueryCondition> ql = new ArrayList<QueryCondition>();
        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"));
                if (value.indexOf(",") > 0) {
                    ql.add(new QueryCondition(andOr, cond, field, value.split(",")));
                } else {
                    ql.add(new QueryCondition(andOr, cond, field, value));
                }
            }
        }
        return ql;
    }
    /**
     * 新增参数
     *
     * @param oldParams
     * @param key
     * @param value
     * @return
     */
    private String addParams(String oldParams, String key, String value) {
        String newParam;
        if (value.startsWith("[") && value.endsWith("]")) {
            newParam = "\"" + key + "\":" + value;
        } else {
            newParam = "\"" + key + "\":\"" + value.replace("\"", "\\\"") + "\"";
        }
        if (oldParams != null && oldParams.length() > 3 && oldParams.startsWith("{") && oldParams.endsWith("}")) {
            return oldParams.substring(0, oldParams.length() - 1) + "," + newParam + "}";
        } else {
            return "{" + newParam + "}";
        }
    }
    /**
     * 获取档案包中数据集列表
     *
     * @param packId
     * @param version
     * @return
     * @throws Exception
     */
    public List<String> dataSetList(String packId, String version) throws Exception {
        Envelop envelop = new Envelop();
        List<String> dataSetCodes = new ArrayList<>();
        StringBuilder stringBuilder = new StringBuilder();
        if (org.apache.commons.lang.StringUtils.isNotEmpty(packId) && !"null".equals(packId)) {
            stringBuilder.append("pack_id=" + packId).append(";");
        }
        if (org.apache.commons.lang.StringUtils.isNotEmpty(version) && !"null".equals(version)) {
            stringBuilder.append("version=" + version);
        }
//        List<Map<String, Object>> list = elasticSearchUtil.list("json_archives_qc", "qc_dataset_info", stringBuilder.toString());
//        for (Map<String, Object> map : list) {
//            List<Map<String, Object>> dataSets = objectMapper.readValue(map.get("details").toString(), List.class);
//            dataSets.stream().forEach(dataSet -> {
//                String code = (String) dataSet.keySet().toArray()[0];
//                dataSetCodes.add(code);
//            });
//        }
//        if (oldParams != null && oldParams.length() > 3 && oldParams.startsWith("{") && oldParams.endsWith("}")) {
//            return oldParams.substring(0, oldParams.length() - 1) + "," + newParam + "}";
//        } else {
//            return "{" + newParam + "}";
//        }
//    }
//
//
//    /**
//     * 获取档案包中数据集列表
//     *
//     * @param packId
//     * @param version
//     * @return
//     * @throws Exception
//     */
//    public List<String> dataSetList(String packId, String version) throws Exception {
//        Envelop envelop = new Envelop();
//        List<String> dataSetCodes = new ArrayList<>();
//        StringBuilder stringBuilder = new StringBuilder();
//        if (org.apache.commons.lang.StringUtils.isNotEmpty(packId) && !"null".equals(packId)) {
//            stringBuilder.append("pack_id=" + packId).append(";");
//        }
//        if (org.apache.commons.lang.StringUtils.isNotEmpty(version) && !"null".equals(version)) {
//            stringBuilder.append("version=" + version);
//        }
//
////        List<Map<String, Object>> list = elasticSearchUtil.list("json_archives_qc", "qc_dataset_info", stringBuilder.toString());
////        for (Map<String, Object> map : list) {
////            List<Map<String, Object>> dataSets = objectMapper.readValue(map.get("details").toString(), List.class);
////            dataSets.stream().forEach(dataSet -> {
////                String code = (String) dataSet.keySet().toArray()[0];
////                dataSetCodes.add(code);
////            });
////        }
//        return dataSetCodes;
//    }
//
//
//    /**
//     * 获取结果集
//     *
//     * @param dataSets 数据集编码列表
//     * @param roleId   角色ID
//     * @param orgCode  机构编码
//     * @param areaCode 区域编码
//     * @param rowKey   查询条件
//     * @return
//     * @throws Exception
//     */
        return dataSetCodes;
    }
    /**
     * 获取结果集
     *
     * @param dataSets 数据集编码列表
     * @param roleId   角色ID
     * @param orgCode  机构编码
     * @param areaCode 区域编码
     * @param rowKey   查询条件
     * @return
     * @throws Exception
     */
//    public Envelop getResultDataList(String version, List<String> dataSets, String roleId, String orgCode, String areaCode, String rowKey) throws Exception {
//        Map<String, Object> resultMap = new HashMap<>();
//        List<Map<String, Object>> resultData = null;
@ -574,23 +735,23 @@
//
//        }
//
//        Envelop envelop = new Envelop();
//        ObjEnvelop envelop = new ObjEnvelop();
//        envelop.setStatus(200);
//        envelop.setObj(resultMap);
//        return envelop;
//    }
//
//    /**
//     * 获取结果集 (通过数据集编码)
//     *
//     * @param dataSets 数据集编码列表
//     * @param roleId   角色ID
//     * @param orgCode  机构编码
//     * @param areaCode 区域编码
//     * @param rowKey   查询条件
//     * @return
//     * @throws Exception
//     */
    /**
     * 获取结果集 (通过数据集编码)
     *
     * @param dataSets 数据集编码列表
     * @param roleId   角色ID
     * @param orgCode  机构编码
     * @param areaCode 区域编码
     * @param rowKey   查询条件
     * @return
     * @throws Exception
     */
//    public Envelop getResultByDataSets(String version, List<String> dataSets, String roleId, String orgCode, String areaCode, String rowKey) throws Exception {
//        Map<String, Object> resultMap = new HashMap<>();
//        List<Map<String, Object>> resultData = null;
@ -654,12 +815,12 @@
//        Map<String, Object> subMap = resourceBrowseDao.getEhrCenterSubMapByScan(subDatas, roleId, saas.toString(), rowKey);
//        resultMap.putAll(subMap);
//
//        Envelop envelop = new Envelop();
//        ObjEnvelop envelop = new ObjEnvelop();
//        envelop.setStatus(200);
//        envelop.setObj(resultMap);
//        return envelop;
//    }
//
//}
//
//
}

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/StdCdaTypeController.java

@ -9,7 +9,7 @@
//import com.yihu.hos.web.framework.constant.ErrorCode;
//import com.yihu.hos.web.framework.constant.SessionAttributeKeys;
//import com.yihu.hos.web.framework.model.Envelop;
//import com.yihu.hos.web.framework.util.controller.BaseUIController;
//import com.yihu.hos.web.framework.util.controller.EnvelopRestEndpoint;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
@ -28,7 +28,7 @@
//@RequestMapping(value = "/cdatype", produces = "application/json;charset=utf-8")
//@RestController
//@SessionAttributes(SessionAttributeKeys.CurrentUser)
//public class StdCdaTypeController extends BaseUIController {
//public class StdCdaTypeController extends EnvelopRestEndpoint {
//
//    @Autowired
//    private CDATypeFeginClient cDATypeFeginClient;

+ 1 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/StdRedisEndPoint.java

@ -3,7 +3,7 @@ package com.yihu.jw.basic.standard.controller;
import com.yihu.jw.basic.standard.service.redis.StdRedisService;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.svrBasic.ServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.util.thread.ContextAttributes;
import com.yihu.jw.util.thread.LocalContext;
import io.swagger.annotations.Api;

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/DictController.java

@ -32,7 +32,7 @@
//    }
//
//    @RequestMapping("/dictDialog")
//    public String resourceRestDialog(Model model, String id, String mode) {
//    public String resourceRestDialog(EnvelopRestEndpointString id, String mode) {
//        SystemDictList sdl;
//        try {
//            if ("view".equals(mode)) {
@ -53,7 +53,7 @@
//    }
//
//    @RequestMapping("/dictItemDialog")
//    public String resourceRestDetailDialog(Model model, String id, String mode, String dictName) {
//    public String resourceRestDetailDialog(EnvelopRestEndpointString id, String mode, String dictName) {
//        SystemDict sd = null;
//        try {
//            if ("view".equals(mode)) {

+ 1 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/FlowController.java

@ -90,7 +90,7 @@
//     * @return
//     */
//    @RequestMapping("/editorFlow")
//    public String editorFlow(Model model, String id) {
//    public String editorFlow(EnvelopRestEndpointString id) {
//        try {
//            ObjectMapper objectMapper = new ObjectMapper();
//            SystemServiceFlow flow = null;

+ 1 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/ParamController.java

@ -68,7 +68,7 @@
//     * 系统参数编辑界面
//     */
//    @RequestMapping("editorParam")
//    public String editorParam(Model model, String id) {
//    public String editorParam(EnvelopRestEndpointString id) {
//        try {
//            //是否编辑
//            if (id != null && id.length() > 0) {