|
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; |
|
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; |
5
|
import com.sunyo.wlpt.message.bus.service.domain.*;
|
5
|
import com.sunyo.wlpt.message.bus.service.domain.*;
|
6
|
import com.sunyo.wlpt.message.bus.service.mapper.MessageNoteMapper;
|
6
|
import com.sunyo.wlpt.message.bus.service.mapper.MessageNoteMapper;
|
7
|
import com.sunyo.wlpt.message.bus.service.mapper.UserMessageBindingMapper;
|
7
|
import com.sunyo.wlpt.message.bus.service.mapper.UserMessageBindingMapper;
|
|
|
8
|
+import com.sunyo.wlpt.message.bus.service.rabbit.utils.DirectUtils;
|
8
|
import com.sunyo.wlpt.message.bus.service.service.*;
|
9
|
import com.sunyo.wlpt.message.bus.service.service.*;
|
9
|
import com.sunyo.wlpt.message.bus.service.utils.IdUtils;
|
10
|
import com.sunyo.wlpt.message.bus.service.utils.IdUtils;
|
10
|
import lombok.extern.slf4j.Slf4j;
|
11
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -47,6 +48,9 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
@@ -47,6 +48,9 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
47
|
@Resource
|
48
|
@Resource
|
48
|
private MessageNoteMapper messageNoteMapper;
|
49
|
private MessageNoteMapper messageNoteMapper;
|
49
|
|
50
|
|
|
|
51
|
+ @Resource
|
|
|
52
|
+ private DirectUtils directUtils;
|
|
|
53
|
+
|
50
|
@Override
|
54
|
@Override
|
51
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
55
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
52
|
public int deleteByPrimaryKey(String id)
|
56
|
public int deleteByPrimaryKey(String id)
|
|
@@ -80,7 +84,7 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
@@ -80,7 +84,7 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
80
|
}
|
84
|
}
|
81
|
|
85
|
|
82
|
@Override
|
86
|
@Override
|
83
|
- public int insertSelective(MessageNote record)
|
87
|
+ public int insertSelective(MessageNote record) throws Exception
|
84
|
{
|
88
|
{
|
85
|
return validateNoteAndFill(record);
|
89
|
return validateNoteAndFill(record);
|
86
|
}
|
90
|
}
|
|
@@ -164,15 +168,15 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
@@ -164,15 +168,15 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
164
|
messageNote.setId(IdUtils.generateId());
|
168
|
messageNote.setId(IdUtils.generateId());
|
165
|
|
169
|
|
166
|
// 填充,用户名称
|
170
|
// 填充,用户名称
|
167
|
- UserInfo userInfo = userInfoService.selectByPrimaryKey(messageNote.getUserId());
|
|
|
168
|
- messageNote.setUsername(userInfo.getUsername());
|
171
|
+// UserInfo userInfo = userInfoService.selectByPrimaryKey(messageNote.getUserId());
|
|
|
172
|
+// messageNote.setUsername(userInfo.getUsername());
|
169
|
|
173
|
|
170
|
// 填充,发送内容(编辑 or 新增)
|
174
|
// 填充,发送内容(编辑 or 新增)
|
171
|
messageNote.setSendContent(messageNote.getAlias_sendContent().getBytes());
|
175
|
messageNote.setSendContent(messageNote.getAlias_sendContent().getBytes());
|
172
|
|
176
|
|
173
|
// 填充,服务器名称
|
177
|
// 填充,服务器名称
|
174
|
- BusServer busServer = busServerService.selectByPrimaryKey(messageNote.getServerId());
|
|
|
175
|
- messageNote.setServerName(busServer.getServerName());
|
178
|
+// BusServer busServer = busServerService.selectByPrimaryKey(messageNote.getServerId());
|
|
|
179
|
+// messageNote.setServerName(busServer.getServerName());
|
176
|
|
180
|
|
177
|
// 填充,虚拟主机名称
|
181
|
// 填充,虚拟主机名称
|
178
|
VirtualHost virtualHost = virtualHostService.selectByPrimaryKey(messageNote.getVirtualHostId());
|
182
|
VirtualHost virtualHost = virtualHostService.selectByPrimaryKey(messageNote.getVirtualHostId());
|
|
@@ -205,9 +209,35 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
@@ -205,9 +209,35 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
205
|
* @param messageNote {@link MessageNote}
|
209
|
* @param messageNote {@link MessageNote}
|
206
|
* @return 发送信息记录的条数
|
210
|
* @return 发送信息记录的条数
|
207
|
*/
|
211
|
*/
|
208
|
- public int validateNoteAndFill(MessageNote messageNote)
|
212
|
+ public int validateNoteAndFill(MessageNote messageNote) throws Exception
|
209
|
{
|
213
|
{
|
210
|
- return validateNote(messageNote) ? messageNoteMapper.insertSelective(note_fillName(messageNote)) : 0;
|
214
|
+ if (validateNote(messageNote)) {
|
|
|
215
|
+ // 填充,用户名称
|
|
|
216
|
+ UserInfo userInfo = userInfoService.selectByPrimaryKey(messageNote.getUserId());
|
|
|
217
|
+ messageNote.setUsername(userInfo.getUsername());
|
|
|
218
|
+ // 填充,服务器名称
|
|
|
219
|
+ BusServer busServer = busServerService.selectByPrimaryKey(messageNote.getServerId());
|
|
|
220
|
+ messageNote.setServerName(busServer.getServerName());
|
|
|
221
|
+
|
|
|
222
|
+ MessageNote note = note_fillName(messageNote);
|
|
|
223
|
+ // 发送到MQ服务器
|
|
|
224
|
+ XmlData xmlData = XmlData.builder()
|
|
|
225
|
+ .sender(note.getUsername())
|
|
|
226
|
+ .password(userInfo.getPassword())
|
|
|
227
|
+ .sendContent(note.getAlias_sendContent())
|
|
|
228
|
+ .sendDateTime(note.getSendTime())
|
|
|
229
|
+ .exchangeName(note.getExchangeName())
|
|
|
230
|
+ .routingKeyName(note.getRoutingKeyName())
|
|
|
231
|
+ .virtualHostName(note.getVirtualHostName())
|
|
|
232
|
+ .serverName(note.getServerName())
|
|
|
233
|
+ .serverIp(busServer.getServerIp())
|
|
|
234
|
+ .serverPort(busServer.getServerPort())
|
|
|
235
|
+ .build();
|
|
|
236
|
+ directUtils.sendMessage(xmlData);
|
|
|
237
|
+ return messageNoteMapper.insertSelective(note);
|
|
|
238
|
+ } else {
|
|
|
239
|
+ return 0;
|
|
|
240
|
+ }
|
211
|
}
|
241
|
}
|
212
|
}
|
242
|
}
|
213
|
|
243
|
|