diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SysSmsConstant.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SysSmsConstant.java new file mode 100644 index 0000000000..c0655993f7 --- /dev/null +++ b/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"; + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java index 49721eb3d0..4615b2792e 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java +++ b/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 {} diff --git a/epmet-module/epmet-message/epmet-message-server/pom.xml b/epmet-module/epmet-message/epmet-message-server/pom.xml index 6a10b4724d..778985212f 100644 --- a/epmet-module/epmet-message/epmet-message-server/pom.xml +++ b/epmet-module/epmet-message/epmet-message-server/pom.xml @@ -112,6 +112,12 @@ 2.0.0 compile + + + com.epmet + oper-crm-client + 2.0.0 + diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java index 766cc279e3..17e6c855f2 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java +++ b/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 implements SysSmsService { @@ -49,6 +56,8 @@ public class SysSmsServiceImpl extends BaseServiceImpl @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; @Override public PageData page(Map params) { @@ -191,13 +200,57 @@ public class SysSmsServiceImpl extends BaseServiceImpl **/ @Override public void projectSendMsg(List 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> groupByCustomer = formDTOList.stream().collect(Collectors.groupingBy(ProjectSendMsgFormDTO::getCustomerId)); + List parameterFormDTOS = ConvertUtils.sourceToTarget(formDTOList, CrmParameterFormDTO.class); + Result> listResult = operCrmOpenFeignClient.selectParamInfo(parameterFormDTOS); + if (!listResult.success()){ + throw new RenException(SysSmsConstant.SELECT_PARAMETER_INFO_FAILURE); + } + List 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); +// }); } /** diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerParameterDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerParameterDTO.java new file mode 100644 index 0000000000..cd5f22e098 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CrmParameterFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CrmParameterFormDTO.java new file mode 100644 index 0000000000..ab31d56ae7 --- /dev/null +++ b/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; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CrmParameterResultDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CrmParameterResultDTO.java new file mode 100644 index 0000000000..d4781d6be2 --- /dev/null +++ b/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; + + /** + * 余额状态【parameterValue】true:充足,false:不足 + */ + private Boolean balanceStatus = true; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 27d5c239d4..78ee285226 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/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 getGridCount(@RequestBody GridCountFormDTO formDTO); + + /** + * @Description 查询客户配置信息 + * @Param formDTO + * @author zxc + * @date 2021/1/4 上午11:20 + */ + @PostMapping("/oper/crm/parameter/parameterinfo") + Result> selectParamInfo(@RequestBody List formDTOs); } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java index f4ad95f4ca..cebbe65f40 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java +++ b/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 getGridCount(GridCountFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getGridCount", formDTO); } + + @Override + public Result> selectParamInfo(List formDTOs) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "selectParamInfo", formDTOs); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerParameterController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerParameterController.java new file mode 100644 index 0000000000..03053106d0 --- /dev/null +++ b/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> selectParamInfo(@RequestBody List formDTOs){ + formDTOs.forEach(formDTO -> { + ValidatorUtils.validateEntity(formDTO, CrmParameterFormDTO.CrmParameterForm.class); + }); + return new Result>().ok(parameterService.selectParamInfo(formDTOs)); + } + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerParameterDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerParameterDao.java new file mode 100644 index 0000000000..2095d06646 --- /dev/null +++ b/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 { + + /** + * @Description 查询客户的配置信息 + * @Param customerIds + * @author zxc + * @date 2021/1/4 上午11:07 + */ + List selectParamInfo(@Param("formDTOS")List formDTOS); + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerParameterEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerParameterEntity.java new file mode 100644 index 0000000000..a99c99573b --- /dev/null +++ b/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; + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerParameterService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerParameterService.java new file mode 100644 index 0000000000..999ec3cc3d --- /dev/null +++ b/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 selectParamInfo(List formDTOs); + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerParameterServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerParameterServiceImpl.java new file mode 100644 index 0000000000..467e19fd77 --- /dev/null +++ b/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 selectParamInfo(List formDTOs) { + if (CollectionUtils.isEmpty(formDTOs)){ + return new ArrayList<>(); + } + List result = parameterDao.selectParamInfo(formDTOs); + if (CollectionUtils.isEmpty(result)){ + return new ArrayList<>(); + } + return result; + } +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml new file mode 100644 index 0000000000..35bf8738d1 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file