细节优化

bug修复
yun-zuoyi
yunhao.wang 6 years ago
parent cc0e350e73
commit 8b4600606b

@ -120,7 +120,11 @@ public class WhiteController extends CoreBaseController {
logout();
SessionUser user = userService.queryUserLogin(loginName,loginPwd.trim(),languageCode);
// 去除前后空格
loginName = loginName.trim();
loginPwd = loginPwd.trim();
SessionUser user = userService.queryUserLogin(loginName,loginPwd,languageCode);
String redisKey = CommonConstWords.USER_LOGIN_ERROR + "_" + user.getUser().getId();
redisCore.deleteKey(redisKey);

@ -12,7 +12,6 @@ import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserMessage;
import cn.estsh.i3plus.pojo.platform.bean.SysUser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.rabbitmq.client.Channel;
import org.apache.commons.lang3.StringUtils;
@ -42,10 +41,10 @@ public class MessageLetterQueueReceiver {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageLetterQueueReceiver.class);
@Autowired
ISysMessageService sysMessageService;
private ISysMessageService sysMessageService;
@Autowired
ISysUserService sysUserService;
private ISysUserService sysUserService;
@Autowired
private IPersonnelService personnelService;
@ -57,27 +56,28 @@ public class MessageLetterQueueReceiver {
/**
*
*
* @param msg
* @param channel
* @param message rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_QUEUE, new SysMessage(....));
*/
@RabbitListener(queues = PlatformConstWords.IMPP_MESSAGE_LETTER_QUEUE)
public void processImppMessage(SysMessage msg, Channel channel, Message message) {
LOGGER.info("【MQ-{}】 数据接收成功:{}",PlatformConstWords.IMPP_MESSAGE_LETTER_QUEUE, msg);
LOGGER.info("【MQ-{}】 数据接收成功:{}", PlatformConstWords.IMPP_MESSAGE_LETTER_QUEUE, msg);
try {
msg = sysMessageService.insertSysMessage(msg);
if (!StringUtils.isBlank(msg.getMessageReceiversId())) {
String[] userIds = msg.getMessageReceiversId().split(",");
if(userIds != null && userIds.length > 0){
if (userIds != null && userIds.length > 0) {
List<SysUser> userList = personnelService.findSysUserByIds(StringTool.getArrayLong(userIds));
if(userList != null && userList.size() > 0){
if (userList != null && userList.size() > 0) {
List<SysRefUserMessage> insertList = new ArrayList<>(userList.size());
SysRefUserMessage refUserMessage;
for (SysUser user : userList){
for (SysUser user : userList) {
refUserMessage = new SysRefUserMessage();
refUserMessage.setMessageId(msg.getId());
refUserMessage.setMessageTitleRdd(msg.getMessageTitle());
@ -95,7 +95,7 @@ public class MessageLetterQueueReceiver {
List<SysRefUserMessage> refList = sysMessageService.insertSysRefUserMessage(insertList);
// 站内信使用 Web Socket 推送
if(refList != null && refList.size() > 0){
if (refList != null && refList.size() > 0) {
for (SysRefUserMessage userMessage : refList) {
MessageWebSocket.sendMessage(userMessage.getReceiverId(), MAPPER.writeValueAsString(userMessage));
}
@ -106,21 +106,21 @@ public class MessageLetterQueueReceiver {
// 消息处理完成
LOGGER.info("【MQ-{}】站内信{} DeliveryTag:{} 处理成功", PlatformConstWords.IMPP_MESSAGE_LETTER_QUEUE,
msg,message.getMessageProperties().getDeliveryTag());
msg, message.getMessageProperties().getDeliveryTag());
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
}catch (IOException e){
printErrorMessage(e,Exception.class, msg);
} catch (IOException e) {
printErrorMessage(e, Exception.class, msg);
try {
// 未成功处理,重新发送
channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
private void printErrorMessage(Exception e,Class zlass,SysMessage msg){
private void printErrorMessage(Exception e, Class zlass, SysMessage msg) {
Long time = System.currentTimeMillis();
LOGGER.error("【MQ-{}】{} 异常代码:{} 消息内容{},处理出错:{}", PlatformConstWords.IMPP_MESSAGE_LETTER_QUEUE, time, zlass, msg, e.getMessage());
e.printStackTrace();
@ -129,13 +129,13 @@ public class MessageLetterQueueReceiver {
SysMessage sysMessage = new SysMessage();
sysMessage.setMessageSenderNameRdd("系统管理员");
sysMessage.setMessageTitle("【IMPP-MQ异常】站内信消息推送失败");
sysMessage.setMessageContent("推送站内信["+zlass+"]错误异常代码:"+time);
sysMessage.setMessageContent("推送站内信[" + zlass + "]错误异常代码:" + time);
sysMessage.setMessageContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.HTML.getValue());
sysMessage.setMessageSendTime(TimeTool.getNowTime(true));
sysMessage.setIsSystem(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
sysMessage.setMessageReceiverType(ImppEnumUtil.MESSAGE_RECEIVER_TYPE.EXTERNAL.getValue());
sysMessage.setMessageReceiversNameRdd("yunhao.wang@estsh.com,wei.peng@estsh.com");
rabbitTemplate.convertAndSend(PlatformConstWords.IMPP_MESSAGE_MAIL_QUEUE,sysMessage);
rabbitTemplate.convertAndSend(PlatformConstWords.IMPP_MESSAGE_MAIL_QUEUE, sysMessage);
}

@ -35,24 +35,25 @@ public class MessageMailQueueReceiver {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageMailQueueReceiver.class);
@Autowired
ISysMessageService sysMessageService;
private ISysMessageService sysMessageService;
@Autowired
ISysUserService sysUserService;
private ISysUserService sysUserService;
@Autowired
ISysConfigService sysConfigService;
private ISysConfigService sysConfigService;
@Autowired
MailUtil mailUtil;
private MailUtil mailUtil;
/**
*
* @param msg
*
* @param msg
* @param channel
* @param message
*/
@RabbitListener(queues = PlatformConstWords.IMPP_MESSAGE_MAIL_QUEUE)
public void processImppMail(SysMessage msg, Channel channel, Message message) {
try {
LOGGER.info("【MQ-IMPP_MESSAGE_MAIL_QUEUE】数据接收成功{}",msg);
LOGGER.info("【MQ-IMPP_MESSAGE_MAIL_QUEUE】数据接收成功{}", msg);
if (msg.getMessageSendTime() == null) {
msg.setMessageSendTime(TimeTool.getNowTime(true));
}
@ -65,16 +66,16 @@ public class MessageMailQueueReceiver {
mailUtil.setContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.valueOfDescription(msg.getMessageContentType()));
mailUtil.setBody(msg.getMessageContent());
if(msg.getMessageReceiverType() != null){
if(msg.getMessageReceiverType().intValue() == ImppEnumUtil.MESSAGE_RECEIVER_TYPE.URGENT.getValue()){
if (msg.getMessageReceiverType() != null) {
if (msg.getMessageReceiverType().intValue() == ImppEnumUtil.MESSAGE_RECEIVER_TYPE.URGENT.getValue()) {
// 判断是否为系统紧急提示 微服注册状态提示
mailUtil.setTo(sysConfigService.getSysConfigByCode(PlatformConstWords.CONTACT_MAIL).getConfigValue());
// 次数过于频繁
// mailUtil.send();
} else if(msg.getMessageReceiverType().intValue() == ImppEnumUtil.MESSAGE_RECEIVER_TYPE.EXTERNAL.getValue()){
} else if (msg.getMessageReceiverType().intValue() == ImppEnumUtil.MESSAGE_RECEIVER_TYPE.EXTERNAL.getValue()) {
//判断是否为外部邮件
mailUtil.setTo(StringUtils.split(msg.getMessageReceiversNameRdd(),","));
mailUtil.setTo(StringUtils.split(msg.getMessageReceiversNameRdd(), ","));
mailUtil.send();
} else if (msg.getMessageReceiverType().intValue() == ImppEnumUtil.MESSAGE_RECEIVER_TYPE.INTERNAL.getValue()) {
@ -106,16 +107,16 @@ public class MessageMailQueueReceiver {
}
//信息已处理
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
LOGGER.error("【MQ-IMPP_MESSAGE_MAIL_QUEUE】处理出错{}",e.getMessage(),e);
LOGGER.error("【MQ-IMPP_MESSAGE_MAIL_QUEUE】处理出错{}", e.getMessage(), e);
//丢弃这条消息
try {
// 未成功处理,重新发送
//channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
//todo 此处对邮件持久化,通过参数设置,是否还需要重复重新发送
// 改为接收成功
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e1) {
e1.printStackTrace();
}

@ -47,6 +47,7 @@ public class ScheduleQueueReceiver {
/**
*
*
* @param logTaskTime
* @param channel
* @param message
@ -54,9 +55,9 @@ public class ScheduleQueueReceiver {
@RabbitListener(queues = PlatformConstWords.IMPP_SCHEDULE_QUEUE)
public void processSchedule(SysLogTaskTime logTaskTime, Channel channel, Message message) {
try {
LOGGER.info("【MQ-IMPP_SCHEDULE_QUEUE】数据接收成功{}",logTaskTime);
LOGGER.info("【MQ-IMPP_SCHEDULE_QUEUE】数据接收成功{}", logTaskTime);
// 跟新最后执行时间 及 任务状态
SysTaskPlan taskPlan = sysTaskPlanService.getSysTaskPlanByNameAndGroup(logTaskTime.getName(),logTaskTime.getGroupName());
SysTaskPlan taskPlan = sysTaskPlanService.getSysTaskPlanByNameAndGroup(logTaskTime.getName(), logTaskTime.getGroupName());
if (taskPlan != null) {
taskPlan.setLastRunDateTime(logTaskTime.getCreateDatetime());
taskPlan.setTaskPlanExecNum(taskPlan.getTaskPlanExecNumValue() + 1);
@ -80,7 +81,7 @@ public class ScheduleQueueReceiver {
sysMessage.setMessageTitle("任务计划失败通知");
sysMessage.setMessageContent(
String.format("<p>管理员 您好:</p><div style=\"text-align:center\">任务计划(Name: %s,GroupName: %s执行失败,详细信息请查看定时任务日志(ID: %s).</div>",
taskPlan.getName(),taskPlan.getGroupName(),logTaskTime.getId())
taskPlan.getName(), taskPlan.getGroupName(), logTaskTime.getId())
);
sysMessage.setMessageContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.HTML.getValue());
sysMessage.setMessageSendTime(TimeTool.getNowTime(true));
@ -90,7 +91,7 @@ public class ScheduleQueueReceiver {
if (CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue() == taskPlan.getIsInternalUser()) {
sysMessage.setMessageReceiverType(ImppEnumUtil.MESSAGE_RECEIVER_TYPE.EXTERNAL.getValue());
sysMessage.setMessageReceiversNameRdd(taskPlan.getNoticeChannel());
}else{
} else {
sysMessage.setMessageReceiverType(ImppEnumUtil.MESSAGE_RECEIVER_TYPE.INTERNAL.getValue());
// 设置收件人名称
String[] messageReceiver = taskPlan.getNoticeChannel().split(",");
@ -101,22 +102,22 @@ public class ScheduleQueueReceiver {
}
// 发送到对应处理队列
if(taskPlan.getNoticeMethod() != null && ImppEnumUtil.MESSAGE_TYPE.MAIL.getValue() == taskPlan.getNoticeMethod().intValue()){
rabbitTemplate.convertAndSend(PlatformConstWords.IMPP_MESSAGE_MAIL_QUEUE,sysMessage);
}else{
rabbitTemplate.convertAndSend(PlatformConstWords.IMPP_MESSAGE_LETTER_QUEUE,sysMessage);
if (taskPlan.getNoticeMethod() != null && ImppEnumUtil.MESSAGE_TYPE.MAIL.getValue() == taskPlan.getNoticeMethod().intValue()) {
rabbitTemplate.convertAndSend(PlatformConstWords.IMPP_MESSAGE_MAIL_QUEUE, sysMessage);
} else {
rabbitTemplate.convertAndSend(PlatformConstWords.IMPP_MESSAGE_LETTER_QUEUE, sysMessage);
}
}
}
//信息已处理
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
LOGGER.error("【MQ-IMPP_MESSAGE_MAIL_QUEUE】处理出错{}",e.getMessage(),e);
LOGGER.error("【MQ-IMPP_MESSAGE_MAIL_QUEUE】处理出错{}", e.getMessage(), e);
//丢弃这条消息
try {
// 未成功处理,重新发送
channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e1) {
e1.printStackTrace();
}

Loading…
Cancel
Save