新增监控模块

This commit is contained in:
Administrator 2018-11-21 17:32:19 +08:00
parent 861b49a415
commit 048b60b751
31 changed files with 2168 additions and 239 deletions

View File

@ -1,148 +1,194 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId>
<version>3.0</version>
</parent>
<groupId>com.cronie</groupId>
<artifactId>mengyu-trade</artifactId>
<packaging>jar</packaging>
<version>3.0</version>
<name>mengyu-trade</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- spring-boot-devtools -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-admin</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<verbose/>
<bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\jce.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<includeScope>system</includeScope>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>com.cronie.MengYuApplication</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>./</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>mapper/**</exclude>
<exclude>application.yml</exclude>
<exclude>*.properties</exclude>
<exclude>public/**</exclude>
<exclude>static/**</exclude>
<exclude>templates/**</exclude>
<exclude>library/**</exclude>
<exclude>freemaker.properties</exclude>
<exclude>logback-spring.xml</exclude>
<exclude>*.jar</exclude>
<exclude>ehcache/**</exclude>
<exclude>i18n/**</exclude>
</excludes>
</configuration>
</plugin>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId>
<version>3.0</version>
</parent>
<groupId>com.cronie</groupId>
<artifactId>mengyu-trade</artifactId>
<packaging>jar</packaging>
<version>3.0</version>
<name>mengyu-trade</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- spring-boot-devtools -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-admin</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency> 
            <groupId>org.springframework</groupId>  
            <artifactId>spring-test</artifactId>  
            <version>4.2.4.RELEASE</version>  
<scope>test</scope>
       </dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
-->
<dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.11</version>
   <scope>test</scope>
  </dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<verbose />
<bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\jce.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<includeScope>system</includeScope>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>com.cronie.MengYuApplication</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>./</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>mapper/**</exclude>
<exclude>application.yml</exclude>
<exclude>*.properties</exclude>
<exclude>public/**</exclude>
<exclude>static/**</exclude>
<exclude>templates/**</exclude>
<exclude>library/**</exclude>
<exclude>freemaker.properties</exclude>
<exclude>logback-spring.xml</exclude>
<exclude>*.jar</exclude>
<exclude>ehcache/**</exclude>
<exclude>i18n/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.4</version>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>src/main/build/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.4</version>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>src/main/build/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1542248987" Name="MengYu" Objects="64" Symbols="7" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.1.0.2850"?>
<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1542787798" Name="MengYu" Objects="66" Symbols="7" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.1.0.2850"?>
<!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@ -2991,7 +2991,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:CreationDate>1542184039</a:CreationDate>
<a:ModificationDate>1542186391</a:ModificationDate>
<a:IconMode>-1</a:IconMode>
<a:Rect>((8640,-598), (22258,8250))</a:Rect>
<a:Rect>((8446,-1010), (22452,8662))</a:Rect>
<a:LineColor>12615680</a:LineColor>
<a:FillColor>4227072</a:FillColor>
<a:ShadowColor>12632256</a:ShadowColor>
@ -3016,7 +3016,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:CreationDate>1542184039</a:CreationDate>
<a:ModificationDate>1542186391</a:ModificationDate>
<a:IconMode>-1</a:IconMode>
<a:Rect>((8640,-8100), (19170,-2552))</a:Rect>
<a:Rect>((7868,-8512), (19942,-2140))</a:Rect>
<a:LineColor>12615680</a:LineColor>
<a:FillColor>4227072</a:FillColor>
<a:ShadowColor>12632256</a:ShadowColor>
@ -3378,10 +3378,11 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>code_type</a:Code>
<a:CreationDate>1542184146</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542184704</a:ModificationDate>
<a:ModificationDate>1542764258</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>品种类型 (股标,基金等)</a:Comment>
<a:DataType>int</a:DataType>
<a:DataType>varchar(20)</a:DataType>
<a:Length>20</a:Length>
</o:Column>
<o:Column Id="o40">
<a:ObjectID>6F71D630-AF64-4486-88C3-14882DE86859</a:ObjectID>
@ -3389,10 +3390,11 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>industry_type</a:Code>
<a:CreationDate>1542184146</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542184722</a:ModificationDate>
<a:ModificationDate>1542764258</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>行业类型(军工,证券等)</a:Comment>
<a:DataType>int</a:DataType>
<a:DataType>varchar(20)</a:DataType>
<a:Length>20</a:Length>
</o:Column>
<o:Column Id="o41">
<a:ObjectID>449E7898-8832-4B87-A903-AB85C095B759</a:ObjectID>
@ -3400,10 +3402,11 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>plate_type</a:Code>
<a:CreationDate>1542184146</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542184743</a:ModificationDate>
<a:ModificationDate>1542764258</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>板块类型(上证,深证 创业板等)</a:Comment>
<a:DataType>int</a:DataType>
<a:DataType>varchar(20)</a:DataType>
<a:Length>20</a:Length>
</o:Column>
<o:Column Id="o42">
<a:ObjectID>2CEC7C33-E4B8-485A-B7EE-5CF4A30645D9</a:ObjectID>
@ -3454,7 +3457,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>my_goods_trade_model</a:Code>
<a:CreationDate>1542184039</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542186108</a:ModificationDate>
<a:ModificationDate>1542787109</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>品种计划模型表</a:Comment>
<a:TotalSavingCurrency/>
@ -3569,9 +3572,20 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o54">
<a:ObjectID>C19870BD-D11E-4B64-B826-3780E2DBC68A</a:ObjectID>
<a:Name>has_mail_notice</a:Name>
<a:Code>has_mail_notice</a:Code>
<a:CreationDate>1542787087</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542787179</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>是否邮件提醒</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
</c:Columns>
<c:Keys>
<o:Key Id="o54">
<o:Key Id="o55">
<a:ObjectID>D48EEC9A-9D6A-4149-9332-841A0E37811C</a:ObjectID>
<a:Name>Key_1</a:Name>
<a:Code>Key_1</a:Code>
@ -3585,7 +3599,7 @@ LABL 0 新宋体,8,N</a:FontList>
</o:Key>
</c:Keys>
<c:PrimaryKey>
<o:Key Ref="o54"/>
<o:Key Ref="o55"/>
</c:PrimaryKey>
</o:Table>
<o:Table Id="o16">
@ -3594,12 +3608,12 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>my_goods_trade_model_ins</a:Code>
<a:CreationDate>1542184039</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542186123</a:ModificationDate>
<a:ModificationDate>1542787125</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>计划模型实例表</a:Comment>
<a:TotalSavingCurrency/>
<c:Columns>
<o:Column Id="o55">
<o:Column Id="o56">
<a:ObjectID>0C89A765-395B-4841-8AF3-E74D73E4DEAF</a:ObjectID>
<a:Name>ins_id</a:Name>
<a:Code>ins_id</a:Code>
@ -3612,7 +3626,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Identity>1</a:Identity>
<a:Mandatory>1</a:Mandatory>
</o:Column>
<o:Column Id="o56">
<o:Column Id="o57">
<a:ObjectID>F4F46760-E1F0-470A-B122-8C191F7015A5</a:ObjectID>
<a:Name>model_id</a:Name>
<a:Code>model_id</a:Code>
@ -3623,7 +3637,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>模型ID</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o57">
<o:Column Id="o58">
<a:ObjectID>9E94D94F-DCFC-4D1A-8FCE-9A9A8A8A8035</a:ObjectID>
<a:Name>ins_status</a:Name>
<a:Code>ins_status</a:Code>
@ -3634,7 +3648,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>计划状态</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o58">
<o:Column Id="o59">
<a:ObjectID>651A0C28-954C-49EE-B04D-7740244615C1</a:ObjectID>
<a:Name>creater</a:Name>
<a:Code>creater</a:Code>
@ -3645,7 +3659,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建人</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o59">
<o:Column Id="o60">
<a:ObjectID>A5C83096-9298-4EBE-8540-4C43D72ED822</a:ObjectID>
<a:Name>create_time</a:Name>
<a:Code>create_time</a:Code>
@ -3656,9 +3670,20 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o61">
<a:ObjectID>EE9CC8F4-EA51-4BFB-BC29-6A8AB4DB5A58</a:ObjectID>
<a:Name>has_mail_notice</a:Name>
<a:Code>has_mail_notice</a:Code>
<a:CreationDate>1542787114</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542787207</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>是否邮件提醒</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
</c:Columns>
<c:Keys>
<o:Key Id="o60">
<o:Key Id="o62">
<a:ObjectID>CB637D26-22DF-4165-B9B4-1B8F14F85B30</a:ObjectID>
<a:Name>Key_1</a:Name>
<a:Code>Key_1</a:Code>
@ -3667,12 +3692,12 @@ LABL 0 新宋体,8,N</a:FontList>
<a:ModificationDate>1542185695</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<c:Key.Columns>
<o:Column Ref="o55"/>
<o:Column Ref="o56"/>
</c:Key.Columns>
</o:Key>
</c:Keys>
<c:PrimaryKey>
<o:Key Ref="o60"/>
<o:Key Ref="o62"/>
</c:PrimaryKey>
</o:Table>
<o:Table Id="o18">
@ -3686,7 +3711,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>交易计划操作表</a:Comment>
<a:TotalSavingCurrency/>
<c:Columns>
<o:Column Id="o61">
<o:Column Id="o63">
<a:ObjectID>91E83142-005D-448A-A902-13E9C9E2834C</a:ObjectID>
<a:Name>node_id</a:Name>
<a:Code>node_id</a:Code>
@ -3699,7 +3724,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Identity>1</a:Identity>
<a:Mandatory>1</a:Mandatory>
</o:Column>
<o:Column Id="o62">
<o:Column Id="o64">
<a:ObjectID>F5C4577D-92EA-48B2-B340-DF72EB1FA416</a:ObjectID>
<a:Name>ins_id</a:Name>
<a:Code>ins_id</a:Code>
@ -3710,7 +3735,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>实例号</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o63">
<o:Column Id="o65">
<a:ObjectID>CFFED4D7-B163-4548-903E-5DC4607F7D9C</a:ObjectID>
<a:Name>price</a:Name>
<a:Code>price</a:Code>
@ -3723,7 +3748,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Length>10</a:Length>
<a:Precision>4</a:Precision>
</o:Column>
<o:Column Id="o64">
<o:Column Id="o66">
<a:ObjectID>6384BC85-AEC9-4F41-A9AF-E8F5539B7F6F</a:ObjectID>
<a:Name>volumes</a:Name>
<a:Code>volumes</a:Code>
@ -3735,7 +3760,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:DataType>numeric(12)</a:DataType>
<a:Length>12</a:Length>
</o:Column>
<o:Column Id="o65">
<o:Column Id="o67">
<a:ObjectID>18149A63-E040-4595-BB37-43F21B61CB99</a:ObjectID>
<a:Name>trade_time</a:Name>
<a:Code>trade_time</a:Code>
@ -3746,7 +3771,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>交易时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o66">
<o:Column Id="o68">
<a:ObjectID>4B5095B3-8B50-4ED4-960C-BC8BE96A6BC8</a:ObjectID>
<a:Name>creater</a:Name>
<a:Code>creater</a:Code>
@ -3757,7 +3782,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建人</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o67">
<o:Column Id="o69">
<a:ObjectID>8AD96BED-139A-4F3D-A53E-610713C8771B</a:ObjectID>
<a:Name>create_time</a:Name>
<a:Code>create_time</a:Code>
@ -3768,7 +3793,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o68">
<o:Column Id="o70">
<a:ObjectID>4C5F409C-CD47-4DF2-9067-037E68FD1FE8</a:ObjectID>
<a:Name>trade_type</a:Name>
<a:Code>trade_type</a:Code>
@ -3779,7 +3804,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>交易类型(建仓,加仓,减仓,平仓,止损)</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o69">
<o:Column Id="o71">
<a:ObjectID>F47DA95D-9187-4862-87BB-AC8D7A6313C7</a:ObjectID>
<a:Name>trade_note</a:Name>
<a:Code>trade_note</a:Code>
@ -3792,7 +3817,7 @@ LABL 0 新宋体,8,N</a:FontList>
</o:Column>
</c:Columns>
<c:Keys>
<o:Key Id="o70">
<o:Key Id="o72">
<a:ObjectID>12C60F49-270E-442C-9EDC-F5DB2664E2D6</a:ObjectID>
<a:Name>Key_1</a:Name>
<a:Code>Key_1</a:Code>
@ -3801,17 +3826,17 @@ LABL 0 新宋体,8,N</a:FontList>
<a:ModificationDate>1542187776</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<c:Key.Columns>
<o:Column Ref="o61"/>
<o:Column Ref="o63"/>
</c:Key.Columns>
</o:Key>
</c:Keys>
<c:PrimaryKey>
<o:Key Ref="o70"/>
<o:Key Ref="o72"/>
</c:PrimaryKey>
</o:Table>
</c:Tables>
<c:DefaultGroups>
<o:Group Id="o71">
<o:Group Id="o73">
<a:ObjectID>46EC3E2A-6CBF-421A-9DA8-6BCCEDEC7DF5</a:ObjectID>
<a:Name>PUBLIC</a:Name>
<a:Code>PUBLIC</a:Code>
@ -3822,13 +3847,13 @@ LABL 0 新宋体,8,N</a:FontList>
</o:Group>
</c:DefaultGroups>
<c:TargetModels>
<o:TargetModel Id="o72">
<o:TargetModel Id="o74">
<a:ObjectID>3AE1A68F-D267-4CD1-91CC-A80630C419C0</a:ObjectID>
<a:Name>MySQL 5.0</a:Name>
<a:Code>MYSQL50</a:Code>
<a:CreationDate>1542181843</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542248966</a:ModificationDate>
<a:ModificationDate>1542787798</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:TargetModelURL>file:///%_DBMS%/mysql50.xdb</a:TargetModelURL>
<a:TargetModelID>F4F16ECD-F2F1-4006-AF6F-638D5C65F35E</a:TargetModelID>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1542248987" Name="MengYu" Objects="64" Symbols="7" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.1.0.2850"?>
<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1542787798" Name="MengYu" Objects="66" Symbols="7" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.1.0.2850"?>
<!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@ -2991,7 +2991,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:CreationDate>1542184039</a:CreationDate>
<a:ModificationDate>1542186391</a:ModificationDate>
<a:IconMode>-1</a:IconMode>
<a:Rect>((8640,-598), (22258,8250))</a:Rect>
<a:Rect>((8446,-1010), (22452,8662))</a:Rect>
<a:LineColor>12615680</a:LineColor>
<a:FillColor>4227072</a:FillColor>
<a:ShadowColor>12632256</a:ShadowColor>
@ -3016,7 +3016,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:CreationDate>1542184039</a:CreationDate>
<a:ModificationDate>1542186391</a:ModificationDate>
<a:IconMode>-1</a:IconMode>
<a:Rect>((8640,-8100), (19170,-2552))</a:Rect>
<a:Rect>((7868,-8512), (19942,-2140))</a:Rect>
<a:LineColor>12615680</a:LineColor>
<a:FillColor>4227072</a:FillColor>
<a:ShadowColor>12632256</a:ShadowColor>
@ -3378,10 +3378,11 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>code_type</a:Code>
<a:CreationDate>1542184146</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542184704</a:ModificationDate>
<a:ModificationDate>1542764258</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>品种类型 (股标,基金等)</a:Comment>
<a:DataType>int</a:DataType>
<a:DataType>varchar(20)</a:DataType>
<a:Length>20</a:Length>
</o:Column>
<o:Column Id="o40">
<a:ObjectID>6F71D630-AF64-4486-88C3-14882DE86859</a:ObjectID>
@ -3389,10 +3390,11 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>industry_type</a:Code>
<a:CreationDate>1542184146</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542184722</a:ModificationDate>
<a:ModificationDate>1542764258</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>行业类型(军工,证券等)</a:Comment>
<a:DataType>int</a:DataType>
<a:DataType>varchar(20)</a:DataType>
<a:Length>20</a:Length>
</o:Column>
<o:Column Id="o41">
<a:ObjectID>449E7898-8832-4B87-A903-AB85C095B759</a:ObjectID>
@ -3400,10 +3402,11 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>plate_type</a:Code>
<a:CreationDate>1542184146</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542184743</a:ModificationDate>
<a:ModificationDate>1542764258</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>板块类型(上证,深证 创业板等)</a:Comment>
<a:DataType>int</a:DataType>
<a:DataType>varchar(20)</a:DataType>
<a:Length>20</a:Length>
</o:Column>
<o:Column Id="o42">
<a:ObjectID>2CEC7C33-E4B8-485A-B7EE-5CF4A30645D9</a:ObjectID>
@ -3454,7 +3457,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>my_goods_trade_model</a:Code>
<a:CreationDate>1542184039</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542186108</a:ModificationDate>
<a:ModificationDate>1542787109</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>品种计划模型表</a:Comment>
<a:TotalSavingCurrency/>
@ -3569,9 +3572,20 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o54">
<a:ObjectID>C19870BD-D11E-4B64-B826-3780E2DBC68A</a:ObjectID>
<a:Name>has_mail_notice</a:Name>
<a:Code>has_mail_notice</a:Code>
<a:CreationDate>1542787087</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542787179</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>是否邮件提醒</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
</c:Columns>
<c:Keys>
<o:Key Id="o54">
<o:Key Id="o55">
<a:ObjectID>D48EEC9A-9D6A-4149-9332-841A0E37811C</a:ObjectID>
<a:Name>Key_1</a:Name>
<a:Code>Key_1</a:Code>
@ -3585,7 +3599,7 @@ LABL 0 新宋体,8,N</a:FontList>
</o:Key>
</c:Keys>
<c:PrimaryKey>
<o:Key Ref="o54"/>
<o:Key Ref="o55"/>
</c:PrimaryKey>
</o:Table>
<o:Table Id="o16">
@ -3594,12 +3608,12 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>my_goods_trade_model_ins</a:Code>
<a:CreationDate>1542184039</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542186123</a:ModificationDate>
<a:ModificationDate>1542787125</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>计划模型实例表</a:Comment>
<a:TotalSavingCurrency/>
<c:Columns>
<o:Column Id="o55">
<o:Column Id="o56">
<a:ObjectID>0C89A765-395B-4841-8AF3-E74D73E4DEAF</a:ObjectID>
<a:Name>ins_id</a:Name>
<a:Code>ins_id</a:Code>
@ -3612,7 +3626,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Identity>1</a:Identity>
<a:Mandatory>1</a:Mandatory>
</o:Column>
<o:Column Id="o56">
<o:Column Id="o57">
<a:ObjectID>F4F46760-E1F0-470A-B122-8C191F7015A5</a:ObjectID>
<a:Name>model_id</a:Name>
<a:Code>model_id</a:Code>
@ -3623,7 +3637,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>模型ID</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o57">
<o:Column Id="o58">
<a:ObjectID>9E94D94F-DCFC-4D1A-8FCE-9A9A8A8A8035</a:ObjectID>
<a:Name>ins_status</a:Name>
<a:Code>ins_status</a:Code>
@ -3634,7 +3648,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>计划状态</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o58">
<o:Column Id="o59">
<a:ObjectID>651A0C28-954C-49EE-B04D-7740244615C1</a:ObjectID>
<a:Name>creater</a:Name>
<a:Code>creater</a:Code>
@ -3645,7 +3659,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建人</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o59">
<o:Column Id="o60">
<a:ObjectID>A5C83096-9298-4EBE-8540-4C43D72ED822</a:ObjectID>
<a:Name>create_time</a:Name>
<a:Code>create_time</a:Code>
@ -3656,9 +3670,20 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o61">
<a:ObjectID>EE9CC8F4-EA51-4BFB-BC29-6A8AB4DB5A58</a:ObjectID>
<a:Name>has_mail_notice</a:Name>
<a:Code>has_mail_notice</a:Code>
<a:CreationDate>1542787114</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542787207</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>是否邮件提醒</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
</c:Columns>
<c:Keys>
<o:Key Id="o60">
<o:Key Id="o62">
<a:ObjectID>CB637D26-22DF-4165-B9B4-1B8F14F85B30</a:ObjectID>
<a:Name>Key_1</a:Name>
<a:Code>Key_1</a:Code>
@ -3667,12 +3692,12 @@ LABL 0 新宋体,8,N</a:FontList>
<a:ModificationDate>1542185695</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<c:Key.Columns>
<o:Column Ref="o55"/>
<o:Column Ref="o56"/>
</c:Key.Columns>
</o:Key>
</c:Keys>
<c:PrimaryKey>
<o:Key Ref="o60"/>
<o:Key Ref="o62"/>
</c:PrimaryKey>
</o:Table>
<o:Table Id="o18">
@ -3686,7 +3711,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>交易计划操作表</a:Comment>
<a:TotalSavingCurrency/>
<c:Columns>
<o:Column Id="o61">
<o:Column Id="o63">
<a:ObjectID>91E83142-005D-448A-A902-13E9C9E2834C</a:ObjectID>
<a:Name>node_id</a:Name>
<a:Code>node_id</a:Code>
@ -3699,7 +3724,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Identity>1</a:Identity>
<a:Mandatory>1</a:Mandatory>
</o:Column>
<o:Column Id="o62">
<o:Column Id="o64">
<a:ObjectID>F5C4577D-92EA-48B2-B340-DF72EB1FA416</a:ObjectID>
<a:Name>ins_id</a:Name>
<a:Code>ins_id</a:Code>
@ -3710,7 +3735,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>实例号</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o63">
<o:Column Id="o65">
<a:ObjectID>CFFED4D7-B163-4548-903E-5DC4607F7D9C</a:ObjectID>
<a:Name>price</a:Name>
<a:Code>price</a:Code>
@ -3723,7 +3748,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Length>10</a:Length>
<a:Precision>4</a:Precision>
</o:Column>
<o:Column Id="o64">
<o:Column Id="o66">
<a:ObjectID>6384BC85-AEC9-4F41-A9AF-E8F5539B7F6F</a:ObjectID>
<a:Name>volumes</a:Name>
<a:Code>volumes</a:Code>
@ -3735,7 +3760,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:DataType>numeric(12)</a:DataType>
<a:Length>12</a:Length>
</o:Column>
<o:Column Id="o65">
<o:Column Id="o67">
<a:ObjectID>18149A63-E040-4595-BB37-43F21B61CB99</a:ObjectID>
<a:Name>trade_time</a:Name>
<a:Code>trade_time</a:Code>
@ -3746,7 +3771,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>交易时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o66">
<o:Column Id="o68">
<a:ObjectID>4B5095B3-8B50-4ED4-960C-BC8BE96A6BC8</a:ObjectID>
<a:Name>creater</a:Name>
<a:Code>creater</a:Code>
@ -3757,7 +3782,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建人</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o67">
<o:Column Id="o69">
<a:ObjectID>8AD96BED-139A-4F3D-A53E-610713C8771B</a:ObjectID>
<a:Name>create_time</a:Name>
<a:Code>create_time</a:Code>
@ -3768,7 +3793,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>创建时间</a:Comment>
<a:DataType>datetime</a:DataType>
</o:Column>
<o:Column Id="o68">
<o:Column Id="o70">
<a:ObjectID>4C5F409C-CD47-4DF2-9067-037E68FD1FE8</a:ObjectID>
<a:Name>trade_type</a:Name>
<a:Code>trade_type</a:Code>
@ -3779,7 +3804,7 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Comment>交易类型(建仓,加仓,减仓,平仓,止损)</a:Comment>
<a:DataType>int</a:DataType>
</o:Column>
<o:Column Id="o69">
<o:Column Id="o71">
<a:ObjectID>F47DA95D-9187-4862-87BB-AC8D7A6313C7</a:ObjectID>
<a:Name>trade_note</a:Name>
<a:Code>trade_note</a:Code>
@ -3792,7 +3817,7 @@ LABL 0 新宋体,8,N</a:FontList>
</o:Column>
</c:Columns>
<c:Keys>
<o:Key Id="o70">
<o:Key Id="o72">
<a:ObjectID>12C60F49-270E-442C-9EDC-F5DB2664E2D6</a:ObjectID>
<a:Name>Key_1</a:Name>
<a:Code>Key_1</a:Code>
@ -3801,17 +3826,17 @@ LABL 0 新宋体,8,N</a:FontList>
<a:ModificationDate>1542187776</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<c:Key.Columns>
<o:Column Ref="o61"/>
<o:Column Ref="o63"/>
</c:Key.Columns>
</o:Key>
</c:Keys>
<c:PrimaryKey>
<o:Key Ref="o70"/>
<o:Key Ref="o72"/>
</c:PrimaryKey>
</o:Table>
</c:Tables>
<c:DefaultGroups>
<o:Group Id="o71">
<o:Group Id="o73">
<a:ObjectID>46EC3E2A-6CBF-421A-9DA8-6BCCEDEC7DF5</a:ObjectID>
<a:Name>PUBLIC</a:Name>
<a:Code>PUBLIC</a:Code>
@ -3822,13 +3847,13 @@ LABL 0 新宋体,8,N</a:FontList>
</o:Group>
</c:DefaultGroups>
<c:TargetModels>
<o:TargetModel Id="o72">
<o:TargetModel Id="o74">
<a:ObjectID>3AE1A68F-D267-4CD1-91CC-A80630C419C0</a:ObjectID>
<a:Name>MySQL 5.0</a:Name>
<a:Code>MYSQL50</a:Code>
<a:CreationDate>1542181843</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1542248966</a:ModificationDate>
<a:ModificationDate>1542787798</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:TargetModelURL>file:///%_DBMS%/mysql50.xdb</a:TargetModelURL>
<a:TargetModelID>F4F16ECD-F2F1-4006-AF6F-638D5C65F35E</a:TargetModelID>

View File

@ -0,0 +1,50 @@
package com.cronie.mengyu.common.constants;
public final class TradeConstants {
//1.固定板指
public final static String GOODS_FIXED_SH_PLATE_INDEX = "000001";//上证
public final static String GOODS_FIXED_SZ_PLATE_INDEX = "399001";//深证
public final static String GOODS_FIXED_ZXB_PLATE_INDEX = "399005";//中小板
public final static String GOODS_FIXED_CYB_PLATE_INDEX = "399006";//创业板
//2.商品类型
public final static String GOODS_TYPE_STOCK = "stock";
public final static String GOODS_TYPE_FUND = "fund";
//3.所属板块
public final static String GOODS_PLATE_BELONG_SH="sh" ;
public final static String GOODS_PLATE_BELONG_SZ="sz" ;
//4.数据源源
public final static String DATASOURCE_SINA_URL="http://hq.sinajs.cn/list=" ;//新浪请求地址
public final static String DATASOURCE_SINA = "Sina" ;//数据来源:新浪
public final static String DATASOURCE_SINA_MIN_UNIT_VOL = "1000000" ;//成交量单位
public final static String DATASOURCE_TENCENT_URL="http://qt.gtimg.cn/q=" ;//腾讯请求地址
public final static String DATASOURCE_TENCENT = "Tencent" ;//数据来源:腾讯
public final static String DATASOURCE_TENCENT_MIN_UNIT_VOL = "10000" ;//成交量单位
//5.计划模型状态
public final static Integer GOODS_MODEL_STATUS_VALID = 1 ;//启用
public final static Integer GOODS_MODEL_STATUS_INVALID = 0 ;//停用
//6.交易参数
public final static String GOODS_PRICE_INCREASE_RATE="goods_price_increase_rate" ;//涨副比
public final static String GOODS_VOLUMES_INCREASE_RATE="goods_volumes_increase_rate" ;//放量比
public final static String MONEY_POOL_LOSS_RATE = "money_pool_loss_rate" ;//风控比
public final static String MONEY_POOL_TRADE_NUMS= "money_pool_trade_nums" ;//计划交易次数
public final static String GOODS_TRADE_MIN_AMOUNT="goods_trade_min_amount" ;//最小建仓份额
//7.模型实例状态
public final static Integer MODEL_INS_STATUS_RUNING = 1 ;//进行中
public final static Integer MODEL_INS_STATUS_COMPLETED = 2 ;//已完成
public final static Integer MODEL_INS_STATUS_NOTSTARTED= 0 ;//已完成
//邮件提醒状态
public final static Integer MAIL_NOTICE_YES = 1;//已提醒
public final static Integer MAIL_NOTICE_NO = 0;//未提醒
}

View File

@ -0,0 +1,60 @@
package com.cronie.mengyu.common.goods;
import com.cronie.mengyu.domain.Goods;
/**
* 实时商品信息
* @author cronie
*
*/
public class ActualTimeGoods extends Goods {
private static final long serialVersionUID = 1L;
public double actualTimePrice ;//当前价格
public double actualTimeVolumes ;//当日成交量
public String refreshTime ;//刷新时间
public double yesterdayPrice;//昨天收盘价
public double todayPrice;//今天开盘价
public String dataSource ;
public double getActualTimePrice() {
return actualTimePrice;
}
public void setActualTimePrice(double actualTimePrice) {
this.actualTimePrice = actualTimePrice;
}
public double getActualTimeVolumes() {
return actualTimeVolumes;
}
public void setActualTimeVolumes(double actualTimeVolumes) {
this.actualTimeVolumes = actualTimeVolumes;
}
public String getRefreshTime() {
return refreshTime;
}
public void setRefreshTime(String refreshTime) {
this.refreshTime = refreshTime;
}
public double getYesterdayPrice() {
return yesterdayPrice;
}
public void setYesterdayPrice(double yesterdayPrice) {
this.yesterdayPrice = yesterdayPrice;
}
public double getTodayPrice() {
return todayPrice;
}
public void setTodayPrice(double todayPrice) {
this.todayPrice = todayPrice;
}
public String getDataSource() {
return dataSource;
}
public void setDataSource(String dataSource) {
this.dataSource = dataSource;
}
}

