待阅功能

This commit is contained in:
fuqingji
2022-03-24 14:09:01 +08:00
parent e2ec3c64ed
commit d23e85357e
16 changed files with 806 additions and 0 deletions

View File

@ -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,""),
;
/**

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<NotificationCenterApi> {
@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();
}
};
}
}

View File

@ -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<BizProjectNotification> getNotification(@ApiParam(value = "主键id", required = true) @RequestBody BizProjectNotification notification) {
return BaseResponse.success(notificationService.getNotification(notification));
}
/**
* 新增待阅
*
* @param notification 实体
* @return 返回结果
*/
@ApiOperation("新增待阅")
@PostMapping("/addOrUpdate")
public BaseResponse<Boolean> addOrUpdate(@ApiParam(value = "实体", required = true) @RequestBody BizProjectNotification notification) {
return BaseResponse.success(notificationService.addOrUpdate(notification));
}
}

View File

@ -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<BizProjectNotificationLog> {
}

View File

@ -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<BizProjectNotification> {
}

View File

@ -0,0 +1,25 @@
<?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.chinaunicom.mall.ebtp.project.projectrecord.dao.BizProjectNotificationLogMapper">
<resultMap id="BaseResultMap"
type="com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotificationLog">
<result column="id" jdbcType="BIGINT" property="id"/>
<result column="project_id" jdbcType="VARCHAR" property="projectId"/>
<result column="notification_id" jdbcType="VARCHAR" property="notificationId"/>
<result column="notification_type" jdbcType="VARCHAR" property="notificationType"/>
<result column="send_content" jdbcType="VARCHAR" property="sendContent"/>
<result column="send_time" jdbcType="TIMESTAMP" property="sendTime"/>
<result column="revert_outcome" jdbcType="VARCHAR" property="revertOutcome"/>
<result column="revert_time" jdbcType="TIMESTAMP" property="revertTime"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
</resultMap>
<!--逻辑删除方法 此方法为代码生成器生成 不允许修改 如有特殊需求 请自行新建SQL语句-->
<update id="deleteOff" parameterType="java.lang.Long">
update biz_project_notification_log
set
delete_flag="deleted"
where ID=#{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,29 @@
<?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.chinaunicom.mall.ebtp.project.projectrecord.dao.BizProjectNotificationMapper">
<resultMap id="BaseResultMap"
type="com.chinaunicom.mall.ebtp.project.projectrecord.entity.BizProjectNotification">
<result column="id" jdbcType="BIGINT" property="id"/>
<result column="project_id" jdbcType="VARCHAR" property="projectId"/>
<result column="status" jdbcType="VARCHAR" property="status"/>
<result column="exchange" jdbcType="INTEGER" property="exchange"/>
<result column="reading_user_id" jdbcType="VARCHAR" property="readingUserId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="tenant_name" jdbcType="VARCHAR" property="tenantName"/>
<result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag"/>
<result column="last_update_time" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
</resultMap>
<!--逻辑删除方法 此方法为代码生成器生成 不允许修改 如有特殊需求 请自行新建SQL语句-->
<update id="deleteOff" parameterType="java.lang.Long">
update biz_project_notification
set
delete_flag="deleted"
where ID=#{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<BizProjectNotificationLog> {
}

View File

@ -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<BizProjectNotification> {
/**
* 查询待阅信息
*
* @param notification
* @return
*/
BizProjectNotification getNotification(BizProjectNotification notification);
/**
* 新增待阅
*
* @param po
* @return
*/
boolean addOrUpdate(BizProjectNotification notification);
}

View File

@ -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<BizProjectNotificationLogMapper, BizProjectNotificationLog> implements IBizProjectNotificationLogService {
}

View File

@ -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<BizProjectNotificationMapper, BizProjectNotification> 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());
}
}