Browse Source

Merge remote-tracking branch 'remotes/origin/dev_thirdplatform' into dev_temp

master
jianjun 4 years ago
parent
commit
55acd7c84a
  1. 19
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java
  2. 11
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java
  3. 28
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

19
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java

@ -2,10 +2,8 @@ package com.epmet.apiservice;
import com.alibaba.fastjson.JSON;
import com.epmet.apiservice.result.LZGridPlatformBaseResult;
import com.epmet.dto.form.UploadFileFormDTO;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.dto.result.ProjectAssistResult;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SpringContextUtils;
@ -14,10 +12,13 @@ import com.epmet.dao.ThirdplatformCustomerRegisterDao;
import com.epmet.dao.ThirdplatformDao;
import com.epmet.dto.form.ProjectApplyAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
import com.epmet.dto.form.UploadFileFormDTO;
import com.epmet.dto.result.ProjectAssistResult;
import com.epmet.dto.result.UploadFileResultDTO;
import com.epmet.entity.ThirdplatformActionEntity;
import com.epmet.entity.ThirdplatformCustomerRegisterEntity;
import com.epmet.entity.ThirdplatformEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import java.io.File;
@ -30,6 +31,7 @@ import java.util.concurrent.TimeUnit;
* 每一个具体平台的ApiService都是该抽象类的子类选择性实现抽象类中的某些需要实现方法提供具体业务逻辑
* 此抽象类中定义方法的具体返回类型所有子类都要统一使用在具体实现中做转换若是不需要返回返回null即可
*/
@Slf4j
public abstract class ApiService {
/**
* 重试次数
@ -73,12 +75,12 @@ public abstract class ApiService {
// 填充access token到头当中
headers.put("X-Access-Token", accessToken);
log.info("apiService sendGetRequest param:{},headers:{}",params,headers);
Result<String> result = HttpClientManager.getInstance().sendGet(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()),
thirdplatform.getBaseUrl().startsWith("https://"),
params,
headers);
log.info("apiService sendGetRequest result:{}",JSON.toJSONString(result));
if (result == null) {
throw new RenException("请求第三方平台,获取AccessToken失败。result为null");
}
@ -113,11 +115,12 @@ public abstract class ApiService {
// 填充access token到头当中
headers.put("X-Access-Token", accessToken);
log.info("apiService sendPostRequest param:{},headers:{}",jsonString,headers);
Result<String> result = HttpClientManager.getInstance().sendPost(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()),
thirdplatform.getBaseUrl().startsWith("https://"),
jsonString,
headers);
log.info("apiService sendPostRequest result:{}",JSON.toJSONString(result));
if (result == null) {
throw new RenException("请求第三方平台,发送Post请求失败。result为null");
}
@ -142,13 +145,13 @@ public abstract class ApiService {
// 填充access token到头当中
headers.put("X-Access-Token", accessToken);
log.info("apiService sendPostRequestToUploadFile fileName:{}",headers);
Result<String> result = HttpClientManager.getInstance().uploadFile(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()),
thirdplatform.getBaseUrl().startsWith("https://"),
file,
fileName,
headers);
log.info("apiService sendPostRequestToUploadFile result:{}",JSON.toJSONString(result));
if (result == null) {
throw new RenException("请求第三方平台,发送Post请求失败。result为null");
}

11
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java

@ -3,6 +3,7 @@ package com.epmet.apiservice.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.apiservice.ApiService;
import com.epmet.apiservice.result.LZGridPlatformBaseResult;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
@ -69,8 +70,16 @@ public class LuzhouGridPlatformApiService extends ApiService {
@Override
public ProjectAssistResult projectAssist(ProjectApplyAssistFormDTO formDTO) {
String platformId = formDTO.getPlatformId();
//开发环境由测试环境转发 所以 开发和本地 都使用测试环境地址
//todo 项目回调地址 仍需要从参数中获取
EnvEnum currentEnv = EnvEnum.getCurrentEnv();
if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) {
formDTO.setNotifyUrl(EnvEnum.PROD.getUrl().concat("gov/project/project/platformcallback"));
} else {
formDTO.setNotifyUrl(EnvEnum.TEST.getUrl().concat("gov/project/project/platformcallback"));
}
formDTO.setNotifyUrl("https://epmet-dev.elinkservice.cn/api/gov/project/project/platformcallback");
// 正式调用第三方平台
String argsStr = JSON.toJSONString(formDTO);

28
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

@ -2269,6 +2269,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
if (CollectionUtils.isNotEmpty(files)) {
String all = String.join(StrConstant.COMMA, files);
platformFileDTO.setTopicImages(all);
applyAssistFormDTO.setImageLink(all);
}
}
if (CollectionUtils.isNotEmpty(topicAttachment.getData().getVoiceList())) {
@ -2288,6 +2289,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
if (CollectionUtils.isNotEmpty(files)) {
String all = String.join(StrConstant.COMMA, files);
platformFileDTO.setTopicVoices(all);
applyAssistFormDTO.setVoiceLink(all);
}
}
if (CollectionUtils.isNotEmpty(topicAttachment.getData().getVideoList())) {
@ -2307,6 +2309,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
if (CollectionUtils.isNotEmpty(files)) {
String all = String.join(StrConstant.COMMA, files);
platformFileDTO.setTopicVideos(all);
applyAssistFormDTO.setVideoLink(all);
}
}
if (CollectionUtils.isNotEmpty(topicAttachment.getData().getDocList())) {
@ -2464,18 +2467,18 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
}
String source = "议题标题:" + sourceDTO.getIssueTitle() + "\n" +
"针对话题\n" + (null == sourceDTO.getTopicContent()?"":sourceDTO.getTopicContent()) + "\n";
if (StringUtils.isNotEmpty(platformFileDTO.getTopicImages())) {
source = source + "话题图片:" + platformFileDTO.getTopicImages() + "\n";
}
if (StringUtils.isNotEmpty(platformFileDTO.getTopicVoices())) {
source = source + "话题语音:" + platformFileDTO.getTopicVoices() + "\n";
}
if (StringUtils.isNotEmpty(platformFileDTO.getTopicVideos())) {
source = source + "话题视频:" + platformFileDTO.getTopicVideos() + "\n";
}
if (StringUtils.isNotEmpty(platformFileDTO.getTopicDocs())) {
source = source + "话题文档:" + platformFileDTO.getTopicDocs() + "\n";
}
// if (StringUtils.isNotEmpty(platformFileDTO.getTopicImages())) {
// source = source + "话题图片:" + platformFileDTO.getTopicImages() + "\n";
// }
// if (StringUtils.isNotEmpty(platformFileDTO.getTopicVoices())) {
// source = source + "话题语音:" + platformFileDTO.getTopicVoices() + "\n";
// }
// if (StringUtils.isNotEmpty(platformFileDTO.getTopicVideos())) {
// source = source + "话题视频:" + platformFileDTO.getTopicVideos() + "\n";
// }
// if (StringUtils.isNotEmpty(platformFileDTO.getTopicDocs())) {
// source = source + "话题文档:" + platformFileDTO.getTopicDocs() + "\n";
// }
source = source + "建议采用如下处理方式\n" + sourceDTO.getIssueSuggestion() + "\n" +
"所属网格:" + sourceDTO.getBelongsGridName() + "\n" +
"话题发表人:" + sourceDTO.getTopicPublisher() + sourceDTO.getTopicPublisherMobile() + "\n" +
@ -2497,7 +2500,6 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
DateUtils.formatTimestamp(item.getProcessTime(), DateUtils.DATE_TIME_PATTERN) + "\n" +
"处理部门:" + item.getDepartmentName() + "\n" +
"说明:" + item.getPublicReply() + "\n";
//TODO 上传图片
detail = detail + process;
}
System.out.println(detail);

Loading…
Cancel
Save