Initial commit

This commit is contained in:
易焱
2019-06-01 23:03:25 +08:00
commit cbfa434a27
46 changed files with 2489 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
.idea
target
**/lib
**/classes
+83
View File
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</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" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-push:3.10.1" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-core:4.4.2" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.8" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.11" level="project" />
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.1" level="project" />
<orderEntry type="library" name="Maven: javax.xml.stream:stax-api:1.0-2" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: org.jacoco:org.jacoco.agent:runtime:0.8.3" level="project" />
<orderEntry type="library" name="Maven: org.ini4j:ini4j:0.5.4" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.activemq:activemq-all:5.15.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jms:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.xbean:xbean-spring:3.16" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.5" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.3.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.6.2" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-generator:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:1.4" level="project" />
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.28" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid:1.1.6" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.4" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.56" level="project" />
</component>
</module>
View File
+1
View File
@@ -0,0 +1 @@
[ifishTasks][DEBUG] [2019-06-01 12:26:38][com.baomidou.mybatisplus.generator.AutoGenerator]==========================文件生成完成!!!==========================
+287
View File
@@ -0,0 +1,287 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ifish7</groupId>
<artifactId>ifishTasks</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>ifish7.ifishTasks Webapp</name>
<properties>
<java.version>1.8</java.version>
<java.encoding>UTF-8</java.encoding>
<spring.version>5.0.8.RELEASE</spring.version>
<mybatis.version>3.4.5</mybatis.version>
<mybatis-spring.version>1.3.2</mybatis-spring.version>
<log4j.version>1.2.17</log4j.version>
<activemq.version>5.15.4</activemq.version>
<lombok.version>1.18.6</lombok.version>
<fastjson.version>1.2.56</fastjson.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.0.8.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<!-- 阿里云推送 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-push</artifactId>
<version>3.10.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>[4.3.2,5.0.0)</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<!-- Active MQ -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>${activemq.version}</version>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 提供JMSFreemarker,Quartz集成服务 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 集成JMS -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- mybatis 包 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<!--mybatis spring 插件 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis-spring.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<!-- mybaits-plus 插件 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.0</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
<!-- 数据源 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.4</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!-- apache 支持包 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<!-- json 解析器 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
</dependencies>
<build>
<finalName>ifishTasks</finalName>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<!-- 测试资源 -->
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>${basedir}/src/main/webapp</webappDirectory>
<warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${java.encoding}</encoding>
</configuration>
</plugin>
<!-- 跳过测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,98 @@
package com.ifish7.tasks.business.device.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
@Data
@Accessors(chain = true)
@TableName("tbl_device")
public class TblDevice{
private static final long serialVersionUID = 1L;
@TableId(value = "device_id", type = IdType.AUTO)
private Integer deviceId;
private String serverIp;
private String deviceIp;
private String macAddress;
private Integer loginCount;
private LocalDateTime loginTime;
private String isBlacklist;
private LocalDateTime firstActivate;
private LocalDateTime createTime;
private String hardwareType;
private String softwareVersion;
private String onOff;
private String todayRemind;
private String waterRemind;
private LocalDate remindDate;
private Integer remindCycle;
private String factoryCode;
private String brandCode;
private Integer sdkVersion;
private LocalDate sdkTime;
private LocalDate createDate;
private String isUpgrade;
private Integer upgradeVersion;
private LocalDateTime upgradeTime;
private LocalDateTime authorizeTime;
private String createCode;
private String isCharge;
private Integer number1;
private Integer number2;
private Integer number3;
private Integer number4;
private Integer number5;
/**
* 收费时间
*/
private LocalDateTime chargeTime;
}
@@ -0,0 +1,56 @@
package com.ifish7.tasks.business.device.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
@Data
@Accessors(chain = true)
@TableName("tbl_device_heater")
public class TblDeviceHeater {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId(value = "heater_id", type = IdType.AUTO)
private Integer heaterId;
/**
* mac 地址
*/
private String heaterMacAddress;
/**
* 水温
*/
private String heaterWaterTemperature;
/**
* 水流量
*/
private String heaterPh;
/**
* 数据采集时间
*/
private String heaterGatheringTime;
/**
* 日期
*/
private String heaterGatheringDate;
}
@@ -0,0 +1,71 @@
package com.ifish7.tasks.business.device.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
@Data
@Accessors(chain = true)
@TableName("tbl_device_heater_detail")
public class TblDeviceHeaterDetail{
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "heater_id", type = IdType.AUTO)
private Integer heaterId;
/**
* Mac地址
*/
private String heaterMacAddress;
/**
* 鱼缸体积
*/
private String heaterVolume;
/**
* 长
*/
private String heaterLong;
/**
* 宽
*/
private String heaterWidth;
/**
* 高
*/
private String heaterHeight;
/**
* 换水周期
*/
private String heaterCycle;
/**
* 提醒时间
*/
private String heaterReminderTime;
/**
* 提醒日期
*/
private String herterRemindDate;
}
@@ -0,0 +1,41 @@
package com.ifish7.tasks.business.device.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
@Data
@Accessors(chain = true)
@TableName("tbl_device_user")
public class TblDeviceUser{
private static final long serialVersionUID = 1L;
private Integer userId;
private Integer deviceId;
private String isMaster;
private String showName;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private String customIconName;
private String customShowName;
}
@@ -0,0 +1,47 @@
package com.ifish7.tasks.business.device.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDate;
/**
* <p>
*
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
@Data
@Accessors(chain = true)
@TableName("tbl_tmp_push_remind")
public class TblTmpPushRemind {
private static final long serialVersionUID = 1L;
@TableId(value = "device_id", type = IdType.NONE)
private Integer deviceId;
@TableId(value = "device_id", type = IdType.NONE)
private Integer userId;
private String phoneNumber;
private String macAddress;
private String showName;
private String loginType;
private LocalDate remindDate;
private Integer remindCycle;
private String isPush;
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.mapper;
import com.ifish7.tasks.business.device.entity.TblDeviceHeaterDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
public interface TblDeviceHeaterDetailMapper extends BaseMapper<TblDeviceHeaterDetail> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.mapper;
import com.ifish7.tasks.business.device.entity.TblDeviceHeater;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
public interface TblDeviceHeaterMapper extends BaseMapper<TblDeviceHeater> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.mapper;
import com.ifish7.tasks.business.device.entity.TblDevice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
public interface TblDeviceMapper extends BaseMapper<TblDevice> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.mapper;
import com.ifish7.tasks.business.device.entity.TblDeviceUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
public interface TblDeviceUserMapper extends BaseMapper<TblDeviceUser> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.mapper;
import com.ifish7.tasks.business.device.entity.TblTmpPushRemind;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
public interface TblTmpPushRemindMapper extends BaseMapper<TblTmpPushRemind> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.service;
import com.ifish7.tasks.business.device.entity.TblDeviceHeaterDetail;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
public interface ITblDeviceHeaterDetailService extends IService<TblDeviceHeaterDetail> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.service;
import com.ifish7.tasks.business.device.entity.TblDeviceHeater;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
public interface ITblDeviceHeaterService extends IService<TblDeviceHeater> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.service;
import com.ifish7.tasks.business.device.entity.TblDevice;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
public interface ITblDeviceService extends IService<TblDevice> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.service;
import com.ifish7.tasks.business.device.entity.TblDeviceUser;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
public interface ITblDeviceUserService extends IService<TblDeviceUser> {
}
@@ -0,0 +1,16 @@
package com.ifish7.tasks.business.device.service;
import com.ifish7.tasks.business.device.entity.TblTmpPushRemind;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
public interface ITblTmpPushRemindService extends IService<TblTmpPushRemind> {
}
@@ -0,0 +1,20 @@
package com.ifish7.tasks.business.device.service.impl;
import com.ifish7.tasks.business.device.entity.TblDeviceHeaterDetail;
import com.ifish7.tasks.business.device.mapper.TblDeviceHeaterDetailMapper;
import com.ifish7.tasks.business.device.service.ITblDeviceHeaterDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
@Service
public class TblDeviceHeaterDetailServiceImpl extends ServiceImpl<TblDeviceHeaterDetailMapper, TblDeviceHeaterDetail> implements ITblDeviceHeaterDetailService {
}
@@ -0,0 +1,20 @@
package com.ifish7.tasks.business.device.service.impl;
import com.ifish7.tasks.business.device.entity.TblDeviceHeater;
import com.ifish7.tasks.business.device.mapper.TblDeviceHeaterMapper;
import com.ifish7.tasks.business.device.service.ITblDeviceHeaterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
@Service
public class TblDeviceHeaterServiceImpl extends ServiceImpl<TblDeviceHeaterMapper, TblDeviceHeater> implements ITblDeviceHeaterService {
}
@@ -0,0 +1,20 @@
package com.ifish7.tasks.business.device.service.impl;
import com.ifish7.tasks.business.device.entity.TblDevice;
import com.ifish7.tasks.business.device.mapper.TblDeviceMapper;
import com.ifish7.tasks.business.device.service.ITblDeviceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author yan.y
* @since 2019-04-09
*/
@Service
public class TblDeviceServiceImpl extends ServiceImpl<TblDeviceMapper, TblDevice> implements ITblDeviceService {
}
@@ -0,0 +1,20 @@
package com.ifish7.tasks.business.device.service.impl;
import com.ifish7.tasks.business.device.entity.TblDeviceUser;
import com.ifish7.tasks.business.device.mapper.TblDeviceUserMapper;
import com.ifish7.tasks.business.device.service.ITblDeviceUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
@Service
public class TblDeviceUserServiceImpl extends ServiceImpl<TblDeviceUserMapper, TblDeviceUser> implements ITblDeviceUserService {
}
@@ -0,0 +1,20 @@
package com.ifish7.tasks.business.device.service.impl;
import com.ifish7.tasks.business.device.entity.TblTmpPushRemind;
import com.ifish7.tasks.business.device.mapper.TblTmpPushRemindMapper;
import com.ifish7.tasks.business.device.service.ITblTmpPushRemindService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author yan.y
* @since 2019-06-01
*/
@Service
public class TblTmpPushRemindServiceImpl extends ServiceImpl<TblTmpPushRemindMapper, TblTmpPushRemind> implements ITblTmpPushRemindService {
}
@@ -0,0 +1,33 @@
package com.ifish7.tasks.business.enums;
public enum PushTypeEnum {
remove_device("remove_device","解除设备"),
wendu_warn("wendu_warn","温度报警"),
qu_reply("qu_reply","问题反馈"),
app_update("app_update","IOS更新推送"),
remind_water("remind_water","换水提醒"),
offline_push("offline_push","设备离线推送");
private PushTypeEnum(String key, String value){
this.key = key;
this.value = value;
}
private String key;
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -0,0 +1,50 @@
package com.ifish7.tasks.business.event;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName: tbl_push_list
* @date 2015年7月2日 下午16:40:00
*
*/
@Data
public class PushList implements Serializable{
private static final long serialVersionUID = -6718129027121198763L;
//ID
private Integer pushId;
//用户ID
private Integer userId;
//设备ID
private Integer deviceId;
//推送手机类型
private String phoneType;
//显示名称
private String showName;
//推送消息类型
private String pushType;
//推送标题
private String pushTitle;
//推送内容
private String pushContext;
//极光推送状态
private String jpushStatus;
//云信推送状态
private String neteaseStatus;
//创建时间
private Date createTime;
//MCU启动次数
private Integer number1;
//模块启动次数
private Integer number2;
//连接路由器次数
private Integer number3;
//成功连接服务器次数
private Integer number4;
//尝试连接服务器次数
private Integer number5;
}
@@ -0,0 +1,37 @@
package com.ifish7.tasks.business.event;
import com.alibaba.fastjson.JSONObject;
/**
* @author: yan.y
* @Description:
* @Date: Created in 16:58 2019-04-10
* @Modified by:
*/
public class QueueEventBody {
public QueueEventBody(String entity, JSONObject data) {
this.entity = entity;
this.data = data;
}
private String entity;
private JSONObject data;
public String getEntity() {
return entity;
}
public void setEntity(String entity) {
this.entity = entity;
}
public JSONObject getData() {
return data;
}
public void setData(JSONObject data) {
this.data = data;
}
}
@@ -0,0 +1,40 @@
package com.ifish7.tasks.business.event;
/**
* @author: yan.y
* @Description:
* @Date: Created in 16:46 2019-04-10
* @Modified by:
*/
public class QueueEventEntity {
private String eventProcess;
private String eventName;
private QueueEventBody eventBody;
public String getEventProcess() {
return eventProcess;
}
public void setEventProcess(String eventProcess) {
this.eventProcess = eventProcess;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public QueueEventBody getEventBody() {
return eventBody;
}
public void setEventBody(QueueEventBody eventBody) {
this.eventBody = eventBody;
}
}
@@ -0,0 +1,29 @@
package com.ifish7.tasks.execption;
/**
* @author: yan.y
* @Description:
* @Date: Created in 14:03 2019-04-10
* @Modified by:
*/
public class TasksExecption extends Exception {
public TasksExecption() {
super();
}
public TasksExecption(String message) {
super(message);
}
public TasksExecption(String message, Throwable cause) {
super(message, cause);
}
public TasksExecption(Throwable cause) {
super(cause);
}
protected TasksExecption(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
@@ -0,0 +1,19 @@
package com.ifish7.tasks.job;
/**
* @author: yan.y
* @Description:
* @Date: Created in 12:30 2019/6/1
*/
public interface RemindJob {
/**
* 通用设备换水提醒
*/
void commDeviceChangeWater();
/**
* 加热器换水提醒
*/
void heaterDeviceChangeWater();
}
@@ -0,0 +1,151 @@
package com.ifish7.tasks.job.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ifish7.tasks.business.device.entity.TblDevice;
import com.ifish7.tasks.business.device.entity.TblDeviceHeaterDetail;
import com.ifish7.tasks.business.device.entity.TblDeviceUser;
import com.ifish7.tasks.business.device.entity.TblTmpPushRemind;
import com.ifish7.tasks.business.device.service.ITblDeviceHeaterDetailService;
import com.ifish7.tasks.business.device.service.ITblDeviceService;
import com.ifish7.tasks.business.device.service.ITblDeviceUserService;
import com.ifish7.tasks.business.device.service.ITblTmpPushRemindService;
import com.ifish7.tasks.business.enums.PushTypeEnum;
import com.ifish7.tasks.business.event.PushList;
import com.ifish7.tasks.business.event.QueueEventBody;
import com.ifish7.tasks.business.event.QueueEventEntity;
import com.ifish7.tasks.job.RemindJob;
import com.ifish7.tasks.utils.IfishTaskUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.jms.Destination;
import javax.jms.Session;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author: yan.y
* @Description:
* @Date: Created in 12:41 2019/6/1
*/
@Component
public class RemindJobImpl implements RemindJob {
private static final Logger log = LoggerFactory.getLogger(RemindJobImpl.class);
@Autowired
private JmsTemplate jmsTemplate;
@Autowired
private Destination ifish7PushQueueDestination;
@Autowired
private ITblDeviceHeaterDetailService deviceHeaterDetailService;
@Autowired
private ITblDeviceUserService deviceUserService;
@Autowired
private ITblTmpPushRemindService tmpPushRemindService;
@Autowired
private ITblDeviceService deviceService;
private final String pushContent = "【换水提醒】您的水族箱需要换水啦~您可以在水箱设置中更改提醒设置";
@Scheduled(cron = "0 0 10 * * ?")
@Override
public void commDeviceChangeWater() {
log.info("RemindJobImpl - commDeviceChangeWater --> begin");
List<TblTmpPushRemind> list = tmpPushRemindService.list(new QueryWrapper<TblTmpPushRemind>().lambda()
.eq(TblTmpPushRemind::getIsPush, 0)
.eq(TblTmpPushRemind::getRemindDate, LocalDate.now()));
final PushList pushList = new PushList();
list.forEach(tblTmpPushRemind -> {
pushList.setUserId(tblTmpPushRemind.getUserId());
pushList.setDeviceId(tblTmpPushRemind.getDeviceId());
pushList.setPhoneType("ALL");
pushList.setShowName(tblTmpPushRemind.getShowName());
pushList.setPushType(PushTypeEnum.remind_water.getKey());
pushList.setPushTitle(PushTypeEnum.remind_water.getValue());
pushList.setPushContext(pushContent);
sendPushQueueMessage(pushList);
//更新换水提醒下次时间
Date nextRemindDate = nextRemindDate(tblTmpPushRemind.getRemindCycle());
Instant instant = nextRemindDate.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
tblTmpPushRemind.setRemindDate(instant.atZone(zoneId).toLocalDate());
tmpPushRemindService.saveOrUpdate(tblTmpPushRemind);
});
log.info("RemindJobImpl - commDeviceChangeWater --> end");
}
@Scheduled(cron = "0 0 10 * * ?")
@Override
public void heaterDeviceChangeWater() {
String nowDate = IfishTaskUtil.format(new Date());
log.info("RemindJobImpl - heaterDeviceChangeWater --> begin");
List<TblDeviceHeaterDetail> list = deviceHeaterDetailService.list(new QueryWrapper<TblDeviceHeaterDetail>().lambda()
.eq(TblDeviceHeaterDetail::getHerterRemindDate, nowDate));
final PushList pushList = new PushList();
list.forEach(tblDeviceHeaterDetail -> {
String macAddress = tblDeviceHeaterDetail.getHeaterMacAddress();
//根据MAC地址查询出设备信息
TblDevice device = deviceService.getOne(new QueryWrapper<TblDevice>().lambda()
.eq(TblDevice::getMacAddress, macAddress));
//根据设备ID查询出用户所对应的设备
List<TblDeviceUser> deviceUsers = deviceUserService.list(new QueryWrapper<TblDeviceUser>().lambda()
.eq(TblDeviceUser::getDeviceId, device.getDeviceId()));
deviceUsers.forEach(deviceUser -> {
pushList.setUserId(deviceUser.getUserId());
pushList.setDeviceId(deviceUser.getDeviceId());
pushList.setPhoneType("ALL");
pushList.setShowName(deviceUser.getShowName());
pushList.setPushType(PushTypeEnum.remind_water.getKey());
pushList.setPushTitle(PushTypeEnum.remind_water.getValue());
pushList.setPushContext(pushContent);
sendPushQueueMessage(pushList);
});
Date date = nextRemindDate(Integer.parseInt(tblDeviceHeaterDetail.getHeaterCycle()));
String nextRemindDate = IfishTaskUtil.format(date);
//更新下次提醒时间
tblDeviceHeaterDetail.setHerterRemindDate(nextRemindDate);
deviceHeaterDetailService.updateById(tblDeviceHeaterDetail);
});
log.info("RemindJobImpl - heaterDeviceChangeWater --> end");
}
/**
* 设置下次提醒日期
* @param remindCycle
* @return
*/
private Date nextRemindDate(Integer remindCycle){
//设置下次提醒日期
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH) + remindCycle);
return calendar.getTime();
}
/**
* 推送Push消息队列
* @param pushList 内容
*/
private void sendPushQueueMessage(final PushList pushList) {
JSONObject data = JSON.parseObject(JSON.toJSONString(pushList));
QueueEventEntity eventEntity = new QueueEventEntity();
eventEntity.setEventName("com.ifish7.mq.queues.event.PushNotifcationEvent");
eventEntity.setEventProcess("deviceNotifcationPlus");
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.user.entity.TblPushList",data);
eventEntity.setEventBody(eventBody);
String json = JSONObject.toJSONString(eventEntity);
log.info("sendPushQueueMessage : {}",json);
jmsTemplate.send(ifish7PushQueueDestination,(Session session) -> session.createTextMessage(json));
}
}
@@ -0,0 +1,28 @@
package com.ifish7.tasks.utils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* @author: yan.y
* @Description: 获取spring管理的bean
* @Date: Created in 22:13 2019/4/9
*/
public class AppBeans implements ApplicationContextAware {
private static ApplicationContext app;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
AppBeans.app = applicationContext;
}
public static <T> T getBean(Class<T> clazz){
if (app == null)
return null;
else
return app.getBean(clazz);
}
}
@@ -0,0 +1,26 @@
package com.ifish7.tasks.utils;
import org.apache.commons.lang3.StringUtils;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author: yan.y
* @Description:
* @Date: Created in 12:57 2019/6/1
*/
public class IfishTaskUtil extends StringUtils {
/**
* 格式化日期 yyyy-MM-dd
* @param date
* @return
*/
public static String format(Date date){
Format format = new SimpleDateFormat("yyyy-MM-dd");
return format.format(date);
}
}
@@ -0,0 +1,126 @@
package com.ifish7.tasks.utils;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* @author: yan.y
* @Description: mybatis代码生成
* @Date: Created in 20:30 2019/4/9
*/
public class MybatisCodeGenerator {
/**
* <p>
* 读取控制台内容
* </p>
*/
public static String scanner(String tip) {
Scanner scanner = new Scanner(System.in);
StringBuilder help = new StringBuilder();
help.append("请输入" + tip + "");
System.out.println(help.toString());
if (scanner.hasNext()) {
String ipt = scanner.next();
if (StringUtils.isNotEmpty(ipt)) {
return ipt;
}
}
throw new MybatisPlusException("请输入正确的" + tip + "");
}
public static void main(String[] args) {
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + "/src/main/java");
gc.setAuthor("yan.y");
gc.setOpen(false);
// gc.setSwagger2(true); 实体属性 Swagger2 注解
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl("jdbc:mysql://139.196.24.156:3306/myfishdb?useUnicode=true&useSSL=false&characterEncoding=utf8");
// dsc.setSchemaName("public");
dsc.setDriverName("com.mysql.jdbc.Driver");
dsc.setUsername("root");
dsc.setPassword("ifish7mysql");
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setModuleName(scanner("模块名"));
pc.setParent("com.ifish7.tasks.business");
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
// to do nothing
}
};
// 如果模板引擎是 freemarker
String templatePath = "/templates/mapper.xml.ftl";
// 如果模板引擎是 velocity
// String templatePath = "/templates/mapper.xml.vm";
// 自定义输出配置
List<FileOutConfig> focList = new ArrayList<>();
// 自定义配置会被优先输出
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
// 配置模板
TemplateConfig templateConfig = new TemplateConfig();
// 配置自定义输出模板
//指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
// templateConfig.setEntity("templates/entity2.java");
// templateConfig.setService();
// templateConfig.setController();
templateConfig.setXml(null);
mpg.setTemplate(templateConfig);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setSuperEntityClass("com.baomidou.ant.common.BaseEntity");
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
strategy.setSuperEntityColumns("id");
strategy.setControllerMappingHyphenStyle(true);
strategy.setTablePrefix(pc.getModuleName() + "_");
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute();
}
}
@@ -0,0 +1,682 @@
/*
* Copyright (c) 2011-2019, hubin (jobob@qq.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.ifish7.tasks.utils;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder;
import com.baomidou.mybatisplus.core.MybatisXMLConfigBuilder;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory;
import com.baomidou.mybatisplus.extension.handlers.EnumTypeHandler;
import com.baomidou.mybatisplus.extension.toolkit.AopUtils;
import com.baomidou.mybatisplus.extension.toolkit.JdbcUtils;
import com.baomidou.mybatisplus.extension.toolkit.PackageHelper;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import lombok.Setter;
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.cache.Cache;
import org.apache.ibatis.executor.ErrorContext;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.io.VFS;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.type.TypeHandler;
import org.apache.ibatis.type.TypeHandlerRegistry;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.NestedIOException;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import org.springframework.util.ClassUtils;
import javax.sql.DataSource;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Stream;
import static org.springframework.util.Assert.notNull;
import static org.springframework.util.Assert.state;
import static org.springframework.util.ObjectUtils.isEmpty;
import static org.springframework.util.StringUtils.hasLength;
import static org.springframework.util.StringUtils.tokenizeToStringArray;
/**
* 拷贝类 {@link SqlSessionFactoryBean} 修改方法 buildSqlSessionFactory() 加载自定义
* <p>MybatisXmlConfigBuilder</p>
*
* @author hubin
* @since 2017-01-04
*/
public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFactory>, InitializingBean, ApplicationListener<ApplicationEvent> {
private static final Logger LOGGER = LoggerFactory.getLogger(MybatisSqlSessionFactoryBean.class);
private static final ResourcePatternResolver RESOURCE_PATTERN_RESOLVER = new PathMatchingResourcePatternResolver();
private static final MetadataReaderFactory METADATA_READER_FACTORY = new CachingMetadataReaderFactory();
private Resource configLocation;
private MybatisConfiguration configuration;
private Resource[] mapperLocations;
private DataSource dataSource;
private TransactionFactory transactionFactory;
private Properties configurationProperties;
private SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new MybatisSqlSessionFactoryBuilder();
private SqlSessionFactory sqlSessionFactory;
//EnvironmentAware requires spring 3.1
private String environment = MybatisSqlSessionFactoryBean.class.getSimpleName();
private boolean failFast;
private Interceptor[] plugins;
private TypeHandler<?>[] typeHandlers;
private String typeHandlersPackage;
private Class<?>[] typeAliases;
private String typeAliasesPackage;
private Class<?> typeAliasesSuperType;
//issue #19. No default provider.
private DatabaseIdProvider databaseIdProvider;
private Class<? extends VFS> vfs;
private Cache cache;
private ObjectFactory objectFactory;
private ObjectWrapperFactory objectWrapperFactory;
// TODO 自定义枚举包
@Setter
private String typeEnumsPackage;
// TODO 自定义全局配置
@Setter
private GlobalConfig globalConfig;
/**
* Sets the ObjectFactory.
*
* @param objectFactory a custom ObjectFactory
* @since 1.1.2
*/
public void setObjectFactory(ObjectFactory objectFactory) {
this.objectFactory = objectFactory;
}
/**
* Sets the ObjectWrapperFactory.
*
* @param objectWrapperFactory a specified ObjectWrapperFactory
* @since 1.1.2
*/
public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) {
this.objectWrapperFactory = objectWrapperFactory;
}
/**
* Gets the DatabaseIdProvider
*
* @return a specified DatabaseIdProvider
* @since 1.1.0
*/
public DatabaseIdProvider getDatabaseIdProvider() {
return databaseIdProvider;
}
/**
* Sets the DatabaseIdProvider.
* As of version 1.2.2 this variable is not initialized by default.
*
* @param databaseIdProvider a DatabaseIdProvider
* @since 1.1.0
*/
public void setDatabaseIdProvider(DatabaseIdProvider databaseIdProvider) {
this.databaseIdProvider = databaseIdProvider;
}
/**
* Gets the VFS.
*
* @return a specified VFS
*/
public Class<? extends VFS> getVfs() {
return this.vfs;
}
/**
* Sets the VFS.
*
* @param vfs a VFS
*/
public void setVfs(Class<? extends VFS> vfs) {
this.vfs = vfs;
}
/**
* Gets the Cache.
*
* @return a specified Cache
*/
public Cache getCache() {
return this.cache;
}
/**
* Sets the Cache.
*
* @param cache a Cache
*/
public void setCache(Cache cache) {
this.cache = cache;
}
/**
* Mybatis plugin list.
*
* @param plugins list of plugins
* @since 1.0.1
*/
public void setPlugins(Interceptor[] plugins) {
this.plugins = plugins;
}
/**
* Packages to search for type aliases.
*
* <p>Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.model}.
*
* @param typeAliasesPackage package to scan for domain objects
* @since 1.0.1
*/
public void setTypeAliasesPackage(String typeAliasesPackage) {
this.typeAliasesPackage = typeAliasesPackage;
}
/**
* Super class which domain objects have to extend to have a type alias created.
* No effect if there is no package to scan configured.
*
* @param typeAliasesSuperType super class for domain objects
* @since 1.1.2
*/
public void setTypeAliasesSuperType(Class<?> typeAliasesSuperType) {
this.typeAliasesSuperType = typeAliasesSuperType;
}
/**
* Packages to search for type handlers.
*
* <p>Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.typehandler}.
*
* @param typeHandlersPackage package to scan for type handlers
* @since 1.0.1
*/
public void setTypeHandlersPackage(String typeHandlersPackage) {
this.typeHandlersPackage = typeHandlersPackage;
}
/**
* Set type handlers. They must be annotated with {@code MappedTypes} and optionally with {@code MappedJdbcTypes}
*
* @param typeHandlers Type handler list
* @since 1.0.1
*/
public void setTypeHandlers(TypeHandler<?>[] typeHandlers) {
this.typeHandlers = typeHandlers;
}
/**
* List of type aliases to register. They can be annotated with {@code Alias}
*
* @param typeAliases Type aliases list
* @since 1.0.1
*/
public void setTypeAliases(Class<?>[] typeAliases) {
this.typeAliases = typeAliases;
}
/**
* If true, a final check is done on Configuration to assure that all mapped
* statements are fully loaded and there is no one still pending to resolve
* includes. Defaults to false.
*
* @param failFast enable failFast
* @since 1.0.1
*/
public void setFailFast(boolean failFast) {
this.failFast = failFast;
}
/**
* Set the location of the MyBatis {@code SqlSessionFactory} config file. A typical value is
* "WEB-INF/mybatis-configuration.xml".
*
* @param configLocation a location the MyBatis config file
*/
public void setConfigLocation(Resource configLocation) {
this.configLocation = configLocation;
}
/**
* Set a customized MyBatis configuration.
* TODO 这里的入参使用 MybatisConfiguration 而不是 Configuration
*
* @param configuration MyBatis configuration
* @since 1.3.0
*/
public void setConfiguration(MybatisConfiguration configuration) {
this.configuration = configuration;
}
/**
* Set locations of MyBatis mapper files that are going to be merged into the {@code SqlSessionFactory}
* configuration at runtime.
* <p>
* This is an alternative to specifying "&lt;sqlmapper&gt;" entries in an MyBatis config file.
* This property being based on Spring's resource abstraction also allows for specifying
* resource patterns here: e.g. "classpath*:sqlmap/*-mapper.xml".
*
* @param mapperLocations location of MyBatis mapper files
*/
public void setMapperLocations(Resource[] mapperLocations) {
this.mapperLocations = mapperLocations;
}
/**
* Set optional properties to be passed into the SqlSession configuration, as alternative to a
* {@code &lt;properties&gt;} tag in the configuration xml file. This will be used to
* resolve placeholders in the config file.
*
* @param sqlSessionFactoryProperties optional properties for the SqlSessionFactory
*/
public void setConfigurationProperties(Properties sqlSessionFactoryProperties) {
this.configurationProperties = sqlSessionFactoryProperties;
}
/**
* Set the JDBC {@code DataSource} that this instance should manage transactions for. The {@code DataSource}
* should match the one used by the {@code SqlSessionFactory}: for example, you could specify the same
* JNDI DataSource for both.
* <p>
* A transactional JDBC {@code Connection} for this {@code DataSource} will be provided to application code
* accessing this {@code DataSource} directly via {@code DataSourceUtils} or {@code DataSourceTransactionManager}.
* <p>
* The {@code DataSource} specified here should be the target {@code DataSource} to manage transactions for, not
* a {@code TransactionAwareDataSourceProxy}. Only data access code may work with
* {@code TransactionAwareDataSourceProxy}, while the transaction manager needs to work on the
* underlying target {@code DataSource}. If there's nevertheless a {@code TransactionAwareDataSourceProxy}
* passed in, it will be unwrapped to extract its target {@code DataSource}.
*
* @param dataSource a JDBC {@code DataSource}
*/
public void setDataSource(DataSource dataSource) {
if (dataSource instanceof TransactionAwareDataSourceProxy) {
// If we got a TransactionAwareDataSourceProxy, we need to perform
// transactions for its underlying target DataSource, else data
// access code won't see properly exposed transactions (i.e.
// transactions for the target DataSource).
this.dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource();
} else {
this.dataSource = dataSource;
}
}
/**
* Sets the {@code SqlSessionFactoryBuilder} to use when creating the {@code SqlSessionFactory}.
* <p>
* This is mainly meant for testing so that mock SqlSessionFactory classes can be injected. By
* default, {@code SqlSessionFactoryBuilder} creates {@code DefaultSqlSessionFactory} instances.
*
* @param sqlSessionFactoryBuilder a SqlSessionFactoryBuilder
*/
public void setSqlSessionFactoryBuilder(SqlSessionFactoryBuilder sqlSessionFactoryBuilder) {
this.sqlSessionFactoryBuilder = sqlSessionFactoryBuilder;
}
/**
* Set the MyBatis TransactionFactory to use. Default is {@code SpringManagedTransactionFactory}
* <p>
* The default {@code SpringManagedTransactionFactory} should be appropriate for all cases:
* be it Spring transaction management, EJB CMT or plain JTA. If there is no active transaction,
* SqlSession operations will execute SQL statements non-transactionally.
*
* <b>It is strongly recommended to use the default {@code TransactionFactory}.</b> If not used, any
* attempt at getting an SqlSession through Spring's MyBatis framework will throw an exception if
* a transaction is active.
*
* @param transactionFactory the MyBatis TransactionFactory
* @see SpringManagedTransactionFactory
*/
public void setTransactionFactory(TransactionFactory transactionFactory) {
this.transactionFactory = transactionFactory;
}
/**
* <b>NOTE:</b> This class <em>overrides</em> any {@code Environment} you have set in the MyBatis
* config file. This is used only as a placeholder name. The default value is
* {@code SqlSessionFactoryBean.class.getSimpleName()}.
*
* @param environment the environment name
*/
public void setEnvironment(String environment) {
this.environment = environment;
}
/**
* {@inheritDoc}
*/
@Override
public void afterPropertiesSet() throws Exception {
notNull(dataSource, "Property 'dataSource' is required");
notNull(sqlSessionFactoryBuilder, "Property 'sqlSessionFactoryBuilder' is required");
state((configuration == null && configLocation == null) || !(configuration != null && configLocation != null),
"Property 'configuration' and 'configLocation' can not specified with together");
this.sqlSessionFactory = buildSqlSessionFactory();
}
/**
* Build a {@code SqlSessionFactory} instance.
* <p>
* The default implementation uses the standard MyBatis {@code XMLConfigBuilder} API to build a
* {@code SqlSessionFactory} instance based on an Reader. Since 1.3.0, it can be specified a
* {@link Configuration} instance directly(without config file).
* </p>
*
* @return SqlSessionFactory
* @throws IOException if loading the config file failed
*/
protected SqlSessionFactory buildSqlSessionFactory() throws Exception {
final MybatisConfiguration targetConfiguration;
// TODO 使用 MybatisXmlConfigBuilder 而不是 XMLConfigBuilder
MybatisXMLConfigBuilder xmlConfigBuilder = null;
if (this.configuration != null) {
targetConfiguration = this.configuration;
if (targetConfiguration.getVariables() == null) {
targetConfiguration.setVariables(this.configurationProperties);
} else if (this.configurationProperties != null) {
targetConfiguration.getVariables().putAll(this.configurationProperties);
}
} else if (this.configLocation != null) {
// TODO 使用 MybatisXMLConfigBuilder
xmlConfigBuilder = new MybatisXMLConfigBuilder(this.configLocation.getInputStream(), null, this.configurationProperties);
targetConfiguration = xmlConfigBuilder.getConfiguration();
} else {
LOGGER.debug("Property 'configuration' or 'configLocation' not specified, using default MyBatis Configuration");
// TODO 使用 MybatisConfiguration
targetConfiguration = new MybatisConfiguration();
Optional.ofNullable(this.configurationProperties).ifPresent(targetConfiguration::setVariables);
}
// TODO 无配置启动所必须的
this.globalConfig = Optional.ofNullable(this.globalConfig).orElseGet(GlobalConfigUtils::defaults);
this.globalConfig.setDbConfig(Optional.ofNullable(this.globalConfig.getDbConfig()).orElseGet(GlobalConfig.DbConfig::new));
// TODO 初始化 id-work 以及 打印骚东西
targetConfiguration.init(this.globalConfig);
// TODO 自动注入 map 接收返回结果下是否下划线转驼峰
if (targetConfiguration.isMapUnderscoreToCamelCase()) {
targetConfiguration.setObjectWrapperFactory(new MybatisMapWrapperFactory());
}
// TODO 设置元数据相关 如果用户没有配置 dbType 则自动获取
if (globalConfig.getDbConfig().getDbType() == DbType.OTHER) {
try (Connection connection = AopUtils.getTargetObject(this.dataSource).getConnection()) {
globalConfig.getDbConfig().setDbType(JdbcUtils.getDbType(connection.getMetaData().getURL()));
} catch (Exception e) {
throw ExceptionUtils.mpe("Error: GlobalConfigUtils setMetaData Fail ! Cause:" + e);
}
}
// TODO 自定义枚举类扫描处理
if (hasLength(this.typeEnumsPackage)) {
Set<Class> classes;
if (typeEnumsPackage.contains(StringPool.STAR) && !typeEnumsPackage.contains(StringPool.COMMA)
&& !typeEnumsPackage.contains(StringPool.SEMICOLON)) {
classes = PackageHelper.scanTypePackage(typeEnumsPackage);
if (classes.isEmpty()) {
LOGGER.warn("Can't find class in '[" + typeEnumsPackage + "]' package. Please check your configuration.");
}
} else {
String[] typeEnumsPackageArray = tokenizeToStringArray(this.typeEnumsPackage,
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
Assert.notNull(typeEnumsPackageArray, "not find typeEnumsPackage:" + typeEnumsPackage);
classes = new HashSet<>();
Stream.of(typeEnumsPackageArray).forEach(typePackage -> {
Set<Class> scanTypePackage = PackageHelper.scanTypePackage(typePackage);
if (scanTypePackage.isEmpty()) {
LOGGER.warn("Can't find class in '[" + typePackage + "]' package. Please check your configuration.");
} else {
classes.addAll(PackageHelper.scanTypePackage(typePackage));
}
});
}
// 取得类型转换注册器
TypeHandlerRegistry typeHandlerRegistry = targetConfiguration.getTypeHandlerRegistry();
classes.stream()
.filter(Class::isEnum)
.filter(cls -> IEnum.class.isAssignableFrom(cls) || EnumTypeHandler.dealEnumType(cls).isPresent())
.forEach(cls -> typeHandlerRegistry.register(cls, EnumTypeHandler.class));
}
Optional.ofNullable(this.objectFactory).ifPresent(targetConfiguration::setObjectFactory);
Optional.ofNullable(this.objectWrapperFactory).ifPresent(targetConfiguration::setObjectWrapperFactory);
Optional.ofNullable(this.vfs).ifPresent(targetConfiguration::setVfsImpl);
if (hasLength(this.typeAliasesPackage)) {
scanClasses(this.typeAliasesPackage, this.typeAliasesSuperType)
.forEach(targetConfiguration.getTypeAliasRegistry()::registerAlias);
}
if (!isEmpty(this.typeAliases)) {
Stream.of(this.typeAliases).forEach(typeAlias -> {
targetConfiguration.getTypeAliasRegistry().registerAlias(typeAlias);
LOGGER.debug("Registered type alias: '" + typeAlias + "'");
});
}
if (!isEmpty(this.plugins)) {
Stream.of(this.plugins).forEach(plugin -> {
targetConfiguration.addInterceptor(plugin);
LOGGER.debug("Registered plugin: '" + plugin + "'");
});
}
if (hasLength(this.typeHandlersPackage)) {
scanClasses(this.typeHandlersPackage, TypeHandler.class).stream()
.filter(clazz -> !clazz.isInterface())
.filter(clazz -> !Modifier.isAbstract(clazz.getModifiers()))
.filter(clazz -> ClassUtils.getConstructorIfAvailable(clazz) != null)
.forEach(targetConfiguration.getTypeHandlerRegistry()::register);
}
if (!isEmpty(this.typeHandlers)) {
Stream.of(this.typeHandlers).forEach(typeHandler -> {
targetConfiguration.getTypeHandlerRegistry().register(typeHandler);
LOGGER.debug("Registered type handler: '" + typeHandler + "'");
});
}
if (this.databaseIdProvider != null) {//fix #64 set databaseId before parse mapper xmls
try {
targetConfiguration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource));
} catch (SQLException e) {
throw new NestedIOException("Failed getting a databaseId", e);
}
}
Optional.ofNullable(this.cache).ifPresent(targetConfiguration::addCache);
if (xmlConfigBuilder != null) {
try {
xmlConfigBuilder.parse();
LOGGER.debug("Parsed configuration file: '" + this.configLocation + "'");
} catch (Exception ex) {
throw new NestedIOException("Failed to parse config resource: " + this.configLocation, ex);
} finally {
ErrorContext.instance().reset();
}
}
targetConfiguration.setEnvironment(new Environment(this.environment,
this.transactionFactory == null ? new SpringManagedTransactionFactory() : this.transactionFactory,
this.dataSource));
if (this.mapperLocations != null) {
if (this.mapperLocations.length == 0) {
LOGGER.warn("Property 'mapperLocations' was specified but matching resources are not found.");
} else {
for (Resource mapperLocation : this.mapperLocations) {
if (mapperLocation == null) {
continue;
}
try {
XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(mapperLocation.getInputStream(),
targetConfiguration, mapperLocation.toString(), targetConfiguration.getSqlFragments());
xmlMapperBuilder.parse();
} catch (Exception e) {
throw new NestedIOException("Failed to parse mapping resource: '" + mapperLocation + "'", e);
} finally {
ErrorContext.instance().reset();
}
LOGGER.debug("Parsed mapper file: '" + mapperLocation + "'");
}
}
} else {
LOGGER.debug("Property 'mapperLocations' was not specified.");
}
SqlSessionFactory sqlSessionFactory = this.sqlSessionFactoryBuilder.build(targetConfiguration);
// TODO SqlRunner
SqlHelper.FACTORY = sqlSessionFactory;
// TODO 设置全局参数属性 以及 缓存 sqlSessionFactory
globalConfig.signGlobalConfig(sqlSessionFactory);
return sqlSessionFactory;
}
/**
* {@inheritDoc}
*/
@Override
public SqlSessionFactory getObject() throws Exception {
if (this.sqlSessionFactory == null) {
afterPropertiesSet();
}
return this.sqlSessionFactory;
}
/**
* {@inheritDoc}
*/
@Override
public Class<? extends SqlSessionFactory> getObjectType() {
return this.sqlSessionFactory == null ? SqlSessionFactory.class : this.sqlSessionFactory.getClass();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isSingleton() {
return true;
}
/**
* {@inheritDoc}
*/
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (failFast && event instanceof ContextRefreshedEvent) {
// fail-fast -> check all statements are completed
this.sqlSessionFactory.getConfiguration().getMappedStatementNames();
}
}
private Set<Class<?>> scanClasses(String packagePatterns, Class<?> assignableType)
throws IOException {
Set<Class<?>> classes = new HashSet<>();
String[] packagePatternArray = tokenizeToStringArray(packagePatterns,
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
for (String packagePattern : packagePatternArray) {
Resource[] resources = RESOURCE_PATTERN_RESOLVER.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
org.springframework.util.ClassUtils.convertClassNameToResourcePath(packagePattern) + "/**/*.class");
for (Resource resource : resources) {
try {
ClassMetadata classMetadata = METADATA_READER_FACTORY.getMetadataReader(resource).getClassMetadata();
Class<?> clazz = Resources.classForName(classMetadata.getClassName());
if (assignableType == null || assignableType.isAssignableFrom(clazz)) {
classes.add(clazz);
}
} catch (Throwable e) {
LOGGER.warn("Cannot load the '" + resource + "'. Cause by " + e.toString());
}
}
}
return classes;
}
}
+27
View File
@@ -0,0 +1,27 @@
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=root
#jdbc.password=123456
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
+22
View File
@@ -0,0 +1,22 @@
log4j.rootLogger=DEBUG,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=[ifishTasks][%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/ifishTasks.log
#\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F
log4j.appender.File.MaxFileSize = 100
#\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 =[ifishTasks][%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n
log4j.logger.org.apache.activemq=INFO
log4j.logger.org.springframework=INFO
log4j.logger.org.mybatis.spring=INFO
log4j.logger.com.ifish7.tasks=INFO
+7
View File
@@ -0,0 +1,7 @@
#broker_url=tcp://test.ifish7.com:61616
broker_url=tcp://www.ifish7.com:61616
username=admin
#password=admin
password=adminifish7
queue_data_name=ifishDataMq
queue_push_name=ifishPushMq
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" >
<list>
<value>classpath:mq.properties</value>
<value>classpath:jdbc.properties</value>
<value>classpath:log4j.properties</value>
</list>
</property>
</bean>
<import resource="spring/spring-mq.xml" />
<import resource="spring/spring-mybatis.xml" />
<task:annotation-driven />
<!-- 自动扫描 -->
<context:component-scan base-package="com.ifish7.tasks.*" />
<bean id="app" class="com.ifish7.tasks.utils.AppBeans" />
</beans>
+39
View File
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" >
<property name="brokerURL" value="${broker_url}" />
<property name="userName" value="${username}" />
<property name="password" value="${password}" />
</bean>
<bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="maxConnections" value="100"></property>
</bean>
<!--使用缓存可以提升效率-->
<bean id="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="jmsFactory"/>
<property name="sessionCacheSize" value="1"/>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="cachingConnectionFactory"/>
<property name="messageConverter">
<bean class="org.springframework.jms.support.converter.SimpleMessageConverter"/>
</property>
</bean>
<!-- 定义消息推送消息队列(Queue -->
<bean id="ifish7PushQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
<!-- 设置消息队列的名字 -->
<constructor-arg>
<value>${queue_push_name}</value>
</constructor-arg>
</bean>
</beans>
@@ -0,0 +1,97 @@
<?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: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/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">
<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="com.ifish7.tasks.utils.MybatisSqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mapping.xml文件 -->
<!--<property name="mapperLocations" value="classpath:mapper/*/*.xml"></property>-->
</bean>
<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.ifish7.tasks.business.*.mapper" />
<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.tasks.business.*.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="get*" read-only="true"/>
<tx:method name="list*" read-only="true"/>
<tx:method name="page*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="remove*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
</beans>
+5
View File
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Built-By: Administrator
Created-By: IntelliJ IDEA
Build-Jdk: 1.8.0_201
+39
View File
@@ -0,0 +1,39 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<!-- Spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 防止Spring内存溢出监听器 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<!-- Spring和mybatis的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-main.xml</param-value>
</context-param>
<!-- 编码过滤器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
@@ -0,0 +1,21 @@
package com.ifish7.tasks.utils;
import org.junit.Test;
import java.util.Date;
import static org.junit.Assert.*;
/**
* @author: yan.y
* @Description:
* @Date: Created in 14:10 2019/6/1
*/
public class IfishTaskUtilTest {
@Test
public void format() {
String format = IfishTaskUtil.format(new Date());
System.out.println(format);
}
}
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" >
<list>
<value>classpath:push.properties</value>
</list>
</property>
</bean>
<bean id="app" class="com.ifish7.tasks.utils.AppBeans" />
<bean id="push" class="com.aliyuncs.push.model.v20160801.PushRequest" scope="prototype">
<property name="appKey" value="${appKey}" />
<property name="sysProtocol" value="${protocol}" />
<property name="sysMethod" value="${method}" />
<property name="storeOffline" value="${storeOffline}" />
<property name="sysRegionId" value="${regionId}"/>
<property name="sysVersion" value="${version}" />
</bean>
<bean id="api" class="com.ifish7.tasks.push.AliyunPushApi" scope="prototype" >
<constructor-arg name="regionId" value="${regionId}" />
<constructor-arg name="accessKeyId" value="${accessKeyId}" />
<constructor-arg name="accessKeySecret" value="${accessKeySecret}" />
</bean>
</beans>