Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Third.OnlineCustomization.V4.5
Project
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
陶然
Kivii.Third.OnlineCustomization.V4.5
Commits
1f9603c7
Commit
1f9603c7
authored
May 26, 2025
by
Neo Turing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
c2e7b548
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
17 deletions
+139
-17
Configs.cs
Src/Configs.cs
+1
-1
OrderExtension.cs
Src/Extensions/OrderExtension.cs
+0
-16
OrderJob.cs
Src/Jobs/OrderJob.cs
+137
-0
Kivii.Third.OnlineCustomization.V4.5.csproj
Src/Kivii.Third.OnlineCustomization.V4.5.csproj
+1
-0
No files found.
Src/Configs.cs
View file @
1f9603c7
...
...
@@ -9,7 +9,7 @@ namespace Kivii.OnlineCustomization
{
internal
static
class
Configs
{
public
const
string
_pdfUrl
=
"http://
bjhyfi.lims.kivii.org
"
;
public
const
string
_pdfUrl
=
"http://
k5.jst-gov.com
"
;
//正式环境
public
const
string
_defaultUrl
=
"http://jstonline.kivii.org"
;
...
...
Src/Extensions/OrderExtension.cs
View file @
1f9603c7
...
...
@@ -88,17 +88,6 @@ namespace Kivii.OnlineCustomization.Extensions
(
appsecret
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"UploadOrderPdf:请传入appsecret"
);
orderNo
.
ThrowIfNullOrEmpty
(
"请传入订单号"
);
pdfUrls
.
ThrowIfNullOrEmpty
(
"UploadOrderPdf:请传入回传内容"
);
//var timeStamp = GetTimeStamp();
//var appSign = $"apptoken={apptoken}&appsecret={appsecret}×tamp={timeStamp}";
//var signature = GetSign(appSign);
//var jsons = JsonSerializer.SerializeToString(orderPdfs);
//var body = new Dictionary<string, string>();
//body.Add("DATA", jsons);
//body.Add("ORDER_NO", orderNo);
//var paramsString = $"?appToken={apptoken}&signature={signature}×tamp={timeStamp}";
//Console.WriteLine($"-------PrePost:UploadOrderPdf:{JsonSerializer.SerializeToString(body)}\n");
var
request
=
new
OnlineOrderUploadResults
();
request
.
PdfUrls
=
new
List
<
string
>();
request
.
PdfUrls
.
AddRange
(
pdfUrls
);
...
...
@@ -146,10 +135,6 @@ namespace Kivii.OnlineCustomization.Extensions
third
.
ManufacturerName
=
item
.
BuyerCompony
;
third
.
ManufacturerContactName
=
item
.
BuyerName
;
//third.SampleName = item.MAT_NAME;
//third.BatchNumber = item.PRD_CODE;
//third.Brand = item.BRAND_DISPLAY;
//thirdReportOrder.Content = JsonSerializer.SerializeToString(item);
third
.
Metadata
=
new
Dictionary
<
string
,
string
>();
foreach
(
var
propertyInfo
in
item
.
GetType
().
GetProperties
())
{
...
...
@@ -364,6 +349,5 @@ namespace Kivii.OnlineCustomization.Extensions
}
return
md
;
}
}
}
Src/Jobs/OrderJob.cs
0 → 100644
View file @
1f9603c7
using
Kivii.Lims
;
using
Kivii.Lims.Entities
;
using
Kivii.Linq
;
using
Kivii.OnlineCustomization.Entities
;
using
Kivii.OnlineCustomization.Extensions
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Kivii.OnlineCustomization.Jobs
{
public
class
OrderPullJob
:
IJob
{
public
string
Name
=>
"拉取订单"
;
public
string
Description
=>
"拉取订单"
;
public
IJobContext
TaskContext
{
get
;
set
;
}
public
bool
Execution
()
{
#
region
设置缓存
1
分钟内不能连续请求
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
typeof
(
OnlineOrder
).
FullName
}
.PullOrder:LockedOneMinute"
);
var
cacheValue
=
cache
.
Get
<
string
>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
cacheValue
);
}
#
endregion
var
baseUrl
=
TaskContext
.
Arguments
[
"BaseUrl"
];
if
(
baseUrl
.
IsNullOrEmpty
())
baseUrl
=
Configs
.
_defaultUrl
;
var
token
=
TaskContext
.
Arguments
[
"Token"
];
if
(
token
.
IsNullOrEmpty
())
token
=
Configs
.
_token
;
var
secret
=
TaskContext
.
Arguments
[
"Secret"
];
if
(
secret
.
IsNullOrEmpty
())
secret
=
Configs
.
_secret
;
var
length
=
TaskContext
.
Arguments
.
ContainsKey
(
"Length"
)
?
TaskContext
.
Arguments
[
"Length"
].
ToInt
()
:
200
;
var
ownerKvidstr
=
TaskContext
.
Arguments
[
"OwnerKvid"
];
var
ownerKvid
=
Guid
.
Empty
;
if
(!
ownerKvidstr
.
IsNullOrEmpty
())
Guid
.
TryParse
(
ownerKvidstr
,
out
ownerKvid
);
var
ownerName
=
TaskContext
.
Arguments
[
"OwnerName"
];
var
opTime
=
TaskContext
.
Arguments
[
"BeginTime"
];
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
ThirdReportOrder
>();
DateTime
maxTranslateTime
=
conn
.
Scalar
<
ThirdReportOrder
,
DateTime
>(
o
=>
Sql
.
Max
(
o
.
OperateTime
),
p
=>
p
.
ThirdType
==
typeof
(
OnlineOrder
).
FullName
);
if
(
maxTranslateTime
==
null
||
maxTranslateTime
==
DateTime
.
MinValue
)
{
DateTime
.
TryParse
(
opTime
,
out
maxTranslateTime
);
}
var
client
=
new
JsonHttpClient
(
baseUrl
);
try
{
var
response
=
client
.
PullOrders
(
token
,
secret
,
maxTranslateTime
);
cache
.
Set
(
cacheKey
,
"一分钟内不可多次查询!"
,
TimeSpan
.
FromMinutes
(
1
));
if
(
response
==
null
)
{
TaskContext
.
Message
=
$"response空,服务器无响应!"
;
return
false
;
}
if
(
response
.
Results
.
IsNullOrEmpty
())
{
TaskContext
.
Message
=
$"未获取到
{
maxTranslateTime
:
yyyy
-
MM
-
dd
}
以后的新数据!"
;
return
true
;
}
var
results
=
response
.
Results
.
AcceptThirdContractOrder
(
ownerKvid
,
ownerName
,
conn
);
TaskContext
.
Message
=
$"新增
{
results
.
Count
}
条!"
;
return
true
;
}
catch
(
Exception
ex
)
{
TaskContext
.
Message
=
$"错误:
{
ex
.
Message
}
"
;
return
false
;
}
finally
{
var
thread
=
KiviiContext
.
NewThread
(()
=>
{
//没有关联报告的 自动执行符合条件的关联
OrderExtension
.
LinkReports
();
});
thread
.
Start
();
}
}
public
void
Dispose
()
{
}
}
public
class
OrderUploadJob
:
IJob
{
public
string
Name
=>
"上传订单"
;
public
string
Description
=>
"上传订单"
;
public
IJobContext
TaskContext
{
get
;
set
;
}
public
bool
Execution
()
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
ThirdReportOrder
>();
try
{
var
pbs
=
conn
.
Select
<
ThirdReportOrder
>(
o
=>
o
.
ThirdType
==
typeof
(
OnlineOrder
).
FullName
&
o
.
IsUploaded
==
false
&
o
.
IsAccepted
==
true
);
if
(
pbs
.
IsNullOrEmpty
())
{
TaskContext
.
Message
=
"暂无数据处理"
;
return
true
;
}
var
pbKvids
=
pbs
.
ConvertAll
(
o
=>
o
.
Kvid
);
var
instance
=
Activator
.
CreateInstance
(
typeof
(
OnlineOrder
))
as
IEntityIsThirdReportOrder
;
var
successed
=
0
;
var
skip
=
0
;
foreach
(
var
kvid
in
pbKvids
)
{
var
result
=
instance
.
OnUploadThirdReport
(
kvid
);
if
(
result
)
successed
++;
else
skip
++;
}
TaskContext
.
Message
=
$"合计待回传订单:
{
pbKvids
.
Count
}
条,成功回传:
{
successed
}
条,跳过
{
skip
}
条。"
;
return
true
;
}
catch
(
Exception
ex
)
{
TaskContext
.
Message
=
$"错误:
{
ex
.
Message
}
"
;
throw
;
}
}
public
void
Dispose
()
{
}
}
}
Src/Kivii.Third.OnlineCustomization.V4.5.csproj
View file @
1f9603c7
...
...
@@ -53,6 +53,7 @@
<Compile
Include=
"Configs.cs"
/>
<Compile
Include=
"Entities\OnlineOrder.cs"
/>
<Compile
Include=
"Extensions\OrderExtension.cs"
/>
<Compile
Include=
"Jobs\OrderJob.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Requests\OrderRequest.cs"
/>
</ItemGroup>
...
...
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