优化提交目录

This commit is contained in:
yiyan 2019-04-10 11:30:36 +08:00
parent f411d81a63
commit 977986231b
33 changed files with 15 additions and 240 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.idea
target
**/lib
**/classes

View File

@ -17,6 +17,7 @@ import lombok.extern.log4j.Log4j;
public class DeviceInfoEvent {
/**
* 设备开关设置
* {
* "eventProcess": "updateWarnOnoff",
* "eventName": "com.ifish7.mq.queues.event.DeviceInfoEvent",
@ -25,18 +26,22 @@ public class DeviceInfoEvent {
* "data" : {
* "macAddress" : "5ccf7f006686",
* "onOff" : "0"
* }
* }
* }
* }
* @param eventEntity 事件体
*/
private void updateWarnOnoff(Object eventEntity) {
log.info("DeviceInfoEvent eventEntity : " + eventEntity);
TblDevice device = (TblDevice) eventEntity;
ITblDeviceService deviceService = AppBeans.getBean(TblDeviceServiceImpl.class);
TblDevice tblDevice = deviceService.getOne(new QueryWrapper<TblDevice>().lambda().eq(TblDevice::getMacAddress, device.getMacAddress()));
tblDevice.setOnOff(device.getOnOff());
deviceService.updateById(tblDevice);
try {
TblDevice device = (TblDevice) eventEntity;
ITblDeviceService deviceService = AppBeans.getBean(TblDeviceServiceImpl.class);
TblDevice tblDevice = deviceService.getOne(new QueryWrapper<TblDevice>().lambda().eq(TblDevice::getMacAddress, device.getMacAddress()));
tblDevice.setOnOff(device.getOnOff());
deviceService.updateById(tblDevice);
} catch (Exception e) {
log.info(e.getMessage(),e);
}
}
}

View File

@ -1,58 +0,0 @@
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
#jdbc.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
jdbc.username=ifish
jdbc.password=ifish7pwd
#jdbc.username=root
#jdbc.password=ifish7mysql
#jdbc.testWhileIdle=true
jdbc.validationQuery=SELECT * FROM DUAL
initialSize=1
minIdle=1
maxActive=20
maxWait=60000
timeBetweenEvictionRunsMillis=60000
minEvictableIdleTimeMillis=300000
poolPreparedStatements=true
maxPoolPreparedStatementPerConnectionSize=20
removeAbandonedTimeout=1800
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false
hibernate.format_sql=true
hibernate.hbm2ddl.auto=false
hibernate.jdbc.batch_size=50
hibernate.query.substitutions=true 1,false 0
#c3p0.driverClassName=com.mysql.jdbc.Driver
#c3p0.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
#c3p0.username=ifish
#c3p0.password=ifish7pwd
##c3p0.username=root
##c3p0.password=123456
#
#c3p0.autoCommitOnClose=true
#c3p0.initialPoolSize=20
#c3p0.minPoolSize=20
#c3p0.maxPoolSize=50
#c3p0.acquireIncrement=3
#
#c3p0.checkoutTimeout=5000
#c3p0.maxIdleTime=7200
#c3p0.idleConnectionTestPeriod=18000
##c3p0.maxIdleTimeExcessConnections=1800
#
##c3p0.automaticTestTable=C3P0TestTable
##c3p0.testConnectionOnCheckout=false
##c3p0.testConnectionOnCheckin=false
#
##org.hibernate.dialect.MySQLInnoDBDialect
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
#hibernate.show_sql=false
#hibernate.format_sql=true
#hibernate.hbm2ddl.auto=false
#hibernate.jdbc.batch_size=50
#hibernate.query.substitutions=true 1,false 0

View File

