Browse Source

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

master
wangchao 5 years ago
parent
commit
10d7650de0
  1. 34
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  2. 2
      epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-dev.yml
  3. 2
      epmet-module/epmet-heart/epmet-heart-server/pom.xml
  4. 8
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml
  5. 2
      epmet-module/epmet-message/epmet-message-server/deploy/docker-compose-dev.yml
  6. 2
      epmet-module/epmet-message/epmet-message-server/pom.xml
  7. 3
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/UserMessageServiceImpl.java
  8. 2
      epmet-module/epmet-point/epmet-point-server/deploy/docker-compose-dev.yml
  9. 2
      epmet-module/epmet-point/epmet-point-server/pom.xml
  10. 86
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/FixationAppIdDTO.java
  11. 26
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ModifyCustomerFormDTO.java
  12. 30
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/FixationAppIdResultDTO.java
  13. 15
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java
  14. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java
  15. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java
  16. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java
  17. 43
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FixationAppIdDao.java
  18. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java
  19. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java
  20. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerUserAgencyDao.java
  21. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java
  22. 56
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/FixationAppIdEntity.java
  23. 13
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
  24. 38
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  25. 37
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
  26. 146
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java
  27. 5
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java
  28. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
  29. 13
      epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.4__thirdUpdate.sql
  30. 8
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml
  31. 17
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FixationAppIdDao.xml
  32. 8
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml
  33. 8
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
  34. 8
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerUserAgencyDao.xml
  35. 16
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml
  36. 12
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  37. 6
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  38. 2
      epmet-module/oper-crm/oper-crm-server/deploy/docker-compose-dev.yml
  39. 13
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java
  40. 6
      epmet-module/resi-mine/resi-mine-server/pom.xml
  41. 22
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java
  42. 10
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/service/ResiMineGridService.java
  43. 47
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/service/impl/ResiMineGridServiceImpl.java
  44. 38
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/LatestGridInfoFormDTO.java
  45. 10
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  46. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  47. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java
  48. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GridLatestDao.java
  49. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java
  50. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java
  51. 15
      epmet-user/epmet-user-server/src/main/resources/mapper/GridLatestDao.xml

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

