|
@@ -1,16 +1,13 @@
|
1
|
1
|
package com.lyg.application.service.impl;
|
2
|
2
|
|
3
|
|
-import com.lyg.application.entity.TaMessage;
|
4
|
3
|
import com.lyg.application.entity.TaRotation;
|
5
|
|
-import com.lyg.application.entity.TaSending;
|
6
|
4
|
import com.lyg.application.mapper.TaMessageMapper;
|
7
|
5
|
import com.lyg.application.mapper.TaRotationMapper;
|
8
|
6
|
import com.lyg.application.mapper.TaSendingMapper;
|
9
|
7
|
import com.lyg.application.service.TaMessageService;
|
10
|
8
|
import com.lyg.application.service.TaRotationService;
|
|
9
|
+import com.lyg.application.util.MessageHandle;
|
11
|
10
|
import com.lyg.application.util.Rule;
|
12
|
|
-import com.lyg.common.util.StringUtil;
|
13
|
|
-import com.lyg.system.entity.SysUser;
|
14
|
11
|
import com.lyg.system.mapper.SysPositionMapper;
|
15
|
12
|
import com.lyg.system.mapper.SysUserMapper;
|
16
|
13
|
import com.lyg.system.service.SysOrgService;
|
|
@@ -35,6 +32,9 @@ import java.util.List;
|
35
|
32
|
|
36
|
33
|
public class TaRotationServiceImpl extends BaseServiceImpl<TaRotationMapper, TaRotation> implements TaRotationService {
|
37
|
34
|
|
|
35
|
+ private static final String WARNING_TYPE = "waring";
|
|
36
|
+ private static final String PROMPT_TYPE = "prompt";
|
|
37
|
+ private static final String MESSAGE_SOURCE_NAME = "taRotation";
|
38
|
38
|
private final List<Object> errorMessages = new ArrayList<>();
|
39
|
39
|
@Autowired
|
40
|
40
|
Rule rule;
|
|
@@ -59,6 +59,10 @@ public class TaRotationServiceImpl extends BaseServiceImpl<TaRotationMapper, TaR
|
59
|
59
|
@Autowired
|
60
|
60
|
private SysUserMapper sysUserMapper;
|
61
|
61
|
|
|
62
|
+ @Autowired
|
|
63
|
+ private MessageHandle messageHandle;
|
|
64
|
+
|
|
65
|
+
|
62
|
66
|
public TaRotation handleEntity(TaRotation entity, Integer index) throws Exception {
|
63
|
67
|
//校验验证
|
64
|
68
|
System.out.println("******************************entity**************************************");
|
|
@@ -140,85 +144,68 @@ public class TaRotationServiceImpl extends BaseServiceImpl<TaRotationMapper, TaR
|
140
|
144
|
|
141
|
145
|
@Override
|
142
|
146
|
public void selectGetWaring() {
|
|
147
|
+//
|
|
148
|
+////预警 消息
|
|
149
|
+// List<TaRotation> earlyWaringList = baseMapper.waring(localDate);
|
|
150
|
+//
|
|
151
|
+// if (!earlyWaringList.isEmpty()) {
|
|
152
|
+// for (TaRotation item : earlyWaringList) {
|
|
153
|
+// TaMessage taMessage = new TaMessage();
|
|
154
|
+// String uuid = StringUtil.UUID();
|
|
155
|
+// taMessage.setMessageId(uuid);
|
|
156
|
+// taMessage.setSourceId(item.getRotationId());
|
|
157
|
+// StringBuilder sb = new StringBuilder(warningTmp);
|
|
158
|
+// sb.insert(Constants.numI, item.getEmployeeNum());
|
|
159
|
+// Integer i = item.getEmployeeNum().length() + Constants.nameI;
|
|
160
|
+// sb.insert(i, item.getEmployeeName());
|
|
161
|
+// taMessage.setContentSent(sb.toString());
|
|
162
|
+// taMessage.setSourceName("taRotation");
|
|
163
|
+// taMessage.setWaringType("waring");
|
|
164
|
+//
|
|
165
|
+// Long count = taMessageService.countBy("source_id", item.getRotationId(), true);
|
|
166
|
+// if (count == 0) {
|
|
167
|
+// taMessageMapper.insert(taMessage);
|
|
168
|
+// insertIntoTaSending(item.getCreateUser(), uuid);
|
|
169
|
+// }
|
|
170
|
+//
|
|
171
|
+// }
|
|
172
|
+// }
|
|
173
|
+////提示消息
|
|
174
|
+// List<TaRotation> earlyPromptList = baseMapper.prompt(localDate);
|
|
175
|
+//
|
|
176
|
+// if (earlyPromptList.size() != 0) {
|
|
177
|
+// for (TaRotation item : earlyPromptList) {
|
|
178
|
+// TaMessage taMessage = new TaMessage();
|
|
179
|
+// String uuid = StringUtil.UUID();
|
|
180
|
+// taMessage.setMessageId(uuid);
|
|
181
|
+// taMessage.setSourceId(item.getRotationId());
|
|
182
|
+// StringBuilder sb = new StringBuilder(promptTmp);
|
|
183
|
+// sb.insert(Constants.numI, item.getEmployeeNum());
|
|
184
|
+// Integer i = item.getEmployeeNum().length() + Constants.nameI;
|
|
185
|
+// sb.insert(i, item.getEmployeeName());
|
|
186
|
+// taMessage.setContentSent(sb.toString());
|
|
187
|
+// taMessage.setSourceName("taRotation");
|
|
188
|
+// taMessage.setWaringType("prompt");
|
|
189
|
+//
|
|
190
|
+// Long count = taMessageService.countBy("source_id", item.getRotationId(), true);
|
|
191
|
+// if (count == 0) {
|
|
192
|
+// taMessageMapper.insert(taMessage);
|
|
193
|
+// insertIntoTaSending(item.getCreateUser(), uuid);
|
|
194
|
+// }
|
|
195
|
+//
|
|
196
|
+// }
|
|
197
|
+// }
|
|
198
|
+
|
|
199
|
+// return;
|
143
|
200
|
LocalDate localDate = LocalDate.now();
|
144
|
|
- Integer numI = 3;
|
145
|
|
- Integer nameI = 8;
|
146
|
|
-//预警 消息
|
147
|
|
- List<TaRotation> earlyWaringList = baseMapper.waring(localDate);
|
148
|
|
-
|
149
|
|
- if (earlyWaringList.size() != 0) {
|
150
|
|
- for (TaRotation item : earlyWaringList) {
|
151
|
|
- TaMessage taMessage = new TaMessage();
|
152
|
|
- String uuid = StringUtil.UUID();
|
153
|
|
- taMessage.setMessageId(uuid);
|
154
|
|
- taMessage.setSourceId(item.getRotationId());
|
155
|
|
- StringBuilder sb = new StringBuilder(warningTmp);
|
156
|
|
- sb.insert(numI, item.getEmployeeNum());
|
157
|
|
- Integer i = item.getEmployeeNum().length() + nameI;
|
158
|
|
- sb.insert(i, item.getEmployeeName());
|
159
|
|
- taMessage.setContentSent(sb.toString());
|
160
|
|
- taMessage.setSourceName("taRotation");
|
161
|
|
- taMessage.setWaringType("waring");
|
162
|
|
-
|
163
|
|
- Long count = taMessageService.countBy("source_id", item.getRotationId(), true);
|
164
|
|
- if (count == 0) {
|
165
|
|
- taMessageMapper.insert(taMessage);
|
166
|
|
- insertIntoTaSending(item.getCreateUser(), uuid);
|
167
|
|
- }
|
168
|
|
-
|
169
|
|
- }
|
170
|
|
- }
|
171
|
|
-//提示消息
|
172
|
|
- List<TaRotation> earlyPromptList = baseMapper.prompt(localDate);
|
173
|
|
-
|
174
|
|
- if (earlyPromptList.size() != 0) {
|
175
|
|
- for (TaRotation item : earlyPromptList) {
|
176
|
|
- TaMessage taMessage = new TaMessage();
|
177
|
|
- String uuid = StringUtil.UUID();
|
178
|
|
- taMessage.setMessageId(uuid);
|
179
|
|
- taMessage.setSourceId(item.getRotationId());
|
180
|
|
- StringBuilder sb = new StringBuilder(promptTmp);
|
181
|
|
- sb.insert(numI, item.getEmployeeNum());
|
182
|
|
- Integer i = item.getEmployeeNum().length() + nameI;
|
183
|
|
- sb.insert(i, item.getEmployeeName());
|
184
|
|
- taMessage.setContentSent(sb.toString());
|
185
|
|
- taMessage.setSourceName("taRotation");
|
186
|
|
- taMessage.setWaringType("prompt");
|
187
|
|
-
|
188
|
|
- Long count = taMessageService.countBy("source_id", item.getRotationId(), true);
|
189
|
|
- if (count == 0) {
|
190
|
|
- taMessageMapper.insert(taMessage);
|
191
|
|
- insertIntoTaSending(item.getCreateUser(), uuid);
|
192
|
|
- }
|
193
|
|
-
|
194
|
|
- }
|
195
|
|
- }
|
196
|
201
|
|
|
202
|
+ // 预警消息处理
|
|
203
|
+ messageHandle.handleMessages(localDate, warningTmp,WARNING_TYPE,MESSAGE_SOURCE_NAME ,baseMapper::waring);
|
197
|
204
|
|
198
|
|
- return;
|
|
205
|
+ // 提示消息处理
|
|
206
|
+ messageHandle.handleMessages(localDate,promptTmp, PROMPT_TYPE, MESSAGE_SOURCE_NAME ,baseMapper::prompt);
|
199
|
207
|
}
|
200
|
208
|
|
201
|
|
- public void insertIntoTaSending(String createUser, String uuid) {
|
202
|
|
-
|
203
|
|
- // item.getCreateUser() 就是新增这个数据的人
|
204
|
|
- //现在需要去重 创建人和管理员 是一个人只能往 Tasending插入一条数据否则是两条数据
|
205
|
|
- SysUser sysUserAdmin = sysUserMapper.getAdmin(createUser);
|
206
|
|
-// 如果为空 就不是管理员创建的;
|
207
|
|
- List<String> userIdList = new ArrayList<>();
|
208
|
|
-
|
209
|
|
- if (sysUserAdmin == null) {
|
210
|
|
- userIdList.add(createUser);
|
211
|
|
- }
|
212
|
|
- userIdList = sysUserMapper.allAdmin();
|
213
|
|
-
|
214
|
|
- for (String it : userIdList) {
|
215
|
|
- TaSending taSending = new TaSending();
|
216
|
|
- taSending.setMessageId(uuid);
|
217
|
|
- taSending.setRecipientId(it);
|
218
|
|
- taSendingMapper.insert(taSending);
|
219
|
|
- }
|
220
|
|
-
|
221
|
|
- }
|
222
|
209
|
|
223
|
210
|
public List<Object> getErrorMessages() {
|
224
|
211
|
return errorMessages;
|