View File

@ -0,0 +1,11 @@
package com.cronie.mengyu.common.goods;
/**
*
* @author cronie
* 得到商品的实时信息
*/
public interface ILoadGoodsInfo {
ActualTimeGoods loadGoodsInfo(String code);
}

View File

@ -0,0 +1,35 @@
package com.cronie.mengyu.common.goods;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class LoadGoodsInfoFactory implements ApplicationContextAware{
ApplicationContext ctx = null;
@Override
public void setApplicationContext(ApplicationContext arg0) throws BeansException {
ctx = arg0 ;
}
public ILoadGoodsInfo getLoadGoodsInfoInstance() {
ILoadGoodsInfo loadGoodsInfo = null;
Long time = System.currentTimeMillis();
if(time%2==0){
loadGoodsInfo = ctx.getBean("sinaDataSource", ILoadGoodsInfo.class) ;
}else {
loadGoodsInfo = ctx.getBean("tencentDataSource", ILoadGoodsInfo.class) ;
}
return loadGoodsInfo ;
}
}

View File

@ -0,0 +1,125 @@
package com.cronie.mengyu.common.goods.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.cronie.mengyu.common.constants.TradeConstants;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.cronie.mengyu.common.goods.ILoadGoodsInfo;
import com.cronie.mengyu.common.http.HttpUtil;
public abstract class AbstractLoadGoodsInfo implements ILoadGoodsInfo {
private static final Logger logger = LoggerFactory.getLogger(AbstractLoadGoodsInfo.class);
@Override
public ActualTimeGoods loadGoodsInfo(String code) {
ActualTimeGoods goodsInfo = new ActualTimeGoods();
//解析代码
praseStockCode(code, goodsInfo);
//加载URL
String url = loadGoodsUrl(goodsInfo);
String data;
try {
data = HttpUtil.sendGet(url);
} catch (Exception e) {
e.printStackTrace();
logger.warn("查询品种【"+code+"】的信息失败。",e);
return null;
}
//解析数据
try {
praseData(data,goodsInfo);
} catch (Exception e) {
e.printStackTrace();
logger.warn("解析品种【"+code+"】的信息失败,原始数据:【"+data+"",e);
return null;
}
logger.info(JSONObject.toJSONString(goodsInfo));
return goodsInfo;
}
/**
* 解析URl
* @return String
*/
protected abstract String loadGoodsUrl(ActualTimeGoods goodsInfo);
/**
* 解析数据
* @param data
* @return
* @throws Exception
*/
protected abstract void praseData(String data,ActualTimeGoods goodsInfo) throws Exception;
/**
* @author: 王冲
* @description:解析代码 信息
* @date:2016年3月4日
*/
protected void praseStockCode(String code ,ActualTimeGoods goodsInfo){
goodsInfo.setCode(code);
//版指
if(code.equalsIgnoreCase(TradeConstants.GOODS_FIXED_SH_PLATE_INDEX)) {
goodsInfo.setPlateType(TradeConstants.GOODS_PLATE_BELONG_SH);
goodsInfo.setCodeType(TradeConstants.GOODS_TYPE_STOCK);
}else if (code.equalsIgnoreCase(TradeConstants.GOODS_FIXED_SZ_PLATE_INDEX)||
code.equalsIgnoreCase(TradeConstants.GOODS_FIXED_CYB_PLATE_INDEX)||
code.equalsIgnoreCase(TradeConstants.GOODS_FIXED_ZXB_PLATE_INDEX) ) {
goodsInfo.setPlateType(TradeConstants.GOODS_PLATE_BELONG_SZ);
goodsInfo.setCodeType(TradeConstants.GOODS_TYPE_STOCK);
}
//
else if(code.startsWith("60")) {
goodsInfo.setPlateType(TradeConstants.GOODS_PLATE_BELONG_SH);
goodsInfo.setCodeType(TradeConstants.GOODS_TYPE_STOCK);
}else if (code.startsWith("002")|| code.startsWith("300")) {
goodsInfo.setPlateType(TradeConstants.GOODS_PLATE_BELONG_SZ);
goodsInfo.setCodeType(TradeConstants.GOODS_TYPE_STOCK);
}else if (code.startsWith("510")) {
goodsInfo.setPlateType(TradeConstants.GOODS_PLATE_BELONG_SH);
goodsInfo.setCodeType(TradeConstants.GOODS_TYPE_FUND);
}else if ( code.startsWith("150")) {
goodsInfo.setPlateType(TradeConstants.GOODS_PLATE_BELONG_SZ);
goodsInfo.setCodeType(TradeConstants.GOODS_TYPE_FUND);
}
// if(stockCode.equalsIgnoreCase("000001")){
//
//
// }else if(stockCode.startsWith("60")){
// stockCodeInfo.setStockType(TYPE_STOCK);
// stockCodeInfo.setBelong("sh");
// }else if(stockCode.startsWith("000")){
// stockCodeInfo.setStockType(TYPE_STOCK);
// stockCodeInfo.setBelong("sz");
// }else if(stockCode.startsWith("300")){
// stockCodeInfo.setStockType(TYPE_STOCK);
// stockCodeInfo.setBelong("sz");
// }else if(stockCode.startsWith("399")){
// stockCodeInfo.setStockType(TYPE_STOCK);
// stockCodeInfo.setBelong("sz");
// }else if(stockCode.startsWith("150")){
// stockCodeInfo.setStockType(TYPE_FUND);
// stockCodeInfo.setBelong("sz");
// }else if(stockCode.startsWith("002")){
// stockCodeInfo.setStockType(TYPE_STOCK);
// stockCodeInfo.setBelong("sz");
// }else if(stockCode.startsWith("502")){
// stockCodeInfo.setStockType(TYPE_FUND);
// stockCodeInfo.setBelong("sh");
// }else {
// stockCodeInfo.setBelong("sh");
// stockCodeInfo.setStockType(TYPE_FUND);
// }
}
}

