Browse Source

Merge branch 'dev_thirdplatform' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_thirdplatform

dev_shibei_match
sunyuchao 5 years ago
parent
commit
02f6d40618
  1. 24
      epmet-auth/src/main/java/com/epmet/constant/AuthHttpUrlConstant.java
  2. 10
      epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java
  3. 86
      epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
  4. 26
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ConvertUtils.java
  5. 19
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/constant/HttpUrlConstant.java
  6. 14
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ComponentAccessTokenServiceImpl.java
  7. 14
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/RefreshAuthAccessTokenServiceImpl.java
  8. 11
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/constant/GuideHttpUrlConstant.java
  9. 32
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java

24
epmet-auth/src/main/java/com/epmet/constant/AuthHttpUrlConstant.java

@ -0,0 +1,24 @@
package com.epmet.constant;
/**
* @Author zxc
* @CreateTime 2020/7/30 10:05
*/
public interface AuthHttpUrlConstant {
/**
* 注册url
*/
String REGISTER_URL = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/register";
/**
* 获取客户信息url
*/
String CUSTOMER_MSG_URL = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/";
/**
* 登录url
*/
String RESI_AND_WORK_LOGIN_URL = "https://epmet-cloud.elinkservice.cn/api/third/customermp/resiandworklogin";
}

10
epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java

