package com.yihu.hos.standard.controller; import com.yihu.hos.core.constants.MicroServices; import com.yihu.hos.standard.model.standard.DataSetModel; import com.yihu.hos.standard.model.standard.StdDataSetModel; import com.yihu.hos.standard.model.standard.resultModel.StandardParamResultModel; import com.yihu.hos.standard.service.standard.StandardService; import com.yihu.hos.web.framework.constant.SqlConstants; import com.yihu.hos.web.framework.model.DetailModelResult; import com.yihu.hos.web.framework.model.DictionaryResult; import com.yihu.hos.web.framework.model.Envelop; import com.yihu.hos.web.framework.model.Result; import com.yihu.hos.web.framework.model.standard.StandardVersion; 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 org.apache.commons.lang.StringUtils; 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.annotation.Resource; import java.io.IOException; import java.util.ArrayList; import java.util.List; @RestController("StandardController") @RequestMapping(MicroServices.ApiVersion.Version1_0 + "/admin/std") @Api(protocols = "https", value = "StandardController", description = "标准管理", tags = {"标准"}) public class StandardController extends BaseController { @Resource(name = StandardService.BEAN_ID) private StandardService standardService; @RequestMapping(value = "/data_sets", method = RequestMethod.GET) @ApiOperation(value = "查询数据集的方法") public Envelop getDataSets( @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "") @RequestParam(value = "fields", required = false) String fields, @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "") @RequestParam(value = "filters", required = false) String filters, @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "") @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, @ApiParam(name = "version", value = "版本", defaultValue = "") @RequestParam(value = "version") String version) throws IOException { List responseEntity = standardService.searchPage(StdDataSetModel.class, StandardVersion.DataSetTable,version, filters, sorts, page, size,true); List all = standardService.searchPage(StdDataSetModel.class, StandardVersion.DataSetTable,version, filters, sorts, null, null,true); Long count = Long.valueOf(all.size()); //使用该方法后, id属性转换失败 // List dataSetModelList11 = (List) convertToModels(responseEntity, new ArrayList(responseEntity.size()), DataSetModel.class, null); List dataSetModelList = new ArrayList<>(); if(responseEntity!=null){ for(StdDataSetModel data:responseEntity){ DataSetModel dataSetModel = new DataSetModel(); dataSetModel.setId(data.getId()); dataSetModel.setCode(data.getCode()); dataSetModel.setName(data.getName()); dataSetModel.setSummary(data.getSummary()); dataSetModelList.add(dataSetModel); } } // List dataSetModels = new ArrayList<>(); // for(DataSetModel dataSetModel:dataSetModelList){ // String reference = dataSetModel.getReference(); // if (!StringUtils.isEmpty(reference)){ // MStdSource mStdSource = stdSourcrClient.getStdSource(reference); // dataSetModel.setReferenceCode(mStdSource == null ? "" : mStdSource.getInnerCode()); // } // dataSetModels.add(dataSetModel); // } Envelop envelop = getResult(dataSetModelList,count.intValue(), page, size); return envelop; } /** * 查询集成标准首页信息(get) * @param condition * @return * @throws Exception */ @RequestMapping(value = "/searchStandard", produces = "application/json", method = RequestMethod.GET) @ApiOperation(value = "获取标准树列表", response = DetailModelResult.class, responseContainer = "List", notes = "获取标准列表") public DetailModelResult searchStandard( @ApiParam(name = "condition", value = "查询条件name:厂商、标准、标准版本名称,标准类别type:0为集成标准,1为应用标准") @RequestParam(value = "condition", required = false) String condition) { return standardService.getDetailModelResult(condition); } /** * 获取集成标准系统参数 * @return * @throws Exception */ @RequestMapping(value = "/getSysParamList", produces = "application/json", method = RequestMethod.GET) @ApiOperation(value = "获取集成标准系统参数", response = StandardParamResultModel.class, notes = "获取集成标准系统参数") public StandardParamResultModel getSysParamList() { StandardParamResultModel standardParamResultModel = standardService.getStandardParam(SqlConstants.STANDARD); return standardParamResultModel; } /** * 根据标准ID获取集成标准信息(get) * @param standardId * @return * @throws Exception */ @RequestMapping(value = "/getForStandardId", produces = "application/json", method = RequestMethod.GET) @ApiOperation(value = "获取标准", response = Object.class, produces = "application/json", notes = "获取标准") public Object getForStandardId( @ApiParam(name = "standardId", value = "标准ID") @RequestParam(value = "standardId") Long standardId){ return standardService.get(standardId); } /** * 修改标准信息(PUT) * @param standard * @return * @throws Exception */ @RequestMapping(value = "/updateStandard", produces = "application/json", method = RequestMethod.POST) @ApiOperation(value = "修改标准", response = Object.class, produces = "application/json", notes = "修改标准") public Object modify( @ApiParam(name = "standard", value = "标准基本信息") @RequestParam(value = "standard") String standard) { return standardService.update(standard); } /** * 新增标准信息(POST) * @param standard * @return * @throws Exception */ @RequestMapping(value = "/addStandard", produces = "application/json", method = RequestMethod.POST) @ApiOperation(value = "保存标准", response = Result.class, produces = "application/json", notes = "保存标准") public Object add( @ApiParam(name = "standard", value = "标准基本信息") @RequestParam(value = "standard") String standard) { return standardService.add(standard); } /** * 删除标准信息(DELETE) * @param standardId * @return * @throws Exception */ @RequestMapping("/deleteStandard") @ApiOperation(value = "删除标准", response = Object.class, produces = "application/json", notes = "删除标准") public Object delete( @ApiParam(name = "standardId", value = "标准ID") @RequestParam(value = "standardId") Long standardId) { return standardService.delete(standardId); } /** * 获取平台标准名称/应用标准名称列表 * @param condition * @return * @throws Exception */ @RequestMapping(value = "/getStandards", method = RequestMethod.GET) @ApiOperation(value = "获取标准列表", response = DictionaryResult.class, produces = "application/json", notes = "获取标准列表") public DictionaryResult getStandardList( @ApiParam(name = "condition", value = "Must be Json,其中type为区分集成与应用标准") @RequestParam(value = "condition", required = false) String condition, @ApiParam(name = "order", value = "Must be Json") @RequestParam(value = "order", required = false) String order, @ApiParam(name = "rows", value = "Limit the size of result set. Must be an integer") @RequestParam(value = "rows", required = false) Integer rows, @ApiParam(name = "page", value = "Start position of result set. Must be an integer") @RequestParam(value = "page", required = false) Integer page) { DictionaryResult dictionaryResult = standardService.getDictionaryResult(condition, order, rows, page); return dictionaryResult; } /** * 根据orgCode获取std_info 表数据(单条) * @param orgCode * @return * @throws Exception */ @RequestMapping(value = "/getStandByOrgCode", method = RequestMethod.GET) @ApiOperation(value = "获取标准列表", response = DictionaryResult.class, produces = "application/json", notes = "根据orgCode获取std_info 表数据(单条)") public Envelop getStandByOrgCode(@ApiParam(value="机构code") @RequestParam(value = "orgCode", required = true) String orgCode){ return standardService.getStandByOrgCode(orgCode); } @RequestMapping(value = "/getLastStandByOrgCode", method = RequestMethod.GET) @ApiOperation(value = "获取某个机构已发布的最新版本号", response = DictionaryResult.class, notes = "获取某个机构已发布的最新版本号") public String getLastStandByOrgCode(@ApiParam(value="机构code") @RequestParam(value = "orgCode") String orgCode){ String ver = standardService.getLastStandByOrgCode(orgCode); if(StringUtils.isBlank(ver)){ return ""; } return ver; } }