View File

@ -0,0 +1,71 @@
package com.cronie.mengyu.common.goods.impl;
import java.math.BigDecimal;
import java.util.Date;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.cronie.mengyu.common.constants.TradeConstants;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.ruoyi.common.utils.DateUtils;
@Component("sinaDataSource")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SinaLoadGoodsInfoImpl extends AbstractLoadGoodsInfo {
@Override
public String loadGoodsUrl(ActualTimeGoods goodsInfo) {
return TradeConstants.DATASOURCE_SINA_URL.concat(goodsInfo.getPlateType()).concat(goodsInfo.getCode());
}
// 0大秦铁路股票名字
// 127.55今日开盘价
// 227.25昨日收盘价
// 326.91当前价格
// 427.55今日最高价
// 526.20今日最低价
// 626.91竞买价买一报价
// 726.92竞卖价卖一报价
// 822114263成交的股票数由于股票交易以一百股为基本单位所以在使用时通常把该值除以一百
// 9589824680成交金额单位为为了一目了然通常以万元为成交金额的单位所以通常把该值除以一万
// 104695买一申请4695股即47手
// 1126.91买一报价
// 1257590买二
// 1326.90买二
// 1414700买三
// 1526.89买三
// 1614300买四
// 1726.88买四
// 1815100买五
// 1926.87买五
// 203100卖一申报3100股即31手
// 2126.92卖一报价
// (22, 23), (24, 25), (26,27), (28, 29)分别为卖二卖四的情况
// 302008-01-11日期
// 3115:05:32时间
@Override
public void praseData(String data,ActualTimeGoods goodsInfo) throws Exception{
String pureData = null;
pureData = data.substring(data.indexOf("\"")+1, data.lastIndexOf("\""));
String datas[] = pureData.split(",");
goodsInfo.setActualTimePrice(Double.parseDouble(datas[3]));
goodsInfo.setYesterdayPrice(Double.parseDouble(datas[2]));
goodsInfo.setTodayPrice(Double.parseDouble(datas[1]));
BigDecimal bd = new BigDecimal(datas[8]) ;
//(100股)*单位10000= 1000000 万手
BigDecimal _i = new BigDecimal(TradeConstants.DATASOURCE_SINA_MIN_UNIT_VOL) ;
double v = bd.divide(_i,2,BigDecimal.ROUND_HALF_UP).doubleValue();
goodsInfo.setActualTimeVolumes(v);
goodsInfo.setName(datas[0]);
goodsInfo.setDataSource(TradeConstants.DATASOURCE_SINA);
goodsInfo.setRefreshTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date()));
}
}

View File

@ -0,0 +1,80 @@
package com.cronie.mengyu.common.goods.impl;
import java.math.BigDecimal;
import java.util.Date;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.cronie.mengyu.common.constants.TradeConstants;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.ruoyi.common.utils.DateUtils;
@Component("tencentDataSource")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class TencentLoadGoodsInfoImpl extends AbstractLoadGoodsInfo {
@Override
public String loadGoodsUrl(ActualTimeGoods goodsInfo) {
return TradeConstants.DATASOURCE_TENCENT_URL.concat(goodsInfo.getPlateType()).concat(goodsInfo.getCode());
}
// 0: 未知
// 1: 名字
// 2: 代码
// 3: 当前价格
// 4: 昨收
// 5: 今开
// 6: 成交量
// 7: 外盘
// 8: 内盘
// 9: 买一
// 10: 买一量
// 11-18: 买二 买五
// 19: 卖一
// 20: 卖一量
// 21-28: 卖二 卖五
// 29: 最近逐笔成交
// 30: 时间
// 31: 涨跌
// 32: 涨跌%
// 33: 最高
// 34: 最低
// 35: 价格/成交量/成交额
// 36: 成交量
// 37: 成交额
// 38: 换手率
// 39: 市盈率
// 40:
// 41: 最高
// 42: 最低
// 43: 振幅
// 44: 流通市值
// 45: 总市值
// 46: 市净率
// 47: 涨停价
// 48: 跌停价
@Override
public void praseData(String data,ActualTimeGoods goodsInfo) throws Exception{
String pureData = null;
pureData = data.substring(data.indexOf("\"")+1, data.lastIndexOf("\""));
String datas[] = pureData.split("~");
goodsInfo.setActualTimePrice(Double.parseDouble(datas[3]));
goodsInfo.setYesterdayPrice(Double.parseDouble(datas[4]));
goodsInfo.setTodayPrice(Double.parseDouble(datas[5]));
BigDecimal bd = new BigDecimal(datas[6]) ;
//(100股)*单位10000= 1000000 万手
BigDecimal _i = new BigDecimal(TradeConstants.DATASOURCE_TENCENT_MIN_UNIT_VOL) ;
double v = bd.divide(_i,2,BigDecimal.ROUND_HALF_UP).doubleValue();
goodsInfo.setActualTimeVolumes(v);
goodsInfo.setName(datas[1]);
goodsInfo.setDataSource(TradeConstants.DATASOURCE_TENCENT);
goodsInfo.setRefreshTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date()));
}
}

View File

