Browse Source

Merge branches 'dev' and 'dev_heart' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_heart

master
yinzuomei 5 years ago
parent
commit
b3e9cf5d82
  1. 2
      epmet-auth/deploy/docker-compose-dev.yml
  2. 2
      epmet-auth/pom.xml
  3. 31
      epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java
  4. 48
      epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgsFormDTO.java
  5. 20
      epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
  6. 189
      epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
  7. 9
      epmet-commons/epmet-commons-tools/pom.xml
  8. 80
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java
  9. 23
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  10. 2
      epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml
  11. 2
      epmet-module/epmet-third/epmet-third-server/pom.xml
  12. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java
  13. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java
  14. 89
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
  15. 34
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  16. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java
  17. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
  18. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml
  19. 3
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml
  20. 11
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  21. 6
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  22. 2
      epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml
  23. 2
      epmet-module/gov-org/gov-org-server/pom.xml
  24. 16
      epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.2__addCutomerApp.sql
  25. 25
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ThirdCustomerStaffFormDTO.java
  26. 9
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  27. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  28. 2
      epmet-user/epmet-user-server/deploy/docker-compose-dev.yml
  29. 2
      epmet-user/epmet-user-server/pom.xml
  30. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  31. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java
  32. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  33. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  34. 12
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

2
epmet-auth/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-auth-server: epmet-auth-server:
container_name: epmet-auth-server-dev container_name: epmet-auth-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.56 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.57
ports: ports:
- "8081:8081" - "8081:8081"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-auth/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" <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"> 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> <modelVersion>4.0.0</modelVersion>
<version>0.3.56</version> <version>0.3.57</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId> <artifactId>epmet-cloud</artifactId>

31
epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java

@ -3,7 +3,10 @@ package com.epmet.controller;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.LoginFormDTO; import com.epmet.dto.form.LoginFormDTO;
import com.epmet.dto.form.StaffOrgsFormDTO;
import com.epmet.dto.form.ThirdStaffOrgsFormDTO;
import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO; import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.ThirdLoginService; import com.epmet.service.ThirdLoginService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -12,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @Description 第三方-居民端政府端登陆服务 * @Description 第三方-居民端政府端登陆服务
* @author sun * @author sun
@ -60,4 +65,30 @@ public class ThirdLoginController {
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO); return new Result<UserTokenResultDTO>().ok(userTokenResultDTO);
} }
/**
* @param formDTO
* @return
* @Author sun
* @Description 单客户-手机验证码获取组织
**/
@PostMapping(value = "/getmyorg")
public Result<List<StaffOrgsResultDTO>> getmyorg(@RequestBody ThirdStaffOrgsFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, StaffOrgsFormDTO.AddUserShowGroup.class, StaffOrgsFormDTO.GetMyOrgByLoginWxmp.class);
List<StaffOrgsResultDTO> staffOrgs = thirdLoginService.getMyOrg(formDTO);
return new Result<List<StaffOrgsResultDTO>>().ok(staffOrgs);
}
/**
* @param formDTO
* @return
* @author sun
* @description 单客户-手机号密码获取组织
**/
@PostMapping(value = "/getmyorgbypassword")
public Result<List<StaffOrgsResultDTO>> getMyOrgByPassword(@RequestBody ThirdStaffOrgsFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, StaffOrgsFormDTO.AddUserShowGroup.class, StaffOrgsFormDTO.GetMyOrgByPassWordGroup.class);
List<StaffOrgsResultDTO> staffOrgs = thirdLoginService.getMyOrgByPassword(formDTO);
return new Result<List<StaffOrgsResultDTO>>().ok(staffOrgs);
}
} }

48
epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgsFormDTO.java

@ -0,0 +1,48 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description appId手机号验证码获取组织-接口入参
* @Author sun
*/
@Data
public class ThirdStaffOrgsFormDTO implements Serializable {
private static final long serialVersionUID = 4193133227120225342L;
/**
* 添加用户操作的用户可见异常分组
* 该分组用于校验需要返回给前端错误信息提示的列需要继承CustomerClientShowGroup
* 返回错误码为8999提示信息为DTO中具体的列的校验注解message的内容
*/
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
public interface GetMyOrgByPassWordGroup extends CustomerClientShowGroup {
}
public interface GetMyOrgByLoginWxmp extends CustomerClientShowGroup{}
/**
* 小程序appId
*/
@NotBlank(message = "appId不能为空", groups = {AddUserShowGroup.class})
private String appId;
/**
* 手机号
*/
@NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class})
private String mobile;
/**
* 验证码
*/
@NotBlank(message="验证码不能为空", groups = {GetMyOrgByLoginWxmp.class})
private String smsCode;
@NotBlank(message = "密码不能为空",groups ={GetMyOrgByPassWordGroup.class})
private String password;
}

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

