|
@@ -1,5 +1,7 @@
|
|
|
package com.dragoninfo.dcuc.app.business.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
import cn.hutool.core.util.PageUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.dragoninfo.dcuc.app.business.IDataCatalogBusiness;
|
|
@@ -15,6 +17,7 @@ import com.dragonsoft.duceap.commons.util.UUIDUtils;
|
|
|
import com.dragonsoft.duceap.commons.util.json.JsonUtils;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
|
import org.springframework.http.HttpMethod;
|
|
@@ -26,10 +29,7 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.lang.reflect.Type;
|
|
|
import java.net.URI;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -72,9 +72,7 @@ public class DataCatalogBusinessImpl implements IDataCatalogBusiness {
|
|
|
Integer requestPageSize = dataResourceConfig.getDataResource().getRequestPageSize();
|
|
|
int totalPage = PageUtil.totalPage(totalCount, requestPageSize);
|
|
|
int reqPage = 1;
|
|
|
-
|
|
|
- appDataResourceInfoService.deleteAll();
|
|
|
- appDataItemInfoService.deleteAll();
|
|
|
+ CopyOptions ignoreNullCopyOptions = CopyOptions.create().setIgnoreNullValue(true);
|
|
|
|
|
|
do {
|
|
|
PageReqDTO pageReqDTO = new PageReqDTO();
|
|
@@ -86,32 +84,63 @@ public class DataCatalogBusinessImpl implements IDataCatalogBusiness {
|
|
|
PageDataRespDTO<DataResourceInfoDTO> pageDataRespDTO = pageOptional.get();
|
|
|
List<DataResourceInfoDTO> dataList = pageDataRespDTO.getDataList();
|
|
|
|
|
|
- List<AppDataResourceInfo> resourceInfoList = new ArrayList<>();
|
|
|
- List<AppDataItemInfo> dataItemInfoList = new ArrayList<>();
|
|
|
+ List<AppDataResourceInfo> addResourceInfoList = new ArrayList<>();
|
|
|
+ List<AppDataResourceInfo> updateResourceInfoList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<AppDataItemInfo> addDataItemInfoList = new ArrayList<>();
|
|
|
+ List<AppDataItemInfo> updateDataItemInfoList = new ArrayList<>();
|
|
|
+
|
|
|
for (DataResourceInfoDTO dataResourceInfoDTO : dataList) {
|
|
|
- AppDataResourceInfo appDataResourceInfo = dataResourceInfoDTO.parseToAppDataResourceInfo();
|
|
|
- String uuid = UUIDUtils.getUUID();
|
|
|
- appDataResourceInfo.setId(uuid);
|
|
|
- appDataResourceInfo.setDeleted(BooleanEnum.FALSE.value);
|
|
|
+ String dataObjectId = dataResourceInfoDTO.getDataObjectId();
|
|
|
+
|
|
|
+ AppDataResourceInfo appDataResourceInfo = appDataResourceInfoService.selectByDataObjectId(dataObjectId);
|
|
|
+ if (appDataResourceInfo == null) {
|
|
|
+ appDataResourceInfo = dataResourceInfoDTO.parseToAppDataResourceInfo();
|
|
|
+ String uuid = UUIDUtils.getUUID();
|
|
|
+ appDataResourceInfo.setId(uuid);
|
|
|
+ appDataResourceInfo.setDeleted(BooleanEnum.FALSE.value);
|
|
|
+ addResourceInfoList.add(appDataResourceInfo);
|
|
|
+ } else {
|
|
|
+ AppDataResourceInfo newAppDataResourceInfo = dataResourceInfoDTO.parseToAppDataResourceInfo();
|
|
|
+ BeanUtil.copyProperties(newAppDataResourceInfo, appDataResourceInfo, ignoreNullCopyOptions);
|
|
|
+ updateResourceInfoList.add(appDataResourceInfo);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- resourceInfoList.add(appDataResourceInfo);
|
|
|
List<DataResourceItemIntoDTO> dataItems = dataResourceInfoDTO.getDataItems();
|
|
|
for (DataResourceItemIntoDTO dataItem : dataItems) {
|
|
|
- AppDataItemInfo appDataItemInfo = dataItem.parseToAppDataItemInfo();
|
|
|
- appDataItemInfo.setDeleted(BooleanEnum.FALSE.value);
|
|
|
- appDataItemInfo.setResourceTableId(uuid);
|
|
|
- dataItemInfoList.add(appDataItemInfo);
|
|
|
+ String id = appDataResourceInfo.getId();
|
|
|
+ String dataItemNo = dataItem.getDataItemNo();
|
|
|
+ AppDataItemInfo appDataItemInfo = appDataItemInfoService.selectByDataItemNo(dataItemNo);
|
|
|
+ if (appDataItemInfo == null) {
|
|
|
+ appDataItemInfo = dataItem.parseToAppDataItemInfo();
|
|
|
+ appDataItemInfo.setDeleted(BooleanEnum.FALSE.value);
|
|
|
+ appDataItemInfo.setResourceTableId(id);
|
|
|
+ addDataItemInfoList.add(appDataItemInfo);
|
|
|
+ } else {
|
|
|
+ AppDataItemInfo newAppDataItemInfo = dataItem.parseToAppDataItemInfo();
|
|
|
+ BeanUtil.copyProperties(newAppDataItemInfo, appDataItemInfo, ignoreNullCopyOptions);
|
|
|
+ updateDataItemInfoList.add(appDataItemInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- appDataResourceInfoService.saveAll(resourceInfoList);
|
|
|
- appDataItemInfoService.saveAll(dataItemInfoList);
|
|
|
+ appDataResourceInfoService.saveAll(addResourceInfoList);
|
|
|
+ appDataResourceInfoService.updateAll(updateResourceInfoList);
|
|
|
+ appDataItemInfoService.saveAll(addDataItemInfoList);
|
|
|
+ appDataItemInfoService.updateAll(updateDataItemInfoList);
|
|
|
}
|
|
|
|
|
|
reqPage++;
|
|
|
} while (reqPage <= totalPage);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取总条数
|
|
|
+ *
|
|
|
+ * @return 总条数
|
|
|
+ */
|
|
|
public int getTotalCount() {
|
|
|
PageReqDTO pageReqDTO = new PageReqDTO();
|
|
|
pageReqDTO.setPage(1);
|
|
@@ -124,7 +153,12 @@ public class DataCatalogBusinessImpl implements IDataCatalogBusiness {
|
|
|
return totalCount;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 获取分页信息
|
|
|
+ *
|
|
|
+ * @param pageReqDTO 分页请求信息
|
|
|
+ * @return 分页信息
|
|
|
+ */
|
|
|
public Optional<PageDataRespDTO<DataResourceInfoDTO>> getPage(PageReqDTO pageReqDTO) {
|
|
|
String url = dataResourceConfig.getDataResource().getDataCatalogUrl() + CATALOG_LIST_URL;
|
|
|
log.info("Request dataCatalog page info:{} ", JsonUtils.toJSONString(pageReqDTO));
|
|
@@ -148,8 +182,16 @@ public class DataCatalogBusinessImpl implements IDataCatalogBusiness {
|
|
|
return Optional.ofNullable(baseResp.getResultData());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取资源信息
|
|
|
+ *
|
|
|
+ * @param paramMap 请求参数 请求参数
|
|
|
+ * @param type 类型 类型
|
|
|
+ * @param <T> 泛型
|
|
|
+ * @return 资源信息
|
|
|
+ */
|
|
|
@Override
|
|
|
- public <T> T getDataResource(Map<String,Object> paramMap, Type type) {
|
|
|
+ public <T> T getDataResource(Map<String, Object> paramMap, Type type) {
|
|
|
String url = dataResourceConfig.getDataResource().getDataCatalogUrl() + RESOURCE_TYPE;
|
|
|
|
|
|
String response = HttpUtil.postJSON(url, JSON.toJSONString(paramMap), null, null);
|