StandardController.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. package com.yihu.hos.standard.controller;
  2. import com.yihu.hos.core.constants.MicroServices;
  3. import com.yihu.hos.standard.model.standard.DataSetModel;
  4. import com.yihu.hos.standard.model.standard.StdDataSetModel;
  5. import com.yihu.hos.standard.model.standard.resultModel.StandardParamResultModel;
  6. import com.yihu.hos.standard.service.standard.StandardService;
  7. import com.yihu.hos.web.framework.constant.SqlConstants;
  8. import com.yihu.hos.web.framework.model.DetailModelResult;
  9. import com.yihu.hos.web.framework.model.DictionaryResult;
  10. import com.yihu.hos.web.framework.model.Envelop;
  11. import com.yihu.hos.web.framework.model.Result;
  12. import com.yihu.hos.web.framework.model.standard.StandardVersion;
  13. import com.yihu.hos.web.framework.util.controller.BaseController;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import io.swagger.annotations.ApiParam;
  17. import org.apache.commons.lang.StringUtils;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RequestMethod;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import javax.annotation.Resource;
  23. import java.io.IOException;
  24. import java.util.ArrayList;
  25. import java.util.List;
  26. @RestController("StandardController")
  27. @RequestMapping(MicroServices.ApiVersion.Version1_0 + "/admin/std")
  28. @Api(protocols = "https", value = "StandardController", description = "标准管理", tags = {"标准"})
  29. public class StandardController extends BaseController {
  30. @Resource(name = StandardService.BEAN_ID)
  31. private StandardService standardService;
  32. @RequestMapping(value = "/data_sets", method = RequestMethod.GET)
  33. @ApiOperation(value = "查询数据集的方法")
  34. public Envelop getDataSets(
  35. @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
  36. @RequestParam(value = "fields", required = false) String fields,
  37. @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
  38. @RequestParam(value = "filters", required = false) String filters,
  39. @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
  40. @RequestParam(value = "sorts", required = false) String sorts,
  41. @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
  42. @RequestParam(value = "size", required = false) int size,
  43. @ApiParam(name = "page", value = "页码", defaultValue = "1")
  44. @RequestParam(value = "page", required = false) int page,
  45. @ApiParam(name = "version", value = "版本", defaultValue = "")
  46. @RequestParam(value = "version") String version) throws IOException {
  47. List<StdDataSetModel> responseEntity = standardService.searchPage(StdDataSetModel.class, StandardVersion.DataSetTable,version, filters, sorts, page, size,true);
  48. List<StdDataSetModel> all = standardService.searchPage(StdDataSetModel.class, StandardVersion.DataSetTable,version, filters, sorts, null, null,true);
  49. Long count = Long.valueOf(all.size());
  50. //使用该方法后, id属性转换失败
  51. // List<DataSetModel> dataSetModelList11 = (List<DataSetModel>) convertToModels(responseEntity, new ArrayList<DataSetModel>(responseEntity.size()), DataSetModel.class, null);
  52. List<DataSetModel> dataSetModelList = new ArrayList<>();
  53. if(responseEntity!=null){
  54. for(StdDataSetModel data:responseEntity){
  55. DataSetModel dataSetModel = new DataSetModel();
  56. dataSetModel.setId(data.getId());
  57. dataSetModel.setCode(data.getCode());
  58. dataSetModel.setName(data.getName());
  59. dataSetModel.setSummary(data.getSummary());
  60. dataSetModelList.add(dataSetModel);
  61. }
  62. }
  63. // List<DataSetModel> dataSetModels = new ArrayList<>();
  64. // for(DataSetModel dataSetModel:dataSetModelList){
  65. // String reference = dataSetModel.getReference();
  66. // if (!StringUtils.isEmpty(reference)){
  67. // MStdSource mStdSource = stdSourcrClient.getStdSource(reference);
  68. // dataSetModel.setReferenceCode(mStdSource == null ? "" : mStdSource.getInnerCode());
  69. // }
  70. // dataSetModels.add(dataSetModel);
  71. // }
  72. Envelop envelop = getResult(dataSetModelList,count.intValue(), page, size);
  73. return envelop;
  74. }
  75. /**
  76. * 查询集成标准首页信息(get)
  77. * @param condition
  78. * @return
  79. * @throws Exception
  80. */
  81. @RequestMapping(value = "/searchStandard", produces = "application/json", method = RequestMethod.GET)
  82. @ApiOperation(value = "获取标准树列表", response = DetailModelResult.class, responseContainer = "List", notes = "获取标准列表")
  83. public DetailModelResult searchStandard(
  84. @ApiParam(name = "condition", value = "查询条件name:厂商、标准、标准版本名称,标准类别type:0为集成标准,1为应用标准")
  85. @RequestParam(value = "condition", required = false) String condition) {
  86. return standardService.getDetailModelResult(condition);
  87. }
  88. /**
  89. * 获取集成标准系统参数
  90. * @return
  91. * @throws Exception
  92. */
  93. @RequestMapping(value = "/getSysParamList", produces = "application/json", method = RequestMethod.GET)
  94. @ApiOperation(value = "获取集成标准系统参数", response = StandardParamResultModel.class, notes = "获取集成标准系统参数")
  95. public StandardParamResultModel getSysParamList() {
  96. StandardParamResultModel standardParamResultModel = standardService.getStandardParam(SqlConstants.STANDARD);
  97. return standardParamResultModel;
  98. }
  99. /**
  100. * 根据标准ID获取集成标准信息(get)
  101. * @param standardId
  102. * @return
  103. * @throws Exception
  104. */
  105. @RequestMapping(value = "/getForStandardId", produces = "application/json", method = RequestMethod.GET)
  106. @ApiOperation(value = "获取标准", response = Object.class, produces = "application/json", notes = "获取标准")
  107. public Object getForStandardId(
  108. @ApiParam(name = "standardId", value = "标准ID")
  109. @RequestParam(value = "standardId") Long standardId){
  110. return standardService.get(standardId);
  111. }
  112. /**
  113. * 修改标准信息(PUT)
  114. * @param standard
  115. * @return
  116. * @throws Exception
  117. */
  118. @RequestMapping(value = "/updateStandard", produces = "application/json", method = RequestMethod.POST)
  119. @ApiOperation(value = "修改标准", response = Object.class, produces = "application/json", notes = "修改标准")
  120. public Object modify(
  121. @ApiParam(name = "standard", value = "标准基本信息")
  122. @RequestParam(value = "standard") String standard) {
  123. return standardService.update(standard);
  124. }
  125. /**
  126. * 新增标准信息(POST)
  127. * @param standard
  128. * @return
  129. * @throws Exception
  130. */
  131. @RequestMapping(value = "/addStandard", produces = "application/json", method = RequestMethod.POST)
  132. @ApiOperation(value = "保存标准", response = Result.class, produces = "application/json", notes = "保存标准")
  133. public Object add(
  134. @ApiParam(name = "standard", value = "标准基本信息")
  135. @RequestParam(value = "standard") String standard) {
  136. return standardService.add(standard);
  137. }
  138. /**
  139. * 删除标准信息(DELETE)
  140. * @param standardId
  141. * @return
  142. * @throws Exception
  143. */
  144. @RequestMapping("/deleteStandard")
  145. @ApiOperation(value = "删除标准", response = Object.class, produces = "application/json", notes = "删除标准")
  146. public Object delete(
  147. @ApiParam(name = "standardId", value = "标准ID")
  148. @RequestParam(value = "standardId") Long standardId) {
  149. return standardService.delete(standardId);
  150. }
  151. /**
  152. * 获取平台标准名称/应用标准名称列表
  153. * @param condition
  154. * @return
  155. * @throws Exception
  156. */
  157. @RequestMapping(value = "/getStandards", method = RequestMethod.GET)
  158. @ApiOperation(value = "获取标准列表", response = DictionaryResult.class, produces = "application/json", notes = "获取标准列表")
  159. public DictionaryResult getStandardList(
  160. @ApiParam(name = "condition", value = "Must be Json,其中type为区分集成与应用标准")
  161. @RequestParam(value = "condition", required = false) String condition,
  162. @ApiParam(name = "order", value = "Must be Json")
  163. @RequestParam(value = "order", required = false) String order,
  164. @ApiParam(name = "rows", value = "Limit the size of result set. Must be an integer")
  165. @RequestParam(value = "rows", required = false) Integer rows,
  166. @ApiParam(name = "page", value = "Start position of result set. Must be an integer")
  167. @RequestParam(value = "page", required = false) Integer page) {
  168. DictionaryResult dictionaryResult = standardService.getDictionaryResult(condition, order, rows, page);
  169. return dictionaryResult;
  170. }
  171. /**
  172. * 根据orgCode获取std_info 表数据(单条)
  173. * @param orgCode
  174. * @return
  175. * @throws Exception
  176. */
  177. @RequestMapping(value = "/getStandByOrgCode", method = RequestMethod.GET)
  178. @ApiOperation(value = "获取标准列表", response = DictionaryResult.class, produces = "application/json", notes = "根据orgCode获取std_info 表数据(单条)")
  179. public Envelop getStandByOrgCode(@ApiParam(value="机构code")
  180. @RequestParam(value = "orgCode", required = true) String orgCode){
  181. return standardService.getStandByOrgCode(orgCode);
  182. }
  183. @RequestMapping(value = "/getLastStandByOrgCode", method = RequestMethod.GET)
  184. @ApiOperation(value = "获取某个机构已发布的最新版本号", response = DictionaryResult.class, notes = "获取某个机构已发布的最新版本号")
  185. public String getLastStandByOrgCode(@ApiParam(value="机构code")
  186. @RequestParam(value = "orgCode") String orgCode){
  187. String ver = standardService.getLastStandByOrgCode(orgCode);
  188. if(StringUtils.isBlank(ver)){
  189. return "";
  190. }
  191. return ver;
  192. }
  193. }