@ -1,9 +1,13 @@
package com.epmet.service; package com.epmet.service;
import com.epmet.dto.form.LoginFormDTO; import com.epmet.dto.form.LoginFormDTO;
import com.epmet.dto.form.ThirdStaffOrgsFormDTO;
import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO; import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.dto.result.UserTokenResultDTO;
import java.util.List;
/** /**
* @Description 第三方-居民端政府端登陆服务 * @Description 第三方-居民端政府端登陆服务
* @author sun * @author sun
@ -33,4 +37,20 @@ public interface ThirdLoginService {
* @Description 单客户-选择组织进入首页 * @Description 单客户-选择组织进入首页
**/ **/
UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO); UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 单客户-手机验证码获取组织
**/
List<StaffOrgsResultDTO> getMyOrg(ThirdStaffOrgsFormDTO formDTO);
/**
* @param formDTO
* @return
* @author sun
* @description 单客户-手机号密码获取组织
**/
List<StaffOrgsResultDTO> getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO);
} }

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

@ -2,38 +2,36 @@ package com.epmet.service.impl;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.epmet.common.token.constant.LoginConstant; import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.DepartmentListResultDTO; import com.epmet.dto.result.*;
import com.epmet.dto.result.GridByStaffResultDTO;
import com.epmet.dto.result.StaffLatestAgencyResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.feign.EpmetThirdFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils; import com.epmet.jwt.JwtTokenUtils;
import com.epmet.redis.CaptchaRedis;
import com.epmet.service.ThirdLoginService; import com.epmet.service.ThirdLoginService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -48,6 +46,8 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
@Autowired @Autowired
private JwtTokenUtils jwtTokenUtils; private JwtTokenUtils jwtTokenUtils;
@Autowired @Autowired
private CaptchaRedis captchaRedis;
@Autowired
private JwtTokenProperties jwtTokenProperties; private JwtTokenProperties jwtTokenProperties;
@Autowired @Autowired
private CpUserDetailRedis cpUserDetailRedis; private CpUserDetailRedis cpUserDetailRedis;
@ -142,6 +142,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
**/ **/
@Override @Override
public UserTokenResultDTO workLogin(LoginFormDTO formDTO) { public UserTokenResultDTO workLogin(LoginFormDTO formDTO) {
//1.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 //1.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息
WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO();
resiLoginFormDTO.setAppId(formDTO.getAppId()); resiLoginFormDTO.setAppId(formDTO.getAppId());
@ -379,66 +380,150 @@ public class ThirdLoginServiceImpl implements ThirdLoginService {
wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey());
wxMaJscode2SessionResult.setUnionid(""); wxMaJscode2SessionResult.setUnionid("");
// end // end
//3、记录staff_wechat,并记录用户激活状态,激活时间 //3、记录staff_wechat,并记录用户激活状态,激活时间
this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); this.savestaffwechat(customerStaff.getUserId(), userWechatDTO.getWxOpenId());
//4、记录登录日志 //4、记录登录日志
this.saveGovStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = new StaffLatestAgencyResultDTO();
staffLatestAgencyResultDTO.setCustomerId(formDTO.getCustomerId());
staffLatestAgencyResultDTO.setStaffId(customerStaff.getUserId());
staffLatestAgencyResultDTO.setWxOpenId(userWechatDTO.getWxOpenId());
staffLatestAgencyResultDTO.setMobile(formDTO.getMobile());
staffLatestAgencyResultDTO.setAgencyId(formDTO.getRootAgencyId());
this.saveStaffLoginRecord(staffLatestAgencyResultDTO);
//5.1、获取用户token //5.1、获取用户token
String token = this.generateGovWxmpToken(customerStaff.getUserId()); String token = this.generateGovWxmpToken(customerStaff.getUserId());
//5.2、保存到redis //5.2、保存到redis
this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token); StaffLatestAgencyResultDTO staffLatestAgency = new StaffLatestAgencyResultDTO();
staffLatestAgency.setAgencyId(formDTO.getRootAgencyId());
staffLatestAgency.setCustomerId(formDTO.getCustomerId());
staffLatestAgency.setStaffId(customerStaff.getUserId());
this.saveLatestGovTokenDto(staffLatestAgency, userWechatDTO, token);
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(token); userTokenResultDTO.setToken(token);
return userTokenResultDTO; return userTokenResultDTO;
} }
//保存登录日志 /**
private Result saveGovStaffLoginRecord(ThirdWxmpEnteOrgFormDTO formDTO, String staffId, String openId) { * @param formDTO
StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); * @return
staffLoginAgencyRecordFormDTO.setCustomerId(formDTO.getCustomerId()); * @Author sun
staffLoginAgencyRecordFormDTO.setStaffId(staffId); * @Description 单客户-手机验证码获取组织
staffLoginAgencyRecordFormDTO.setWxOpenId(openId); **/
staffLoginAgencyRecordFormDTO.setMobile(formDTO.getMobile()); @Override
staffLoginAgencyRecordFormDTO.setAgencyId(formDTO.getRootAgencyId()); public List<StaffOrgsResultDTO> getMyOrg(ThirdStaffOrgsFormDTO formDTO) {
Result staffLoginRecordResult = epmetUserOpenFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); //0、验证码是否正确
return staffLoginRecordResult; String rightSmsCode = captchaRedis.getSmsCode(formDTO.getMobile());
if (!formDTO.getSmsCode().equals(rightSmsCode)) {
logger.error(String.format("验证码错误code[%s],msg[%s]",EpmetErrorCode.MOBILE_CODE_ERROR.getCode(),EpmetErrorCode.MOBILE_CODE_ERROR.getMsg()));
throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
}
//1.根据appId查询对应客户Id
Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId());
if (!resultDTO.success()) {
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId()));
throw new RenException(resultDTO.getMsg());
}
PaCustomerDTO customer = resultDTO.getData().getCustomer();
//7.28 根据appId只能存在一个客户Id,后边的批量操作逻辑
//2.根据手机号查询到用户信息
ThirdCustomerStaffFormDTO dto = new ThirdCustomerStaffFormDTO();
dto.setCustomerId(customer.getId());
dto.setMobile(formDTO.getMobile());
Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserOpenFeignClient.getCustsomerStaffByIdAndPhone(dto);
if (!customerStaffResult.success()) {
logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg()));
throw new RenException(customerStaffResult.getCode());
}
//3、查询用户所有的组织信息
List<String> customerIdList = new ArrayList<>();
for (CustomerStaffDTO customerStaffDTO : customerStaffResult.getData()) {
customerIdList.add(customerStaffDTO.getCustomerId());
}
StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO();
staffOrgFormDTO.setCustomerIdList(customerIdList);
Result<List<StaffOrgsResultDTO>> result = govOrgOpenFeignClient.getStaffOrgList(staffOrgFormDTO);
if(result.success()&&null!=result.getData()){
return result.getData();
}
logger.error(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,验证码%s,返回错误码%s,错误提示信息%s", ServiceConstant.GOV_ORG_SERVER,formDTO.getMobile(),formDTO.getSmsCode(),result.getCode(),result.getMsg()));
return new ArrayList<>();
} }
/** /**
* @Description 生成token * @param formDTO
* @Date 2020/4/18 23:04 * @return
* @author sun
* @description 单客户-手机号密码获取组织
**/ **/
private void saveGovTokenDto(String orgId, @Override
String customerId, public List<StaffOrgsResultDTO> getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO) {
String staffId, //0.根据appId查询对应客户Id
WxMaJscode2SessionResult wxMaJscode2SessionResult, Result<PublicCustomerResultDTO> resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId());
String token) { if (!resultDTO.success()) {
int expire = jwtTokenProperties.getExpire(); logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId()));
GovTokenDto govTokenDto = new GovTokenDto(); throw new RenException(resultDTO.getMsg());
govTokenDto.setApp(LoginConstant.APP_GOV); }
govTokenDto.setClient(LoginConstant.CLIENT_WXMP); PaCustomerDTO customer = resultDTO.getData().getCustomer();
govTokenDto.setUserId(staffId); //7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun
govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); //1、根据手机号查询到用户信息
govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); ThirdCustomerStaffFormDTO dto = new ThirdCustomerStaffFormDTO();
govTokenDto.setUnionId(null == wxMaJscode2SessionResult.getUnionid() ? "" : wxMaJscode2SessionResult.getUnionid()); dto.setCustomerId(customer.getId());
govTokenDto.setToken(token); dto.setMobile(formDTO.getMobile());
govTokenDto.setUpdateTime(System.currentTimeMillis()); Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserOpenFeignClient.getCustsomerStaffByIdAndPhone(dto);
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); if (!customerStaffResult.success()) {
govTokenDto.setRootAgencyId(orgId); logger.error(String.format("手机密码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg()));
govTokenDto.setCustomerId(customerId); throw new RenException(customerStaffResult.getCode());
}
//2、密码是否正确
List<CustomerStaffDTO> customerStaffList=customerStaffResult.getData();
//3、查询用户所有的组织信息
List<String> customerIdList = new ArrayList<>();
//是否设置过密码
boolean havePasswordFlag=false;
//密码是否正确
boolean passwordRightFlag=false;
for (CustomerStaffDTO customerStaffDTO : customerStaffList) {
if(StringUtils.isNotBlank(customerStaffDTO.getPassword())){
havePasswordFlag=true;
}else{
logger.warn(String.format("当前用户:手机号%s,客户Id%s下未设置密码.",formDTO.getMobile(),customerStaffDTO.getCustomerId()));
continue;
}
if (!PasswordUtils.matches(formDTO.getPassword(), customerStaffDTO.getPassword())) {
logger.warn(String.format("当前用户:手机号%s,客户Id%s密码匹配错误.",formDTO.getMobile(),customerStaffDTO.getCustomerId()));
//设置部门,网格,角色列表 }else{
govTokenDto.setDeptIdList(getDeptartmentIdList(staffId)); logger.warn(String.format("当前用户:手机号%s,客户Id%s密码匹配正确.",formDTO.getMobile(),customerStaffDTO.getCustomerId()));
govTokenDto.setGridIdList(getGridIdList(staffId)); passwordRightFlag=true;
CustomerAgencyDTO agency = getAgencyByStaffId(staffId); customerIdList.add(customerStaffDTO.getCustomerId());
if (agency != null) { }
govTokenDto.setAgencyId(agency.getId());
govTokenDto.setRoleList(queryGovStaffRoles(staffId, agency.getId()));
} }
govTokenDto.setOrgIdPath(getOrgIdPath(staffId)); //根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码
cpUserDetailRedis.set(govTokenDto, expire); if(!havePasswordFlag){
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); logger.error(String.format("当前手机号(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getMobile()));
throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode());
}
//密码错误
if(!passwordRightFlag){
logger.error(String.format("根据当前手机号(%s)密码未找到所属组织,密码错误",formDTO.getMobile()));
throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode());
}
StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO();
staffOrgFormDTO.setCustomerIdList(customerIdList);
Result<List<StaffOrgsResultDTO>> result = govOrgOpenFeignClient.getStaffOrgList(staffOrgFormDTO);
if(result.success()&&null!=result.getData()){
return result.getData();
}
logger.error(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,密码%s,返回错误码%s,错误提示信息%s",
ServiceConstant.GOV_ORG_SERVER,
formDTO.getMobile(),
formDTO.getPassword(),
result.getCode(),
result.getMsg()));
return new ArrayList<>();
} }
} }

