Browse Source

短信发送限制

dev_shibei_match
zxc 5 years ago
parent
commit
26b056f759
  1. 17
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SysSmsConstant.java
  2. 6
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java
  3. 6
      epmet-module/epmet-message/epmet-message-server/pom.xml
  4. 65
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java
  5. 77
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerParameterDTO.java
  6. 28
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CrmParameterFormDTO.java
  7. 39
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CrmParameterResultDTO.java
  8. 13
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  9. 7
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  10. 42
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerParameterController.java
  11. 27
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerParameterDao.java
  12. 44
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerParameterEntity.java
  13. 22
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerParameterService.java
  14. 43
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerParameterServiceImpl.java
  15. 19
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml

17
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SysSmsConstant.java

@ -0,0 +1,17 @@
package com.epmet.constant;
/**
* @Author zxc
* @DateTime 2021/1/4 下午1:42
*/
public interface SysSmsConstant {
String IS_NULL_PARAM_LIST = "项目流转或滞留推送短信提醒入参集合为空......";
String SELECT_PARAMETER_INFO_FAILURE = "查询客户配置参数失败......";
String PARAMETER_INFO_IS_ZERO = "未查到客户配置参数......";
String NOT_ENOUGH_BALANCE = "客户:%s ,当前余额为:%s";
}

6
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java

@ -31,6 +31,12 @@ public class ProjectSendMsgFormDTO implements Serializable {
@NotBlank(message = "客户ID不能为空", groups = {AddUserInternalGroup.class})
private String customerId;
/**
* 参数KEY
*/
@NotBlank(message = "参数KEY不能为空", groups = {AddUserInternalGroup.class})
private String parameterKey;
public interface AddUserInternalGroup {}
public interface AddUserShowGroup extends CustomerClientShowGroup {}

6
epmet-module/epmet-message/epmet-message-server/pom.xml

@ -112,6 +112,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<!-- crm -->
<dependency>
<groupId>com.epmet</groupId>
<artifactId>oper-crm-client</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>

65
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java

@ -17,15 +17,20 @@ import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.SysSmsConstant;
import com.epmet.dao.SysSmsDao;
import com.epmet.dto.SysSmsDTO;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.form.ProjectSendMsgFormDTO;
import com.epmet.dto.form.SendVerificationCodeFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.dto.result.SendVerificationCodeResultDTO;
import com.epmet.entity.SysSmsEntity;
import com.epmet.exception.ModuleErrorCode;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.service.SysSmsService;
import com.epmet.sms.AbstractSmsService;
import com.epmet.sms.SmsFactory;
@ -36,11 +41,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class SysSmsServiceImpl extends BaseServiceImpl<SysSmsDao, SysSmsEntity> implements SysSmsService {
@ -49,6 +56,8 @@ public class SysSmsServiceImpl extends BaseServiceImpl<SysSmsDao, SysSmsEntity>
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Override
public PageData<SysSmsDTO> page(Map<String, Object> params) {
@ -191,13 +200,57 @@ public class SysSmsServiceImpl extends BaseServiceImpl<SysSmsDao, SysSmsEntity>
**/
@Override
public void projectSendMsg(List<ProjectSendMsgFormDTO> formDTOList) {
formDTOList.forEach(dto->{
SysSmsDTO sysSmsDTO = new SysSmsDTO();
sysSmsDTO.setMobile(dto.getMobile());
sysSmsDTO.setAliyunTemplateCode(dto.getAliyunTemplateCode());
//推送短信
this.sendMsg(sysSmsDTO);
if (CollectionUtils.isEmpty(formDTOList)){
logger.error(SysSmsConstant.IS_NULL_PARAM_LIST);
return;
}
Map<String, List<ProjectSendMsgFormDTO>> groupByCustomer = formDTOList.stream().collect(Collectors.groupingBy(ProjectSendMsgFormDTO::getCustomerId));
List<CrmParameterFormDTO> parameterFormDTOS = ConvertUtils.sourceToTarget(formDTOList, CrmParameterFormDTO.class);
Result<List<CrmParameterResultDTO>> listResult = operCrmOpenFeignClient.selectParamInfo(parameterFormDTOS);
if (!listResult.success()){
throw new RenException(SysSmsConstant.SELECT_PARAMETER_INFO_FAILURE);
}
List<CrmParameterResultDTO> parameterResult = listResult.getData();
if (CollectionUtils.isEmpty(parameterResult)){
logger.error(SysSmsConstant.PARAMETER_INFO_IS_ZERO);
return;
}
groupByCustomer.forEach((customerId,v) -> {
parameterResult.forEach(p -> {
if (customerId.equals(p.getCustomerId())){
p.setBalanceStatus(Integer.valueOf(p.getParameterValue()) >= v.size() ? true : false);
}
});
});
try {
groupByCustomer.forEach((customerId,v) -> {
parameterResult.forEach(p -> {
if (customerId.equals(p.getCustomerId())){
if (p.getBalanceStatus() == false){
logger.error(String.format(SysSmsConstant.NOT_ENOUGH_BALANCE,customerId,p.getParameterValue()));
}else {
v.forEach(dto->{
SysSmsDTO sysSmsDTO = new SysSmsDTO();
sysSmsDTO.setMobile(dto.getMobile());
sysSmsDTO.setAliyunTemplateCode(dto.getAliyunTemplateCode());
//推送短信
this.sendMsg(sysSmsDTO);
});
}
}
});
});
}catch (RenException e){
logger.error(e.getInternalMsg());
}
// formDTOList.forEach(dto->{
// SysSmsDTO sysSmsDTO = new SysSmsDTO();
// sysSmsDTO.setMobile(dto.getMobile());
// sysSmsDTO.setAliyunTemplateCode(dto.getAliyunTemplateCode());
// //推送短信
// this.sendMsg(sysSmsDTO);
// });
}
/**

77
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerParameterDTO.java

@ -0,0 +1,77 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Author zxc
* @DateTime 2021/1/4 上午10:59
*/
@Data
public class CustomerParameterDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键 唯一标识
*/
private String id;
/**
* 客户ID
*/
private String customerId;
/**
* 参数KEY值
*/
private String parameterKey;
/**
* 参数名称
*/
private String parameterName;
/**
* 参数VALUE值
*/
private String parameterValue;
/**
* 说明
*/
private String description;
/**
* 删除标识0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

28
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CrmParameterFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/1/4 上午10:44
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CrmParameterFormDTO implements Serializable {
private static final long serialVersionUID = -1892384189805073724L;
public interface CrmParameterForm{}
@NotBlank(message = "客户ID不能为空",groups = {CrmParameterForm.class})
private String customerId;
@NotBlank(message = "参数KEY值不能为空",groups = {CrmParameterForm.class})
private String parameterKey;
}

39
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CrmParameterResultDTO.java

@ -0,0 +1,39 @@
package com.epmet.dto.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/1/4 上午10:46
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CrmParameterResultDTO implements Serializable {
private static final long serialVersionUID = 8082721392714934568L;
/**
* 客户ID
*/
private String customerId;
/**
* 参数KEY值
*/
private String parameterKey;
/**
* 参数VALUE值
*/
private String parameterValue;
/**
* 余额状态parameterValuetrue充足false不足
*/
private Boolean balanceStatus = true;
}

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

@ -4,9 +4,11 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.GridCountFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
@ -22,7 +24,7 @@ import java.util.List;
* @date 2020/6/4 13:25
*/
@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class)
//@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class, url = "118.190.150.119:48080/api")
//@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class, url = "localhost:8090")
public interface OperCrmOpenFeignClient {
/**
* 获取客户信息
@ -74,4 +76,13 @@ public interface OperCrmOpenFeignClient {
*/
@PostMapping("/oper/crm/customer/getgridcount")
Result<GridCountResultDTO> getGridCount(@RequestBody GridCountFormDTO formDTO);
/**
* @Description 查询客户配置信息
* @Param formDTO
* @author zxc
* @date 2021/1/4 上午11:20
*/
@PostMapping("/oper/crm/parameter/parameterinfo")
Result<List<CrmParameterResultDTO>> selectParamInfo(@RequestBody List<CrmParameterFormDTO> formDTOs);
}

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

@ -5,9 +5,11 @@ import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.dto.form.CustomerManagerFormDTO;
import com.epmet.dto.form.GridCountFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.dto.result.GridCountResultDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import org.springframework.stereotype.Component;
@ -57,4 +59,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result<GridCountResultDTO> getGridCount(GridCountFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getGridCount", formDTO);
}
@Override
public Result<List<CrmParameterResultDTO>> selectParamInfo(List<CrmParameterFormDTO> formDTOs) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "selectParamInfo", formDTOs);
}
}

