Browse Source

Merge branch 'dev'

master
wxz 5 years ago
parent
commit
19dc19c458
  1. 25
      epmet-auth/pom.xml
  2. 21
      epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java
  3. 53
      epmet-auth/src/main/java/com/epmet/controller/SsoController.java
  4. 39
      epmet-auth/src/main/java/com/epmet/dto/form/SsoLoginFormDTO.java
  5. 21
      epmet-auth/src/main/java/com/epmet/dto/result/SsoLoginResultDTO.java
  6. 39
      epmet-auth/src/main/java/com/epmet/redis/SsoRedis.java
  7. 20
      epmet-auth/src/main/java/com/epmet/service/SsoService.java
  8. 185
      epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java
  9. 7
      epmet-auth/src/main/resources/bootstrap.yml
  10. 22
      epmet-commons/epmet-commons-thirdplat/pom.xml
  11. 36
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/DemoApp.java
  12. 45
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java
  13. 98
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java
  14. 10
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/bean/ThirdPlatUserInfo.java
  15. 28
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/config/ThirdplatConfig.java
  16. 9
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/constants/ApiServiceBeansConstants.java
  17. 14
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/constants/JcetConstants.java
  18. 8
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/form/jcet/SsoTicketFormDTO.java
  19. 8
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/form/jcet/SsoTokenFormDTO.java
  20. 13
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetResult.java
  21. 29
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java
  22. 51
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/encrypt/EncryptUtils.java
  23. 15
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/encrypt/SignUtils.java
  24. 13
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/JcetThirdplatProps.java
  25. 12
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java
  26. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  27. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  28. 48
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  29. 1
      epmet-commons/pom.xml
  30. 10
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/UserMessageConstans.java
  31. 43
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java
  32. 2
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml
  33. 20
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/ApiServiceFormDTO.java
  34. 16
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ThirdplatApiserviceResultDTO.java
  35. 15
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  36. 11
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  37. 22
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  38. 36
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java
  39. 51
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerThirdplatApiserviceEntity.java
  40. 16
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java
  41. 17
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java
  42. 42
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java
  43. 14
      epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.6__create_thirdplat_apiservice.sql
  44. 33
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml
  45. 13
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java
  46. 10
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java
  47. 43
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java
  48. 12
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java
  49. 9
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/service/ResiMineGridService.java
  50. 26
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/service/impl/ResiMineGridServiceImpl.java
  51. 40
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserInfoFormDTO.java
  52. 9
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  53. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  54. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java
  55. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java
  56. 18
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java
  57. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java
  58. 43
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java
  59. 29
      epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml

25
epmet-auth/pom.xml

@ -18,6 +18,11 @@
</properties>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-thirdplat</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-admin-client</artifactId>
@ -193,6 +198,11 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>http://101.206.141.251:21006</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>soXDEoM1</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.appsecret>
</properties>
</profile>
<profile>
@ -237,6 +247,11 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>http://101.206.141.251:21006</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>soXDEoM1</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.appsecret>
</properties>
</profile>
<profile>
@ -276,6 +291,11 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>http://101.206.141.251:21006</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>soXDEoM1</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.appsecret>
</properties>
</profile>
@ -319,6 +339,11 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>https://jcytc.lzjczl.com:21009</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>2cy0a9lA</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>6hU3PQgxLcXr27SE</thirdplat.jcet.appsecret>
</properties>
</profile>
</profiles>

21
epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java

@ -0,0 +1,21 @@
package com.epmet.constant;
/**
* @Author zxc
* @DateTime 2021/1/19 上午10:26
*/
public interface SsoConstant {
/**
* 酒城e通appId
*/
String WINE_CITY_E_OPEN_APP_ID = "64929543";
String USER_INFO_IS_NULL = "【jcetApiService.getUserInfoByTicket(formDTO.getTicket()】结果为空......";
String INSERT_UPDATE_USER_FAILURE = "新增或更新user_weChat失败......";
String USER_ID_IS_NULL = "userId为空,生成token失败......";
String CUSTOMER_ID_IS_NULL = "customerId为空,缓存放置token失败......";
}

53
epmet-auth/src/main/java/com/epmet/controller/SsoController.java

@ -0,0 +1,53 @@
package com.epmet.controller;
import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService;
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.SsoLoginFormDTO;
import com.epmet.dto.result.SsoLoginResultDTO;
import com.epmet.service.SsoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author zxc
* @DateTime 2021/1/18 下午4:33
*/
@RestController
@RequestMapping("sso")
public class SsoController {
@Autowired
private SsoService ssoService;
@Autowired
private JcetApiService jcetApiService;
/**
* @Description 0入口得到token
* @Param formDTO
* @author zxc
* @date 2021/1/18 下午4:59
*/
@PostMapping("resi/login")
public Result<SsoLoginResultDTO> ssoLogin(@RequestBody SsoLoginFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class);
return new Result<SsoLoginResultDTO>().ok(ssoService.ssoLogin(formDTO));
}
@PostMapping("test")
public Result<ThirdPlatUserInfo> testssoLogin(){
ThirdPlatUserInfo userInfoByTicket = null;
try {
userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui");
} catch (Exception e) {
e.printStackTrace();
}
return new Result<ThirdPlatUserInfo>().ok(userInfoByTicket);
}
}

39
epmet-auth/src/main/java/com/epmet/dto/form/SsoLoginFormDTO.java

@ -0,0 +1,39 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/1/18 下午4:43
*/
@Data
public class SsoLoginFormDTO implements Serializable {
private static final long serialVersionUID = -6543952487970013031L;
public interface SsoLoginForm{}
/**
* sso票据有效期为300秒
*/
@NotBlank(message = "sso票据不能为空",groups = SsoLoginForm.class)
private String ticket;
/**
* 三方平台应用AppId
*/
@NotBlank(message = "三方平台应用AppId不能为空",groups = SsoLoginForm.class)
private String appId;
/**
* app类型 resi居民段work工作端
*/
@NotBlank(message = "app不能为空",groups = SsoLoginForm.class)
private String app;
@NotBlank(message = "client不能为空",groups = SsoLoginForm.class)
private String client;
}

21
epmet-auth/src/main/java/com/epmet/dto/result/SsoLoginResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/1/18 下午4:45
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SsoLoginResultDTO implements Serializable {
private static final long serialVersionUID = 3491079788196180035L;
private String token = "";
}

39
epmet-auth/src/main/java/com/epmet/redis/SsoRedis.java

