Commit f9098968 by mahaisong

fix:搭建quartz3+状态模式+得到基金推荐信息接口(伪代码)+3个榜单推荐接口(伪代码)

parent 12a713a6
<configuration>
<configuration>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D5313665-73B9-4825-B778-C34EEB3247C4}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>GHRecomDataInterface</RootNamespace>
<AssemblyName>GHRecomDataInterface</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HooLab.Log">
<HintPath>..\..\..\..\worksapce\Palas\include\HooLab.Log.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Quartz, Version=3.0.5.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.3.0.5\lib\net452\Quartz.dll</HintPath>
</Reference>
<Reference Include="Quartz.Jobs, Version=3.0.5.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.Jobs.3.0.5\lib\net452\Quartz.Jobs.dll</HintPath>
</Reference>
<Reference Include="Quartz.Plugins, Version=3.0.5.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.Plugins.3.0.5\lib\net452\Quartz.Plugins.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QuartzJobs\mallintf.cs" />
<Compile Include="QuartzJobs\TestJob.cs" />
<Compile Include="State\B_BuildFundPool.cs" />
<Compile Include="State\A_FundIn.cs" />
<Compile Include="State\C_GetFundURLcs.cs" />
<Compile Include="State\D_EndOther.cs" />
<Compile Include="State\State.cs" />
<Compile Include="State\Work.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="job_scheduling_data_2_0.xsd">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="quartz.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ReadMe.md" />
<None Include="State\ReadMe.md" />
</ItemGroup>
<ItemGroup>
<Content Include="quartz_jobs.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GHHttpClient\GHHttpClient.csproj">
<Project>{2b952b48-7ea9-4279-99b5-ca04872e7347}</Project>
<Name>GHHttpClient</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using HooLab.Log;
using HooLab.Log;
using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecomDataInterface
{
class Program
{
private static IScheduler scheduler;
private static string wstr = "";
static void Main(string[] args)
{
try
{
Console.Title = "国海推荐-产品数据定时同步";//设置窗口标题
Console.WindowWidth = 120;//一屏幕宽120个字,多了换行
Console.WindowHeight = 34;//一屏幕最多34行,多了就滚动
Console.BufferWidth = 120; //一行内容120个字,多了换行。 如果BufferWidth比WindowWidth大,则代表可以水平向后滚动
Console.BufferHeight = 9999; //最大高度
Console.BackgroundColor = ConsoleColor.DarkYellow; //设置背景色 黄
//开启quartz
wstr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ": 1.程序启动";
Console.WriteLine(wstr);
Logger.Info(wstr);
scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
scheduler.Start();
wstr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ": 2.定时任务启动--------若要关闭本程序,请输入exit!";
Console.WriteLine(wstr);
Logger.Info(wstr);
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ": 2.1定时任务执行日志,请观察debug.log文件");
}
catch (Exception ex)
{
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Cyan;
wstr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ": 启动失败,定时任务自动停止!!!错误如下:" + ex.ToString();
Console.WriteLine(wstr);
Logger.Info(wstr);
try
{
//quartz 停止
scheduler.Shutdown();
}
catch { }
Console.BackgroundColor = ConsoleColor.DarkYellow; //设置默认背景色
Console.ForegroundColor = ConsoleColor.Gray; //设置默认背景色
}
finally
{
while (true)
{
string key = Console.ReadLine();
if (key.Trim().ToUpper().Equals("EXIT"))
{
//quartz 停止
scheduler.Shutdown();
break;
}
}
Console.WriteLine("3.程序关闭--手工关闭!");
//LogService.WriteInfo("3.程序关闭--手工关闭!");
}
}
//显示出console中支持的背景色及前景色
//ShowColor(); //人工挑选1个需要的文本、背景颜色
//Console.ResetColor(); //将控制台的前景色和背景色设为默认值
//Console.BackgroundColor = ConsoleColor.Blue; //设置背景色 蓝
//Console.ForegroundColor = ConsoleColor.White; //设置前景色,即字体颜色 白
static void ShowColor()
{
Type type = typeof(ConsoleColor);
Console.ForegroundColor = ConsoleColor.White;
foreach (string name in Enum.GetNames(type))
{
Console.BackgroundColor = (ConsoleColor)Enum.Parse(type, name);
Console.WriteLine(name);
}
Console.BackgroundColor = ConsoleColor.Black;
foreach (string name in Enum.GetNames(type))
{
Console.ForegroundColor = (ConsoleColor)Enum.Parse(type, name);
Console.WriteLine(name);
}
foreach (string bc in Enum.GetNames(type))
{
Console.BackgroundColor = (ConsoleColor)Enum.Parse(type, bc);
foreach (string fc in Enum.GetNames(type))
{
Console.ForegroundColor = (ConsoleColor)Enum.Parse(type, fc);
Console.WriteLine("bc=" + bc + ",fc=" + fc);
}
Console.WriteLine();
}
}
}
}
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("GHRecomDataInterface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GHRecomDataInterface")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("d5313665-73b9-4825-b778-c34eeb3247c4")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]