9
epmet-commons/epmet-commons-tools/pom.xml

@ -133,6 +133,15 @@
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId> <artifactId>httpmime</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

80
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java

@ -1,37 +1,65 @@
package com.epmet.commons.tools.utils; package com.epmet.commons.tools.utils;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
/**
* @author kamui
*/
public class FileUtils { public class FileUtils {
/** /**
* 创建临时文件. * 创建临时文件
* *
* @param inputStream 输入文件流 * @param inputStream
* @param name 文件名 * @param name 文件名
* @param ext 扩展名 * @param ext 扩展名
* @param tmpDirFile 临时文件夹目录 * @param tmpDirFile 临时文件夹目录
*/ */
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException {
File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile); File tmpFile;
if (tmpDirFile == null) {
resultFile.deleteOnExit(); tmpFile = File.createTempFile(name, '.' + ext);
org.apache.commons.io.FileUtils.copyToFile(inputStream, resultFile); } else {
return resultFile; tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile);
} }
/** tmpFile.deleteOnExit();
* 创建临时文件. FileOutputStream fos = new FileOutputStream(tmpFile);
* try {
* @param inputStream 输入文件流 int read = 0;
* @param name 文件名 byte[] bytes = new byte[1024 * 100];
* @param ext 扩展名 while ((read = inputStream.read(bytes)) != -1) {
*/ fos.write(bytes, 0, read);
public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { }
return createTmpFile(inputStream, name, ext, Files.createTempDirectory("weixin-java-tools-temp").toFile());
} fos.flush();
} catch (Exception e) {
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
}
}
}
return tmpFile;
}
/**
* 创建临时文件
*
* @param inputStream
* @param name 文件名
* @param ext 扩展名
*/
public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException {
return createTmpFile(inputStream, name, ext, null);
}
} }

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

@ -22,7 +22,6 @@ import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.MultipartEntityBuilder;
@ -171,20 +170,14 @@ public class HttpClientManager {
try { try {
HttpPost httppost = new HttpPost(url); HttpPost httppost = new HttpPost(url);
httppost.setConfig(requestConfig); httppost.setConfig(requestConfig);
String boundaryStr = "------------" + System.currentTimeMillis(); if (file != null) {
httppost.addHeader("Connection", "keep-alive"); HttpEntity entity = MultipartEntityBuilder
httppost.addHeader("Accept", "*/*"); .create()
httppost.addHeader("Content-Type", "multipart/form-data;boundary=" + boundaryStr); .addBinaryBody("media", file)
httppost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); .setMode(HttpMultipartMode.RFC6532)
MultipartEntityBuilder meb = MultipartEntityBuilder.create(); .build();
meb.setBoundary(boundaryStr).setCharset(StandardCharsets.UTF_8).setMode(HttpMultipartMode.BROWSER_COMPATIBLE); httppost.setEntity(entity);
meb.addBinaryBody("media", file, ContentType.APPLICATION_OCTET_STREAM, file.getName()); }
HttpEntity entity = meb.build();
httppost.setEntity(entity);
// FileBody fileBody = new FileBody(file);
// HttpEntity reqEntity = MultipartEntityBuilder.create()
// .addPart("media", fileBody).build();
// httppost.setEntity(reqEntity);
return execute(httppost,false); return execute(httppost,false);
} catch (Exception e) { } catch (Exception e) {
log.error("send exception", e); log.error("send exception", e);

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

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-third-server: epmet-third-server:
container_name: epmet-third-server-dev container_name: epmet-third-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.67 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.72
ports: ports:
- "8110:8110" - "8110:8110"
network_mode: host # 使用现有网络 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" <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"> 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> <modelVersion>4.0.0</modelVersion>
<version>0.0.67</version> <version>0.0.72</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>

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

@ -72,7 +72,7 @@ public interface CodeCustomerService extends BaseService<CodeCustomerEntity> {
* @author generator * @author generator
* @date 2020-07-09 * @date 2020-07-09
*/ */
void save(CodeCustomerDTO dto); String save(CodeCustomerDTO dto);
/** /**
* 默认更新 * 默认更新

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java

@ -86,9 +86,10 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl<CodeCustomerDao, Co
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(CodeCustomerDTO dto) { public String save(CodeCustomerDTO dto) {
CodeCustomerEntity entity = ConvertUtils.sourceToTarget(dto, CodeCustomerEntity.class); CodeCustomerEntity entity = ConvertUtils.sourceToTarget(dto, CodeCustomerEntity.class);
insert(entity); insert(entity);
return entity.getId();
} }
@Override @Override
@ -123,4 +124,5 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl<CodeCustomerDao, Co
baseDao.deleteCode(customerId, clientType); baseDao.deleteCode(customerId, clientType);
} }
} }

89
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java

@ -14,7 +14,6 @@ import com.epmet.dao.ComponentAccessTokenDao;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.feign.OssFeignClient; import com.epmet.feign.OssFeignClient;
import com.epmet.service.*; import com.epmet.service.*;
import com.epmet.wxapi.param.*; import com.epmet.wxapi.param.*;
@ -22,6 +21,8 @@ import com.epmet.wxapi.result.*;
import com.epmet.wxapi.service.WxMaCodeService; import com.epmet.wxapi.service.WxMaCodeService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -29,17 +30,18 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author zhaoqifeng * @author zhaoqifeng
* @dscription * @dscription
* @date 2020/7/10 10:27 * @date 2020/7/10 10:27
*/ */
@Slf4j
@Service @Service
public class CodeServiceImpl implements CodeService { public class CodeServiceImpl implements CodeService {
@ -52,8 +54,6 @@ public class CodeServiceImpl implements CodeService {
@Autowired @Autowired
private CodeCustomerService codeCustomerService; private CodeCustomerService codeCustomerService;
@Autowired @Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private CodeAuditResultService codeAuditResultService; private CodeAuditResultService codeAuditResultService;
@Autowired @Autowired
private CustomerMpService customerMpService; private CustomerMpService customerMpService;
@ -81,12 +81,14 @@ public class CodeServiceImpl implements CodeService {
if (null == wxResult.getData() || wxResult.getData().size() == NumConstant.ZERO) { if (null == wxResult.getData() || wxResult.getData().size() == NumConstant.ZERO) {
return resultList; return resultList;
} }
wxResult.getData().forEach(temp -> { List<WxMaTemplateResult> sortList =
wxResult.getData().stream().sorted(Comparator.comparing(WxMaTemplateResult::getCreateTime).reversed()).collect(Collectors.toList());
sortList.forEach(temp -> {
TemplateListResultDTO dto = new TemplateListResultDTO(); TemplateListResultDTO dto = new TemplateListResultDTO();
dto.setId(temp.getTemplateId()); dto.setId(temp.getTemplateId());
dto.setUserVersion(temp.getUserVersion()); dto.setUserVersion(temp.getUserVersion());
dto.setUserDesc(temp.getUserDesc()); dto.setUserDesc(temp.getUserDesc());
dto.setCreateTime(DateUtils.formatTimestamp(temp.getCreateTime(), DateUtils.DATE_PATTERN)); dto.setCreateTime(DateUtils.formatTimestamp(temp.getCreateTime(), DateUtils.DATE_TIME_PATTERN));
resultList.add(dto); resultList.add(dto);
}); });
return resultList; return resultList;
@ -101,14 +103,6 @@ public class CodeServiceImpl implements CodeService {
return codeExtDTO.getExtJson(); return codeExtDTO.getExtJson();
} }
public static void main(String[] args) {
String json = "{\"extEnable\":true,\"extAppid\":\"wx2679392c4cc2af22\",\"directCommit\":false,\"ext\":{\"extAppid\":\"wx2679392c4cc2af22\",\"footbar\":{\"work\":{\"name\":\"工作\",\"pageTile\":\"工作\"},\"org\":{\"name\":\"组织\",\"pageTile\":\"组织\"},\"data\":{\"name\":\"数据\",\"pageTile\":\"数据\"},\"find\":{\"name\":\"更多\",\"pageTile\":\"更多\"}}}}";
WxExtJson wxExtJson = JSONObject.parseObject(json, WxExtJson.class);
wxExtJson.setExtAppid("123456");
wxExtJson.getExt().setExtAppid("123456");
String extJson = JSON.toJSONString(wxExtJson);
System.out.println(extJson);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -122,14 +116,11 @@ public class CodeServiceImpl implements CodeService {
if (null == authInfo) { if (null == authInfo) {
throw new RenException("未授权"); throw new RenException("未授权");
} }
if (!isJson(formDTO.getExtJson())) { String extJson = getExtJson(formDTO);
throw new RenException("第三方配置不是有效的Json"); WxExtJson wxExtJson = JSONObject.parseObject(extJson, WxExtJson.class);
}
WxExtJson wxExtJson = JSONObject.parseObject(formDTO.getExtJson(), WxExtJson.class);
wxExtJson.setExtAppid(authInfo.getAuthorizerAppid()); wxExtJson.setExtAppid(authInfo.getAuthorizerAppid());
wxExtJson.getExt().setExtAppid(authInfo.getAuthorizerAppid()); wxExtJson.getExt().setExtAppid(authInfo.getAuthorizerAppid());
String extJson = JSON.toJSONString(wxExtJson); extJson = JSON.toJSONString(wxExtJson);
CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType());
if (null == codeExtDTO) { if (null == codeExtDTO) {
codeExtDTO = new CodeExtDTO(); codeExtDTO = new CodeExtDTO();
@ -164,9 +155,9 @@ public class CodeServiceImpl implements CodeService {
codeCustomerDTO.setExtJson(extJson); codeCustomerDTO.setExtJson(extJson);
codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid()); codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid());
codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); codeCustomerDTO.setStatus(CodeConstant.UNAUDITED);
codeCustomerService.save(codeCustomerDTO); String codeId = codeCustomerService.save(codeCustomerDTO);
saveOperation(formDTO.getCustomerId(), codeCustomerDTO.getId(), formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, "上传成功"); saveOperation(formDTO.getCustomerId(), codeId, formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, "上传成功");
} }
@Override @Override
@ -373,7 +364,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息 //获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
if (null != codeCustomerDTO.getQrCode()) { if (null != codeCustomerDTO.getQrCode()) {
result.setQrcode(codeCustomerDTO.getQrCode()); result.setQrcode(codeCustomerDTO.getQrCode());
return result; return result;
} }
//是否授权 //是否授权
@ -409,8 +400,8 @@ public class CodeServiceImpl implements CodeService {
@Override @Override
public String mediaUpload(MediaUploadFormDTO formDTO) { public String mediaUpload(MediaUploadFormDTO formDTO) {
try { try {
Result<UploadImgResultDTO> uploadWxImg = ossFeignClient.uploadWxImg(formDTO.getMedia()); File file = new File(formDTO.getMedia().getOriginalFilename());
File file = new File(uploadWxImg.getData().getUrl()); FileUtils.copyInputStreamToFile(formDTO.getMedia().getInputStream(), file);
//获取上传代码信息 //获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//获取小程序调用令牌 //获取小程序调用令牌
@ -443,50 +434,4 @@ public class CodeServiceImpl implements CodeService {
codeOperationHistoryService.save(operationDTO); codeOperationHistoryService.save(operationDTO);
} }
/**
* 校验是否是Json
*
* @param content
* @return boolean
* @author zhaoqifeng
* @date 2020/7/17 15:43
*/
private boolean isJson(String content) {
try {
JSONObject jsonStr = JSONObject.parseObject(content);
return true;
} catch (Exception e) {
return false;
}
}
private byte[] toPrimitives(Byte[] oBytes) {
byte[] bytes = new byte[oBytes.length];
for (int i = 0; i < oBytes.length; i++) {
bytes[i] = oBytes[i];
}
return bytes;
}
private void byteToFile(byte[] bytes)
{
try
{
// 根据绝对路径初始化文件
File localFile = new File(".");
if (!localFile.exists())
{
localFile.createNewFile();
}
// 输出流
OutputStream os = new FileOutputStream(localFile);
os.write(bytes);
os.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
} }

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

@ -241,23 +241,25 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData();
log.info(String.format(POST_RESULT,post)); log.info(String.format(POST_RESULT,post));
Map hashMap = JSON.parseObject(post, Map.class); Map hashMap = JSON.parseObject(post, Map.class);
preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString(); if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) {
Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString();
Date expiresInTime = this.countExpirationTime(expiresIn.toString()); Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN);
if (StringUtils.isNotEmpty(preAuthCode)) { Date expiresInTime = this.countExpirationTime(expiresIn.toString());
//预授权码 存DB if (StringUtils.isNotEmpty(preAuthCode)) {
PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO(); //预授权码 存DB
formDTO.setPreAuthToken(preAuthCode); PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO();
formDTO.setExpiresInTime(expiresInTime); formDTO.setPreAuthToken(preAuthCode);
//先逻辑删除,在插入DB formDTO.setExpiresInTime(expiresInTime);
preAuthTokenDao.updateOldPreAuthCode(); //先逻辑删除,在插入DB
preAuthTokenDao.insertPreAuthToken(formDTO); preAuthTokenDao.updateOldPreAuthCode();
//预授权码 放入缓存 preAuthTokenDao.insertPreAuthToken(formDTO);
redisThird.setPreAuthCode(preAuthCode); //预授权码 放入缓存
} else { redisThird.setPreAuthCode(preAuthCode);
throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE); } else {
throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE);
}
log.info(END_GET_PRE_AUTH_CODE);
} }
log.info(END_GET_PRE_AUTH_CODE);
return preAuthCode; return preAuthCode;
} }

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

@ -159,10 +159,10 @@ public interface WxMaCodeConstant {
/** /**
* 新增临时素材 * 新增临时素材
*/ */
String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain"; String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload";
/** /**
* 新增临时素材 * 获取模板列表
*/ */
String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/gettemplatelist"; String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/gettemplatelist";

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java

@ -156,7 +156,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
return result; return result;
} }
WxMaAuditStatusResult auditStatusResult = JSONObject.parseObject(statusResult.getData(), WxMaAuditStatusResult.class); WxMaAuditStatusResult auditStatusResult = JSONObject.parseObject(statusResult.getData(), WxMaAuditStatusResult.class);
if (!auditStatusResult.success()){ if (!auditStatusResult.success()) {
result.setErrorCode(auditStatusResult.getErrcode()); result.setErrorCode(auditStatusResult.getErrcode());
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(auditStatusResult.getErrcode())); result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(auditStatusResult.getErrcode()));
return result; return result;
@ -269,6 +269,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
WxMaUploadMediaResult mediaInfo = gson.fromJson(mediaResult.getData(), WxMaUploadMediaResult.class); WxMaUploadMediaResult mediaInfo = gson.fromJson(mediaResult.getData(), WxMaUploadMediaResult.class);
result.setErrorCode(mediaInfo.getErrCode()); result.setErrorCode(mediaInfo.getErrCode());
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(mediaInfo.getErrCode())); result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(mediaInfo.getErrCode()));
result.ok(mediaInfo);
return result; return result;
} }

2
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml

@ -28,7 +28,7 @@
DATE_FORMAT(coh.CREATED_TIME, '%Y-%m-%d %T') AS "operationTime", DATE_FORMAT(coh.CREATED_TIME, '%Y-%m-%d %T') AS "operationTime",
coh.VERSION, coh.VERSION,
coh.OPERATION, coh.OPERATION,
coh.`DESCRIPTION` coh.`DESCRIPTION` AS "describe"
FROM code_operation_history coh FROM code_operation_history coh
INNER JOIN code_customer cc ON coh.CODE_ID = cc.ID INNER JOIN code_customer cc ON coh.CODE_ID = cc.ID
WHERE WHERE

3
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml

@ -96,6 +96,9 @@
WHERE WHERE
del_flag = '0' del_flag = '0'
AND app_id = #{appId} AND app_id = #{appId}
AND AUTHORIZATION_FLAG = '1'<!-- 必须是已经完成授权的 -->
ORDER BY CREATED_TIME DESC
LIMIT 1
</select> </select>
<select id="selectCustomerByAppId" resultType="com.epmet.dto.PaCustomerDTO"> <select id="selectCustomerByAppId" resultType="com.epmet.dto.PaCustomerDTO">

11
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -7,6 +7,7 @@ import com.epmet.dto.CustomerPartyBranchDTO;
import com.epmet.dto.form.AddAgencyAndStaffFormDTO; import com.epmet.dto.form.AddAgencyAndStaffFormDTO;
import com.epmet.dto.form.BelongGridNameFormDTO; import com.epmet.dto.form.BelongGridNameFormDTO;
import com.epmet.dto.form.ListPartyBranchFormDTO; import com.epmet.dto.form.ListPartyBranchFormDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.feign.fallback.GovOrgOpenFeignClientFallback; import com.epmet.feign.fallback.GovOrgOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
@ -176,4 +177,14 @@ public interface GovOrgOpenFeignClient {
*/ */
@PostMapping("/gov/org/customergrid/getgridnamebygridid") @PostMapping("/gov/org/customergrid/getgridnamebygridid")
Result<BelongGridNameResultDTO> getGridNameByGridId(@RequestBody BelongGridNameFormDTO formDTO); Result<BelongGridNameResultDTO> getGridNameByGridId(@RequestBody BelongGridNameFormDTO formDTO);
/**
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.StaffOrgsResultDTO>>
* @param staffOrgFormDTO
* @Author yinzuomei
* @Description 获取客户对应的根级组织名称
* @Date 2020/4/20 21:37
**/
@PostMapping(value = "/gov/org/customeragency/getStaffOrgList",consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO);
} }

6
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -8,6 +8,7 @@ import com.epmet.dto.CustomerPartyBranchDTO;
import com.epmet.dto.form.AddAgencyAndStaffFormDTO; import com.epmet.dto.form.AddAgencyAndStaffFormDTO;
import com.epmet.dto.form.BelongGridNameFormDTO; import com.epmet.dto.form.BelongGridNameFormDTO;
import com.epmet.dto.form.ListPartyBranchFormDTO; import com.epmet.dto.form.ListPartyBranchFormDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -108,4 +109,9 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
public Result<BelongGridNameResultDTO> getGridNameByGridId(BelongGridNameFormDTO formDTO) { public Result<BelongGridNameResultDTO> getGridNameByGridId(BelongGridNameFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridNameByGridId", formDTO); return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridNameByGridId", formDTO);
} }
@Override
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffOrgList", staffOrgFormDTO);
}
} }

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

@ -2,7 +2,7 @@ version: "3.7"
services: services:
gov-org-server: gov-org-server:
container_name: gov-org-server-dev container_name: gov-org-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.76 image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.77
ports: ports:
- "8092:8092" - "8092:8092"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-module/gov-org/gov-org-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" <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"> 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> <modelVersion>4.0.0</modelVersion>
<version>0.3.76</version> <version>0.3.77</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>gov-org</artifactId> <artifactId>gov-org</artifactId>

