Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
Jst.Domain.Lims.Timeliness.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
陶然
Jst.Domain.Lims.Timeliness.V4.5
Commits
dd46fdff
Commit
dd46fdff
authored
Jun 04, 2025
by
Neo Turing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加实验室数据录入及时性统计功能
parent
6932b452
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
234 additions
and
2 deletions
+234
-2
AssemblyInfo.cs
Src/Properties/AssemblyInfo.cs
+2
-2
RestfulTimeliness.cs
Src/RestfulTimeliness.cs
+232
-0
No files found.
Src/Properties/AssemblyInfo.cs
View file @
dd46fdff
...
...
@@ -32,6 +32,6 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2025.
512
0")]
[assembly: AssemblyFileVersion("5.4.2025.
512
0")]
[assembly: AssemblyVersion("5.4.2025.
604
0")]
[assembly: AssemblyFileVersion("5.4.2025.
604
0")]
Src/RestfulTimeliness.cs
View file @
dd46fdff
...
...
@@ -54,6 +54,16 @@ namespace Jst.Lims.Timeliness
public
decimal
NormalQuantity
{
get
;
set
;
}
public
decimal
TimeFilterQuantity
{
get
;
set
;
}
public
decimal
TimeFiltertTimeoutQuantity
{
get
;
set
;
}
public
decimal
FirstDayQuantity
{
get
;
set
;
}
public
List
<
Timeline
>
FirstDayTimelines
{
get
;
set
;
}
public
decimal
SecondDayQuantity
{
get
;
set
;
}
public
List
<
Timeline
>
SecondDayTimelines
{
get
;
set
;
}
public
decimal
ThirdDayQuantity
{
get
;
set
;
}
public
List
<
Timeline
>
ThirdDayTimelines
{
get
;
set
;
}
public
decimal
FourthDayQuantity
{
get
;
set
;
}
public
List
<
Timeline
>
FourthDayTimelines
{
get
;
set
;
}
public
decimal
OtherDayQuantity
{
get
;
set
;
}
public
List
<
Timeline
>
OtherDayTimelines
{
get
;
set
;
}
public
DateTime
?
PlanStartTime
{
get
;
set
;
}
public
DateTime
?
RealStartTime
{
get
;
set
;
}
...
...
@@ -411,6 +421,228 @@ namespace Jst.Lims.Timeliness
}
}
[
Api
(
Description
=
"报告数据录入时效统计"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
TimelineStatisticDataEntry3
:
RestfulExecution
<
TimelineStatistic
>
{
public
List
<
Guid
>
PolicyNodeKvids
{
get
;
set
;
}
/// <summary>
/// 统计的开始日期
/// </summary>
public
DateTime
BeginDate
{
get
;
set
;
}
/// <summary>
/// 统计的结束日期
/// </summary>
public
DateTime
EndDate
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
PolicyNodeKvids
.
ThrowIfNullOrEmpty
(
"请传入组别"
);
int
monthDay
=
DateTime
.
DaysInMonth
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
);
if
(
BeginDate
==
DateTime
.
MinValue
)
BeginDate
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
1
);
if
(
EndDate
==
DateTime
.
MinValue
)
EndDate
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
monthDay
);
BeginDate
=
DateTime
.
Parse
(
BeginDate
.
ToString
(
"yyyy-MM-dd"
));
EndDate
=
DateTime
.
Parse
(
EndDate
.
ToString
(
"yyyy-MM-dd"
));
if
(
EndDate
<
BeginDate
)
throw
new
Exception
(
"查询结束日期不可小于开始日期!"
);
(
EndDate
.
Subtract
(
BeginDate
).
Days
>
31
).
ThrowIfTrue
(
"时间跨度不得大于31天!"
);
var
kvids
=
PolicyNodeKvids
.
OrderBy
(
o
=>
o
).
Join
(
","
);
#
region
启用缓存
,
20
分钟内查询条件相同不重复请求数据库
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
BeginDate
:
G
}
_
{
EndDate
:
G
}
_
{
kvids
}
"
);
var
cacheValue
=
cache
.
Get
<
RestfulQueryResponse
<
TimelineStatistic
>>(
cacheKey
);
if
(
cacheValue
!=
null
)
{
return
cacheValue
;
}
#
endregion
var
rtns
=
new
RestfulQueryResponse
<
TimelineStatistic
>();
rtns
.
Results
=
new
List
<
TimelineStatistic
>();
var
connL
=
KiviiContext
.
GetOpenedDbConnection
<
Report
>();
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Timeline
>();
List
<
ReportItem
>
reportItems
=
null
;
List
<
Report
>
reports
=
null
;
List
<
Timeline
>
timelines
=
null
;
if
(
connL
.
ConnectionString
==
conn
.
ConnectionString
)
//同一个数据库下的情况 用leftjoin联合查询
{
//connL.Close();
connL
=
conn
;
var
queryReport
=
conn
.
From
<
Report
>();
queryReport
.
Where
(
o
=>
o
.
DealDate
>=
BeginDate
&&
o
.
DealDate
<=
EndDate
);
queryReport
.
Select
(
o
=>
new
{
o
.
ReportId
,
o
.
DeadDate
,
o
.
Kvid
,
o
.
DealDate
,
o
.
PreparationDate
,
o
.
IssueDate
,
o
.
ReviewDate
,
o
.
UrgentRate
,
o
.
CreateTime
});
reports
=
conn
.
Select
(
queryReport
);
if
(
reports
.
IsNullOrEmpty
())
return
rtns
;
//根据条件查出所有报告的Kvid
var
queryReportKvid
=
conn
.
From
<
Report
>();
queryReportKvid
.
Where
(
o
=>
o
.
DealDate
>=
BeginDate
&&
o
.
DealDate
<=
EndDate
);
queryReportKvid
.
Select
(
o
=>
o
.
Kvid
);
//一次性查出日期范围内的报告的项目
var
queryReportItem
=
conn
.
From
<
ReportItem
>();
queryReportItem
.
Select
(
o
=>
new
{
o
.
ReportKvid
,
o
.
WorkGroupName
,
o
.
Status
,
o
.
Type
});
queryReportItem
.
Where
(
o
=>
Sql
.
In
(
o
.
ReportKvid
,
queryReportKvid
));
reportItems
=
conn
.
Select
(
queryReportItem
);
reportItems
=
reportItems
.
filterReportItem
();
var
queryBizKvid
=
conn
.
From
<
Report
>();
queryBizKvid
.
Where
(
o
=>
o
.
DealDate
>=
BeginDate
&&
o
.
DealDate
<=
EndDate
);
queryBizKvid
.
Select
(
o
=>
o
.
Kvid
);
var
queryTimeline
=
conn
.
From
<
Timeline
>();
if
(
PolicyNodeKvids
.
IsNullOrEmpty
())
queryTimeline
.
And
<
Timeline
>(
o
=>
o
.
PreKvid
==
Guid
.
Empty
&&
o
.
RootKvid
==
o
.
Kvid
);
//不指定节点,就查根节点
else
queryTimeline
.
And
<
Timeline
>(
o
=>
Sql
.
In
(
o
.
PolicyNodeKvid
,
PolicyNodeKvids
)
&&
o
.
PreKvid
!=
Guid
.
Empty
);
//指定节点,不能包含根节点
queryTimeline
.
And
(
o
=>
Sql
.
In
(
o
.
BizKvid
,
queryBizKvid
));
queryTimeline
.
Select
(
o
=>
new
{
o
.
BizId
,
o
.
BizKvid
,
o
.
BizType
,
o
.
OperatorName
,
o
.
OperatorKvid
,
o
.
OwnerKvid
,
o
.
OwnerName
,
o
.
Title
,
o
.
RealFinishTime
,
o
.
RealStartTime
,
o
.
PlanFinishTime
,
o
.
PlanStartTime
,
o
.
RootKvid
,
o
.
ParentKvid
,
o
.
Kvid
,
o
.
Type
,
o
.
Summary
});
timelines
=
conn
.
Select
(
queryTimeline
);
if
(
timelines
.
IsNullOrEmpty
())
return
rtns
;
}
List
<
Report
>
results
=
new
List
<
Report
>();
if
(
reportItems
.
IsNullOrEmpty
())
return
rtns
;
var
groupReportItem
=
reportItems
.
GroupBy
(
o
=>
o
.
WorkGroupName
);
foreach
(
var
kv
in
groupReportItem
)
{
var
repItems
=
kv
.
ToList
();
var
repKvids
=
repItems
.
ConvertAll
(
o
=>
o
.
ReportKvid
).
Distinct
().
ToList
();
var
currentReports
=
reports
.
Where
(
o
=>
repKvids
.
Contains
(
o
.
Kvid
)).
ToList
();
foreach
(
var
item
in
currentReports
)
{
var
reportGp
=
new
Report
();
reportGp
.
PopulateWith
(
item
);
reportGp
.
DealDate
=
DateTime
.
Parse
(
item
.
DealDate
.
Value
.
ToString
(
"yyyy-MM-dd"
));
reportGp
.
Category
=
kv
.
Key
;
results
.
Add
(
reportGp
);
}
}
var
titles
=
timelines
.
ConvertAll
(
x
=>
x
.
Title
).
Distinct
().
ToList
();
var
group
=
results
.
GroupBy
(
o
=>
new
{
o
.
DealDate
,
o
.
Category
});
foreach
(
var
kv
in
group
)
{
DateTime
?
filterTime
=
DateTime
.
Parse
(
kv
.
Key
.
DealDate
.
Value
.
ToString
(
"yyyy-MM-dd 14:00:00"
));
var
currentReports
=
kv
.
ToList
();
var
reportKvids
=
currentReports
.
ConvertAll
(
o
=>
o
.
Kvid
);
var
currtReportItems
=
reportItems
.
Where
(
o
=>
o
.
WorkGroupName
==
kv
.
Key
.
Category
).
ToList
();
//根据检验组分组统计
var
reportCount
=
currtReportItems
.
ConvertAll
(
o
=>
o
.
ReportKvid
).
Where
(
o
=>
reportKvids
.
Contains
(
o
)).
Distinct
().
Count
();
var
reportkvids
=
currtReportItems
.
ConvertAll
(
o
=>
o
.
ReportKvid
).
Where
(
o
=>
reportKvids
.
Contains
(
o
)).
Distinct
().
ToList
();
var
currentTimelines
=
timelines
.
Where
(
o
=>
Sql
.
In
(
o
.
BizKvid
,
reportKvids
)
&&
o
.
Title
==
kv
.
Key
.
Category
).
ToList
();
var
total
=
new
TimelineStatistic
();
total
.
ReportDealDate
=
kv
.
Key
.
DealDate
;
total
.
Title
=
kv
.
Key
.
Category
;
total
.
ReportTotalQuantity
=
currentReports
.
Count
();
total
.
Quantity
=
currentTimelines
.
IsNullOrEmpty
()
?
0
:
currentTimelines
.
Count
();
total
.
TimeFilter
=
TimeFilter
.
TwoPM
;
total
.
Details
=
new
List
<
TimelineStatistic
>();
total
.
Reports
=
new
List
<
Report
>();
total
.
Timelines
=
new
List
<
Timeline
>();
total
.
TimelineTimeouts
=
new
List
<
Timeline
>();
total
.
FirstDayTimelines
=
new
List
<
Timeline
>();
total
.
SecondDayTimelines
=
new
List
<
Timeline
>();
total
.
ThirdDayTimelines
=
new
List
<
Timeline
>();
total
.
FourthDayTimelines
=
new
List
<
Timeline
>();
total
.
OtherDayTimelines
=
new
List
<
Timeline
>();
total
.
ReportNoTimelines
=
new
List
<
Report
>();
if
(
currentTimelines
.
IsNullOrEmpty
())
{
total
.
ReportNoTimelines
.
AddRange
(
currentReports
);
}
else
{
foreach
(
var
report
in
kv
)
{
var
item
=
currentTimelines
.
FirstOrDefault
(
o
=>
o
.
BizKvid
==
report
.
Kvid
&&
o
.
Title
==
report
.
Category
);
if
(
item
==
null
)
{
total
.
ReportNoTimelines
.
Add
(
report
);
}
else
{
total
.
Reports
.
Add
(
report
);
var
reportDealDate
=
report
.
DealDate
.
Value
.
AddDays
(
1
).
AddSeconds
(-
1
);
var
realFinishTime
=
item
.
RealFinishTime
;
if
(
realFinishTime
==
null
)
realFinishTime
=
DateTime
.
Now
;
if
(
realFinishTime
<=
reportDealDate
)
{
total
.
FirstDayQuantity
++;
total
.
FirstDayTimelines
.
Add
(
item
);
}
else
if
(
realFinishTime
<=
reportDealDate
.
AddDays
(
1
))
{
total
.
SecondDayQuantity
++;
total
.
SecondDayTimelines
.
Add
(
item
);
}
else
if
(
realFinishTime
<=
reportDealDate
.
AddDays
(
2
))
{
total
.
ThirdDayQuantity
++;
total
.
ThirdDayTimelines
.
Add
(
item
);
}
else
if
(
realFinishTime
<=
reportDealDate
.
AddDays
(
3
))
{
total
.
FourthDayQuantity
++;
total
.
FourthDayTimelines
.
Add
(
item
);
}
else
{
total
.
OtherDayQuantity
++;
total
.
OtherDayTimelines
.
Add
(
item
);
}
if
(
filterTime
==
null
)
{
if
(
item
.
PlanFinishTime
!=
reportDealDate
)
item
.
PlanFinishTime
=
reportDealDate
;
if
(
item
.
PlanFinishTime
!=
null
&&
realFinishTime
>
item
.
PlanFinishTime
)
total
.
TimelineTimeouts
.
Add
(
item
);
else
total
.
Timelines
.
Add
(
item
);
}
else
{
if
(
realFinishTime
<=
filterTime
)
total
.
Timelines
.
Add
(
item
);
else
total
.
TimelineTimeouts
.
Add
(
item
);
}
}
}
}
total
.
ReportQuantity
=
total
.
Reports
.
Count
;
total
.
TimelinesQuantity
=
total
.
Timelines
.
Count
;
total
.
TimelineTimeoutsQuantity
=
total
.
TimelineTimeouts
.
Count
;
total
.
ReportNoTimelinesQuantity
=
total
.
ReportNoTimelines
.
Count
;
if
(
titles
.
Contains
(
total
.
Title
))
rtns
.
Results
.
Add
(
total
);
}
//按照指定顺序排序
foreach
(
var
rtn
in
rtns
.
Results
)
{
if
(
rtn
.
Title
==
"安全组"
)
rtn
.
SortId
=
1
;
else
if
(
rtn
.
Title
==
"纤维含量组"
)
rtn
.
SortId
=
2
;
else
if
(
rtn
.
Title
==
"微生物组"
)
rtn
.
SortId
=
3
;
else
if
(
rtn
.
Title
==
"物理组"
)
rtn
.
SortId
=
4
;
else
if
(
rtn
.
Title
==
"色牢度组"
)
rtn
.
SortId
=
5
;
else
if
(
rtn
.
Title
==
"开样组"
)
rtn
.
SortId
=
6
;
else
if
(
rtn
.
Title
==
"功能组"
)
rtn
.
SortId
=
7
;
else
if
(
rtn
.
Title
==
"轻工组"
)
rtn
.
SortId
=
8
;
else
if
(
rtn
.
Title
==
"纤检组"
)
rtn
.
SortId
=
9
;
else
if
(
rtn
.
Title
==
"羽绒组"
)
rtn
.
SortId
=
10
;
else
rtn
.
SortId
=
99
;
}
rtns
.
Results
=
rtns
.
Results
.
OrderBy
(
o
=>
o
.
SortId
).
ThenBy
(
o
=>
o
.
ReportDealDate
).
ToList
();
rtns
.
Total
=
rtns
.
Results
.
Count
;
cache
.
Set
(
cacheKey
,
rtns
,
TimeSpan
.
FromMinutes
(
20
));
return
rtns
;
}
}
[
Api
(
Description
=
"报告数据录入时效统计"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
TimelineStatisticDataEntry
:
RestfulExecution
<
TimelineStatistic
>
...
...
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