@ -0,0 +1,39 @@
package com.epmet.redis;
import cn.hutool.core.bean.BeanUtil;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.security.dto.TokenDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @Author zxc
* @DateTime 2021/1/18 下午5:09
*/
@Component
public class SsoRedis {
@Autowired
private RedisUtils redisUtils;
/**
* @Description token放入缓存
* @Param user
* @Param expire
* @author zxc
* @date 2021/1/18 下午5:10
*/
public void set(TokenDto user, long expire) {
if (user == null) {
return;
}
String key = RedisKeys.getCpUserKey(user.getApp(), user.getClient(), user.getUserId());
//bean to map
Map<String, Object> map = BeanUtil.beanToMap(user, false, true);
redisUtils.hMSet(key, map, expire);
}
}

20
epmet-auth/src/main/java/com/epmet/service/SsoService.java

@ -0,0 +1,20 @@
package com.epmet.service;
import com.epmet.dto.form.SsoLoginFormDTO;
import com.epmet.dto.result.SsoLoginResultDTO;
/**
* @Author zxc
* @DateTime 2021/1/18 下午4:34
*/
public interface SsoService {
/**
* @Description 0入口得到token
* @Param formDTO
* @author zxc
* @date 2021/1/18 下午4:59
*/
SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO);
}

185
epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java

@ -0,0 +1,185 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.thirdplat.apiservice.AbstractApiService;
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.*;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.UserDTO;
import com.epmet.dto.form.ApiServiceFormDTO;
import com.epmet.dto.form.SsoLoginFormDTO;
import com.epmet.dto.form.UserInfoFormDTO;
import com.epmet.dto.result.SsoLoginResultDTO;
import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils;
import com.epmet.redis.SsoRedis;
import com.epmet.service.SsoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @Author zxc
* @DateTime 2021/1/18 下午4:35
*/
@Service
@Slf4j
public class SsoServiceImpl implements SsoService {
Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private SsoRedis ssoRedis;
@Autowired
private JwtTokenUtils jwtTokenUtils;
@Autowired
private JwtTokenProperties jwtTokenProperties;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
/**
* @Description 0入口得到token
* @Param formDTO
* @author zxc
* @date 2021/1/18 下午4:59
*/
@Override
public SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO) {
String customerId = getCustomerId(formDTO.getAppId());
String userId = "";
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId));
if (!apiServiceResult.success()) {
throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg());
}
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) {
throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString());
}
ThirdPlatUserInfo userInfo;
try {
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName());
userInfo = apiService.getUserInfoByTicket(formDTO.getTicket());
} catch (Exception e) {
throw new RenException(e.getMessage());
}
if (null == userInfo){
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(),
"【SSO登录】调用第三方平台查询用户信息失败,用户信息为空");
}
UserInfoFormDTO userInfoFormDTO = new UserInfoFormDTO();
userInfoFormDTO.setApp(formDTO.getApp());
userInfoFormDTO.setUid(userInfo.getOpenId());
userInfoFormDTO.setName(userInfo.getName());
userInfoFormDTO.setMobile(userInfo.getMobile());
Result<UserDTO> userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO);
if (!userDTOResult.success()){
throw new RenException("【SSO登录】新增或更新user_weChat失败");
}
userId = userDTOResult.getData().getId();
if (StringUtils.isBlank(userId)){
throw new RenException("【SSO登录】userId为空,生成token失败");
}
//生成业务token
String token = this.generateToken(formDTO.getApp(),formDTO.getClient(), userId);
//存放Redis
if (StringUtils.isBlank(customerId)){
throw new RenException("【SSO登录】customerId为空,缓存放置token失败");
}
this.disposeTokenDto(formDTO, userId, token, customerId);
return new SsoLoginResultDTO(token);
}
/**
* @Description token放缓存
* @Param formDTO
* @Param userId
* @Param token
* @Param customerId
* @author zxc
* @date 2021/1/18 下午5:32
*/
public void disposeTokenDto(SsoLoginFormDTO formDTO, String userId, String token, String customerId){
int expire = jwtTokenProperties.getExpire();
TokenDto tokenDto = new TokenDto();
tokenDto.setCustomerId(customerId);
tokenDto.setApp(formDTO.getApp());
tokenDto.setClient(formDTO.getClient());
tokenDto.setUserId(userId);
tokenDto.setToken(token);
tokenDto.setUpdateTime(System.currentTimeMillis());
tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
ssoRedis.set(tokenDto, expire);
log.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
}
/**
* @Description 居民端登陆生成业务token的key
* @Param app
* @Param client
* @Param userId
* @author zxc
* @date 2021/1/18 下午5:14
*/
private String generateToken(String app,String client, String userId) {
Map<String, Object> map = new HashMap<>(16);
map.put("app", app);
map.put("client", client);
map.put("userId", userId);
String token = jwtTokenUtils.createToken(map);
log.info("app:" + app + ";client:" + client + ";userId:" + userId + ";生成token[" + token + "]");
return token;
}
/**
* @Description 获取customerId
* @Param appId
* @author zxc
* @date 2021/1/19 下午1:47
*/
public String getCustomerId(String appId){
JSONObject jsonObject = new JSONObject();
String customerMsgUrl = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/";
String data = HttpClientManager.getInstance().sendPostByJSON(customerMsgUrl + appId, JSON.toJSONString(jsonObject)).getData();
log.info("调用third服务,根据appId查询客户信息:httpclient->url:" + customerMsgUrl + ",结果->" + data);
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (null != toResult.get("code")) {
mapToResult.setCode(((Integer) toResult.get("code")).intValue());
}
if (!mapToResult.success()) {
log.error(String.format("根据appId查询客户信息失败,对应appId->" + appId));
throw new RenException(mapToResult.getMsg());
}
Object publicCustomerResultDTO = mapToResult.getData();
JSONObject json = JSON.parseObject(publicCustomerResultDTO.toString());
Map<String, Object> map = (Map) json.get("customer");
PaCustomerDTO customer = ConvertUtils.mapToEntity(map, PaCustomerDTO.class);
log.info("小程序登陆third服务获取客户用户信息PaCustomerDTO->" + customer);
return customer.getId();
}
}

7
epmet-auth/src/main/resources/bootstrap.yml

@ -132,3 +132,10 @@ shutdown:
graceful:
enable: true #是否开启优雅停机
waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警
# 调用第三方平台相关参数
thirdplat:
jcet:
domain: @thirdplat.jcet.domain@
appkey: @thirdplat.jcet.appkey@
appsecret: @thirdplat.jcet.appsecret@

22
epmet-commons/epmet-commons-thirdplat/pom.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>epmet-commons</artifactId>
<groupId>com.epmet</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>epmet-commons-thirdplat</artifactId>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</project>

36
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/DemoApp.java