@ -6,11 +6,13 @@ import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.*;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.commons.tools.validator.PhoneValidatorUtils;
import com.epmet.constant.AuthHttpUrlConstant;
import com.epmet.constant.PublicUserLoginConstant; import com.epmet.constant.PublicUserLoginConstant;
import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.SmsTemplateConstant;
import com.epmet.constant.ThirdApiConstant; import com.epmet.constant.ThirdApiConstant;
@ -260,12 +262,16 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService {
@Override @Override
public UserTokenResultDTO register(RegisterFormDTO formDTO) { public UserTokenResultDTO register(RegisterFormDTO formDTO) {
//1.调用epmet-third服务,完成信息注册 //1.调用epmet-third服务,完成信息注册
Result<RegisterResultDTO> result = epmetThirdFeignClient.register(formDTO); String data = HttpClientManager.getInstance().sendPostByJSON(AuthHttpUrlConstant.REGISTER_URL, JSON.toJSONString(formDTO)).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) { if (!result.success()) {
logger.error("调用epmet_third服务初始化用户信息失败"); logger.error("调用epmet_third服务初始化用户信息失败");
throw new RenException(result.getCode()); throw new RenException(result.getCode());
} }
RegisterResultDTO resultDTO = result.getData(); Object RegisterResult = result.getData();
JSONObject jsonObject = JSON.parseObject(RegisterResult.toString());
RegisterResultDTO resultDTO = ConvertUtils.mapToEntity(jsonObject, RegisterResultDTO.class);
//2.直接生成一个新的token放入缓存中(不管缓存中是否存在旧的token,都重新生成) //2.直接生成一个新的token放入缓存中(不管缓存中是否存在旧的token,都重新生成)
//2-1.生成token //2-1.生成token

86
epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java

@ -1,6 +1,8 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.common.token.constant.LoginConstant; import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
@ -9,10 +11,8 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.security.password.PasswordUtils;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.*;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.constant.AuthHttpUrlConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
@ -70,12 +70,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO();
resiLoginFormDTO.setAppId(formDTO.getAppId()); resiLoginFormDTO.setAppId(formDTO.getAppId());
resiLoginFormDTO.setWxCode(formDTO.getWxCode()); resiLoginFormDTO.setWxCode(formDTO.getWxCode());
Result<UserWechatDTO> result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO);
if (!result.success()) {
logger.error("居民端小程序登陆,调用epmet_third服务获取数据失败");
throw new RenException(result.getCode());
}
UserWechatDTO userWechatDTO = result.getData();
//2.调用epmet-user服务,新增用户信息(先判断用户是否存在,不存在则新增存在则更新) //2.调用epmet-user服务,新增用户信息(先判断用户是否存在,不存在则新增存在则更新)
WxUserFormDTO wxUserFormDTO = new WxUserFormDTO(); WxUserFormDTO wxUserFormDTO = new WxUserFormDTO();
@ -83,7 +78,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
wxUserFormDTO.setApp(formDTO.getApp()); wxUserFormDTO.setApp(formDTO.getApp());
Result<UserDTO> userResult = epmetUserOpenFeignClient.saveWxUser(wxUserFormDTO); Result<UserDTO> userResult = epmetUserOpenFeignClient.saveWxUser(wxUserFormDTO);
if (!userResult.success()) { if (!userResult.success()) {
throw new RenException(result.getCode()); throw new RenException(userResult.getCode());
} }
UserDTO userDTO = userResult.getData(); UserDTO userDTO = userResult.getData();
@ -147,12 +142,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO();
resiLoginFormDTO.setAppId(formDTO.getAppId()); resiLoginFormDTO.setAppId(formDTO.getAppId());
resiLoginFormDTO.setWxCode(formDTO.getWxCode()); resiLoginFormDTO.setWxCode(formDTO.getWxCode());
Result<UserWechatDTO> result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO);
if (!result.success()) {
logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败");
throw new RenException(result.getCode());
}
UserWechatDTO userWechatDTO = result.getData();
//2.根据openid查询用户是否存在历史登陆信息 //2.根据openid查询用户是否存在历史登陆信息
Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserOpenFeignClient.getLatestStaffWechatLoginRecord(userWechatDTO.getWxOpenId()); Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserOpenFeignClient.getLatestStaffWechatLoginRecord(userWechatDTO.getWxOpenId());
@ -369,12 +359,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO();
resiLoginFormDTO.setAppId(formDTO.getAppId()); resiLoginFormDTO.setAppId(formDTO.getAppId());
resiLoginFormDTO.setWxCode(formDTO.getWxCode()); resiLoginFormDTO.setWxCode(formDTO.getWxCode());
Result<UserWechatDTO> result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO);
if (!result.success()) {
logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败");
throw new RenException(result.getCode());
}
UserWechatDTO userWechatDTO = result.getData();
WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult(); WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult();
wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId()); wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId());
wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey());
@ -419,12 +404,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
} }
//1.根据appId查询对应客户Id //1.根据appId查询对应客户Id
Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId());
if (!resultDTO.success()) {
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId()));
throw new RenException(resultDTO.getMsg());
}
PaCustomerDTO customer = resultDTO.getData().getCustomer();
//7.28 根据appId只能存在一个客户Id,后边的批量操作逻辑 //7.28 根据appId只能存在一个客户Id,后边的批量操作逻辑
//2.根据手机号查询到用户信息 //2.根据手机号查询到用户信息
@ -461,12 +441,8 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
@Override @Override
public List<StaffOrgsResultDTO> getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO) { public List<StaffOrgsResultDTO> getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO) {
//0.根据appId查询对应客户Id //0.根据appId查询对应客户Id
Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); // Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId());
if (!resultDTO.success()) { PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId());
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId()));
throw new RenException(resultDTO.getMsg());
}
PaCustomerDTO customer = resultDTO.getData().getCustomer();
//7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun //7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun
//1、根据手机号查询到用户信息 //1、根据手机号查询到用户信息
ThirdCustomerStaffFormDTO dto = new ThirdCustomerStaffFormDTO(); ThirdCustomerStaffFormDTO dto = new ThirdCustomerStaffFormDTO();
@ -526,4 +502,44 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
return new ArrayList<>(); return new ArrayList<>();
} }
/**
* @Description 获取客户信息
* @param appId
* @author zxc
*/
public PaCustomerDTO getCustomerInfo(String appId){
JSONObject jsonObject = new JSONObject();
String data = HttpClientManager.getInstance().sendPostByJSON(AuthHttpUrlConstant.CUSTOMER_MSG_URL + appId, JSON.toJSONString(jsonObject)).getData();
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (!mapToResult.success()) {
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + appId));
throw new RenException(mapToResult.getMsg());
}
Object PublicCustomerResultDTO = mapToResult.getData();
JSONObject json = JSON.parseObject(PublicCustomerResultDTO.toString());
PublicCustomerResultDTO publicCustomerResultDTO = ConvertUtils.mapToEntity(json, PublicCustomerResultDTO.class);
PaCustomerDTO customer = publicCustomerResultDTO.getCustomer();
return customer;
}
/**
* @Description 获取UserWechatDTO
* @param resiLoginFormDTO
* @author zxc
*/
public UserWechatDTO getUserWeChat(WxLoginFormDTO resiLoginFormDTO){
String data = HttpClientManager.getInstance().sendPostByJSON(AuthHttpUrlConstant.RESI_AND_WORK_LOGIN_URL, JSON.toJSONString(resiLoginFormDTO)).getData();
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (!mapToResult.success()) {
logger.error("居民端小程序登陆,调用epmet_third服务获取数据失败");
throw new RenException(mapToResult.getCode());
}
Object UserWeChatDTO = mapToResult.getData();
JSONObject json = JSON.parseObject(UserWeChatDTO.toString());
UserWechatDTO userWechatDTO = ConvertUtils.mapToEntity(json, UserWechatDTO.class);
return userWechatDTO;
}
} }

26
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ConvertUtils.java

@ -12,9 +12,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 转换工具类 * 转换工具类
@ -58,4 +60,28 @@ public class ConvertUtils {
return targetList; return targetList;
} }
public static <T> T mapToEntity(Map<String, Object> map, Class<T> entity) {
T t = null;
try {
t = entity.newInstance();
for(Field field : entity.getDeclaredFields()) {
if (map.containsKey(field.getName())) {
boolean flag = field.isAccessible();
field.setAccessible(true);
Object object = map.get(field.getName());
if (object!= null && field.getType().isAssignableFrom(object.getClass())) {
field.set(t, object);
}
field.setAccessible(flag);
}
}
return t;
} catch (InstantiationException e) {
logger.error("convert error ", e);
} catch (IllegalAccessException e) {
logger.error("convert error ", e);
}
return t;
}
} }

19
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/constant/HttpUrlConstant.java

