Commit a0927245 by jianshuqin

增加功能:同步资金系统亚马逊交易流水

parent e7c62d23
...@@ -54,5 +54,10 @@ namespace Bailun.DC.Common ...@@ -54,5 +54,10 @@ namespace Bailun.DC.Common
/// </summary> /// </summary>
public static string ConnectionString_Pro = "Server=gz-cdb-oxt89knc.sql.tencentcdb.com;port=62967;database=bailun_bltpro;uid=root;password=#7kfnymAM$Y9-Ntf;Convert Zero Datetime=True;Allow User Variables=True;pooling=true"; public static string ConnectionString_Pro = "Server=gz-cdb-oxt89knc.sql.tencentcdb.com;port=62967;database=bailun_bltpro;uid=root;password=#7kfnymAM$Y9-Ntf;Convert Zero Datetime=True;Allow User Variables=True;pooling=true";
/// <summary>
/// 财务资金
/// </summary>
public static string ConnectionString_Fund = "Server=gz-cdb-lnrmt5zh.sql.tencentcdb.com;port=61369;database=bailun_caiwu;uid=root;password=#7kfnymAM$Y9-Ntf;Convert Zero Datetime=True;SslMode=none;";
} }
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Bailun.DC.Models.Component.Enum namespace Bailun.DC.Models.Component.Enum
{ {
/// <summary> /// <summary>
/// 数据库:1: 数据中心, 2: 交易流水, 3: 产品库 /// 数据库:1: 数据中心, 2: 交易流水, 3: 产品库, 4: 财务资金
/// </summary> /// </summary>
public enum DBEnum public enum DBEnum
{ {
...@@ -23,6 +23,12 @@ namespace Bailun.DC.Models.Component.Enum ...@@ -23,6 +23,12 @@ namespace Bailun.DC.Models.Component.Enum
/// 产品库 /// 产品库
/// </summary> /// </summary>
[Description("产品库")] [Description("产品库")]
Pro = 3 Pro = 3,
/// <summary>
/// 财务资金
/// </summary>
[Description("财务资金")]
Fund = 4
} }
} }
namespace Bailun.DC.Models.DataWareHouse.DTO
{
public class FundAmazonTransactionDTO
{
/// <summary>
/// ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 平台
/// </summary>
public string Platform { get; set; }
/// <summary>
/// 账号
/// </summary>
public string AccountName { get; set; }
/// <summary>
/// 站点
/// </summary>
public string Website { get; set; }
/// <summary>
/// 年月
/// </summary>
public string Month { get; set; }
/// <summary>
/// 流水数据
/// </summary>
public string DataJson { get; set; }
/// <summary>
/// 报告数量
/// </summary>
public int ReportCount { get; set; }
}
}
using System; using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.DataWareHouse namespace Bailun.DC.Models.DataWareHouse
{ {
...@@ -31,6 +29,11 @@ namespace Bailun.DC.Models.DataWareHouse ...@@ -31,6 +29,11 @@ namespace Bailun.DC.Models.DataWareHouse
public string createuser { get; set; } public string createuser { get; set; }
public int has_error { get; set; }
public string md5code { get; set; }
public int? delstatus { get; set; } = 0;
} }
} }
using System;
namespace Bailun.DC.Models.DataWareHouse
{
/// <summary>
/// 交易流水进程
/// </summary>
public class flowing_sales_progress
{
/// <summary>
/// ID
/// </summary>
public int id { get; set; }
/// <summary>
/// 平台
/// </summary>
public string platform { get; set; }
/// <summary>
/// 帐号名称
/// </summary>
public string account_name { get; set; }
/// <summary>
/// 站点
/// </summary>
public string website { get; set; }
/// <summary>
/// 月份
/// </summary>
public string month { get; set; }
/// <summary>
/// 资金流水数量
/// </summary>
public int fund_flowing_count { get; set; }
/// <summary>
/// 同步流水数量
/// </summary>
public int sync_flowing_count { get; set; }
/// <summary>
/// 同步时间数量
/// </summary>
public int sync_time_count { get; set; }
/// <summary>
/// 同步状态
/// </summary>
public int sync_status { get; set; }
/// <summary>
/// 是否删除
/// </summary>
public bool delstatus { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime create_time { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime update_time { get; set; }
}
}
...@@ -4,6 +4,7 @@ using MySql.Data.MySqlClient; ...@@ -4,6 +4,7 @@ using MySql.Data.MySqlClient;
using Newtonsoft.Json; using Newtonsoft.Json;
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.XSSF.Streaming;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
...@@ -71,6 +72,24 @@ namespace Bailun.DC.Services.Component ...@@ -71,6 +72,24 @@ namespace Bailun.DC.Services.Component
} }
} }
private MySqlConnection _FUND_DB;
public MySqlConnection FUND_DB
{
get
{
if (_FUND_DB == null)
{
_FUND_DB = new MySqlConnection(GlobalConfig.ConnectionString_Fund);
}
if (_FUND_DB.State == ConnectionState.Closed)
{
_FUND_DB.Open();
}
return _FUND_DB;
}
}
public IEnumerable<T> DeserializeCollection<T>(string jsonStr) public IEnumerable<T> DeserializeCollection<T>(string jsonStr)
{ {
IEnumerable<T> list = default(IEnumerable<T>); IEnumerable<T> list = default(IEnumerable<T>);
...@@ -224,8 +243,8 @@ namespace Bailun.DC.Services.Component ...@@ -224,8 +243,8 @@ namespace Bailun.DC.Services.Component
MemoryStream ms = null; MemoryStream ms = null;
try try
{ {
workbook = new HSSFWorkbook(); workbook = dataCount <= 65535 ? (IWorkbook)new HSSFWorkbook() : new SXSSFWorkbook();
int excelMaxRowCount = 65535; int excelMaxRowCount = dataCount <= 65535 ? 65535 : 1048576;
for (int i = 0; (i * excelMaxRowCount < dataCount); i++) for (int i = 0; (i * excelMaxRowCount < dataCount); i++)
{ {
ISheet sheet = workbook.CreateSheet($"Sheet{i + 1}"); ISheet sheet = workbook.CreateSheet($"Sheet{i + 1}");
......
...@@ -44,6 +44,9 @@ namespace Bailun.DC.Services.Component ...@@ -44,6 +44,9 @@ namespace Bailun.DC.Services.Component
case DBEnum.Pro: case DBEnum.Pro:
db = PRO_DB; db = PRO_DB;
break; break;
case DBEnum.Fund:
db = FUND_DB;
break;
default: default:
db = DB; db = DB;
break; break;
......
using Bailun.DC.Models.Component.DTO; using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Models.Component.Entity; using Bailun.DC.Models.Component.Entity;
using Bailun.DC.Models.Component.Enum;
using Dapper; using Dapper;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Bailun.DC.Services.Component namespace Bailun.DC.Services.Component
......
...@@ -464,6 +464,7 @@ namespace Bailun.DC.Services.Component ...@@ -464,6 +464,7 @@ namespace Bailun.DC.Services.Component
{ {
byte[] b = default(byte[]); byte[] b = default(byte[]);
string name = default(string); string name = default(string);
int dataCount = default(int);
if (queryFilter != null) if (queryFilter != null)
{ {
TableDTO entity = this.Get(queryFilter.Code); TableDTO entity = this.Get(queryFilter.Code);
...@@ -482,6 +483,7 @@ namespace Bailun.DC.Services.Component ...@@ -482,6 +483,7 @@ namespace Bailun.DC.Services.Component
if (!string.IsNullOrWhiteSpace(entity.DataValue) && dataTypes.Contains(entity.DataType)) if (!string.IsNullOrWhiteSpace(entity.DataValue) && dataTypes.Contains(entity.DataType))
{ {
(int, IDataReader) reader = this.GetListDataReader(queryFilter, entity); (int, IDataReader) reader = this.GetListDataReader(queryFilter, entity);
dataCount = reader.Item1;
using (reader.Item2) using (reader.Item2)
{ {
b = DataReaderToExcel(listColumn, reader.Item2, reader.Item1); b = DataReaderToExcel(listColumn, reader.Item2, reader.Item1);
...@@ -500,7 +502,7 @@ namespace Bailun.DC.Services.Component ...@@ -500,7 +502,7 @@ namespace Bailun.DC.Services.Component
} }
if (b != null) if (b != null)
{ {
name = $"{(name ?? "Export")}_{DateTime.Now.ToString("yyyyMMddhhmm")}.xls"; name = $"{(name ?? "Export")}_{DateTime.Now.ToString("yyyyMMddhhmm")}.{(dataCount <= 65535 ? "xls" : "xlsx")}";
} }
return (name, b); return (name, b);
...@@ -757,6 +759,9 @@ namespace Bailun.DC.Services.Component ...@@ -757,6 +759,9 @@ namespace Bailun.DC.Services.Component
case DBEnum.Pro: case DBEnum.Pro:
db = PRO_DB; db = PRO_DB;
break; break;
case DBEnum.Fund:
db = FUND_DB;
break;
default: default:
db = DB; db = DB;
break; break;
......
using Bailun.DC.Models.Component.DTO; using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Services.Component; using Bailun.DC.Services.Component;
using Dapper;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
namespace Bailun.DC.Web.Areas.Component.Controllers namespace Bailun.DC.Web.Areas.Component.Controllers
{ {
......
using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Models.DataWareHouse.DTO;
using Bailun.DC.Services.DataWareHouse;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{
[Area("DataWareHouse")]
public class SyncController : Base.BaseController
{
[HttpPost]
public JsonResult LoadFundAmazonTransaction([FromForm] string month)
{
ResultDTO result = default(ResultDTO);
try
{
result = new SyncService().LoadFundAmazonTransaction(month);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
[HttpPost]
public JsonResult FundAmazonTransaction([FromForm] string month, [FromForm] IEnumerable<FundAmazonTransactionDTO> list)
{
ResultDTO result = default(ResultDTO);
try
{
result = new SyncService().FundAmazonTransaction(month, list);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
}
}
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