@ -0,0 +1,36 @@
package com.epmet.commons.thirdplat;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTicketFormDTO;
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTokenFormDTO;
import com.epmet.commons.thirdplat.encrypt.SignUtils;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
public class DemoApp {
private static String appid = "soXDEoM1";
private static String appsecret = "V7ea0KnlYt7eSyzc";
public static void main(String[] args) throws UnsupportedEncodingException {
//SsoToken ssoToken = new SsoToken();
//ssoToken.setSsoToken("wxz");
SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO();
ssoTicket.setSsoTicket("wxz");
int bodyLength = JSON.toJSONString(ssoTicket).getBytes("utf-8").length;
Map<String, Object> headers = new HashMap();
long timestamp = System.currentTimeMillis();
headers.put("openTimestamp", String.valueOf(timestamp));
headers.put("openAppId", appid);
String encryptContent = appid + timestamp + bodyLength;
headers.put("openSign", SignUtils.generate(encryptContent, appsecret));
System.out.println(headers);
}
}

45
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java

@ -0,0 +1,45 @@
package com.epmet.commons.thirdplat.apiservice;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo;
import com.epmet.commons.thirdplat.dto.result.jcet.JcetResult;
import com.epmet.commons.thirdplat.properties.ThirdplatProps;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
public abstract class AbstractApiService {
protected ThirdplatProps thirdplatProps;
/**
* 通过ticket查询用户信息
* @param ticket
* @return
* @throws Exception
*/
public abstract ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws Exception;
/**
* @Description 解析请求结果
* @return
* @author wxz
* @date 2021.01.19 09:53
*/
protected <R> R parseResult(Result<String> thResult, Class<R> resultType) {
if (!thResult.success()) {
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(),
EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getMsg().concat(":").concat(thResult.getInternalMsg()));
}
JcetResult jcetResult = JSON.parseObject(thResult.getData(), JcetResult.class);
if (!jcetResult.isSuccess()) {
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(),
jcetResult.getMsg().concat(",错误码:") + jcetResult.getCode());
}
JSONObject jo = (JSONObject) jcetResult.getData();
return jo.toJavaObject(resultType);
}
}

98
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java

@ -0,0 +1,98 @@
package com.epmet.commons.thirdplat.apiservice.jcet;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.thirdplat.apiservice.AbstractApiService;
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo;
import com.epmet.commons.thirdplat.constants.JcetConstants;
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTicketFormDTO;
import com.epmet.commons.thirdplat.dto.result.jcet.JcetUserInfoResultDTO;
import com.epmet.commons.thirdplat.encrypt.SignUtils;
import com.epmet.commons.thirdplat.properties.JcetThirdplatProps;
import com.epmet.commons.thirdplat.properties.ThirdplatProps;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
public class JcetApiService extends AbstractApiService {
private JcetThirdplatProps jcetThirdplatProps;
public JcetApiService(ThirdplatProps props) {
this.thirdplatProps = props;
jcetThirdplatProps = props.getJcet();
}
/**
* @return
* @Description 通过第三方平台ticket获取用户信息
* @author wxz
* @date 2021.01.19 10:26
*/
public ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws UnsupportedEncodingException {
SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO();
ssoTicket.setSsoTicket(ticket);
String domain = jcetThirdplatProps.getDomain();
Result<String> result = HttpClientManager.getInstance().sendPost(
domain.concat(JcetConstants.URL_GET_USER_BY_TICKET),
domain.startsWith("https://"),
JSON.toJSONString(ssoTicket),
getHeaders(ssoTicket));
JcetUserInfoResultDTO resultDTO = parseResult(result, JcetUserInfoResultDTO.class);
ThirdPlatUserInfo userInfo = new ThirdPlatUserInfo();
userInfo.setOpenId(resultDTO.getId());
userInfo.setName(resultDTO.getName());
userInfo.setMobile(resultDTO.getMobile());
return userInfo;
}
/**
* @return
* @Description 通过token获取用户信息
* @author wxz
* @date 2021.01.19 10:28
*/
//public JcetUserInfoResultDTO getUserInfoByToken(String token) throws UnsupportedEncodingException {
// SsoTokenFormDTO ssoToken = new SsoTokenFormDTO();
// ssoToken.setSsoToken(token);
//
// HashMap<String, Object> paramMap = new HashMap<>();
// paramMap.put(JcetConstants.PLAT_TOKEN_NAME, token);
//
// String domain = jcetThirdplatProps.getDomain();
//
// Result<String> result = HttpClientManager.getInstance().sendGet(
// domain.concat(JcetConstants.URL_GET_USER_BY_TOKEN),
// domain.startsWith("https://"),
// paramMap,
// getHeaders(ssoToken));
//
// JcetUserInfoResultDTO resultDTO = parseResult(result, JcetUserInfoResultDTO.class);
// return resultDTO;
//}
/**
* 获取请求所需要的头信息
*
* @param contentObject
* @return
* @throws UnsupportedEncodingException
*/
private Map<String, String> getHeaders(Object contentObject) throws UnsupportedEncodingException {
int bodyLength = JSON.toJSONString(contentObject).getBytes("utf-8").length;
Map<String, String> headers = new HashMap();
long timestamp = System.currentTimeMillis();
headers.put(JcetConstants.PLAT_HEADER_OPEN_TIMESTAMP, String.valueOf(timestamp));
headers.put(JcetConstants.PLAT_HEADER_OPEN_APP_ID, jcetThirdplatProps.getAppkey());
String encryptContent = jcetThirdplatProps.getAppkey() + timestamp + bodyLength;
headers.put(JcetConstants.PLAT_HEADER_OPEN_SIGN, SignUtils.generate(encryptContent, jcetThirdplatProps.getAppsecret()));
return headers;
}
}

10
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/bean/ThirdPlatUserInfo.java

@ -0,0 +1,10 @@
package com.epmet.commons.thirdplat.bean;
import lombok.Data;
@Data
public class ThirdPlatUserInfo {
private String openId;
private String name;
private String mobile;
}

28
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/config/ThirdplatConfig.java

@ -0,0 +1,28 @@
package com.epmet.commons.thirdplat.config;
import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService;
import com.epmet.commons.thirdplat.constants.ApiServiceBeansConstants;
import com.epmet.commons.thirdplat.properties.ThirdplatProps;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 第三方平台的相关配置
*/
@Configuration
@EnableConfigurationProperties(ThirdplatProps.class)
public class ThirdplatConfig {
/**
* @Description 酒城e通的apiService这个name需要注册进数据库使用的时候去数据库根据客户id找对应的apiService出来用
* @return
* @author wxz
* @date 2021.01.20 13:50
*/
@Bean(name = ApiServiceBeansConstants.JCET_API_SERVICE)
public JcetApiService JcetApiService(ThirdplatProps props) {
return new JcetApiService(props);
}
}

