Commit ac75f19fe271ad255707c12841b0fc0635497630
Merge remote-tracking branch 'origin/develop' into develop
Showing
16 changed files
with
272 additions
and
125 deletions
ant-design-vue-jeecg/package.json
ant-design-vue-jeecg/src/main.js
... | ... | @@ -25,6 +25,10 @@ import Print from 'vue-print-nb-jeecg' |
25 | 25 | import preview from 'vue-photo-preview' |
26 | 26 | import 'vue-photo-preview/dist/skin.css' |
27 | 27 | import SSO from '@/cas/sso.js' |
28 | + | |
29 | +import moment from "moment" | |
30 | +Vue.prototype.$moment = moment | |
31 | + | |
28 | 32 | import { |
29 | 33 | ACCESS_TOKEN, |
30 | 34 | DEFAULT_COLOR, |
... | ... |
ant-design-vue-jeecg/src/views/system/monitor/ApiLogList.vue
... | ... | @@ -23,47 +23,50 @@ |
23 | 23 | <j-input placeholder="请输入响应方名称" v-model="queryParam.responseBy"></j-input> |
24 | 24 | </a-form-item> |
25 | 25 | </a-col> |
26 | - <template v-if="toggleSearchStatus"> | |
27 | - <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
28 | - <a-form-item label="请求地址"> | |
29 | - <j-input placeholder="请输入请求地址" v-model="queryParam.url"></j-input> | |
30 | - </a-form-item> | |
31 | - </a-col> | |
32 | - <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
33 | - <a-form-item label="请求内容"> | |
34 | - <j-input placeholder="请输入请求内容" v-model="queryParam.requestBody"></j-input> | |
35 | - </a-form-item> | |
36 | - </a-col> | |
37 | - <a-col :xl="12" :lg="14" :md="16" :sm="24"> | |
38 | - <a-form-item label="请求时间"> | |
39 | - <j-date | |
40 | - :show-time="true" | |
41 | - date-format="YYYY-MM-DD HH:mm:ss" | |
42 | - placeholder="请选择开始时间" | |
43 | - class="query-group-cust" | |
44 | - v-model="queryParam.requestTime_begin" | |
45 | - /> | |
46 | - <span class="query-group-split-cust"></span> | |
47 | - <j-date | |
48 | - :show-time="true" | |
49 | - date-format="YYYY-MM-DD HH:mm:ss" | |
50 | - placeholder="请选择结束时间" | |
51 | - class="query-group-cust" | |
52 | - v-model="queryParam.requestTime_end" | |
53 | - /> | |
54 | - </a-form-item> | |
55 | - </a-col> | |
56 | - <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
57 | - <a-form-item label="业务响应码"> | |
58 | - <a-input placeholder="请输入业务响应码" v-model="queryParam.retCode"></a-input> | |
59 | - </a-form-item> | |
60 | - </a-col> | |
61 | - <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
62 | - <a-form-item label="响应耗时(毫秒)"> | |
63 | - <a-input placeholder="请输入大于响应耗时" v-model="queryParam.duration_begin"></a-input> | |
64 | - </a-form-item> | |
65 | - </a-col> | |
66 | - </template> | |
26 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
27 | + <a-form-item label="请求地址"> | |
28 | + <j-input placeholder="请输入请求地址" v-model="queryParam.url"></j-input> | |
29 | + </a-form-item> | |
30 | + </a-col> | |
31 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
32 | + <a-form-item label="请求内容"> | |
33 | + <j-input placeholder="请输入请求内容" v-model="queryParam.requestBody"></j-input> | |
34 | + </a-form-item> | |
35 | + </a-col> | |
36 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
37 | + <a-form-item label="响应内容"> | |
38 | + <j-input placeholder="请输入请求内容" v-model="queryParam.responseBody"></j-input> | |
39 | + </a-form-item> | |
40 | + </a-col> | |
41 | + <a-col :xl="12" :lg="14" :md="16" :sm="24"> | |
42 | + <a-form-item label="请求时间"> | |
43 | + <j-date | |
44 | + :show-time="true" | |
45 | + date-format="YYYY-MM-DD HH:mm:ss" | |
46 | + placeholder="请选择开始时间" | |
47 | + class="query-group-cust" | |
48 | + v-model="queryParam.requestTime_begin" | |
49 | + /> | |
50 | + <span class="query-group-split-cust"></span> | |
51 | + <j-date | |
52 | + :show-time="true" | |
53 | + date-format="YYYY-MM-DD HH:mm:ss" | |
54 | + placeholder="请选择结束时间" | |
55 | + class="query-group-cust" | |
56 | + v-model="queryParam.requestTime_end" | |
57 | + /> | |
58 | + </a-form-item> | |
59 | + </a-col> | |
60 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
61 | + <a-form-item label="业务响应码"> | |
62 | + <a-input placeholder="请输入业务响应码" v-model="queryParam.retCode"></a-input> | |
63 | + </a-form-item> | |
64 | + </a-col> | |
65 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
66 | + <a-form-item label="响应耗时(毫秒)"> | |
67 | + <a-input placeholder="请输入大于响应耗时" v-model="queryParam.duration_begin"></a-input> | |
68 | + </a-form-item> | |
69 | + </a-col> | |
67 | 70 | <a-col :xl="6" :lg="7" :md="8" :sm="24"> |
68 | 71 | <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> |
69 | 72 | <a-button type="primary" @click="searchQuery" icon="search">查询</a-button> |
... | ... | @@ -134,6 +137,7 @@ |
134 | 137 | </template> |
135 | 138 | |
136 | 139 | <script> |
140 | +import moment from 'moment' | |
137 | 141 | import '@/assets/less/TableExpand.less' |
138 | 142 | import { mixinDevice } from '@/utils/mixin' |
139 | 143 | import { JeecgListMixin } from '@/mixins/JeecgListMixin' |
... | ... | @@ -153,6 +157,9 @@ export default { |
153 | 157 | return { |
154 | 158 | description: '接口日志管理页面', |
155 | 159 | apiNameList: [], |
160 | + queryParam: { | |
161 | + requestTime_begin: this.getDefaultDate() | |
162 | + }, | |
156 | 163 | // 表头 |
157 | 164 | columns: [ |
158 | 165 | { |
... | ... | @@ -236,6 +243,11 @@ export default { |
236 | 243 | } |
237 | 244 | }, |
238 | 245 | methods: { |
246 | + getDefaultDate() { | |
247 | + var tempDate = new Date() | |
248 | + tempDate.setDate(tempDate.getDate() - 7) | |
249 | + return moment(tempDate).utcOffset(480).format('YYYY-MM-DD HH:mm:ss'); | |
250 | + }, | |
239 | 251 | loadFrom() { |
240 | 252 | getApiNameList().then((res) => { |
241 | 253 | if (res.success) { |
... | ... |
huaheng-wms-core/pom.xml
... | ... | @@ -22,6 +22,17 @@ |
22 | 22 | <groupId>org.springframework.boot</groupId> |
23 | 23 | <artifactId>spring-boot-starter</artifactId> |
24 | 24 | </dependency> |
25 | + | |
26 | + <!-- <dependency> --> | |
27 | +<!-- <groupId>net.javacrumbs.shedlock</groupId> --> | |
28 | +<!-- <artifactId>shedlock-spring</artifactId> --> | |
29 | +<!-- <version>4.46.0</version> --> | |
30 | +<!-- </dependency> --> | |
31 | +<!-- <dependency> --> | |
32 | +<!-- <groupId>net.javacrumbs.shedlock</groupId> --> | |
33 | +<!-- <artifactId>shedlock-provider-jdbc-template</artifactId> --> | |
34 | +<!-- <version>4.46.0</version> --> | |
35 | +<!-- </dependency> --> | |
25 | 36 | |
26 | 37 | <dependency> |
27 | 38 | <groupId>org.jeecgframework.boot</groupId> |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java
... | ... | @@ -18,6 +18,7 @@ import org.springframework.context.annotation.ComponentScan; |
18 | 18 | import org.springframework.context.annotation.ComponentScan.Filter; |
19 | 19 | import org.springframework.context.annotation.FilterType; |
20 | 20 | import org.springframework.core.env.Environment; |
21 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
21 | 22 | |
22 | 23 | import lombok.extern.slf4j.Slf4j; |
23 | 24 | |
... | ... | @@ -26,6 +27,8 @@ import lombok.extern.slf4j.Slf4j; |
26 | 27 | */ |
27 | 28 | @Slf4j |
28 | 29 | @EnableCaching |
30 | +@EnableScheduling | |
31 | +//@EnableSchedulerLock(defaultLockAtMostFor = "PT30S") // 默认最长等待时间30秒 | |
29 | 32 | @SpringBootApplication |
30 | 33 | @EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class}) |
31 | 34 | @ComponentScan(excludeFilters = {@Filter(type = FilterType.REGEX, pattern = {"org.jeecg.config.mybatis.MybatisInterceptor", "org.jeecg.config.Swagger2Config"})}) |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/message/websocket/WebSocket.java
... | ... | @@ -17,6 +17,7 @@ import javax.websocket.server.ServerEndpoint; |
17 | 17 | import org.jeecg.common.base.BaseMap; |
18 | 18 | import org.jeecg.common.constant.WebsocketConst; |
19 | 19 | import org.jeecg.common.modules.redis.client.JeecgRedisClient; |
20 | +import org.jeecg.modules.system.entity.SysAnnouncement; | |
20 | 21 | import org.jeecg.modules.system.entity.SysUser; |
21 | 22 | import org.springframework.scheduling.annotation.Async; |
22 | 23 | import org.springframework.stereotype.Component; |
... | ... | @@ -160,6 +161,35 @@ public class WebSocket { |
160 | 161 | } |
161 | 162 | |
162 | 163 | /** |
164 | + * 发送系统消息 | |
165 | + * @param userId | |
166 | + * @param sysAnnouncement | |
167 | + */ | |
168 | + public void sendMessage(int userId, SysAnnouncement sysAnnouncement){ | |
169 | + sendMessage(String.valueOf(userId), createJson(sysAnnouncement)); | |
170 | + } | |
171 | + | |
172 | + public void sendMessage(List<SysUser> userList, SysAnnouncement announcement){ | |
173 | + userList.forEach(user -> sendMessage(user.getId(), announcement)); | |
174 | + } | |
175 | + | |
176 | + private String createJson(SysAnnouncement announcement){ | |
177 | + JSONObject obj = new JSONObject(); | |
178 | + obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC); | |
179 | + obj.put(WebsocketConst.MSG_ID, announcement.getId()); | |
180 | + obj.put(WebsocketConst.MSG_TXT, announcement.getTitile()); | |
181 | + return obj.toJSONString(); | |
182 | + } | |
183 | + | |
184 | + /** | |
185 | + * 广播系统消息 | |
186 | + * @param sysAnnouncement | |
187 | + */ | |
188 | + public void sendMessage(SysAnnouncement sysAnnouncement){ | |
189 | + sendMessage(createJson(sysAnnouncement)); | |
190 | + } | |
191 | + | |
192 | + /** | |
163 | 193 | * 此为单点消息(多人) |
164 | 194 | * @param userIds |
165 | 195 | * @param message |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/LoginController.java
... | ... | @@ -22,7 +22,6 @@ import org.apache.shiro.SecurityUtils; |
22 | 22 | import org.jeecg.common.api.vo.Result; |
23 | 23 | import org.jeecg.common.constant.CacheConstant; |
24 | 24 | import org.jeecg.common.constant.CommonConstant; |
25 | -import org.jeecg.common.constant.WebsocketConst; | |
26 | 25 | import org.jeecg.common.system.api.ISysBaseAPI; |
27 | 26 | import org.jeecg.common.system.util.JwtUtil; |
28 | 27 | import org.jeecg.common.system.vo.LoginUser; |
... | ... | @@ -34,7 +33,6 @@ import org.jeecg.common.util.RedisUtil; |
34 | 33 | import org.jeecg.common.util.oConvertUtils; |
35 | 34 | import org.jeecg.common.util.encryption.EncryptedString; |
36 | 35 | import org.jeecg.modules.base.service.BaseCommonService; |
37 | -import org.jeecg.modules.message.websocket.WebSocket; | |
38 | 36 | import org.jeecg.modules.system.entity.SysDepart; |
39 | 37 | import org.jeecg.modules.system.entity.SysTenant; |
40 | 38 | import org.jeecg.modules.system.entity.SysUser; |
... | ... | @@ -46,7 +44,6 @@ import org.jeecg.modules.system.service.ISysLogService; |
46 | 44 | import org.jeecg.modules.system.service.ISysTenantService; |
47 | 45 | import org.jeecg.modules.system.service.ISysUserService; |
48 | 46 | import org.jeecg.modules.system.util.RandImageUtil; |
49 | -import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService; | |
50 | 47 | import org.jeecg.utils.HuahengJwtUtil; |
51 | 48 | import org.jeecg.utils.HuahengRedisUtil; |
52 | 49 | import org.jeecg.utils.StringUtils; |
... | ... | @@ -59,8 +56,6 @@ import org.springframework.beans.factory.annotation.Value; |
59 | 56 | import org.springframework.context.annotation.Bean; |
60 | 57 | import org.springframework.core.io.DefaultResourceLoader; |
61 | 58 | import org.springframework.core.io.ResourceLoader; |
62 | -import org.springframework.scheduling.annotation.Async; | |
63 | -import org.springframework.scheduling.annotation.EnableAsync; | |
64 | 59 | import org.springframework.util.FileCopyUtils; |
65 | 60 | import org.springframework.web.bind.annotation.GetMapping; |
66 | 61 | import org.springframework.web.bind.annotation.PathVariable; |
... | ... | @@ -79,7 +74,6 @@ import com.auth0.jwt.JWTVerifier; |
79 | 74 | import com.auth0.jwt.algorithms.Algorithm; |
80 | 75 | import com.auth0.jwt.exceptions.JWTVerificationException; |
81 | 76 | import com.auth0.jwt.exceptions.TokenExpiredException; |
82 | -import com.auth0.jwt.interfaces.DecodedJWT; | |
83 | 77 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
84 | 78 | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
85 | 79 | |
... | ... | @@ -204,7 +198,7 @@ public class LoginController { |
204 | 198 | baseCommonService.addLog("用户名:" + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null, loginUser); |
205 | 199 | // update-end--Author:wangshuai Date:20200714 for:登录日志没有记录人员 |
206 | 200 | |
207 | - systemSync.sendMaterialAlarm(sysUser); | |
201 | + systemSync.sendSysAnnouncement(sysUser); | |
208 | 202 | return result; |
209 | 203 | } |
210 | 204 | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementController.java
... | ... | @@ -3,10 +3,8 @@ package org.jeecg.modules.system.controller; |
3 | 3 | import static org.jeecg.common.constant.CommonConstant.ANNOUNCEMENT_SEND_STATUS_1; |
4 | 4 | |
5 | 5 | import java.io.IOException; |
6 | -import java.util.Date; | |
7 | -import java.util.HashMap; | |
8 | -import java.util.List; | |
9 | -import java.util.Map; | |
6 | +import java.util.*; | |
7 | +import java.util.stream.Collectors; | |
10 | 8 | |
11 | 9 | import javax.annotation.Resource; |
12 | 10 | import javax.servlet.http.HttpServletRequest; |
... | ... | @@ -345,9 +343,12 @@ public class SysAnnouncementController { |
345 | 343 | querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND); // 已发布 |
346 | 344 | querySaWrapper.ge(SysAnnouncement::getEndTime, new Date()); // 新注册用户不看结束通知 |
347 | 345 | // update-begin--Author:liusq Date:20210108 for:[JT-424] 【开源issue】bug处理-------------------- |
348 | - querySaWrapper.notInSql(SysAnnouncement::getId, "select annt_id from sys_announcement_send where user_id ='" + userId + "'"); | |
346 | + querySaWrapper.notInSql(SysAnnouncement::getId, "select annt_id from sys_announcement_send where user_id ='" + userId + "' and read_flag='1'"); | |
349 | 347 | // update-begin--Author:liusq Date:20210108 for: [JT-424] 【开源issue】bug处理-------------------- |
350 | 348 | List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper); |
349 | + announcements = announcements.stream().filter(a-> CommonConstant.MSG_TYPE_ALL.equals(a.getMsgType()) | |
350 | + || (a.getUserIds() != null && Arrays.stream(a.getUserIds().split(",")).anyMatch(i->i.equals(userId)))).collect(Collectors.toList()); | |
351 | + | |
351 | 352 | if (announcements.size() > 0) { |
352 | 353 | for (int i = 0; i < announcements.size(); i++) { |
353 | 354 | // update-begin--Author:wangshuai Date:20200803 for: 通知公告消息重复LOWCOD-759-------------------- |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/service/ISysAnnouncementService.java
... | ... | @@ -4,6 +4,11 @@ import org.jeecg.modules.system.entity.SysAnnouncement; |
4 | 4 | |
5 | 5 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
6 | 6 | import com.baomidou.mybatisplus.extension.service.IService; |
7 | +import org.jeecg.modules.system.entity.SysRole; | |
8 | +import org.jeecg.modules.system.entity.SysUser; | |
9 | + | |
10 | +import java.util.Date; | |
11 | +import java.util.List; | |
7 | 12 | |
8 | 13 | /** |
9 | 14 | * @Description: 系统通告表 |
... | ... | @@ -21,4 +26,8 @@ public interface ISysAnnouncementService extends IService<SysAnnouncement> { |
21 | 26 | |
22 | 27 | public Page<SysAnnouncement> querySysCementPageByUserId(Page<SysAnnouncement> page, String userId, String msgCategory); |
23 | 28 | |
29 | + public void quickAnnouncementToUser(List<SysUser> userList, String title, String msg, Date endTime, String level); | |
30 | + | |
31 | + public void quickAnnouncementToRole(List<SysRole> roleList, String title, String msg, Date endTime, String level); | |
32 | + | |
24 | 33 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/service/impl/SysAnnouncementServiceImpl.java
1 | 1 | package org.jeecg.modules.system.service.impl; |
2 | 2 | |
3 | -import java.util.Arrays; | |
4 | -import java.util.Collection; | |
5 | -import java.util.Date; | |
6 | -import java.util.List; | |
3 | +import java.util.*; | |
4 | +import java.util.stream.Collectors; | |
7 | 5 | |
8 | 6 | import javax.annotation.Resource; |
9 | 7 | |
8 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
10 | 9 | import org.jeecg.common.constant.CommonConstant; |
10 | +import org.jeecg.common.constant.CommonSendStatus; | |
11 | +import org.jeecg.common.exception.JeecgBootException; | |
11 | 12 | import org.jeecg.common.util.oConvertUtils; |
13 | +import org.jeecg.modules.message.websocket.WebSocket; | |
12 | 14 | import org.jeecg.modules.system.entity.SysAnnouncement; |
13 | 15 | import org.jeecg.modules.system.entity.SysAnnouncementSend; |
16 | +import org.jeecg.modules.system.entity.SysRole; | |
17 | +import org.jeecg.modules.system.entity.SysUser; | |
14 | 18 | import org.jeecg.modules.system.mapper.SysAnnouncementMapper; |
15 | 19 | import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper; |
16 | 20 | import org.jeecg.modules.system.service.ISysAnnouncementService; |
... | ... | @@ -36,10 +40,19 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe |
36 | 40 | @Resource |
37 | 41 | private SysAnnouncementSendMapper sysAnnouncementSendMapper; |
38 | 42 | |
43 | + @Resource | |
44 | + private SysAnnouncementSendServiceImpl sysAnnouncementSendService; | |
45 | + | |
46 | + @Resource | |
47 | + private WebSocket webSocket; | |
48 | + | |
49 | + @Resource | |
50 | + private SysUserServiceImpl sysUserService; | |
51 | + | |
39 | 52 | @Transactional |
40 | 53 | @Override |
41 | 54 | public void saveAnnouncement(SysAnnouncement sysAnnouncement) { |
42 | - if (sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_ALL)) { | |
55 | + if (CommonConstant.MSG_TYPE_ALL.equals(sysAnnouncement.getMsgType())) { | |
43 | 56 | sysAnnouncementMapper.insert(sysAnnouncement); |
44 | 57 | } else { |
45 | 58 | // 1.插入通告表记录 |
... | ... | @@ -60,6 +73,104 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe |
60 | 73 | } |
61 | 74 | } |
62 | 75 | |
76 | + | |
77 | + /** | |
78 | + * 快速发送系统消息 | |
79 | + * @param userList 目标用户, 为null时发送广播消息 | |
80 | + * @param title 消息标题 | |
81 | + * @param msg 消息内容 | |
82 | + * @param endTime 消息有效期 | |
83 | + * @param level 消息级别,H M L | |
84 | + */ | |
85 | + @Override | |
86 | + public void quickAnnouncementToUser(List<SysUser> userList, String title, String msg, Date endTime, String level){ | |
87 | + SysAnnouncement sysAnnouncement = new SysAnnouncement(); | |
88 | + sysAnnouncement.setTitile(title); | |
89 | + sysAnnouncement.setMsgContent(msg); | |
90 | + sysAnnouncement.setEndTime(endTime); | |
91 | + sysAnnouncement.setPriority(level); | |
92 | + sysAnnouncement.setSendTime(new Date()); | |
93 | + sysAnnouncement.setMsgCategory(CommonConstant.MSG_CATEGORY_2); | |
94 | + sysAnnouncement.setMsgAbstract(title); | |
95 | + sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_ALL); | |
96 | + sysAnnouncement.setSender("WMS"); | |
97 | + sysAnnouncement.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); | |
98 | + sysAnnouncement.setSendStatus(CommonSendStatus.PUBLISHED_STATUS_1); | |
99 | + saveAnnouncement(sysAnnouncement); | |
100 | + | |
101 | + if(userList == null) { | |
102 | + //发送广播消息 | |
103 | + webSocket.sendMessage(sysAnnouncement); | |
104 | + }else if (userList.size() == 0){ | |
105 | + throw new JeecgBootException("发送系统消息时,用户列表为空"); | |
106 | + } else { | |
107 | + //发送给指定用户 | |
108 | + // 2.插入用户通告阅读标记表记录 | |
109 | + sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_UESR); | |
110 | + List<String> userIds = userList.stream().map(SysUser::getId).distinct().map(Object::toString).collect(Collectors.toList()); | |
111 | + sysAnnouncement.setUserIds(String.join(",", userIds)); | |
112 | + webSocket.sendMessage(userList, sysAnnouncement); | |
113 | + } | |
114 | + updateById(sysAnnouncement); | |
115 | + } | |
116 | + | |
117 | + /** | |
118 | + * 快速发送系统消息 | |
119 | + * @param roleList 目标角色 | |
120 | + * @param title 消息标题 | |
121 | + * @param msg 消息内容 | |
122 | + * @param endTime 消息有效期 | |
123 | + * @param level 消息级别,H M L | |
124 | + */ | |
125 | + @Override | |
126 | + public void quickAnnouncementToRole(List<SysRole> roleList, String title, String msg, Date endTime, String level){ | |
127 | + List<SysUser> userList = new ArrayList<>(); | |
128 | + roleList.forEach(sysRole -> { | |
129 | + Page<SysUser> page = new Page<SysUser>(1, 9999); | |
130 | + String roleId = String.valueOf(sysRole.getId()); | |
131 | + IPage<SysUser> pageList = sysUserService.getUserByRoleId(page, roleId, null); | |
132 | + userList.addAll(pageList.getRecords()); | |
133 | + }); | |
134 | + quickAnnouncementToUser(userList, title, msg, endTime, level); | |
135 | + } | |
136 | + | |
137 | + /** | |
138 | + * 获取用户的新的通知消息,生成未读的消息记录 | |
139 | + * @param sysUser | |
140 | + * @return | |
141 | + */ | |
142 | + public List<SysAnnouncement> getNewAnnouncementOfUser(SysUser sysUser){ | |
143 | + String userId = String.valueOf(sysUser.getId()); | |
144 | + LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>(); | |
145 | + // 未删除 | |
146 | + querySaWrapper.eq(SysAnnouncement::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); | |
147 | + // 已发布 | |
148 | + querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND); | |
149 | + // 新注册用户不看结束通知 | |
150 | + querySaWrapper.ge(SysAnnouncement::getEndTime, new Date()); | |
151 | + querySaWrapper.notInSql(SysAnnouncement::getId, "select annt_id from sys_announcement_send where user_id ='" + sysUser.getId() + "' and read_flag='1'"); | |
152 | + List<SysAnnouncement> announcements = list(querySaWrapper); | |
153 | + announcements = announcements.stream().filter(a-> CommonConstant.MSG_TYPE_ALL.equals(a.getMsgType()) | |
154 | + || (a.getUserIds() != null && Arrays.stream(a.getUserIds().split(",")).anyMatch(i->i.equals(userId)))).collect(Collectors.toList()); | |
155 | + | |
156 | + if (announcements.size() > 0) { | |
157 | + for (int i = 0; i < announcements.size(); i++) { | |
158 | + LambdaQueryWrapper<SysAnnouncementSend> query = new LambdaQueryWrapper<>(); | |
159 | + query.eq(SysAnnouncementSend::getAnntId, announcements.get(i).getId()); | |
160 | + query.eq(SysAnnouncementSend::getUserId, sysUser.getId()); | |
161 | + SysAnnouncementSend one = sysAnnouncementSendService.getOne(query); | |
162 | + if (null == one) { | |
163 | + SysAnnouncementSend announcementSend = new SysAnnouncementSend(); | |
164 | + announcementSend.setAnntId(announcements.get(i).getId()); | |
165 | + announcementSend.setUserId(Integer.valueOf(sysUser.getId())); | |
166 | + announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG); | |
167 | + sysAnnouncementSendService.save(announcementSend); | |
168 | + } | |
169 | + } | |
170 | + } | |
171 | + return announcements; | |
172 | + } | |
173 | + | |
63 | 174 | /** |
64 | 175 | * @功能:编辑消息信息 |
65 | 176 | */ |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
... | ... | @@ -157,8 +157,7 @@ public class WcsController extends HuahengBaseController { |
157 | 157 | Result result = handleMultiProcess("completeTaskByWMS", lockKey, new MultiProcessListener() { |
158 | 158 | @Override |
159 | 159 | public Result<?> doProcess() { |
160 | - Result result = taskHeaderService.completeTaskByWMS(Integer.parseInt(taskNo), foldFlag); | |
161 | - return result; | |
160 | + return taskHeaderService.completeTaskByWMS(Integer.parseInt(taskNo), foldFlag); | |
162 | 161 | } |
163 | 162 | }); |
164 | 163 | return result; |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/materialWarning/entity/MaterialLevelAlarm.java
... | ... | @@ -50,13 +50,13 @@ public class MaterialLevelAlarm extends MaterialWarning { |
50 | 50 | public String toString() { |
51 | 51 | String str = "<ul>"; |
52 | 52 | if (inLower) { |
53 | - str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数" + getQtySum() + " 低于下限预警值" + getLower() + "</li>"; | |
53 | + str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 低于下限预警值<b> " + getLower() + "</b></li>"; | |
54 | 54 | } else if (inUpper) { |
55 | - str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数" + getQtySum() + " 高于上限预警值" + getUpper() + "</li>"; | |
55 | + str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 高于上限预警值<b> " + getUpper() + "</b></li>"; | |
56 | 56 | } else if (inMin) { |
57 | - str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数" + getQtySum() + " 低于最低值" + getMin() + "</li>"; | |
57 | + str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 低于最低值<b> " + getMin() + "</b></li>"; | |
58 | 58 | } else if (inMax) { |
59 | - str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数" + getQtySum() + " 超过最高值" + getMax() + "</li>"; | |
59 | + str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 超过最高值<b> " + getMax() + "</b></li>"; | |
60 | 60 | } |
61 | 61 | return str + "</ul>"; |
62 | 62 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/apiLog/service/impl/ApiLogServiceImpl.java
... | ... | @@ -8,6 +8,7 @@ import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; |
8 | 8 | import org.jeecg.modules.wms.monitor.apiLog.mapper.ApiLogMapper; |
9 | 9 | import org.jeecg.modules.wms.monitor.apiLog.service.IApiLogService; |
10 | 10 | import org.springframework.cache.annotation.Cacheable; |
11 | +import org.springframework.scheduling.annotation.Scheduled; | |
11 | 12 | import org.springframework.stereotype.Service; |
12 | 13 | |
13 | 14 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
... | ... | @@ -26,7 +27,9 @@ import cn.hutool.core.date.DateUtil; |
26 | 27 | public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements IApiLogService { |
27 | 28 | |
28 | 29 | @Override |
29 | - @Cacheable(cacheNames = "getApiNameList#7200", key = "#root.methodName", unless = "#result == null ") | |
30 | + @Scheduled(fixedDelay = 1800 * 1000) // 计划任务:每次方法执行后1800秒执行 | |
31 | +// @SchedulerLock(name = "getApiNameList", lockAtLeastFor = "PT900S", lockAtMostFor = "PT3600S") // 计划任务锁:最短等待时间1800秒,最长等待时间3600秒 | |
32 | + @Cacheable(cacheNames = "getApiNameList#1800", key = "#root.methodName", unless = "#result == null ") | |
30 | 33 | public List<String> getApiNameList() { |
31 | 34 | LambdaQueryWrapper<ApiLog> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
32 | 35 | lambdaQueryWrapper.select(ApiLog::getApiName).groupBy(ApiLog::getApiName).ge(ApiLog::getCreateTime, DateUtil.offsetDay(new Date(), -7)); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/MaterialLevelAlarmTask.java
... | ... | @@ -2,28 +2,19 @@ package org.jeecg.modules.wms.monitor.job; |
2 | 2 | |
3 | 3 | import cn.hutool.core.date.DateUtil; |
4 | 4 | import cn.hutool.core.util.StrUtil; |
5 | -import com.alibaba.fastjson.JSONObject; | |
6 | -import com.baomidou.mybatisplus.core.metadata.IPage; | |
7 | -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
8 | 5 | import lombok.extern.slf4j.Slf4j; |
9 | 6 | import org.apache.ibatis.session.SqlSession; |
10 | -import org.jeecg.common.constant.CommonConstant; | |
11 | -import org.jeecg.common.constant.CommonSendStatus; | |
12 | -import org.jeecg.common.constant.WebsocketConst; | |
13 | 7 | import org.jeecg.common.util.DateUtils; |
14 | 8 | import org.jeecg.modules.message.websocket.WebSocket; |
15 | -import org.jeecg.modules.system.controller.SysAnnouncementController; | |
16 | -import org.jeecg.modules.system.entity.SysAnnouncement; | |
17 | 9 | import org.jeecg.modules.system.entity.SysUser; |
18 | -import org.jeecg.modules.system.mapper.SysUserMapper; | |
19 | 10 | import org.jeecg.modules.system.service.impl.SysAnnouncementServiceImpl; |
20 | 11 | import org.jeecg.modules.system.service.impl.SysRoleServiceImpl; |
21 | 12 | import org.jeecg.modules.system.service.impl.SysUserServiceImpl; |
22 | 13 | import org.jeecg.modules.wms.config.materialWarning.entity.MaterialLevelAlarm; |
23 | 14 | import org.jeecg.modules.wms.config.materialWarning.service.impl.MaterialWarningServiceImpl; |
24 | -import org.jeecg.utils.SpringUtils; | |
25 | 15 | import org.quartz.*; |
26 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
17 | +import org.springframework.util.CollectionUtils; | |
27 | 18 | |
28 | 19 | import javax.annotation.Resource; |
29 | 20 | import java.util.ArrayList; |
... | ... | @@ -68,57 +59,26 @@ public class MaterialLevelAlarmTask implements Job { |
68 | 59 | @Override |
69 | 60 | public void execute(JobExecutionContext context) throws JobExecutionException { |
70 | 61 | log.info(StrUtil.format("定时任务 MaterialLevelAlarmTask 参数:{},执行时间:{}", this.parameter, DateUtils.getTimestamp())); |
62 | + | |
71 | 63 | List<MaterialLevelAlarm> alarmList = materialWarningService.getLevelAlarm(null); |
72 | - if (alarmList == null && alarmList.size() == 0) { | |
64 | + if (CollectionUtils.isEmpty(alarmList)) { | |
73 | 65 | return; |
74 | 66 | } |
75 | 67 | |
76 | 68 | List<String> list = alarmList.stream().map(MaterialLevelAlarm::toString).collect(Collectors.toList()); |
77 | 69 | String msg = String.join("\n", list); |
78 | 70 | |
79 | - SysAnnouncement sysAnnouncement = new SysAnnouncement(); | |
80 | - String title = "物料水位预警"; | |
81 | - sysAnnouncement.setTitile(title); | |
82 | - sysAnnouncement.setMsgContent(msg); | |
83 | - sysAnnouncement.setEndTime(DateUtil.offsetDay(new Date(), 1)); | |
84 | - sysAnnouncement.setPriority("H"); | |
85 | - sysAnnouncement.setSendTime(new Date()); | |
86 | - sysAnnouncement.setMsgCategory(CommonConstant.MSG_CATEGORY_2); | |
87 | - sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_ALL); | |
88 | - sysAnnouncement.setMsgAbstract(title); | |
89 | - sysAnnouncement.setSender("WMS"); | |
90 | - sysAnnouncement.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); | |
91 | - sysAnnouncement.setSendStatus(CommonSendStatus.PUBLISHED_STATUS_1); | |
92 | - sysAnnouncementService.saveAnnouncement(sysAnnouncement); | |
93 | - | |
94 | - List<SysUser> userList = new ArrayList<>(); | |
71 | + | |
72 | + List<SysUser> userList; | |
95 | 73 | try { |
96 | 74 | String[] userOrRoleArr = this.parameter.split(","); |
97 | 75 | userList = sysUserService.getUserByRoleNameArray(userOrRoleArr); |
76 | + if(userList.size() == 0){ | |
77 | + userList = null; | |
78 | + } | |
79 | + sysAnnouncementService.quickAnnouncementToUser(userList, "物料水位预警", msg, DateUtil.offsetDay(new Date(), 1), "H"); | |
98 | 80 | } catch (Exception e) { |
99 | 81 | log.error("获取预警通知用户出错", e); |
100 | 82 | } |
101 | - | |
102 | - if (userList.size() == 0) { | |
103 | - sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_ALL); | |
104 | - JSONObject obj = new JSONObject(); | |
105 | - obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC); | |
106 | - obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId()); | |
107 | - obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile()); | |
108 | - webSocket.sendMessage(obj.toJSONString()); | |
109 | - } else { | |
110 | - // 2.插入用户通告阅读标记表记录 | |
111 | - sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_UESR); | |
112 | - List<String> userIds = userList.stream().map(SysUser::getId).map(Object::toString).collect(Collectors.toList()); | |
113 | - sysAnnouncement.setUserIds(String.join(",", userIds)); | |
114 | - | |
115 | - JSONObject obj = new JSONObject(); | |
116 | - obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER); | |
117 | - obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId()); | |
118 | - obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile()); | |
119 | - webSocket.sendMessage(userIds, obj.toJSONString()); | |
120 | - } | |
121 | - | |
122 | - sysAnnouncementService.updateById(sysAnnouncement); | |
123 | 83 | } |
124 | 84 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java
... | ... | @@ -341,11 +341,10 @@ public class TaskHeaderController extends HuahengBaseController { |
341 | 341 | return Result.error("taskHeader不能为空"); |
342 | 342 | } |
343 | 343 | Integer taskId = taskHeader.getId(); |
344 | - Result result = handleMultiProcess("completeTaskByWMS", new MultiProcessListener() { | |
344 | + Result result = handleMultiProcess("completeTaskByWMS", taskId + "", new MultiProcessListener() { | |
345 | 345 | @Override |
346 | 346 | public Result<?> doProcess() { |
347 | - Result result = taskHeaderService.completeTaskByWMS(taskId, false); | |
348 | - return result; | |
347 | + return taskHeaderService.completeTaskByWMS(taskId, false); | |
349 | 348 | } |
350 | 349 | }); |
351 | 350 | return result; |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/utils/support/SystemSync.java
1 | 1 | package org.jeecg.utils.support; |
2 | 2 | |
3 | 3 | import java.math.BigDecimal; |
4 | +import java.util.Date; | |
4 | 5 | import java.util.List; |
5 | 6 | import java.util.concurrent.Future; |
6 | 7 | |
7 | 8 | import javax.annotation.Resource; |
8 | 9 | |
10 | +import org.jeecg.common.constant.CommonConstant; | |
9 | 11 | import org.jeecg.common.constant.WebsocketConst; |
10 | 12 | import org.jeecg.modules.message.websocket.WebSocket; |
13 | +import org.jeecg.modules.system.entity.SysAnnouncement; | |
14 | +import org.jeecg.modules.system.entity.SysAnnouncementSend; | |
11 | 15 | import org.jeecg.modules.system.entity.SysUser; |
16 | +import org.jeecg.modules.system.service.impl.SysAnnouncementServiceImpl; | |
12 | 17 | import org.jeecg.modules.wms.inventory.inventoryTransaction.entity.InventoryTransaction; |
13 | 18 | import org.jeecg.modules.wms.inventory.inventoryTransaction.service.IInventoryTransactionService; |
14 | 19 | import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; |
... | ... | @@ -34,20 +39,25 @@ public class SystemSync { |
34 | 39 | |
35 | 40 | @Autowired |
36 | 41 | private IInventoryTransactionService inventoryTransactionService; |
37 | - | |
42 | + | |
38 | 43 | @Autowired |
39 | 44 | private WebSocket webSocket; |
40 | - | |
45 | + | |
46 | + @Autowired | |
47 | + private SysAnnouncementServiceImpl sysAnnouncementService; | |
48 | + | |
49 | + /** | |
50 | + * 登录弹框后发送未读消息 | |
51 | + * @param sysUser | |
52 | + */ | |
41 | 53 | @Async("asyncPoolTaskExecutor") |
42 | - public void sendMaterialAlarm(SysUser sysUser) { | |
54 | + public void sendSysAnnouncement(SysUser sysUser) { | |
43 | 55 | try { |
44 | 56 | Thread.sleep(20000); |
45 | - JSONObject obj = new JSONObject(); | |
46 | - obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC); | |
47 | - obj.put(WebsocketConst.MSG_ID, "111"); | |
48 | - obj.put(WebsocketConst.MSG_TXT, "登录通知测试"); | |
49 | - webSocket.sendMessage(obj.toJSONString()); | |
57 | + List<SysAnnouncement> sysAnnouncementList = sysAnnouncementService.getNewAnnouncementOfUser(sysUser); | |
58 | + sysAnnouncementList.forEach(a->webSocket.sendMessage(sysUser.getId(), a)); | |
50 | 59 | } catch (Exception e) { |
60 | + log.error("websocket系统消息发送失败", e); | |
51 | 61 | } |
52 | 62 | } |
53 | 63 | |
... | ... |