42
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerParameterController.java

@ -0,0 +1,42 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.form.ParameterFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.service.CustomerParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author zxc
* @DateTime 2021/1/4 上午10:51
*/
@RestController
@RequestMapping("parameter")
public class CustomerParameterController {
@Autowired
private CustomerParameterService parameterService;
/**
* @Description 查询客户配置信息
* @Param formDTO
* @author zxc
* @date 2021/1/4 上午11:20
*/
@PostMapping("parameterinfo")
public Result<List<CrmParameterResultDTO>> selectParamInfo(@RequestBody List<CrmParameterFormDTO> formDTOs){
formDTOs.forEach(formDTO -> {
ValidatorUtils.validateEntity(formDTO, CrmParameterFormDTO.CrmParameterForm.class);
});
return new Result<List<CrmParameterResultDTO>>().ok(parameterService.selectParamInfo(formDTOs));
}
}

27
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerParameterDao.java

@ -0,0 +1,27 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.entity.CustomerParameterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author zxc
* @DateTime 2021/1/4 上午11:01
*/
@Mapper
public interface CustomerParameterDao extends BaseDao<CustomerParameterEntity> {
/**
* @Description 查询客户的配置信息
* @Param customerIds
* @author zxc
* @date 2021/1/4 上午11:07
*/
List<CrmParameterResultDTO> selectParamInfo(@Param("formDTOS")List<CrmParameterFormDTO> formDTOS);
}

44
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerParameterEntity.java

@ -0,0 +1,44 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @Author zxc
* @DateTime 2021/1/4 上午11:03
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("customer_project_parameter")
public class CustomerParameterEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 参数KEY值
*/
private String parameterKey;
/**
* 参数名称
*/
private String parameterName;
/**
* 参数VALUE值
*/
private String parameterValue;
/**
* 说明
*/
private String description;
}

22
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerParameterService.java

@ -0,0 +1,22 @@
package com.epmet.service;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import java.util.List;
/**
* @Author zxc
* @DateTime 2021/1/4 上午10:52
*/
public interface CustomerParameterService {
/**
* @Description 查询客户配置信息
* @Param formDTO
* @author zxc
* @date 2021/1/4 上午11:20
*/
List<CrmParameterResultDTO> selectParamInfo(List<CrmParameterFormDTO> formDTOs);
}

43
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerParameterServiceImpl.java

@ -0,0 +1,43 @@
package com.epmet.service.impl;
import com.epmet.dao.CustomerParameterDao;
import com.epmet.dto.form.CrmParameterFormDTO;
import com.epmet.dto.result.CrmParameterResultDTO;
import com.epmet.service.CustomerParameterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @Author zxc
* @DateTime 2021/1/4 上午10:53
*/
@Service
@Slf4j
public class CustomerParameterServiceImpl implements CustomerParameterService {
@Autowired
private CustomerParameterDao parameterDao;
/**
* @Description 查询客户配置信息
* @Param formDTO
* @author zxc
* @date 2021/1/4 上午11:20
*/
@Override
public List<CrmParameterResultDTO> selectParamInfo(List<CrmParameterFormDTO> formDTOs) {
if (CollectionUtils.isEmpty(formDTOs)){
return new ArrayList<>();
}
List<CrmParameterResultDTO> result = parameterDao.selectParamInfo(formDTOs);
if (CollectionUtils.isEmpty(result)){
return new ArrayList<>();
}
return result;
}
}

19
epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml

@ -0,0 +1,19 @@
<?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.CustomerParameterDao">
<!-- 查询客户的配置信息 -->
<select id="selectParamInfo" resultType="com.epmet.dto.result.CrmParameterResultDTO">
SELECT
CUSTOMER_ID,
PARAMETER_KEY,
PARAMETER_VALUE
FROM customer_parameter
WHERE DEL_FLAG = 0
AND
<foreach collection="formDTOS" item="formDTO" separator=" OR ">
CUSTOMER_ID = #{formDTO.customerId}
AND PARAMETER_KEY = #{formDTO.parameterKey}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save