9
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/constants/ApiServiceBeansConstants.java

@ -0,0 +1,9 @@
package com.epmet.commons.thirdplat.constants;
/**
* ApiService常量
*/
public interface ApiServiceBeansConstants {
// 酒城e通apiService
String JCET_API_SERVICE = "jcetApiService";
}

14
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/constants/JcetConstants.java

@ -0,0 +1,14 @@
package com.epmet.commons.thirdplat.constants;
public interface JcetConstants {
String URL_GET_USER_BY_TICKET = "/openapi-cgw/openapi-login/sso/getUserInfoByTicket";
String URL_GET_USER_BY_TOKEN = "/openapi-cgw/openapi-login/sso/getUserInfoByToken";
String PLAT_TICKET_NAME = "ssoTicket";
String PLAT_TOKEN_NAME = "ssoToken";
String PLAT_HEADER_OPEN_TIMESTAMP = "openTimestamp";
String PLAT_HEADER_OPEN_APP_ID = "openAppId";
String PLAT_HEADER_OPEN_SIGN = "openSign";
}

8
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/form/jcet/SsoTicketFormDTO.java

@ -0,0 +1,8 @@
package com.epmet.commons.thirdplat.dto.form.jcet;
import lombok.Data;
@Data
public class SsoTicketFormDTO {
private String ssoTicket;
}

8
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/form/jcet/SsoTokenFormDTO.java

@ -0,0 +1,8 @@
package com.epmet.commons.thirdplat.dto.form.jcet;
import lombok.Data;
@Data
public class SsoTokenFormDTO {
private String ssoToken;
}

13
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetResult.java

@ -0,0 +1,13 @@
package com.epmet.commons.thirdplat.dto.result.jcet;
import lombok.Data;
@Data
public class JcetResult {
private boolean success;
private String msg;
private Object data;
private int code;
}

29
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java

@ -0,0 +1,29 @@
package com.epmet.commons.thirdplat.dto.result.jcet;
import lombok.Data;
@Data
public class JcetUserInfoResultDTO {
private String id;
/**
* 用户名称
*/
private String userName;
/**
* 手机号码
*/
private String mobile;
/**
* 姓名
*/
private String name;
/**
* 邮箱
*/
private String email;
/**
* sessionId,用于维持在线状态
*/
private String oaSessionId;
}

51
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/encrypt/EncryptUtils.java

@ -0,0 +1,51 @@
package com.epmet.commons.thirdplat.encrypt;
import com.epmet.commons.tools.exception.RenException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class EncryptUtils {
private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
/**
* 32位 MD5加密
*
* @param s
* @return
*/
public static String md5Hex(String s) throws UnsupportedEncodingException {
byte[] result = digest("MD5", s.getBytes(Charset.defaultCharset()));
return hex(result);
}
/**
* 32 sha256加密
*
* @param s
* @return
*/
public static String sha256(String s) {
byte[] result = digest("SHA-256", s.getBytes(Charset.defaultCharset()));
return hex(result);
}
private static byte[] digest(String algorithm, byte[] data) {
try {
MessageDigest digest = MessageDigest.getInstance(algorithm);
digest.update(data, 0, data.length);
return digest.digest();
} catch (NoSuchAlgorithmException e) {
throw new RenException(algorithm + " error", e);
}
}
private static String hex(byte[] data) {
char[] result = new char[data.length * 2];
int c = 0;
for (byte b : data) {
result[c++] = HEX_DIGITS[(b >> 4) & 0xf];
result[c++] = HEX_DIGITS[b & 0xf];
}
return new String(result);
}
}

15
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/encrypt/SignUtils.java

@ -0,0 +1,15 @@
package com.epmet.commons.thirdplat.encrypt;
import java.io.UnsupportedEncodingException;
public class SignUtils {
public static String generate(String content, String secret) throws UnsupportedEncodingException {
String sign = EncryptUtils.sha256(content);
sign = EncryptUtils.md5Hex(sign + secret);
return sign;
}
public static void main(String[] args) {
System.out.println(777);
}
}

13
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/JcetThirdplatProps.java

@ -0,0 +1,13 @@
package com.epmet.commons.thirdplat.properties;
import lombok.Data;
/**
* 酒城e通三方平台配置
*/
@Data
public class JcetThirdplatProps {
private String domain;
private String appkey;
private String appsecret;
}

12
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java