using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecomDataInterface.QuartzJobs
{
public class TestJob : IJob
{
private static string sync_name = "test";
async Task IJob.Execute(IJobExecutionContext context)
{
try
{
// dummy 1ms sleep
await Task.Delay(1);
//#region 测试调用
//try
//{
//}
//catch (Exception ex)
//{
// throw;
//}
//#endregion
//LogService.WriteInfo("test");
}
catch (Exception ex)
{
throw;
}
//return Task.FromResult(true);
}
}
}
\ No newline at end of file
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GHRecomDataInterface.State;
using Newtonsoft.Json;
using Quartz;
namespace GHRecomDataInterface.QuartzJobs
{
public class mallintf : IJob
{
async Task IJob.Execute(IJobExecutionContext context)
{
try
{
//读取数据
Work emergencyProjects = new Work();
emergencyProjects.Node = 1;
emergencyProjects.NextProgram();
//清洗,构建产品池
emergencyProjects.Node = 2;
emergencyProjects.NextProgram();
//对产品池贴URL
emergencyProjects.Node = 3;
emergencyProjects.NextProgram();
//榜单并行、同时对产品池贴亮点标签
emergencyProjects.Node = 4;
emergencyProjects.NextProgram();
}
catch (Exception ex)
{
throw;
}
//return Task.FromResult(true);
}
}
}
1.定时:调用国海接口,将数据放入存储(新区)。
1.定时:调用国海接口,将数据放入存储(新区)。
2.数据存储完毕后,执行清洗任务,刷新产品池。
3.对数据计算所有榜单数据,存储到各个计算结果位置。
存储;
注意:quartz.net 升级版本,出现了DLL分包和功能迁移。注意
https://www.quartz-scheduler.net/documentation/quartz-3.x/migration-guide.html
\ No newline at end of file
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace GHRecomDataInterface.State
{
//数据同步
public class A_FundIn : State
{
private static string sync_name = "国海产品数据;mallintf.getProdAction";
public override void NextProgram(Work w)
{
if (w.Node <=1)
{
DateTime dt = DateTime.Now;
try
{
int page = 1;
int size = 100;
//国海产品数据。数据保留,过滤产品池
String cmd = "mallintf.getProdAction";
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("page", page);
dic.Add("size", size);
TagToday:
String resp = String.Empty;
try
{
int retrytime = 0;
do
{
retrytime++;
resp = GHHttpClient.ESBFinder.Instance.sendRequest(cmd, dic);
}
while (retrytime < 10);
}
catch (Exception ext)
{
Console.WriteLine(ext.ToString());
}
//反解析JSON为对象List
List<String> resultModelList = JsonConvert.DeserializeObject<List<String>>(resp);
//将数据放入存储区域、同步时间统一为dt。入库时间为DateTime.Now.
if (null != resultModelList && resultModelList.Count == size)
{
//还有其他记录,需继续执行。
page++;
goto TagToday;
}
//数据同步完毕
}
catch (Exception ex)
{
throw;
}
}
else
{
//超过1,则转入下一个
w.SetState(new B_BuildFundPool());
w.NextProgram();
}
}
}
}
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecomDataInterface.State
{
//构建产品池
public class B_BuildFundPool : State
{
public override void NextProgram(Work w)
{
if (w.Node <= 2)
{
/*清洗产品池,得到符合<推荐产品池定位>的数据*/
//await Task.Factory.StartNew(() =>
//{
//});
}
else
{
//超过2,则转入下一个
w.SetState(new C_GetFundURLcs());
w.NextProgram();
}
}
}
}
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecomDataInterface.State
{
//产品页面URL
public class C_GetFundURLcs : State
{
public override void NextProgram(Work w)
{
if (w.Node <= 3)
{
//循环产品池,对产品池贴URL update
}
else
{
//超过3,则转入下一个
w.SetState(new D_EndOther());
w.NextProgram();
}
}
}
}
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecomDataInterface.State
{
//收益榜单、行业榜单、个股榜单、产品亮点标签(补充打上的)、 并行计算。
public class D_EndOther : State
{
public override void NextProgram(Work w)
{
if (w.Node <= 4)
{
//并行执行TASK
Stopwatch swTask = new Stopwatch();
swTask.Start();
/*创建任务 t1 收益榜单*/
Task t1 = Task.Factory.StartNew(() =>
{
//收益榜单
});
/*创建任务 t2 行业榜单*/
Task t2 = Task.Factory.StartNew(() =>
{
//行业榜单
});
/*创建任务 t3 个股榜单*/
Task t3 = Task.Factory.StartNew(() =>
{
//个股榜单
});
/*创建任务 t4 产品亮点标签*/
Task t4 = Task.Factory.StartNew(() =>
{
//并行产品池,对产品池贴亮点标签
});
Task.WaitAll(t2, t3);
swTask.Stop();
Console.WriteLine("执行时间为:" + swTask.ElapsedMilliseconds);
}
}
}
}
状态模式:
状态模式:
原本不用搞状态模式,
用户风险信息(凌晨3点) 可以单独
后来发现 产品信息(同步+清洗-9点15分)、产品页面URL(9点15分), 其实是同样发送HTTP请求,2个不能并行,只能顺序,而且后续操作必须在前2个都执行完才能执行。
后面的操作:收益榜单、行业榜单、个股榜单、产品亮点标签(补充打上的)、 是可以并行计算的。
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecomDataInterface.State
{
//抽象状态
public abstract class State
{
public abstract void NextProgram(Work w);
}
}
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecomDataInterface.State
{
/// <summary>
/// 一定不能做成单例或静态。必须私有实例化对象。
/// </summary>
public class Work
{
private State current;
public Work()
{
//工作状态初始化为读取同步接口
current = new A_FundIn();
}
private double node;
public double Node
{
get { return node; }
set { node = value; }
}
private bool finish;
public bool TaskFinished
{
get { return finish; }
set { finish = value; }
}
public void SetState(State s)
{
current = s;
}
public void NextProgram()
{
current.NextProgram(this);
}
}
}
<configuration>
<configuration>
</configuration>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
 # You can configure your scheduler in either <quartz> configuration section
 # You can configure your scheduler in either <quartz> configuration section
# or in quartz properties file
# Configuration section has precedence
quartz.scheduler.instanceName = MyScheduler
quartz.jobStore.type = Quartz.Simpl.RAMJobStore, Quartz
# configure thread pool info
quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz
quartz.threadPool.threadCount = 10
quartz.threadPool.threadPriority = Normal
# job initialization plugin handles our xml reading, without it defaults are used
quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz.Plugins
quartz.plugin.xml.fileNames = ~/quartz_jobs.xml
# export this server to remoting context
#quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz
#quartz.scheduler.exporter.port = 555
#quartz.scheduler.exporter.bindName = QuartzScheduler
#quartz.scheduler.exporter.channelType = tcp
#quartz.scheduler.exporter.channelName = httpQuartz
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains job definitions in schema version 2.0 format -->
<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives>
<schedule>
<!--begin-每天凌晨1点执行一次-TaikorESJob-->
<job>
<name>Cycle_TaikorESJob</name>
<group>Test</group>
<description>每天凌晨1点钟执行一次-TaikorESJob</description>
<job-type>GHRecomDataInterface.QuartzJobs.mallintf,GHRecomDataInterface</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<cron>
<name>Cycle_TaikorESTrigger</name>
<group>Test</group>
<job-name>Cycle_TaikorESJob</job-name>
<job-group>Test</job-group>
<!--start-time(选填) 任务开始执行时间utc时间,北京时间需要+08:00,如:<start-time>2012-04-01T08:00:00+08:00</start-time>表示北京时间2012年4月1日上午8:00开始执行,注意服务启动或重启时都会检测此属性,若没有设置此属性,服务会根据cron-expression的设置执行任务调度;若start-time设置的时间比当前时间较早,则服务启动后会忽略掉cron-expression设置,立即执行一次调度,之后再根据cron-expression执行任务调度;若设置的时间比当前时间晚,则服务会在到达设置时间相同后才会应用cron-expression,根据规则执行任务调度,一般若无特殊需要请不要设置此属性-->
<!--<start-time>2015-01-22T00:00:00+08:00</start-time>-->
<!--0 0 1 * * ?
0/1 * * * * ?-->
<cron-expression>0 24 0,18 4 7 ? 2018-2018</cron-expression>
</cron>
</trigger>
<!--end-每天凌晨1点执行一次-TaikorESJob-->
</schedule>
</job-scheduling-data>
\ No newline at end of file
++ "b/14.java\350\275\254C#/TestC/GHRecomDataInterface/obj/Debug/GHRecomDataInterface.csproj.CopyComplete"
4fdbab51b4b30be65258f473d772331e7bc9202a
4fdbab51b4b30be65258f473d772331e7bc9202a
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\quartz_jobs.xml
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\quartz_jobs.xml
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\quartz.config
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\GHRecomDataInterface.exe.config
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\GHRecomDataInterface.exe
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\GHRecomDataInterface.pdb
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\HooLab.Log.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\HooLab.Config.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\HooLab.Runtime.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.pdb
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.xml
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\obj\Debug\GHRecomDataInterface.csproj.CoreCompileInputs.cache
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\obj\Debug\GHRecomDataInterface.csproj.CopyComplete
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\obj\Debug\GHRecomDataInterface.exe
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\obj\Debug\GHRecomDataInterface.pdb
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\job_scheduling_data_2_0.xsd
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.Jobs.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.Plugins.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.Jobs.pdb
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.Jobs.xml
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.Plugins.pdb
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Quartz.Plugins.xml
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\obj\Debug\GHRecomDataInterface.csprojAssemblyReference.cache
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\GHHttpClient.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Newtonsoft.Json.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\BouncyCastle.Crypto.dll
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\GHHttpClient.pdb
D:\smallproject\14.java转C#\TestC\GHRecomDataInterface\bin\Debug\Newtonsoft.Json.xml
++ "b/14.java\350\275\254C#/TestC/GHRecomDataInterface/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs"
++ "b/14.java\350\275\254C#/TestC/GHRecomDataInterface/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs"
++ "b/14.java\350\275\254C#/TestC/GHRecomDataInterface/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs"
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
<package id="Quartz" version="3.0.5" targetFramework="net461" />
<package id="Quartz.Jobs" version="3.0.5" targetFramework="net461" />
<package id="Quartz.Plugins" version="3.0.5" targetFramework="net461" />
</packages>
\ No newline at end of file
 # You can configure your scheduler in either <quartz> configuration section
 # You can configure your scheduler in either <quartz> configuration section
