Browse Source

发送消息同时发送站内信,增加info,infoId到user_message表,方便日后跳转消息详情。

dev
yinzuomei 4 years ago
parent
commit
f84506ea7b
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
  2. 3
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SendInfoFormDTO.java
  3. 4
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/UserMessageConstans.java
  4. 12
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoAttEntity.java
  5. 13
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoReplyContentEntity.java
  6. 8
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java
  7. 39
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java
  8. 5
      epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.14__create_info_table.sql
  9. 3
      epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.15__alter_user_message.sql

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java

@ -36,6 +36,7 @@ public interface NumConstant {
int THIRTY_ONE = 31;
int FORTY = 40;
int FORTY_ONE = 41;
int FORTY_NINE = 49;
int FIFTY = 50;
int FIFTY_ONE = 51;
int SIXTY = 60;

3
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SendInfoFormDTO.java

@ -28,7 +28,8 @@ public class SendInfoFormDTO implements Serializable {
/**
* 消息内容不能超过100不可为空
*/
@Length(min = 1, max = 1000, message = "消息内容不能为空", groups = AddUserShowGroup.class)
@NotBlank(message = "消息内容不能为空",groups = AddUserShowGroup.class)
@Length(min = 1, max = 1000, message = "消息内容最多输入1000字", groups = AddUserShowGroup.class)
private String content;
/**
* 单独选择的人的userId集合

4
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/UserMessageConstans.java

@ -18,4 +18,8 @@ public interface UserMessageConstans {
*/
String APP = "app";
String INFO_TITLE="您有一条新消息";
String MESSAGE_TYPE_INFO="info";
String INFO_CONTENT_TEMP="您有一条【%s】的新消息,请您查看";
}

12
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoAttEntity.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;
/**
* 消息的附件表
*
@ -73,4 +70,13 @@ public class InfoAttEntity extends BaseEpmetEntity {
*/
private Integer sort;
/**
* 文件大小
*/
private Integer attachmentSize;
/**
* 语音或视频时长
*/
private Integer duration;
}

13
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoReplyContentEntity.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;
/**
* 回复详情表
*
@ -73,4 +70,14 @@ public class InfoReplyContentEntity extends BaseEpmetEntity {
*/
private Integer sort;
/**
* 文件大小
*/
private Integer attachmentSize;
/**
* 语音或视频时长
*/
private Integer duration;
}

8
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java

@ -75,4 +75,12 @@ public class UserMessageEntity extends BaseEpmetEntity {
*/
private String referer;
/**
* 消息分类:info-上传下达消息
*/
private String messageType;
/**
* 消息对应的业务id,比如message_type=info时此列存储的是消息id,可跳转到消息详情
*/
private String targetId;
}

39
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java