@ -0,0 +1,12 @@
package com.epmet.commons.thirdplat.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties(prefix = "thirdplat")
public class ThirdplatProps {
private JcetThirdplatProps jcet;
}

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -72,6 +72,7 @@ public enum EpmetErrorCode {
NOT_DEL_AGENCY_GRID(8207, "该机关存在网格,不允许删除"),
REQUIRE_PERMISSION(8301, "您没有足够的操作权限"),
THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"),
NOT_ADD_GRID(8401,"您当前的网格名称已存在,请重新修改"),
MOBILE_USED(8402,"该手机号已注册"),
@ -144,7 +145,6 @@ public enum EpmetErrorCode {
TOPIC_IS_HIDDEN(9006,"该话题已被屏蔽,请先解除屏蔽"),
TOPIC_IS_CLOSED(9008,"该话题已关闭,无法转为议题");
private int code;
private String msg;

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -360,4 +360,14 @@ public class RedisKeys {
public static String getResiUserKey(String userId){
return rootPrefix.concat("resi:user:").concat(userId);
}
/**
* @Description 客户的ApiService
* @return
* @author wxz
* @date 2021.01.20 16:56
*/
public static String getCustomerApiServiceKey(String customerId) {
return rootPrefix.concat("customer:thirdplat:apiservice:").concat(customerId);
}
}

48
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -188,6 +188,29 @@ public class HttpClientManager {
}
public Result<String> sendPost(String url, boolean isHttps, String jsonStrParam,Map<String,String> headerMap) {
try {
HttpPost httppost = new HttpPost(url);
httppost.setConfig(requestConfig);
httppost.addHeader(HEADER_CONTENT_TYPE, HEADER_APPLICATION_JSON);
if (null != headerMap){
headerMap.forEach((k,v) -> {
httppost.addHeader(k,v);
});
}
if (StringUtils.isNotEmpty(jsonStrParam)) {
StringEntity se = new StringEntity(jsonStrParam, UTF8);
httppost.setEntity(se);
}
return execute(httppost, isHttps);
} catch (Exception e) {
log.error("send exception", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
}
/**
* 上传临时素材
* @author zhaoqifeng
@ -325,6 +348,31 @@ public class HttpClientManager {
}
}
public Result<String> sendGet(String url, boolean isHttps, Map<String, Object> params, Map<String,String> headerMap) {
try {
URIBuilder builder = new URIBuilder(url);
if (!CollectionUtils.isEmpty(params)) {
Set<String> set = params.keySet();
for (String key : set) {
builder.setParameter(key, params.get(key) == null ? "" : String.valueOf(params.get(key)));
}
}
HttpGet httpGet = new HttpGet(builder.build());
httpGet.setConfig(requestConfig);
if (null != headerMap){
headerMap.forEach((k,v) -> {
httpGet.addHeader(k,v);
});
}
return execute(httpGet, isHttps);
} catch (Exception e) {
log.error("sendGet exception", e);
return new Result<String>().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
}
private Result<String> execute(HttpRequestBase httpMethod, boolean isHttps) {
CloseableHttpResponse response = null;
try {

1
epmet-commons/pom.xml

@ -23,6 +23,7 @@
<module>epmet-commons-tools-wx-mp</module>
<module>epmet-commons-service-call</module>
<module>epmet-commons-extapp-auth</module>
<module>epmet-commons-thirdplat</module>
<module>epmet-commons-rocketmq</module>
</modules>

10
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/UserMessageConstans.java

@ -8,4 +8,14 @@ package com.epmet.constant;
public interface UserMessageConstans {
String READ = "read";
String UNREAD = "unread";
/**
* 小程序
*/
String MINI = "mini";
/**
* 第三方app
*/
String APP = "app";
}

43
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java

@ -26,12 +26,14 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserMessageConstans;
import com.epmet.constant.WxMsgTemplateSubscribeStatus;
import com.epmet.constant.WxmpMessageConstant;
import com.epmet.dao.WxmpResiUserSubscribeDao;
import com.epmet.dao.WxmpTemplateMsgSubscribeStatusDao;
import com.epmet.dao.WxmpUserSubscribeRecordDao;
import com.epmet.dao.WxmpWorkUserSubscribeDao;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.*;
@ -140,6 +142,13 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
if (!(msgList.size() > NumConstant.ZERO)) {
throw new RenException("待发送消息不能为空");
}
//2021.1.19 根据客户类型判断是否允许推送微信消息【兼容泸州】 sun start
PaCustomerDTO pc = thirdCustomer(msgList.get(NumConstant.ZERO).getCustomerId());
if (!pc.getType().equals(UserMessageConstans.MINI)) {
logger.warn(String.format("当前客户不允许推送微信消息,客户Id->%s", msgList.get(NumConstant.ZERO).getCustomerId()));
return;
}
//2021.1.19 end
int succecssCount = 0;
// 获取templateId
CustomerTemplateListFormDTO customerTemplateListFormDTO = new CustomerTemplateListFormDTO();
@ -337,6 +346,13 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
if (msgList.size() == 0){
return;
}
//2021.1.19 根据客户类型判断是否允许推送微信消息【兼容泸州】 sun start
PaCustomerDTO pc = thirdCustomer(msgList.get(NumConstant.ZERO).getCustomerId());
if (!pc.getType().equals(UserMessageConstans.MINI)) {
logger.warn(String.format("当前客户不允许推送微信消息,客户Id->%s", msgList.get(NumConstant.ZERO).getCustomerId()));
return;
}
//2021.1.19 end
// 获取templateId
TemplateListV2FormDTO templateListV2FormDTO = new TemplateListV2FormDTO();
templateListV2FormDTO.setCustomerId(msgList.get(0).getCustomerId());
@ -873,8 +889,33 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
if(msgSubscribeStatusDao.updateUserSubscribe(formDTO)<NumConstant.ONE){
throw new RenException("重新激活订阅操作失败");
}
}
/**
* @return
* @Description 根据客户Id获取客户基础数据
* @author sun
*/
private PaCustomerDTO thirdCustomer(String customerId) {
String url = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/" + customerId;
Result<String> data = HttpClientManager.getInstance().sendGet(url, null);
logger.info("WxmpMessageServiceImpl.thirdCustomer:httpclient->url:" + url + ",结果->" + data);
if (!data.success()) {
logger.error(String.format("调用third服务查询客户基础数据失败,客户Id->%s", customerId));
throw new RenException(data.getCode(), data.getInternalMsg());
}
JSONObject toResult = JSON.parseObject(data.getData());
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (null != toResult.get("code")) {
result.setCode(((Integer) toResult.get("code")).intValue());
}
if (!result.success()) {
throw new RenException(result.getCode());
}
Object RegisterResult = result.getData();
JSONObject jsonObject = JSON.parseObject(RegisterResult.toString());
PaCustomerDTO resultDTO = ConvertUtils.mapToEntity(jsonObject, PaCustomerDTO.class);
return resultDTO;
}
}

2
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml

@ -54,6 +54,8 @@
AND GRID_ID = #{gridId}
AND ISSUE_STATUS = 'shift_project'
ORDER BY UPDATED_TIME DESC
LIMIT #{pageNo},
#{pageSize}
</select>
<!-- 新增议题 -->

20
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/ApiServiceFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiServiceFormDTO {
public interface GetByCustomerId extends PageFormDTO.AddUserShowGroup {}
@NotBlank(message = "客户ID不能为空", groups = { GetByCustomerId.class })
private String customerId;
}

16
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ThirdplatApiserviceResultDTO.java

@ -0,0 +1,16 @@
package com.epmet.dto.result;
import lombok.Data;
@Data
public class ThirdplatApiserviceResultDTO {
/**
* 客户id
*/
private String customerId;
/**
* aipService名称
*/
private String apiServiceName;
}

15
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java

@ -4,12 +4,10 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.GridCountFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@ -94,4 +92,13 @@ public interface OperCrmOpenFeignClient {
*/
@PostMapping("/oper/crm/parameter/parameterupdate")
Result updateParamInfo(@RequestBody List<CrmParameterResultDTO> formDTOS);
/**
* @Description 根据客户id查询配置的apiService
* @return
* @author wxz
* @date 2021.01.20 15:55
*/
@PostMapping("/oper/crm/customer/get-apiservice-by-customerid")
Result<ThirdplatApiserviceResultDTO> getApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form);
}

11
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java

@ -5,12 +5,10 @@ import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.GridCountFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import org.springframework.stereotype.Component;
@ -69,4 +67,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result updateParamInfo(List<CrmParameterResultDTO> formDTOS) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "updateParamInfo", formDTOS);
}
@Override
public Result<ThirdplatApiserviceResultDTO> getApiServiceByCustomerId(ApiServiceFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getApiServiceByCustomerId", form);
}
}

