微服务状态提醒

及部分dashboard
yun-zuoyi
yunhao.wang 6 years ago
parent b524929d7e
commit 2c1088a431

@ -14,89 +14,4 @@
</configuration> </configuration>
</facet> </facet>
</component> </component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="i3plus-pojo-platform" />
<orderEntry type="module" module-name="i3plus-pojo-base" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.0.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.0.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.0.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.0.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.0.7.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.0.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.13" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.0.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.7.9" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.2.17.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.22.0-GA" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss:jandex:2.0.3.Final" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: javax.transaction:javax.transaction-api:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:2.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aspects:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-mongodb:2.0.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver:3.6.4" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:bson:3.6.4" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.6.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:2.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.20" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.20" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.9.2" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.7.11" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.9.2" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.22" level="project" />
<orderEntry type="module" module-name="i3plus-pojo-mes" />
<orderEntry type="module" module-name="i3plus-pojo-model" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-core:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-lang:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-cache:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-crypto-hash:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-crypto-core:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-crypto-cipher:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-config-core:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-config-ogdl:1.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-event:1.4.0" level="project" />
</component>
</module> </module>

@ -3,6 +3,7 @@ package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.SysDepartment; import cn.estsh.i3plus.pojo.platform.bean.SysDepartment;
import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
@ -68,4 +69,11 @@ public interface ISysDepartmentService {
* @return * @return
*/ */
ListPager<SysDepartment> findSysDepartmentByPager(SysDepartment department, Pager pager); ListPager<SysDepartment> findSysDepartmentByPager(SysDepartment department, Pager pager);
/**
*
* @return
*/
@ApiOperation(value = "获取部门数量")
long getSysDepartmentCount();
} }

@ -73,4 +73,12 @@ public interface ISysLogOperateService {
*/ */
@ApiOperation(value = "操作日志复杂查询,分页,排序",notes = "操作日志复杂查询,分页,排序") @ApiOperation(value = "操作日志复杂查询,分页,排序",notes = "操作日志复杂查询,分页,排序")
ListPager<SysLogOperate> querySysLogOperateByPager(SysLogOperate logOperate, Pager pager); ListPager<SysLogOperate> querySysLogOperateByPager(SysLogOperate logOperate, Pager pager);
/**
*
* @param num
* @return
*/
@ApiOperation(value = "查询最新的操作日志")
List<SysLogOperate> findNewSysLogOperate(Integer num);
} }

@ -6,6 +6,7 @@ import cn.estsh.i3plus.pojo.platform.bean.SysLogSystem;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description : * @Description :
@ -30,4 +31,13 @@ public interface ISysLogSystemService {
@ApiOperation(value = "系统日志分页复杂查询",notes = "系统日志分页复杂查询") @ApiOperation(value = "系统日志分页复杂查询",notes = "系统日志分页复杂查询")
ListPager querySysLogSystemByPager(SysLogSystem logSystem, Pager pager); ListPager querySysLogSystemByPager(SysLogSystem logSystem, Pager pager);
/**
*
* @param startTime
* @param endTime
* @return
*/
@ApiOperation(value = "查询时间段内平均请求耗时")
Map<String, Object> queryAvgExecuteTime(String startTime,String endTime);
} }

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
* @Author : wei.peng * @Author : wei.peng
* @Date : 2018-10-22 16:58:42.941 * @Date : 2018-10-22 16:58:42.941
@ -72,4 +72,11 @@ public interface ISysOrganizeService {
* @return * @return
*/ */
SysOrganize getSysOrganizeById(Long id); SysOrganize getSysOrganizeById(Long id);
/**
*
* @return
*/
@ApiOperation(value = "查询组织个数")
long getSysOrganizeCount();
} }

@ -3,6 +3,7 @@ package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.*; import cn.estsh.i3plus.pojo.platform.bean.*;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import java.util.List; import java.util.List;
@ -175,4 +176,11 @@ public interface ISysUserService {
* @param user * @param user
*/ */
void checkSysUserOnly(SysUser user); void checkSysUserOnly(SysUser user);
/**
*
* @return
*/
@ApiOperation(value = "查询账户数量")
long getSysUserCount();
} }

