|
@ -2,15 +2,22 @@ package com.yihu.ehr.standard.service.adapter;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.ehr.common.Services;
|
|
|
import com.yihu.ehr.crawler.model.adapter.AdapterDataSet;
|
|
|
import com.yihu.ehr.crawler.model.flow.CrawlerFlowHeadModel;
|
|
|
import com.yihu.ehr.crawler.model.flow.CrawlerFlowModel;
|
|
|
import com.yihu.ehr.datacollect.model.DtoJobDataset;
|
|
|
import com.yihu.ehr.datacollect.model.RsJobDataset;
|
|
|
import com.yihu.ehr.framework.common.dao.SQLGeneralDAO;
|
|
|
import com.yihu.ehr.framework.constrant.Constants;
|
|
|
import com.yihu.ehr.framework.constrant.ErrorCode;
|
|
|
import com.yihu.ehr.framework.exception.ApiException;
|
|
|
import com.yihu.ehr.framework.model.ActionResult;
|
|
|
import com.yihu.ehr.framework.model.DataGridResult;
|
|
|
import com.yihu.ehr.framework.util.operator.CollectionUtil;
|
|
|
import com.yihu.ehr.framework.util.operator.StringUtil;
|
|
|
import com.yihu.ehr.resource.model.RsDatasourceDataset;
|
|
|
import com.yihu.ehr.resource.service.IStdService;
|
|
|
import com.yihu.ehr.standard.model.adapter.AdapterDatasetModel;
|
|
|
import com.yihu.ehr.standard.model.adapter.AdapterSchemeModel;
|
|
|
import com.yihu.ehr.standard.model.adapter.AdapterSchemeVersionModel;
|
|
@ -23,6 +30,7 @@ import org.hibernate.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@ -38,6 +46,10 @@ public class AdapterSchemeService extends SQLGeneralDAO {
|
|
|
|
|
|
public static final String BEAN_ID = "AdapterSchemeService";
|
|
|
|
|
|
@Resource(name = Services.StdService)
|
|
|
private IStdService stdManager;
|
|
|
|
|
|
|
|
|
public AdapterSchemeModel add(String scheme) {
|
|
|
Boolean existFlg = false;
|
|
|
try {
|
|
@ -330,6 +342,52 @@ public class AdapterSchemeService extends SQLGeneralDAO {
|
|
|
return adapterDataSet;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存编排映射关系
|
|
|
* @param schemeId 适配方案ID
|
|
|
* @param version 适配方案版本
|
|
|
* @param json 映射数据
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public ActionResult saveDataSetRelation(Integer schemeId,String version,String json) throws Exception {
|
|
|
JSONObject root = JSONObject.fromObject(json);
|
|
|
JSONArray jsonList = root.getJSONArray("lines");
|
|
|
JSONArray entrances = root.getJSONArray("entrances");
|
|
|
String adapterVersionHql = "FROM AdapterSchemeVersionModel WHERE schemeId = :schemeId and version = :version";
|
|
|
Query query = getCurrentSession().createQuery(adapterVersionHql);
|
|
|
query.setParameter("schemeId", schemeId);
|
|
|
query.setParameter("version", version);
|
|
|
AdapterSchemeVersionModel versionModel =(AdapterSchemeVersionModel) query.uniqueResult();
|
|
|
for (Object item : jsonList) {
|
|
|
JSONObject obj = JSONObject.fromObject(item);
|
|
|
String from = obj.getString("from");
|
|
|
String to = obj.getString("to");
|
|
|
String fromPort = obj.getString("fromPort");
|
|
|
String toPort = obj.getString("toPort");
|
|
|
//TODO 保存编排关系
|
|
|
CrawlerFlowModel crawlerFlow=new CrawlerFlowModel();
|
|
|
crawlerFlow.setDatasetCode(to);
|
|
|
crawlerFlow.setInputDatasetCode(from);
|
|
|
crawlerFlow.setMetadataCode(toPort);
|
|
|
crawlerFlow.setInputMetadataCode(fromPort);
|
|
|
crawlerFlow.setSchemeVersionId(versionModel.getId());
|
|
|
saveEntity(crawlerFlow);
|
|
|
}
|
|
|
|
|
|
for (Object item : entrances) {
|
|
|
JSONObject obj = JSONObject.fromObject(item);
|
|
|
String dataSet = obj.getString("dataSet");
|
|
|
String meta = obj.getString("meta");
|
|
|
//TODO 保存入口数据集
|
|
|
CrawlerFlowHeadModel headModel=new CrawlerFlowHeadModel();
|
|
|
headModel.setSchemeVersionId(versionModel.getId());
|
|
|
headModel.setDatasetCode(dataSet);
|
|
|
headModel.setMetadataCode(meta);
|
|
|
saveEntity(headModel);
|
|
|
}
|
|
|
return new ActionResult(true, "保存成功!");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|