@ -0,0 +1,395 @@
package com.cronie.mengyu.common.http;
import java.io.IOException;
import java.net.InetAddress;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.config.MessageConstraints;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.config.SocketConfig;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpConnectionFactory;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.DefaultHttpResponseParser;
import org.apache.http.impl.conn.DefaultHttpResponseParserFactory;
import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.conn.SystemDefaultDnsResolver;
import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
import org.apache.http.io.HttpMessageParser;
import org.apache.http.io.HttpMessageParserFactory;
import org.apache.http.io.HttpMessageWriterFactory;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.message.BasicLineParser;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.message.LineParser;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.CharArrayBuffer;
import org.apache.http.util.EntityUtils;
/**
* Http
*
* @author Zhao.Hailin
*
*/
public class HttpUtil {
/** 连接池管理 */
private static volatile PoolingHttpClientConnectionManager connManager = null;
/** 配置信息 */
private static volatile Properties properties = null;
private static final String CLIENT_PROTOCOL_ERR = "客户端协议异常";
private static final String HTTP_HOST_CONNECT_ERR = "连接请求被拒绝";
private static final String SOCKET_TIMEOUT_ERR = "连接请求超时";
private static final String IO_ERR = "通信过程中发生了异常";
private static final String CLOSE_IO_ERR = "关闭连接时发生了异常";
// private static final String UNSUPPORTED_ENCODING_ERR = "不支持的编码格式";
/**
* HttpClient POST
*
* @param url URL
* @param params Map<String, Object>
* @return String
* @throws Exception
*/
public static String sendPost(String url, Map<String, Object> params) throws Exception {
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> pairs = covertParams2NVPS(params);
try {
httpPost.setEntity(new UrlEncodedFormEntity(pairs, "utf-8"));
} catch (Exception e) {
throw e;
}
return getResult(httpPost, Charset.forName("utf-8"));
}
private static List<NameValuePair> covertParams2NVPS(
Map<String, Object> params) {
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
for (Map.Entry<String, Object> param : params.entrySet()) {
pairs.add(new BasicNameValuePair(param.getKey(),
nullIsEmptyStr(param.getValue())));
}
return pairs;
}
/**
* application/viid+json, utf-8 编码的 POST 请求华尊 1400 专用
*
* @param url 请求 URI
* @return String JSON格式的字符串
* @throws Exception
*/
public static String sendGet(String url) throws Exception {
// add request header
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("Content-Type", "application/viid+json");
headers.put("User-Identify", "51340000041205914046");
headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
headers.put("Connection", "Keep-Alive");
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");
return get(url, Charset.forName("utf-8"), headers);
}
/**
* GET 请求
*
* @param uri 请求 URI
* @param charset 字符集
* @param headers 请求头
* @return String 响应实体消息
* @throws Exception
*/
public static String get(String uri, Charset charset,
Map<String, Object> headers) throws Exception {
HttpGet httpGet = new HttpGet(uri);
return getResult(httpGet, charset);
}
// /**
// * 设置请求头
// *
// * @param request HttpGet/HttpPost
// * @param headers 请求头
// */
// private static void setHeader(HttpRequestBase request,
// Map<String, Object> headers) {
// if (headers != null) {
// for (Map.Entry<String, Object> entry : headers.entrySet()) {
// request.setHeader(entry.getKey(),
// nullIsEmptyStr(entry.getValue()));
// }
// }
// }
/**
* 将对象转换成 String 的表现形式如果该对象是 null则返回空字符串
*
* @param obj Object
* @return String
*/
private static String nullIsEmptyStr(Object obj) {
return obj == null ? "" : String.valueOf(obj);
}
/**
* 获取响应实体消息
*
* @param request HttpGet/HttpPost
* @param charset 字符集
* @return String 一个新分配的字符串
* @throws Exception
*/
private static String getResult(HttpRequestBase request, Charset charset) throws Exception {
HttpClientContext context = HttpClientContext.create();
CloseableHttpResponse response = null;
try {
response = getHttpClient().execute(request, context);
// 获取响应状态码
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK) {
HttpEntity entity = response.getEntity();
if (entity != null) {
// String result = new String(EntityUtils.toByteArray(entity),
// charset);
String result = EntityUtils.toString(entity,charset) ;
// String result = new String(EntityUtils.toByteArray(entity));
return result;
}
}
} catch (IOException e) {
if (e instanceof ClientProtocolException)
throw new Exception(CLIENT_PROTOCOL_ERR);
if (e instanceof HttpHostConnectException)
throw new Exception(HTTP_HOST_CONNECT_ERR);
else if (e instanceof SocketTimeoutException)
throw new Exception(SOCKET_TIMEOUT_ERR);
else
throw new Exception(IO_ERR);
} finally {
if (response != null) {
try {
response.close();
} catch (IOException e) {
throw new Exception(CLOSE_IO_ERR);
}
}
}
return null;
}
/**
* 从连接池中获取 HttpClient
*
* @return CloseableHttpClient
*/
private static CloseableHttpClient getHttpClient() {
defaultConfigure();
// 默认的请求配置
RequestConfig defaultRequestConfig = RequestConfig
.custom()
.setConnectTimeout((int) properties.get("connectTimeout"))
.setSocketTimeout((int) properties.get("socketTimeout"))
.setConnectionRequestTimeout(
(int) properties.get("connectionRequestTimeout"))
.build();
// 使用给定的自定义依赖项和配置创建 HttpClient
CloseableHttpClient httpClient = HttpClients
.custom()
.setConnectionManager(getConnManager())
.setConnectionManagerShared(false)
.evictIdleConnections((int) properties.get("maxIdleTime"),
TimeUnit.SECONDS)
.evictExpiredConnections()
.setConnectionTimeToLive(
(int) properties.get("connTimeToLive"),
TimeUnit.SECONDS)
.setDefaultRequestConfig(defaultRequestConfig)
.setConnectionReuseStrategy(
DefaultConnectionReuseStrategy.INSTANCE)
.setKeepAliveStrategy(
DefaultConnectionKeepAliveStrategy.INSTANCE)
.setRetryHandler(
new DefaultHttpRequestRetryHandler((int) properties
.get("retryCount"), false)).build();
return httpClient;
}
/**
* 配置连接池
*
* @return PoolingHttpClientConnectionManager
*/
private static PoolingHttpClientConnectionManager getConnManager() {
if (connManager == null) {
synchronized (HttpUtil.class) {
if (connManager == null) {
HttpMessageParserFactory<HttpResponse> responseParserFactory = new DefaultHttpResponseParserFactory() {
@Override
public HttpMessageParser<HttpResponse> create(
final SessionInputBuffer buffer,
final MessageConstraints constraints) {
LineParser lineParser = new BasicLineParser() {
@Override
public Header parseHeader(
final CharArrayBuffer buffer)
throws ParseException {
return super.parseHeader(buffer);
}
};
return new DefaultHttpResponseParser(buffer,
lineParser,
DefaultHttpResponseFactory.INSTANCE,
constraints) {
@Override
protected boolean reject(
final CharArrayBuffer line,
final int count) {
// 无限地忽略状态行前面的所有垃圾
return false;
}
};
}
};
HttpMessageWriterFactory<HttpRequest> requestWriterFactory = new DefaultHttpRequestWriterFactory();
// 定制初始化传出 HTTP 连接的过程
HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory = new ManagedHttpClientConnectionFactory(
requestWriterFactory, responseParserFactory);
// 使用自定义 DNS 解析器覆盖系统 DNS 解析
DnsResolver dnsResolver = new SystemDefaultDnsResolver() {
@Override
public InetAddress[] resolve(final String host)
throws UnknownHostException {
return super.resolve(host);
}
};
// 创建自定义连接套接字工厂的注册表
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
.<ConnectionSocketFactory> create()
.register("http",
PlainConnectionSocketFactory.INSTANCE)
.register(
"https",
new SSLConnectionSocketFactory(SSLContexts
.createSystemDefault())).build();
// 使用自定义配置创建连接管理器
connManager = new PoolingHttpClientConnectionManager(
socketFactoryRegistry, connFactory, dnsResolver);
// 套接字配置
SocketConfig socketConfig = SocketConfig.custom()
.setTcpNoDelay(true).build();
connManager.setDefaultSocketConfig(socketConfig);
connManager.setValidateAfterInactivity((int) properties
.get("validateAfterInactivity"));
connManager.setMaxTotal((int) properties.get("maxTotal"));
connManager.setDefaultMaxPerRoute((int) properties
.get("defaultMaxPerRoute"));
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
if (connManager != null) {
connManager.close();
}
}
});
}
}
}
return connManager;
}
/**
* 加载默认配置
*/
private static void defaultConfigure() {
if (properties == null) {
synchronized (HttpUtil.class) {
if (properties == null) {
properties = new Properties();
properties.put("validateAfterInactivity", 5000);
// 最大连接数
properties.put("maxTotal", 25);
// 每个路由的最大连接数
properties.put("defaultMaxPerRoute", 5);
// 连接超时时间单位毫秒
properties.put("connectTimeout", 3000);
// 等待数据超时时间单位毫秒
properties.put("socketTimeout", 1000 * 60 * 3);
// 从连接池获取连接的等待超时时间单位毫秒
properties.put("connectionRequestTimeout", 1000 * 60);
properties.put("maxIdleTime", 60);
properties.put("connTimeToLive", 60);
properties.put("retryCount", 0);
}
}
}
}
}

View File

@ -0,0 +1,149 @@
package com.cronie.mengyu.common.json;
import org.springframework.stereotype.Component;
/**
* 该类提供格式化JSON字符串的方法
* 该类的方法formatJson将JSON字符串格式化方便查看JSON数据
* <p>例如
* </p><p>JSON字符串["yht","xzj","zwy"]
* </p><p>格式化为
* </p><p>[
* </p><p> "yht",
* </p><p> "xzj",
* </p><p> "zwy"
* </p><p>]
*
* </p><p>使用算法如下
* </p><p>对输入字符串追个字符的遍历
* </p><p>1获取当前字符
* </p><p>2如果当前字符是前方括号前花括号做如下处理
* </p><p>1如果前面还有字符并且字符为打印换行和缩进字符字符串
* </p><p>2打印当前字符
* </p><p>3前方括号前花括号的后面必须换行打印换行
* </p><p>4每出现一次前方括号前花括号缩进次数增加一次打印新行缩进
* </p><p>5进行下一次循环
* </p><p>3如果当前字符是后方括号后花括号做如下处理
* </p><p>1后方括号后花括号的前面必须换行打印换行
* </p><p>2每出现一次后方括号后花括号缩进次数减少一次打印缩进
* </p><p>3打印当前字符
* </p><p>4如果当前字符后面还有字符并且字符不为打印换行
* </p><p>5继续下一次循环
* </p><p>4如果当前字符是逗号逗号后面换行并缩进不改变缩进次数
* </p><p>5打印当前字符
*
*/
@Component
public class JSONBeautifyUtils {
/**
* 单位缩进字符串
*/
private static String SPACE = " ";
/**
* 返回格式化JSON字符串
*
* @param json 未格式化的JSON字符串
* @return 格式化的JSON字符串
*/
public String formatJson(String json)
{
StringBuffer result = new StringBuffer();
int length = json.length();
int number = 0;
char key = 0;
//遍历输入字符串
for (int i = 0; i < length; i++)
{
//1获取当前字符
key = json.charAt(i);
//2如果当前字符是前方括号前花括号做如下处理
if((key == '[') || (key == '{') )
{
//1如果前面还有字符并且字符为打印换行和缩进字符字符串
if((i - 1 > 0) && (json.charAt(i - 1) == ':'))
{
result.append('\n');
result.append(indent(number));
}
//2打印当前字符
result.append(key);
//3前方括号前花括号的后面必须换行打印换行
result.append('\n');
//4每出现一次前方括号前花括号缩进次数增加一次打印新行缩进
number++;
result.append(indent(number));
//5进行下一次循环
continue;
}
//3如果当前字符是后方括号后花括号做如下处理
if((key == ']') || (key == '}') )
{
//1后方括号后花括号的前面必须换行打印换行
result.append('\n');
//2每出现一次后方括号后花括号缩进次数减少一次打印缩进
number--;
result.append(indent(number));
//3打印当前字符
result.append(key);
//4如果当前字符后面还有字符并且字符不为打印换行
if(((i + 1) < length) && (json.charAt(i + 1) != ','))
{
result.append('\n');
}
//5继续下一次循环
continue;
}
//4如果当前字符是逗号逗号后面换行并缩进不改变缩进次数
if((key == ','))
{
result.append(key);
result.append('\n');
result.append(indent(number));
continue;
}
//5打印当前字符
result.append(key);
}
return result.toString();
}
/**
* 返回指定次数的缩进字符串每一次缩进三个空格即SPACE
*
* @param number 缩进次数
* @return 指定缩进次数的字符串
*/
private String indent(int number)
{
StringBuffer result = new StringBuffer();
for(int i = 0; i < number; i++)
{
result.append(SPACE);
}
return result.toString();
}
public static void main(String[] args) {
JSONBeautifyUtils json = new JSONBeautifyUtils();
String str = "{'age':23,'aihao':['pashan','movies'],'name':{'firstName':'zhang','lastName':'san','aihao':['pashan','movies','name':{'firstName':'zhang','lastName':'san','aihao':['pashan','movies']}]}}";
String result = json.formatJson(str);
System.out.println(result);
}
}