@ -19,22 +19,21 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.form.FileCommonDTO;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserMessageConstans;
import com.epmet.dao.*;
import com.epmet.dto.form.OrgCommonDTO;
import com.epmet.dto.form.OrgStaffFormDTO;
import com.epmet.dto.form.RoleStaffIdFormDTO;
import com.epmet.dto.form.SendInfoFormDTO;
import com.epmet.dto.result.SendInfoResultDTO;
import com.epmet.entity.InfoAttEntity;
import com.epmet.entity.InfoEntity;
import com.epmet.entity.InfoProfileEntity;
import com.epmet.entity.InfoReceiversEntity;
import com.epmet.entity.*;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.InfoService;
@ -76,6 +75,8 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private UserMessageDao userMessageDao;
/**
* 发送消息
@ -102,7 +103,7 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
log.info("群组选择的人:"+JSON.toJSONString(groupStaffIds,true));
//3、计算接收人:
Set<String> totalReceiver=new LinkedHashSet<String>();;
Set<String> totalReceiver=new LinkedHashSet<String>();
totalReceiver.addAll(formDTO.getStaffIdList());
totalReceiver.addAll(orgStaffIds);
totalReceiver.addAll(roleStaffIds);
@ -116,6 +117,7 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
baseDao.insert(infoEntity);
//5、插入附件表
String firstAttId= StrConstant.EPMETY_STR;
if(CollectionUtils.isNotEmpty(formDTO.getAttachmentList())){
int sort=1;
for (FileCommonDTO att : formDTO.getAttachmentList()) {
InfoAttEntity infoAttEntity = new InfoAttEntity();
@ -126,12 +128,15 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
infoAttEntity.setAttachmentType(att.getType());
infoAttEntity.setAttachmentUrl(att.getUrl());
infoAttEntity.setSort(sort);
infoAttEntity.setAttachmentSize(att.getSize());
infoAttEntity.setDuration(att.getDuration());
infoAttDao.insert(infoAttEntity);
if(sort==1){
firstAttId=infoAttEntity.getId();
}
sort++;
}
}
//6、接收人
totalReceiver.forEach(staffId->{
InfoReceiversEntity infoReceiversEntity=new InfoReceiversEntity();
@ -140,17 +145,29 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
infoReceiversEntity.setStaffId(staffId);
infoReceiversEntity.setReadFlag(false);
infoReceiversDao.insert(infoReceiversEntity);
// 6.1 插入站内信:
UserMessageEntity userMessageEntity=new UserMessageEntity();
userMessageEntity.setCustomerId(formDTO.getCustomerId());
userMessageEntity.setGridId(StrConstant.STAR);
userMessageEntity.setUserId(staffId);
userMessageEntity.setApp(AppClientConstant.APP_GOV);
userMessageEntity.setTitle(UserMessageConstans.INFO_TITLE);
userMessageEntity.setMessageContent(String.format(UserMessageConstans.INFO_CONTENT_TEMP,
infoEntity.getContent().length() >= NumConstant.FIFTY ?
StringUtils.substring(infoEntity.getContent(), NumConstant.FORTY_NINE) : infoEntity.getContent()));
userMessageEntity.setReadFlag(UserMessageConstans.UNREAD);
userMessageEntity.setMessageType(UserMessageConstans.MESSAGE_TYPE_INFO);
userMessageEntity.setTargetId(infoEntity.getId());
userMessageEntity.setCreatedBy(formDTO.getUserId());
userMessageEntity.setUpdatedBy(formDTO.getUserId());
userMessageDao.insert(userMessageEntity);
});
//7、插入概要表
InfoProfileEntity infoProfileEntity=new InfoProfileEntity();
infoProfileEntity.setCustomerId(formDTO.getCustomerId());
infoProfileEntity.setInfoId(infoEntity.getId());
if(infoEntity.getContent().length()>NumConstant.ONE_HUNDRED){
infoProfileEntity.setContent(StringUtils.substring(infoEntity.getContent(),NumConstant.NINETY_NINE));
}else{
infoProfileEntity.setContent(infoEntity.getContent());
}
infoProfileEntity.setContent(infoEntity.getContent().length() >= NumConstant.FIFTY ? StringUtils.substring(infoEntity.getContent(), NumConstant.FORTY_NINE) : infoEntity.getContent());
infoProfileEntity.setPublishStaffId(formDTO.getUserId());
infoProfileEntity.setTotalReceiver(totalReceiver.size());
infoProfileEntity.setFirstAttId(firstAttId);
@ -160,8 +177,8 @@ public class InfoServiceImpl extends BaseServiceImpl<InfoDao, InfoEntity> implem
infoProfileEntity.setUpdatedTime(infoEntity.getUpdatedTime());
infoProfileDao.insert(infoProfileEntity);
//8、发送站内信 todo
SendInfoResultDTO resultDTO=new SendInfoResultDTO();
resultDTO.setInfoId(infoEntity.getId());
return resultDTO;
}

5
epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.14__create_info_table.sql

@ -22,6 +22,8 @@ CREATE TABLE `info_att` (
`ATTACHMENT_FORMAT` varchar(64) NOT NULL COMMENT '文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS)',
`ATTACHMENT_TYPE` varchar(64) NOT NULL COMMENT '附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc))',
`ATTACHMENT_URL` varchar(255) NOT NULL COMMENT '附件地址',
`ATTACHMENT_SIZE` int(11) DEFAULT NULL COMMENT '文件大小,单位b',
`DURATION` int(11) unsigned DEFAULT '0' COMMENT '语音或视频时长,秒',
`SORT` int(1) NOT NULL COMMENT '排序字段',
`DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标记 0:未删除,1:已删除',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
@ -127,6 +129,8 @@ CREATE TABLE `info_reply_content` (
`REPLY_TYPE` varchar(64) NOT NULL COMMENT '回复的类型(文本-text、图片 - image、 视频 - video、 语音 - voice、 文档 - doc))',
`CONTENT` varchar(255) NOT NULL COMMENT '如果是文本对应的是文字,如果是其他类型,对应的是url',
`SORT` int(1) NOT NULL COMMENT '排序字段',
`ATTACHMENT_SIZE` int(11) DEFAULT NULL COMMENT '文件大小,单位b',
`DURATION` int(11) unsigned DEFAULT '0' COMMENT '语音或视频时长,秒',
`DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标记 0:未删除,1:已删除',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
@ -135,4 +139,3 @@ CREATE TABLE `info_reply_content` (
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='回复详情表';

3
epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.15__alter_user_message.sql

@ -0,0 +1,3 @@
alter table user_message add COLUMN message_type VARCHAR(32) comment '消息分类:info-上传下达消息' AFTER app;
alter table user_message add COLUMN target_id VARCHAR(64) comment '消息对应的业务id,比如message_type=info时,此列存储的是消息id,可跳转到消息详情' AFTER message_type;
Loading…
Cancel
Save