@ -6,6 +6,7 @@ import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
@ -326,6 +327,23 @@ public class HttpClientManager {
}
}
public Result<byte[]> getMediaByteArray(String url, String json) {
try {
HttpPost httppost = new HttpPost(url);
httppost.setConfig(requestConfig);
httppost.addHeader("Content-Type", "application/json");
if (StringUtils.isNotEmpty(json)) {
StringEntity se = new StringEntity(json, "utf-8");
httppost.setEntity(se);
}
return executeToByte(httppost);
} catch (Exception e) {
log.error("sendGet exception", e);
return new Result<byte[]>().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
}
private Result<byte[]> executeToByte(HttpRequestBase httpMethod) {
CloseableHttpResponse response = null;
try {
@ -334,14 +352,16 @@ public class HttpClientManager {
if (response != null && response.getStatusLine() != null) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
InputStream in = response.getEntity().getContent();
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int n = 0;
while (-1 != (n = in.read(buffer))) {
output.write(buffer, 0, n);
}
byte[] responseContent = IOUtils.toByteArray(in);
// ByteArrayOutputStream output = new ByteArrayOutputStream();
// byte[] buffer = new byte[4096];
// int n = 0;
// while (-1 != (n = in.read(buffer))) {
// output.write(buffer, 0, n);
// }
// return new Result<byte[]>().ok(ArrayUtils.toObject(output.toByteArray()));
return new Result<byte[]>().ok(output.toByteArray());
// return new Result<byte[]>().ok(output.toByteArray());
return new Result<byte[]>().ok(responseContent);
} else {
log.warn("execute http method fail,httpStatus:{0}", response.getStatusLine().getStatusCode());
}

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

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-heart-server:
container_name: epmet-heart-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-heart-server:0.0.29
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-heart-server:0.0.30
ports:
- "8111:8111"
network_mode: host # 使用现有网络

2
epmet-module/epmet-heart/epmet-heart-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.0.29</version>
<version>0.0.30</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-heart</artifactId>

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

@ -348,10 +348,12 @@
i.ACT_ADDRESS actAddress,
'finished' actCurrentState
FROM act_info i
LEFT JOIN act_live_rec r ON r.ACT_ID = i.ID AND r.DEL_FLAG = '0'
WHERE i.DEL_FLAG = '0'
AND i.SUMMARY_FLAG = 1 OR (SELECT r.ACT_ID FROM act_live_rec r WHERE r.DEL_FLAG = '0' AND r.ACT_ID = i.ID GROUP BY r.ACT_ID)
AND i.SUMMARY_FLAG = 1 OR r.ID is NOT NULL
AND i.CUSTOMER_ID = #{customerId}
AND i.ACT_STATUS = 'finished'
GROUP BY r.ACT_ID
ORDER BY i.CREATED_TIME DESC
LIMIT #{pageNo}, #{pageSize}
</select>
@ -711,10 +713,12 @@
i.ACT_ADDRESS actAddress,
'finished' actCurrentState
FROM act_info i
LEFT JOIN act_live_rec r ON r.ACT_ID = i.ID AND r.DEL_FLAG = '0'
WHERE i.DEL_FLAG = '0'
AND i.SUMMARY_FLAG = 1 OR (SELECT r.ACT_ID FROM act_live_rec r WHERE r.DEL_FLAG = '0' AND r.ACT_ID = i.ID GROUP BY r.ACT_ID)
AND i.SUMMARY_FLAG = 1 OR r.ID is NOT NULL
AND i.CUSTOMER_ID = #{customerId}
AND i.ACT_STATUS = 'finished'
GROUP BY r.ACT_ID
ORDER BY i.CREATED_TIME DESC
LIMIT 0, #{num}
</select>

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

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-message-server:
container_name: epmet-message-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-message-server:0.3.26
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-message-server:0.3.27
ports:
- "8085:8085"
network_mode: host # 使用现有网络

2
epmet-module/epmet-message/epmet-message-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.26</version>
<version>0.3.27</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-message</artifactId>

3
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/UserMessageServiceImpl.java

@ -149,7 +149,8 @@ public class UserMessageServiceImpl extends BaseServiceImpl<UserMessageDao, User
QueryWrapper<UserMessageEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id)
.eq(StringUtils.isNotBlank(customerId), FieldConstant.CUSTOMER_ID, customerId)
.eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId)
// 注释掉此列,居民端和工作端消息浮窗看到的是当前客户下所有的消息
// .eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId)
.eq(StringUtils.isNotBlank(userId), FieldConstant.USER_ID, userId)
.eq(StringUtils.isNotBlank(deFlag), FieldConstant.DEL_FLAG, deFlag)
.eq(StringUtils.isNotBlank(readFlag), "read_flag", readFlag);

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

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-point-server:
container_name: epmet-point-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-point-server:0.0.19
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-point-server:0.0.20
ports:
- "8112:8112"
network_mode: host # 使用现有网络

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

@ -3,7 +3,7 @@
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.0.19</version>
<version>0.0.20</version>
<parent>
<artifactId>epmet-point</artifactId>
<groupId>com.epmet</groupId>

86
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/FixationAppIdDTO.java

@ -0,0 +1,86 @@
/**
* 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.dto;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 固定的AppId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-03
*/
@Data
public class FixationAppIdDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private String id;
/**
* 小程序AppId
*/
private String appId;
/**
* 客户Id
*/
private String customerId;
/**
* 客户端类型resi居民端work工作端
*/
private String clientType;
/**
* 删除状态0:正常已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

26
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ModifyCustomerFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author sun
* @Description 修改各业务表customerId(兼容党群e事通已上线客户将已有客户Id同步到第三方问题)-接口入参
*/
@Data
public class ModifyCustomerFormDTO implements Serializable {
private static final long serialVersionUID = -6547893374373422628L;
/**
* 待修改的客户Id 公众号创建的客户
* */
private String oldCustomerId;
/**
* 修改后的客户Id crm表原来的customerId
*/
private String newCustomerId;
}

30
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/FixationAppIdResultDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/3 4:15 下午
*/
@Data
public class FixationAppIdResultDTO implements Serializable {
private static final long serialVersionUID = 3810567059789358255L;
/**
* 客户ID
*/
private String masterCustomerId;
/**
* 客户端类型resi居民端work工作端
*/
private String clientType;
/**
* AppId
*/
private String appId;
}

15
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java

@ -86,6 +86,21 @@ public interface ModuleConstant {
String AUDIT_FAILED = "audit_failed";
String XML = "xml";
String CREATE_TIME = "CreateTime";
String QUERY_AUTH_CODE = "QUERY_AUTH_CODE";
String _CALL_BACK = "_callback";
String FROM_CALLBACK = "from_callback";
String APPLICATION_JSON = "application/json";
String _FROM_API = "_from_api";
/**
* 微信模推送给第三方平台方 Content固定格式
*/
String TESTCOMPONENT_MSG_TYPE_TEXT = "TESTCOMPONENT_MSG_TYPE_TEXT";
/**
* 第三方平台方立马回应文本消息并最终触达粉丝 Content固定格式
*/
String TESTCOMPONENT_MSG_TYPE_TEXT_callback = "TESTCOMPONENT_MSG_TYPE_TEXT_callback";
int FORTY_THOUSAND_AND_THIRTEEN = 40013;
int EIGHTY_NINE_THOUSAND = 89000;

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

@ -78,4 +78,8 @@ public interface PaConstant {
* 获取访问记录表数据失败失败
*/
String SELECT_VISITED_EXCEPTION = "获取访问记录表数据失败";
/**
* 更新客户Id信息失败
*/
String UPDATE_CUSTOMER_EXCEPTION = "更新客户Id信息失败";
}

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

@ -103,4 +103,8 @@ public interface ThirdRunTimeInfoConstant {
String BEGIN_CREATE_OPEN = "============================开始执行绑定开放平台账号===================================";
String CODE_AUDIT_RESULT = "----------------------------------代码审核结果即将插入,需要插入的内容为:%s-----------------------------------------";
String TEXT_MESSAGE_LOG_INFO = "content:%s,content[1]:%s,fromUserName:%s,toUserName:%s";
String SEND_MESSAGE_XML = "要发送的xml内容为:%s";
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CustomerMpDTO;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.form.AuthCodeFormDTO;
import com.epmet.dto.form.ModifyCustomerFormDTO;
import com.epmet.entity.CustomerMpEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -123,4 +124,12 @@ public interface CustomerMpDao extends BaseDao<CustomerMpEntity> {
* @author zxc
*/
String getAppId(@Param("customerId")String customerId,@Param("clientType")String clientType);
/**
* @param formDTO
* @return
* @Author sun
* @Description 修改customer_mp表客户Id
**/
int updateCustomerId(ModifyCustomerFormDTO formDTO);
}

43
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FixationAppIdDao.java

@ -0,0 +1,43 @@
/**
* 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.FixationAppIdResultDTO;
import com.epmet.entity.FixationAppIdEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 固定的AppId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-03
*/
@Mapper
public interface FixationAppIdDao extends BaseDao<FixationAppIdEntity> {
/**
* @Description 查询固定AppId信息
* @author zxc
* @date 2020/8/3 4:25 下午
*/
List<FixationAppIdResultDTO> selectFixationInfos();
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PaCustomerAgencyDTO;
import com.epmet.dto.form.ModifyCustomerFormDTO;
import com.epmet.entity.PaCustomerAgencyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -54,4 +55,12 @@ public interface PaCustomerAgencyDao extends BaseDao<PaCustomerAgencyEntity> {
* @Description 公众号-查询客户组织信息
**/
PaCustomerAgencyDTO selectAgency(@Param("customerId") String customerId);
/**
* @param formDTO
* @return
* @Author sun
* @Description 修改pa_customer_agency表客户Id
**/
int updateCustomerId(ModifyCustomerFormDTO formDTO);
}

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

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
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.RegisterByAuthResultDTO;
@ -69,4 +70,11 @@ public interface PaCustomerDao extends BaseDao<PaCustomerEntity> {
**/
List<RegisterByAuthResultDTO> selectCustomerList(RegisterByAuthFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 修改pa_customer表主键值
**/
int updateIdById(ModifyCustomerFormDTO formDTO);
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerUserAgencyDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PaCustomerUserAgencyDTO;
import com.epmet.dto.form.ModifyCustomerFormDTO;
import com.epmet.entity.PaCustomerUserAgencyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -47,4 +48,12 @@ public interface PaCustomerUserAgencyDao extends BaseDao<PaCustomerUserAgencyEnt
* @Description 根据userId查询客户信息
**/
PaCustomerUserAgencyDTO selectCustomerIdByUserId(@Param("userId") String userId);
/**
* @param formDTO
* @return
* @Author sun
* @Description 修改pa_customer_user_agency表客户Id
**/
int updateCustomerId(ModifyCustomerFormDTO formDTO);
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java

@ -20,6 +20,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PaUserDTO;
import com.epmet.dto.form.CheckPaUserFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.entity.PaUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -58,4 +59,12 @@ public interface PaUserDao extends BaseDao<PaUserEntity> {
* @Description 根据数据来源和手机号查询公众号用户基本信息校验用户是否存在
**/
PaUserDTO selectUser(@Param("id") String id, @Param("source") String source);
/**
* @Description 查询管理员基本信息
* @param customerId
* @author zxc
* @date 2020/8/3 5:21 下午
*/
CustomerManagerFormDTO selectManagerInfo(@Param("customerId") String customerId);
}

56
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/FixationAppIdEntity.java

@ -0,0 +1,56 @@
/**
* 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;
/**
* 固定的AppId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-03
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("fixation_app_id")
public class FixationAppIdEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 小程序AppId
*/
private String appId;
/**
* 客户Id
*/
private String customerId;
/**
* 客户端类型resi居民端work工作端
*/
private String clientType;
}

13
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java

@ -21,10 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.form.CreateAgencyFormDTO;
import com.epmet.dto.form.RegisterByAuthFormDTO;
import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.form.RegisterInfoFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.PaCustomerEntity;
@ -163,4 +160,12 @@ public interface PaCustomerService extends BaseService<PaCustomerEntity> {
* @Description 根据初始化状态获取公众号注册的客户列表
**/
List<RegisterByAuthResultDTO> registerByAuth(RegisterByAuthFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 修改各业务表customerId(兼容党群e事通已上线客户将已有客户Id同步到第三方问题)
**/
void modifyCustomer(ModifyCustomerFormDTO formDTO);
}

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

@ -15,6 +15,7 @@ import com.epmet.dao.*;
import com.epmet.dto.PaCustomerUserAgencyDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.mpaes.WXBizMsgCrypt;
import com.epmet.mpaes.WXXmlToMapUtil;
import com.epmet.redis.RedisThird;
@ -79,6 +80,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
private AuthResultRecordDao authResultRecordDao;
@Autowired
private PaCustomerUserAgencyDao paCustomerUserAgencyDao;
@Autowired
private FixationAppIdDao fixationAppIdDao;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private PaUserDao paUserDao;
@Autowired
private PaCustomerServiceImpl paCustomerServiceImpl;
@Value("${third.platform.appId}")
private String componentAppId;
@ -386,8 +395,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String authCode = authCodeAndTime.getAuthCode();
String clientType = authCodeAndTime.getClientType();
String expiresIn = authCodeAndTime.getExpiresIn();
// 公众号创建客户的id
String customerId = this.getLoginUserCustomerId(tokenDto);
Date expiresInTime = this.countExpirationTime(expiresIn);
//authCode存数据库
AuthCodeFormDTO formDTO = new AuthCodeFormDTO();
formDTO.setAuthCode(authCode);
@ -402,6 +414,32 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
// 1. 开始获取授权信息(使用授权码)
AuthorizationInfoResultDTO authorizationInfoResultDTO = this.authInfoByAuthCode(authCode, customerId, clientType);
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid();
List<FixationAppIdResultDTO> fixationAppIdResultDTOS = fixationAppIdDao.selectFixationInfos();
String finalCustomerId = customerId;//
fixationAppIdResultDTOS.forEach(fixationAppId -> {
if (fixationAppId.getAppId().equals(authAppId)){
// TODO 是城阳项目或者党群e事通
// crm表中的customerId【原customerId】
String masterCustomerId = fixationAppId.getMasterCustomerId();
formDTO.setCustomerId(masterCustomerId);
authCodeDao.deleteCustomerAuthCode(finalCustomerId,clientType);
authCodeDao.insertRedirectAuthCode(formDTO);
//authCode存缓存
redisThird.setAuthCode(formDTO);
ModifyCustomerFormDTO modifyCustomer = new ModifyCustomerFormDTO();
modifyCustomer.setOldCustomerId(finalCustomerId);
modifyCustomer.setNewCustomerId(masterCustomerId);
paCustomerServiceImpl.modifyCustomer(modifyCustomer);
// 管理员授权
CustomerManagerFormDTO customerManager = paUserDao.selectManagerInfo(finalCustomerId);
customerManager.setCustomerId(finalCustomerId);
operCrmOpenFeignClient.addManager(customerManager);
}
});
//替换 新customerId为旧customerId
customerId = formDTO.getCustomerId();
// 2. 创建开放平台账号并绑定 或者 直接绑定开放平台
this.createAndBindOpenAccount(customerId,authAppId,clientType);
// 3. 更新 customer_mp 表授权状态和AuthAppId

37
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java

@ -34,10 +34,7 @@ import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.constant.PaConstant;
import com.epmet.dao.*;
import com.epmet.dto.*;
import com.epmet.dto.form.CreateAgencyFormDTO;
import com.epmet.dto.form.RegisterByAuthFormDTO;
import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.form.RegisterInfoFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.*;
import com.epmet.redis.PaCustomerRedis;
@ -505,4 +502,36 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
return baseDao.selectCustomerList(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 修改各业务表customerId(兼容党群e事通已上线客户将已有客户Id同步到第三方问题)
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void modifyCustomer(ModifyCustomerFormDTO formDTO) {
//1.修改pa_customer表主键
if (baseDao.updateIdById(formDTO) < NumConstant.ONE) {
logger.error(String.format("修改pa_customer表Id失败,待修改的客户Id->%s,修改后的客户Id->%s", formDTO.getOldCustomerId(), formDTO.getNewCustomerId()));
throw new RenException(PaConstant.UPDATE_CUSTOMER_EXCEPTION);
}
//2.修改pa_customer_agency表customerId
if (paCustomerAgencyDao.updateCustomerId(formDTO) < NumConstant.ONE) {
logger.error(String.format("修改pa_customer_agency表客户Id失败,待修改的客户Id->%s,修改后的客户Id->%s", formDTO.getOldCustomerId(), formDTO.getNewCustomerId()));
throw new RenException(PaConstant.UPDATE_CUSTOMER_EXCEPTION);
}
//3.修改customer_mp表customerId
if (customerMpDao.updateCustomerId(formDTO) < NumConstant.ONE) {
logger.error(String.format("修改customer_mp表客户Id失败,待修改的客户Id->%s,修改后的客户Id->%s", formDTO.getOldCustomerId(), formDTO.getNewCustomerId()));
throw new RenException(PaConstant.UPDATE_CUSTOMER_EXCEPTION);
}
//4.修改pa_customer_user_agency表customerId
if (paCustomerUserAgencyDao.updateCustomerId(formDTO) < NumConstant.ONE) {
logger.error(String.format("修改pa_customer_user_agency表客户Id失败,待修改的客户Id->%s,修改后的客户Id->%s", formDTO.getOldCustomerId(), formDTO.getNewCustomerId()));
throw new RenException(PaConstant.UPDATE_CUSTOMER_EXCEPTION);
}
}
}

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

@ -1,18 +1,29 @@
package com.epmet.service.impl;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.client.config.utils.IOUtils;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ModuleConstant;
import com.epmet.constant.ThirdRedisKeyConstant;
import com.epmet.constant.ThirdRunTimeInfoConstant;
import com.epmet.dao.*;
import com.epmet.dto.form.CodeAuditRecordFormDTO;
import com.epmet.dto.form.MessagePushTextFormDTO;
import com.epmet.dto.result.AuthorizationInfoResultDTO;
import com.epmet.dto.result.CustomerIdAndClientResultDTO;
import com.epmet.dto.result.TemplateAndAppIdResultDTO;
import com.epmet.mpaes.AesException;
import com.epmet.mpaes.WXBizMsgCrypt;
import com.epmet.mpaes.WXXmlToMapUtil;
import com.epmet.redis.RedisThird;
import com.epmet.service.WarrantService;
import com.epmet.wxapi.constant.WxMaCodeConstant;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.DocumentException;
@ -26,6 +37,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
@ -56,6 +68,8 @@ public class WarrantServiceImpl implements WarrantService {
private ComponentVerifyTicketServiceImpl componentVerifyTicketServiceImpl;
@Autowired
private MessagePushTextDao messagePushTextDao;
@Autowired
private RedisThird redisThird;
/**
* @Description 1.保存代码审核结果 2.更新代码上传结果
@ -134,8 +148,140 @@ public class WarrantServiceImpl implements WarrantService {
Date date = componentVerifyTicketServiceImpl.sToDate(createTime.toString());
messagePushTextFormDTO.setWeChatCreateTime(date);
messagePushTextDao.insertMessageText(messagePushTextFormDTO);
// switch (messagePushTextFormDTO.getContent()){
// //测试公众号处理用户消息
// case ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT:
//
//
// }
// if (messagePushTextFormDTO.getContent().startsWith(ModuleConstant.QUERY_AUTH_CODE)){
// // 测试公众号使用客服消息接口处理用户消息
// String content = messagePushTextFormDTO.getContent();
// String contentBefore = content.substring(NumConstant.ZERO, content.indexOf(ThirdRedisKeyConstant.COLON));
// //auth_code
// String queryAuthCode = content.substring(contentBefore.length() + NumConstant.ONE, content.length());
//
// }
}
log.info("消息与事件接收URL【代码审核结果】结束......");
return ModuleConstant.SUCCESS;
}
/**
* 方法描述: 类型为enevt的时候拼接
* @param request
* @param response
* @param event
* @param toUserName 发送接收人
* @param fromUserName 发送人
* @author zxc
*/
public void replyEventMessage(HttpServletRequest request, HttpServletResponse response,
String event, String toUserName, String fromUserName)
throws DocumentException, IOException {
String content = event + ModuleConstant.FROM_CALLBACK;
replyTextMessage(request,response,content,toUserName,fromUserName);
}
/**
* 立马回应文本消息并最终触达粉丝
* @param content 文本
* @param toUserName 发送接收人
* @param fromUserName 发送人
* @author zxc
*/
public void processTextMessage(HttpServletRequest request, HttpServletResponse response,
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);
}else if(StringUtils.startsWithIgnoreCase(content, ModuleConstant.QUERY_AUTH_CODE)){
response.getWriter().print("");//需在5秒内返回空串表明暂时不回复,然后再立即使用客服消息接口发送消息回复粉丝
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);
}
}
/**
* 方法描述: 直接返回给微信开放平台
* @param request
* @param response
* @param content 文本
* @param toUserName 发送接收人
* @param fromUserName 发送人
* @author zxc
*/
public void replyTextMessage(HttpServletRequest request, HttpServletResponse response,
String content,String toUserName, String fromUserName)
throws DocumentException, IOException {
Long createTime = System.currentTimeMillis() / 1000;
StringBuffer sb = new StringBuffer(512);
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("<Content><![CDATA["+content+"]]></Content>");
sb.append("</xml>");
String replyMsg = sb.toString();
log.info(String.format(ThirdRunTimeInfoConstant.SEND_MESSAGE_XML,replyMsg));
returnJSON(replyMsg,response);
}
/**
* 方法描述: 调用客服回复消息给粉丝
* @param auth_code
* @param fromUserName
* @throws DocumentException
* @throws IOException
* @return void
* @author zxc
*/
public void replyApiTextMessage(String auth_code, String fromUserName) throws DocumentException, IOException {
// 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来
//第三方平台【component_access_token】
String componentAccessToken = redisThird.getComponentAccessToken();
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
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);
Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO);
AuthorizationInfoResultDTO authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class);
String authorizer_access_token = authorizationInfoResultDTO.getAuthorizer_access_token();
JSONObject json = new JSONObject();
json.put("touser",fromUserName);
json.put("msgtype", "text");
json.put("text", "{\"content\":\""+auth_code+ModuleConstant._FROM_API+"\"}");
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.SEND_MESSAGE_CUSTOM + authorizer_access_token, JSON.toJSONString(json)).getData();
log.info("客服发送接口返回值:"+data);
}
/**
* 方法描述: 返回数据到请求方
* @param data 数据
* @param response
* @author zxc
*/
public void returnJSON(Object data,HttpServletResponse response) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonEncoding encoding = JsonEncoding.UTF8;
response.setContentType(ModuleConstant.APPLICATION_JSON);
JsonGenerator generator = objectMapper.getJsonFactory().
createJsonGenerator(response.getOutputStream(), encoding);
objectMapper.writeValue(generator, data);
} catch (IOException e) {
e.printStackTrace();
}
}
}

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