@ -0,0 +1,19 @@
package com.epmet.constant;
/**
* @Author zxc
* @CreateTime 2020/7/30 9:47
*/
public interface HttpUrlConstant {
/**
* 定时任务 刷新authorizer_access_tokenurl
*/
String AUTH_ACCESS_TOKEN_URL = "https://epmet-cloud.elinkservice.cn/api/third/wechatthird/refreshtoken";
/**
* 定时任务 刷新component_access_tokenurl
*/
String COMPONENT_ACCESS_TOKEN_URL = "https://epmet-cloud.elinkservice.cn/api/third/wechatthird/componentaccesstoken";
}

14
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ComponentAccessTokenServiceImpl.java

@ -1,6 +1,11 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.HttpUrlConstant;
import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.feign.EpmetThirdFeignClient;
import com.epmet.service.ComponentAccessTokenService; import com.epmet.service.ComponentAccessTokenService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -15,11 +20,12 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ComponentAccessTokenServiceImpl implements ComponentAccessTokenService { public class ComponentAccessTokenServiceImpl implements ComponentAccessTokenService {
@Autowired
private EpmetThirdFeignClient epmetThirdFeignClient;
@Override @Override
public Result componentAccessTokenJob() { public Result componentAccessTokenJob() {
return epmetThirdFeignClient.getComponentAccessTokenJob(); JSONObject jsonObject = new JSONObject();
String data = HttpClientManager.getInstance().sendPostByJSON(HttpUrlConstant.COMPONENT_ACCESS_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
return result;
} }
} }

14
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/RefreshAuthAccessTokenServiceImpl.java

@ -1,6 +1,11 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.HttpUrlConstant;
import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.feign.EpmetThirdFeignClient;
import com.epmet.service.RefreshAuthAccessTokenService; import com.epmet.service.RefreshAuthAccessTokenService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,11 +18,12 @@ import org.springframework.stereotype.Service;
@Service @Service
public class RefreshAuthAccessTokenServiceImpl implements RefreshAuthAccessTokenService { public class RefreshAuthAccessTokenServiceImpl implements RefreshAuthAccessTokenService {
@Autowired
private EpmetThirdFeignClient epmetThirdFeignClient;
@Override @Override
public Result refreshAuthorizerAccessTokenJob() { public Result refreshAuthorizerAccessTokenJob() {
return epmetThirdFeignClient.refreshAuthorizerAccessTokenJob(); JSONObject jsonObject = new JSONObject();
String data = HttpClientManager.getInstance().sendPostByJSON(HttpUrlConstant.AUTH_ACCESS_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
return result;
} }
} }

11
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/constant/GuideHttpUrlConstant.java

@ -0,0 +1,11 @@
package com.epmet.constant;
/**
* @Author zxc
* @CreateTime 2020/7/30 13:56
*/
public interface GuideHttpUrlConstant {
String CUSTOMER_MSG_URL = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/";
}

32
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java

@ -1,6 +1,8 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -11,7 +13,9 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.GuideHttpUrlConstant;
import com.epmet.constant.StrangerResiGuideConstant; import com.epmet.constant.StrangerResiGuideConstant;
import com.epmet.dao.StrangerAccessRecordDao; import com.epmet.dao.StrangerAccessRecordDao;
import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaCustomerDTO;
@ -255,12 +259,7 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc
public Result<List<PublicCustomerGridForStrangerResultDTO>> thirdCustomerGridList(PublicCustomerGridListFormDTO formDTO) { public Result<List<PublicCustomerGridForStrangerResultDTO>> thirdCustomerGridList(PublicCustomerGridListFormDTO formDTO) {
//0.调用epmet-third服务,根据appId查询客户信息 //0.调用epmet-third服务,根据appId查询客户信息
Result<PublicCustomerResultDTO> result = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId());
if(!result.success()){
throw new RenException(result.getCode());
}
PublicCustomerResultDTO resultDTO = result.getData();
PaCustomerDTO customer = resultDTO.getCustomer();
ThirdCustomerGridListFormDTO third = new ThirdCustomerGridListFormDTO(); ThirdCustomerGridListFormDTO third = new ThirdCustomerGridListFormDTO();
third.setCustomerId(customer.getId()); third.setCustomerId(customer.getId());
@ -306,4 +305,25 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc
} }
/**
* @Description 获取客户信息
* @param appId
* @author zxc
*/
public PaCustomerDTO getCustomerInfo(String appId){
JSONObject jsonObject = new JSONObject();
String data = HttpClientManager.getInstance().sendPostByJSON(GuideHttpUrlConstant.CUSTOMER_MSG_URL + appId, JSON.toJSONString(jsonObject)).getData();
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (!mapToResult.success()) {
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + appId));
throw new RenException(mapToResult.getMsg());
}
Object PublicCustomerResultDTO = mapToResult.getData();
JSONObject json = JSON.parseObject(PublicCustomerResultDTO.toString());
PublicCustomerResultDTO publicCustomerResultDTO = ConvertUtils.mapToEntity(json, PublicCustomerResultDTO.class);
PaCustomerDTO customer = publicCustomerResultDTO.getCustomer();
return customer;
}
} }

Loading…
Cancel
Save