22
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java

@ -31,13 +31,11 @@ import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CustomerDetailResultDTO;
import com.epmet.dto.result.CustomerInfoResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.dto.result.ValidCustomerResultDTO;
import com.epmet.dto.result.*;
import com.epmet.excel.CustomerExcel;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.service.CustomerService;
import com.epmet.service.CustomerThirdplatApiServiceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -67,6 +65,9 @@ public class CustomerController {
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private CustomerThirdplatApiServiceService customerThirdplatApiServiceService;
@GetMapping("page")
public Result<PageData<CustomerDTO>> page(@RequestParam Map<String, Object> params) {
PageData<CustomerDTO> page = customerService.page(params);
@ -330,4 +331,17 @@ public class CustomerController {
return new Result();
}
/**
* @Description 根据客户id查询配置的apiService
* @return
* @author wxz
* @date 2021.01.20 15:55
*/
@PostMapping("get-apiservice-by-customerid")
public Result<ThirdplatApiserviceResultDTO> getApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form) {
ValidatorUtils.validateEntity(form, ApiServiceFormDTO.GetByCustomerId.class);
String customerId = form.getCustomerId();
return new Result<ThirdplatApiserviceResultDTO>().ok(customerThirdplatApiServiceService.getByCustomerId(customerId));
}
}

36
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java

@ -0,0 +1,36 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.entity.CustomerThirdplatApiserviceEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 客户所属的第三方平台的apiService列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-01-20
*/
@Mapper
public interface CustomerThirdplatApiserviceDao extends BaseDao<CustomerThirdplatApiserviceEntity> {
ThirdplatApiserviceResultDTO getByCustomerId(@Param("customerId") String customerId);
}

51
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerThirdplatApiserviceEntity.java

@ -0,0 +1,51 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 客户所属的第三方平台的apiService列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-01-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("customer_thirdplat_apiservice")
public class CustomerThirdplatApiserviceEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* aipService名称
*/
private String apiServiceName;
}

16
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java

@ -0,0 +1,16 @@
package com.epmet.service;
import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.entity.CustomerThirdplatApiserviceEntity;
public interface CustomerThirdplatApiServiceService {
/**
* @Description 根据客户id查询客户第三方平台的ApiService
* @return
* @author wxz
* @date 2021.01.20 15:47
*/
ThirdplatApiserviceResultDTO getByCustomerId(String customerId);
}

17
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

@ -33,6 +33,7 @@ import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ModuleConstant;
import com.epmet.constant.RoleKeyConstants;
import com.epmet.constant.ThirdConstant;
import com.epmet.constant.SystemMessageType;
import com.epmet.constant.UserWorkType;
import com.epmet.dao.CustomerDao;
@ -538,13 +539,15 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
throw new RenException(customerResult.getCode(), customerResult.getInternalMsg());
}
//7.设置服务器域名,业务域名
String domainUrl = "https://epmet-cloud.elinkservice.cn/api/third/code/setdomain/" + formDTO.getCustomerId();
String domainData = HttpClientManager.getInstance().sendPostByJSON(domainUrl, null).getData();
JSONObject domainObject = JSON.parseObject(domainData);
Result domainResult = ConvertUtils.mapToEntity(domainObject, Result.class);
if (!domainResult.success()) {
throw new RenException(domainResult.getCode(), domainResult.getInternalMsg());
//7.为微信小程序客户设置服务器域名,业务域名
if (ThirdConstant.MINI.equals(paCustomer.getType())) {
String domainUrl = "https://epmet-cloud.elinkservice.cn/api/third/code/setdomain/" + formDTO.getCustomerId();
String domainData = HttpClientManager.getInstance().sendPostByJSON(domainUrl, null).getData();
JSONObject domainObject = JSON.parseObject(domainData);
Result domainResult = ConvertUtils.mapToEntity(domainObject, Result.class);
if (!domainResult.success()) {
throw new RenException(domainResult.getCode(), domainResult.getInternalMsg());
}
}
}

42
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java

@ -0,0 +1,42 @@
package com.epmet.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.dao.CustomerThirdplatApiserviceDao;
import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.entity.CustomerThirdplatApiserviceEntity;
import com.epmet.service.CustomerThirdplatApiServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Map;
@Service
public class CustomerThirdplatApiServiceServiceImpl implements CustomerThirdplatApiServiceService {
@Autowired
private RedisUtils redisUtils;
@Autowired
private CustomerThirdplatApiserviceDao thirdplatApiserviceDao;
@Override
public ThirdplatApiserviceResultDTO getByCustomerId(String customerId) {
ThirdplatApiserviceResultDTO apiService = null;
// 查redis,存redis
Map<String, Object> apiServiceMap = redisUtils.hGetAll(RedisKeys.getCustomerApiServiceKey(customerId));
if (!CollectionUtils.isEmpty(apiServiceMap)) {
apiService = BeanUtil.mapToBean(apiServiceMap, ThirdplatApiserviceResultDTO.class, true);
}
if (apiService == null) {
apiService = thirdplatApiserviceDao.getByCustomerId(customerId);
redisUtils.hMSet(RedisKeys.getCustomerApiServiceKey(customerId), BeanUtil.beanToMap(apiService));
}
return apiService;
}
}

14
epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.6__create_thirdplat_apiservice.sql

@ -0,0 +1,14 @@
create table customer_thirdplat_apiservice
(
`ID` varchar(64) NOT NULL COMMENT '唯一标识',
`CUSTOMER_ID` varchar(64) not null comment '客户id',
`API_SERVICE_NAME` varchar(64) not null comment 'aipService名称',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
collate utf8mb4_general_ci COMMENT ='客户所属的第三方平台的apiService列表';

33
epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.CustomerThirdplatApiserviceDao">
<resultMap type="com.epmet.entity.CustomerThirdplatApiserviceEntity" id="customerThirdplatApiserviceMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="apiServiceName" column="API_SERVICE_NAME"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getByCustomerId" resultType="com.epmet.dto.result.ThirdplatApiserviceResultDTO">
select id,
customer_id,
api_service_name,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from customer_thirdplat_apiservice cta
where cta.CUSTOMER_ID = #{customerId}
</select>
</mapper>

13
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java

@ -79,6 +79,19 @@ public class StrangerResiGuideController {
}
/**
* @Description H5版 自动/选定定位获取地附近网格列表
* @param customerGridListFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerGridForStrangerResultDTO>>
* @author wangc
* @date 2021.01.18 16:39
*/
@PostMapping("sso/publiclocationgridlist")
Result<List<CustomerGridForStrangerResultDTO>> locationGridList(@RequestBody CustomerGridListFormDTO customerGridListFormDTO){
ValidatorUtils.validateEntity(customerGridListFormDTO);
return strangerAccessRecordService.listCustomerGridH5(customerGridListFormDTO);
}
/**
* @Description 陌生访客手动选定位置获取附近网格数据
* @Param CustomerGridListFormDTO

10
epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java

@ -120,4 +120,14 @@ public interface StrangerAccessRecordService extends BaseService<StrangerAccessR
* @Description 单客户-陌生人根据地区编码查询附近网格列表
**/
Result<List<PublicCustomerGridForStrangerResultDTO>> thirdCustomerGridList(PublicCustomerGridListFormDTO formDTO);
/**
* @Description H5版 自动/选定定位获取地附近网格列表
* @param customerGridListFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerGridForStrangerResultDTO>>
* @author wangc
* @date 2021.01.18 16:39
*/
Result<List<CustomerGridForStrangerResultDTO>> listCustomerGridH5(CustomerGridListFormDTO customerGridListFormDTO);
}

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