@ -1,18 +0,0 @@
log4j.rootLogger=INFO,Console,File
#\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
#\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n
#\u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6
log4j.appender.File = org.apache.log4j.RollingFileAppender
#\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55
log4j.appender.File.File = logs/dnkx.log
#\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F
log4j.appender.File.MaxFileSize = 10MB
#\u8F93\u51FA\u6240\u4EE5\u65E5\u5FD7\uFF0C\u5982\u679C\u6362\u6210DEBUG\u8868\u793A\u8F93\u51FADEBUG\u4EE5\u4E0A\u7EA7\u522B\u65E5\u5FD7
log4j.appender.File.Threshold = ALL
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n

View File

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.14.1.xsd">
<context:component-scan base-package="com.ifish7.mq.activemq" />
<amq:connectionFactory id="amqConnectionFactory"
brokerURL="tcp://localhost:61616"
userName="admin"
password="admin" />
<!-- 配置JMS连接工长 -->
<bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg ref="amqConnectionFactory" />
<property name="sessionCacheSize" value="100" />
</bean>
<!-- 定义消息队列Queue -->
<bean id="dnkxQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
<!-- 设置消息队列的名字 -->
<constructor-arg>
<value>dnkxmq</value>
</constructor-arg>
</bean>
<!-- 配置JMS模板QueueSpring提供的JMS工具类它发送、接收消息。 -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultDestination" ref="dnkxQueueDestination" />
<property name="receiveTimeout" value="10000" />
<!-- true是topicfalse是queue默认是false此处显示写出false -->
<property name="pubSubDomain" value="false" />
</bean>
<!-- 配置消息队列监听者Queue -->
<bean id="queueMessageListener" class="com.ifish7.mq.activemq.listener.QueueMessageListener" />
<!-- 显示注入消息监听容器Queue配置连接工厂监听的目标是demoQueueDestination监听器是上面定义的监听器 -->
<bean id="queueListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="dnkxQueueDestination" />
<property name="messageListener" ref="queueMessageListener" />
</bean>
</beans>

View File

@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 自动扫描 -->
<context:component-scan base-package="com.ifish7.mq.data">
<!-- 这里要把controler下面的 controller去除他们是在spring-mvc.xml中配置的如果不去除会影响事务管理的。 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 引入配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties" />
</bean>
<bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- 初始化连接大小 -->
<property name="initialSize" value="${initialSize}" />
<!-- 连接池最大使用连接数量 -->
<property name="maxActive" value="${maxActive}" />
<!-- 连接池最小空闲 -->
<property name="minIdle" value="${minIdle}" />
<!-- 获取连接最大等待时间 -->
<property name="maxWait" value="${maxWait}" />
<property name="poolPreparedStatements" value="${poolPreparedStatements}" />
<property name="maxPoolPreparedStatementPerConnectionSize"
value="${maxPoolPreparedStatementPerConnectionSize}" />
<!-- 用来检测有效sql -->
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="testWhileIdle" value="true" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis}" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis}" />
<!-- 打开removeAbandoned功能 -->
<property name="removeAbandoned" value="true" />
<!-- 1800秒也就是30分钟 -->
<property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}" />
<!-- 关闭abanded连接时输出错误日志 -->
<property name="logAbandoned" value="true" />
<!-- 监控数据库 -->
<property name="filters" value="mergeStat" />
</bean>
<!-- spring和MyBatis完美整合不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mapping.xml文件 -->
<property name="mapperLocations" value="classpath:com/ifish7/mq/data/mapping/*.xml"></property>
</bean>
<!-- DAO接口所在包名Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.dnkx.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- 这个标记,主要是这里用的是注解事务 -->
<!-- <tx:annotation-driven transaction-manager="transactionManager" /> -->
<!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 启动对@AspectJ注解的支持 -->
<!-- <aop:aspectj-autoproxy/> -->
<aop:config>
<!-- 定义切点 -->
<aop:pointcut id="allServiceMethods" expression="execution(* com.ifish7.mq.data.*.service.impl.*.*(..))"/>
<!-- 植入切面通知(增强处理) -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethods"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="load*" read-only="true"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
</beans>