@ -0,0 +1,88 @@
package cn.estsh.i3plus.core.apiservice.controller.busi;
import cn.estsh.i3plus.core.api.iservice.busi.*;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2018-12-10 17:04
* @Modify:
**/
@RestController
@Api(description = "Dashboard服务")
@RequestMapping(PlatformConstWords.BASE_URL + "/dashboard")
public class SysDashboardController {
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysOrganizeService sysOrganizeService;
@Autowired
private ISysDepartmentService sysDepartmentService;
@Autowired
private ISysMessageService sysMessageService;
@Autowired
private ISysLogOperateService sysLogOperateService;
@Autowired
private ISysLogSystemService sysLogSystemService;
// @Autowired
// private EurekaServerContext eurekaServerContext;
@Resource(name="redisRes")
private ImppRedis redisRes;
@GetMapping("/get")
@ApiOperation(value = "获取dashboard数据")
public ResultBean getDashboardData(){
try {
Map<String,Object> dashboardData = (Map<String, Object>) redisRes.getObject(PlatformConstWords.DASHBOARD_REDIS_KEY);
if(dashboardData == null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
String startTime = sdf.format(new Date());
cal.add(Calendar.MINUTE,10);
String endTime = sdf.format(cal.getTime());
dashboardData = new HashMap<>();
dashboardData.put("userNum",sysUserService.getSysUserCount());
dashboardData.put("orgNum",sysOrganizeService.getSysOrganizeCount());
dashboardData.put("deptNum",sysDepartmentService.getSysDepartmentCount());
dashboardData.put("logOperate",sysLogOperateService.findNewSysLogOperate(10));
dashboardData.put("",sysLogSystemService.queryAvgExecuteTime(startTime,endTime));
redisRes.putHashMap(PlatformConstWords.DASHBOARD_REDIS_KEY,dashboardData,1000*60);
}
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultMap(dashboardData);
} catch (
ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -64,8 +64,6 @@ public class SysMessageController extends CoreBaseController {
sysMessage.setMessageSendTime(sdf.format(new Date())); sysMessage.setMessageSendTime(sdf.format(new Date()));
sysMessage.setMessageContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.HTML.getValue()); sysMessage.setMessageContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.HTML.getValue());
ConvertBean.modelInitialize(sysMessage,getSessionUser());
sysMessageService.doSendSysMessage(sysMessage); sysMessageService.doSendSysMessage(sysMessage);
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){ }catch(ImppBusiException busExcep){

@ -0,0 +1,28 @@
package cn.estsh.i3plus.core.apiservice.dao;
import io.swagger.annotations.ApiOperation;
import org.bson.Document;
import java.util.List;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2018-12-11 13:22
* @Modify:
**/
public interface ISysLogSystemDao {
/**
*
* @param startTime
* @param endTime
* @return
*/
@ApiOperation(value = "查询时间段内平均请求耗时")
Map<String,Object> querySysLogOperateAvgExecuteTime(String startTime, String endTime);
}

@ -1,97 +0,0 @@
package cn.estsh.i3plus.core.apiservice.mq;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
import cn.estsh.i3plus.core.apiservice.util.MailUtil;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
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.rabbitmq.client.Channel;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2018-11-15 22:15
* @Modify:
**/
@Component
public class MailQueueReceiver {
private static final Logger LOGGER = LoggerFactory.getLogger(MailQueueReceiver.class);
@Autowired
ISysMessageService sysMessageService;
@Autowired
ISysUserService sysUserService;
@Autowired
MailUtil mailUtil;
/**
*
* @param msg
* @param channel
* @param message
*/
// @RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_MAIL_QUEUE)
public void processImppMail(SysMessage msg, Channel channel, Message message) {
try {
LOGGER.info("【MQ-IMPP_MESSAGE_MAIL_QUEUE】数据接收成功{}",msg);msg = sysMessageService.insertSysMessage(msg);
mailUtil.init();
// 收件人信息
String[] messageReceiver = msg.getMessageReceiversId().split(",");
String[] receiverName = new String[messageReceiver.length];
SysRefUserMessage refUserMessage;
SysUser sysUser;
for (int i = 0; i < messageReceiver.length; i++) {
sysUser = sysUserService.getSysUserById(Long.parseLong(messageReceiver[i]));
receiverName[i] = sysUser.getUserName();
refUserMessage = new SysRefUserMessage();
refUserMessage.setMessageId(msg.getId());
refUserMessage.setMessageTitleRdd(msg.getMessageTitle());
refUserMessage.setMessageTypeRdd(msg.getMessageType());
refUserMessage.setMessageSenderNameRdd(msg.getMessageSenderNameRdd());
refUserMessage.setReceiverId(sysUser.getId());
refUserMessage.setReceiverNameRdd(sysUser.getUserName());
refUserMessage.setMessageStatus(ImppEnumUtil.MESSAGE_STATUS.UNREAD.getValue());
refUserMessage.setReceiverTime(TimeTool.getNowTime(true));
sysMessageService.insertSysRefUserMessage(refUserMessage);
// 发送邮件
mailUtil.setSubject(msg.getMessageTitle());
mailUtil.setContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.valueOfDescription(msg.getMessageContentType()));
mailUtil.setBody(msg.getMessageContent());
mailUtil.setTo(sysUser.getUserEmail());
mailUtil.send();
}
msg.setMessageSenderNameRdd(StringUtils.join(receiverName, ","));
sysMessageService.updateSysMessage(msg);
//信息已处理
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
} catch (IOException e) {
LOGGER.error("【MQ-IMPP_MESSAGE_MAIL_QUEUE】处理出错{}",e.getMessage(),e);
//丢弃这条消息
try {
// 未成功处理,重新发送
channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}

@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -28,8 +29,8 @@ import java.util.List;
* @Modify: * @Modify:
**/ **/
@Component @Component
public class LetterQueueReceiver { public class MessageLetterQueueReceiver {
private static final Logger LOGGER = LoggerFactory.getLogger(LetterQueueReceiver.class); private static final Logger LOGGER = LoggerFactory.getLogger(MessageLetterQueueReceiver.class);
@Autowired @Autowired
ISysMessageService sysMessageService; ISysMessageService sysMessageService;
@ -43,7 +44,7 @@ public class LetterQueueReceiver {
* @param message * @param message
* rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_QUEUE, new SysMessage(....)); * rabbitTemplate.convertAndSend(I3CoreQueueConfig.IMPP_MESSAGE_QUEUE, new SysMessage(....));
*/ */
// @RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_LETTER_QUEUE) @RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_LETTER_QUEUE)
public void processImppMessage(SysMessage msg, Channel channel, Message message) { public void processImppMessage(SysMessage msg, Channel channel, Message message) {
try { try {
LOGGER.info("【MQ-IMPP_MESSAGE_LETTER_QUEUE】数据接收成功{}",msg); LOGGER.info("【MQ-IMPP_MESSAGE_LETTER_QUEUE】数据接收成功{}",msg);

@ -0,0 +1,112 @@
package cn.estsh.i3plus.core.apiservice.mq;
import cn.estsh.i3plus.core.api.iservice.busi.ISysConfigService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
import cn.estsh.i3plus.core.apiservice.util.MailUtil;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
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.rabbitmq.client.Channel;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2018-11-15 22:15
* @Modify:
**/
@Component
public class MessageMailQueueReceiver {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageMailQueueReceiver.class);
@Autowired
ISysMessageService sysMessageService;
@Autowired
ISysUserService sysUserService;
@Autowired
ISysConfigService sysConfigService;
@Autowired
MailUtil mailUtil;
/**
*
* @param msg
* @param channel
* @param message
*/
@RabbitListener(queues = I3CoreQueueConfig.IMPP_MESSAGE_MAIL_QUEUE)
public void processImppMail(SysMessage msg, Channel channel, Message message) {
try {
LOGGER.info("【MQ-IMPP_MESSAGE_MAIL_QUEUE】数据接收成功{}",msg);msg = sysMessageService.insertSysMessage(msg);
mailUtil.init();
// 系统预警邮件与用户邮件判断
if(PlatformConstWords.CONTACT_MAIL.equals(msg.getMessageReceiversId())){
// 发送邮件
mailUtil.setSubject(msg.getMessageTitle());
mailUtil.setContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.valueOfDescription(msg.getMessageContentType()));
mailUtil.setBody(msg.getMessageContent());
mailUtil.setTo(sysConfigService.getSysConfigByCode(PlatformConstWords.CONTACT_MAIL).getConfigValue());
mailUtil.send();
}else {
// 收件人信息
String[] messageReceiver = msg.getMessageReceiversId().split(",");
String[] receiverName = new String[messageReceiver.length];
SysRefUserMessage refUserMessage;
SysUser sysUser;
for (int i = 0; i < messageReceiver.length; i++) {
sysUser = sysUserService.getSysUserById(Long.parseLong(messageReceiver[i]));
receiverName[i] = sysUser.getUserName();
refUserMessage = new SysRefUserMessage();
refUserMessage.setMessageId(msg.getId());
refUserMessage.setMessageTitleRdd(msg.getMessageTitle());
refUserMessage.setMessageTypeRdd(msg.getMessageType());
refUserMessage.setMessageSenderNameRdd(msg.getMessageSenderNameRdd());
refUserMessage.setReceiverId(sysUser.getId());
refUserMessage.setReceiverNameRdd(sysUser.getUserName());
refUserMessage.setMessageStatus(ImppEnumUtil.MESSAGE_STATUS.UNREAD.getValue());
refUserMessage.setReceiverTime(TimeTool.getNowTime(true));
sysMessageService.insertSysRefUserMessage(refUserMessage);
// 发送邮件
mailUtil.setSubject(msg.getMessageTitle());
mailUtil.setContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.valueOfDescription(msg.getMessageContentType()));
mailUtil.setBody(msg.getMessageContent());
mailUtil.setTo(sysUser.getUserEmail());
mailUtil.send();
}
msg.setMessageSenderNameRdd(StringUtils.join(receiverName, ","));
sysMessageService.updateSysMessage(msg);
}
//信息已处理
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
} catch (IOException e) {
LOGGER.error("【MQ-IMPP_MESSAGE_MAIL_QUEUE】处理出错{}",e.getMessage(),e);
//丢弃这条消息
try {
// 未成功处理,重新发送
channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}

@ -202,4 +202,9 @@ public class SysDepartmentService implements ISysDepartmentService {
} }
} }
@Override
public long getSysDepartmentCount() {
return departmentRDao.listCount();
}
} }

@ -4,6 +4,7 @@ import cn.estsh.i3plus.core.api.iservice.busi.ISysLogOperateService;
import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper; import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysLogOperate; import cn.estsh.i3plus.pojo.platform.bean.SysLogOperate;
import cn.estsh.i3plus.pojo.platform.repositorymongo.SysLogOperateRepository; import cn.estsh.i3plus.pojo.platform.repositorymongo.SysLogOperateRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreBsonPack; import cn.estsh.i3plus.pojo.platform.sqlpack.CoreBsonPack;
@ -87,4 +88,15 @@ public class SysLogOperateService implements ISysLogOperateService {
return new ListPager(logOperateRDao.findByBsonPager(bson,pager,logOperate.getOrderByParam(),logOperate.getAscOrDesc()),pager); return new ListPager(logOperateRDao.findByBsonPager(bson,pager,logOperate.getOrderByParam(),logOperate.getAscOrDesc()),pager);
} }
} }
@Override
public List<SysLogOperate> findNewSysLogOperate(Integer num) {
Pager page = new Pager();
page.setCurrentPage(1);
page.setPageSize(num);
SysLogOperate sysLogOperate = new SysLogOperate();
sysLogOperate.setOrderByParam("createDatetime");
sysLogOperate.setAscOrDesc(CommonEnumUtil.ASC_OR_DESC.DESC.getValue());
return logOperateRDao.findByBsonPager(null,page,sysLogOperate.getOrderByParam(),sysLogOperate.getAscOrDesc());
}
} }

@ -1,7 +1,7 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysLogSystemService; import cn.estsh.i3plus.core.api.iservice.busi.ISysLogSystemService;
import cn.estsh.i3plus.core.api.iservice.busi.ISystemResourceService; import cn.estsh.i3plus.core.apiservice.dao.ISysLogSystemDao;
import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper; import cn.estsh.i3plus.pojo.base.common.PagerHelper;
@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description : * @Description :
@ -31,6 +32,8 @@ public class SysLogSystemService implements ISysLogSystemService {
@Autowired @Autowired
private SysLogSystemRepository logSystemRDao; private SysLogSystemRepository logSystemRDao;
@Autowired
private ISysLogSystemDao sysLogSystemDao;
@Override @Override
@ApiOperation(value = "添加系统日志",notes = "添加系统日志") @ApiOperation(value = "添加系统日志",notes = "添加系统日志")
@ -69,4 +72,9 @@ public class SysLogSystemService implements ISysLogSystemService {
,logSystem.getAscOrDesc()),pager); ,logSystem.getAscOrDesc()),pager);
} }
} }
@Override
public Map<String, Object> queryAvgExecuteTime(String startTime, String endTime) {
return sysLogSystemDao.querySysLogOperateAvgExecuteTime(startTime,endTime);
}
} }

