Commit a4a9cd2d by zhouminghui

会计流水模块

parent 5a54f711
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="10.0.1" />
<PackageReference Include="NPOI" Version="2.4.1" /> <PackageReference Include="NPOI" Version="2.4.1" />
<PackageReference Include="Qiniu.Shared" Version="7.2.15" />
<PackageReference Include="StackExchange.Redis" Version="2.1.28" /> <PackageReference Include="StackExchange.Redis" Version="2.1.28" />
</ItemGroup> </ItemGroup>
......
using Qiniu.Http;
using Qiniu.IO;
using Qiniu.IO.Model;
using Qiniu.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Bailun.DC.Common
{
public class QiNiuHelper
{
private static string AK = "";
private static string SK = "";
/// <summary>
///
/// </summary>
/// <param name="ak">AccessKey</param>
/// <param name="sk">SecretKey</param>
public QiNiuHelper(string ak, string sk)
{
AK = ak;
SK = sk;
}
/// <summary>
/// 上传文件到七牛云
/// </summary>
public HttpResult UploadStream(byte[] content, string filename)
{
// 生成(上传)凭证时需要使用此Mac
// 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey
// 实际应用中,请自行设置您的AccessKey和SecretKey
Mac mac = new Mac(AK, SK);
string bucket = "bailun-data-center";
string saveKey = filename;
//设置区域
Qiniu.Common.Config.AutoZone(AK, bucket, false);
// 上传策略,参见
// https://developer.qiniu.com/kodo/manual/put-policy
PutPolicy putPolicy = new PutPolicy();
// 如果需要设置为"覆盖"上传(如果云端已有同名文件则覆盖),请使用 SCOPE = "BUCKET:KEY"
putPolicy.Scope = bucket + ":" + saveKey;
//putPolicy.Scope = bucket;
// 上传策略有效期(对应于生成的凭证的有效期)
putPolicy.SetExpires(3600);
// 上传到云端多少天后自动删除该文件,如果不设置(即保持默认默认)则不删除
//putPolicy.DeleteAfterDays = 7;
// 生成上传凭证,参见
// https://developer.qiniu.com/kodo/manual/upload-token
string jstr = putPolicy.ToJsonString();
string token = Auth.CreateUploadToken(mac, jstr);
FormUploader fu = new FormUploader();
var result = fu.UploadStream(new MemoryStream(content), filename, token);
return result;
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.18" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bailun.DC.Services\Bailun.DC.Services.csproj" />
</ItemGroup>
</Project>
FROM microsoft/dotnet:2.1-runtime AS base
WORKDIR /app
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY Bailun.DC.ExportTask/Bailun.DC.ExportTask.csproj Bailun.DC.ExportTask/
COPY Bailun.DC.Services/Bailun.DC.Services.csproj Bailun.DC.Services/
RUN dotnet restore Bailun.DC.ExportTask/Bailun.DC.ExportTask.csproj
COPY . .
WORKDIR /src/Bailun.DC.ExportTask
RUN dotnet build Bailun.DC.ExportTask.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish Bailun.DC.ExportTask.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Bailun.DC.ExportTask.dll"]
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;
namespace Bailun.DC.ExportTask
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("启动新数据中心导出任务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Services>();
});
await builder.RunConsoleAsync();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using Dapper;
using Bailun.DC.Models;
using Bailun.DC.Common;
using System.Threading;
using Microsoft.Extensions.Hosting;
using System.Threading.Tasks;
using System.Linq;
using Bailun.DC.Services.WebApiService;
namespace Bailun.DC.ExportTask
{
public class Services : BackgroundService
{
private Timer _timer;
private bool Run;//等待上一个任务执行完成才能执行新的任务
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
return Task.CompletedTask;
}
private void DoWork(object state)
{
if (!Run)
{
try
{
Run = true;
new FinanceService().SyncExprotTask();
}
catch (Exception ex)
{
Console.WriteLine($"同步月销售利润错误,堆栈信息:{ex.Message}");
}
finally
{
Run = false;
}
}
}
}
}
{
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"DCFileUrl": "http://dcfile.blsct.com"
}
}
\ No newline at end of file
...@@ -8,18 +8,27 @@ namespace Bailun.DC.Models.Common ...@@ -8,18 +8,27 @@ namespace Bailun.DC.Models.Common
/// Api返回参数 /// Api返回参数
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public class CommonApiResponseDto<T> public class CommonApiResponseDto<T> : BaseCommonApiResponseDto
{ {
/// <summary> /// <summary>
/// 指示是否成功 /// 返回的业务数据
/// </summary> /// </summary>
public bool IsSuccess { get; set; } = true; public T Data { get; set; }
}
public class CommonApiResponseDto : BaseCommonApiResponseDto
{
/// <summary> /// <summary>
/// 返回的业务数据 /// 返回的业务数据
/// </summary> /// </summary>
public T Data { get; set; } public object Data { get; set; }
}
public class BaseCommonApiResponseDto
{
/// <summary>
/// 指示是否成功
/// </summary>
public bool IsSuccess { get; set; } = true;
/// <summary> /// <summary>
/// 消息 /// 消息
/// </summary> /// </summary>
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.WebApiModels
{
public class AccountingSubjectInput : Common.Page.PageRequest
{
public int? DataType { get; set; }
public string PlatForm { get; set; }
public string Site { get; set; }
public string[] BillTime { get; set; }
public string BillMonth { get; set; }
}
public class AccountingSubjectOptionsData
{
public List<PlatformWithSite> PlatformWithSite { get; set; }
public List<string> DataCol { get; set; }
}
public class PlatformWithSite
{
public string platform { get; set; }
public string website { get; set; }
}
}
...@@ -22,5 +22,6 @@ namespace Bailun.DC.Models.WebApiModels ...@@ -22,5 +22,6 @@ namespace Bailun.DC.Models.WebApiModels
public string ExchangeRate { get; set; } public string ExchangeRate { get; set; }
public decimal? AmountValRmb { get; set; } public decimal? AmountValRmb { get; set; }
public string Month { get; set; } public string Month { get; set; }
public int Total { get; set; }
} }
} }
...@@ -5,7 +5,7 @@ using System.Text; ...@@ -5,7 +5,7 @@ using System.Text;
namespace Bailun.DC.Models namespace Bailun.DC.Models
{ {
public class dc_exprot_task public class dc_export_task
{ {
public int id { get; set; } public int id { get; set; }
public string task_title { get; set; } public string task_title { get; set; }
......
...@@ -57,8 +57,8 @@ namespace Bailun.DC.SyncMonthSalesProfitNew ...@@ -57,8 +57,8 @@ namespace Bailun.DC.SyncMonthSalesProfitNew
} }
else else
{ {
var data = new FinanceService().GetTest(); //var data = new FinanceService().GetTest();
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(data)); //Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(data));
Console.WriteLine($"现在是 【{now.Hour}点】,未到同步时间,本次同步结束~"); Console.WriteLine($"现在是 【{now.Hour}点】,未到同步时间,本次同步结束~");
} }
} }
......
...@@ -574,17 +574,43 @@ namespace Bailun.DC.WebApi.Controllers ...@@ -574,17 +574,43 @@ namespace Bailun.DC.WebApi.Controllers
[HttpGet("syncMonthSalesProfiOrderDetail")] [HttpGet("syncMonthSalesProfiOrderDetail")]
public bool SyncMonthSalesProfiOrderDetail(string date) public bool SyncMonthSalesProfiOrderDetail(string date)
=>new FinanceService().SyncMonthSalesProfiOrderDetail(date); =>new FinanceService().SyncMonthSalesProfiOrderDetail(date);
#endregion
#region 会计科目
/// <summary>
/// 获取财务会计科目流水分页
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost("getAccountingSubjectFlowPage")]
public CommonApiResponseDto<PageResult<List<MonthPlatformProfitDto>>> GetAccountingSubjectFlowPage(AccountingSubjectInput query)
=> new FinanceService().GetAccountingSubjectFlowPage(query);
/// <summary>
/// 获取查询的下拉列表数据
/// </summary>
/// <returns></returns>
[HttpGet("getOptionsData")]
public CommonApiResponseDto<AccountingSubjectOptionsData> GetOptionsData()
=> new FinanceService().GetOptionsData();
#endregion
#region 导出
/// <summary> /// <summary>
/// 添加导出任务 /// 添加导出任务
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("addExportTask")] [HttpPost("addExportTask")]
public object AddExportTask(AddExprotTaskInput input) public CommonApiResponseDto<bool> AddExportTask(AddExprotTaskInput input)
{ {
input.CreateName = HttpContext.User.GetUserName(); input.CreateName = HttpContext.User.GetUserName();
return new FinanceService().AddExprotTask(input); var result = new FinanceService().AddExprotTask(input);
return new CommonApiResponseDto<bool> { Data = result };
} }
[HttpGet("getExportTaskPage")]
public object GetExportTaskPage()
=> new FinanceService().GetExportTaskPage();
#endregion #endregion
} }
} }
...@@ -19,5 +19,10 @@ ...@@ -19,5 +19,10 @@
"BrowseLogSetting": { "BrowseLogSetting": {
"Url": "http://10.0.0.11:5001/operationloginfo/addoperationloginfo", "Url": "http://10.0.0.11:5001/operationloginfo/addoperationloginfo",
"CanLog": "yes" "CanLog": "yes"
},
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"DCFileUrl": "http://dcfile.blsct.com"
} }
} }
\ No newline at end of file
...@@ -19,5 +19,10 @@ ...@@ -19,5 +19,10 @@
"BrowseLogSetting": { "BrowseLogSetting": {
"Url": "http://10.0.0.11:5001/operationloginfo/addoperationloginfo", "Url": "http://10.0.0.11:5001/operationloginfo/addoperationloginfo",
"CanLog": "yes" "CanLog": "yes"
},
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"DCFileUrl": "http://dcfile.blsct.com"
} }
} }
\ No newline at end of file
...@@ -19,5 +19,10 @@ ...@@ -19,5 +19,10 @@
"BrowseLogSetting": { "BrowseLogSetting": {
"Url": "http://10.0.0.11:5001/operationloginfo/addoperationloginfo", "Url": "http://10.0.0.11:5001/operationloginfo/addoperationloginfo",
"CanLog": "yes" "CanLog": "yes"
},
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"DCFileUrl": "http://dcfile.blsct.com"
} }
} }
\ No newline at end of file
...@@ -91,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.WebApi", "Bailun. ...@@ -91,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.WebApi", "Bailun.
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncMonthSalesProfitNew", "Bailun.DC.SyncMonthSalesProfitNew\Bailun.DC.SyncMonthSalesProfitNew.csproj", "{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncMonthSalesProfitNew", "Bailun.DC.SyncMonthSalesProfitNew\Bailun.DC.SyncMonthSalesProfitNew.csproj", "{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.ExportTask", "Bailun.DC.ExportTask\Bailun.DC.ExportTask.csproj", "{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -269,6 +271,10 @@ Global ...@@ -269,6 +271,10 @@ Global
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Debug|Any CPU.Build.0 = Debug|Any CPU {DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Release|Any CPU.ActiveCfg = Release|Any CPU {DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Release|Any CPU.Build.0 = Release|Any CPU {DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Release|Any CPU.Build.0 = Release|Any CPU
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -310,6 +316,7 @@ Global ...@@ -310,6 +316,7 @@ Global
{2215D072-9F97-45DD-AD4D-2691581B5305} = {AE2CE86A-8538-4142-920F-684DCF47C064} {2215D072-9F97-45DD-AD4D-2691581B5305} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{B0E4B05A-2330-46E1-8CF7-C6D69DBB7850} = {AE2CE86A-8538-4142-920F-684DCF47C064} {B0E4B05A-2330-46E1-8CF7-C6D69DBB7850} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61} = {AE2CE86A-8538-4142-920F-684DCF47C064} {DEAD70F9-01C4-4178-AB0B-1C4874AA7A61} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94} = {AE2CE86A-8538-4142-920F-684DCF47C064}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E53AF28-A282-4FB0-A769-EAEA9769C02A} SolutionGuid = {6E53AF28-A282-4FB0-A769-EAEA9769C02A}
......
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