|
@ -0,0 +1,335 @@
|
|
|
//package com.yihu.jw.basic.standard.controller;
|
|
|
//
|
|
|
//
|
|
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
//import com.fasterxml.jackson.databind.cfg.ContextAttributes;
|
|
|
//import com.yihu.fastdfs.FastDFSUtil;
|
|
|
//import com.yihu.jw.basic.standard.model.BaseCDADataSetRelationship;
|
|
|
//import com.yihu.jw.basic.standard.model.BaseCDADocument;
|
|
|
//import com.yihu.jw.basic.standard.model.CDADocument;
|
|
|
//import com.yihu.jw.basic.standard.service.bo.StandardVersion;
|
|
|
//import com.yihu.jw.basic.standard.service.document.CDADataSetRelationshipManager;
|
|
|
//import com.yihu.jw.basic.standard.service.document.CDADocumentService;
|
|
|
//import com.yihu.jw.basic.standard.service.standard.StdCDAService;
|
|
|
//import com.yihu.jw.entity.ehr.id.BizObject;
|
|
|
//import com.yihu.jw.restmodel.ehr.standard.CDAModel;
|
|
|
//import com.yihu.jw.restmodel.ehr.standard.CdaDataSetRelationshipModel;
|
|
|
//import com.yihu.jw.restmodel.ehr.standard.MCDADocument;
|
|
|
//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.DateUtil;
|
|
|
//import com.yihu.jw.util.sql.ErrorCode;
|
|
|
//import io.swagger.annotations.ApiOperation;
|
|
|
//import io.swagger.annotations.ApiParam;
|
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
//import org.springframework.http.ResponseEntity;
|
|
|
//import org.springframework.util.StringUtils;
|
|
|
//import org.springframework.web.bind.annotation.*;
|
|
|
//
|
|
|
//import javax.annotation.Resource;
|
|
|
//import javax.servlet.http.HttpServletRequest;
|
|
|
//import java.io.BufferedReader;
|
|
|
//import java.io.File;
|
|
|
//import java.io.FileReader;
|
|
|
//import java.io.IOException;
|
|
|
//import java.util.ArrayList;
|
|
|
//import java.util.Collection;
|
|
|
//import java.util.Date;
|
|
|
//import java.util.List;
|
|
|
//
|
|
|
//
|
|
|
//@RequestMapping(value = "/cdatmp", produces = "application/json;charset=utf-8")
|
|
|
//@RestController
|
|
|
//public class StdCdaTmpController extends EnvelopRestEndpoint {
|
|
|
//
|
|
|
// @Resource(name = CDADocumentService.BEAN_ID)
|
|
|
// private CDADocumentService cdaDocumentService;
|
|
|
// @Autowired
|
|
|
// private CDADataSetRelationshipManager cdaDatasetRelationshipManager;
|
|
|
// @Autowired
|
|
|
// private FastDFSUtil fastDFSUtil;
|
|
|
// @Autowired
|
|
|
// private ObjectMapper objectMapper;
|
|
|
//
|
|
|
// @RequestMapping(value = "/cdas", method = RequestMethod.GET)
|
|
|
// @ApiOperation(value = "根据条件获取cda列表")
|
|
|
// public Envelop getCdaListByKey(
|
|
|
// @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<BaseCDADocument> ls = cdaDocumentService.searchPage(BaseCDADocument.class, StandardVersion.CDADocumentTable, version, filters, sorts, page, size,true);
|
|
|
// Long totalCount = cdaDocumentService.searchCount(BaseCDADocument.class, version, StandardVersion.CDADocumentTable, filters);
|
|
|
// Collection<MCDADocument> cdaDocumentList = convertToModels(ls, new ArrayList<>(ls.size()), MCDADocument.class, fields);
|
|
|
//
|
|
|
// ResponseEntity<Collection<MCDADocument>> responseEntity = ResponseEntity.ok().body(cdaDocumentList);
|
|
|
// cdaDocumentList = responseEntity.getBody();
|
|
|
// List<CDAModel> cdaModelList = new ArrayList<>();
|
|
|
// for (MCDADocument mcdaDocument : cdaDocumentList) {
|
|
|
// mcdaDocument.setVersionCode(version);
|
|
|
// cdaModelList.add(convertToCDAModel(mcdaDocument));
|
|
|
// }
|
|
|
// return PageEnvelop.getSuccessListWithPage("查询成功",cdaModelList, page, size, totalCount);
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// @RequestMapping(value = "/cda", method = RequestMethod.GET)
|
|
|
// @ApiOperation(value = "根据id获取cda")
|
|
|
// public Envelop getCda(
|
|
|
// @ApiParam(name = "cda_id", value = "cda_id")
|
|
|
// @RequestParam(value = "cda_id") String cdaId,
|
|
|
// @ApiParam(name = "version_code", value = "标准版本代码")
|
|
|
// @RequestParam(value = "version_code") String versionCode) {
|
|
|
// try {
|
|
|
// List<CDADocument> list = cdaDocumentService.searchPageData(BaseCDADocument.class, StandardVersion.CDADocumentTable, versionCode, "id=" + cdaId, null, null, null);
|
|
|
// Collection<MCDADocument> mcdaDocumentList = convertToModels(list, new ArrayList<>(list.size()), MCDADocument.class, "");
|
|
|
//
|
|
|
// if (mcdaDocumentList == null) {
|
|
|
// return failed("数据获取失败!");
|
|
|
// }
|
|
|
// List<CDAModel> cdaModelList = new ArrayList<>();
|
|
|
// for (MCDADocument mcdaDocument : mcdaDocumentList) {
|
|
|
// mcdaDocument.setVersionCode(versionCode);
|
|
|
// cdaModelList.add(convertToCDAModel(mcdaDocument));
|
|
|
// }
|
|
|
// return ListEnvelop.getSuccess("",cdaModelList);
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// return failed("获取失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// @RequestMapping(value = "/cda", method = RequestMethod.POST)
|
|
|
// @ApiOperation(value = "保存CDADocuments")
|
|
|
// public Envelop saveCdaInfo(
|
|
|
// @ApiParam(name = "version", value = "标准版本", defaultValue = "")
|
|
|
// @RequestParam(value = "version") String version,
|
|
|
// @ApiParam(name = "cdaInfoJson", value = "CDAJson")
|
|
|
// @RequestParam(value = "cdaInfoJson") String cdaInfoJson) {
|
|
|
// try {
|
|
|
// CDADocument cdaModel = objectMapper.readValue(cdaInfoJson, CDADocument.class);
|
|
|
// cdaModel.setStdVersion(version);
|
|
|
// BaseCDADocument model = (BaseCDADocument) cdaModel;
|
|
|
//
|
|
|
// model.setId(getObjectId(BizObject.STANDARD));
|
|
|
// model.setCreateDate(new Date());
|
|
|
// cdaDocumentService.add(version, model);
|
|
|
// model.setVersionCode(cdaModel.getVersionCode());
|
|
|
// return success(model);
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// return failed("保存失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// @RequestMapping(value = "/cda", method = RequestMethod.PUT)
|
|
|
// @ApiOperation(value = "修改CDADocuments")
|
|
|
// public Envelop updateCDADocuments(
|
|
|
// @ApiParam(name = "version", value = "标准版本", defaultValue = "")
|
|
|
// @RequestParam(value = "version") String version,
|
|
|
// @ApiParam(name = "cdaInfoJson", value = "CDAJson")
|
|
|
// @RequestParam(value = "cdaInfoJson") String cdaInfoJson) {
|
|
|
// try {
|
|
|
// CDADocument cdaModel = objectMapper.readValue(cdaInfoJson, CDADocument.class);
|
|
|
// BaseCDADocument model = (BaseCDADocument) cdaModel;
|
|
|
//
|
|
|
// model.setUpdateDate(new Date());
|
|
|
// cdaDocumentService.modify(version, model);
|
|
|
// model.setVersionCode(cdaModel.getVersionCode());
|
|
|
// return success(model);
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// return failed("修改失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// @RequestMapping(value = "/cda", method = RequestMethod.DELETE)
|
|
|
// @ApiOperation(value = "删除CDADocuments")
|
|
|
// public Envelop deleteCda(
|
|
|
// @ApiParam(name = "cdaId", value = "cdaID")
|
|
|
// @RequestParam(value = "cdaId") String cdaId,
|
|
|
// @ApiParam(name = "versionCode", value = "标准版本代码")
|
|
|
// @RequestParam(value = "versionCode") String versionCode) {
|
|
|
// String[] cdaIds = cdaId.split(",");
|
|
|
// boolean bo = cdaDocumentService.deleteByField("id", cdaIds, StandardVersion.CDADocumentTable, versionCode);
|
|
|
// if(bo){
|
|
|
// return success("删除成功");
|
|
|
// }else {
|
|
|
// return failed("删除失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// @RequestMapping(value = "/relationships", method = RequestMethod.GET)
|
|
|
// @ApiOperation(value = "根据条件获取getCDADataSetRelationship")
|
|
|
// public Envelop getRelationByCdaId(
|
|
|
// @ApiParam(name = "cdaId", value = "cdaID")
|
|
|
// @RequestParam(value = "cdaId") String cdaId,
|
|
|
// @ApiParam(name = "versionCode", value = "标准版本代码")
|
|
|
// @RequestParam(value = "versionCode") String versionCode) throws IOException {
|
|
|
// Collection<BaseCDADataSetRelationship> mcdaDocumentList = cdaDatasetRelationshipManager.searchPageData(BaseCDADataSetRelationship.class, StandardVersion.CDADatasetTable, versionCode, "cdaId=" + cdaId, null, null, null);
|
|
|
// List<CdaDataSetRelationshipModel> cdaDataSetRelationshipModels = new ArrayList<>();
|
|
|
//
|
|
|
// for (BaseCDADataSetRelationship mCdaDataSetRelationship : mcdaDocumentList) {
|
|
|
// CdaDataSetRelationshipModel cdaDataSetRelationshipModel = new CdaDataSetRelationshipModel();
|
|
|
// cdaDataSetRelationshipModel.setId(mCdaDataSetRelationship.getDataSetId());
|
|
|
// cdaDataSetRelationshipModel.setCdaId(mCdaDataSetRelationship.getCdaId());
|
|
|
// cdaDataSetRelationshipModel.setDataSetId(mCdaDataSetRelationship.getId());
|
|
|
// cdaDataSetRelationshipModels.add(cdaDataSetRelationshipModel);
|
|
|
// }
|
|
|
//
|
|
|
// if (cdaDataSetRelationshipModels != null) {
|
|
|
// return ListEnvelop.getSuccess("查询成功",cdaDataSetRelationshipModels);
|
|
|
// } else {
|
|
|
// return failed("查询失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// @RequestMapping(value = "saveRelationship", method = RequestMethod.POST)
|
|
|
// @ApiOperation(value = "保存CDADataSetRelationship")
|
|
|
// public Envelop saveRelationship(
|
|
|
// @ApiParam(name = "dataSetIds", value = "数据集ID(多ID以逗号隔开)")
|
|
|
// @RequestParam(value = "dataSetIds") String dataSetIds,
|
|
|
// @ApiParam(name = "cdaId", value = "cdaID")
|
|
|
// @RequestParam(value = "cdaId") String cdaId,
|
|
|
// @ApiParam(name = "versionCode", value = "标准版本代码")
|
|
|
// @RequestParam(value = "versionCode") String versionCode,
|
|
|
// @ApiParam(name = "xmlInfo", value = "XML文件信息")
|
|
|
// @RequestParam(value = "xmlInfo") String xmlInfo) throws Exception {
|
|
|
// boolean bo = cdaDatasetRelationshipManager.SaveDataSetRelationship(dataSetIds, cdaId, versionCode, xmlInfo);
|
|
|
// if(bo){
|
|
|
// return success("保存成功");
|
|
|
// }else {
|
|
|
// return failed("保存失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// @ApiOperation(value = "根基id删除CDADataSetRelationship")
|
|
|
// @RequestMapping(value = "/cda_data_set_relationships", method = RequestMethod.DELETE)
|
|
|
// public Envelop deleteCDADataSetRelationship(
|
|
|
// @ApiParam(name = "versionCode", value = "versionCode")
|
|
|
// @RequestParam(value = "versionCode") String versionCode,
|
|
|
// @ApiParam(name = "ids", value = "ids")
|
|
|
// @RequestParam(value = "ids") String[] ids) {
|
|
|
// boolean bo = cdaDatasetRelationshipManager.deleteRelationshipById(versionCode, ids);
|
|
|
// if(bo){
|
|
|
// return success("删除成功");
|
|
|
// }else {
|
|
|
// return failed("删除失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// @RequestMapping(value = "/file/existence/cda_id", method = RequestMethod.GET)
|
|
|
// @ApiOperation(value = "根据cdaId和versionCode判断文件是否存在")
|
|
|
// public Envelop FileExists(
|
|
|
// @ApiParam(name = "versionCode", value = "versionCode")
|
|
|
// @RequestParam(value = "versionCode") String versionCode,
|
|
|
// @ApiParam(name = "cda_id", value = "cda_id")
|
|
|
// @RequestParam(value = "cda_id") String cdaId) {
|
|
|
// boolean bo = cdaDocumentService.isFileExists(cdaId, versionCode);
|
|
|
// return ObjEnvelop.getSuccess("查询成功",bo);
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// @RequestMapping(value = "documentExist", method = RequestMethod.GET)
|
|
|
// public Object documentExist(
|
|
|
// @ApiParam(name = "code", value = "CDA代码")
|
|
|
// @RequestParam(value = "code") String code,
|
|
|
// @ApiParam(name = "versionCode", value = "标准版本代码")
|
|
|
// @PathVariable(value = "versionCode") String versionCode) {
|
|
|
// return null;
|
|
|
// }
|
|
|
//
|
|
|
// @RequestMapping(value = "/getCdaXmlFileInfo", method = RequestMethod.GET)
|
|
|
// public Envelop getCdaXmlFileInfo1(
|
|
|
// @ApiParam(name = "cdaId", value = "cdaID")
|
|
|
// @RequestParam(value = "cdaId") String cdaId,
|
|
|
// @ApiParam(name = "versionCode", value = "标准版本代码")
|
|
|
// @RequestParam(value = "versionCode") String versionCode) throws Exception {
|
|
|
// String strXmlInfo = "";
|
|
|
// String strFileGroup = "";
|
|
|
// String strSchemePath = "";
|
|
|
//
|
|
|
// String strPath = System.getProperty("java.io.tmpdir");
|
|
|
// strPath += "StandardFiles";
|
|
|
//
|
|
|
// String splitMark = System.getProperty("file.separator");
|
|
|
// String strXMLFilePath = strPath + splitMark + "xml" + splitMark + versionCode + splitMark + "downfile" + splitMark;
|
|
|
//
|
|
|
// List<String> listIds = new ArrayList<>();
|
|
|
// listIds.add(cdaId);
|
|
|
//
|
|
|
// BaseCDADocument cdaDocument = (BaseCDADocument) cdaDocumentService.get(BaseCDADocument.class, versionCode, StandardVersion.CDADocumentTable, cdaId);
|
|
|
//
|
|
|
//
|
|
|
// if (cdaDocument != null) {
|
|
|
// strFileGroup = cdaDocument.getFileGroup();
|
|
|
// strSchemePath = cdaDocument.getSchema();
|
|
|
// }
|
|
|
//
|
|
|
// File files = new File(strXMLFilePath);
|
|
|
// if (!files.exists()) {
|
|
|
// files.mkdirs();
|
|
|
// }
|
|
|
//
|
|
|
// String strLocalFileName = strXMLFilePath + "\\" + strSchemePath.replaceAll("/", "_");
|
|
|
// File localFile = new File(strLocalFileName);
|
|
|
// if (localFile.exists() && localFile.isFile()) {
|
|
|
// localFile.delete();
|
|
|
// }
|
|
|
// if (null != strFileGroup && !strFileGroup.equals("") && !strSchemePath.equals("")) {
|
|
|
// strLocalFileName = fastDFSUtil.download(strFileGroup, strSchemePath, strXMLFilePath);
|
|
|
//
|
|
|
// File file = new File(strLocalFileName);
|
|
|
// FileReader fr = new FileReader(file);
|
|
|
// BufferedReader bReader = new BufferedReader(fr);
|
|
|
// strXmlInfo = bReader.readLine();
|
|
|
// } else {
|
|
|
// strXmlInfo = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><root></root>";
|
|
|
// }
|
|
|
//
|
|
|
// if (strXmlInfo != null) {
|
|
|
// return ObjEnvelop.getSuccess("获取成功",strXmlInfo);
|
|
|
// } else {
|
|
|
// return Envelop.getError("获取cda文档XML文件信息失败");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// @RequestMapping(value = "createCDASchemaFile", method = RequestMethod.POST)
|
|
|
// @ApiOperation(value = "生成CDA文件")
|
|
|
// public Envelop createCDASchemaFile(
|
|
|
// @ApiParam(name = "versionCode", value = "versionCode")
|
|
|
// @RequestParam(value = "versionCode") String versionCode,
|
|
|
// @ApiParam(name = "cda_id", value = "cda_id")
|
|
|
// @RequestParam(value = "cda_id") String cdaId) throws Exception {
|
|
|
// boolean bo = cdaDatasetRelationshipManager.createCDASchemaFile(cdaId, versionCode);
|
|
|
// return ObjEnvelop.getSuccess("操作成功",bo);
|
|
|
// }
|
|
|
//
|
|
|
// public CDAModel convertToCDAModel(MCDADocument mcdaDocument) {
|
|
|
// CDAModel cdaModel = convertToModel(mcdaDocument, CDAModel.class);
|
|
|
// cdaModel.setCreateDate(DateUtil.dateToStr(mcdaDocument.getCreateDate(), DateUtil.YYYY_MM_DD_HH_MM));
|
|
|
// cdaModel.setUpdateDate(DateUtil.dateToStr(mcdaDocument.getUpdateDate(), DateUtil.YYYY_MM_DD_HH_MM));
|
|
|
//
|
|
|
//// MSTDVersion versionModel = versionClient.getVersion(mcdaDocument.getVersionCode());
|
|
|
//// cdaModel.setStaged(versionModel.isInStage() ? "1" : "0");
|
|
|
//
|
|
|
// return cdaModel;
|
|
|
// }
|
|
|
//
|
|
|
//}
|