|
@ -40,6 +40,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@ -398,12 +399,6 @@ public class AdapterDatasetService extends SQLGeneralDAO {
|
|
public ListEnvelop getDatasetCustomize(String adapterVersion, String stdVersion) {
|
|
public ListEnvelop getDatasetCustomize(String adapterVersion, String stdVersion) {
|
|
try {
|
|
try {
|
|
List<TreeView> treeViewList = getAdapterCustomize(adapterVersion);
|
|
List<TreeView> treeViewList = getAdapterCustomize(adapterVersion);
|
|
|
|
|
|
// List<TreeView> treeViewList = new ArrayList<>();
|
|
|
|
// List<Long> hasCheckDatasetIdList = new ArrayList<>();
|
|
|
|
// List<Long> hasCheckMetadataIdList = new ArrayList<>();
|
|
|
|
// getAdapterCustomize(adapterVersion, treeViewList, hasCheckDatasetIdList, hasCheckMetadataIdList);
|
|
|
|
// getStdCustomize(stdVersion, treeViewList, hasCheckDatasetIdList, hasCheckMetadataIdList);
|
|
|
|
ListEnvelop detailModelResult = ListEnvelop.getSuccess("获取定制数据集列表成功",treeViewList);
|
|
ListEnvelop detailModelResult = ListEnvelop.getSuccess("获取定制数据集列表成功",treeViewList);
|
|
return detailModelResult;
|
|
return detailModelResult;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@ -436,7 +431,7 @@ public class AdapterDatasetService extends SQLGeneralDAO {
|
|
}
|
|
}
|
|
|
|
|
|
if (newDatasetIdList.size() == 0) {
|
|
if (newDatasetIdList.size() == 0) {
|
|
return Envelop.getError("定制内容为空");
|
|
|
|
|
|
return Envelop.getError("定制数据集失败");
|
|
}
|
|
}
|
|
|
|
|
|
updateDatasetCustomizeData(schemeId, aVersion, sVersion, newDatasetIdList, newMetadataIdList);
|
|
updateDatasetCustomizeData(schemeId, aVersion, sVersion, newDatasetIdList, newMetadataIdList);
|
|
@ -448,102 +443,43 @@ public class AdapterDatasetService extends SQLGeneralDAO {
|
|
}
|
|
}
|
|
|
|
|
|
public void updateDatasetCustomizeData(Long schemeId, AdapterVersion aVersion, StandardVersion sVersion, List<Long> newDatasetIdList, List<Long> newMetadataIdList) throws Exception {
|
|
public void updateDatasetCustomizeData(Long schemeId, AdapterVersion aVersion, StandardVersion sVersion, List<Long> newDatasetIdList, List<Long> newMetadataIdList) throws Exception {
|
|
List<StdMetaDataModel> metadataList = new ArrayList<StdMetaDataModel>();
|
|
|
|
if (newMetadataIdList.size() > 0) {
|
|
|
|
SqlCreator sqlCreator = new SqlCreator(StdMetaDataModel.class);
|
|
|
|
sqlCreator.inCondition("id", newMetadataIdList);
|
|
|
|
String sql = sqlCreator.selectData(sVersion.getMetaDataTableName());
|
|
|
|
metadataList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(StdMetaDataModel.class));
|
|
|
|
|
|
//首先把适配数据集和适配的数据元,字典 全部设置成不需要采集
|
|
|
|
String dataSetTableName = aVersion.getDataSetTableName();
|
|
|
|
String metaDataTableName = aVersion.getMetaDataTableName();
|
|
|
|
String dictName = aVersion.getDictTableName();
|
|
|
|
jdbcTemplate.execute("update "+dataSetTableName +" set need_crawer=0");
|
|
|
|
jdbcTemplate.execute("update "+metaDataTableName +" set need_crawer=0");
|
|
|
|
jdbcTemplate.execute("update "+dictName +" set need_crawer=0");
|
|
|
|
|
|
|
|
//设置需要采集的数据集
|
|
|
|
if(CollectionUtils.isNotEmpty(newDatasetIdList)){
|
|
|
|
String ids="";
|
|
|
|
for(Long id:newDatasetIdList){
|
|
|
|
ids+=","+id;
|
|
|
|
}
|
|
|
|
jdbcTemplate.execute("update "+dataSetTableName +" set need_crawer=1 where id in ("+ids.substring(1,ids.length())+")");
|
|
}
|
|
}
|
|
|
|
|
|
List<Long> newDictdList = new ArrayList<>();
|
|
|
|
for (StdMetaDataModel stdMetaDataModel : metadataList) {
|
|
|
|
if (stdMetaDataModel.getDictId() != null && !newDictdList.contains(stdMetaDataModel.getDictId())) {
|
|
|
|
newDictdList.add(stdMetaDataModel.getDictId());
|
|
|
|
|
|
String metadaIds = "";
|
|
|
|
//设置需要采集的数据元
|
|
|
|
if(CollectionUtils.isNotEmpty(newMetadataIdList)){
|
|
|
|
for(Long id:newMetadataIdList){
|
|
|
|
metadaIds+=","+id;
|
|
}
|
|
}
|
|
|
|
metadaIds = metadaIds.substring(1, metadaIds.length());
|
|
|
|
jdbcTemplate.execute("update "+metaDataTableName +" set need_crawer=1 where id in ("+metadaIds+")");
|
|
}
|
|
}
|
|
|
|
|
|
List<String> insertSqlList = new ArrayList<>();
|
|
|
|
// 找出新增 删除 modify by cyj
|
|
|
|
List<AdapterDatasetModel> datasetModels = selectData(aVersion.getDataSetTableName(), AdapterDatasetModel.class);
|
|
|
|
List<AdapterMetadataModel> metadataModels = selectData(aVersion.getMetaDataTableName(), AdapterMetadataModel.class);
|
|
|
|
List<AdapterDictModel> dictModels = selectData(aVersion.getDictTableName(), AdapterDictModel.class);
|
|
|
|
// List<AdapterDictEntryModel> dictEntryModels = selectData(aVersion.getDictEntryTableName(), AdapterDictEntryModel.class);
|
|
|
|
List<Long> oldDatasetIdList = new ArrayList<>();
|
|
|
|
for (AdapterDatasetModel datasetModel : datasetModels) {
|
|
|
|
oldDatasetIdList.add(datasetModel.getId());
|
|
|
|
}
|
|
|
|
List<Long> oldMetadataIdList = new ArrayList<>();
|
|
|
|
for (AdapterMetadataModel metadataModel : metadataModels) {
|
|
|
|
oldMetadataIdList.add(metadataModel.getId());
|
|
|
|
}
|
|
|
|
List<Long> oldDictIdList = new ArrayList<>();
|
|
|
|
for (AdapterDictModel dictModel : dictModels) {
|
|
|
|
oldDictIdList.add(dictModel.getId());
|
|
|
|
}
|
|
|
|
// List<Integer> oldDictEntryIdList = new ArrayList<>();
|
|
|
|
// for (AdapterDictEntryModel entryModel : dictEntryModels) {
|
|
|
|
// oldDictEntryIdList.add(entryModel.getStdDictId());
|
|
|
|
// }
|
|
|
|
Map<String, List<Long>> datasetMap = getDiffId(newDatasetIdList, oldDatasetIdList);
|
|
|
|
Map<String, List<Long>> metaMap = getDiffId(newMetadataIdList, oldMetadataIdList);
|
|
|
|
Map<String, List<Long>> dicMap = getDiffId(newDictdList, oldDictIdList);
|
|
|
|
// Map<String,List<Integer>> dicEntryMap = getDiffId(newDictdList,oldDictEntryIdList);
|
|
|
|
// add del
|
|
|
|
List<Long> delDatasetList = datasetMap.get("del");
|
|
|
|
if (delDatasetList.size() > 0) {
|
|
|
|
insertSqlList.add(delData(aVersion.getDataSetTableName(), "id", delDatasetList));
|
|
|
|
}
|
|
|
|
List<Long> delMetaList = metaMap.get("del");
|
|
|
|
if (delMetaList.size() > 0) {
|
|
|
|
insertSqlList.add(delData(aVersion.getMetaDataTableName(), "id", delMetaList));
|
|
|
|
}
|
|
|
|
List<Long> delDicList = dicMap.get("del");
|
|
|
|
if (delDicList.size() > 0) {
|
|
|
|
insertSqlList.add(delData(aVersion.getDictTableName(), "id", delDicList));
|
|
|
|
insertSqlList.add(delData(aVersion.getDictEntryTableName(), "std_dict_id", delDicList));
|
|
|
|
}
|
|
|
|
/* insertSqlList.add(SqlConstants.DELETE + SqlConstants.FROM + aVersion.getDataSetTableName());
|
|
|
|
insertSqlList.add(SqlConstants.DELETE + SqlConstants.FROM + aVersion.getMetaDataTableName());
|
|
|
|
insertSqlList.add(SqlConstants.DELETE + SqlConstants.FROM + aVersion.getDictTableName());
|
|
|
|
insertSqlList.add(SqlConstants.DELETE + SqlConstants.FROM + aVersion.getDictEntryTableName());*/
|
|
|
|
|
|
|
|
List<Long> addDataSetList = datasetMap.get("add");
|
|
|
|
if (addDataSetList.size() > 0) {
|
|
|
|
insertSqlList.add(insertData(aVersion.getDataSetTableName(), sVersion.getDataSetTableName(),
|
|
|
|
new String[]{"id,std_dataset_id,std_dataset_code,std_dataset_name"},
|
|
|
|
new String[]{"id,id,code,name"},
|
|
|
|
schemeId,
|
|
|
|
"id",
|
|
|
|
addDataSetList));
|
|
|
|
}
|
|
|
|
List<Long> addMetaList = metaMap.get("add");
|
|
|
|
if (addMetaList.size() > 0) {
|
|
|
|
insertSqlList.add(insertData(aVersion.getMetaDataTableName(), sVersion.getMetaDataTableName(),
|
|
|
|
new String[]{"id,std_metadata_id,std_metadata_code,std_metadata_name,std_dataset_id,std_dict_id"},
|
|
|
|
new String[]{"id,id,code,name,dataset_id,dict_id"},
|
|
|
|
schemeId,
|
|
|
|
"id",
|
|
|
|
addMetaList));
|
|
|
|
}
|
|
|
|
List<Long> addDicList = dicMap.get("add");
|
|
|
|
if (addDicList.size() > 0) {
|
|
|
|
insertSqlList.add(insertData(aVersion.getDictTableName(), sVersion.getDictTableName(),
|
|
|
|
new String[]{"id,std_dict_id,std_dict_code,std_dict_name"},
|
|
|
|
new String[]{"id,id,code,name"},
|
|
|
|
schemeId,
|
|
|
|
"id",
|
|
|
|
addDicList));
|
|
|
|
insertSqlList.add(insertData(aVersion.getDictEntryTableName(), sVersion.getDictEntryTableName(),
|
|
|
|
new String[]{"id,std_entry_id,std_entry_code,std_entry_value,std_dict_id"},
|
|
|
|
new String[]{"id,id,code,value,dict_id"},
|
|
|
|
schemeId,
|
|
|
|
"dict_id",
|
|
|
|
addDicList));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (insertSqlList.size() > 0) {
|
|
|
|
insertBatch(insertSqlList);
|
|
|
|
|
|
if(!StringUtils.isEmpty(metadaIds)){
|
|
|
|
//设置需要采集的字典
|
|
|
|
List<Long> dictIds = jdbcTemplate.queryForList("select DISTINCT std_dict_id from " + metaDataTableName + " where std_dict_id is not null and std_dict_id!='' and id in (" + metadaIds + ")",Long.class);
|
|
|
|
if(CollectionUtils.isNotEmpty(dictIds)){
|
|
|
|
String ids = "";
|
|
|
|
for(Long id:dictIds){
|
|
|
|
ids+=","+id;
|
|
|
|
}
|
|
|
|
jdbcTemplate.execute("update "+dictName +" set need_crawer=1 where id in ("+ids.substring(1,ids.length())+")");
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|