From 6471044f6ecf2f8534830cdd935f2e926c04eac8 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 23 Jul 2020 16:18:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86=E8=A7=84=E5=88=99=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/constant/StrConstant.java | 10 + epmet-gateway/pom.xml | 4 +- .../src/main/resources/bootstrap.yml | 2 + .../java/com/epmet/dto/form/EventFormDTO.java | 4 +- .../com/epmet/controller/EventController.java | 10 +- .../java/com/epmet/entity/EventEntity.java | 5 +- .../java/com/epmet/enu/SysResponseEnum.java | 6 +- .../epmet/service/impl/EventServiceImpl.java | 11 - .../db/migration/epmet_common_service.sql | 37 +- .../src/main/resources/mapper/EventDao.xml | 2 +- .../com/epmet/dto/form/PointRuleFormDTO.java | 40 +- .../com/epmet/common/enu/PointUnitEnum.java | 8 +- .../com/epmet/common/enu/SysResponseEnum.java | 1 + .../com/epmet/config/MqSubcribeConfig.java | 4 +- .../epmet/controller/BackDoorController.java | 23 +- .../com/epmet/entity/PointRuleEntity.java | 28 +- .../epmet/entity/RuleOperateLogEntity.java | 4 +- .../service/impl/PointRuleServiceImpl.java | 47 ++- .../resources/db/migration/epmet_point.sql | 6 +- .../main/resources/mapper/PointRuleDao.xml | 4 +- .../resources/mapper/RuleOperateLogDao.xml | 5 +- .../feign/OperCustomizeOpenFeignClient.java | 6 +- .../OperCustomizeOpenFeignClientFallback.java | 3 - .../CustomerFunctionController.java | 2 +- .../impl/CustomerFunctionServiceImpl.java | 357 +++++++++--------- 25 files changed, 340 insertions(+), 289 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java index a7ae559a01..ef2e916937 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java @@ -53,4 +53,14 @@ public interface StrConstant { * 反斜杠 */ String SEPARATOR = "/"; + + /** + * true + */ + String TRUE = "true"; + + /** + * true + */ + String FALSE = "false"; } diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 057ba37342..7839322d12 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -282,7 +282,7 @@ lb://epmet-heart-server - http://127.0.0.1:8112 + lb://epmet-point-server @@ -367,7 +367,7 @@ lb://epmet-heart-server - http://127.0.0.1:8112 + lb://epmet-point-server diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index c2105542bb..851ac62764 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -353,6 +353,8 @@ renren: - /resi/group/** - /resi/partymember/** - /gov/grid/** + - /heart/** + - /point/** management: endpoints: web: diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java index 2c72dd5e4b..10aadcb475 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/EventFormDTO.java @@ -77,8 +77,8 @@ public class EventFormDTO implements Serializable { /** * 事件功能分组ID 来自oper_customize.customer_function表 */ - @NotBlank(message = "事件功能分组ID不能为空",groups = {AddGroup.class}) - private String eventGroupId; + @NotBlank(message = "功能分组ID不能为空",groups = {AddGroup.class}) + private String functionId; /** * 是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值 diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java index f07730295b..a9a8108669 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java @@ -49,11 +49,11 @@ public class EventController { * "classId":"epmet_heart", * "appId":"202007161443499985fa2d397436d10356542134c8f008c48", * "appName":"党群e事通开发测试", - * "eventCode":"epmet_heart_active_send_point", - * "eventName":"活动发放积分", - * "eventDesc":"给参加活动的人发放积分", - * "eventGroupId":"1234", - * "isCommon":"1" + * "eventCode":"register_volunteer", + * "eventName":"认证志愿者", + * "eventDesc":"给注册志愿者的人发放积分", + * "functionId":"43addd0735230c01eedbb38d721076b0", + * "isCommon":"0" * } */ @PostMapping("addEvent") diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java index 391b11ad40..7db253d389 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/EventEntity.java @@ -18,13 +18,10 @@ 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; - /** * 事件表 * @@ -71,7 +68,7 @@ public class EventEntity extends BaseEpmetEntity { /** * 事件功能分组ID 来自oper_customize.customer_function表 */ - private String eventGroupId; + private String functionId; /** * 是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值 diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java index a34883da65..373689f711 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/enu/SysResponseEnum.java @@ -11,17 +11,17 @@ public enum SysResponseEnum { * * 编码样式:【CCCBBOOXX】 * 编码示例说明: - * CCC 中心编码&业务系统 (120-内容扫描服务中心服务) + * CCC 中心编码&业务系统 (103-内容扫描服务中心服务) * BB 业务类型(00-默认 ) * OO 操作类型(00-默认) * */ /*通用枚举 */ - EXCEPTION(12001,"系统异常"), + EXCEPTION(10301,"系统异常"), /*事件 业务 01*/ - EVENT_HAS_ALREADY_EXIST(120010001,"事件已存在无需重复添加"), + EVENT_HAS_ALREADY_EXIST(103010001,"事件已存在无需重复添加"), ; private Integer code; diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java index fed5a58ed3..53f892b9a5 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java @@ -18,13 +18,10 @@ package com.epmet.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.EventDao; import com.epmet.dto.form.EventFormDTO; import com.epmet.entity.EventEntity; -import com.epmet.enu.SysResponseEnum; import com.epmet.service.EventService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -41,15 +38,7 @@ public class EventServiceImpl extends BaseServiceImpl imp @Override public void addEvent(EventFormDTO formDTO) { - if (baseDao.getCountByEventCode(formDTO.getEventCode()) > 0) { - log.warn("addEvent fail,msg:{}", SysResponseEnum.EVENT_HAS_ALREADY_EXIST.getMsg()); - return; - } - EventEntity eventEntity = ConvertUtils.sourceToTarget(formDTO, EventEntity.class); - if (eventEntity == null) { - throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); - } baseDao.insert(eventEntity); } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql index bcf0b493c7..2702dde08b 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/epmet_common_service.sql @@ -418,21 +418,22 @@ INSERT INTO `calender` VALUES ('ffe45e7059c67874f88498cfcfd19b4c', 0, '20200424' SET FOREIGN_KEY_CHECKS = 1; #add by liujianjun 2020-07-16 -CREATE TABLE event( - ID VARCHAR(64) NOT NULL COMMENT '主键' , - CLASS_ID VARCHAR(32) COMMENT '消息网关事件类别ID 从消息网关获取事件类型Id' , - APP_ID VARCHAR(128) COMMENT '消息网关APP_ID' , - APP_NAME VARCHAR(32) COMMENT '消息网关APP_NAME' , - EVENT_CODE VARCHAR(32) COMMENT '事件标识 与消息网关事件tag一致' , - EVENT_NAME VARCHAR(32) COMMENT '事件名称' , - EVENT_DESC VARCHAR(64) COMMENT '事件说明' , - EVENT_GROUP_ID VARCHAR(512) COMMENT '事件功能分组ID 来自oper_customize.customer_function表' , - IS_COMMON VARCHAR(1) COMMENT '是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值' , - DEL_FLAG VARCHAR(1) COMMENT '删除标识 0-否,1-是' , - REVISION INT COMMENT '乐观锁 查询时添加版本号,新加的事件需要更新版本号' , - CREATED_BY VARCHAR(32) COMMENT '创建人' , - CREATED_TIME DATETIME COMMENT '创建时间' , - UPDATED_BY VARCHAR(32) COMMENT '更新人' , - UPDATED_TIME DATETIME COMMENT '更新时间' , - PRIMARY KEY (ID) -) COMMENT = '事件表'; +CREATE TABLE `event` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CLASS_ID` varchar(32) DEFAULT NULL COMMENT '消息网关事件类别ID 从消息网关获取事件类型Id', + `APP_ID` varchar(128) DEFAULT NULL COMMENT '消息网关APP_ID', + `APP_NAME` varchar(32) DEFAULT NULL COMMENT '消息网关APP_NAME', + `EVENT_CODE` varchar(32) DEFAULT NULL COMMENT '事件标识 与消息网关事件tag一致', + `EVENT_NAME` varchar(32) DEFAULT NULL COMMENT '事件名称', + `EVENT_DESC` varchar(64) DEFAULT NULL COMMENT '事件说明', + `FUNCTION_ID` varchar(64) DEFAULT NULL COMMENT '功能ID 来自oper_customize.customer_function表', + `IS_COMMON` varchar(1) DEFAULT NULL COMMENT '是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值', + `DEL_FLAG` varchar(1) DEFAULT NULL COMMENT '删除标识 0-否,1-是', + `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`), + UNIQUE KEY `unx_event_code` (`EVENT_CODE`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='事件表'; diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml index 9865ab0efa..e5418337ad 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/EventDao.xml @@ -11,7 +11,7 @@ - + diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java index fca065c9d6..5d3c6dabfa 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointRuleFormDTO.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import lombok.Data; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -16,33 +17,51 @@ import java.io.Serializable; @Data public class PointRuleFormDTO implements Serializable { private static final long serialVersionUID = -3228252683629912008L; + + /** + * 客户Id + */ + @NotBlank(message = "客户Id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String customerId; + /** * 积分规则Id */ @NotBlank(message = "积分规则Id不能为空", groups = UpdateGroup.class) private String ruleId; + + /** + * 功能Id + */ + @NotBlank(message = "功能Id不能为空", groups = {AddGroup.class}) + private String functionId; + + /** + * 积分规则名称 + */ + @NotBlank(message = "积分规则名称不能为空", groups = AddGroup.class) + private String ruleName; /** * 积分 */ - @NotBlank(message = "积分不能为空", groups = {AddGroup.class, UpdateGroup.class}) - private String point; + @NotNull(message = "积分不能为空", groups = {UpdateGroup.class}) + private Integer point; /** * 是否开启 */ - @NotBlank(message = "是否开启不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @NotBlank(message = "是否开启不能为空", groups = {UpdateGroup.class}) private String enabledFlag; /** - * 上限开启 + * 是否启用 */ - @NotBlank(message = "积分上限不能为空", groups = {AddGroup.class, UpdateGroup.class}) - private String upLimit; + @NotNull(message = "积分上限不能为空", groups = {UpdateGroup.class}) + private Integer upLimit; /** - * 积分规则Id + * 积分上限描述 */ - @NotBlank(message = "客户Id不能为空", groups = {AddGroup.class, UpdateGroup.class}) - private String customerId; + private String upLimitDesc; //=======系统添加时的属性====== /** @@ -58,9 +77,8 @@ public class PointRuleFormDTO implements Serializable { private String eventCode; /** - * 操作类型 加积分:add;减积分:subtract + * 操作类型 加积分:plus;减积分:minus */ - @NotBlank(message = "操作类型不能为空", groups = AddGroup.class) private String operateType; /** * 获得积分单位 次:time;分钟:minute;小时:hour diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java index ab1d97453c..eefb1d8b4d 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/PointUnitEnum.java @@ -14,12 +14,12 @@ public enum PointUnitEnum { ; private String code; - private String name; + private String desc; PointUnitEnum(String code, String name) { this.code = code; - this.name = name; + this.desc = name; } public static PointUnitEnum getEnum(String code) { @@ -36,7 +36,7 @@ public enum PointUnitEnum { return code; } - public String getName() { - return name; + public String getDesc() { + return desc; } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java index e7ff400906..5ae3c00775 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/SysResponseEnum.java @@ -24,6 +24,7 @@ public enum SysResponseEnum { /*积分规则 业务 01*/ THIRD_SERVICE_ERROR(112010001,"调用第三方接口异常"), POINT_RULE_IS_NOT_EXIST(112010002,"积分规则不存在"), + POINT_ENABLE_FLAG_PARAM_ERROR(112010003,"积分规则开启状态参数错误"), ; private Integer code; diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java index e7e1a33c7f..d8e6ceac75 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java @@ -30,8 +30,8 @@ public class MqSubcribeConfig { event.setBelongAppId("202007161443499985fa2d397436d10356542134c8f008c48"); event.setEventClass("epmet_heart"); event.setEventTag("active_send_point"); - String callbackUrl = "http://192.168.51.49/point/callback/sendPoint"; - callbackUrl = ""; + String callbackUrl = "http://192.168.1.119/point/callback/sendPoint"; + //callbackUrl = ""; event.setCallbackUrl(callbackUrl); List subscribeFormDTOList = new ArrayList<>(); subscribeFormDTOList.add(event); diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java index 9d2b01d291..5c9dc10f67 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java @@ -1,6 +1,7 @@ package com.epmet.controller; -import com.epmet.commons.tools.security.dto.TokenDto; +import com.alibaba.fastjson.JSON; +import com.epmet.common.enu.PointUnitEnum; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; @@ -28,13 +29,23 @@ public class BackDoorController { * @param formDTO * @return */ - @PostMapping(value = "sysadd") + @PostMapping(value = "addpointrule") public Result add(@RequestBody PointRuleFormDTO formDTO) { - TokenDto tokenDTO = new TokenDto(); - tokenDTO.setUserId("default"); - formDTO.setCustomerId(tokenDTO.getCustomerId()); ValidatorUtils.validateEntity(formDTO, AddGroup.class); - pointRuleService.add(tokenDTO, formDTO); + pointRuleService.add(null, formDTO); return new Result().ok(true); } + + public static void main(String[] args) { + PointRuleFormDTO formDTO = new PointRuleFormDTO(); + formDTO.setPoint(0); + formDTO.setUpLimit(0); + //微笑山东 + formDTO.setCustomerId("57a648d230bf459b18ea23fc278c3de7"); + formDTO.setRuleDesc("认证志愿者会获得积分"); + formDTO.setEventCode("register_volunteer"); + formDTO.setPointUnit(PointUnitEnum.TIME.getCode()); + System.out.println(JSON.toJSONString(formDTO)); + + } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java index c2132a4292..dff7131269 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/PointRuleEntity.java @@ -57,6 +57,11 @@ public class PointRuleEntity extends BaseEpmetEntity { */ private String eventCode; + /** + * 功能分组Id + */ + private String functionId; + /** * 操作类型 加积分:add;减积分:subtract */ @@ -93,20 +98,21 @@ public class PointRuleEntity extends BaseEpmetEntity { if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; PointRuleEntity entity = (PointRuleEntity) o; - return customerId.equals(entity.customerId) && - ruleName.equals(entity.ruleName) && - ruleDesc.equals(entity.ruleDesc) && - eventCode.equals(entity.eventCode) && - operateType.equals(entity.operateType) && - upLimit.equals(entity.upLimit) && - upLimitDesc.equals(entity.upLimitDesc) && - point.equals(entity.point) && - pointUnit.equals(entity.pointUnit) && - enabledFlag.equals(entity.enabledFlag); + return Objects.equals(customerId, entity.customerId) && + Objects.equals(ruleName, entity.ruleName) && + Objects.equals(ruleDesc, entity.ruleDesc) && + Objects.equals(eventCode, entity.eventCode) && + Objects.equals(functionId, entity.functionId) && + Objects.equals(operateType, entity.operateType) && + Objects.equals(upLimit, entity.upLimit) && + Objects.equals(upLimitDesc, entity.upLimitDesc) && + Objects.equals(point, entity.point) && + Objects.equals(pointUnit, entity.pointUnit) && + Objects.equals(enabledFlag, entity.enabledFlag); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), customerId, ruleName, ruleDesc, eventCode, operateType, upLimit, upLimitDesc, point, pointUnit, enabledFlag); + return Objects.hash(super.hashCode(), customerId, ruleName, ruleDesc, eventCode, functionId, operateType, upLimit, upLimitDesc, point, pointUnit, enabledFlag); } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java index 573a9f52da..b1bfa7c61a 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/RuleOperateLogEntity.java @@ -30,7 +30,7 @@ import lombok.EqualsAndHashCode; */ @Data @EqualsAndHashCode(callSuper=false) -@TableName("sys_operate_log") +@TableName("rule_operate_log") public class RuleOperateLogEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; @@ -58,7 +58,7 @@ public class RuleOperateLogEntity extends BaseEpmetEntity { /** * 变更前数据 JSON串 */ - private String befordData; + private String beforeData; /** * 变更后数据 JSON串 diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java index 8e40169645..a0ef4fed91 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java @@ -21,6 +21,8 @@ import com.alibaba.fastjson.JSON; import com.epmet.common.enu.PointUnitEnum; import com.epmet.common.enu.SysResponseEnum; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.Constant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.enums.CommonOperateTypeEnum; import com.epmet.commons.tools.exception.RenException; @@ -44,8 +46,10 @@ import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.PointRuleService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.ArrayList; @@ -111,7 +115,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl fun != null).collect(Collectors.toList()); return result; @@ -123,43 +127,60 @@ public class PointRuleServiceImpl extends BaseServiceImpl UPDATE point_rule diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml index e20a977e8f..0569aa74b5 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/RuleOperateLogDao.xml @@ -6,11 +6,10 @@ - - + - + diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java index 8707b1cf55..81a0e35046 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java @@ -6,6 +6,9 @@ import com.epmet.dto.form.CustomerFunctionListFormDTO; import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.feign.fallback.OperCustomizeOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -17,5 +20,6 @@ import java.util.List; */ @FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeOpenFeignClientFallback.class) public interface OperCustomizeOpenFeignClient { - Result> getOpenedFunctionList(CustomerFunctionListFormDTO formDTO); + @PostMapping(value = "/oper/customize/customerfunction/getOpenedFunctionList", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result> getOpenedFunctionList(@RequestBody CustomerFunctionListFormDTO formDTO); } diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java index d8e2fa7249..ba959f424b 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java @@ -6,9 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.CustomerFunctionListFormDTO; import com.epmet.dto.result.DefaultFunctionListResultDTO; import com.epmet.feign.OperCustomizeOpenFeignClient; -import org.springframework.http.MediaType; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.PostMapping; import java.util.List; @@ -26,7 +24,6 @@ public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFe * @return */ @Override - @PostMapping(value = "/oper/customize/customerfunction/getOpenedFunctionList", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) public Result> getOpenedFunctionList(CustomerFunctionListFormDTO formDTO){ return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "getOpenedFunctionList", formDTO); } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java index 71e165696b..45f4a7ed95 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFunctionController.java @@ -133,7 +133,7 @@ public class CustomerFunctionController { * @param formDTO * @return */ - @PostMapping("openedfunctionlist") + @PostMapping("getOpenedFunctionList") public Result> getOpenedFunctionList(@RequestBody CustomerFunctionListFormDTO formDTO) { return new Result>().ok(customerFunctionService.getOpenedFunctionList(formDTO)); } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java index dadf4257ea..8d57b09cdb 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFunctionServiceImpl.java @@ -17,7 +17,6 @@ package com.epmet.service.impl; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -63,185 +62,181 @@ import java.util.stream.Collectors; @Service public class CustomerFunctionServiceImpl extends BaseServiceImpl implements CustomerFunctionService { - @Autowired - private CustomerFunctionRedis customerFunctionRedis; - @Autowired - private FunctionDao functionDao; - @Autowired - private OperCrmFeignClient operCrmFeignClient; - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, CustomerFunctionDTO.class); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, CustomerFunctionDTO.class); - } - - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - - return wrapper; - } - - @Override - public CustomerFunctionDTO get(String id) { - CustomerFunctionEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, CustomerFunctionDTO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(CustomerFunctionDTO dto) { - CustomerFunctionEntity entity = ConvertUtils.sourceToTarget(dto, CustomerFunctionEntity.class); - insert(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(CustomerFunctionDTO dto) { - CustomerFunctionEntity entity = ConvertUtils.sourceToTarget(dto, CustomerFunctionEntity.class); - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 运营端-获取客户功能(已勾选、未勾选)详情列表 - **/ - @Override - public CustomerFunctionListResultDTO customerFunctionList(CustomerFunctionListFormDTO formDTO) { - CustomerFunctionListResultDTO resultDTO = new CustomerFunctionListResultDTO(); - //1:调用oper-crm服务。查询客户基本信息 - Result result = operCrmFeignClient.queryCustomerInfo(formDTO.getCustomerId()); - if (!result.success() || null == result.getData()) { - throw new RenException(CustomerFunctionConstant.SELECT_CUSTOMER_EXCEPTION); - } - CustomerDTO customerDTO = result.getData(); - resultDTO.setCustomerId(customerDTO.getId()); - resultDTO.setCustomerName(customerDTO.getCustomerName()); - resultDTO.setLogo(customerDTO.getLogo()); - - //2:查询所有已上架功能列表(默认、定制功能) - List funList = functionDao.selectShopFunctionList(NumConstant.ONE); - if(null==funList||funList.size() csList = baseDao.selectCustomerFunctionList(formDTO.getCustomerId()); - - //4:封装数据,客户已拥有但已下架的功能不展示 - List defaultFunctionList = new ArrayList<>(); - List customizedFunctionList = new ArrayList<>(); - funList.forEach(fun -> { - //默认功能 - if (fun.getFunctionGroup() == NumConstant.ZERO) { - DefaultFunctionListResultDTO df = new DefaultFunctionListResultDTO(); - df.setFunctionId(fun.getId()); - df.setFunctionName(fun.getFunctionName()); - csList.forEach(cs -> { - if (fun.getId().equals(cs.getFunctionId())) { - df.setFlag(true); - } - }); - defaultFunctionList.add(df); - } - //定制功能 - if (fun.getFunctionGroup() == NumConstant.ONE) { - CustomizedFunctionListResultDTO cf = new CustomizedFunctionListResultDTO(); - cf.setFunctionId(fun.getId()); - cf.setFunctionName(fun.getFunctionName()); - csList.forEach(cs -> { - if (fun.getId().equals(cs.getFunctionId())) { - cf.setFlag(true); - } - }); - customizedFunctionList.add(cf); - } - }); - resultDTO.setDefaultFunctionList(defaultFunctionList); - resultDTO.setCustomizedFunctionList(customizedFunctionList); - return resultDTO; - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 运营端-保存客户功能关系数据 - **/ - @Override - @Transactional(rollbackFor = Exception.class) - public void saveCustomerFunction(SaveCustomerFunctionFormDTO formDTO) { - //1:逻辑删除旧的客户功能关联数据 - baseDao.updateByCustomerId(formDTO.getCustomerId()); - - //2:批量新增新的客户功能关系数据 - List entityList = new ArrayList<>(); - formDTO.getDefaultFunctionList().forEach(dfId -> { - CustomerFunctionEntity entity = new CustomerFunctionEntity(); - entity.setCustomerId(formDTO.getCustomerId()); - entity.setFunctionId(dfId); - entityList.add(entity); - }); - formDTO.getCustomizedFunctionList().forEach(cfId -> { - CustomerFunctionEntity entity = new CustomerFunctionEntity(); - entity.setCustomerId(formDTO.getCustomerId()); - entity.setFunctionId(cfId); - entityList.add(entity); - }); - insertBatch(entityList); - } - - @Override - public List getOpenedFunctionList(CustomerFunctionListFormDTO formDTO) { - if (StringUtils.isBlank(formDTO.getCustomerId())){ - throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); - } - List result = new ArrayList<>(); - //查询所有已上架功能列表(默认、定制功能) - List funList = functionDao.selectFunctionList(); - if(CollectionUtils.isEmpty(funList)){ - return result; - } - //查询当前客户已拥有的功能 - List openedList = baseDao.selectCustomerFunctionList(formDTO.getCustomerId()); - if(CollectionUtils.isEmpty(openedList)){ - log.warn("getOpenedFunctionList customerId:{} have any function",formDTO.getCustomerId()); - return result; - } - Set openedFunIdSet = openedList.stream().map(CustomerFunctionDTO::getFunctionId).collect(Collectors.toSet()); - for (FunctionDTO function : funList) { - if (openedFunIdSet.contains(function.getId())) { - DefaultFunctionListResultDTO resultDTO = ConvertUtils.sourceToTarget(function, DefaultFunctionListResultDTO.class); - if (resultDTO == null) { - log.error("getOpenedFunctionList convert return null,function:{}", JSON.toJSONString(function)); - continue; - } - result.add(resultDTO); - } - } - return result; - } + @Autowired + private CustomerFunctionRedis customerFunctionRedis; + @Autowired + private FunctionDao functionDao; + @Autowired + private OperCrmFeignClient operCrmFeignClient; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CustomerFunctionDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CustomerFunctionDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public CustomerFunctionDTO get(String id) { + CustomerFunctionEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CustomerFunctionDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CustomerFunctionDTO dto) { + CustomerFunctionEntity entity = ConvertUtils.sourceToTarget(dto, CustomerFunctionEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CustomerFunctionDTO dto) { + CustomerFunctionEntity entity = ConvertUtils.sourceToTarget(dto, CustomerFunctionEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 运营端-获取客户功能(已勾选、未勾选)详情列表 + **/ + @Override + public CustomerFunctionListResultDTO customerFunctionList(CustomerFunctionListFormDTO formDTO) { + CustomerFunctionListResultDTO resultDTO = new CustomerFunctionListResultDTO(); + //1:调用oper-crm服务。查询客户基本信息 + Result result = operCrmFeignClient.queryCustomerInfo(formDTO.getCustomerId()); + if (!result.success() || null == result.getData()) { + throw new RenException(CustomerFunctionConstant.SELECT_CUSTOMER_EXCEPTION); + } + CustomerDTO customerDTO = result.getData(); + resultDTO.setCustomerId(customerDTO.getId()); + resultDTO.setCustomerName(customerDTO.getCustomerName()); + resultDTO.setLogo(customerDTO.getLogo()); + + //2:查询所有已上架功能列表(默认、定制功能) + List funList = functionDao.selectShopFunctionList(NumConstant.ONE); + if (null == funList || funList.size() < NumConstant.ONE) { + return resultDTO; + } + + //3:查询当前客户已拥有的功能 + List csList = baseDao.selectCustomerFunctionList(formDTO.getCustomerId()); + + //4:封装数据,客户已拥有但已下架的功能不展示 + List defaultFunctionList = new ArrayList<>(); + List customizedFunctionList = new ArrayList<>(); + funList.forEach(fun -> { + //默认功能 + if (fun.getFunctionGroup() == NumConstant.ZERO) { + DefaultFunctionListResultDTO df = new DefaultFunctionListResultDTO(); + df.setFunctionId(fun.getId()); + df.setFunctionName(fun.getFunctionName()); + csList.forEach(cs -> { + if (fun.getId().equals(cs.getFunctionId())) { + df.setFlag(true); + } + }); + defaultFunctionList.add(df); + } + //定制功能 + if (fun.getFunctionGroup() == NumConstant.ONE) { + CustomizedFunctionListResultDTO cf = new CustomizedFunctionListResultDTO(); + cf.setFunctionId(fun.getId()); + cf.setFunctionName(fun.getFunctionName()); + csList.forEach(cs -> { + if (fun.getId().equals(cs.getFunctionId())) { + cf.setFlag(true); + } + }); + customizedFunctionList.add(cf); + } + }); + resultDTO.setDefaultFunctionList(defaultFunctionList); + resultDTO.setCustomizedFunctionList(customizedFunctionList); + return resultDTO; + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 运营端-保存客户功能关系数据 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveCustomerFunction(SaveCustomerFunctionFormDTO formDTO) { + //1:逻辑删除旧的客户功能关联数据 + baseDao.updateByCustomerId(formDTO.getCustomerId()); + + //2:批量新增新的客户功能关系数据 + List entityList = new ArrayList<>(); + formDTO.getDefaultFunctionList().forEach(dfId -> { + CustomerFunctionEntity entity = new CustomerFunctionEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setFunctionId(dfId); + entityList.add(entity); + }); + formDTO.getCustomizedFunctionList().forEach(cfId -> { + CustomerFunctionEntity entity = new CustomerFunctionEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setFunctionId(cfId); + entityList.add(entity); + }); + insertBatch(entityList); + } + + @Override + public List getOpenedFunctionList(CustomerFunctionListFormDTO formDTO) { + if (StringUtils.isBlank(formDTO.getCustomerId())) { + throw new RenException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); + } + List result = new ArrayList<>(); + //查询所有已上架功能列表(默认、定制功能) + List funList = functionDao.selectFunctionList(); + if (CollectionUtils.isEmpty(funList)) { + return result; + } + //查询当前客户已拥有的功能 + List openedList = baseDao.selectCustomerFunctionList(formDTO.getCustomerId()); + if (CollectionUtils.isEmpty(openedList)) { + log.warn("getOpenedFunctionList customerId:{} have any function", formDTO.getCustomerId()); + return result; + } + Set openedFunIdSet = openedList.stream().map(CustomerFunctionDTO::getFunctionId).collect(Collectors.toSet()); + return funList.stream().filter(fun -> openedFunIdSet.contains(fun.getId())) + .map(fun -> { + DefaultFunctionListResultDTO resultDTO = new DefaultFunctionListResultDTO(); + resultDTO.setFunctionId(fun.getId()); + resultDTO.setFunctionName(fun.getFunctionName()); + return resultDTO; + }).collect(Collectors.toList()); + } } \ No newline at end of file