commit cbfa434a2771a938b52c4ab356896256e459d28b Author: 易焱 Date: Sat Jun 1 23:03:25 2019 +0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3087554 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +target +**/lib +**/classes \ No newline at end of file diff --git a/ifishTasks.iml b/ifishTasks.iml new file mode 100644 index 0000000..74686f3 --- /dev/null +++ b/ifishTasks.iml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/logs/ifishTasks.log b/logs/ifishTasks.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/ifishTasks.log.1 b/logs/ifishTasks.log.1 new file mode 100644 index 0000000..01c2ed3 --- /dev/null +++ b/logs/ifishTasks.log.1 @@ -0,0 +1 @@ +[ifishTasks][DEBUG] [2019-06-01 12:26:38][com.baomidou.mybatisplus.generator.AutoGenerator]==========================文件生成完成!!!========================== diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f296608 --- /dev/null +++ b/pom.xml @@ -0,0 +1,287 @@ + + + + 4.0.0 + + com.ifish7 + ifishTasks + 1.0.0-SNAPSHOT + war + + ifish7.ifishTasks Webapp + + + 1.8 + UTF-8 + 5.0.8.RELEASE + 3.4.5 + 1.3.2 + 1.2.17 + 5.15.4 + 1.18.6 + 1.2.56 + + + + + + junit + junit + 4.12 + test + + + + org.springframework + spring-test + 5.0.8.RELEASE + + + * + * + + + test + + + + + com.aliyun + aliyun-java-sdk-push + 3.10.1 + + + com.aliyun + aliyun-java-sdk-core + [4.3.2,5.0.0) + + + + mysql + mysql-connector-java + 5.1.9 + + + + + org.apache.activemq + activemq-all + ${activemq.version} + + + + + org.springframework + spring-core + ${spring.version} + + + + org.springframework + spring-beans + ${spring.version} + + + + org.springframework + spring-context + ${spring.version} + + + + org.springframework + spring-tx + ${spring.version} + + + + org.springframework + spring-web + ${spring.version} + + + + org.springframework + spring-webmvc + ${spring.version} + + + + org.springframework + spring-jdbc + ${spring.version} + + + + + org.springframework + spring-context-support + ${spring.version} + + + + + org.springframework + spring-jms + ${spring.version} + + + + org.apache.xbean + xbean-spring + 3.16 + + + + org.springframework + spring-test + ${spring.version} + test + + + + + org.mybatis + mybatis + ${mybatis.version} + + + + + org.mybatis + mybatis-spring + ${mybatis-spring.version} + + + + org.apache.commons + commons-pool2 + 2.6.2 + + + + commons-logging + commons-logging + 1.2 + + + + + com.baomidou + mybatis-plus-boot-starter + 3.1.0 + + + * + * + + + + + + com.baomidou + mybatis-plus-generator + 3.1.0 + + + + org.freemarker + freemarker + 2.3.28 + + + + + com.alibaba + druid + 1.1.6 + + + + org.aspectj + aspectjweaver + 1.8.4 + + + + + log4j + log4j + ${log4j.version} + + + + org.projectlombok + lombok + ${lombok.version} + + + + + + org.apache.commons + commons-lang3 + 3.1 + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + + ifishTasks + ${basedir}/src/main/java + + + ${basedir}/src/main/resources + + **/*.java + + + + + ${basedir}/src/test/java + ${basedir}/target/test-classes + + + ${basedir}/src/test/resources + + **/*.java + + + + + + + maven-war-plugin + + ${basedir}/src/main/webapp + ${basedir}/src/main/webapp + + + + maven-compiler-plugin + + ${java.version} + ${java.version} + ${java.encoding} + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + diff --git a/src/main/java/com/ifish7/tasks/business/device/entity/TblDevice.java b/src/main/java/com/ifish7/tasks/business/device/entity/TblDevice.java new file mode 100644 index 0000000..307805a --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/entity/TblDevice.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceHeater.java b/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceHeater.java new file mode 100644 index 0000000..49ea0d5 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceHeater.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceHeaterDetail.java b/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceHeaterDetail.java new file mode 100644 index 0000000..c696b2b --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceHeaterDetail.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceUser.java b/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceUser.java new file mode 100644 index 0000000..0c882f7 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/entity/TblDeviceUser.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/entity/TblTmpPushRemind.java b/src/main/java/com/ifish7/tasks/business/device/entity/TblTmpPushRemind.java new file mode 100644 index 0000000..b85441e --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/entity/TblTmpPushRemind.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceHeaterDetailMapper.java b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceHeaterDetailMapper.java new file mode 100644 index 0000000..80c3015 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceHeaterDetailMapper.java @@ -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; + +/** + *

+ * Mapper 接口 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +public interface TblDeviceHeaterDetailMapper extends BaseMapper { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceHeaterMapper.java b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceHeaterMapper.java new file mode 100644 index 0000000..cda25dd --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceHeaterMapper.java @@ -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; + +/** + *

+ * Mapper 接口 + *

+ * + * @author yan.y + * @since 2019-04-09 + */ +public interface TblDeviceHeaterMapper extends BaseMapper { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceMapper.java b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceMapper.java new file mode 100644 index 0000000..dfc1f62 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceMapper.java @@ -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; + +/** + *

+ * Mapper 接口 + *

+ * + * @author yan.y + * @since 2019-04-09 + */ +public interface TblDeviceMapper extends BaseMapper { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceUserMapper.java b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceUserMapper.java new file mode 100644 index 0000000..09fda6a --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/mapper/TblDeviceUserMapper.java @@ -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; + +/** + *

+ * Mapper 接口 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +public interface TblDeviceUserMapper extends BaseMapper { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/mapper/TblTmpPushRemindMapper.java b/src/main/java/com/ifish7/tasks/business/device/mapper/TblTmpPushRemindMapper.java new file mode 100644 index 0000000..2088116 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/mapper/TblTmpPushRemindMapper.java @@ -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; + +/** + *

+ * Mapper 接口 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +public interface TblTmpPushRemindMapper extends BaseMapper { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceHeaterDetailService.java b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceHeaterDetailService.java new file mode 100644 index 0000000..acf2c67 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceHeaterDetailService.java @@ -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; + +/** + *

+ * 服务类 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +public interface ITblDeviceHeaterDetailService extends IService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceHeaterService.java b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceHeaterService.java new file mode 100644 index 0000000..e055eae --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceHeaterService.java @@ -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; + +/** + *

+ * 服务类 + *

+ * + * @author yan.y + * @since 2019-04-09 + */ +public interface ITblDeviceHeaterService extends IService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceService.java b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceService.java new file mode 100644 index 0000000..1202753 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceService.java @@ -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; + +/** + *

+ * 服务类 + *

+ * + * @author yan.y + * @since 2019-04-09 + */ +public interface ITblDeviceService extends IService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceUserService.java b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceUserService.java new file mode 100644 index 0000000..6f3b5ef --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/ITblDeviceUserService.java @@ -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; + +/** + *

+ * 服务类 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +public interface ITblDeviceUserService extends IService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/ITblTmpPushRemindService.java b/src/main/java/com/ifish7/tasks/business/device/service/ITblTmpPushRemindService.java new file mode 100644 index 0000000..2658923 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/ITblTmpPushRemindService.java @@ -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; + +/** + *

+ * 服务类 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +public interface ITblTmpPushRemindService extends IService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceHeaterDetailServiceImpl.java b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceHeaterDetailServiceImpl.java new file mode 100644 index 0000000..6a570ad --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceHeaterDetailServiceImpl.java @@ -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; + +/** + *

+ * 服务实现类 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +@Service +public class TblDeviceHeaterDetailServiceImpl extends ServiceImpl implements ITblDeviceHeaterDetailService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceHeaterServiceImpl.java b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceHeaterServiceImpl.java new file mode 100644 index 0000000..e5c5a1e --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceHeaterServiceImpl.java @@ -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; + +/** + *

+ * 服务实现类 + *

+ * + * @author yan.y + * @since 2019-04-09 + */ +@Service +public class TblDeviceHeaterServiceImpl extends ServiceImpl implements ITblDeviceHeaterService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceServiceImpl.java b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceServiceImpl.java new file mode 100644 index 0000000..3709217 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceServiceImpl.java @@ -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; + +/** + *

+ * 服务实现类 + *

+ * + * @author yan.y + * @since 2019-04-09 + */ +@Service +public class TblDeviceServiceImpl extends ServiceImpl implements ITblDeviceService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceUserServiceImpl.java b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceUserServiceImpl.java new file mode 100644 index 0000000..3dcf485 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblDeviceUserServiceImpl.java @@ -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; + +/** + *

+ * 服务实现类 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +@Service +public class TblDeviceUserServiceImpl extends ServiceImpl implements ITblDeviceUserService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/device/service/impl/TblTmpPushRemindServiceImpl.java b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblTmpPushRemindServiceImpl.java new file mode 100644 index 0000000..9a4cc1d --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/device/service/impl/TblTmpPushRemindServiceImpl.java @@ -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; + +/** + *

+ * 服务实现类 + *

+ * + * @author yan.y + * @since 2019-06-01 + */ +@Service +public class TblTmpPushRemindServiceImpl extends ServiceImpl implements ITblTmpPushRemindService { + +} diff --git a/src/main/java/com/ifish7/tasks/business/enums/PushTypeEnum.java b/src/main/java/com/ifish7/tasks/business/enums/PushTypeEnum.java new file mode 100644 index 0000000..0a27ecb --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/enums/PushTypeEnum.java @@ -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; + } + +} diff --git a/src/main/java/com/ifish7/tasks/business/event/PushList.java b/src/main/java/com/ifish7/tasks/business/event/PushList.java new file mode 100644 index 0000000..fb2da0a --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/event/PushList.java @@ -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; + +} diff --git a/src/main/java/com/ifish7/tasks/business/event/QueueEventBody.java b/src/main/java/com/ifish7/tasks/business/event/QueueEventBody.java new file mode 100644 index 0000000..77bf4a4 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/event/QueueEventBody.java @@ -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; + } +} diff --git a/src/main/java/com/ifish7/tasks/business/event/QueueEventEntity.java b/src/main/java/com/ifish7/tasks/business/event/QueueEventEntity.java new file mode 100644 index 0000000..f1b7c66 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/business/event/QueueEventEntity.java @@ -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; + } +} diff --git a/src/main/java/com/ifish7/tasks/execption/TasksExecption.java b/src/main/java/com/ifish7/tasks/execption/TasksExecption.java new file mode 100644 index 0000000..fce7416 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/execption/TasksExecption.java @@ -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); + } +} diff --git a/src/main/java/com/ifish7/tasks/job/RemindJob.java b/src/main/java/com/ifish7/tasks/job/RemindJob.java new file mode 100644 index 0000000..2cfaaf8 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/job/RemindJob.java @@ -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(); +} diff --git a/src/main/java/com/ifish7/tasks/job/impl/RemindJobImpl.java b/src/main/java/com/ifish7/tasks/job/impl/RemindJobImpl.java new file mode 100644 index 0000000..40d7d4d --- /dev/null +++ b/src/main/java/com/ifish7/tasks/job/impl/RemindJobImpl.java @@ -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 list = tmpPushRemindService.list(new QueryWrapper().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 list = deviceHeaterDetailService.list(new QueryWrapper().lambda() + .eq(TblDeviceHeaterDetail::getHerterRemindDate, nowDate)); + final PushList pushList = new PushList(); + list.forEach(tblDeviceHeaterDetail -> { + String macAddress = tblDeviceHeaterDetail.getHeaterMacAddress(); + //根据MAC地址查询出设备信息 + TblDevice device = deviceService.getOne(new QueryWrapper().lambda() + .eq(TblDevice::getMacAddress, macAddress)); + //根据设备ID查询出用户所对应的设备 + List deviceUsers = deviceUserService.list(new QueryWrapper().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)); + } +} diff --git a/src/main/java/com/ifish7/tasks/utils/AppBeans.java b/src/main/java/com/ifish7/tasks/utils/AppBeans.java new file mode 100644 index 0000000..56c1fdd --- /dev/null +++ b/src/main/java/com/ifish7/tasks/utils/AppBeans.java @@ -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 getBean(Class clazz){ + if (app == null) + return null; + else + return app.getBean(clazz); + } +} diff --git a/src/main/java/com/ifish7/tasks/utils/IfishTaskUtil.java b/src/main/java/com/ifish7/tasks/utils/IfishTaskUtil.java new file mode 100644 index 0000000..b0c1263 --- /dev/null +++ b/src/main/java/com/ifish7/tasks/utils/IfishTaskUtil.java @@ -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); + } + +} diff --git a/src/main/java/com/ifish7/tasks/utils/MybatisCodeGenerator.java b/src/main/java/com/ifish7/tasks/utils/MybatisCodeGenerator.java new file mode 100644 index 0000000..3826ccd --- /dev/null +++ b/src/main/java/com/ifish7/tasks/utils/MybatisCodeGenerator.java @@ -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 { + /** + *

+ * 读取控制台内容 + *

+ */ + 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 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(); + } +} diff --git a/src/main/java/com/ifish7/tasks/utils/MybatisSqlSessionFactoryBean.java b/src/main/java/com/ifish7/tasks/utils/MybatisSqlSessionFactoryBean.java new file mode 100644 index 0000000..6cf974f --- /dev/null +++ b/src/main/java/com/ifish7/tasks/utils/MybatisSqlSessionFactoryBean.java @@ -0,0 +1,682 @@ +/* + * Copyright (c) 2011-2019, hubin (jobob@qq.com). + *

+ * 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 + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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() 加载自定义 + *

MybatisXmlConfigBuilder

+ * + * @author hubin + * @since 2017-01-04 + */ +public class MybatisSqlSessionFactoryBean implements FactoryBean, InitializingBean, ApplicationListener { + + 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 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 getVfs() { + return this.vfs; + } + + /** + * Sets the VFS. + * + * @param vfs a VFS + */ + public void setVfs(Class 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. + * + *

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. + * + *

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. + *

+ * This is an alternative to specifying "<sqlmapper>" 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 <properties>} 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. + *

+ * 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}. + *

+ * 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}. + *

