From d23e85357e25a203165b338ae81869c27b99dbee Mon Sep 17 00:00:00 2001 From: fuqingji <51312040@qq.com> Date: Thu, 24 Mar 2022 14:09:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E9=98=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/common/ProjectExceptionEnum.java | 2 + .../project/feign/NotificationCenterApi.java | 43 +++++ .../project/feign/entity/NoticeReadingPO.java | 169 ++++++++++++++++++ .../NoticeReadingUpdateRequestBody.java | 43 +++++ .../NotificationCenterApiFallback.java | 57 ++++++ .../controller/BizNotificationController.java | 56 ++++++ .../dao/BizProjectNotificationLogMapper.java | 10 ++ .../dao/BizProjectNotificationMapper.java | 10 ++ .../BizProjectNotificationLogMapper.xml | 25 +++ .../mapper/BizProjectNotificationMapper.xml | 29 +++ .../entity/BizProjectNotification.java | 56 ++++++ .../entity/BizProjectNotificationLog.java | 84 +++++++++ .../IBizProjectNotificationLogService.java | 15 ++ .../IBizProjectNotificationService.java | 30 ++++ .../BizProjectNotificationLogServiceImpl.java | 18 ++ .../BizProjectNotificationServiceImpl.java | 159 ++++++++++++++++ 16 files changed, 806 insertions(+) create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/feign/NotificationCenterApi.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingPO.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingUpdateRequestBody.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/feign/fallback/NotificationCenterApiFallback.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/controller/BizNotificationController.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationLogMapper.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationMapper.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationLogMapper.xml create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationMapper.xml create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotification.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotificationLog.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationLogService.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationService.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationLogServiceImpl.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationServiceImpl.java diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/common/ProjectExceptionEnum.java b/src/main/java/com/chinaunicom/mall/ebtp/project/common/ProjectExceptionEnum.java index 23e0e1e..1aa4cc3 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/project/common/ProjectExceptionEnum.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/common/ProjectExceptionEnum.java @@ -185,6 +185,8 @@ public enum ProjectExceptionEnum implements BusinessExceptionAssert { FRAME_EXCEPTION_INQUIRY_RESPONSE_FORMAT_LIST_NAME_EMPTY(110086,"询价应答格式列表数据中目录名称不能为空字符并且不能超过30个字符"), FRAME_EXCEPTION_PROJECT_RECORD_NOT_BACK(110087,"该项目已建档,无法撤回"), + + FRAME_EXCEPTION_NOTIFICATION_MESSAGE(110088,""), ; /** diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/feign/NotificationCenterApi.java b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/NotificationCenterApi.java new file mode 100644 index 0000000..4c53226 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/NotificationCenterApi.java @@ -0,0 +1,43 @@ +package com.chinaunicom.mall.ebtp.project.feign; + +import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; +import com.chinaunicom.mall.ebtp.project.feign.entity.NoticeReadingPO; +import com.chinaunicom.mall.ebtp.project.feign.entity.NoticeReadingUpdateRequestBody; +import com.chinaunicom.mall.ebtp.project.feign.fallback.NotificationCenterApiFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.validation.Valid; + +/** + * 通知中心 + * + * @author f + * @date 2022/3/22 + */ +@FeignClient(value = "${mconfig.service-name-notification}", fallbackFactory = NotificationCenterApiFallback.class) +public interface NotificationCenterApi { + + /** + * 新增待阅 + * + * @param noticeReadingPO 待阅参数实体类 + * @return BaseResponse + * @author f + * @date 2022-3-23 + */ + @PostMapping("/v1/notification/sendReading") + public BaseResponse sendPending(@Valid @RequestBody NoticeReadingPO noticeReadingPO); + + /** + * 待阅更新或删除 + * + * @param noticeReadingUpdateRequestBody 待阅参数实体类 + * @return BaseResponse + * @author f + * @date 2022-3-23 + */ + @PostMapping("/v1/notification/updateReading") + public BaseResponse updateReading(@Valid @RequestBody NoticeReadingUpdateRequestBody noticeReadingUpdateRequestBody); +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingPO.java b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingPO.java new file mode 100644 index 0000000..8fafbe0 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingPO.java @@ -0,0 +1,169 @@ +package com.chinaunicom.mall.ebtp.project.feign.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 待阅PO实体类 + * @description 待阅PO实体类 + * @author: yaowang + * @date: 2022-3-8 + * @version: V1.0 + * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述] + */ +@Data +@Accessors(chain = true) +//@TableName("eshop_bpm_reading") +@ApiModel(value="EshopBpmReading对象", description="待阅表信息实体") +public class NoticeReadingPO { + + private static final long serialVersionUID = 1L; + +// @ApiModelProperty(value = "主键") +// private String id; + + @ApiModelProperty(value = "发送中心标识") + private String sendCenter; + + @ApiModelProperty(value = "发送业务模块标识") + private String sendModule; + + @ApiModelProperty(value = "待阅信息的编号") + private String readingCode; + + @ApiModelProperty(value = "待阅标题") + private String readingTitle; + +// @ApiModelProperty(value = "待阅产生时间") +// private String readingDate; + + @ApiModelProperty(value = "待阅人用户标识,门户待办为邮箱前缀;非门户待办为用户账号") + private String readingUserId; + + @ApiModelProperty(value = "待阅人名") + private String readingUserCn; + + @ApiModelProperty(value = "待阅信息URL") + private String readingUrl; + + @ApiModelProperty(value = "待阅状态 0:待阅 1:以阅") + private String readingStatus; + + @ApiModelProperty(value = "待阅等级 0.普通,1.重要,2加急") + private Integer readingLevel; + +// @ApiModelProperty(value = "省分代码") +// private String readingCityCode; + + @ApiModelProperty(value = "待阅类型 1:门户待阅 2:门户流程待阅 3:商城待阅") + private String readingType; + + @ApiModelProperty(value = "待阅信息上一步处理人邮件前缀 上一步处理人的帐号,若为发起待办则填发起人的账号") + private String readingSourceUserId; + + @ApiModelProperty(value = "上一步处理人的姓名") + private String readingSourceUserCn; + + @ApiModelProperty(value = "a:新增待阅 u:更新待阅 t:更新待阅标题 d:删除待阅") + private String operatorType; +// +// @ApiModelProperty(value = "省ou") +// @Length(message = "省ou不能超过{max}个字符", max = 20) +// private String provinceOu; +// +// @ApiModelProperty(value = "省ou名") +// @Length(message = "省ou名不能超过{max}个字符", max = 100) +// private String provinceOuName; +// +// @ApiModelProperty(value = "市ou") +// @Length(message = "市ou不能超过{max}个字符", max = 20) +// private String cityOu; +// +// @ApiModelProperty(value = "市ou名") +//// @Length(message = "市ou名不能超过{max}个字符", max = 100) +// private String cityOuName; +// +// @ApiModelProperty(value = "待办所属系统简称") +// private String readingNote; +// +// @ApiModelProperty(value = "待阅接口入参信息") +// private String inputMessage; +// +// @ApiModelProperty(value = "待阅接口返回结果") +// private String returnResult; +// +// @ApiModelProperty(value = "创建人uid") +// private String createBy; +// +// @ApiModelProperty(value = "更新人uid") +// private String updateBy; +// +// @ApiModelProperty(value = "表插入生成时间") +// private LocalDateTime createDate; +// +// @ApiModelProperty(value = "待办生成时间") +// private LocalDateTime launchDate; +// +// @ApiModelProperty(value = "更新时间") +// private LocalDateTime updateDate; +// +// @ApiModelProperty(value = "租户标识") +// private String tenantId; +// +// @ApiModelProperty(value = "逻辑删除,normal表示正常(默认),deleted表示删除") +// private String deleteFlag; +// +// @ApiModelProperty(value = "乐观锁") +// private Integer versions; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved1; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved2; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved3; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved4; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved5; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved6; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved7; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved8; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved9; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved10; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved11; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved12; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved13; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved14; +// +// @ApiModelProperty(value = "云门户预留字段") +// private String dbReserved15; +// +// @ApiModelProperty(value = "最后一次更新时间") +// private LocalDateTime lastUpdateTime; + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingUpdateRequestBody.java b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingUpdateRequestBody.java new file mode 100644 index 0000000..d99f576 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/entity/NoticeReadingUpdateRequestBody.java @@ -0,0 +1,43 @@ +package com.chinaunicom.mall.ebtp.project.feign.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @description 待阅跟新或删除实体类 + * @author: yaowang + * @date: 2022-3-8 + * @version: V1.0 + * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述] + */ +@Data +@Accessors(chain = true) +public class NoticeReadingUpdateRequestBody { + + @ApiModelProperty(value = "待阅信息的编号") + private String readingCode; + + @ApiModelProperty(value = "待阅状态 0:待阅 1:已阅 d:待阅删除") + private String readingStatus; + +// @ApiModelProperty(value = "待阅状态更新时间") +// @Length(message = "待阅更新时间不能超过{max}个字符", max = 20) +// private String lastUpdateDate; + + @ApiModelProperty(value = "待办类型:1 门户待阅 2 门户流程待办 3 商城待阅") + private String readingType; +// +// @ApiModelProperty(value = "待阅产生时间") +// private String readingDate; +// +// @ApiModelProperty(value = "待阅接口入参信息") +// private String inputMessage; +// +// @ApiModelProperty(value = "待阅接口返回结果:100为成功") +// private String returnCode; +// +// @ApiModelProperty(value = "待阅接口返回信息") +// private String returnMessage; + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/feign/fallback/NotificationCenterApiFallback.java b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/fallback/NotificationCenterApiFallback.java new file mode 100644 index 0000000..73dc560 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/feign/fallback/NotificationCenterApiFallback.java @@ -0,0 +1,57 @@ +package com.chinaunicom.mall.ebtp.project.feign.fallback; + + +import cn.hutool.core.exceptions.ExceptionUtil; +import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; +import com.chinaunicom.mall.ebtp.project.feign.NotificationCenterApi; +import com.chinaunicom.mall.ebtp.project.feign.entity.NoticeReadingPO; +import com.chinaunicom.mall.ebtp.project.feign.entity.NoticeReadingUpdateRequestBody; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + + +/** + * @author fu + * @version 1.0 + * @date 2022-3-23 + */ +@Slf4j +@Component +public class NotificationCenterApiFallback implements FallbackFactory { + + + @Override + public NotificationCenterApi create(Throwable throwable) { + log.error(ExceptionUtil.stacktraceToString(throwable)); + return new NotificationCenterApi() { + /** + * 新增待阅 + * + * @param noticeReadingPO 待阅参数实体类 + * @return BaseResponse + * @author yaowang + * @date 2022-3-8 + * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述] + */ + @Override + public BaseResponse sendPending(NoticeReadingPO noticeReadingPO) { + return BaseResponse.fail(); + } + + /** + * 待阅更新或删除 + * + * @param noticeReadingUpdateRequestBody 待阅参数实体类 + * @return BaseResponse + * @author yaowang + * @date 2022-3-8 + * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述] + */ + @Override + public BaseResponse updateReading(NoticeReadingUpdateRequestBody noticeReadingUpdateRequestBody) { + return BaseResponse.fail(); + } + }; + } +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/controller/BizNotificationController.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/controller/BizNotificationController.java new file mode 100644 index 0000000..929de52 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/controller/BizNotificationController.java @@ -0,0 +1,56 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.controller; + + +import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotification; +import com.chinaunicom.mall.ebtp.project.projectrecord.service.IBizProjectNotificationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * 通知中心controller + * + * @author f + * @date 2022/3/23 + */ +@RestController +@Api(tags = "通知中心") +@RequestMapping("/v1/notification/") +public class BizNotificationController { + + @Resource + private IBizProjectNotificationService notificationService; + + + /** + * 查询待阅信息 + * + * @param notification 实体 + * @return 返回结果 + */ + @ApiOperation("查询待阅信息") + @PostMapping("/getReading") + public BaseResponse getNotification(@ApiParam(value = "主键id", required = true) @RequestBody BizProjectNotification notification) { + + return BaseResponse.success(notificationService.getNotification(notification)); + } + + + /** + * 新增待阅 + * + * @param notification 实体 + * @return 返回结果 + */ + @ApiOperation("新增待阅") + @PostMapping("/addOrUpdate") + public BaseResponse addOrUpdate(@ApiParam(value = "实体", required = true) @RequestBody BizProjectNotification notification) { + + return BaseResponse.success(notificationService.addOrUpdate(notification)); + } + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationLogMapper.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationLogMapper.java new file mode 100644 index 0000000..8f17959 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationLogMapper.java @@ -0,0 +1,10 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.dao; + + +import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotificationLog; + +public interface BizProjectNotificationLogMapper extends IBaseMapper { + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationMapper.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationMapper.java new file mode 100644 index 0000000..1d97cd4 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/BizProjectNotificationMapper.java @@ -0,0 +1,10 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.dao; + + +import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotification; + +public interface BizProjectNotificationMapper extends IBaseMapper { + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationLogMapper.xml b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationLogMapper.xml new file mode 100644 index 0000000..e6aa955 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationLogMapper.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + update biz_project_notification_log + set + delete_flag="deleted" + where ID=#{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationMapper.xml b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationMapper.xml new file mode 100644 index 0000000..9901871 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/dao/mapper/BizProjectNotificationMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + update biz_project_notification + set + delete_flag="deleted" + where ID=#{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotification.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotification.java new file mode 100644 index 0000000..4ce65be --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotification.java @@ -0,0 +1,56 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 实体类 BizProjectNotification + * + * @auto.generated + */ +@Data +@Accessors(chain = true) +@ApiModel +@TableName(value = "biz_project_notification", autoResultMap = true) +public class BizProjectNotification extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private String id; + + /** + * 项目id + */ + @ApiModelProperty(value = "项目id") + private String projectId; + + /** + * 状态0:待阅 1:已阅 d:删除 + */ + @ApiModelProperty(value = "状态0:待阅 1:已阅 d:删除") + private String status; + + /** + * 0:不需要;1:需要 + */ + @ApiModelProperty(value = "0:不需要;1:需要") + private Boolean exchange; + + /** + * 跳转的用户id + */ + @ApiModelProperty(value = "跳转的用户id") + private String readingUserId; + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotificationLog.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotificationLog.java new file mode 100644 index 0000000..6d2357c --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/entity/BizProjectNotificationLog.java @@ -0,0 +1,84 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.chinaunicom.mall.ebtp.common.config.CustomLocalDateTimeTypeHandler; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; + +/** + * 实体类 BizProjectNotificationLog + * + * @auto.generated + */ +@Data +@Accessors(chain = true) +@ApiModel +@TableName(value = "biz_project_notification_log", autoResultMap = true) +public class BizProjectNotificationLog implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + @ApiModelProperty(value = "") + private String id; + + /** + * 项目id + */ + @ApiModelProperty(value = "项目id") + private String projectId; + + /** + * 待阅id + */ + @ApiModelProperty(value = "待阅id") + private String notificationId; + + /** + * 1:新增;2:修改 + */ + @ApiModelProperty(value = "1:新增;2:修改") + private String notificationType; + + /** + * 发送内容 + */ + @ApiModelProperty(value = "发送内容") + private String sendContent; + + /** + * 发送时间 + */ + @ApiModelProperty(value = "发送时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(typeHandler = CustomLocalDateTimeTypeHandler.class) + private java.time.LocalDateTime sendTime; + + /** + * 返回内容 + */ + @ApiModelProperty(value = "返回内容") + private String revertOutcome; + + /** + * 返回时间 + */ + @ApiModelProperty(value = "返回时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(typeHandler = CustomLocalDateTimeTypeHandler.class) + private java.time.LocalDateTime revertTime; + + @ApiModelProperty("创建者") + private String createBy; +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationLogService.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationLogService.java new file mode 100644 index 0000000..7e38270 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationLogService.java @@ -0,0 +1,15 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.service; + + +import com.chinaunicom.mall.ebtp.common.base.service.IBaseService; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotificationLog; + +/** + * 对数据表 biz_project_notification_log 操作的 service + * + * @author Auto create + */ +public interface IBizProjectNotificationLogService extends IBaseService { + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationService.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationService.java new file mode 100644 index 0000000..42e635f --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/IBizProjectNotificationService.java @@ -0,0 +1,30 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.service; + + +import com.chinaunicom.mall.ebtp.common.base.service.IBaseService; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotification; + +/** + * 对数据表 biz_project_notification 操作的 service + * + * @author Auto create + */ +public interface IBizProjectNotificationService extends IBaseService { + + /** + * 查询待阅信息 + * + * @param notification + * @return + */ + BizProjectNotification getNotification(BizProjectNotification notification); + + /** + * 新增待阅 + * + * @param po + * @return + */ + boolean addOrUpdate(BizProjectNotification notification); + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationLogServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationLogServiceImpl.java new file mode 100644 index 0000000..5a8b246 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationLogServiceImpl.java @@ -0,0 +1,18 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.service.impl; + + +import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl; +import com.chinaunicom.mall.ebtp.project.projectrecord.dao.BizProjectNotificationLogMapper; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotificationLog; +import com.chinaunicom.mall.ebtp.project.projectrecord.service.IBizProjectNotificationLogService; +import org.springframework.stereotype.Service; + +/** + * 对数据表 biz_project_notification_log 操作的 serviceImpl + * + * @author f + */ +@Service +public class BizProjectNotificationLogServiceImpl extends BaseServiceImpl implements IBizProjectNotificationLogService { + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationServiceImpl.java new file mode 100644 index 0000000..d0c699e --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/project/projectrecord/service/impl/BizProjectNotificationServiceImpl.java @@ -0,0 +1,159 @@ +package com.chinaunicom.mall.ebtp.project.projectrecord.service.impl; + + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser; +import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; +import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService; +import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl; +import com.chinaunicom.mall.ebtp.common.util.JsonUtils; +import com.chinaunicom.mall.ebtp.common.util.PropertyUtils; +import com.chinaunicom.mall.ebtp.project.common.ProjectExceptionEnum; +import com.chinaunicom.mall.ebtp.project.feign.NotificationCenterApi; +import com.chinaunicom.mall.ebtp.project.feign.entity.NoticeReadingPO; +import com.chinaunicom.mall.ebtp.project.feign.entity.NoticeReadingUpdateRequestBody; +import com.chinaunicom.mall.ebtp.project.projectrecord.dao.BizProjectNotificationMapper; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotification; +import com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotificationLog; +import com.chinaunicom.mall.ebtp.project.projectrecord.service.IBizProjectNotificationLogService; +import com.chinaunicom.mall.ebtp.project.projectrecord.service.IBizProjectNotificationService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.Objects; +import java.util.regex.Pattern; + +/** + * 对数据表 biz_project_notification 操作的 serviceImpl + * + * @author Auto create + */ +@Service +@Slf4j +public class BizProjectNotificationServiceImpl extends BaseServiceImpl implements IBizProjectNotificationService { + + @Autowired + private ProjectRecordServiceImpl projectRecordService; + @Autowired + private IBizProjectNotificationLogService notificationLogService; + + @Autowired + private IBaseCacheUserService userService; + + @Autowired + private NotificationCenterApi notificationCenterApi; + + @Value("${client.notification-url}") + private String readingUrl; + + private static final String SEND_CENTER = "ebtp"; + private static final String SEND_MODULE = "biz-service-ebtp-project"; + + /** + * 查询待阅信息 + * + * @param notification + * @return + */ + @Override + public BizProjectNotification getNotification(BizProjectNotification notification) { + if (Objects.isNull(notification.getId())) { + notification.setReadingUserId(userService.getCacheUser().getUserId()); + } + return this.list(Wrappers.query(notification)).stream().findAny().orElse(null); + } + + @Override + public boolean addOrUpdate(BizProjectNotification notification) { + if (Objects.isNull(notification.getId())) { + BaseCacheUser user = userService.getCacheUser(); + + //新增 + notification.setId(PropertyUtils.getSnowflakeId()) + .setStatus("0") + .setExchange(reg(user.getUserId())) + .setReadingUserId(user.getUserId()); + insertNotification(notification); + + save(notification); + } else { + //修改状态 + updateNotification(notification); + + updateById(notification); + } + return true; + } + + private static final String REG_PATTEN = "^.+_\\d*$"; + + private boolean reg(String str) { + return Pattern.matches(REG_PATTEN, str); + } + + private void insertNotification(BizProjectNotification notification) { + BaseCacheUser user = userService.getCacheUser(); + NoticeReadingPO po = new NoticeReadingPO(); + po.setSendCenter(SEND_CENTER) + .setSendModule(SEND_MODULE) + .setReadingCode(notification.getId()) + .setReadingTitle(projectRecordService.getById(notification.getProjectId()).getProjectName()) //项目名称 + .setReadingUserId(user.getUserId()) + .setReadingUserCn(user.getFullName()) + .setReadingUrl(readingUrl.replace("{{id}}", notification.getId())) //跳转路径 + .setReadingStatus("0") //待阅 + .setReadingLevel(0) + .setReadingSourceUserId(user.getUserId()) + .setReadingSourceUserCn(user.getFullName()) + .setReadingType("3") + .setOperatorType("a"); + //日志 + BizProjectNotificationLog notificationLog = new BizProjectNotificationLog(); + notificationLog.setId(PropertyUtils.getSnowflakeId()) + .setProjectId(notification.getProjectId()) + .setNotificationId(notification.getId()) + .setNotificationType("1") + .setSendContent(JsonUtils.objectToJson(po)) + .setSendTime(LocalDateTime.now()); + //发送 + BaseResponse response = notificationCenterApi.sendPending(po); + + notificationLog.setRevertTime(LocalDateTime.now()) + .setRevertOutcome(JsonUtils.objectToJson(response)); + log.info("新增待阅,项目id:{}, 详细信息:{}", notification.getProjectId(), JsonUtils.objectToJson(notificationLog)); + + notificationLogService.save(notificationLog); + + ProjectExceptionEnum.FRAME_EXCEPTION_NOTIFICATION_MESSAGE.customValidName(response.getMessage(), !response.isSuccess()); + } + + private void updateNotification(BizProjectNotification notification) { + BaseCacheUser user = userService.getCacheUser(); + NoticeReadingUpdateRequestBody body = new NoticeReadingUpdateRequestBody(); + body.setReadingCode(notification.getId()) + .setReadingStatus(notification.getStatus()) + .setReadingType("3"); + //日志 + BizProjectNotificationLog notificationLog = new BizProjectNotificationLog(); + notificationLog.setId(PropertyUtils.getSnowflakeId()) + .setProjectId(notification.getProjectId()) + .setNotificationId(notification.getId()) + .setNotificationType("2") + .setSendContent(JsonUtils.objectToJson(body)) + .setSendTime(LocalDateTime.now()) + .setCreateBy(user.getUserId()); + //发送 + BaseResponse response = notificationCenterApi.updateReading(body); + + notificationLog.setRevertTime(LocalDateTime.now()) + .setRevertOutcome(JsonUtils.objectToJson(response)); + log.info("修改待阅,项目id:{}, 详细信息:{}", notification.getProjectId(), JsonUtils.objectToJson(notificationLog)); + + notificationLogService.save(notificationLog); + + ProjectExceptionEnum.FRAME_EXCEPTION_NOTIFICATION_MESSAGE.customValidName(response.getMessage(), !response.isSuccess()); + } +}