@ -17,6 +17,7 @@ import cn.estsh.i3plus.pojo.platform.repository.SysUserRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack; import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum; import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -24,6 +25,8 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**

@ -20,7 +20,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
* @Author : wei.peng * @Author : wei.peng
* @Date : 2018-10-22 16:58:42.957 * @Date : 2018-10-22 16:58:42.957
@ -167,4 +167,9 @@ public class SysOrganizeService implements ISysOrganizeService {
LOGGER.info("组织 ORGANIZE find id:{}", id); LOGGER.info("组织 ORGANIZE find id:{}", id);
return organizeRDao.getById(id); return organizeRDao.getById(id);
} }
@Override
public long getSysOrganizeCount() {
return organizeRDao.listCount();
}
} }

@ -410,6 +410,12 @@ public class SysUserService implements ISysUserService {
} }
} }
@Override
@ApiOperation(value = "查询账户数量")
public long getSysUserCount() {
return sysUserRDao.listCount();
}
/** /**
* *
* *

@ -61,6 +61,17 @@ public class MailUtil {
/** /**
* *
* *
* @param nick
* Email
*/
public void setNick(String nick) {
this.nick = nick;
}
/**
*
*
* @param aEmail * @param aEmail
* Email * Email
*/ */

@ -2,6 +2,7 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysConfigService; import cn.estsh.i3plus.core.api.iservice.busi.ISysConfigService;
import cn.estsh.impp.framework.boot.init.ApplicationProperties; import cn.estsh.impp.framework.boot.init.ApplicationProperties;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
@ -12,6 +13,8 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
@ -31,10 +34,14 @@ public class TestBase {
@Autowired @Autowired
private ISysConfigService sysConfigService; private ISysConfigService sysConfigService;
@Resource(name="redisRes")
private ImppRedis redisRes;
@Before @Before
public void init() { public void init() {
System.out.println("-----------------开始测试-----------------"); System.out.println("-----------------开始测试-----------------");
app.setProfilesActive("unit-test"); app.setProfilesActive("unit-test");
redisRes.multi();
} }
@After @After

@ -0,0 +1,35 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import java.beans.Transient;
import java.util.HashMap;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2018-12-12 22:06
* @Modify:
**/
public class TestRedis extends TestBase {
@Autowired
private ISysMessageService sysMessageService;
@Test
public void testReids(){
// // 放入缓存
// HashMap<String,String> resource = new HashMap<String,String>();
// resource.put("test","test110");
// redisRes.putHashMap("junit3",resource,1000 * 60);
// System.out.println(redisRes.getHashMap("junit3"));
// System.out.println(redisRes.commit());
// System.out.println(redisRes.getHashMap("junit3"));
sysMessageService.insertRedis();
}
}
Loading…
Cancel
Save