123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- package com.yihu.hos.standard.controller;
- import com.yihu.hos.config.JsonDateValueProcessor;
- import com.yihu.hos.core.constants.MicroServices;
- import com.yihu.hos.standard.model.adapter.*;
- import com.yihu.hos.standard.service.adapter.*;
- import com.yihu.hos.web.framework.model.standard.AdapterVersion;
- import com.yihu.hos.web.framework.util.controller.BaseController;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import net.sf.json.JSONArray;
- import net.sf.json.JsonConfig;
- import org.apache.commons.collections.CollectionUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.MediaType;
- import org.springframework.jdbc.core.JdbcTemplate;
- 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 javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.text.ParseException;
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.Date;
- import java.util.List;
- @RestController("AdapterCenterEndPoint")
- @RequestMapping(value = MicroServices.ApiVersion.Version1_0+"/adapterCenter")
- @Api(protocols = "https", description = "适配数据管理", tags = {"适配数据管理"})
- public class AdapterCenterEndPoint extends BaseController {
- @Autowired
- private AdapterSchemeService adapterSchemeService;
- @Autowired
- private AdapterSchemeVersionService adapterSchemeVersionService;
- @Autowired
- private AdapterDatasetService adapterDatasetService;
- @Autowired
- private AdapterMetadataService adapterMetadataService;
- @Autowired
- private AdapterDictService adapterDictService;
- @Autowired
- private AdapterDictEntryService adapterDictEntryService;
- @Autowired
- private JdbcTemplate jdbcTemplate;
- @RequestMapping(value="/schema/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "获取版本号列表", produces = "application/json", notes = "获取版本号列表")
- public String getSchema(@ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters) throws ParseException {
- List<AdapterSchemeModel> schema = adapterSchemeService.search(null, filters, null, null, null);
- JSONArray json = JSONArray.fromObject(schema);
- return json.toString();
- }
- @RequestMapping(value="/version/list", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "获取版本号列表", produces = "application/json", notes = "获取版本号列表")
- public String getVersions(@ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters) throws ParseException {
- List versions = adapterSchemeVersionService.search(null, filters, null, null, null);
- JsonConfig config = new JsonConfig();
- config.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
- JSONArray json = JSONArray.fromObject(versions, config);
- return json.toString();
- }
- @RequestMapping(value="/dataset/list", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "获取适配数据集列表", produces = "application/json", notes = "获取适配数据集列表")
- public String getDatasetList(@ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters,
- @ApiParam(name = "version", value = "版本", defaultValue = "")
- @RequestParam(value = "version") String version) throws IOException {
- List<AdapterDatasetModel> list = adapterDatasetService.searchPage(AdapterDatasetModel.class, AdapterVersion.DataSetTablePrefix,version, filters, null, null, null,false);
- JSONArray json = JSONArray.fromObject(list);
- return json.toString();
- }
- @RequestMapping(value = "/metadata/list", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "获取适配数据元列表", produces = "application/json", notes = "获取适配数据元列表")
- public String getMetadataList(@ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters,
- @ApiParam(name = "version", value = "版本", defaultValue = "")
- @RequestParam(value = "version") String version) throws IOException {
- List<AdapterMetadataModel> list = adapterMetadataService.searchPage(AdapterMetadataModel.class, AdapterVersion.MetaDataTablePrefix,version, filters, null, null, null,false);
- JSONArray json = JSONArray.fromObject(list);
- return json.toString();
- }
- @RequestMapping(value = "/dict/list", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "获取标准字典列表", produces = "application/json", notes = "获取标准字典列表")
- public String getDictList(@ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters,
- @ApiParam(name = "version", value = "版本", defaultValue = "")
- @RequestParam(value = "version") String version) throws IOException {
- List<AdapterDictModel> list = adapterDictService.searchPage(AdapterDictModel.class, AdapterVersion.DictTablePrefix,version, filters, null, null, null,false);
- JSONArray json = JSONArray.fromObject(list);
- return json.toString();
- }
- @RequestMapping(value = "/dictItem/list", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "获取标准字典项列表", produces = "application/json", notes = "获取标准字典项列表")
- public String getDictItemList(@ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters,
- @ApiParam(name = "version", value = "版本", defaultValue = "")
- @RequestParam(value = "version") String version) throws IOException {
- List<AdapterDictEntryModel> list = adapterDictEntryService.searchPage(AdapterDictEntryModel.class, AdapterVersion.DictEntryTablePrefix,version, filters, null, null, null,false);
- JSONArray json = JSONArray.fromObject(list);
- return json.toString();
- }
- @RequestMapping(value="/dataset/pageList", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "分页获取适配数据集列表", produces = "application/json", notes = "分页获取适配数据集列表")
- public Collection<AdapterDatasetModel> datasetPageList(
- @ApiParam(name = "version", value = "版本", defaultValue = "")
- @RequestParam(value = "version") String version,
- @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
- @RequestParam(value = "fields", required = false) String fields,
- @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters,
- @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
- @RequestParam(value = "sorts", required = false) String sorts,
- @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
- @RequestParam(value = "size", required = false) int size,
- @ApiParam(name = "page", value = "页码", defaultValue = "1")
- @RequestParam(value = "page", required = false) int page,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- List<AdapterDatasetModel> ls = adapterDatasetService.searchPage(AdapterDatasetModel.class, AdapterVersion.DataSetTablePrefix,version, filters,sorts , page, size,false);
- List all = adapterMetadataService.searchPage(AdapterMetadataModel.class, AdapterVersion.MetaDataTablePrefix,version, filters, sorts, null, null,false);
- long total = Long.valueOf(all.size());
- pagedResponse(request, response, total, page, size);
- return convertToModels(ls, new ArrayList<>(ls.size()), AdapterDatasetModel.class, fields);
- }
- @RequestMapping(value="/metadata/pageList", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @ApiOperation(value = "分页获取适配数据元列表", produces = "application/json", notes = "分页获取适配数据元列表")
- public Collection<AdapterMetadataModel> metadataPageList(
- @ApiParam(name = "version", value = "版本", defaultValue = "")
- @RequestParam(value = "version") String version,
- @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
- @RequestParam(value = "fields", required = false) String fields,
- @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
- @RequestParam(value = "filters", required = false) String filters,
- @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
- @RequestParam(value = "sorts", required = false) String sorts,
- @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
- @RequestParam(value = "size", required = false) int size,
- @ApiParam(name = "page", value = "页码", defaultValue = "1")
- @RequestParam(value = "page", required = false) int page,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- List<AdapterMetadataModel> ls = adapterMetadataService.searchPage(AdapterMetadataModel.class, AdapterVersion.MetaDataTablePrefix,version, filters,sorts , page, size,false);
- List all = adapterMetadataService.searchPage(AdapterMetadataModel.class, AdapterVersion.MetaDataTablePrefix,version, filters, sorts, null, null,false);
- long total = Long.valueOf(all.size());
- pagedResponse(request, response, total, page, size);
- return convertToModels(ls, new ArrayList<>(ls.size()), AdapterMetadataModel.class, fields);
- }
- @RequestMapping(value="/last/adapterVersion" ,method = RequestMethod.GET)
- @ApiOperation(value = "获取2家机构适配的最新版本号", notes = "获取2家机构适配的最新版本号")
- public String getLastAdapterVersion(
- @ApiParam(name = "originOrgCode", value = "源机构编码[eip的机构表]如,jkzl", defaultValue = "")
- @RequestParam(value = "originOrgCode") String originOrgCode,
- @ApiParam(name = "targetOrgCode", value = "目标机构编码[eip的机构表],如上传 江西省平台的机构编码", defaultValue = "")
- @RequestParam(value = "targetOrgCode") String targetOrgCode){
- String sql = String.format("select id from adapter_scheme where adapter_publisher_org_code='%s' and std_publisher_org_code='%s'",originOrgCode,targetOrgCode);
- List<Long> idList = jdbcTemplate.queryForList(sql,Long.class);
- String version = "";
- if(CollectionUtils.isNotEmpty(idList)){
- String ids = "";
- for(Long id:idList){
- ids+=","+id;
- }
- ids = ids.substring(1,ids.length());
- List<String> versions = jdbcTemplate.queryForList("select version from adapter_scheme_version where scheme_id in ("+ids+") and publish_status=1 order by publish_time desc",String.class);
- if(CollectionUtils.isNotEmpty(versions)){
- version = versions.get(0);
- }
- }
- return version;
- }
- }
|