diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java index 28a82836b1..1281b269f4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java +++ b/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; diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SendInfoFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SendInfoFormDTO.java index 7fdbee71b8..6090d7f4e6 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SendInfoFormDTO.java +++ b/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集合 diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/UserMessageConstans.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/UserMessageConstans.java index 455169adf9..7c20b668a6 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/UserMessageConstans.java +++ b/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】的新消息,请您查看"; } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoAttEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoAttEntity.java index d458461500..01e385aa50 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoAttEntity.java +++ b/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; + } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoReplyContentEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoReplyContentEntity.java index e83345449a..04e9160c71 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/InfoReplyContentEntity.java +++ b/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; + } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java index dcdd460cde..5d908e98c5 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java +++ b/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; } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java index 7fc355d483..c3b60aae1c 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/InfoServiceImpl.java +++ b/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 implem private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Autowired private GovOrgOpenFeignClient govOrgOpenFeignClient; + @Autowired + private UserMessageDao userMessageDao; /** * 发送消息 @@ -102,7 +103,7 @@ public class InfoServiceImpl extends BaseServiceImpl implem log.info("群组选择的人:"+JSON.toJSONString(groupStaffIds,true)); //3、计算接收人: - Set totalReceiver=new LinkedHashSet();; + Set totalReceiver=new LinkedHashSet(); totalReceiver.addAll(formDTO.getStaffIdList()); totalReceiver.addAll(orgStaffIds); totalReceiver.addAll(roleStaffIds); @@ -116,21 +117,25 @@ public class InfoServiceImpl extends BaseServiceImpl implem baseDao.insert(infoEntity); //5、插入附件表 String firstAttId= StrConstant.EPMETY_STR; - int sort=1; - for (FileCommonDTO att : formDTO.getAttachmentList()) { - InfoAttEntity infoAttEntity = new InfoAttEntity(); - infoAttEntity.setInfoId(infoEntity.getId()); - infoAttEntity.setCustomerId(formDTO.getCustomerId()); - infoAttEntity.setAttachmentFormat(att.getFormat()); - infoAttEntity.setAttachmentName(att.getName()); - infoAttEntity.setAttachmentType(att.getType()); - infoAttEntity.setAttachmentUrl(att.getUrl()); - infoAttEntity.setSort(sort); - infoAttDao.insert(infoAttEntity); - if(sort==1){ - firstAttId=infoAttEntity.getId(); + if(CollectionUtils.isNotEmpty(formDTO.getAttachmentList())){ + int sort=1; + for (FileCommonDTO att : formDTO.getAttachmentList()) { + InfoAttEntity infoAttEntity = new InfoAttEntity(); + infoAttEntity.setInfoId(infoEntity.getId()); + infoAttEntity.setCustomerId(formDTO.getCustomerId()); + infoAttEntity.setAttachmentFormat(att.getFormat()); + infoAttEntity.setAttachmentName(att.getName()); + 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++; } - sort++; } //6、接收人 totalReceiver.forEach(staffId->{ @@ -140,17 +145,29 @@ public class InfoServiceImpl extends BaseServiceImpl 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 implem infoProfileEntity.setUpdatedTime(infoEntity.getUpdatedTime()); infoProfileDao.insert(infoProfileEntity); - //8、发送站内信 todo SendInfoResultDTO resultDTO=new SendInfoResultDTO(); + resultDTO.setInfoId(infoEntity.getId()); return resultDTO; } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.14__create_info_table.sql b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.14__create_info_table.sql index 6a53aa8b54..820e8ca67c 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.14__create_info_table.sql +++ b/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='回复详情表'; - diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.15__alter_user_message.sql b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.15__alter_user_message.sql new file mode 100644 index 0000000000..c4bfcc7743 --- /dev/null +++ b/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; \ No newline at end of file