View File

@ -0,0 +1,55 @@
package com.cronie.mengyu.config;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.mail.MailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Component;
@Component
@PropertySource("classpath:mail/mail.properties")
public class MailConfig {
private static final Logger logger = LoggerFactory.getLogger(MailConfig.class);
@Value("${sender.mail.host}")
String host ;
@Value("${sender.mail.port}")
String port;
@Value("${sender.mail.userName}")
String senderUserName;
@Value("${sender.mail.passWord}")
String senderPassWord;
@Value("${sender.mail.smtp.auth}")
String auth ;
@Value("${sender.mail.smtp.timeout}")
String timeOut;
/**
* 配置邮件发送器
* @return
*/
@Bean
public MailSender mailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(host);//指定用来发送Email的邮件服务器主机名
mailSender.setPort(Integer.parseInt(port));//默认端口标准的SMTP端口
mailSender.setUsername(senderUserName);//用户名
mailSender.setPassword(senderPassWord);//密码
Properties javaMailProperties = new Properties();
javaMailProperties.put("mail.smtp.auth", auth);
javaMailProperties.put("mail.smtp.timeout", timeOut);
mailSender.setJavaMailProperties(javaMailProperties);
logger.info("初始化163邮箱发送器完成.");
return mailSender;
}
public String getUserName() {
return senderUserName;
}
}

View File