@ -76,6 +76,11 @@ public interface WxMaCodeConstant {
*/
String API_OPEN_GET = "https://api.weixin.qq.com/cgi-bin/open/get?access_token=";
/**
*
*/
String SEND_MESSAGE_CUSTOM = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=";
/**
* 为授权的小程序帐号上传小程序代码.
*/

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

@ -204,7 +204,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
public WxResult<byte[]> getMaterial(String accessToken, WxMaNewsReq request) {
WxResult<byte[]> result = new WxResult<>();
String url = WxMaCodeConstant.GET_MATERIAL_URL + "?" + "access_token=" + accessToken;
Result<byte[]> statusResult = HttpClientManager.getInstance().getByteArray(url, toMap(request));
Result<byte[]> statusResult = HttpClientManager.getInstance().getMediaByteArray(url, toJson(request));
if (!statusResult.success()) {
result.setErrorCode(statusResult.getCode());
result.setErrorMsg(statusResult.getMsg());

13
epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.4__thirdUpdate.sql

@ -0,0 +1,13 @@
CREATE TABLE `fixation_app_id` (
`ID` varchar(64) NOT NULL COMMENT 'ID',
`APP_ID` varchar(64) DEFAULT NULL COMMENT '小程序AppId',
`CUSTOMER_ID` varchar(64) DEFAULT NULL COMMENT '客户Id',
`CLIENT_TYPE` varchar(32) DEFAULT NULL COMMENT '客户端类型resi:居民端,work:工作端',
`DEL_FLAG` int(11) DEFAULT NULL COMMENT '删除状态0:正常,已删除',
`REVISION` int(11) DEFAULT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建人',
`CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新人',
`UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='固定的AppId表 ';

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

@ -145,4 +145,12 @@
AND client = #{clientType}
</select>
<update id="updateCustomerId">
UPDATE customer_mp
SET customer_id = #{newCustonerId}
WHERE
del_flag = '0'
AND customer_id = #{oldCustomerId}
</update>
</mapper>

17
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FixationAppIdDao.xml

@ -0,0 +1,17 @@
<?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.FixationAppIdDao">
<!-- 查询固定AppId信息 -->
<select id="selectFixationInfos" resultType="com.epmet.dto.result.FixationAppIdResultDTO">
SELECT
customer_id AS masterCustomerId,
client_type AS clientType,
app_id AS appId
FROM
fixation_app_id
WHERE
del_flag = 0
</select>
</mapper>

8
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml

@ -82,4 +82,12 @@
LIMIT 1
</select>
<update id="updateCustomerId">
UPDATE pa_customer_agency
SET customer_id = #{newCustonerId}
WHERE
del_flag = '0'
AND customer_id = #{oldCustomerId}
</update>
</mapper>

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

@ -79,4 +79,12 @@
AND id = #{id}
</update>
<update id="updateIdById">
UPDATE pa_customer
SET id = #{newCustonerId}
WHERE
del_flag = '0'
AND id = #{oldCustomerId}
</update>
</mapper>

8
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerUserAgencyDao.xml

@ -34,4 +34,12 @@
AND pcua.user_id = #{userId}
</select>
<update id="updateCustomerId">
UPDATE pa_customer_user_agency
SET customer_id = #{newCustonerId}
WHERE
del_flag = '0'
AND customer_id = #{oldCustomerId}
</update>
</mapper>

16
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml

@ -50,4 +50,20 @@
AND source = #{source}
</select>
<!-- 查询管理员基本信息 -->
<select id="selectManagerInfo" resultType="com.epmet.dto.form.CustomerManagerFormDTO">
SELECT
pu.real_name AS realName,
pu.gender AS gender,
pu.phone AS mobile
FROM
pa_user pu
LEFT JOIN customer_mp cm ON cm.created_by = pu.id
WHERE
pu.del_flag = '0'
AND cm.CUSTOMER_ID = #{customerId}
AND CM.DEL_FLAG = '0'
LIMIT 1
</select>
</mapper>

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

@ -5,9 +5,11 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@ -41,4 +43,14 @@ public interface OperCrmOpenFeignClient {
*/
@PostMapping("/oper/crm/customerapp/getconfigallapp")
Result<List<CustomerAppDTO>> getConfigAllApp();
/**
* 添加根管理员
* @author zhaoqifeng
* @date 2020/8/3 15:24
* @param form
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("/oper/crm/customer/addmanager")
Result addManager(@RequestBody CustomerManagerFormDTO form);
}

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

@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import org.springframework.stereotype.Component;
@ -39,4 +40,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result<List<CustomerAppDTO>> getConfigAllApp() {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getConfigAllApp", null);
}
@Override
public Result addManager(CustomerManagerFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "CustomerManagerFormDTO", form);
}
}

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

@ -2,7 +2,7 @@ version: "3.7"
services:
oper-crm-server:
container_name: oper-crm-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/oper-crm-server:0.3.58
image: 192.168.1.130:10080/epmet-cloud-dev/oper-crm-server:0.3.59
ports:
- "8090:8090"
network_mode: host # 使用现有网络

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

@ -278,6 +278,19 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
throw new RenException("没有查询到客户根级组织,无法设置管理员:".concat(getRoleResult.toString()));
}
StaffRoleFormDTO staffRoleFormDTO = new StaffRoleFormDTO();
staffRoleFormDTO.setOrgId(customerRootAgencyResult.getData().getId());
staffRoleFormDTO.setRoleKey(RoleKeyConstants.ROLE_KEY_ROOT_MANAGER);
Result<List<GovStaffRoleResultDTO>> managersResult = epmetUserFeignClient.getStaffsInRole(staffRoleFormDTO);
if(!managersResult.success()) {
log.error("查询客户根级组织的管理员失败".concat(getRoleResult.toString()));
throw new RenException("查询客户根级组织的管理员失败".concat(getRoleResult.toString()));
}
if(null != managersResult.getData() && managersResult.getData().size() > NumConstant.ZERO) {
log.error("客户已存在管理员".concat(getRoleResult.toString()));
throw new RenException("客户已存在管理员".concat(getRoleResult.toString()));
}
StaffSubmitFromDTO staffSubmitFrom = new StaffSubmitFromDTO();
staffSubmitFrom.setCustomerId(form.getCustomerId());
staffSubmitFrom.setAgencyId(customerRootAgencyResult.getData().getId());

6
epmet-module/resi-mine/resi-mine-server/pom.xml

@ -90,6 +90,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-third-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

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

@ -3,14 +3,13 @@ package com.epmet.modules.grid.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.result.AllGridsByUserIdResultDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
import com.epmet.modules.grid.service.ResiMineGridService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -48,4 +47,19 @@ public class ResiMineGridController {
public Result<List<AllGridsByUserIdResultDTO>> allGrids(@LoginUser TokenDto tokenDto){
return resiMineGridService.allGrids(tokenDto.getUserId());
}
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-获取用户最近访问网格
* @Date 2020/8/3
**/
@PostMapping("latestgridinfo")
public Result<LatestGridInfoResultDTO> latestGridInfo(@LoginUser TokenDto token, @RequestBody LatestGridInfoFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
formDTO.setUserId(token.getUserId());
return new Result<LatestGridInfoResultDTO>().ok(resiMineGridService.latestGridInfo(formDTO));
}
}

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

@ -2,6 +2,7 @@ package com.epmet.modules.grid.service;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.result.AllGridsByUserIdResultDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
@ -29,4 +30,13 @@ public interface ResiMineGridService {
* @Author sun
**/
Result<List<AllGridsByUserIdResultDTO>> allGrids(String userId);
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-获取用户最近访问网格
* @Date 2020/8/3
**/
LatestGridInfoResultDTO latestGridInfo(LatestGridInfoFormDTO formDTO);
}

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

@ -1,13 +1,19 @@
package com.epmet.modules.grid.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.result.AllGridsByUserIdResultDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.modules.feign.EpmetUserFeignClient;
import com.epmet.modules.feign.GovOrgFeignClient;
import com.epmet.modules.grid.service.ResiMineGridService;
@ -20,6 +26,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description 居民端用户网格信息service
@ -33,6 +40,8 @@ public class ResiMineGridServiceImpl implements ResiMineGridService {
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
/**
* @param tokenDto
@ -88,4 +97,42 @@ public class ResiMineGridServiceImpl implements ResiMineGridService {
}
return result.ok(resultGrids.getData());
}
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-获取用户最近访问网格
* @Date 2020/8/3
**/
@Override
public LatestGridInfoResultDTO latestGridInfo(LatestGridInfoFormDTO formDTO) {
logger.info(String.format("居民端获取用户最近访问网格入参%s", JSON.toJSONString(formDTO)));
//1.调用third服务,根据appId获取客户Id
JSONObject jsonObject = new JSONObject();
String customerMsgUrl = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/";
String data = HttpClientManager.getInstance().sendPostByJSON(customerMsgUrl + formDTO.getAppId(), JSON.toJSONString(jsonObject)).getData();
logger.info("调用third服务,根据appId查询客户信息:httpclient->url:" + customerMsgUrl + ",结果->" + data);
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (!mapToResult.success()) {
logger.error(String.format("根据appId查询客户信息失败,对应appId->" + formDTO.getAppId()));
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);
logger.info("小程序登陆third服务获取客户用户信息PaCustomerDTO->" + customer);
//2.调用epmet-user服务,根据客户Id和用户Id查询最后一次访问记录
formDTO.setCustomerId(customer.getId());
Result<LatestGridInfoResultDTO> userResult = epmetUserOpenFeignClient.latestGridInfo(formDTO);
if (!userResult.success()) {
logger.error(String.format("居民端获取用户最近访问网格失败,接口入参客户Id->%s,appId->%s,调用epmet-user-server服务返回->%s", formDTO.getCustomerId(), formDTO.getAppId(), JSON.toJSONString(userResult)));
}
return userResult.getData();
}
}

38
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/LatestGridInfoFormDTO.java

@ -0,0 +1,38 @@
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 单客户-获取用户最近访问网格-接口入参
* @Auth sun
*/
@Data
public class LatestGridInfoFormDTO implements Serializable {
private static final long serialVersionUID = -6534841370041338474L;
public interface AddUserInternalGroup {
}
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
/**
* 小程序绑定的appId
*/
@NotBlank(message = "数据来源不能为空", groups = {LatestGridInfoFormDTO.AddUserInternalGroup.class, LatestGridInfoFormDTO.AddUserShowGroup.class})
private String appId;
/**
* 根据appId查询到的客户Id
*/
private String customerId;
/**
* token中userId
*/
private String userId;
}

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

@ -249,4 +249,14 @@ public interface EpmetUserOpenFeignClient {
**/
@PostMapping("/epmetuser/userbaseinfo/volunteerbaseinfo")
Result volunteerBaseInfo(@RequestBody ResiVolunteerAuthenticateFormDTO param);
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-获取用户最近访问网格
* @Date 2020/8/3
**/
@PostMapping(value = "epmetuser/gridlatest/latestgridinfo")
Result<LatestGridInfoResultDTO> latestGridInfo(@RequestBody LatestGridInfoFormDTO formDTO);
}

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

@ -178,4 +178,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
public Result volunteerBaseInfo(ResiVolunteerAuthenticateFormDTO param) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "volunteerBaseInfo", param);
}
@Override
public Result<LatestGridInfoResultDTO> latestGridInfo(LatestGridInfoFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "latestGridInfo", formDTO);
}
}