@ -31,6 +31,7 @@ import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.OperCustomizeFeignClient;
import com.epmet.service.StrangerAccessRecordService;
import com.epmet.utils.ModuleConstant;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -303,6 +304,48 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc
}
/**
* @Description H5版 自动/选定定位获取地附近网格列表
* @param customerGridListFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerGridForStrangerResultDTO>>
* @author wangc
* @date 2021.01.18 16:39
*/
@Override
public Result<List<CustomerGridForStrangerResultDTO>> listCustomerGridH5(CustomerGridListFormDTO customerGridListFormDTO) {
ListCustomerGridFormDTO listCustomerGridFormDTO = new ListCustomerGridFormDTO();
listCustomerGridFormDTO.setAreaCode(StringUtils.isBlank(customerGridListFormDTO.getSelectedAreaCode()) ?
customerGridListFormDTO.getAreaCode() : customerGridListFormDTO.getSelectedAreaCode());
listCustomerGridFormDTO.setPageNo(null == customerGridListFormDTO.getPageNo() ? ModuleConstant.MIN_CURRENT_PAGE_NO : customerGridListFormDTO.getPageNo());
listCustomerGridFormDTO.setPageSize(customerGridListFormDTO.getPageSize());
Result<List<CustomerGridForStrangerResultDTO>> queryResult =
govOrgFeignClient
.queryGridListByAreaCode(listCustomerGridFormDTO);
//Feign调用成功
if (queryResult.success()) {
List<CustomerGridForStrangerResultDTO> queryList = queryResult.getData();
if (null != queryResult && queryList.size() > 0) {
StrangerAccessRecordEntity strangerTrance = new StrangerAccessRecordEntity();
strangerTrance.setLocationAreaCode(listCustomerGridFormDTO.getAreaCode());
strangerTrance.setIsAuthorized(customerGridListFormDTO.getIsAuthorized());
strangerTrance.setGridNumber(queryList.size());
strangerTrance.setVisitTime(new Date());
strangerTrance.setProvince(customerGridListFormDTO.getProvince());
strangerTrance.setCity(customerGridListFormDTO.getCity());
strangerTrance.setArea(customerGridListFormDTO.getArea());
insert(strangerTrance);
}
}
return queryResult;
}
/**
* @Description 获取客户信息
* @param appId

12
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java

@ -63,4 +63,16 @@ public class ResiMineGridController {
return new Result<LatestGridInfoResultDTO>().ok(resiMineGridService.latestGridInfo(formDTO));
}
/**
* @return com.epmet.resi.mine.dto.result.LatestGridInfoResultDTO
* @param tokenDto
* @Author yinzuomei
* @Description 获取用户最近访问网格
* @Date 2020/3/24 11:10
**/
@PostMapping("sso/latestgridinfo")
public Result<LatestGridInfoResultDTO> latestGridInfo(@LoginUser TokenDto tokenDto){
LatestGridInfoResultDTO latestGridInfoResultDTO=resiMineGridService.getLatestGridInfoH5(tokenDto);
return new Result<LatestGridInfoResultDTO>().ok(latestGridInfoResultDTO);
}
}

9
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/service/ResiMineGridService.java

@ -39,4 +39,13 @@ public interface ResiMineGridService {
* @Date 2020/8/3
**/
LatestGridInfoResultDTO latestGridInfo(LatestGridInfoFormDTO formDTO);
/**
* H5版本 - 获取用户最近访问网格
*
* @Author
* @param tokenDto
* @return com.epmet.commons.tools.utils.Result<com.epmet.resi.mine.dto.result.LatestGridInfoResultDTO>
*/
LatestGridInfoResultDTO getLatestGridInfoH5(TokenDto tokenDto);
}

26
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/service/impl/ResiMineGridServiceImpl.java

@ -138,4 +138,30 @@ public class ResiMineGridServiceImpl implements ResiMineGridService {
return userResult.getData();
}
/**
* @Description H5版本 - 获取用户最近访问网格
* @param tokenDto
* @return com.epmet.dto.result.LatestGridInfoResultDTO
* @author wangc
* @date 2021.01.18 17:22
*/
@Override
public LatestGridInfoResultDTO getLatestGridInfoH5(TokenDto tokenDto) {
if (null == tokenDto || StringUtils.isBlank(tokenDto.getUserId())) {
logger.error(String.format("居民端获取用户最近访问的网格失败:tokenDto is null or userId is null"));
throw new RenException(ModuleConstant.USER_NOT_NULL);
}
if(!AppClientConstant.APP_RESI.equals(tokenDto.getApp())){
logger.error(String.format("居民端获取用户最近访问的网格失败,userId:%s,错误提示:%s",tokenDto.getUserId(),ModuleConstant.FOR_RESI_CALL));
throw new RenException(ModuleConstant.FOR_RESI_CALL);
}
logger.info(String.format("居民端获取用户最近访问网格入参%s", JSON.toJSONString(tokenDto)));
Result<LatestGridInfoResultDTO> userResult=epmetUserFeignClient.getLatestGridInfoByUserId(tokenDto.getUserId());
if(userResult.success()&&null!=userResult.getData()){
return userResult.getData();
}
logger.warn(String.format("居民端获取用户最近访问网格失败,调用epmet-user-server服务返回%s",JSON.toJSONString(userResult)));
return null ;
}
}

40
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserInfoFormDTO.java