16
epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.2__addCutomerApp.sql

@ -0,0 +1,16 @@
CREATE TABLE `customer_app` (
`ID` varchar(64) NOT NULL COMMENT '主键',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id',
`APP_ID` varchar(128) NOT NULL COMMENT '小程序的appId',
`CLIENT` varchar(32) NOT NULL COMMENT 'resi,work',
`SECRET` varchar(255) DEFAULT NULL COMMENT 'app的secret',
`ENABLE_FLAG` int(1) NOT NULL DEFAULT '0' COMMENT '0:停用,1:启用',
`DEL_FLAG` int(11) NOT NULL DEFAULT '0' 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 '更新时间',
PRIMARY KEY (`ID`) USING BTREE,
UNIQUE KEY `unx_app_id` (`APP_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='客户app表';

25
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ThirdCustomerStaffFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 根据客户ID手机号查询政府端工作人员基本信息
* @Author sun
*/
@Data
public class ThirdCustomerStaffFormDTO implements Serializable{
private static final long serialVersionUID = -7994579456530273809L;
/**
* 客户Id
* */
private String customerId;
/**
* 手机号
* */
private String mobile;
}

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

@ -220,4 +220,13 @@ public interface EpmetUserOpenFeignClient {
**/ **/
@PostMapping("/epmetuser/customerstaff/staffmsg") @PostMapping("/epmetuser/customerstaff/staffmsg")
Result<StaffEtAgencyResultDTO> staffMsg(@RequestBody IssueInitiatorFormDTO userId); Result<StaffEtAgencyResultDTO> staffMsg(@RequestBody IssueInitiatorFormDTO userId);
/**
* @param formDTO
* @return
* @Author sun
* @Description 根据客户ID手机号查询政府端工作人员基本信息校验用户是否存在
**/
@GetMapping(value = "epmetuser/customerstaff/getCustsomerStaffByIdAndPhone")
Result<List<CustomerStaffDTO>> getCustsomerStaffByIdAndPhone(@RequestBody ThirdCustomerStaffFormDTO formDTO);
} }

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

@ -162,4 +162,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
public Result<StaffEtAgencyResultDTO> staffMsg(IssueInitiatorFormDTO userId) { public Result<StaffEtAgencyResultDTO> staffMsg(IssueInitiatorFormDTO userId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "staffMsg", userId); return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "staffMsg", userId);
} }
@Override
public Result<List<CustomerStaffDTO>> getCustsomerStaffByIdAndPhone(ThirdCustomerStaffFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByIdAndPhone", formDTO);
}
} }

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

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-user-server: epmet-user-server:
container_name: epmet-user-server-dev container_name: epmet-user-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.82 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.83
ports: ports:
- "8087:8087" - "8087:8087"
network_mode: host # 不会创建新的网络 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" <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"> 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> <modelVersion>4.0.0</modelVersion>
<version>0.3.82</version> <version>0.3.83</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>epmet-user</artifactId> <artifactId>epmet-user</artifactId>

11
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -310,4 +310,15 @@ public class CustomerStaffController {
ValidatorUtils.validateEntity(userId, IssueInitiatorFormDTO.UserIdGroup.class); ValidatorUtils.validateEntity(userId, IssueInitiatorFormDTO.UserIdGroup.class);
return new Result<StaffEtAgencyResultDTO>().ok(customerStaffService.getStaffMsg(userId)); return new Result<StaffEtAgencyResultDTO>().ok(customerStaffService.getStaffMsg(userId));
} }
/**
* @param formDTO
* @return
* @Author sun
* @Description 根据客户ID手机号查询政府端工作人员基本信息校验用户是否存在
**/
@GetMapping(value = "getCustsomerStaffByIdAndPhone")
public Result<List<CustomerStaffDTO>> getCustsomerStaffByIdAndPhone(@RequestBody ThirdCustomerStaffFormDTO formDTO) {
return new Result<List<CustomerStaffDTO>>().ok(customerStaffService.getCustsomerStaffByIdAndPhone(formDTO));
}
} }

8
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java

@ -140,4 +140,12 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
* @Description 根据staffId查询工作人员基本信息 * @Description 根据staffId查询工作人员基本信息
**/ **/
CustomerStaffDTO selectByStaffId(@Param("staffId") String staffId); CustomerStaffDTO selectByStaffId(@Param("staffId") String staffId);
/**
* @param formDTO
* @return
* @Author sun
* @Description 根据客户ID手机号查询政府端工作人员基本信息
**/
List<CustomerStaffDTO> selectStaff(ThirdCustomerStaffFormDTO formDTO);
} }

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

@ -250,4 +250,12 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
* @date 2020.07.27 14:45 * @date 2020.07.27 14:45
**/ **/
StaffEtAgencyResultDTO getStaffMsg(IssueInitiatorFormDTO userId); StaffEtAgencyResultDTO getStaffMsg(IssueInitiatorFormDTO userId);
/**
* @param formDTO
* @return
* @Author sun
* @Description 根据客户ID手机号查询政府端工作人员基本信息校验用户是否存在
**/
List<CustomerStaffDTO> getCustsomerStaffByIdAndPhone(ThirdCustomerStaffFormDTO formDTO);
} }

20
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -25,6 +25,7 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.security.password.PasswordUtils;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
@ -518,4 +519,23 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
return result; return result;
} }
/**
* @param formDTO
* @return
* @Author sun
* @Description 根据客户ID手机号查询政府端工作人员基本信息校验用户是否存在
**/
@Override
public List<CustomerStaffDTO> getCustsomerStaffByIdAndPhone(ThirdCustomerStaffFormDTO formDTO) {
//根据客户Id和手机号查询工作人员信息
List<CustomerStaffDTO> customerStaffDTOList = baseDao.selectStaff(formDTO);
if (null == customerStaffDTOList || customerStaffDTOList.size() < NumConstant.ONE) {
logger.error(String.format("根据客户Id和手机号查询用户异常,客户Id:[%s],手机号:[%s],code[%s],msg[%s]",
formDTO.getCustomerId(), formDTO.getMobile(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(),
EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg()));
throw new RenException(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode());
}
return customerStaffDTOList;
}
} }

12
epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

@ -203,4 +203,16 @@
del_flag = '0' del_flag = '0'
AND user_id = #{staffId} AND user_id = #{staffId}
</select> </select>
<select id="selectStaff" resultType="com.epmet.dto.CustomerStaffDTO">
SELECT
*
FROM
customer_staff
WHERE
del_flag='0'
AND customer_id = #{customerId}
AND mobile = #{mobile}
ORDER BY active_time DESC, created_time ASC
</select>
</mapper> </mapper>
Loading…
Cancel
Save