13
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java

@ -27,6 +27,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.GridLatestDTO;
import com.epmet.dto.form.CustomerUserFormDTO;
import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.result.CustomerUser4PointResultDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
import com.epmet.excel.GridLatestExcel;
@ -130,4 +131,16 @@ public class GridLatestController {
return new Result<List<CustomerUser4PointResultDTO>>().ok(gridLatestService.getCustomerUsers(param));
}
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-根据客户Id和userId查询用户最后一次访问的网格
* @Date 2020/8/3
**/
@PostMapping("latestgridinfo")
public Result<LatestGridInfoResultDTO> latestGridInfo(@RequestBody LatestGridInfoFormDTO formDTO){
return new Result<LatestGridInfoResultDTO>().ok(gridLatestService.latestGridInfo(formDTO));
}
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GridLatestDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.GridLatestDTO;
import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
import com.epmet.entity.GridLatestEntity;
import org.apache.ibatis.annotations.Mapper;
@ -64,4 +65,13 @@ public interface GridLatestDao extends BaseDao<GridLatestEntity> {
* @date 2020.07.25 15:26
**/
List<String> selectAllUserByCustomerId(@Param("customerId")String customerId);
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-根据客户Id和userId查询用户最后一次访问的网格
* @Date 2020/8/3
**/
LatestGridInfoResultDTO selectLatestGridInfo(LatestGridInfoFormDTO formDTO);
}

9
epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java

@ -23,6 +23,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.GridLatestDTO;
import com.epmet.dto.form.CustomerUserFormDTO;
import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.form.VisitedFormDTO;
import com.epmet.dto.result.CustomerUser4PointResultDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
@ -131,4 +132,12 @@ public interface GridLatestService extends BaseService<GridLatestEntity> {
**/
List<CustomerUser4PointResultDTO> getCustomerUsers(CustomerUserFormDTO customerUserFormDTO);
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-根据客户Id和userId查询用户最后一次访问的网格
* @Date 2020/8/3
**/
LatestGridInfoResultDTO latestGridInfo(LatestGridInfoFormDTO formDTO);
}

14
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java

@ -30,6 +30,7 @@ import com.epmet.dao.UserWechatDao;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.GridLatestDTO;
import com.epmet.dto.form.CustomerUserFormDTO;
import com.epmet.dto.form.LatestGridInfoFormDTO;
import com.epmet.dto.form.VisitedFormDTO;
import com.epmet.dto.result.CustomerUser4PointResultDTO;
import com.epmet.dto.result.LatestGridInfoResultDTO;
@ -204,4 +205,17 @@ public class GridLatestServiceImpl extends BaseServiceImpl<GridLatestDao, GridLa
return allData;
}
/**
* @return
* @param formDTO
* @Author sun
* @Description 单客户-根据客户Id和userId查询用户最后一次访问的网格
* @Date 2020/8/3
**/
@Override
public LatestGridInfoResultDTO latestGridInfo(LatestGridInfoFormDTO formDTO) {
return baseDao.selectLatestGridInfo(formDTO);
}
}

15
epmet-user/epmet-user-server/src/main/resources/mapper/GridLatestDao.xml

@ -93,4 +93,19 @@
del_flag = '0'
AND customer_id = #{customerId}
</select>
<select id="selectLatestGridInfo" resultType="com.epmet.dto.result.LatestGridInfoResultDTO">
SELECT
gl.GRID_ID,
gl.CUSTOMER_ID
FROM
grid_latest gl
WHERE
gl.DEL_FLAG = '0'
AND gl.CUSTOMER_ID = #{customerId}
AND gl.CUSTOMER_USER_ID = #{userId}
ORDER BY
gl.LATEST_TIME DESC
LIMIT 1
</select>
</mapper>

Loading…
Cancel
Save