Browse Source

Merge remote-tracking branch 'origin/dev' into release

master
zxc 5 years ago
parent
commit
da37886270
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java
  3. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java
  4. 5
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml
  5. 37
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerAndUserResultDTO.java
  6. 2
      epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml
  7. 2
      epmet-module/epmet-third/epmet-third-server/pom.xml
  8. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PublicAccountCallBackController.java
  9. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java
  10. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java
  11. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXBizMsgCrypt.java
  12. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java
  13. 1
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java
  14. 61
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  15. 105
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java
  16. 24
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
  17. 2
      epmet-user/epmet-user-server/deploy/docker-compose-dev.yml
  18. 2
      epmet-user/epmet-user-server/pom.xml
  19. 62
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java
  20. 26
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java

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

@ -61,6 +61,7 @@ public enum EpmetErrorCode {
HAVE_HANDLE(8123,"存在待处理事项,请先处理"),
ACTUAL_TIME(8124,"请录入实际开始时间,实际结束时间"),
ACTUAL_NOT_FINISHED(8125,"请先结束活动"),
ACT_SIGN_UP_END_TIME_EARLIER_NOW_EERROR(8121,"活动报名截止时间应晚于当前时间"),
CANNOT_AUDIT_WARM(8201, "请完善居民信息"),
NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"),

2
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java

@ -258,7 +258,7 @@ public interface ActInfoDao extends BaseDao<ActInfoEntity> {
* @return java.util.List<com.epmet.dto.result.work.JoinedUserResultDTO>
* @param actId
* @author yinzuomei
* @description 已结束-已参加人员列表
* @description 已结束-已参加人员列表(审核中审核通过)
* @Date 2020/7/24 10:18
**/
List<JoinedUserResultDTO> queryJoinUserList(String actId);

14
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java

@ -147,6 +147,11 @@ public class WorkActServiceImpl implements WorkActService {
//构造属性保存活动属性,活动内容
ActInfoEntity actInfoEntity=this.constructActInfo(formDTO);
//校验参数
//校验 活动报名截止时间应该大于当前时间
if (actInfoEntity.getSignUpEndTime().before(DateUtils.minStrToSecondDate(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)))){
throw new RenException(EpmetErrorCode.ACT_SIGN_UP_END_TIME_EARLIER_NOW_EERROR.getCode(),EpmetErrorCode.ACT_SIGN_UP_END_TIME_EARLIER_NOW_EERROR.getMsg());
}
this.checkPublishFormDTO(actInfoEntity);
PublishActResultDTO publishActResultDTO=new PublishActResultDTO();
//内容审核(活动标题、招募要求、活动内容图文)
@ -186,18 +191,19 @@ public class WorkActServiceImpl implements WorkActService {
* @Date 2020/7/24 16:45
**/
private void checkPublishFormDTO(ActInfoEntity actInfoEntity) {
//
//1、活动预计开始时间、活动预计结束时间
if(actInfoEntity.getActStartTime().compareTo(actInfoEntity.getActEndTime())!=-1){
throw new RenException(EpmetErrorCode.ACT_START_TIME_ERROR.getCode());
throw new RenException(EpmetErrorCode.ACT_START_TIME_ERROR.getCode(),EpmetErrorCode.ACT_START_TIME_ERROR.getMsg());
}
//2、签到开始时间、签到结束时间
if(actInfoEntity.getSignInStartTime().compareTo(actInfoEntity.getSignInEndTime())!=-1){
throw new RenException(EpmetErrorCode.ACT_SIGN_IN_START_TIME_ERROR.getCode());
throw new RenException(EpmetErrorCode.ACT_SIGN_IN_START_TIME_ERROR.getCode(),EpmetErrorCode.ACT_SIGN_IN_START_TIME_ERROR.getMsg());
}
int n=actInfoEntity.getSignUpEndTime().compareTo(actInfoEntity.getActStartTime());
//3、报名截止时间(应该在活动预计开始时间之前)
if(n!=-1){
throw new RenException((EpmetErrorCode.ACT_SIGN_UP_END_TIME_ERROR.getCode()));
throw new RenException(EpmetErrorCode.ACT_SIGN_UP_END_TIME_ERROR.getCode(),EpmetErrorCode.ACT_SIGN_UP_END_TIME_ERROR.getMsg());
}
}
@ -327,7 +333,7 @@ public class WorkActServiceImpl implements WorkActService {
if(result.success()&&null!=result.getData()){
actInfoEntity.setPid(result.getData().getPid());
}else{
logger.warn("根据agencyId查询组织信息失败,agencyId=",formDTO.getSponsorId());
logger.warn("根据agencyId查询组织信息失败,agencyId={}",formDTO.getSponsorId());
}
}else{
actInfoEntity.setPid(StrConstant.EPMETY_STR);

5
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml

@ -551,7 +551,7 @@
limit #{pageNo}, #{pageSize}
</select>
<!-- 已结束-参加人员列表 -->
<!-- 已结束-报名人员列表(审核中、审核通过) -->
<select id="queryJoinUserList" parameterType="java.lang.String" resultType="com.epmet.dto.result.work.JoinedUserResultDTO">
SELECT
aur.id as actUserRelationId,
@ -572,7 +572,8 @@
and ai.DEL_FLAG='0')
WHERE
aur.DEL_FLAG = '0'
AND aur.`STATUS` = 'passed'
AND aur.`STATUS` != 'refused'
AND aur.`STATUS` != 'canceled'
AND aur.ACT_ID =#{actId}
order by aur.CREATED_TIME asc
</select>

37
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerAndUserResultDTO.java

@ -0,0 +1,37 @@
package com.epmet.dto.result;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.PaUserDTO;
import com.epmet.dto.PaUserWechatDTO;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Description 查询授权客户及管理员信息-接口返参
* @Author sun
*/
@Data
public class CustomerAndUserResultDTO implements Serializable {
private static final long serialVersionUID = 5214475907074876716L;
/**
* 客户Id
*/
private String customerId;
/**
* 客户Id
*/
private String customerName;
/**
* 管理员称谓
*/
private String appellation;
/**
* 管理员手机号
*/
private String phone;
}

2
epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-third-server:
container_name: epmet-third-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.108
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.109
ports:
- "8110:8110"
network_mode: host # 使用现有网络

2
epmet-module/epmet-third/epmet-third-server/pom.xml

@ -2,7 +2,7 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.0.108</version>
<version>0.0.109</version>
<parent>
<groupId>com.epmet</groupId>

7
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PublicAccountCallBackController.java

@ -55,6 +55,13 @@ public class PublicAccountCallBackController {
}
}
/**
* @return java.lang.String
* @author sun
* @description 此请求url是公众号后台设置的消息url首次创建公众号时微信会发送get请求调用接口
* 后边公众号所有的消息都是通过该url发送post请求目前对于公众号的消息全部回复空字符串
* 后续可以回复各种格式的消息具体可参考 https://www.cnblogs.com/xdp-gacl/p/5161206.html
*/
@PostMapping(value = "/callback")
public String wxServerValdation() {
return "";

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java

@ -27,9 +27,9 @@ public class WarrantController {
private WarrantService warrantService;
@PostMapping(value ="/{APPID}/callback")
public String acceptMessageAndEvent(HttpServletRequest request, @PathVariable("APPID") String appid,
public void acceptMessageAndEvent(HttpServletRequest request, @PathVariable("APPID") String appid,
HttpServletResponse response)throws IOException, DocumentException, AesException {
return warrantService.acceptMessageAndEvent(request, appid, response);
warrantService.acceptMessageAndEvent(request, appid, response);
}
}

7
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java

@ -22,6 +22,7 @@ import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.form.ModifyCustomerFormDTO;
import com.epmet.dto.form.RegisterByAuthFormDTO;
import com.epmet.dto.result.CustomerAgencyResultDTO;
import com.epmet.dto.result.CustomerAndUserResultDTO;
import com.epmet.dto.result.RegisterByAuthResultDTO;
import com.epmet.entity.PaCustomerEntity;
import org.apache.ibatis.annotations.Mapper;
@ -84,4 +85,10 @@ public interface PaCustomerDao extends BaseDao<PaCustomerEntity> {
* @date 2020/8/5 3:23 下午
*/
String selectCustomerName(@Param("customerId") String customerId);
/**
* @author sun
* @Description 查询客户及管理员信息
*/
CustomerAndUserResultDTO selectCustomerAndUser(@Param("customerId") String customerId);
}

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/mpaes/WXBizMsgCrypt.java

@ -85,7 +85,7 @@ public class WXBizMsgCrypt {
}
// 随机生成16位字符串
String getRandomStr() {
public String getRandomStr() {
String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
@ -103,7 +103,7 @@ public class WXBizMsgCrypt {
* @return 加密后base64编码的字符串
* @throws AesException aes加密失败
*/
String encrypt(String randomStr, String text) throws AesException {
public String encrypt(String randomStr, String text) throws AesException {
ByteGroup byteCollector = new ByteGroup();
byte[] randomStrBytes = randomStr.getBytes(CHARSET);
byte[] textBytes = text.getBytes(CHARSET);

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java

@ -13,6 +13,6 @@ import java.io.IOException;
*/
public interface WarrantService {
String acceptMessageAndEvent(HttpServletRequest request,String appid,HttpServletResponse response)throws IOException, DocumentException, AesException;
void acceptMessageAndEvent(HttpServletRequest request,String appid,HttpServletResponse response)throws IOException, DocumentException, AesException;
}

1
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java

@ -60,7 +60,6 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic
String userId = tokenDto.getUserId();
//获取预授权码
String preAuthCode = componentVerifyTicketService.preAuthCode();
// String redirectUrl = WxMaCodeConstant.WEB_URL + formDTO.getClientType();
String redirectUrl = String.format(WxMaCodeConstant.WEB_URL,source,formDTO.getClientType());
String authUrl = String.format(WxMaCodeConstant.API_AUTH_REGISTER_URL, componentAppId, preAuthCode, redirectUrl);
result.setUrl(authUrl);

61
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -3,6 +3,10 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.config.utils.IOUtils;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.dingtalk.api.response.OapiRobotSendResponse;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -12,6 +16,7 @@ import com.epmet.constant.ModuleConstant;
import com.epmet.constant.ThirdRedisKeyConstant;
import com.epmet.constant.ThirdRunTimeInfoConstant;
import com.epmet.dao.*;
import com.epmet.dto.CustomerMpDTO;
import com.epmet.dto.PaCustomerUserAgencyDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
@ -21,6 +26,7 @@ import com.epmet.mpaes.WXXmlToMapUtil;
import com.epmet.redis.RedisThird;
import com.epmet.service.ComponentVerifyTicketService;
import com.epmet.wxapi.constant.WxMaCodeConstant;
import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -34,6 +40,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN;
import static com.epmet.constant.ThirdRunTimeInfoConstant.*;
@ -88,6 +95,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
private PaUserDao paUserDao;
@Autowired
private PaCustomerServiceImpl paCustomerServiceImpl;
@Autowired
private PaCustomerDao paCustomerDao;
@Value("${third.platform.appId}")
private String componentAppId;
@ -448,6 +457,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
authCodeDao.updateAppId(customerId,clientType,authAppId);
// 4. 保存授权方账户信息
this.saveAuthAccountInfo(customerId,authAppId,clientType);
// 5. 校验客户居民端、工作端小程序是否全部授权,全部授权完成的推送钉钉消息 sun
this.checkAuthorization(customerId);
log.info("回调结束");
}
@ -689,4 +700,54 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
date.setTime(aLong);
return date;
}
/**
* @author sun
* @Description 校验客户两哥小程序是否完成授权
*/
private void checkAuthorization(String customerId){
List<CustomerMpDTO> list = customerMpDao.selectByCustomerId(customerId);
AtomicBoolean bl = new AtomicBoolean(false);
list.forEach(mp->{
if(mp.getAuthorizationFlag()!=NumConstant.ONE){
bl.set(true);
}
});
if(!bl.get()){
dDingNews(customerId);
}
}
/**
* @author sun
* @Description 发送钉钉消息通知运营人员有新客户完成授权
*/
private String dDingNews(String customerId) {
//1.查询客户及管理员信息,用于发送消息使用
CustomerAndUserResultDTO result = paCustomerDao.selectCustomerAndUser(customerId);
if (null == result || null == result.getCustomerId()) {
log.error("授权完成发送钉钉消息失败,原因:未查询到客户信息,客户Id->" + customerId);
return null;
}
//2.拼接钉钉消息内容并发送
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=b4e47783ad72ba643278598ff8af90e745890c13538b2a4dc139635a71289dfd");
OapiRobotSendRequest request = new OapiRobotSendRequest();
request.setMsgtype("markdown");
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
markdown.setTitle("授权客户信息");
//"新客户通知"几个字是设置机器人时自定义的关键字,要保持代码与机器人设置的一致
markdown.setText("新客户通知: \n" +
"> 客户名称: " + result.getCustomerName() + "\n\n" +
"> 管理员称谓: " + result.getAppellation() + "\n\n" +
"> 联系方式: " + result.getPhone() + "\n");
request.setMarkdown(markdown);
try {
OapiRobotSendResponse response = client.execute(request);
} catch (ApiException e) {
log.error("机器人生病了......");
e.printStackTrace();
}
return null;
}
}

105
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

@ -8,6 +8,7 @@ import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.dingtalk.api.response.OapiRobotSendResponse;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ModuleConstant;
@ -41,6 +42,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -87,15 +89,16 @@ public class WarrantServiceImpl implements WarrantService {
*/
@Transactional(rollbackFor = Exception.class)
@Override
public String acceptMessageAndEvent(HttpServletRequest request, String appId, HttpServletResponse response)throws IOException, DocumentException, AesException {
log.info("消息与事件接收URL【代码审核结果】开始执行......");
log.info("appId:"+ appId);
public void acceptMessageAndEvent(HttpServletRequest request, String appId, HttpServletResponse response)throws IOException, DocumentException, AesException {
request.setCharacterEncoding(ModuleConstant.UTF8);
String msgSignature = request.getParameter(ModuleConstant.MSG_SIGNATURE);
String timeStamp = request.getParameter(ModuleConstant.TIMESTAMP);
String nonce = request.getParameter(ModuleConstant.NONCE);
if (!StringUtils.isNotBlank(msgSignature)) {
return ModuleConstant.SUCCESS;// 微信推送给第三方开放平台的消息一定是加过密的,无消息加密无法解密消息
// 微信推送给第三方开放平台的消息一定是加过密的,无消息加密无法解密消息
PrintWriter pw = response.getWriter();
pw.write(ModuleConstant.SUCCESS);
pw.flush();
}
InputStream inputStream;
String postData = null;
@ -109,7 +112,6 @@ public class WarrantServiceImpl implements WarrantService {
} catch (AesException e) {
e.printStackTrace();
}
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg));
// 将xml转为map
Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg);
Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML);
@ -117,20 +119,22 @@ public class WarrantServiceImpl implements WarrantService {
log.info(String.format(ThirdRunTimeInfoConstant.MSG_TYPE,msgType));
String toUserName = null;
String fromUserName = null;
if (xml.containsKey(ModuleConstant.TO_USER_NAME)){
toUserName = xml.get(ModuleConstant.TO_USER_NAME).toString();
log.info("toUserName为:" + toUserName);
}
if (xml.containsKey(ModuleConstant.FROM_USER_NAME)){
fromUserName = xml.get(ModuleConstant.FROM_USER_NAME).toString();
log.info("fromUserName为:"+fromUserName);
}
if (msgType.equals(ModuleConstant.EVENT_LOW)) {
String event = xml.get(ModuleConstant.EVENT).toString();
if (xml.containsKey(ModuleConstant.TO_USER_NAME)){
toUserName = xml.get(ModuleConstant.TO_USER_NAME).toString();
}
if (xml.containsKey(ModuleConstant.FROM_USER_NAME)){
fromUserName = xml.get(ModuleConstant.FROM_USER_NAME).toString();
}
if (event.startsWith(ModuleConstant.WE_APP_AUDIT)) {
log.info("消息与事件接收URL【代码审核结果】开始执行......");
// TODO 目前来看,msgType = ‘event’ 的是代码审核结果
Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString());
CodeAuditRecordFormDTO codeAuditRecord = ConvertUtils.mapToEntity(xml, CodeAuditRecordFormDTO.class);
codeAuditRecord.setWechatCreateTime(componentVerifyTicketServiceImpl.sToDate(createTime.toString()));
// String toUserName = codeAuditRecord.getToUserName();//小程序原始ID
CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName);
String clientType = customerIdAndClientResultDTO.getClientType();
String customerId = customerIdAndClientResultDTO.getCustomerId();
@ -147,7 +151,6 @@ public class WarrantServiceImpl implements WarrantService {
log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml));
codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord);
// 修改 code_audit_result 中的代码审核结果
// String event = codeAuditRecord.getEvent();
String reason = codeAuditRecord.getReason();
String codeResult = null;
switch (event) {
@ -167,7 +170,11 @@ public class WarrantServiceImpl implements WarrantService {
String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord);
codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult);
log.info("消息与事件接收URL【代码审核结果】结束......");
PrintWriter pw = response.getWriter();
pw.write(ModuleConstant.SUCCESS);
pw.flush();
}else {
log.info("==================== ==== event message ========= =");
this.replyEventMessage(request,response,event,toUserName,fromUserName);
}
}else if (msgType.equals(ModuleConstant.TEXT)){
@ -179,18 +186,15 @@ public class WarrantServiceImpl implements WarrantService {
// messagePushTextDao.insertMessageText(messagePushTextFormDTO);
String content = messagePushTextFormDTO.getContent();
log.info(String.format(ThirdRunTimeInfoConstant.CONTENT,content));
/**
* 测试公众号处理用户消息
* 模拟粉丝发送文本消息给专用测试公众号第三方平台方需根据文本消息的内容进行相应的响应
* 1微信模推送给第三方平台方文本消息其中 Content 字段的内容固定为TESTCOMPONENT_MSG_TYPE_TEXT
* 2第三方平台方立马回应文本消息并最终触达粉丝Content 必须固定为TESTCOMPONENT_MSG_TYPE_TEXT_callback
*/
this.processTextMessage(request,response,content,toUserName,fromUserName);
this.processTextMessage(request, response, content, toUserName, fromUserName);
}
return ModuleConstant.SUCCESS;
}
/*public static void main(String[] args) {
WarrantServiceImpl w = new WarrantServiceImpl();
w.dingDingRobot("haha","weapp_audit_fail","haha","jumian");
}*/
/**
* @Description 钉钉机器人报警
* @author zxc
@ -236,7 +240,7 @@ public class WarrantServiceImpl implements WarrantService {
}
/**
* 方法描述: 类型为enevt的时候拼接
* 方法描述: 类型为event的时候拼接
* @param request
* @param response
* @param event
@ -247,8 +251,12 @@ public class WarrantServiceImpl implements WarrantService {
public void replyEventMessage(HttpServletRequest request, HttpServletResponse response,
String event, String toUserName, String fromUserName)
throws DocumentException, IOException {
log.info("================ event + from_callback...................");
String content = event + ModuleConstant.FROM_CALLBACK;
replyTextMessage(request,response,content,toUserName,fromUserName);
String s = replyTextMessage(request, response, content, toUserName, fromUserName);
PrintWriter pw = response.getWriter();
pw.write(s);
pw.flush();
}
@ -263,13 +271,24 @@ public class WarrantServiceImpl implements WarrantService {
String content,String toUserName, String fromUserName)
throws IOException, DocumentException{
if(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT.equals(content)){
String returnContent = content+ModuleConstant._CALL_BACK;
replyTextMessage(request,response,returnContent,toUserName,fromUserName);
log.info("收到消息,要回复了......");
// String returnContent = content+ModuleConstant._CALL_BACK;
String returnContent = "TESTCOMPONENT_MSG_TYPE_TEXT_callback";
log.info("拼接的回复内容【普通】:"+returnContent);
String result = replyTextMessage(request, response, returnContent, toUserName, fromUserName);
log.info("加密的回复内容为:"+result);
PrintWriter pw = response.getWriter();
pw.write(result);
pw.flush();
}else if(StringUtils.startsWithIgnoreCase(content, ModuleConstant.QUERY_AUTH_CODE)){
response.getWriter().print("");//需在5秒内返回空串表明暂时不回复,然后再立即使用客服消息接口发送消息回复粉丝
PrintWriter pw = response.getWriter();//需在5秒内返回空串表明暂时不回复,然后再立即使用客服消息接口发送消息回复粉丝
pw.write("");
pw.flush();
log.info(String.format(ThirdRunTimeInfoConstant.TEXT_MESSAGE_LOG_INFO,content,content.split(ThirdRedisKeyConstant.COLON)[NumConstant.ONE],fromUserName,toUserName));
//接下来客服API再回复一次消息
replyApiTextMessage(content.split(ThirdRedisKeyConstant.COLON)[NumConstant.ONE],toUserName);
String[] split = content.split(ThirdRedisKeyConstant.COLON);
replyApiTextMessage(split[NumConstant.ONE],fromUserName);
}
}
@ -284,21 +303,30 @@ public class WarrantServiceImpl implements WarrantService {
* @param fromUserName 发送人
* @author zxc
*/
public void replyTextMessage(HttpServletRequest request, HttpServletResponse response,
public String replyTextMessage(HttpServletRequest request, HttpServletResponse response,
String content,String toUserName, String fromUserName)
throws DocumentException, IOException {
Long createTime = System.currentTimeMillis() / NumConstant.ONE_THOUSAND;
StringBuffer sb = new StringBuffer(512);
log.info("********************** encryption start..............");
sb.append("<xml>");
sb.append("<ToUserName><![CDATA["+toUserName+"]]></ToUserName>");
sb.append("<FromUserName><![CDATA["+fromUserName+"]]></FromUserName>");
sb.append("<CreateTime>"+createTime.toString()+"</CreateTime>");
sb.append("<MsgType><![CDATA[text]]></MsgType>");
sb.append("<CreateTime>"+createTime+"</CreateTime>");
sb.append("<Content><![CDATA["+content+"]]></Content>");
sb.append("<MsgType><![CDATA[text]]></MsgType>");
sb.append("</xml>");
String replyMsg = sb.toString();
log.info(String.format(ThirdRunTimeInfoConstant.SEND_MESSAGE_XML,replyMsg));
returnJSON(replyMsg,response);
WXBizMsgCrypt wxBizMsgCrypt;
String generate = null;
try {
wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId);
generate = wxBizMsgCrypt.encryptMsg(replyMsg, String.valueOf(createTime), wxBizMsgCrypt.getRandomStr());
} catch (AesException e) {
e.printStackTrace();
}
return generate;
}
/**
@ -319,15 +347,20 @@ public class WarrantServiceImpl implements WarrantService {
jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, auth_code);
String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData();
HashMap<String,Map> hashMap = JSON.parseObject(authInfo, HashMap.class);
if (hashMap.containsKey("errcode")){
throw new RenException("全网发布接入检测【API文本消息回复失败】");
}
Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO);
AuthorizationInfoResultDTO authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class);
String authorizer_access_token = authorizationInfoResultDTO.getAuthorizer_access_token();
Map<String,Object> msgMap = new HashMap<String,Object>();
String msg = auth_code + "_from_api";
msgMap.put("content", msg);
JSONObject json = new JSONObject();
json.put("touser",fromUserName);
json.put("msgtype", "text");
json.put("text", "{\"content\":\""+auth_code+ModuleConstant._FROM_API+"\"}");
json.put("msgtype","text");
json.put("text",msgMap);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.SEND_MESSAGE_CUSTOM + authorizer_access_token, JSON.toJSONString(json)).getData();
log.info("客服发送接口返回值:"+data);
}
@ -347,7 +380,7 @@ public class WarrantServiceImpl implements WarrantService {
JsonGenerator generator = objectMapper.getJsonFactory().
createJsonGenerator(response.getOutputStream(), encoding);
objectMapper.writeValue(generator, data);
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
}

24
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml

@ -82,6 +82,30 @@
AND id = #{customerId}
</select>
<select id="selectCustomerAndUser" resultType="com.epmet.dto.result.CustomerAndUserResultDTO">
SELECT
pc.id AS "customerId",
pc.customer_name AS "customerName",
CONCAT(
pu.real_name,
IF (
pu.gender = 1,
'先生',
IF (pu.gender = 2, '女士', '')
)
) AS "appellation",
pu.phone AS "phone"
FROM
pa_customer pc
INNER JOIN pa_customer_user_agency pcua ON pc.id = pcua.customer_id
INNER JOIN pa_user pu ON pcua.user_id = pu.id
WHERE
pc.del_flag = '0'
AND pcua.del_flag = '0'
AND pu.del_flag = '0'
AND pc.id = #{customerId}
</select>
<update id="updateCustomerById">
UPDATE pa_customer
SET is_initialize = #{isInitialize}

2
epmet-user/epmet-user-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-user-server:
container_name: epmet-user-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.110
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.112
ports:
- "8087:8087"
network_mode: host # 不会创建新的网络

2
epmet-user/epmet-user-server/pom.xml

@ -2,7 +2,7 @@
<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">
<modelVersion>4.0.0</modelVersion>
<version>0.3.110</version>
<version>0.3.112</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-user</artifactId>

62
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java

@ -87,8 +87,17 @@ public class UserBaseInfoRedis {
redisUtils.hMSet(key, map,RedisUtils.DEFAULT_EXPIRE * NumConstant.SEVEN);
}
public String get(String id){
return null;
public UserBaseInfoResultDTO get(String userId){
if(StringUtils.isNotBlank(userId)) {
Map<String, Object> map = redisUtils.hGetAll(UserRedisKeys.getResiUserKey(userId));
if (null != map && !map.isEmpty()) {
//缓存中有数据,直接返回
return BeanUtil.mapToBean(map, UserBaseInfoResultDTO.class, true);
}
}
return null;
}
/**
@ -193,6 +202,14 @@ public class UserBaseInfoRedis {
UserBaseInfoResultDTO currentCache = ConvertUtils.sourceToTarget(entity,UserBaseInfoResultDTO.class);
UserBaseInfoResultDTO orientCache = get(entity.getUserId());
if(null != orientCache && StringUtils.isNotBlank(orientCache.getUserId())){
//将要更改的信息赋值到原缓存中
mergeObject(currentCache,orientCache);
//将原来的缓存对象赋值给要更新的缓存对象
//此时orientCache中包概括要更新的属性以及之前有切不更新的属性
currentCache = orientCache;
}
RegisterRelationEntity relation = registerRelationDao.selectRegisteredGridIdByUserId(entity.getUserId());
//如果没有首次注册网格,则没有网格名称(xx机关-xx网格)、显示昵称(xx网格-x先生/女士)
if(null != relation && StringUtils.isNotBlank(relation.getGridId())){
@ -203,22 +220,24 @@ public class UserBaseInfoRedis {
Result<BelongGridNameResultDTO> gridResult =
govOrgOpenFeignClient.getGridNameByGridId(gridParam);
if(gridResult.success() && null != gridResult.getData()
&& StringUtils.isNotBlank(gridResult.getData().getBelongsGridName())){
&& StringUtils.isNotBlank(gridResult.getData().getBelongsGridName())) {
String gridFullName = gridResult.getData().getBelongsGridName();
currentCache.setRegisteredGridName(gridFullName);
if(StringUtils.isBlank(currentCache.getGender()))currentCache.setGender(NumConstant.ZERO_STR);
StringBuffer buffer = new StringBuffer(gridFullName.split(ModuleConstant.DASH)[NumConstant.ONE]).append(ModuleConstant.DASH).append(currentCache.getSurname());
switch (currentCache.getGender()) {
case NumConstant.ONE_STR:
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_MALE);
break;
case NumConstant.TWO_STR:
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_FEMALE);
break;
default:
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_GENDER_UNKNOWN);
if (StringUtils.isBlank(currentCache.getGender())) currentCache.setGender(NumConstant.ZERO_STR);
if (StringUtils.isNotBlank(currentCache.getNickname())) {
StringBuffer buffer = new StringBuffer(gridFullName.split(ModuleConstant.DASH)[NumConstant.ONE]).append(ModuleConstant.DASH).append(currentCache.getSurname());
switch (currentCache.getGender()) {
case NumConstant.ONE_STR:
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_MALE);
break;
case NumConstant.TWO_STR:
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_FEMALE);
break;
default:
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_GENDER_UNKNOWN);
}
currentCache.setShowName(buffer.toString());
}
currentCache.setShowName(buffer.toString());
}
}else{
//如果没有居民注册记录,说明当前用户是陌生人,需要从陌生人网格访问列表中查询所属的客户Id
@ -240,18 +259,7 @@ public class UserBaseInfoRedis {
// }
//}
Map<String,Object> map = redisUtils.hGetAll(UserRedisKeys.getResiUserKey(entity.getUserId()));
if(null != map && !map.isEmpty()) {
//缓存中有数据,直接返回
UserBaseInfoResultDTO orientCache = BeanUtil.mapToBean(map, UserBaseInfoResultDTO.class, true);
mergeObject(currentCache , orientCache);
set(orientCache);
}else{
//缓存中没有该数据
set(currentCache);
}
set(currentCache);
}

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

@ -8,11 +8,10 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserConstant;
import com.epmet.dao.UserDao;
import com.epmet.dao.UserRoleDao;
import com.epmet.dao.UserWechatDao;
import com.epmet.dao.*;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.UserDTO;
import com.epmet.dto.UserResiInfoDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
@ -21,6 +20,7 @@ import com.epmet.entity.UserEntity;
import com.epmet.entity.UserWechatEntity;
import com.epmet.feign.EpmetPointOpenFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.redis.UserBaseInfoRedis;
import com.epmet.service.UserBaseInfoService;
import com.epmet.service.UserService;
import com.epmet.util.ModuleConstant;
@ -53,6 +53,12 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
private UserBaseInfoService userBaseInfoService;
@Autowired
private EpmetPointOpenFeignClient epmetPointOpenFeignClient;
@Autowired
private UserBaseInfoRedis userBaseInfoRedis;
@Autowired
private UserResiInfoDao userResiInfoDao;
@Autowired
private UserBaseInfoDao userBaseInfoDao;
private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
@ -130,7 +136,21 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
userWechatDTO.setUpdatedTime(new Date());
userWechatDTO.setUpdatedBy(wxUserInfoFormDTO.getUserId());
userWechatDao.updateByUserId(userWechatDTO);
UserBaseInfoEntity baseInfo = new UserBaseInfoEntity();
UserBaseInfoResultDTO cache = userBaseInfoRedis.get(wxUserInfoFormDTO.getUserId());
UserResiInfoDTO resiInfo = userResiInfoDao.selectByUserId(wxUserInfoFormDTO.getUserId());
if(null != resiInfo && StringUtils.isNotBlank((resiInfo.getId()))) {
baseInfo.setSurname(resiInfo.getSurname());
baseInfo.setName(resiInfo.getName());
baseInfo.setStreet(resiInfo.getStreet());
baseInfo.setDistrict(resiInfo.getDistrict());
baseInfo.setBuildingAddress(resiInfo.getBuildingAddress());
baseInfo.setMobile(resiInfo.getRegMobile());
}
baseInfo.setUserId(wxUserInfoFormDTO.getUserId());
baseInfo.setNickname(wxUserInfoFormDTO.getNickName());
baseInfo.setHeadImgUrl(wxUserInfoFormDTO.getAvatarUrl());

Loading…
Cancel
Save