diff --git a/pom.xml b/pom.xml
index bf139940..deab9edd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,6 +51,11 @@
validation-api
2.0.1.Final
+
+ org.hibernate.validator
+ hibernate-validator
+ 6.0.13.Final
+
diff --git a/xhpc-modules/pom.xml b/xhpc-modules/pom.xml
index 565e7a67..3bfb89a7 100644
--- a/xhpc-modules/pom.xml
+++ b/xhpc-modules/pom.xml
@@ -21,6 +21,7 @@
xhpc-tradebill
xhpc-message-board
xhpc-card
+ xhpc-data-big-screen
xhpc-modules
diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/MyDateUtil.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/MyDateUtil.java
new file mode 100644
index 00000000..a910ddb0
--- /dev/null
+++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/MyDateUtil.java
@@ -0,0 +1,76 @@
+package com.xhpc.common.util;
+
+import cn.hutool.core.date.DateTime;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * 进行日期处理的工具类
+ *
+ * @author WH
+ * @date 2022/1/15 15:59
+ * @since version-1.0
+ */
+@SuppressWarnings("all")
+public class MyDateUtil {
+
+ public static void main(String[] args) {
+
+ System.out.println(getCurrentDateStr());
+ }
+
+ /**
+ * 以xxxx年x月xx日 星期x的字符串格式展示当前时间
+ *
+ * @author WH
+ * @date 2022/1/15 16:15
+ * @since version-1.0
+ */
+ public static String getCurrentDateStr() {
+
+ Calendar now = Calendar.getInstance();
+ int year = now.get(Calendar.YEAR);
+ int month = now.get(Calendar.MONTH) + 1;
+ int day = now.get(Calendar.DAY_OF_MONTH);
+ String dayNames[] = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+ int dayOfWeek = now.get(Calendar.DAY_OF_WEEK) - 1;
+ if (dayOfWeek < 0) dayOfWeek = 0;
+ String week = dayNames[dayOfWeek];
+ String nowDateStr = year + "年" + month + "月" + day + "日 " + week;
+
+ return nowDateStr;
+
+ }
+
+ public static final String DATE_FORMAT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
+
+ /**
+ * 获取表示所传入的Date对象的Calendar对象
+ *
+ * @param date 要转换的Date对象
+ * @return 表示所传入的Date对象的Calendar对象
+ * @author WH
+ * @date 2022/1/15 16:11
+ * @since version-1.0
+ */
+ public static Calendar getCalendar(Date date) {
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(date);
+ return c;
+ }
+
+ /**
+ * 获取一个yyyy-MM-dd HH:mm:ss格式的当前时间字符串
+ *
+ * @author WH
+ * @date 2022/1/15 16:04
+ * @since version-1.0
+ */
+ public static String getCurrentDateStrInYyyyMmDdHhMmSsFormat() {
+
+ return DateTime.now().toString(DATE_FORMAT_DATE_TIME);
+ }
+
+}
diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/MyPagingUtil.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/MyPagingUtil.java
new file mode 100644
index 00000000..7ddeb358
--- /dev/null
+++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/MyPagingUtil.java
@@ -0,0 +1,34 @@
+package com.xhpc.common.util;
+
+/**
+ * 用于进行分页的工具类
+ *
+ * @author WH
+ * @date 2022/1/15 15:25
+ * @since version-1.0
+ */
+public class MyPagingUtil {
+
+ /**
+ * 用于计算MySQL数据库中的limit子句的startIndex值
+ *
+ * @param currentPage 当前要显示的记录的页数
+ * @param items 当前页要显示多少条记录
+ * @return 返回MySQL数据库中的limit子句的startIndex值
+ * @throws IllegalArgumentException 传入的参数不符合要求,发生此异常
+ * @author WH
+ * @date 2022/1/15 15:27
+ * @since version-1.0
+ */
+ public static int calculateStartIndex(int currentPage, int items) throws IllegalArgumentException {
+
+ if ((currentPage - 1) < 0) {
+ throw new IllegalArgumentException("当前页数最小为1");
+ }
+ if (items < 1) {
+ throw new IllegalArgumentException("当前页要显示的记录数最小为1");
+ }
+ return (currentPage - 1) * items;
+ }
+
+}
diff --git a/xhpc-modules/xhpc-data-big-screen/pom.xml b/xhpc-modules/xhpc-data-big-screen/pom.xml
new file mode 100644
index 00000000..27a0ae78
--- /dev/null
+++ b/xhpc-modules/xhpc-data-big-screen/pom.xml
@@ -0,0 +1,143 @@
+
+
+
+ xhpc-modules
+ com.ruoyi
+ 3.0.0
+
+ 4.0.0
+
+ xhpc-data-big-screen
+
+
+ 数据大屏服务
+
+
+
+ 8
+ 8
+
+
+
+
+
+
+ junit
+ junit
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ ${swagger.fox.version}
+
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+ com.ruoyi
+ ruoyi-common-datasource
+
+
+
+
+ com.ruoyi
+ ruoyi-common-datascope
+
+
+
+
+ com.ruoyi
+ ruoyi-common-log
+
+
+
+
+ com.ruoyi
+ ruoyi-common-swagger
+
+
+ com.ruoyi
+ ruoyi-common-core
+
+
+ com.squareup.okhttp3
+ okhttp
+
+
+ com.ruoyi
+ xhpc-common
+ 3.0.0
+ compile
+
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ 3.10.2
+ compile
+
+
+
+
+
+ ${project.artifactId}
+
+
+ src/main/resources
+
+
+ src/main/java
+
+ **/*.xml
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.4.0
+
+
+
+ repackage
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/XhpcDataBigScreenApplication.java b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/XhpcDataBigScreenApplication.java
new file mode 100644
index 00000000..9f25dd79
--- /dev/null
+++ b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/XhpcDataBigScreenApplication.java
@@ -0,0 +1,37 @@
+package com.xhpc;
+
+import com.xhpc.common.security.annotation.EnableCustomConfig;
+import com.xhpc.common.swagger.annotation.EnableCustomSwagger2;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+/**
+ * @author WH
+ * @date 2021/12/7 14:55
+ * @since version-1.0
+ */
+@EnableCustomConfig
+@EnableCustomSwagger2
+@EnableFeignClients
+@SpringBootApplication
+@MapperScan("com.xhpc.databigscreen.mapper")
+public class XhpcDataBigScreenApplication {
+
+ public static void main(String[] args) {
+
+ SpringApplication.run(XhpcDataBigScreenApplication.class, args);
+ System.out.println("(♥◠‿◠)ノ゙ 数据大屏模块启动成功 ლ(´ڡ`ლ)゙ \n" +
+ " .-------. ____ __ \n" +
+ " | _ _ \\ \\ \\ / / \n" +
+ " | ( ' ) | \\ _. / ' \n" +
+ " |(_ o _) / _( )_ .' \n" +
+ " | (_,_).' __ ___(_ o _)' \n" +
+ " | |\\ \\ | || |(_,_)' \n" +
+ " | | \\ `' /| `-' / \n" +
+ " | | \\ / \\ / \n" +
+ " ''-' `'-' `-..-' ");
+ }
+
+}
diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/resources/banner.txt b/xhpc-modules/xhpc-data-big-screen/src/main/resources/banner.txt
new file mode 100644
index 00000000..27cacb9c
--- /dev/null
+++ b/xhpc-modules/xhpc-data-big-screen/src/main/resources/banner.txt
@@ -0,0 +1,10 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}
+ _ __ _ _
+ (_) / _|(_)| |
+ _ __ _ _ ___ _ _ _ ______ | |_ _ | | ___
+| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \
+| | | |_| || (_) || |_| || | | | | || || __/
+|_| \__,_| \___/ \__, ||_| |_| |_||_| \___|
+ __/ |
+ |___/
\ No newline at end of file
diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-data-big-screen/src/main/resources/bootstrap.yml
new file mode 100644
index 00000000..767d47f1
--- /dev/null
+++ b/xhpc-modules/xhpc-data-big-screen/src/main/resources/bootstrap.yml
@@ -0,0 +1,28 @@
+# Tomcat
+server:
+ port: 9806
+
+# Spring
+spring:
+ application:
+ # 应用名称
+ name: xhpc-data-big-screen
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 127.0.0.1:8848
+ config:
+ # 配置中心地址
+ server-addr: 127.0.0.1:8848
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+logging:
+ level:
+ com.xhpc.databigscreen.mapper: debug
\ No newline at end of file
diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/resources/logback.xml b/xhpc-modules/xhpc-data-big-screen/src/main/resources/logback.xml
new file mode 100644
index 00000000..089dfd3c
--- /dev/null
+++ b/xhpc-modules/xhpc-data-big-screen/src/main/resources/logback.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+ ${log.pattern}
+
+
+
+
+
+ ${log.path}/info.log
+
+
+
+ ${log.path}/info.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ INFO
+
+ ACCEPT
+
+ DENY
+
+
+
+
+ ${log.path}/error.log
+
+
+
+ ${log.path}/error.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ ERROR
+
+ ACCEPT
+
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java
index 6d345f3e..5225ef4d 100644
--- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java
+++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java
@@ -391,9 +391,15 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
if (xhpcInvoice.getIsRead().equals(IsReadStatusConst.READED)) {
return specificInvoicedResponse;
}
- //一旦调了详情接口,就去掉该已开发票的未读状态,同时redis中的未读数量数据-1
+ //一旦调了详情接口,就去掉该已开发票的未读状态,同时再次查询用户未读的数量,并将其设置到redis当中
xhpcInvoiceMapper.updateByInvoiceId(invoiceId);
- reduceNoReadInvoiceCount(xhpcInvoice);
+ Long notReadCount = xhpcInvoiceMapper.findNotReadCount(xhpcInvoice.getCreatorId(), xhpcInvoice.getCreatorType());
+ String redisKey = generateRedisKey(xhpcInvoice);
+ if (notReadCount == 0) {
+ redisService.deleteObject(redisKey);
+ } else {
+ redisService.setCacheObject(redisKey, notReadCount);
+ }
return specificInvoicedResponse;
}
diff --git a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/controller/XhpcMessageBoardController.java b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/controller/XhpcMessageBoardController.java
index d22962d2..ab141e6d 100644
--- a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/controller/XhpcMessageBoardController.java
+++ b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/controller/XhpcMessageBoardController.java
@@ -1,11 +1,10 @@
package com.xhpc.board.controller;
-import com.xhpc.board.domain.PlatformSendMessageToUserRequest;
-import com.xhpc.board.domain.QueryUserListRequest;
-import com.xhpc.board.domain.QueryUserListResponse;
+import com.xhpc.board.domain.*;
import com.xhpc.board.service.XhpcMessageBoardService;
import com.xhpc.common.core.web.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -48,7 +47,7 @@ public class XhpcMessageBoardController {
* @since version-1.0
*/
@GetMapping("/user/list")
- public AjaxResult queryUserList(QueryUserListRequest param) {
+ public AjaxResult queryUserList(@Validated QueryUserListRequest param) throws Exception {
QueryUserListResponse queryUserListResponse = xhpcMessageBoardService.queryUserList(param);
@@ -56,4 +55,20 @@ public class XhpcMessageBoardController {
}
+ /**
+ * 平台查询指定用户消息
+ *
+ * @author WH
+ * @date 2022/1/15 18:47
+ * @since version-1.0
+ */
+ @GetMapping("/user/message")
+ public AjaxResult platformQueryMessage(UserQueryCondition userQueryCondition) throws Exception {
+
+ QueryUserMassageResponse queryUserMassageResponse = xhpcMessageBoardService.platformQueryMessage(userQueryCondition);
+
+ return AjaxResult.success(queryUserMassageResponse);
+
+ }
+
}
diff --git a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/domain/QueryUserListRequest.java b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/domain/QueryUserListRequest.java
index 2e250e6f..0a54adb1 100644
--- a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/domain/QueryUserListRequest.java
+++ b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/domain/QueryUserListRequest.java
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
+import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@@ -32,29 +33,28 @@ public class QueryUserListRequest {
* currentPage
*/
@JsonProperty("currentPage")
- @NotNull(message = "currentPage的参数名不正确或者currentPage的值为空,检查传入参数")
- @NotBlank(message = "currentPage的参数为''字符串,请检查传入参数")
+ @NotNull(message = "currentPage的参数名不正确或者currentPage的值为空,请检查传入参数")
+ @Min(value = 1, message = "分页参数最小为1")
private Integer currentPage;
/**
* items
*/
@JsonProperty("items")
- @NotNull(message = "items的参数名不正确或者items的值为空,检查传入参数")
- @NotBlank(message = "items的参数为''字符串,请检查传入参数")
+ @NotNull(message = "items的参数名不正确或者items的值为空,请检查传入参数")
+ @Min(value = 1, message = "每页至少需要显示1条数据")
private Integer items;
/**
* tenantId
*/
@JsonProperty("tenantId")
- @NotNull(message = "tenantId的参数名不正确或者tenantId的值为空,检查传入参数")
+ @NotNull(message = "tenantId的参数名不正确或者tenantId的值为空,请检查传入参数")
@NotBlank(message = "tenantId的参数为''字符串,请检查传入参数")
private String tenantId;
/**
* tenantType
*/
@JsonProperty("tenantType")
- @NotNull(message = "tenantType的参数名不正确或者tenantType的值为空,检查传入参数")
- @NotBlank(message = "tenantType的参数为''字符串,请检查传入参数")
+ @NotNull(message = "tenantType的参数名不正确或者tenantType的值为空,请检查传入参数")
private Integer tenantType;
}
diff --git a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java
index 54ae11b7..5ea339f4 100644
--- a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java
+++ b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java
@@ -1,8 +1,12 @@
package com.xhpc.board.mapper;
+import com.xhpc.board.domain.QueryUserListRequest;
import com.xhpc.board.domain.SendMessageToPlatformRequest;
+import com.xhpc.board.domain.UserQueryCondition;
import com.xhpc.board.pojo.XhpcMessageBoardReceiveUser;
+import java.util.List;
+
/**
* the mapper of the xhpc_message_board_receive_user
*
@@ -37,4 +41,36 @@ public interface XhpcMessageBoardReceiveUserMapper {
*/
void updateHaveNewInfoFiledByUserCondition(SendMessageToPlatformRequest userMessage);
+ /**
+ * 查询给平台发消息的用户列表
+ *
+ * @param param 租户查询条件
+ * @return 返回一个装着所有发送过信息的用户列表
+ * @author WH
+ * @date 2022/1/14 16:45
+ * @since version-1.0
+ */
+ List findAllBy(QueryUserListRequest param);
+
+ /**
+ * 查询给平台发消息的用户总数
+ *
+ * @param param 租户查询条件
+ * @return 给平台发消息的用户总数
+ * @author WH
+ * @date 2022/1/15 15:44
+ * @since version-1.0
+ */
+ Long totalUserNumber(QueryUserListRequest param);
+
+ /**
+ * 消除留言板对应用户的红点
+ *
+ * @param userQueryCondition 用户信息
+ * @author WH
+ * @date 2022/1/16 20:13
+ * @since version-1.0
+ */
+ void updateHaveNewInfoIsNull(UserQueryCondition userQueryCondition);
+
}
\ No newline at end of file
diff --git a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/XhpcMessageBoardService.java b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/XhpcMessageBoardService.java
index ab3f12cb..089173e7 100644
--- a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/XhpcMessageBoardService.java
+++ b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/XhpcMessageBoardService.java
@@ -36,6 +36,7 @@ public interface XhpcMessageBoardService {
*
* @param userQueryCondition 用户传入的条件
* @return 用户在数据库中发送的记录
+ *
* @author WH
* @date 2022/1/12 15:30
* @since version-1.0
@@ -59,11 +60,22 @@ public interface XhpcMessageBoardService {
*
* @param param query list condition
* @return 发了信息的用户列表
+ * @throws Exception 当出现空指针异常时,抛出此异常
* @author WH
* @date 2022/1/14 11:25
* @since version-1.0
*/
- QueryUserListResponse queryUserList(QueryUserListRequest param);
+ QueryUserListResponse queryUserList(QueryUserListRequest param) throws Exception;
+ /**
+ * 平台查询用户发送过来的信息,与用户查看它自己的信息逻辑是一致的
+ *
+ * @param userQueryCondition 要查询的用户的信息
+ * @return 返回用户与平台用户的一个月的聊天记录
+ * @author WH
+ * @date 2022/1/16 15:39
+ * @since version-1.0
+ */
+ QueryUserMassageResponse platformQueryMessage(UserQueryCondition userQueryCondition);
}
diff --git a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java
index bdbdfdaa..73047a9e 100644
--- a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java
+++ b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java
@@ -13,6 +13,7 @@ import com.xhpc.common.core.utils.bean.BeanUtils;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.DateUtil;
+import com.xhpc.common.util.MyPagingUtil;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import org.springframework.stereotype.Service;
@@ -153,18 +154,28 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
platformRequest.setTenantId(sysUser.getTenantId());
platformRequest.setTenantType(0);
messageBoardMapper.insertPlatformMessage(platformRequest);
-
+ //往Redis中放置用户未读数量
+ String userNotReadCount = "userNotReadMessageCount:" + platformRequest.getSenderType() + ":" + platformRequest.getSenderAccount() + ":" + "0:" + sysUser.getTenantId();
+ Object cacheObject1 = redisService.getCacheObject(userNotReadCount);
+ if (cacheObject1 == null) {
+ redisService.setCacheObject(userNotReadCount, 1);
+ } else {
+ Integer userNotReadNum = (Integer) cacheObject1 + 1;
+ redisService.setCacheObject(userNotReadCount, userNotReadNum);
+ }
}
/**
* 根据用户条件,查询指定的数据库中的记录
*
* @param userQueryCondition 用户传入的条件
+ * @return 用户在数据库中发送的记录
* @author WH
* @date 2022/1/12 15:30
* @since version-1.0
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public QueryUserMassageResponse queryUserMessage(UserQueryCondition userQueryCondition) {
//完善条件集合
LoginUser loginUser = tokenService.getLoginUser();
@@ -208,8 +219,9 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
Long messageId = aMonthRecords.get(index).getMessageId();
messageIdList.add(messageId);
}
- //设置查询出来的记录为已读状态
+ //设置查询出来的记录为已读状态,然后再查询,保证查询出来的是否有新信息状态被改变
messageBoardMapper.setUserReadedStatus(messageIdList);
+ aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
//封装数据
ArrayList dataDTOS = new ArrayList<>();
for (XhpcMessageBoard aMonthRecord : aMonthRecords) {
@@ -219,7 +231,6 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
dataDTOS.add(dataDTO);
}
//处理下次查询时间
- //todo 截取时间
response.setNextQueryTime(nextTimeStr);
response.setData(dataDTOS);
return response;
@@ -251,9 +262,108 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
* @since version-1.0
*/
@Override
- public QueryUserListResponse queryUserList(QueryUserListRequest param) {
+ public QueryUserListResponse queryUserList(QueryUserListRequest param) throws Exception {
+ //计算分页索引
+ int startIndex = MyPagingUtil.calculateStartIndex(param.getCurrentPage(), param.getItems());
+ param.setCurrentPage(startIndex);
+ //查询用户列表
+ SysUser receiverInfo = tokenService.getLoginUser().getSysUser();
+ if (receiverInfo == null) {
+ throw new Exception("查询不到指定的租户,receiverInfo为null,请检查传递的参数");
+ }
+ QueryUserListResponse queryUserListResponse = new QueryUserListResponse();
+ //查询出该租户拥有的所有用户列表
+ List userList = xhpcMessageBoardReceiveUserMapper.findAllBy(param);
+ if (userList.size() == 0) {
+ return queryUserListResponse;
+ }
+ List dataDtoList = new ArrayList<>();
+ for (XhpcMessageBoardReceiveUser receiveUser : userList) {
+ QueryUserListResponse.DataDTO dataDTO = new QueryUserListResponse.DataDTO();
+ BeanUtils.copyProperties(receiveUser, dataDTO);
+ dataDTO.setUserAccount(receiveUser.getSenderAccount());
+ dataDTO.setUserType(receiveUser.getSenderType());
+ dataDtoList.add(dataDTO);
+ }
+ queryUserListResponse.setData(dataDtoList);
+ //获取该租户总共有多少个用户给他发送了留言
+ Long totalUserNumber = xhpcMessageBoardReceiveUserMapper.totalUserNumber(param);
+ queryUserListResponse.setTotalItems(totalUserNumber);
+ return queryUserListResponse;
+ }
- return null;
+ /**
+ * 平台查询用户发送过来的信息,与用户查看它自己的信息的代码逻辑一致
+ *
+ * @param userQueryCondition 要查询的用户的信息
+ * @return 返回用户与平台用户的一个月的聊天记录
+ * @author WH
+ * @date 2022/1/16 15:39
+ * @since version-1.0
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public QueryUserMassageResponse platformQueryMessage(UserQueryCondition userQueryCondition) {
+ //完善条件集合
+ SysUser sysUser = tokenService.getLoginUser().getSysUser();
+ userQueryCondition.setTenantId(sysUser.getTenantId());
+ userQueryCondition.setTenantType(0);
+ String nextTimeStr = null;
+ if ("".equals(userQueryCondition.getSendMessageTime()) || userQueryCondition.getSendMessageTime() == null || "null".equals(userQueryCondition.getSendMessageTime())) {
+ userQueryCondition.setSendMessageTime(DateUtil.getYyyyMmDdHhMmSs());
+ //查询用户是否有数据,即查询该用户的所有时间记录(有时间记录表示该用户发送过信息)
+ List allTimeRecords = messageBoardMapper.selectTimeRecords(userQueryCondition);
+ QueryUserMassageResponse queryUserMassageResponse = new QueryUserMassageResponse();
+ if (allTimeRecords.size() == 0) {
+ return queryUserMassageResponse;
+ }
+ //获取最后一个时间记录,将其减去一个月,放入查询条件中
+ XhpcMessageBoard xhpcMessageBoard = allTimeRecords.get(allTimeRecords.size() - 1);
+ Date finalTime = xhpcMessageBoard.getSendMessageTime();
+ userQueryCondition.setSendMessageTime(DateUtils.parseDateToStr(finalTime));
+ Calendar finalTimeCalendar = DateUtil.getCalendar(finalTime);
+ finalTimeCalendar.add(Calendar.MONTH, -1);
+ Date nextTime = finalTimeCalendar.getTime();
+ nextTimeStr = DateUtils.parseDateToStr(nextTime);
+ } else {
+ //如果有值过来,说明有之前的记录,计算上一个月的值,作为查询条件,并返回
+ String sendMessageTimeStr = userQueryCondition.getSendMessageTime();
+ Date sendMessageTimeDate = DateUtils.parseDate(sendMessageTimeStr);
+ Calendar nextTimeCalendar = DateUtil.getCalendar(sendMessageTimeDate);
+ nextTimeCalendar.add(Calendar.MONTH, -1);
+ Date nextTime = nextTimeCalendar.getTime();
+ nextTimeStr = DateUtils.parseDateToStr(nextTime);
+ }
+ //根据用户信息中所保存的时间,与上个月时间进行区间查询
+ List aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
+ //如果没有数据,则返回空实体类对象
+ QueryUserMassageResponse response = new QueryUserMassageResponse();
+ if (aMonthRecords.size() == 0) {
+ return response;
+ }
+ List messageIdList = new ArrayList<>();
+ for (int index = 0; index <= aMonthRecords.size() - 1; index++) {
+ Long messageId = aMonthRecords.get(index).getMessageId();
+ messageIdList.add(messageId);
+ }
+ //设置查询出来的记录为已读状态,然后再查询,保证查询出来的信息状态被改变
+ messageBoardMapper.setUserReadedStatus(messageIdList);
+ aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
+ //消除后台留言板红点
+ xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoIsNull(userQueryCondition);
+ //封装数据
+ ArrayList dataDTOS = new ArrayList<>();
+ for (XhpcMessageBoard aMonthRecord : aMonthRecords) {
+ QueryUserMassageResponse.DataDTO dataDTO = new QueryUserMassageResponse.DataDTO();
+ BeanUtils.copyProperties(aMonthRecord, dataDTO);
+ dataDTO.setSendMessageTime(DateUtils.parseDateToStr(aMonthRecord.getSendMessageTime()));
+ dataDTOS.add(dataDTO);
+ }
+ //处理下次查询时间
+ //todo 截取时间
+ response.setNextQueryTime(nextTimeStr);
+ response.setData(dataDTOS);
+ return response;
}
}
diff --git a/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardMapper.xml b/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardMapper.xml
index 0f2c01bf..3becbd5a 100644
--- a/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardMapper.xml
+++ b/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardMapper.xml
@@ -131,8 +131,8 @@
insert into xhpc_message_board
- (sender_type, sender_account, send_message_time, tenant_type, tenant_id, sender)
- values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 1)
+ (sender_type, sender_account, send_message_time, tenant_type, tenant_id, have_new_info, sender)
+ values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 0, 1)
insert into xhpc_message_board
@@ -230,8 +230,8 @@
insert into xhpc_message_board
- (sender_type, sender_account, send_message_time, tenant_type, tenant_id, sender)
- values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 1)
+ (sender_type, sender_account, send_message_time, tenant_type, tenant_id, have_new_info, sender)
+ values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 0, 1)
update xhpc_message_board
diff --git a/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml b/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml
index 4a24934c..dc5b5ff2 100644
--- a/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml
+++ b/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml
@@ -87,6 +87,15 @@
AND sender_type = #{senderType}
AND del_flag IS NULL;
+
+ UPDATE xhpc_message_board_receive_user
+ SET have_new_info = null
+ WHERE tenant_type = #{tenantType}
+ AND tenant_id = #{tenantId}
+ AND sender_account = #{senderAccount}
+ AND sender_type = #{senderType}
+ AND del_flag IS NULL;
+
+
+
\ No newline at end of file