@ -20,11 +20,11 @@ public class Goods extends BaseEntity
/** 品种名称 */
private String name;
/** 品种类型 (股标,基金等) */
private Integer codeType;
private String codeType;
/** 行业类型(军工,证券等) */
private Integer industryType;
private String industryType;
/** 板块类型(上证,深证 创业板等) */
private Integer plateType;
private String plateType;
/** 创建人 */
private Integer creater;
/** 创建时间 */
@ -48,33 +48,31 @@ public class Goods extends BaseEntity
{
return name;
}
public void setCodeType(Integer codeType)
{
public String getCodeType() {
return codeType;
}
public void setCodeType(String codeType) {
this.codeType = codeType;
}
public Integer getCodeType()
{
return codeType;
public String getIndustryType() {
return industryType;
}
public void setIndustryType(Integer industryType)
{
public void setIndustryType(String industryType) {
this.industryType = industryType;
}
public Integer getIndustryType()
{
return industryType;
public String getPlateType() {
return plateType;
}
public void setPlateType(Integer plateType)
{
public void setPlateType(String plateType) {
this.plateType = plateType;
}
public Integer getPlateType()
{
return plateType;
}
public void setCreater(Integer creater)
{
this.creater = creater;

View File

@ -36,6 +36,8 @@ public class GoodsTradeModel extends BaseEntity
private Integer creater;
/** 创建时间 */
private Date createTime;
/** 是否已邮件提醒 */
private Integer hasMailNotice ;
public void setModelId(Integer modelId)
{
@ -51,6 +53,14 @@ public class GoodsTradeModel extends BaseEntity
this.code = code;
}
public Integer getHasMailNotice() {
return hasMailNotice;
}
public void setHasMailNotice(Integer hasMailNotice) {
this.hasMailNotice = hasMailNotice;
}
public String getCode()
{
return code;

View File

@ -25,12 +25,22 @@ public class GoodsTradeModelIns extends BaseEntity
private Integer creater;
/** 创建时间 */
private Date createTime;
/** 是否已邮件提醒 */
private Integer hasMailNotice ;
public void setInsId(Integer insId)
{
this.insId = insId;
}
public Integer getHasMailNotice() {
return hasMailNotice;
}
public void setHasMailNotice(Integer hasMailNotice) {
this.hasMailNotice = hasMailNotice;
}
public Integer getInsId()
{
return insId;

View File

@ -0,0 +1,49 @@
package com.cronie.mengyu.monitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import com.cronie.mengyu.common.json.JSONBeautifyUtils;
import com.cronie.mengyu.config.MailConfig;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;
public abstract class AbstractMonitor implements IMonitor {
private static final Logger logger = LoggerFactory.getLogger(AbstractMonitor.class);
@Autowired(required=true)
private ISysUserService userService;
//邮箱服务器
@Autowired
protected MailSender mailSender;
//邮箱配置
@Autowired
protected MailConfig mailConfig ;
//json美化器
@Autowired
protected JSONBeautifyUtils jsonBeautifyUtils ;
@Override
public void monitor(String loginName) {
SysUser user = userService.selectUserByLoginName(loginName);
if(user == null) {
logger.error("无用户【"+loginName+"】的信息,请检查.");
return ;
}
monitorTask(user);
}
protected abstract void monitorTask(SysUser user);
}

View File

@ -0,0 +1,11 @@
package com.cronie.mengyu.monitor;
/**
* 监控
* @author Administrator
*
*/
public interface IMonitor {
//监控
public void monitor(String loginName) ;
}

View File

@ -0,0 +1,171 @@
package com.cronie.mengyu.monitor.impl;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.cronie.mengyu.common.constants.TradeConstants;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.cronie.mengyu.common.goods.ILoadGoodsInfo;
import com.cronie.mengyu.common.goods.LoadGoodsInfoFactory;
import com.cronie.mengyu.domain.GoodsTradeModel;
import com.cronie.mengyu.domain.GoodsTradeModelIns;
import com.cronie.mengyu.monitor.AbstractMonitor;
import com.cronie.mengyu.service.IGoodsTradeModelInsService;
import com.cronie.mengyu.service.IGoodsTradeModelService;
import com.cronie.mengyu.service.IMoneyPoolService;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysConfigService;
/**
*
* @author 监控模型实例
*
*/
@Component("monitorModelInstance")
public class MonitorModelInstanceImpl extends AbstractMonitor {
private static final Logger logger = LoggerFactory.getLogger(MonitorModelInstanceImpl.class);
//模型服务层
@Autowired
IGoodsTradeModelService goodstradeModelService ;
//模型实例服务层
@Autowired
IGoodsTradeModelInsService goodsTradeModelInsService ;
//系统参数服务层
@Autowired
ISysConfigService sysConfigService ;
//实时数据源工厂
@Autowired
LoadGoodsInfoFactory loadGoodsInfoFactory ;
//资金池服务
@Autowired
IMoneyPoolService moneyPoolService ;
/**
* 系统参数配置
*/
@PostConstruct
protected void initSysConfig() {
}
@Override
protected void monitorTask(SysUser user) {
GoodsTradeModelIns goodsTradeModelInsParamter = new GoodsTradeModelIns();
goodsTradeModelInsParamter.setCreater(user.getUserId().intValue());//查询用户
goodsTradeModelInsParamter.setInsStatus(TradeConstants.MODEL_INS_STATUS_RUNING);//计划是进行中的状态
goodsTradeModelInsParamter.setHasMailNotice(TradeConstants.MAIL_NOTICE_NO);
List<GoodsTradeModelIns> listTradeModelIns = goodsTradeModelInsService.selectGoodsTradeModelInsList(goodsTradeModelInsParamter) ;
logger.info("监控到用户【"+user.getLoginName()+"】的交易模型实例有【"+listTradeModelIns.size()+"】个。");
for(GoodsTradeModelIns planModelIns : listTradeModelIns) {
//监控模型
monitorGoodsTradeModelIns(planModelIns, user);
}
}
/**
* 监控计划模型
* @param model
* @param user
*/
protected void monitorGoodsTradeModelIns(GoodsTradeModelIns planModelIns,SysUser user) {
logger.info("开始扫描用户【"+user.getLoginName()+"】,模型【"+JSONObject.toJSONString(planModelIns)+"】....");
ILoadGoodsInfo loadGoodsInfoInterface = loadGoodsInfoFactory.getLoadGoodsInfoInstance() ;
//模型信息
GoodsTradeModel planModel = goodstradeModelService.selectGoodsTradeModelById(planModelIns.getModelId()) ;
//得到实时品种信息
ActualTimeGoods actualTimeGoods = loadGoodsInfoInterface.loadGoodsInfo(planModel.getCode()) ;
if(actualTimeGoods == null ) {
logger.error("查询的实时品种信息失败.");
return ;
}
//过滤
//1.当前价为0
if(actualTimeGoods.getActualTimePrice() == 0 ){
return ;
}
//2.如果当前价在此买入 卖出区间内则跳过验证
if(actualTimeGoods.getActualTimePrice()<planModel.getExitPrice().doubleValue() && actualTimeGoods.getActualTimePrice()>planModel.getStopPrice().doubleValue()){
return;
}
//至此说明可以平仓了
//1.设置今日不提醒邮件
planModelIns.setHasMailNotice(TradeConstants.MAIL_NOTICE_YES);
goodsTradeModelInsService.updateGoodsTradeModelIns(planModelIns) ;
//2.根据计划实例生成平仓实例
completeModelIns(actualTimeGoods, planModel,planModelIns, user);
logger.info("完成扫描用户【"+user.getLoginName()+"】,模型【"+JSONObject.toJSONString(planModel)+"】.");
}
/**
* 根据模型建仓
* @param actualTimeGoods
* @param planModel
* @param user
*/
protected void completeModelIns(final ActualTimeGoods actualTimeGoods,final GoodsTradeModel planModel,GoodsTradeModelIns planModelIns, final SysUser user) {
//止损价
double lossPrice = planModel.getStopPrice().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() ;
//平仓价
double exitPrice = planModel.getExitPrice().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() ;
//发送邮箱提醒
Map<String,Object> data = new HashMap<String,Object>();
data.put("品种名称", actualTimeGoods.getName()) ;
data.put("实际平仓价格", actualTimeGoods.getActualTimePrice()) ;
String subject = "品种名称:".concat(actualTimeGoods.getName()).concat(",").concat("平仓价格:").concat(String.valueOf(actualTimeGoods.getActualTimePrice())) ;
data.put("计划平仓价格", exitPrice) ;
data.put("止损价格", lossPrice) ;
data.put("平仓时间", actualTimeGoods.getRefreshTime()) ;
String content = JSONObject.toJSONString(data) ;
logger.info("正在向用户【"+user.getLoginName()+"("+user.getEmail()+")】发送平仓邮件.主题【"+subject+"】......");
SimpleMailMessage message = new SimpleMailMessage();//消息构造器
message.setFrom(mailConfig.getUserName());//发件人
message.setTo(user.getEmail());//收件人
message.setSubject( subject );//主题
message.setText(jsonBeautifyUtils.formatJson(content));//正文
mailSender.send(message);
logger.info("已成功发送用户【"+user.getLoginName()+"("+user.getEmail()+")】平仓邮件.主题【"+subject+"】.");
}
}

View File

@ -0,0 +1,248 @@
package com.cronie.mengyu.monitor.impl;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.cronie.mengyu.common.constants.TradeConstants;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.cronie.mengyu.common.goods.ILoadGoodsInfo;
import com.cronie.mengyu.common.goods.LoadGoodsInfoFactory;
import com.cronie.mengyu.domain.GoodsTradeModel;
import com.cronie.mengyu.domain.MoneyPool;
import com.cronie.mengyu.monitor.AbstractMonitor;
import com.cronie.mengyu.service.IGoodsTradeModelService;
import com.cronie.mengyu.service.IMoneyPoolService;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysConfigService;
/**
*
* @author 监控计划模型
*
*/
@Component("monitorTradeModel")
public class MonitorTradeModelImpl extends AbstractMonitor {
private static final Logger logger = LoggerFactory.getLogger(MonitorTradeModelImpl.class);
//模型服务层
@Autowired
IGoodsTradeModelService goodsTradeModelService ;
//系统参数服务层
@Autowired
ISysConfigService sysConfigService ;
//实时数据源工厂
@Autowired
LoadGoodsInfoFactory loadGoodsInfoFactory ;
//资金池服务
@Autowired
IMoneyPoolService moneyPoolService ;
//投资品种涨幅比
BigDecimal goodsPriceIncreaseRate ;
//投资品种放量比
BigDecimal goodsVolumesIncreaseRate;
//资金池风险控比(至多亏损资金池中的百分之多少钱)
BigDecimal moneyPoolLossRate;
//交易次数
BigDecimal moneyPoolTradeNums ;
//最小交易份额
Integer goodsTradeMinAmount = 100;
/**
* 系统参数配置
*/
@PostConstruct
protected void initSysConfig() {
//1.设置涨副比
String goodsPriceIncreaseRateStr = sysConfigService.selectConfigByKey(TradeConstants.GOODS_PRICE_INCREASE_RATE) ;
if(StringUtils.isBlank(goodsPriceIncreaseRateStr) || StringUtils.isEmpty(goodsPriceIncreaseRateStr)) {
logger.error("尚未配置系统参数【goods_Price_Increase_Rate】.");
}else {
goodsPriceIncreaseRate = new BigDecimal(goodsPriceIncreaseRateStr.trim());
}
//2.设置放量比
String goodsVolumesIncreaseRateStr = sysConfigService.selectConfigByKey(TradeConstants.GOODS_VOLUMES_INCREASE_RATE) ;
if(StringUtils.isBlank(goodsVolumesIncreaseRateStr) || StringUtils.isEmpty(goodsVolumesIncreaseRateStr)) {
logger.error("尚未配置系统参数【goods_Volumes_Increase_Rate】.");
}else {
goodsVolumesIncreaseRate = new BigDecimal(goodsVolumesIncreaseRateStr.trim());
}
//3.风控比
String moneyPoolLossRateStr = sysConfigService.selectConfigByKey(TradeConstants.MONEY_POOL_LOSS_RATE) ;
if(StringUtils.isBlank(moneyPoolLossRateStr) || StringUtils.isEmpty(moneyPoolLossRateStr)) {
logger.error("尚未配置系统参数【money_Pool_Loss_Rate】.");
}else {
moneyPoolLossRate = new BigDecimal(moneyPoolLossRateStr.trim());
}
//4.交易次数
String moneyPoolTradeNumsStr = sysConfigService.selectConfigByKey(TradeConstants.MONEY_POOL_TRADE_NUMS) ;
if(StringUtils.isBlank(moneyPoolTradeNumsStr) || StringUtils.isEmpty(moneyPoolTradeNumsStr)) {
logger.error("尚未配置系统参数【money_Pool_Trade_Nums】.");
}else {
moneyPoolTradeNums = new BigDecimal(moneyPoolTradeNumsStr.trim());
}
//4.交易份额
String goodsTradeMinAmountStr = sysConfigService.selectConfigByKey(TradeConstants.GOODS_TRADE_MIN_AMOUNT) ;
if(StringUtils.isBlank(goodsTradeMinAmountStr) || StringUtils.isEmpty(goodsTradeMinAmountStr)) {
logger.error("尚未配置系统参数【goods_trade_min_amount】.");
}else {
goodsTradeMinAmount = Integer.parseInt(goodsTradeMinAmountStr) ;
}
logger.info("完成初始化模型监控参数");
}
@Override
protected void monitorTask(SysUser user) {
GoodsTradeModel goodsTradeModelParamter = new GoodsTradeModel();
goodsTradeModelParamter.setCreater(user.getUserId().intValue());//查询用户
goodsTradeModelParamter.setModelStatus(TradeConstants.GOODS_MODEL_STATUS_VALID);//启用状态
goodsTradeModelParamter.setHasMailNotice(TradeConstants.MAIL_NOTICE_NO);
List<GoodsTradeModel> listTradeModel = goodsTradeModelService.selectGoodsTradeModelList(goodsTradeModelParamter) ;
logger.info("监控用户【"+user.getLoginName()+"】的交易计划模型有【"+listTradeModel.size()+"】个。");
for(GoodsTradeModel planModel : listTradeModel) {
//监控模型
monitorGoodsTradeModel(planModel, user);
}
}
/**
* 监控计划模型
* @param model
* @param user
*/
protected void monitorGoodsTradeModel(GoodsTradeModel planModel,SysUser user) {
logger.info("开始扫描用户【"+user.getLoginName()+"】,模型【"+JSONObject.toJSONString(planModel)+"】....");
ILoadGoodsInfo loadGoodsInfoInterface = loadGoodsInfoFactory.getLoadGoodsInfoInstance() ;
//得到实时品种信息
ActualTimeGoods actualTimeGoods = loadGoodsInfoInterface.loadGoodsInfo(planModel.getCode()) ;
if(actualTimeGoods == null ) {
logger.error("查询的实时品种信息失败.");
return ;
}
//过滤
//1.当前价为0
if(actualTimeGoods.getActualTimePrice() == 0 ){
return ;
}
//2.如果当前价不在此买入 卖出区间内则跳过建仓
if(actualTimeGoods.getActualTimePrice()>planModel.getExitPrice().doubleValue()||actualTimeGoods.getActualTimePrice()<planModel.getStopPrice().doubleValue()){
return;
}
//3.放量比过滤
double planVol = (planModel.getBasicVolumes().add( planModel.getBasicVolumes().multiply(goodsVolumesIncreaseRate))).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
//如果没有放量
if(actualTimeGoods.getActualTimeVolumes()<planVol){
return ;
}
//4.如果放量了 但是没有创新高
if(actualTimeGoods.getActualTimePrice() < planModel.getBuildingPrice().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()){
return ;
}
//5.价格过滤
double planPrice = (planModel.getBuildingPrice().add( planModel.getBuildingPrice().multiply(goodsPriceIncreaseRate))).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
//如果没有放量
if(actualTimeGoods.getActualTimePrice()<planPrice){
return ;
}
//至此说明可以建仓了
//1.将计划模的状态设置成停用状态
planModel.setModelStatus(TradeConstants.GOODS_MODEL_STATUS_INVALID);
planModel.setHasMailNotice(TradeConstants.MAIL_NOTICE_YES);
goodsTradeModelService.updateGoodsTradeModel(planModel) ;
//2.根据计划模型生成建仓实例
buildModelIns(actualTimeGoods, planModel, user);
logger.info("完成扫描用户【"+user.getLoginName()+"】,模型【"+JSONObject.toJSONString(planModel)+"】.");
}
/**
* 根据模型建仓
* @param actualTimeGoods
* @param planModel
* @param user
*/
protected void buildModelIns(final ActualTimeGoods actualTimeGoods,final GoodsTradeModel planModel, final SysUser user) {
//预期成本价
double buildPrice = planModel.getBuildingPrice().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() ;
//止损价
double lossPrice = planModel.getStopPrice().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() ;
//每次亏损金额
BigDecimal perBuildLossMoney = null;
//止损额度
double priceDifferences = actualTimeGoods.getActualTimePrice() - lossPrice;
//建仓份额
int mockAmount = 0;
//总资金
MoneyPool moneyPool = moneyPoolService.selectMoneyPoolById(user.getUserId().intValue()) ;
BigDecimal repMoney = moneyPool.getMoneyPool() ;
//计算每次亏损金额
perBuildLossMoney = repMoney.multiply(moneyPoolLossRate).divide(moneyPoolTradeNums) ;
//(repMoney*sysLossRate)/num;
//计算买入份额
mockAmount = (int) (perBuildLossMoney.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()/priceDifferences) ;
//opt:2015-09-25 换算成MIN_AMOUNT的整数倍.
mockAmount = (mockAmount/goodsTradeMinAmount)*goodsTradeMinAmount;
if(mockAmount == 0){
mockAmount = goodsTradeMinAmount;
}
//发送邮箱提醒
Map<String,Object> data = new HashMap<String,Object>();
data.put("品种名称", actualTimeGoods.getName()) ;
data.put("建仓价格", buildPrice) ;
String subject = "品种名称:".concat(actualTimeGoods.getName()).concat(",").concat("建仓价格:").concat(String.valueOf(buildPrice)) ;
data.put("建仓份额", mockAmount) ;
data.put("建仓金额", mockAmount*buildPrice) ;
data.put("建仓时间", actualTimeGoods.getRefreshTime()) ;
String content = JSONObject.toJSONString(data) ;
logger.info("正在向用户【"+user.getLoginName()+"("+user.getEmail()+")】发送建仓邮件.主题【"+subject+"】......");
SimpleMailMessage message = new SimpleMailMessage();//消息构造器
message.setFrom(mailConfig.getUserName());//发件人
message.setTo(user.getEmail());//收件人
message.setSubject( subject );//主题
message.setText(jsonBeautifyUtils.formatJson(content));//正文
mailSender.send(message);
logger.info("已成功发送用户【"+user.getLoginName()+"("+user.getEmail()+")】建仓邮件.主题【"+subject+"】.");
}
}

View File

@ -0,0 +1,52 @@
package com.cronie.mengyu.monitor.impl;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.cronie.mengyu.common.constants.TradeConstants;
import com.cronie.mengyu.domain.GoodsTradeModelIns;
import com.cronie.mengyu.monitor.AbstractMonitor;
import com.cronie.mengyu.service.IGoodsTradeModelInsService;
import com.ruoyi.system.domain.SysUser;
/**
* 重置所有的交易模型实例邮件通知状态
* @author cronie
*
*/
@Component("resetTradeModelInsMailNotice")
public class ResetTradeModelInsMailNoticeImpl extends AbstractMonitor {
private static final Logger logger = LoggerFactory.getLogger(ResetTradeModelInsMailNoticeImpl.class);
//模型实例服务层
@Autowired
IGoodsTradeModelInsService goodsTradeModelInsService ;
@Override
protected void monitorTask(SysUser user) {
GoodsTradeModelIns goodsTradeModelInsParamter = new GoodsTradeModelIns();
goodsTradeModelInsParamter.setCreater(user.getUserId().intValue());//查询用户
goodsTradeModelInsParamter.setInsStatus(TradeConstants.MODEL_INS_STATUS_RUNING);//计划是进行中的状态
goodsTradeModelInsParamter.setHasMailNotice(TradeConstants.MAIL_NOTICE_YES);
List<GoodsTradeModelIns> listTradeModelIns = goodsTradeModelInsService.selectGoodsTradeModelInsList(goodsTradeModelInsParamter) ;
logger.info("重置用户【"+user.getLoginName()+"】的交易计划模型邮件通知有【"+listTradeModelIns.size()+"】个。");
for(GoodsTradeModelIns planModelIns : listTradeModelIns) {
planModelIns.setHasMailNotice(TradeConstants.MAIL_NOTICE_NO);//未通知状态
goodsTradeModelInsService.updateGoodsTradeModelIns(planModelIns) ;
}
logger.info("已重置完用户【"+user.getLoginName()+"】的交易计划模型实例邮件通知状态。");
}
}

View File

@ -0,0 +1,47 @@
package com.cronie.mengyu.monitor.impl;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.cronie.mengyu.common.constants.TradeConstants;
import com.cronie.mengyu.domain.GoodsTradeModel;
import com.cronie.mengyu.monitor.AbstractMonitor;
import com.cronie.mengyu.service.IGoodsTradeModelService;
import com.ruoyi.system.domain.SysUser;
/**
* 重置所有的交易模型邮件通知状态
* @author cronie
*
*/
@Component("resetTradeModelMailNotice")
public class ResetTradeModelMailNoticeImpl extends AbstractMonitor {
private static final Logger logger = LoggerFactory.getLogger(ResetTradeModelMailNoticeImpl.class);
//模型服务层
@Autowired
IGoodsTradeModelService goodsTradeModelService ;
@Override
protected void monitorTask(SysUser user) {
GoodsTradeModel goodsTradeModelParamter = new GoodsTradeModel();
goodsTradeModelParamter.setCreater(user.getUserId().intValue());//查询用户
goodsTradeModelParamter.setModelStatus(TradeConstants.GOODS_MODEL_STATUS_VALID);//启用状态
goodsTradeModelParamter.setHasMailNotice(TradeConstants.MAIL_NOTICE_YES);
List<GoodsTradeModel> listTradeModel = goodsTradeModelService.selectGoodsTradeModelList(goodsTradeModelParamter) ;
logger.info("重置用户【"+user.getLoginName()+"】的交易计划模型邮件通知有【"+listTradeModel.size()+"】个。");
for(GoodsTradeModel planModel : listTradeModel) {
planModel.setHasMailNotice(TradeConstants.MAIL_NOTICE_NO);//未通知状态
goodsTradeModelService.updateGoodsTradeModel(planModel) ;
}
logger.info("已重置完用户【"+user.getLoginName()+"】的交易计划模型邮件通知状态。");
}
}

View File

@ -0,0 +1,43 @@
package com.cronie.mengyu.web.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.cronie.mengyu.common.goods.LoadGoodsInfoFactory;
import com.cronie.mengyu.common.goods.ILoadGoodsInfo;
import com.ruoyi.framework.web.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@Api(value = "MengYu常用接口", description = "MengYu常用接口")
@Controller
@RequestMapping("/trade/common")
public class TradeCommonController extends BaseController {
@Autowired
LoadGoodsInfoFactory loadGoodsInfoFactory ;
/**
* 查询商品实时信息
*/
@ApiOperation(value = "实时查询品种代码基本信息", notes = "实时查询品种代码基本信息", httpMethod = "GET")
@ResponseBody
@RequestMapping("/loadGoodsInfo")
public ActualTimeGoods loadGoodsInfo(
@ApiParam(value = "品种代码,必填项") @RequestParam(value = "code", required = true, defaultValue = "000001")
String code)
{
ILoadGoodsInfo loadGoodsInfoInterface = loadGoodsInfoFactory.getLoadGoodsInfoInstance() ;
ActualTimeGoods goodsInfo = loadGoodsInfoInterface.loadGoodsInfo(code) ;
return goodsInfo;
}
}

View File

@ -131,4 +131,4 @@ gen:
# 自动去除表前缀默认是true
autoRemovePre: true
# 表前缀(类名不会包含表前缀)
tablePrefix: sys_
tablePrefix: sys_

View File

@ -0,0 +1,6 @@
sender.mail.host=smtp.163.com
sender.mail.port=25
sender.mail.userName=jonw000@163.com
sender.mail.passWord=102204308
sender.mail.smtp.auth=true
sender.mail.smtp.timeout=25000

View File

@ -10,10 +10,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="insStatus" column="ins_status" />
<result property="creater" column="creater" />
<result property="createTime" column="create_time" />
<result property="hasMailNotice" column="has_mail_notice" />
</resultMap>
<sql id="selectGoodsTradeModelInsVo">
select ins_id, model_id, ins_status, creater, create_time from my_goods_trade_model_ins
select ins_id, model_id, ins_status, creater, create_time,has_mail_notice from my_goods_trade_model_ins
</sql>
<select id="selectGoodsTradeModelInsList" parameterType="GoodsTradeModelIns" resultMap="GoodsTradeModelInsResult">
@ -24,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="insStatus != null "> and ins_status = #{insStatus}</if>
<if test="creater != null "> and creater = #{creater}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="hasMailNotice != null "> and has_mail_notice = #{hasMailNotice}</if>
</where>
</select>
@ -40,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="insStatus != null ">ins_status,</if>
<if test="creater != null ">creater,</if>
<if test="createTime != null ">create_time,</if>
<if test="hasMailNotice != null "> #{hasMailNotice},</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="insId != null ">#{insId},</if>
@ -47,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="insStatus != null ">#{insStatus},</if>
<if test="creater != null ">#{creater},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="hasMailNotice != null ">#{hasMailNotice},</if>
</trim>
</insert>
@ -57,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="insStatus != null ">ins_status = #{insStatus},</if>
<if test="creater != null ">creater = #{creater},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="hasMailNotice != null ">has_mail_notice = #{hasMailNotice},</if>
</trim>
where ins_id = #{insId}
</update>

View File

@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="stopPrice" column="stop_price" />
<result property="creater" column="creater" />
<result property="createTime" column="create_time" />
<result property="hasMailNotice" column="has_mail_notice" />
</resultMap>
<sql id="selectGoodsTradeModelVo">
select model_id, code, basic_volumes, model_status, building_price, exit_price, stop_price, creater, create_time from my_goods_trade_model
select model_id, code, basic_volumes, model_status, building_price, exit_price, stop_price, creater, create_time,has_mail_notice from my_goods_trade_model
</sql>
<select id="selectGoodsTradeModelList" parameterType="GoodsTradeModel" resultMap="GoodsTradeModelResult">
@ -32,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stopPrice != null "> and stop_price = #{stopPrice}</if>
<if test="creater != null "> and creater = #{creater}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="hasMailNotice != null "> and has_mail_notice = #{hasMailNotice}</if>
</where>
</select>
@ -52,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stopPrice != null ">stop_price,</if>
<if test="creater != null ">creater,</if>
<if test="createTime != null ">create_time,</if>
<if test="hasMailNotice != null "> #{hasMailNotice},</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="modelId != null ">#{modelId},</if>
@ -63,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stopPrice != null ">#{stopPrice},</if>
<if test="creater != null ">#{creater},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="hasMailNotice != null "> #{hasMailNotice},</if>
</trim>
</insert>
@ -77,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stopPrice != null ">stop_price = #{stopPrice},</if>
<if test="creater != null ">creater = #{creater},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="hasMailNotice != null ">has_mail_notice = #{hasMailNotice},</if>
</trim>
where model_id = #{modelId}
</update>

View File

@ -0,0 +1,36 @@
package com.cronie.mengyu.common.goods.impl;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.alibaba.fastjson.JSONObject;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.cronie.mengyu.common.goods.ILoadGoodsInfo;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={ SinaLoadGoodsInfoImpl.class})
@WebAppConfiguration
public class SinaLoadGoodsInfoImplTest {
private static final Logger logger = LoggerFactory.getLogger(SinaLoadGoodsInfoImplTest.class);
@Autowired
@Qualifier("sinaDataSource")
ILoadGoodsInfo loadGoodsInfo ;
@Test
public void loadGoodsInfo() {
ActualTimeGoods goodsInfo = loadGoodsInfo.loadGoodsInfo("000001") ;
logger.info(JSONObject.toJSONString(goodsInfo));
assertEquals("上证指数", goodsInfo.getName());
}
}

View File

@ -0,0 +1,36 @@
package com.cronie.mengyu.common.goods.impl;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.alibaba.fastjson.JSONObject;
import com.cronie.mengyu.common.goods.ActualTimeGoods;
import com.cronie.mengyu.common.goods.ILoadGoodsInfo;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={ TencentLoadGoodsInfoImpl.class})
@WebAppConfiguration
public class TencentLoadGoodsInfoImplTest {
private static final Logger logger = LoggerFactory.getLogger(TencentLoadGoodsInfoImplTest.class);
@Autowired
@Qualifier("tencentDataSource")
ILoadGoodsInfo loadGoodsInfo ;
@Test
public void loadGoodsInfo() {
ActualTimeGoods goodsInfo = loadGoodsInfo.loadGoodsInfo("000001") ;
logger.info(JSONObject.toJSONString(goodsInfo));
assertEquals("上证指数", goodsInfo.getName());
}
}

View File

@ -0,0 +1,38 @@
package com.cronie.mengyu.config.mail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.cronie.mengyu.config.MailConfig;
import com.cronie.mengyu.monitor.AbstractMonitor;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={ MailConfig.class})
@WebAppConfiguration
public class MailConfigTest {
private static final Logger logger = LoggerFactory.getLogger(AbstractMonitor.class);
@Autowired
MailSender mailSender;
@Test
public void sendSimpleEmail(){
SimpleMailMessage message = new SimpleMailMessage();//消息构造器
message.setFrom("jonw000@163.com");//发件人
message.setTo("413852682@qq.com");//收件人
message.setSubject("Spring Email Test");//主题
message.setText("hello world!!");//正文
mailSender.send(message);
logger.info("邮件发送完成.");
}
}

View File

@ -0,0 +1,37 @@
package com.cronie.mengyu.monitor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.cronie.mengyu.monitor.impl.ResetTradeModelInsMailNoticeImpl;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.impl.SysUserServiceImpl;
@RunWith(SpringJUnit4ClassRunner.class)
@EnableAutoConfiguration
@ContextConfiguration(classes={ ResetTradeModelInsMailNoticeImpl.class})
@WebAppConfiguration
@ComponentScan({"com.ruoyi.*","com.cronie.*"})
public class ResetTradeModelInsMailNoticeImplTest {
private static final Logger logger = LoggerFactory.getLogger(ResetTradeModelInsMailNoticeImplTest.class);
@Autowired
@Qualifier("resetTradeModelInsMailNotice")
IMonitor monitor;
@Test
public void monitor(){
monitor.monitor("admin");
}
}