Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-center-auto
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
data-center-auto
Commits
ba0a3765
Commit
ba0a3765
authored
Jul 18, 2019
by
lizefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增自动数据下载,推送到企业微信
parent
cdcdeac0
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
316 additions
and
6 deletions
+316
-6
GeneratePurchaseAdviseBackgroundService.cs
...PurchaseAdvise/GeneratePurchaseAdviseBackgroundService.cs
+9
-0
Program.cs
AutoGeneratePurchaseAdvise/Program.cs
+1
-0
appsettings.dev.json
AutoGeneratePurchaseAdvise/appsettings.dev.json
+7
-1
appsettings.json
AutoGeneratePurchaseAdvise/appsettings.json
+7
-1
appsettings.prod.json
AutoGeneratePurchaseAdvise/appsettings.prod.json
+8
-1
QiYeJiQiRenMsDto.cs
AutoTurnOver.Models/QiYeJiQiRenMsDto.cs
+17
-0
ApiServices.cs
AutoTurnOver.Services/ApiServices.cs
+7
-0
SkuAutoTurnServices.cs
AutoTurnOver.Services/SkuAutoTurnServices.cs
+15
-0
AutoTurnOver.Utility.csproj
AutoTurnOver.Utility/AutoTurnOver.Utility.csproj
+2
-0
QiNiuCloudHelper.cs
AutoTurnOver.Utility/QiNiuCloudHelper.cs
+222
-0
appsettings.Development.json
AutoTurnOver/appsettings.Development.json
+7
-1
appsettings.Production.json
AutoTurnOver/appsettings.Production.json
+7
-1
appsettings.json
AutoTurnOver/appsettings.json
+7
-1
No files found.
AutoGeneratePurchaseAdvise/GeneratePurchaseAdviseBackgroundService.cs
View file @
ba0a3765
...
...
@@ -45,6 +45,15 @@ namespace AutoGeneratePurchaseAdvise
PurchaseAdviseServices
.
AutoPushBuySys
();
Console
.
WriteLine
(
$"结束推送采购建议任务,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
}
if
(
now
.
Hour
==
7
&&
now
.
Minute
==
29
)
{
Console
.
WriteLine
(
$"开始推送采购建议任务,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
new
SkuAutoTurnServices
().
GenerateData
();
Console
.
WriteLine
(
$"结束推送采购建议任务,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
}
}
catch
(
Exception
ex
)
{
...
...
AutoGeneratePurchaseAdvise/Program.cs
View file @
ba0a3765
...
...
@@ -18,6 +18,7 @@ namespace AutoGeneratePurchaseAdvise
//purchase_advise.ImportJITShortageDetailed(0);
//PurchaseAdviseServices.Generate();
//PurchaseAdviseServices.Generate();
new
SkuAutoTurnServices
().
GenerateData
();
var
builder
=
new
HostBuilder
().
ConfigureServices
((
hostContext
,
services
)
=>
{
services
.
AddHostedService
<
GeneratePurchaseAdviseBackgroundService
>();
...
...
AutoGeneratePurchaseAdvise/appsettings.dev.json
View file @
ba0a3765
...
...
@@ -2,5 +2,11 @@
"ConnectionStrings"
:
{
"Default"
:
"server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"PushBuyPlan"
:
"http://purchase.bailuntec.com/api/CreatePlanToPurchase"
"PushBuyPlan"
:
"http://purchase.bailuntec.com/api/CreatePlanToPurchase"
,
"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"
}
AutoGeneratePurchaseAdvise/appsettings.json
View file @
ba0a3765
...
...
@@ -2,5 +2,11 @@
"ConnectionStrings"
:
{
"Default"
:
"server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"PushBuyPlan"
:
"http://purchase.bailuntec.com/api/CreatePlanToPurchase"
"PushBuyPlan"
:
"http://purchase.bailuntec.com/api/CreatePlanToPurchase"
,
"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"
}
AutoGeneratePurchaseAdvise/appsettings.prod.json
View file @
ba0a3765
...
...
@@ -2,5 +2,11 @@
"ConnectionStrings"
:
{
"Default"
:
"server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"PushBuyPlan"
:
"http://purchase.bailuntec.com/api/CreatePlanToPurchase"
"PushBuyPlan"
:
"http://purchase.bailuntec.com/api/CreatePlanToPurchase"
,
"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"
}
\ No newline at end of file
AutoTurnOver.Models/QiYeJiQiRenMsDto.cs
0 → 100644
View file @
ba0a3765
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
AutoTurnOver.Models
{
public
class
QiYeJiQiRenMsDto
{
public
string
msgtype
{
get
;
set
;
}
public
text_dto
text
{
get
;
set
;
}
public
class
text_dto
{
public
string
content
{
get
;
set
;
}
}
}
}
AutoTurnOver.Services/ApiServices.cs
View file @
ba0a3765
...
...
@@ -546,5 +546,12 @@ namespace AutoTurnOver.Services
return
result
;
}
public
static
void
QiYeJiQiRenMsPush
(
QiYeJiQiRenMsDto
data
)
{
string
url
=
ConfigHelper
.
GetValue
(
"QiYeJiQiRen"
);
string
resultStr
=
HttpHelper
.
Request
(
url
,
RequestType
.
POST
,
data
.
ToJson
(),
timeout
:
1000
*
60
*
60
*
24
,
entype
:
"application/json"
);
}
}
}
AutoTurnOver.Services/SkuAutoTurnServices.cs
View file @
ba0a3765
...
...
@@ -6,6 +6,7 @@ using System.Linq;
using
System.IO
;
using
System.Data
;
using
AutoTurnOver.Utility
;
using
System.Threading.Tasks
;
namespace
AutoTurnOver.Services
{
...
...
@@ -362,5 +363,19 @@ namespace AutoTurnOver.Services
return
memory
;
}
/// <summary>
/// 生产数据
/// </summary>
/// <returns></returns>
public
async
void
GenerateData
()
{
var
memory
=
Export
(
new
UserData
{
UserAccount
=
"admin"
},
new
Condition_AutoTurnOver
{
warehouse_code
=
"GZBLWH"
},
""
,
""
);
var
fileData
=
await
QiNiuCloudHelper
.
UploadAsync
(
memory
,
$"zhouzhuangshuj_
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)}
.csv"
);
ApiServices
.
QiYeJiQiRenMsPush
(
new
QiYeJiQiRenMsDto
{
msgtype
=
"text"
,
text
=
new
QiYeJiQiRenMsDto
.
text_dto
{
content
=
"广州01周转数据:"
+
fileData
}
});
}
}
}
AutoTurnOver.Utility/AutoTurnOver.Utility.csproj
View file @
ba0a3765
...
...
@@ -10,6 +10,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Qiniu.SDK" Version="8.0.0" />
</ItemGroup>
</Project>
\ No newline at end of file
AutoTurnOver.Utility/QiNiuCloudHelper.cs
0 → 100644
View file @
ba0a3765
using
Newtonsoft.Json
;
using
Qiniu.Storage
;
using
Qiniu.Util
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Net
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
using
HttpResult
=
Qiniu
.
Http
.
HttpResult
;
namespace
AutoTurnOver.Utility
{
/// <summary>
/// 七牛云辅助类
/// </summary>
public
class
QiNiuCloudHelper
{
public
static
readonly
string
AccessKey
=
ConfigHelper
.
GetValue
(
"QiNiu:AccessKey"
);
public
static
readonly
string
SecretKey
=
ConfigHelper
.
GetValue
(
"QiNiu:SecretKey"
);
public
static
readonly
string
PicServerUrl
=
ConfigHelper
.
GetValue
(
"QiNiu:CdnUrl"
);
/// <summary>
/// 七牛存储节点
/// </summary>
private
static
readonly
string
Bucket
=
"bailun-kaoqin-img"
;
#
region
上传文件
public
static
async
Task
<
string
>
UploadAsync
(
Stream
stream
,
string
saveFile
)
{
var
resultData
=
await
UploadStreamAsync
(
stream
,
saveFile
);
if
(
resultData
.
Code
!=
200
)
{
throw
new
Exception
(
resultData
.
RefText
);
}
return
PicServerUrl
+
"/"
+
saveFile
;
}
/// <summary>
/// 上传文件
/// </summary>
/// <param name="saveFile"></param>
/// <param name="content"></param>
/// <returns></returns>
public
static
async
Task
<
HttpResult
>
UploadStreamAsync
(
string
saveFile
,
byte
[]
content
)
{
Mac
mac
=
new
Mac
(
AccessKey
,
SecretKey
);
// 设置上传策略,详见:https://developer.qiniu.com/kodo/manual/1206/put-policy
PutPolicy
putPolicy
=
new
PutPolicy
();
putPolicy
.
Scope
=
Bucket
+
":"
+
saveFile
;
//覆盖式更新
// 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;
FormUploader
target
=
new
FormUploader
(
config
);
var
result
=
await
target
.
UploadStream
(
new
MemoryStream
(
content
),
saveFile
,
token
,
null
);
return
result
;
}
public
static
async
Task
<
HttpResult
>
UploadStreamAsync
(
Stream
stream
,
string
saveFile
)
{
Mac
mac
=
new
Mac
(
AccessKey
,
SecretKey
);
// 设置上传策略,详见:https://developer.qiniu.com/kodo/manual/1206/put-policy
PutPolicy
putPolicy
=
new
PutPolicy
();
putPolicy
.
Scope
=
Bucket
+
":"
+
saveFile
;
//覆盖式更新
// 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;
FormUploader
target
=
new
FormUploader
(
config
);
var
result
=
await
target
.
UploadStream
(
stream
,
saveFile
,
token
,
null
);
return
result
;
}
#
endregion
#
region
获取七牛云缩略图,默认为
550
宽高
/// <summary>
/// 获取七牛云等比缩放缩略图,默认为550宽高,可用于放大的配置
/// </summary>
/// <param name="url">七牛云图片路径(clouddn.com格式)</param>
/// <param name="width">宽度</param>
/// <param name="height">高度</param>
/// <param name="quantity">图片质量,0-100</param>
/// <returns></returns>
public
static
string
GetQiNiuScaleThumbnail
(
string
url
,
int
width
=
550
,
int
height
=
550
,
int
quantity
=
75
)
{
var
imgFunc
=
$"imageMogr2/thumbnail/!
{
width
}
x
{
height
}
r/blur/1x0/quality/
{
quantity
}
"
;
if
(
url
.
Contains
(
"clouddn.com"
)
&&
!
url
.
Contains
(
"imageMogr2"
)
&&
width
>
0
&&
height
>
0
)
//代表七牛云图片路径
{
return
url
+
"?"
+
imgFunc
;
}
return
url
;
}
#
endregion
/// <summary>
/// 获取缩略图
/// </summary>
/// <param name="url">七牛云图片路径(clouddn.com格式)</param>
/// <param name="width">宽度</param>
/// <param name="height">高度</param>
/// <returns></returns>
public
static
string
GetQiNiuThumbnail
(
string
url
,
int
width
=
100
,
int
height
=
100
)
{
var
imgFunc
=
$"imageView2/2/w/
{
width
}
/h/
{
height
}
/q/75|imageslim"
;
if
(
url
.
Contains
(
"clouddn.com"
)
&&
!
url
.
Contains
(
"imageView2"
)
&&
width
>
0
&&
height
>
0
)
//代表七牛云图片路径
{
return
url
+
"?"
+
imgFunc
;
}
return
url
;
}
/// <summary>
/// 根据指定宽高强制缩放
/// </summary>
/// <param name="url"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="quantity"></param>
/// <returns></returns>
public
static
string
GetQiNiuScaleLimitSizeThumbnail
(
string
url
,
int
width
=
550
,
int
height
=
550
,
int
quantity
=
75
)
{
var
imgFunc
=
$"imageMogr2/auto-orient/thumbnail/
{
width
}
x
{
height
}
!/blur/1x0/quality/
{
quantity
}
|imageslim"
;
if
(!
string
.
IsNullOrWhiteSpace
(
url
)
&&
IsSupportQiniu
(
url
)
&&
!
url
.
Contains
(
"imageMogr2"
)
&&
!
url
.
Contains
(
"imageView2"
)
&&
width
>
0
&&
height
>
0
)
//代表七牛云图片路径
{
return
ReplaceLocalUrlToQiniuUrl
(
url
)
+
"?"
+
imgFunc
;
}
return
ReplaceLocalUrlToQiniuUrl
(
url
);
}
/// <summary>
/// 本地文件路径替换为七牛云图片路径
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public
static
string
ReplaceLocalUrlToQiniuUrl
(
string
url
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
url
)
&&
url
.
Contains
(
"http://oyd60abh0.bkt.clouddn.com"
))
{
url
=
url
.
Replace
(
"http://oyd60abh0.bkt.clouddn.com"
,
"http://img.blsct.com"
);
}
return
url
;
}
/// <summary>
/// 是否支持七牛云
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public
static
bool
IsSupportQiniu
(
string
url
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
url
))
{
return
url
.
Contains
(
"clouddn.com"
)
||
url
.
Contains
(
"img.blsct.com"
);
}
return
false
;
}
#
region
查找文件路径
/// <summary>
/// 查找文件路径
/// </summary>
/// <param name="saveFile"></param>
/// <returns></returns>
public
static
string
CreatePublishListingUrl
(
string
saveFile
)
{
string
url
=
""
;
try
{
url
=
DownloadManager
.
CreatePublishUrl
(
PicServerUrl
,
saveFile
);
}
catch
(
Exception
ex
)
{
string
error
=
ex
.
ToString
();
}
return
url
;
}
#
endregion
}
/// <summary>
/// 七牛云图片格式
/// </summary>
public
class
QiNiuFileInfo
{
[
JsonProperty
(
"size"
)]
public
long
Size
{
get
;
set
;
}
[
JsonProperty
(
"format"
)]
public
string
Format
{
get
;
set
;
}
[
JsonProperty
(
"width"
)]
public
int
Width
{
get
;
set
;
}
[
JsonProperty
(
"height"
)]
public
int
Height
{
get
;
set
;
}
[
JsonProperty
(
"colorModel"
)]
public
string
ColorModel
{
get
;
set
;
}
}
}
AutoTurnOver/appsettings.Development.json
View file @
ba0a3765
...
...
@@ -27,5 +27,11 @@
"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"
:
""
"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"
}
AutoTurnOver/appsettings.Production.json
View file @
ba0a3765
...
...
@@ -27,5 +27,11 @@
"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"
:
""
"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"
}
AutoTurnOver/appsettings.json
View file @
ba0a3765
...
...
@@ -27,5 +27,11 @@
"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"
:
""
"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"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment