Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
patzn-cloud-service-hmhj
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
wangweidong
patzn-cloud-service-hmhj
Commits
a21efce1
Commit
a21efce1
authored
Jun 24, 2024
by
jiangxuming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加日志并优化速度
parent
ac589cb9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
26 deletions
+85
-26
IOriginalRecordService.java
...oud/service/lims/hmhj/service/IOriginalRecordService.java
+2
-1
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+55
-24
OriginalRecordServiceImpl.java
...ice/lims/hmhj/service/impl/OriginalRecordServiceImpl.java
+16
-1
EntrustSampleItemMapper.xml
src/main/resources/mapper/hmhj/EntrustSampleItemMapper.xml
+12
-0
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IOriginalRecordService.java
View file @
a21efce1
...
...
@@ -3,6 +3,7 @@ package com.patzn.cloud.service.lims.hmhj.service;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.patzn.cloud.commons.controller.Account
;
import
com.patzn.cloud.commons.service.IBaseService
;
import
com.patzn.cloud.commons.toolkit.TimeWatch
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.OriginalRecord
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
...
...
@@ -25,7 +26,7 @@ public interface IOriginalRecordService extends IBaseService<OriginalRecord> {
boolean
removeByIds
(
List
<
Long
>
ids
);
OriginalRecord
uploadExpGenerate
(
Long
[]
ids
,
OriginalTemplate
template
,
Entrust
entrust
,
Account
account
,
String
remark
,
File
file
);
OriginalRecord
uploadExpGenerate
(
Long
[]
ids
,
OriginalTemplate
template
,
Entrust
entrust
,
Account
account
,
String
remark
,
File
file
,
TimeWatch
timeWatch
);
OriginalRecord
uploadExpGenerate
(
Map
<
Long
,
List
<
Long
>>
entrustItemIdMap
,
OriginalTemplate
template
,
Account
account
,
String
remark
,
File
file
);
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
a21efce1
...
...
@@ -320,18 +320,19 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
submitTest
(
Long
[]
ids
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交的检测项目"
);
TimeWatch
timeWatch
=
new
TimeWatch
();
logger
.
info
(
"1数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
List
<
EntrustSampleItem
>
list
=
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
// 获取样品信息
EntrustSample
entrustSample
=
entrustSampleService
.
getById
(
list
.
get
(
0
).
getEntrustSampleId
());
RestAssert
.
fail
(
null
==
entrustSample
,
"样品信息不能为空"
);
logger
.
info
(
"2数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 获取委托编号
long
entrustId
=
entrustSample
.
getEntrustId
();
// 判断提交的检测项目是否完成检测
List
<
EntrustSampleItemVO
>
unfinishItemList
=
baseMapper
.
selectUnfinishItemList
(
new
QueryDTO
().
setEntrustId
(
entrustId
).
setIds
(
ids
));
List
<
EntrustSampleItemVO
>
unfinishItemList
=
baseMapper
.
selectUnfinishItemList
(
new
QueryDTO
().
setEntrustId
(
entrustId
).
setIds
(
ids
));
//todo 性能优化
logger
.
info
(
"3数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
if
(
CollectionUtils
.
isNotEmpty
(
unfinishItemList
))
{
EntrustSampleItemVO
vo
=
unfinishItemList
.
get
(
0
);
RestAssert
.
fail
(
String
.
format
(
"样品编号【%s】的检测项目【%s】未填写检测值,无法提交!"
,
vo
.
getSampleCode
(),
vo
.
getName
()));
...
...
@@ -345,17 +346,17 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
super
.
update
(
sampleItem
,
Condition
.
create
().
in
(
"id"
,
ids
));
entrustSampleItemRecordService
.
record
(
ids
,
EntrustSampleItemStatusEnum
.
TEST
.
getDisplay
(),
EntrustSampleItemStatusEnum
.
END
.
getDisplay
(),
0
,
"数据录入提交"
,
account
);
logger
.
info
(
"4数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 若存在委托下没有完成的检测项目,那么直接返回
unfinishItemList
=
baseMapper
.
selectUnfinishItemList
(
new
QueryDTO
().
setEntrustId
(
entrustId
).
setNonIds
(
ids
));
unfinishItemList
=
baseMapper
.
selectUnfinishItemList
(
new
QueryDTO
().
setEntrustId
(
entrustId
).
setNonIds
(
ids
));
//todo 性能优化
logger
.
info
(
"5数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
if
(
CollectionUtils
.
isNotEmpty
(
unfinishItemList
))
{
return
true
;
}
unfinishItemList
=
baseMapper
.
selectByEntrustId
(
entrustId
);
unfinishItemList
=
unfinishItemList
.
stream
().
filter
(
t
->
!
Arrays
.
asList
(
ids
).
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
logger
.
info
(
"6数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 存在未完成的检测项目,则返回
if
(
CollectionUtils
.
isNotEmpty
(
unfinishItemList
)
&&
unfinishItemList
.
stream
().
anyMatch
(
t
->
t
.
getStatus
()
!=
EntrustSampleItemStatusEnum
.
END
))
{
return
true
;
...
...
@@ -380,6 +381,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
// 提交为报告编制
EntrustSample
sample
=
new
EntrustSample
().
setStatus
(
EntrustSampleStatusEnum
.
REPORT_MAKE
).
setLid
(
account
.
getUserId
()).
setLtime
(
new
Date
());
entrustSampleService
.
update
(
sample
,
Condition
.
create
().
eq
(
"entrust_id"
,
entrustId
));
logger
.
info
(
"7数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 委托信息
Entrust
entrust
=
entrustService
.
getById
(
entrustId
);
// 提交到下一节点,可能是不更改状态
...
...
@@ -394,22 +396,25 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
executor1
.
execute
(()
->
updateSampleRetakeByEntrustId
(
entrustId
));
return
true
;
}
logger
.
info
(
"8数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 修改委托信息
entrust
.
setLid
(
account
.
getUserId
()).
setLtime
(
new
Date
()).
setFlowStatus
(
EntrustFlowEnum
.
REPORT_MAKE
.
getName
()).
setProgress
(
EntrustStatusEnum
.
TEST
).
setStatus
(
EntrustStatusEnum
.
TEST
);
entrustService
.
updateById
(
entrust
);
logger
.
info
(
"9数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 提交后执行组合判定
updateItemComposeJudgeByEntrustId
(
entrustId
);
logger
.
info
(
"10数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
updateComposeJudgeByTestValue
(
entrustId
);
logger
.
info
(
"11数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 添加委托日志
entrustRecordService
.
record
(
new
Long
[]{
entrustId
},
"数据录入"
,
"报告编制"
,
0
,
account
,
"提交至报告编制"
);
logger
.
info
(
"12数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 执行转PDF操作
executor1
.
execute
(()
->
changeExcelToPdf
(
ids
,
list
));
logger
.
info
(
"13数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
// 处理原铝是否重取
executor1
.
execute
(()
->
updateSampleRetakeByEntrustId
(
entrustId
));
logger
.
info
(
"13数据录入提交阶段耗时: {}"
,
timeWatch
.
pointTime
());
return
true
;
}
...
...
@@ -661,7 +666,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
/* 获取采集数据,并保存到SampleVO中 */
getCollectionData
(
null
,
sampleVOList
,
itemNameMap
,
template
,
entrustCodes
);
getCollectionData
(
null
,
null
,
sampleVOList
,
itemNameMap
,
template
,
entrustCodes
);
if
(
null
==
template
.
getSampleBeginRow
()
||
null
==
template
.
getSampleMergerNum
()
||
null
==
template
.
getTemplateSampleNum
())
{
return
null
;
...
...
@@ -672,7 +677,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
else
{
/* 获取采集到的数据 */
getCollectionData
(
voList
,
null
,
itemNameMap
,
template
,
entrustCodes
);
getCollectionData
(
null
,
voList
,
null
,
itemNameMap
,
template
,
entrustCodes
);
EntrustSampleItemVO
firstVO
=
null
;
for
(
EntrustSampleItemVO
vo
:
voList
)
{
...
...
@@ -723,6 +728,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Override
public
OriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
,
String
entrustCode
)
{
TimeWatch
timeWatch
=
new
TimeWatch
();
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择试验项目!"
);
RestAssert
.
fail
(
null
==
templateId
,
"请选择原始记录模板"
);
OriginalTemplate
template
=
originalTemplateService
.
getById
(
templateId
);
...
...
@@ -733,6 +739,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
if
(
CollectionUtils
.
isEmpty
(
voList
))
{
return
null
;
}
logger
.
info
(
"一阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
// 过滤空白样
List
<
EntrustSampleItemVO
>
blank
=
voList
.
stream
().
filter
(
vo
->
vo
.
getSampleCode
().
contains
(
"空白"
)
||
vo
.
getSampleName
().
contains
(
"空白"
)).
collect
(
Collectors
.
toList
());
// 手动插入空白样和配置了空白开始行冲突
...
...
@@ -741,11 +748,15 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
voList
=
voList
.
stream
().
sorted
(
Comparator
.
comparing
(
EntrustSampleItemVO:
:
getOrderBy
)).
collect
(
Collectors
.
toList
());
Entrust
entrust
=
entrustService
.
getById
(
voList
.
get
(
0
).
getEntrustId
());
logger
.
info
(
"二阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
InputStream
io
=
ossClient
.
download
(
template
.
getObjectKey
());
logger
.
info
(
"3阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
if
(
null
==
io
)
{
RestAssert
.
fail
(
"模板不存在"
);
}
List
<
OriginalTemplateConfig
>
configList
=
originalTemplateConfigService
.
list
(
Condition
.
create
().
eq
(
"template_id"
,
templateId
));
logger
.
info
(
"4阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
OriginalRecord
objectKey
=
null
;
XSSFWorkbook
xssfWorkbook
=
null
;
...
...
@@ -759,6 +770,8 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
Map
<
String
,
String
>
mapReplace
=
new
HashMap
<>();
mapReplace
.
put
(
"#{nowDate}"
,
DateUtils
.
toYearMonthDay
(
new
Date
()));
mapReplace
.
put
(
"#{sampleNum}"
,
entrustSampleService
.
countByEntrustId
(
entrust
.
getId
())
+
""
);
logger
.
info
(
"5阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
// itemVoList中的所有项目名 --> 通过检测项目名拿到对应的采集仪器项目名
Set
<
String
>
itemNames
=
voList
.
stream
().
map
(
EntrustSampleItem:
:
getName
).
distinct
().
collect
(
Collectors
.
toSet
());
...
...
@@ -766,13 +779,17 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
Map
<
String
,
String
>
itemNameMap
=
qualifications
.
stream
()
.
filter
(
q
->
StringUtils
.
isNotEmpty
(
q
.
getInstrumentItemName
()))
.
collect
(
Collectors
.
toMap
(
Qualification:
:
getName
,
Qualification:
:
getInstrumentItemName
));
logger
.
info
(
"6阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
logger
.
info
(
"template.getTabletAnalysis():{}"
,
template
.
getTabletAnalysis
());
logger
.
info
(
"ttemplate.getMoreItem():{}"
,
template
.
getMoreItem
());
// 若为压片分析
if
(
Objects
.
equals
(
template
.
getTabletAnalysis
(),
1
))
{
logger
.
info
(
"条件1"
);
// 压片分析单独处理
/* 获取采集到的数据 */
getCollectionData
(
voList
,
null
,
itemNameMap
,
template
,
entrustCode
);
getCollectionData
(
null
,
voList
,
null
,
itemNameMap
,
template
,
entrustCode
);
EntrustSampleItemVO
firstVO
=
null
;
for
(
EntrustSampleItemVO
vo
:
voList
)
{
...
...
@@ -790,11 +807,14 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
operation
.
doMakeOriginal
();
}
else
if
(
null
!=
template
.
getMoreItem
()
&&
1
==
template
.
getMoreItem
())
{
logger
.
info
(
"条件2"
);
logger
.
info
(
"7-1阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
Set
<
Long
>
sampleIdsList
=
new
HashSet
<>();
for
(
EntrustSampleItemVO
itemVO
:
voList
)
{
sampleIdsList
.
add
(
itemVO
.
getEntrustSampleId
());
}
List
<
EntrustSample
>
sampleList
=
entrustSampleService
.
list
(
Condition
.
create
().
in
(
"id"
,
sampleIdsList
).
orderBy
(
"order_by"
,
true
));
logger
.
info
(
"7-2阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
EntrustSample
firstSample
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
sampleList
))
{
for
(
EntrustSample
sample
:
sampleList
)
{
...
...
@@ -810,16 +830,17 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
List
<
EntrustSampleVO
>
sampleVOList
=
new
ArrayList
<>(
sampleList
.
size
());
// 优化:批量获取检测项目指标
List
<
EntrustSampleItemIndexVO
>
itemIndexList
=
entrustSampleItemIndexService
.
listVOBySampleIds
(
new
ArrayList
<>(
sampleIdsList
));
logger
.
info
(
"7-3阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
for
(
EntrustSample
sample
:
sampleList
)
{
EntrustSampleVO
vo
=
sample
.
convert
(
EntrustSampleVO
.
class
);
// 取值时,直接过滤获取
vo
.
setIndexList
(
getIndicesBySampleId
(
sample
.
getId
(),
itemIndexList
));
sampleVOList
.
add
(
vo
);
}
logger
.
info
(
"7-4阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
/* 获取采集数据,并保存到SampleVO中 */
getCollectionData
(
null
,
sampleVOList
,
itemNameMap
,
template
,
entrustCode
);
getCollectionData
(
timeWatch
,
null
,
sampleVOList
,
itemNameMap
,
template
,
entrustCode
);
logger
.
info
(
"7-5阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
if
(
null
==
template
.
getSampleBeginRow
()
||
null
==
template
.
getSampleMergerNum
()
||
null
==
template
.
getTemplateSampleNum
())
{
return
null
;
}
...
...
@@ -832,12 +853,13 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
// moreItemOperation.doMakeOriginal();
/* 多个检测项目放在一个sheet中,一个样品一条记录 */
SingleSheetMoreItemOperation
operation
=
new
SingleSheetMoreItemOperation
(
template
,
entrust
,
null
,
sampleVOList
,
configList
,
xssfWorkbook
);
operation
.
doMakeOriginal
();
operation
.
doMakeOriginal
();
//todo 生成原始记录最耗时代码
logger
.
info
(
"7-6阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
// }
}
else
{
logger
.
info
(
"条件3"
);
/* 获取采集到的数据 */
getCollectionData
(
voList
,
null
,
itemNameMap
,
template
,
entrustCode
);
getCollectionData
(
null
,
voList
,
null
,
itemNameMap
,
template
,
entrustCode
);
EntrustSampleItemVO
firstVO
=
null
;
for
(
EntrustSampleItemVO
vo
:
voList
)
{
...
...
@@ -859,7 +881,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
operation
.
doMakeOriginal
();
}
}
logger
.
info
(
"7阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
0
);
FileOutputStream
os
=
null
;
...
...
@@ -871,7 +893,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
os
=
new
FileOutputStream
(
file
);
xssfWorkbook
.
write
(
os
);
os
.
flush
();
objectKey
=
originalRecordService
.
uploadExpGenerate
(
ids
,
template
,
entrust
,
account
,
"原始记录生成"
,
file
);
objectKey
=
originalRecordService
.
uploadExpGenerate
(
ids
,
template
,
entrust
,
account
,
"原始记录生成"
,
file
,
timeWatch
);
logger
.
error
(
"----------------------17"
);
}
catch
(
Exception
e
)
{
...
...
@@ -883,10 +905,15 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
logger
.
error
(
"----------------------20"
);
logger
.
info
(
"8阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
logger
.
info
(
"总阶段耗时:{} ms"
,
timeWatch
.
getTotal
(
timeWatch
.
printTime
()));
return
objectKey
;
}
private
void
getCollectionData
(
List
<
EntrustSampleItemVO
>
itemVOList
,
List
<
EntrustSampleVO
>
sampleVOList
,
Map
<
String
,
String
>
itemNameMap
,
OriginalTemplate
template
,
String
...
entrustCodes
)
{
private
void
getCollectionData
(
TimeWatch
timeWatch
,
List
<
EntrustSampleItemVO
>
itemVOList
,
List
<
EntrustSampleVO
>
sampleVOList
,
Map
<
String
,
String
>
itemNameMap
,
OriginalTemplate
template
,
String
...
entrustCodes
)
{
logger
.
info
(
"7-4-1阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
/* 拿到所有样品的编号 */
Set
<
String
>
numSet
=
new
HashSet
<>();
if
(
itemVOList
!=
null
)
{
...
...
@@ -906,6 +933,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
else
if
(
template
.
getCollectionType
()
==
2
)
{
records
=
originalRecordInfoService
.
list
(
Condition
.
create
().
in
(
"sample_num"
,
numSet
).
orderBy
(
"ctime"
));
}
logger
.
info
(
"7-4-2阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
/* 按照样品编号和项目分开,来存放采集到的数据 record的data */
HashMap
<
String
,
List
<
String
>>
mapByNumItemName
=
new
HashMap
<>();
for
(
LmsOriginalRecordInfo
record
:
records
)
{
...
...
@@ -919,6 +947,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
String
blank
=
"blank"
;
AtomicBoolean
filledCur
=
new
AtomicBoolean
(
false
);
AtomicBoolean
filledBlank
=
new
AtomicBoolean
(
false
);
logger
.
info
(
"7-4-3阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
/* 设置采集数据的Map -- itemVo */
if
(
itemVOList
!=
null
)
{
itemVOList
.
forEach
(
vo
->
{
...
...
@@ -956,6 +985,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
});
}
logger
.
info
(
"7-4-4阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
/* sampleVo */
if
(
sampleVOList
!=
null
)
{
sampleVOList
.
stream
().
forEach
(
vo
->
{
...
...
@@ -969,6 +999,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
});
}
logger
.
info
(
"7-4-5阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
}
public
static
Map
<
String
,
String
>
toStringStringMap
(
String
jsonString
)
{
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/OriginalRecordServiceImpl.java
View file @
a21efce1
...
...
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.toolkit.MapUtils;
import
com.patzn.cloud.commons.api.RestAssert
;
import
com.patzn.cloud.commons.controller.Account
;
import
com.patzn.cloud.commons.service.impl.BaseServiceImpl
;
import
com.patzn.cloud.commons.toolkit.TimeWatch
;
import
com.patzn.cloud.oss.starter.OssClient
;
import
com.patzn.cloud.oss.starter.OssFileResult
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
...
...
@@ -31,6 +32,9 @@ import java.io.File;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -48,6 +52,8 @@ public class OriginalRecordServiceImpl extends BaseServiceImpl<OriginalRecordMap
@Autowired
private
OssClient
ossClient
;
private
static
final
ThreadPoolExecutor
pool
=
new
ThreadPoolExecutor
(
8
,
20
,
10
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingQueue
<>(
5000
));
@Override
public
Page
<
OriginalRecord
>
page
(
Page
<
OriginalRecord
>
page
,
OriginalRecord
originalRecord
)
{
...
...
@@ -97,7 +103,7 @@ public class OriginalRecordServiceImpl extends BaseServiceImpl<OriginalRecordMap
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
OriginalRecord
uploadExpGenerate
(
Long
[]
ids
,
OriginalTemplate
template
,
Entrust
entrust
,
Account
account
,
String
remark
,
File
file
)
{
public
OriginalRecord
uploadExpGenerate
(
Long
[]
ids
,
OriginalTemplate
template
,
Entrust
entrust
,
Account
account
,
String
remark
,
File
file
,
TimeWatch
timeWatch
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择试验项目"
);
RestAssert
.
fail
(
null
==
entrust
.
getId
(),
"试验委托单ID不能为空"
);
...
...
@@ -113,7 +119,9 @@ public class OriginalRecordServiceImpl extends BaseServiceImpl<OriginalRecordMap
return
null
;
}
originalRecord
.
setObjectKey
(
obsFileResult
.
getObjectKey
());
logger
.
info
(
"7-1阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
if
(
save
(
originalRecord
))
{
logger
.
info
(
"7-2阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
List
<
ItemRelOriginalRecord
>
saveList
=
new
ArrayList
<>();
for
(
Long
id
:
ids
)
{
ItemRelOriginalRecord
relOriginalRecord
=
new
ItemRelOriginalRecord
();
...
...
@@ -121,10 +129,17 @@ public class OriginalRecordServiceImpl extends BaseServiceImpl<OriginalRecordMap
relOriginalRecord
.
setRecordId
(
originalRecord
.
getId
());
saveList
.
add
(
relOriginalRecord
);
}
logger
.
info
(
"7-3阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
if
(
CollectionUtils
.
isNotEmpty
(
saveList
))
{
pool
.
execute
(()
->
{
itemRelOriginalRecordService
.
saveBatch
(
saveList
);
});
}
// if (CollectionUtils.isNotEmpty(saveList)) {
// itemRelOriginalRecordService.saveBatch(saveList);
// }
}
logger
.
info
(
"7-4阶段耗时:{} ms"
,
timeWatch
.
pointTime
());
return
originalRecord
;
}
...
...
src/main/resources/mapper/hmhj/EntrustSampleItemMapper.xml
View file @
a21efce1
...
...
@@ -445,6 +445,18 @@
END) then 1 else 0 end) "END_INDEX"
FROM entrust_sample_item_index ii
WHERE ii.deleted = 0
<if
test=
"null != vo.ids"
>
and ii.entrust_sample_item_id in
<foreach
collection=
"vo.ids"
index=
"index"
item=
"itemId"
open=
"("
separator=
","
close=
")"
>
#{itemId}
</foreach>
</if>
<if
test=
"null != vo.nonIds"
>
and ii.entrust_sample_item_id not in
<foreach
collection=
"vo.nonIds"
index=
"index"
item=
"itemId"
open=
"("
separator=
","
close=
")"
>
#{itemId}
</foreach>
</if>
GROUP BY ii.entrust_sample_item_id
) ii on ii.entrust_sample_item_id = i.id
where e.deleted = 0 and s.deleted = 0 and i.deleted = 0 and s.type = 0
...
...
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