Commit cf7b03ff by 泽锋 李

fix

parent 5bcce937
using AutoTurnOver.Models;
using Bailun.ServiceFabric;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace AutoTurnOver.DB
{
public class dc_task_download_dao : connectionHelper
{
public static void PushData<T>(dc_task_download data, UserData user)
{
data.create_date = DateTime.Now;
data.create_user = user.UserName;
data.end_date = new DateTime(1991,1,1);
data.start_date = new DateTime(1991,1,1);
data.status = (int)dc_task_download_status.待执行;
data.result_file_url = "";
data.error_message = "";
data.error_stack_trace = "";
var parList = new List<string>();
var par = data.parameter.ToObject<T>();
Type dataType = par.GetType();
PropertyInfo[] properts = dataType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
if (properts.Any())
{
foreach (PropertyInfo item in properts)
{
var obj = item.GetValue(par);
if(obj!=null && !string.IsNullOrWhiteSpace(obj.ToString()))
{
parList.Add($"{item.Name}={obj.ToString()}");
}
}
}
if(parList!=null&& parList.Count >= 1)
{
data.parameter_show = string.Join("&", parList);
}
else
{
data.parameter_show = "";
}
_connection.Insert(data);
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
<None Remove="appsettings.Production.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.Production.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AutoTurnOver.DB\AutoTurnOver.DB.csproj" />
<ProjectReference Include="..\AutoTurnOver.Models\AutoTurnOver.Models.csproj" />
<ProjectReference Include="..\AutoTurnOver.Services\AutoTurnOver.Services.csproj" />
<ProjectReference Include="..\AutoTurnOver.Utility\AutoTurnOver.Utility.csproj" />
</ItemGroup>
</Project>
FROM microsoft/dotnet:2.1-runtime-alpine 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-alpine AS build
WORKDIR /src
COPY ["AutoTurnOver.DownloadService/AutoTurnOver.DownloadService.csproj", "AutoTurnOver.DownloadService/"]
COPY ["AutoTurnOver.DB/AutoTurnOver.DB.csproj", "AutoTurnOver.DB/"]
COPY ["AutoTurnOver.Utility/AutoTurnOver.Utility.csproj", "AutoTurnOver.Utility/"]
COPY ["AutoTurnOver.Models/AutoTurnOver.Models.csproj", "AutoTurnOver.Models/"]
COPY ["AutoTurnOver.Services/AutoTurnOver.Services.csproj", "AutoTurnOver.Services/"]
RUN dotnet restore "AutoTurnOver.DownloadService/AutoTurnOver.DownloadService.csproj"
COPY . .
WORKDIR "/src/AutoTurnOver.DownloadService"
RUN dotnet build "AutoTurnOver.DownloadService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "AutoTurnOver.DownloadService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AutoTurnOver.DownloadService.dll"]
\ No newline at end of file
using AutoTurnOver.DB;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AutoTurnOver.DownloadService
{
public class DownloadService : BackgroundService
{
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
return Task.CompletedTask;
}
private void DoWork(object state)
{
var now = DateTime.Now;
}
public override void Dispose()
{
base.Dispose();
_timer?.Dispose();
}
}
}
using AutoTurnOver.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;
namespace AutoTurnOver.DownloadService
{
class Program
{
static async Task Main(string[] args)
{
try
{
await new TaskDownloadServices().Download();
}
catch (Exception ex)
{
throw;
}
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<DownloadService>();
});
await builder.RunConsoleAsync();
}
}
}
{
"profiles": {
"AutoTurnOver.DownloadService": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}
\ No newline at end of file
{
"ConnectionStrings": {
"Default": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"ReadOnly": "server=gz-cdbrg-qdyec2j3.sql.tencentcdb.com;port=59667;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"PushBuyPlan": "http://api.purchase.bailuntec.com/api/CreatePlanToPurchase",
"WebHost_GetUser": "http://oa.bailuntec.com/Login/GetUserByBLUserAcct?webcode=aims",
"WebHost_LoginOut": "http://oa.bailuntec.com/Login/LoginOut",
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": 0
},
"SaveDefaultWares": "http://api.skums.bailuntec.com/api/sku/productware/savedefaultwares",
"Crm_Case_Order": "http://crm.bailuntec.com/api/CaseOrderList",
"Crm_Message": "http://crm.bailuntec.com/api/MessageList",
"Crm_Message_Reply": "http://crm.bailuntec.com/api/MessageReplyList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"Pams_PlatformList": "http://pams.bailuntec.com/Api/GetPlatformSites?type=1",
"Crm_Message_Custom_Template": "http://crm.bailuntec.com/api/MessageCustomTemplateList",
"CRM_SendMessage": "http://kefu.bailuntec.com/api/SendMessage",
"PPS_ShortagePush": "",
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"CdnUrl": "http://imgcache.bailuntec.com"
},
"QiYeJiQiRen": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5fa4c1d5-ce65-4e8a-9ae9-a0d689a13b65",
"GetSchedulings": "http://oa.bailuntec.com/Api/Cq/GetSchedulings?userID=2409",
"SkuSys_CategoryList": "http://api.skums.bailuntec.com/api/category/simplecategory/categoriessimplebylevel",
"Saas_GetTokenValid": "http://sso.bailuntec.com/GetTokenValidation",
"Saas_GetUser": "http://sso.bailuntec.com/GetUserResource",
"Saas_Users": "http://sso.bailuntec.com/GetUserByCompany",
"Saas_Departments": "http://sso.bailuntec.com/GetDepartmentsByCompanyId",
"Saas_GetMenus": "http://sso.bailuntec.com/GetMenus",
"ApiLogisticsGetFilterLogisticsAssignLine": "http://lms.bailuntec.com/api/Logistics/ApiLogistics/GetFilterLogisticsAssignLine",
"PostPlatCategoryRate": "http://test.profit.bailuntec.com/api/platfee/ProfitPlatfee/PostPlatCategoryRate",
"api_plat_category": "http://doc.bailuntec.com:6040/profitplatfee/getplatcategory",
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
},
"SupplierReturnSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertReturnSkuInfo",
"OmsReturnSkuInfo": "http://oms.bailuntec.com/apiV2/bailunOrder/importReturnOrderForExternal"
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"ReadOnly": "server=10.0.8.21;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"PushBuyPlan": "http://api.purchase.bailuntec.com/api/CreatePlanToPurchase",
"WebHost_GetUser": "http://oa.bailuntec.com/Login/GetUserByBLUserAcct?webcode=aims",
"WebHost_LoginOut": "http://oa.bailuntec.com/Login/LoginOut",
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "10.0.2.11",
"Port": "6379",
"Password": "",
"Defaultdatabase": 0
},
"SaveDefaultWares": "http://api.skums.bailuntec.com/api/sku/productware/savedefaultwares",
"Crm_Case_Order": "http://crm.bailuntec.com/api/CaseOrderList",
"Crm_Message": "http://crm.bailuntec.com/api/MessageList",
"Crm_Message_Reply": "http://crm.bailuntec.com/api/MessageReplyList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"Pams_PlatformList": "http://pams.bailuntec.com/Api/GetPlatformSites?type=1",
"Crm_Message_Custom_Template": "http://crm.bailuntec.com/api/MessageCustomTemplateList",
"CRM_SendMessage": "http://kefu.bailuntec.com/api/SendMessage",
"PPS_ShortagePush": "",
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"CdnUrl": "http://imgcache.bailuntec.com"
},
"QiYeJiQiRen": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5fa4c1d5-ce65-4e8a-9ae9-a0d689a13b65",
"GetSchedulings": "http://oa.bailuntec.com/Api/Cq/GetSchedulings?userID=2409",
"SkuSys_CategoryList": "http://api.skums.bailuntec.com/api/category/simplecategory/categoriessimplebylevel",
"Saas_GetTokenValid": "http://sso.bailuntec.com/GetTokenValidation",
"Saas_GetUser": "http://sso.bailuntec.com/GetUserResource",
"Saas_Users": "http://sso.bailuntec.com/GetUserByCompany",
"Saas_Departments": "http://sso.bailuntec.com/GetDepartmentsByCompanyId",
"Saas_GetMenus": "http://sso.bailuntec.com/GetMenus",
"ApiLogisticsGetFilterLogisticsAssignLine": "http://lms.bailuntec.com/api/Logistics/ApiLogistics/GetFilterLogisticsAssignLine",
"PostPlatCategoryRate": "http://172.31.255.11/api/platfee/ProfitPlatfee/PostPlatCategoryRate",
"api_plat_category": "http://doc.bailuntec.com:6040/profitplatfee/getplatcategory",
"BrowseLogSetting": {
"Url": "http://10.0.0.11:5001/operationloginfo/addoperationloginfo",
"CanLog": "yes"
},
"SupplierReturnSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertReturnSkuInfo",
"OmsReturnSkuInfo": "http://oms.bailuntec.com/apiV2/bailunOrder/importReturnOrderForExternal"
}
{
"ConnectionStrings": {
"Default": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"ReadOnly": "server=gz-cdbrg-qdyec2j3.sql.tencentcdb.com;port=59667;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"PushBuyPlan": "http://api.purchase.bailuntec.com/api/CreatePlanToPurchase",
"WebHost_GetUser": "http://oa.bailuntec.com/Login/GetUserByBLUserAcct?webcode=aims",
"WebHost_LoginOut": "http://oa.bailuntec.com/Login/LoginOut",
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": 0
},
"SaveDefaultWares": "http://api.skums.bailuntec.com/api/sku/productware/savedefaultwares",
"Crm_Case_Order": "http://crm.bailuntec.com/api/CaseOrderList",
"Crm_Message": "http://crm.bailuntec.com/api/MessageList",
"Crm_Message_Reply": "http://crm.bailuntec.com/api/MessageReplyList",
"Lms_GetLogistics": "http://api.lms2.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"Pams_PlatformList": "http://pams.bailuntec.com/Api/GetPlatformSites?type=1",
"Crm_Message_Custom_Template": "http://crm.bailuntec.com/api/MessageCustomTemplateList",
"CRM_SendMessage": "http://kefu.bailuntec.com/api/SendMessage",
"PPS_ShortagePush": "",
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"CdnUrl": "http://imgcache.bailuntec.com"
},
"QiYeJiQiRen": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5fa4c1d5-ce65-4e8a-9ae9-a0d689a13b65",
"GetSchedulings": "http://oa.bailuntec.com/Api/Cq/GetSchedulings?userID=2409",
"SkuSys_CategoryList": "http://api.skums.bailuntec.com/api/category/simplecategory/categoriessimplebylevel",
"Saas_GetTokenValid": "http://sso.bailuntec.com/GetTokenValidation",
"Saas_GetUser": "http://sso.bailuntec.com/GetUserResource",
"Saas_Users": "http://sso.bailuntec.com/GetUserByCompany",
"Saas_Departments": "http://sso.bailuntec.com/GetDepartmentsByCompanyId",
"Saas_GetMenus": "http://sso.bailuntec.com/GetMenus",
"ApiLogisticsGetFilterLogisticsAssignLine": "http://lms.bailuntec.com/api/Logistics/ApiLogistics/GetFilterLogisticsAssignLine",
"PostPlatCategoryRate": "http://test.profit.bailuntec.com/api/platfee/ProfitPlatfee/PostPlatCategoryRate",
"api_plat_category": "http://doc.bailuntec.com:6040/profitplatfee/getplatcategory",
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
},
"SupplierReturnSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertReturnSkuInfo",
"OmsReturnSkuInfo": "http://oms.bailuntec.com/apiV2/bailunOrder/importReturnOrderForExternal"
}
using System;
using AutoTurnOver.Models.ApiDto;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -356,16 +357,44 @@ namespace AutoTurnOver.Models
/// </summary>
public int? sku_status { get; set; }
public string sku_status_str { get
public string sku_status_str
{
get
{
if (sku_status == null) return "";
return ((sku_status_enum)sku_status).ToString();
} }
}
}
public enum sku_status_enum
{
停售 =1,
停售 = 1,
在售 = 2
}
}
public class dc_base_stock_search_dto
{
public int? monitor_status { get; set; }
public bool isSum { get; set; }
public bool is_warehouse_sum { get; set; }
public int? searchType { get; set; }
public string key_words { get; set; }
public string warehousecode { get; set; }
public string buyer_name { get; set; }
public string supplier_name { get; set; }
public int offset { get; set; }
public int limit { get; set; }
public string order { get; set; }
public string sort { get; set; }
public string warehousetype { get; set; }
public int? warehousearea { get; set; }
public int? has_tort { get; set; } = null;
public string categoryIds { get; set; } = null;
public DateTime? start_date { get; set; } = null;
public DateTime? end_date { get; set; } = null;
public DateTime? f_start_date { get; set; } = null;
public DateTime? f_end_date { get; set; } = null;
public int? product_type { get; set; } = null;
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
/// <summary>
/// 文件下载任务
/// </summary>
public class dc_task_download
{
public int id { get; set; }
public string task_name { get; set; }
public string parameter { get; set; }
public DateTime create_date { get; set; }
public string parameter_show { get; set; }
public string create_user { get; set; }
public int status { get; set; }
public DateTime start_date { get; set; }
public DateTime end_date { get; set; }
public string result_file_url { get; set; }
public string error_message { get; set; }
public string error_stack_trace { get; set; }
}
public enum dc_task_download_status
{
待执行 = 0, 执行中 = 1, 执行完成 = 2, 执行失败 = 3
}
}
......@@ -39,15 +39,14 @@ namespace AutoTurnOver.Services
}
public List<dc_base_stock_dto> RealtimeList(int? monitor_status,int? searchType, string key_words, string warehouse_code,string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea,bool isSum = false,string order = null,string sort = null,int? has_tort = null,string categoryIds = null,string buyer_name = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null,int? product_type = null, bool is_warehouse_sum = false)
public List<dc_base_stock_dto> RealtimeList(dc_base_stock_search_dto search_data,ref int total)
{
List<bailun_category_new_dto> categoryModels = null;
if (!string.IsNullOrWhiteSpace(categoryIds))
if (!string.IsNullOrWhiteSpace(search_data.categoryIds))
{
categoryModels = ApiServices.GetNewClientNodesByIds(categoryIds.Split(',').Select(s => int.Parse(s)).ToList());
categoryModels = ApiServices.GetNewClientNodesByIds(search_data.categoryIds.Split(',').Select(s => int.Parse(s)).ToList());
}
return DB.daily.RealtimeList(monitor_status, searchType, key_words, warehouse_code, supplier_name, offset, limit, ref total,warehousetype,warehousearea, isSum, order, sort, has_tort:has_tort, categoryModels: categoryModels, buyer_name:buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date, product_type: product_type, is_warehouse_sum);
return DB.daily.RealtimeList(search_data, categoryModels, ref total);
}
public List<dc_auto_shortage_push_route_dto> ShortagePushList(string platform, string bailun_sku, int offset, int limit, ref int total, DateTime? start_date, DateTime? end_date, string warehousecode, string warehousetype, int? warehousearea)
......@@ -137,14 +136,13 @@ namespace AutoTurnOver.Services
private static int export_count = 0;
public MemoryStream Export(UserData user,int? monitor_status, int? searchType, string key_words, string warehousecode, string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea, bool isSum = false, string order = null, string sort = null, int? has_tort = null,string buyer_name =null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null,int? product_type = null)
public string Export(dc_base_stock_search_dto search_data)
{
try
{
export_count++;
var services = new DailyServices();
var fileName = AppContext.BaseDirectory + $@"Result\RealtimeStock\{user.UserAccount}实时库存-{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv";
var fileName = AppContext.BaseDirectory + $@"Result\RealtimeStock\实时库存-{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv";
int page = 1;
int rows = 50000;
if (export_count == 1)
......@@ -154,7 +152,10 @@ namespace AutoTurnOver.Services
while (true)
{
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, (page - 1) * rows, rows, ref total, warehousetype, warehousearea, has_tort: has_tort, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date, product_type:product_type);
int total = 0;
search_data.offset = (page - 1);
search_data.limit = rows;
var list = services.RealtimeList(search_data,ref total);
if (list == null || list.Count <= 0) break;
......@@ -266,14 +267,7 @@ namespace AutoTurnOver.Services
var memory = new MemoryStream();
using (var stream = new FileStream(fileName, FileMode.Open))
{
stream.CopyTo(memory);
}
memory.Position = 0;
export_count--;
return memory;
return fileName;
}
catch (Exception)
{
......@@ -287,10 +281,10 @@ namespace AutoTurnOver.Services
{
try
{
var total = 0;
var memory = Export(new UserData { UserAccount = "admin" },null, null, null, null, null, 0, 0, ref total, "国内仓", null);
var fileData = await QiNiuCloudHelper.UploadAsync(memory, $"stock_{DateTime.Now.ToString("yyyyMMddHmmss")}.csv");
ApiServices.QiYeJiQiRenMsPush(new QiYeJiQiRenMsDto { msgtype = "text", text = new QiYeJiQiRenMsDto.text_dto { content = "国内仓实时库存:" + fileData } });
//var total = 0;
// var memory = Export(new UserData { UserAccount = "admin" },null, null, null, null, null, 0, 0, ref total, "国内仓", null);
// var fileData = await QiNiuCloudHelper.UploadAsync(memory, $"stock_{DateTime.Now.ToString("yyyyMMddHmmss")}.csv");
// ApiServices.QiYeJiQiRenMsPush(new QiYeJiQiRenMsDto { msgtype = "text", text = new QiYeJiQiRenMsDto.text_dto { content = "国内仓实时库存:" + fileData } });
}
catch (Exception ex)
{
......
using AutoTurnOver.Models;
using Bailun.ServiceFabric;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AutoTurnOver.Utility;
using AutoTurnOver.DB;
using Dapper;
using System.Linq;
using System.Threading.Tasks;
namespace AutoTurnOver.Services
{
/// <summary>
/// 下载服务
/// </summary>
public class TaskDownloadServices
{
/// <summary>
/// 开启下载任务
/// </summary>
public async Task<int> Download()
{
int count = 0;
var dc_task_download_datas = MyMySqlConnection._connection_read_only.Query<dc_task_download>(" select * from dc_task_download where status=@status order by create_date desc ", new { status = (int)dc_task_download_status.待执行 }).ToList();
foreach (var item in dc_task_download_datas)
{
// 查询当前待处理的任务
try
{
item.status = (int)dc_task_download_status.执行中;
item.start_date = DateTime.Now;
MyMySqlConnection._connection.Update(item);
switch (item.task_name)
{
case "实时库存":
item.result_file_url = await DownloadStock(item.parameter, item);
break;
default: throw new Exception("无法识别的任务");
}
item.end_date = DateTime.Now;
item.status = (int)dc_task_download_status.执行完成;
count++;
}
catch (Exception ex)
{
item.status = (int)dc_task_download_status.执行失败;
item.error_message = ex.Message;
item.error_stack_trace = ex.StackTrace;
}
MyMySqlConnection._connection.Update(item);
}
return count;
}
/// <summary>
/// 下载库存
/// </summary>
public async Task<string> DownloadStock(string par_json, dc_task_download download_data)
{
dc_base_stock_search_dto search_data = par_json.ToObject<dc_base_stock_search_dto>();
var memory = new DailyServices().Export(search_data);
var fileData = await AutoTurnOver.Utility.QiNiuCloudHelper.UploadSectioningAsync(memory);
return fileData;
}
}
}
......@@ -39,6 +39,15 @@ namespace AutoTurnOver.Utility
}
return PicServerUrl + "/" + saveFile;
}
public static async Task<string> UploadSectioningAsync(string saveFile)
{
var resultData = await UploadStreamSectioningAsync(saveFile);
if (resultData.Code != 200)
{
throw new Exception(resultData.RefText);
}
return PicServerUrl + "/" + Path.GetFileName(saveFile);
}
/// <summary>
/// 上传文件
......@@ -89,6 +98,33 @@ namespace AutoTurnOver.Utility
var result = await target.UploadStream(stream, saveFile, token, null);
return result;
}
public static async Task<HttpResult> UploadStreamSectioningAsync(string filePath)
{
Mac mac = new Mac(AccessKey, SecretKey);
// 设置上传策略
PutPolicy putPolicy = new PutPolicy();
var key = Path.GetFileName(filePath);
putPolicy.Scope = Bucket + ":" + key;
putPolicy.SetExpires(3600);
string token = Auth.CreateUploadToken(mac, putPolicy.ToJsonString());
Config config = new Config();
// 设置上传区域
config.Zone = Zone.ZoneCnSouth;
// 设置 http 或者 https 上传
config.UseHttps = true;
config.UseCdnDomains = true;
config.ChunkSize = ChunkUnit.U512K;
ResumableUploader target = new ResumableUploader(config);
PutExtra extra = new PutExtra();
//设置断点续传进度记录文件
extra.ResumeRecordFile = ResumeHelper.GetDefaultRecordKey(filePath, key);
Console.WriteLine("record file:" + extra.ResumeRecordFile);
extra.ResumeRecordFile = "test.progress";
HttpResult result = await target.UploadFile(filePath, key, token, extra);
Console.WriteLine("resume upload: " + result.ToString());
return result;
}
#endregion
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTurnOver", "AutoTurnOver\AutoTurnOver.csproj", "{DDEDF08E-7F69-49F2-BE22-664DCB4FF9F2}"
EndProject
......@@ -21,7 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGeneratePurchaseAdvise"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResetOutofstock", "ResetOutofstock\ResetOutofstock.csproj", "{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShortagePush", "ShortagePush\ShortagePush.csproj", "{87123947-1F13-4EBE-8667-AEB2CFB07738}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShortagePush", "ShortagePush\ShortagePush.csproj", "{87123947-1F13-4EBE-8667-AEB2CFB07738}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoTurnOver.DownloadService", "AutoTurnOver.DownloadService\AutoTurnOver.DownloadService.csproj", "{1DEF4053-DDCA-4AFF-94E6-25FA4F16CDB4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -65,6 +67,10 @@ Global
{87123947-1F13-4EBE-8667-AEB2CFB07738}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87123947-1F13-4EBE-8667-AEB2CFB07738}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87123947-1F13-4EBE-8667-AEB2CFB07738}.Release|Any CPU.Build.0 = Release|Any CPU
{1DEF4053-DDCA-4AFF-94E6-25FA4F16CDB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DEF4053-DDCA-4AFF-94E6-25FA4F16CDB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DEF4053-DDCA-4AFF-94E6-25FA4F16CDB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DEF4053-DDCA-4AFF-94E6-25FA4F16CDB4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -74,6 +80,7 @@ Global
{350405A0-13DF-4F20-8B3F-0AB923BE9DFF} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{87123947-1F13-4EBE-8667-AEB2CFB07738} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{1DEF4053-DDCA-4AFF-94E6-25FA4F16CDB4} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {09B3C433-2F6E-498C-AB7C-2931F260C5CE}
......
......@@ -88,15 +88,14 @@ namespace AutoTurnOver.Controllers
/// <param name="limit"></param>
/// <returns></returns>
[HttpGet("RealtimeStockList")]
public JsonResult RealtimeStockList(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null, int? product_type = null, bool is_warehouse_sum = false)
public JsonResult RealtimeStockList([FromQuery]dc_base_stock_search_dto search_data)
{
try
{
var services = new DailyServices();
var total = 0;
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, order: order, sort: sort, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date, product_type: product_type, is_warehouse_sum:is_warehouse_sum);
var list = services.RealtimeList(search_data,ref total);
return new JsonResult(new
{
......@@ -116,13 +115,13 @@ namespace AutoTurnOver.Controllers
}
[HttpGet("RealtimeListSumFooter")]
public JsonResult RealtimeListSumFooter(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null, int? product_type = null)
public JsonResult RealtimeListSumFooter([FromQuery]dc_base_stock_search_dto search_data)
{
var services = new DailyServices();
var total = 0;
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, true, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date, product_type: product_type);
search_data.isSum = true;
var list = services.RealtimeList(search_data, ref total) ;
return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]);
}
......
......@@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AutoTurnOver.Common;
using AutoTurnOver.DB;
using AutoTurnOver.Models;
using AutoTurnOver.Services;
using AutoTurnOver.Utility;
......@@ -62,15 +63,14 @@ namespace AutoTurnOver.Controllers
/// <returns></returns>
[UseAction]
[BrowseLog("Bailun_aims", "访问【百伦自动周转系统】->【实时数据】->【实时库存】->【搜索】页面", 0)]
public JsonResult RealtimeList(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null, int? product_type = null)
public JsonResult RealtimeList([FromQuery]dc_base_stock_search_dto search_data)
{
try
{
var services = new DailyServices();
var total = 0;
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, order: order, sort: sort, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date, product_type: product_type);
var list = services.RealtimeList(search_data, ref total);
return new JsonResult(new
{
......@@ -89,16 +89,17 @@ namespace AutoTurnOver.Controllers
}
public JsonResult RealtimeListSumFooter(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null, int? product_type = null)
public JsonResult RealtimeListSumFooter([FromQuery]dc_base_stock_search_dto search_data)
{
var services = new DailyServices();
var total = 0;
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, true, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date, product_type: product_type);
search_data.isSum = true;
var list = services.RealtimeList(search_data, ref total);
return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]);
}
/// <summary>
/// 缺货推送记录
......@@ -169,13 +170,27 @@ namespace AutoTurnOver.Controllers
/// <param name="warehousecode"></param>
/// <returns></returns>
[UseAction]
public FileResult ExportRealtime(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null)
public JsonResult ExportRealtime([FromQuery]dc_base_stock_search_dto search_data)
{
var user = AutoUtility.GetUser();
int total = 0;
var memory = new DailyServices().Export(user, monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, has_tort: has_tort, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date);
return File(memory, "text/csv", $"{user.UserAccount}实时库存.csv");
try
{
var user = AutoUtility.GetUser();
search_data.limit = int.MaxValue;
dc_task_download_dao.PushData<dc_base_stock_search_dto>(new dc_task_download
{
parameter = search_data.ToJson(),
task_name = "实时库存"
}, user);
return new JsonResult(new { success = true });
}
catch (Exception ex)
{
return new JsonResult(new { success = false,message = ex.Message });
}
//int total = 0;
//var memory = new DailyServices().Export(user, monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, has_tort: has_tort, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date);
//return File(memory, "text/csv", $"{user.UserAccount}实时库存.csv");
}
/// <summary>
......@@ -238,7 +253,7 @@ namespace AutoTurnOver.Controllers
var services = new StockMonitorService();
var page_data = services.GetListingStatusPage(new listing_status_view_search_dto
{
product_type= product_type,
product_type = product_type,
product_code = product_code,
source = source,
warehouse_code = warehouse_code,
......
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