+ * 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} + *

+ * 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. + * + * It is strongly recommended to use the default {@code TransactionFactory}. 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; + } + + /** + * NOTE: This class overrides 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. + *

+ * 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). + *

+ * + * @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 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 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 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> scanClasses(String packagePatterns, Class assignableType) + throws IOException { + Set> 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; + } +} \ No newline at end of file diff --git a/src/main/resources/jdbc.properties b/src/main/resources/jdbc.properties new file mode 100644 index 0000000..1a4e53a --- /dev/null +++ b/src/main/resources/jdbc.properties @@ -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 \ No newline at end of file diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties new file mode 100644 index 0000000..c82706d --- /dev/null +++ b/src/main/resources/log4j.properties @@ -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 \ No newline at end of file diff --git a/src/main/resources/mq.properties b/src/main/resources/mq.properties new file mode 100644 index 0000000..a5dcb67 --- /dev/null +++ b/src/main/resources/mq.properties @@ -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 \ No newline at end of file diff --git a/src/main/resources/spring-main.xml b/src/main/resources/spring-main.xml new file mode 100644 index 0000000..fefe42f --- /dev/null +++ b/src/main/resources/spring-main.xml @@ -0,0 +1,30 @@ + + + + + + + classpath:mq.properties + classpath:jdbc.properties + classpath:log4j.properties + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/spring/spring-mq.xml b/src/main/resources/spring/spring-mq.xml new file mode 100644 index 0000000..f31196f --- /dev/null +++ b/src/main/resources/spring/spring-mq.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${queue_push_name} + + + + \ No newline at end of file diff --git a/src/main/resources/spring/spring-mybatis.xml b/src/main/resources/spring/spring-mybatis.xml new file mode 100644 index 0000000..24fae38 --- /dev/null +++ b/src/main/resources/spring/spring-mybatis.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/META-INF/MANIFEST.MF b/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..3698f8d --- /dev/null +++ b/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: Administrator +Created-By: IntelliJ IDEA +Build-Jdk: 1.8.0_201 + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..fe97d65 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,39 @@ + + + + Archetype Created Web Application + + + + org.springframework.web.context.ContextLoaderListener + + + + org.springframework.web.util.IntrospectorCleanupListener + + + + + contextConfigLocation + classpath:spring-main.xml + + + + + + encodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + + + + encodingFilter + /* + + + + diff --git a/src/test/java/com/ifish7/tasks/utils/IfishTaskUtilTest.java b/src/test/java/com/ifish7/tasks/utils/IfishTaskUtilTest.java new file mode 100644 index 0000000..27f060d --- /dev/null +++ b/src/test/java/com/ifish7/tasks/utils/IfishTaskUtilTest.java @@ -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); + } +} \ No newline at end of file diff --git a/src/test/resources/spring-main.xml b/src/test/resources/spring-main.xml new file mode 100644 index 0000000..5a88743 --- /dev/null +++ b/src/test/resources/spring-main.xml @@ -0,0 +1,33 @@ + + + + + + + classpath:push.properties + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file