# or in quartz properties file
# Configuration section has precedence
quartz.scheduler.instanceName = MyScheduler
quartz.jobStore.type = Quartz.Simpl.RAMJobStore, Quartz
# configure thread pool info
quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz
quartz.threadPool.threadCount = 10
quartz.threadPool.threadPriority = Normal
# job initialization plugin handles our xml reading, without it defaults are used
quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz.Plugins
quartz.plugin.xml.fileNames = ~/quartz_jobs.xml
# export this server to remoting context
#quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz
#quartz.scheduler.exporter.port = 555
#quartz.scheduler.exporter.bindName = QuartzScheduler
#quartz.scheduler.exporter.channelType = tcp
#quartz.scheduler.exporter.channelName = httpQuartz
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains job definitions in schema version 2.0 format -->
<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives>
<schedule>
<!--begin-每天凌晨1点执行一次-TaikorESJob-->
<job>
<name>Cycle_TaikorESJob</name>
<group>Test</group>
<description>每天凌晨1点钟执行一次-TaikorESJob</description>
<job-type>GHRecomDataInterface.QuartzJobs.mallintf,GHRecomDataInterface</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<cron>
<name>Cycle_TaikorESTrigger</name>
<group>Test</group>
<job-name>Cycle_TaikorESJob</job-name>
<job-group>Test</job-group>
<!--start-time(选填) 任务开始执行时间utc时间,北京时间需要+08:00,如:<start-time>2012-04-01T08:00:00+08:00</start-time>表示北京时间2012年4月1日上午8:00开始执行,注意服务启动或重启时都会检测此属性,若没有设置此属性,服务会根据cron-expression的设置执行任务调度;若start-time设置的时间比当前时间较早,则服务启动后会忽略掉cron-expression设置,立即执行一次调度,之后再根据cron-expression执行任务调度;若设置的时间比当前时间晚,则服务会在到达设置时间相同后才会应用cron-expression,根据规则执行任务调度,一般若无特殊需要请不要设置此属性-->
<!--<start-time>2015-01-22T00:00:00+08:00</start-time>-->
<!--0 0 1 * * ?
0/1 * * * * ?-->
<cron-expression>0 24 0,18 4 7 ? 2018-2018</cron-expression>
</cron>
</trigger>
<!--end-每天凌晨1点执行一次-TaikorESJob-->
</schedule>
</job-scheduling-data>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{23D7B56F-BFC2-41AC-BC55-A222739A7B4D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GHRecommendCore</RootNamespace>
<AssemblyName>GHRecommendCore</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GetRecommendFund.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHRecommendCore
{
public class GetRecommendFund
{
//以产品URL、用户风险、产品标签,等等,其实默认为定时计算结果。 但是要求方法放在core里面。方便维护、而且可能存在core中实时调用计算的可能。
//ReaderArticleDTO
public static async Task<List<string>> GetFund(List<string> ArticleList, string openid,int RecomCount=2)
{
//最好深拷贝
List<string> listReturn = ArticleList;
//得到用户风险等级
List<string> PRODRISK_LEVEL = await GetAppropriateMatch(openid);
await Task.Run(() =>
{
//随机数-标种子法:种子不同,相似的可能性很小
int[] countAT = new int[RecomCount];
for (int i = 0; i < RecomCount; i++)
{
countAT[i]= new Random(Guid.NewGuid().GetHashCode()).Next(0, listReturn.Count);
}
int NoHave = 0;
for (int i = 0; i < countAT.Length; i++)
{
List<string> listTemp = new List<string>();
//if (null != BlockBaseDTO)
//{
// listTemp.add(listReturn.ElementAt(countAT[i]),GetFromBlocks(PRODRISK_LEVEL,stock_NAME,stock_Code))
//}
//if (null != StockBaseDTO)
//{
// listTemp.add(listReturn.ElementAt(countAT[i]), GetFromStock(PRODRISK_LEVEL,Blocks_NAME,Blocks_Id))
//}
if (null == listTemp || listTemp.Count == 0)
{
NoHave++;
}
else
{
//数据范围内随机取1个,赋值到原listReturn的第I个对象的某个属性字段中。
string entity = listTemp.ElementAt(new Random().Next(0, listTemp.Count));
//listReturn.ElementAt(countAT[i]).Entity = entity;
}
}
//如果行业和个股标签都没有。则调用收益排名推荐方法。随机补充。
if (NoHave == RecomCount)
{
////构造1个空的,只有推荐信息的数据。
//listReturn.Add(GetFromReturn(PRODRISK_LEVEL));
}
//1.10个数据任意取2条数据,循环2个数据,每个都执行分支1,2.
//分支1:如果有行业标签,则调用行业推荐方法。
//分支2:如果有个股标签,则调用个股推荐方法。
//2.如果2条数据行业和个股标签有值,则赋值到其中对象专门用来包装推荐信息的对应字段。
//3.如果2条数据行业和个股标签都没有,或1,2都没有得到推荐结果。则调用收益排名推荐方法。
//得到后,构造为第11条数据,除了推荐信息,其他均为空。
//前端显示注意:
//0只有资讯信息。
//1.代表推荐信息 + 资讯信息
//只有推荐信息,没有资讯信息。
});
return listReturn;
}
/// <summary>
///得到用户风险等级-- 适当性匹配
/// </summary>
/// <param name="openid"></param>
/// <returns></returns>
public static async Task<List<string>> GetAppropriateMatch(string openid)
{
List<string> PRODRISK_LEVEL = new List<string>();
await Task.Run(() =>
{
//1.查询数据库、redis、WEB API接口。
//openid得到客户风险承受能力。(redis过期时间1天)
//如果redis中已经过期,则调用接口拿取新的数据。并更新缓存。
//2.匹配计算
//返回结果
});
return PRODRISK_LEVEL;
}
//DTO 是推荐的基金 DTO
//主题名称,可能是多个? `Palas_V5`.`Blocks`
public static async Task<List<string>> GetFromBlocks(List<string> PRODRISK_LEVEL, string Blocks_NAME, string Blocks_Id)
{
List<string> listReturn = new List<string>();
await Task.Run(() =>
{
//2.得到主题编号
//3.循环产品风险等级,构造R1风险等级、食品行业编号、TOP1。为key,通过多个key获取多条基金数据。
//(此方法简化开发可能为mysql联合条件查询,但是不建议)
//4.所有结果根据收益TOP5,再随机1条。(可加入黑名单功能)
//调用API,得到其网页链接。
//产品标签取其一、二
});
return listReturn;
}
//DTO 是推荐的基金 DTO
//个股 `Palas_V5`.`Organization`
public static async Task<List<string>> GetFromStock(List<string> PRODRISK_LEVEL, string stock_NAME, string stock_Code)
{
List<string> listReturn = new List<string>();
await Task.Run(() =>
{
// 2.得到个股编号
//3.循环产品风险等级,构造R1风险等级、股票代码、TOP1。为key,通过多个key获取多条基金数据。
//(此方法简化开发可能为mysql联合条件查询,但是不建议)
//4.所有结果根据收益TOP5,再随机1条。(可加入黑名单功能)
//调用API,得到其网页链接。
//产品标签取其一、二
});
return listReturn;
}
//DTO 是推荐的基金 DTO
public static async Task<List<string>> GetFromReturn(List<string> PRODRISK_LEVEL)
{
List<string> listReturn = new List<string>();
await Task.Run(() =>
{
// 2.得到基金产品类型字典表
//3.循环产品类型,构造R1风险等级、产品类型、TOP1。为key,通过多个key获取多条基金数据。
//(此方法简化开发可能为mysql联合条件查询,但是不建议)
//4.所有结果根据收益TOP2,再随机1条。(可加入黑名单功能)
//调用API,得到其网页链接。
//产品标签取其一、二
});
return listReturn;
}
}
}
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("GHRecommendCore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GHRecommendCore")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("23d7b56f-bfc2-41ac-bc55-a222739a7b4d")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
1.对外提供“GetRecommendFund得到符合推荐产品”接口。
1.对外提供“GetRecommendFund得到符合推荐产品”接口。
2.内部实现:
GetAppropriateMatch适当性匹配
GetFromTopic行业/主题推荐方法
GetFromStock个股推荐方法
GetFromReturn收益推荐方法
cfb7264b82b62cb55bb72075ca39548f509e760b
cfb7264b82b62cb55bb72075ca39548f509e760b
++ "b/14.java\350\275\254C#/TestC/GHRecommendCore/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs"
++ "b/14.java\350\275\254C#/TestC/GHRecommendCore/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs"
++ "b/14.java\350\275\254C#/TestC/GHRecommendCore/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs"


......@@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestHttpClientGH", "TestHtt
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GHHttpClient", "GHHttpClient\GHHttpClient.csproj", "{2B952B48-7EA9-4279-99B5-CA04872E7347}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GHRecommendCore", "GHRecommendCore\GHRecommendCore.csproj", "{23D7B56F-BFC2-41AC-BC55-A222739A7B4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GHRecomDataInterface", "GHRecomDataInterface\GHRecomDataInterface.csproj", "{D5313665-73B9-4825-B778-C34EEB3247C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -33,6 +37,14 @@ Global
{2B952B48-7EA9-4279-99B5-CA04872E7347}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B952B48-7EA9-4279-99B5-CA04872E7347}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B952B48-7EA9-4279-99B5-CA04872E7347}.Release|Any CPU.Build.0 = Release|Any CPU
{23D7B56F-BFC2-41AC-BC55-A222739A7B4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23D7B56F-BFC2-41AC-BC55-A222739A7B4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23D7B56F-BFC2-41AC-BC55-A222739A7B4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23D7B56F-BFC2-41AC-BC55-A222739A7B4D}.Release|Any CPU.Build.0 = Release|Any CPU
{D5313665-73B9-4825-B778-C34EEB3247C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5313665-73B9-4825-B778-C34EEB3247C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5313665-73B9-4825-B778-C34EEB3247C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5313665-73B9-4825-B778-C34EEB3247C4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
++ "b/14.java\350\275\254C#/TestC/UnitTestProject1/obj/Debug/build.force"
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment