|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dragoninfo.dcuc.app.business.IResourceBusiness;
|
|
|
import com.dragoninfo.dcuc.app.config.DcucResourceConfig;
|
|
|
+import com.dragoninfo.dcuc.app.cons.ServiceStatusCons;
|
|
|
import com.dragoninfo.dcuc.app.dto.*;
|
|
|
import com.dragoninfo.dcuc.app.entity.ResourceSync;
|
|
|
import com.dragoninfo.dcuc.app.enumresources.ResourceTypeEnum;
|
|
@@ -18,8 +19,10 @@ import com.dragoninfo.duceap.core.response.Result;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
import com.dragonsoft.duceap.base.utils.UserContextUtils;
|
|
|
+import com.dragonsoft.duceap.commons.util.ObjectUtils;
|
|
|
import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
|
|
|
import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.http.Header;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.message.BasicHeader;
|
|
@@ -109,6 +112,58 @@ public class ResourceBusiness implements IResourceBusiness {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean serviceIncrSync(String serviceCode) {
|
|
|
+ ServiceResourceAcceptDTO serviceDTO;
|
|
|
+ String serviceStr = null;
|
|
|
+ try {
|
|
|
+ serviceStr = getServiceRemoteDetailByCode(serviceCode);
|
|
|
+ serviceDTO = JSON.parseObject(serviceStr, ServiceResourceAcceptDTO.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.info("get service info from remote serviceStr:{}", serviceStr);
|
|
|
+ logger.error("get service info from remote error.", e);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (null == serviceDTO) {
|
|
|
+ logger.info("appIncrSync get serviceInfo is null. serviceCode is:{}", serviceCode);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ acceptServiceResource(serviceDTO);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getServiceRemoteDetailByCode(String serviceCode) {
|
|
|
+ String busSraId = resourceConfig.getBusSraId();
|
|
|
+ String busSreIdcard = resourceConfig.getBusSreIdcard();
|
|
|
+ String busServiceId = resourceConfig.getServiceModifyResource().getBusServiceId();
|
|
|
+ String busServiceFunc = resourceConfig.getServiceModifyResource().getBusServiceFunc();
|
|
|
+ List<Header> heards = getHeaders(busSraId, busSreIdcard, busServiceId, busServiceFunc);
|
|
|
+ String url = resourceConfig.getResourceUrl();
|
|
|
+ Map<String, String> param = new HashMap<>();
|
|
|
+ param.put("Condition", "FWZYBSF = '" + serviceCode + "'");
|
|
|
+ logger.info("getAppRemoteDetailByCode >> url:{}, busSraId:{}, busServiceId:{}, busServiceFunc:{}, busSreIdcard:{}, serviceCode:{}",
|
|
|
+ url, busSraId, busServiceId, busServiceFunc, busSreIdcard, serviceCode);
|
|
|
+ String response = HttpUtil.postJSON(url, JSON.toJSONString(param), heards, null);
|
|
|
+ logger.info("getServiceRemoteDetailByCode result:{}", response);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(response);
|
|
|
+ String status = jsonObject.getString("status");
|
|
|
+ if (!ResponseStatus.SUCCESS_CODE.equals(status)) {
|
|
|
+ logger.info("getServiceRemoteDetailByCode status code:{}", status);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ JSONObject o = jsonObject.getJSONObject("data").getJSONArray("Resources").getJSONObject(0);
|
|
|
+ if (ObjectUtils.isEmpty(o)) {
|
|
|
+ logger.info("getServiceRemoteDetailByCode Resources is null");
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ JSONObject dataInfo = o.getJSONObject("DataInfo");
|
|
|
+ if (ObjectUtils.isEmpty(dataInfo)) {
|
|
|
+ logger.info("getServiceRemoteDetailByCode dataInfo is null");
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return JSON.toJSONString(dataInfo);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 增量新增/更新应用资源和应用相关的菜单资源
|
|
|
*
|
|
@@ -212,7 +267,8 @@ public class ResourceBusiness implements IResourceBusiness {
|
|
|
syncDTO.setServiceName(acceptDTO.getFWZYMC());
|
|
|
syncDTO.setExtId(acceptDTO.getId());
|
|
|
syncDTO.setContent(JSON.toJSONString(acceptDTO));
|
|
|
- syncDTO.setSync(com.dragoninfo.dcuc.user.user.enumresources.YesNotEnum.YES.getValue());
|
|
|
+ syncDTO.setSync(BooleanEnum.TRUE.getValue());
|
|
|
+ syncDTO.setDeleted(BooleanEnum.FALSE.getValue());
|
|
|
syncService.insertRemoteResourceSync(syncDTO);
|
|
|
//同步更新服务表
|
|
|
ServiceResourceDTO serviceResourceDTO = convertToServiceDTO(acceptDTO);
|
|
@@ -230,7 +286,12 @@ public class ResourceBusiness implements IResourceBusiness {
|
|
|
dto.setBuildUnitCode(acceptDTO.getFWZYGLDW_GAJGJGDM());
|
|
|
dto.setContractUnitCode(acceptDTO.getFWZYSQDW_JGDM());
|
|
|
dto.setServiceUrl(acceptDTO.getFWFWDZ());
|
|
|
- dto.setServiceStatus(acceptDTO.getFWZYZTDM());
|
|
|
+ String fwzyztdm = acceptDTO.getFWZYZTDM();
|
|
|
+ dto.setServiceStatus(fwzyztdm);
|
|
|
+ dto.setDeleted(BooleanEnum.FALSE.getValue());
|
|
|
+ if (ServiceStatusCons.STATUS_DELETED.equals(fwzyztdm)) {
|
|
|
+ dto.setDeleted(BooleanEnum.TRUE.getValue());
|
|
|
+ }
|
|
|
return dto;
|
|
|
}
|
|
|
|
|
@@ -375,7 +436,15 @@ public class ResourceBusiness implements IResourceBusiness {
|
|
|
logger.info("getAppRemoteDetailByCode >> url:{}, busSraId:{}, busServiceId:{}, busServiceFunc:{}, busSreIdcard:{}, appCode:{}",
|
|
|
url, busSraId, busServiceId, busServiceFunc, busSreIdcard, appCode);
|
|
|
CloseableHttpResponse response = HttpUtil.get(url, param, heards);
|
|
|
- return EntityUtils.toString(response.getEntity());
|
|
|
+ String statusCode = String.valueOf(response.getStatusLine().getStatusCode());
|
|
|
+ String result = EntityUtils.toString(response.getEntity());
|
|
|
+ logger.info("getAppRemoteDetailByCode result:{}", result);
|
|
|
+ IOUtils.closeQuietly(response);
|
|
|
+ if (!ResponseStatus.SUCCESS_CODE.equals(response.getStatusLine().getStatusCode())) {
|
|
|
+ logger.info("getAppRemoteDetailByCode status code:{}", statusCode);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|