@ -0,0 +1,40 @@
package com.epmet.dto.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/1/19 上午10:31
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserInfoFormDTO implements Serializable {
private static final long serialVersionUID = 3394557656494741201L;
public interface UserInfoForm{}
/**
* 工作端:WORK居民端:resi运营端:oper
*/
@NotBlank(message = "app类型不能为空",groups = {UserInfoForm.class})
private String app;
/**
* UID 用户唯一标识 即wx_open_id
*/
@NotBlank(message = "UID不能为空",groups = {UserInfoForm.class})
private String uid;
private String name;
private String mobile;
private String account;
private String userId;
}

9
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -477,4 +477,13 @@ public interface EpmetUserOpenFeignClient {
*/
@PostMapping("/epmetuser/staffrole/initrolesforcustomer/{customerId}")
Result initGovStaffRolesForCustomer(@PathVariable String customerId);
/**
* @Description 新增或更新用户信息
* @Param formDTO
* @author zxc
* @date 2021/1/19 上午10:35
*/
@PostMapping(value = "/epmetuser/user/saveuserinfo")
Result<UserDTO> saveUserInfo(@RequestBody UserInfoFormDTO formDTO);
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

@ -332,6 +332,11 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "specificRolesStaffs", rolesUsersListFormDTO);
}
@Override
public Result<UserDTO> saveUserInfo(UserInfoFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveUserInfo", formDTO);
}
@Override
public Result initGovStaffRolesForCustomer(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "initGovStaffRolesForCustomer", customerId);

5
epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java

@ -28,6 +28,11 @@ public interface UserConstant {
*/
String CLIENT_WEB = "web";
/**
* app
*/
String APP = "app";
/**
* 微信端
*/

12
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java

@ -154,4 +154,16 @@ public class UserController {
return new Result<UserBasicInfo>().ok(userService.getUserBasicInfo(formDTO));
}
/**
* @Description 新增或更新用户信息
* @Param formDTO
* @author zxc
* @date 2021/1/19 上午10:35
*/
@PostMapping("saveuserinfo")
public Result<UserDTO> saveUserInfo(@RequestBody UserInfoFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, UserInfoFormDTO.UserInfoForm.class);
return new Result<UserDTO>().ok(userService.saveUserInfo(formDTO));
}
}

18
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java

@ -4,6 +4,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.UserDTO;
import com.epmet.dto.UserHeadPhotoDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.UserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.CertifiedResultDTO;
import com.epmet.dto.result.CustomerUser4PointResultDTO;
@ -77,4 +78,21 @@ public interface UserWechatDao extends BaseDao<UserWechatEntity>{
//临时用下in
List<UserWechatDTO> selectNotInUserBaseInfoTemp();
/**
* @Description 根据appuid查询用户是否存在
* @Param uid
* @Param app
* @author zxc
* @date 2021/1/19 上午10:42
*/
UserDTO selectUserDTOByUid(@Param("uid")String uid,@Param("app")String app);
/**
* @Description 修改user_weChat信息
* @Param formDTO
* @author zxc
* @date 2021/1/19 上午11:04
*/
int editByUserId(UserInfoFormDTO formDTO);
}

8
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java

@ -86,4 +86,12 @@ public interface UserService extends BaseService<UserEntity> {
* @Description 居民端-查询用户基础信息
**/
UserBasicInfo getUserBasicInfo(UserBasicInfoFormDTO formDTO);
/**
* @Description 新增或更新用户信息
* @Param formDTO
* @author zxc
* @date 2021/1/19 上午10:35
*/
UserDTO saveUserInfo(UserInfoFormDTO formDTO);
}

43
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java

@ -279,4 +279,47 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
return baseDao.selectUserBasicInfo(formDTO);
}
/**
* @Description 新增或更新用户信息
* @Param formDTO
* @author zxc
* @date 2021/1/19 上午10:35
*/
@Override
public UserDTO saveUserInfo(UserInfoFormDTO formDTO) {
UserDTO result = new UserDTO();
UserDTO userDTO = userWechatDao.selectUserDTOByUid(formDTO.getUid(), formDTO.getApp());
if (null == userDTO){
// 用户不存在
//user表新增
UserEntity userEntity = new UserEntity();
userEntity.setFromApp(UserConstant.APP_RESI);
userEntity.setFromClient(UserConstant.APP);
if (baseDao.insert(userEntity) < NumConstant.ONE) {
log.error("小程序登陆,居民端user表新增数据失败");
throw new RenException(UserConstant.SAVE_USER);
}
UserWechatEntity entity = new UserWechatEntity();
entity.setMobile(formDTO.getMobile());
entity.setUserId(userEntity.getId());
entity.setNickname(formDTO.getName());
entity.setWxOpenId(formDTO.getUid());
entity.setSex(NumConstant.ZERO);
if (userWechatDao.insert(entity) < NumConstant.ONE) {
log.error("小程序登陆,居民端user_wechat表新增数据失败");
throw new RenException(UserConstant.SAVE_USER_WECHAT);
}
result.setId(userEntity.getId());
}else {
// 用户已存在
formDTO.setUserId(userDTO.getId());
if (userWechatDao.editByUserId(formDTO) < NumConstant.ONE) {
log.error("小程序登陆,居民端user_weChat表更新数据失败");
throw new RenException(UserConstant.UPDATE_USER_WECHAT);
}
result.setId(userDTO.getId());
}
return result;
}
}

29
epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml

@ -38,6 +38,24 @@
USER_ID = #{userId}
</update>
<!-- 修改user_weChat信息 -->
<update id="editByUserId">
UPDATE user_wechat
<set>
<if test="name != null and name != '' ">
NICKNAME = #{name},
</if>
<if test="mobile != null and mobile != '' ">
MOBILE = #{mobile},
</if>
UPDATED_BY = #{userId},
UPDATED_TIME = NOW()
</set>
WHERE
DEL_FLAG = 0
AND USER_ID = #{userId}
</update>
<!-- 根据app、openId查询用户是否存在 -->
<select id="selectUserDTOByOpenId" parameterType="com.epmet.dto.form.WxLoginUserInfoFormDTO" resultType="com.epmet.dto.UserDTO">
SELECT
@ -135,4 +153,15 @@
AND uw.DEL_FLAG = '0'
and uw.NICKNAME is not null
</select>
<!-- 根据app、uid查询用户是否存在 -->
<select id="selectUserDTOByUid" resultType="com.epmet.dto.UserDTO">
SELECT u.*
FROM USER u
LEFT JOIN user_wechat uw ON u.id = uw.USER_ID AND uw.WX_OPEN_ID = #{uid}
WHERE
u.DEL_FLAG = '0'
AND uw.DEL_FLAG = '0'
AND u.FROM_APP = #{app}
</select>
</mapper>

Loading…
Cancel
Save