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
5b317fb6
Commit
5b317fb6
authored
Jun 12, 2021
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改生成报告错误问题;
parent
276f197b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
340 additions
and
344 deletions
+340
-344
EntrustSampleServiceImpl.java
...vice/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
+340
-344
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
View file @
5b317fb6
...
@@ -44,7 +44,7 @@ import java.util.*;
...
@@ -44,7 +44,7 @@ import java.util.*;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
*
服务实现类
* 服务实现类
*
*
* @author wwd
* @author wwd
* @since 2021-02-01
* @since 2021-02-01
...
@@ -59,6 +59,9 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
...
@@ -59,6 +59,9 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
@Autowired
@Autowired
private
IEntrustReportTemplateService
entrustReportTemplateService
;
private
IEntrustReportTemplateService
entrustReportTemplateService
;
@Autowired
private
IEntrustReportTemplateConfigService
entrustReportTemplateConfigService
;
@Autowired
@Autowired
private
OssClient
ossClient
;
private
OssClient
ossClient
;
...
@@ -93,7 +96,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
...
@@ -93,7 +96,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
}
}
@Override
@Override
public
Page
<
EntrustSample
>
pageByWrapper
(
Page
<
EntrustSample
>
page
,
Wrapper
wrapper
)
{
public
Page
<
EntrustSample
>
pageByWrapper
(
Page
<
EntrustSample
>
page
,
Wrapper
wrapper
)
{
return
this
.
page
(
page
,
wrapper
);
return
this
.
page
(
page
,
wrapper
);
}
}
...
@@ -101,29 +104,29 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
...
@@ -101,29 +104,29 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
@Override
@Override
public
Page
<
EntrustSampleVO
>
pageVO
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
public
Page
<
EntrustSampleVO
>
pageVO
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
entrustSample
));
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
entrustSample
));
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
boolean
submitToAcceptanceResultInput
(
Long
[]
ids
,
Account
account
)
{
public
boolean
submitToAcceptanceResultInput
(
Long
[]
ids
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交到验收结果录入的数据"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交到验收结果录入的数据"
);
if
(
submitJudgeCheck
(
ids
,
account
))
{
if
(
submitJudgeCheck
(
ids
,
account
))
{
List
<
EntrustSample
>
sampleList
=
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
List
<
EntrustSample
>
sampleList
=
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
List
<
Long
>
contractSampleIdList
=
new
ArrayList
<>();
List
<
Long
>
contractSampleIdList
=
new
ArrayList
<>();
for
(
EntrustSample
sample
:
sampleList
)
{
for
(
EntrustSample
sample
:
sampleList
)
{
if
(
null
!=
sample
.
getContractSampleId
())
{
if
(
null
!=
sample
.
getContractSampleId
())
{
contractSampleIdList
.
add
(
sample
.
getContractSampleId
());
contractSampleIdList
.
add
(
sample
.
getContractSampleId
());
}
}
}
}
if
(
CollectionUtils
.
isNotEmpty
(
contractSampleIdList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
contractSampleIdList
))
{
ContractSample
sample
=
new
ContractSample
();
ContractSample
sample
=
new
ContractSample
();
sample
.
setStatus
(
ContractSampleStatusEnum
.
CHECK_RESULT_INPUT
);
sample
.
setStatus
(
ContractSampleStatusEnum
.
CHECK_RESULT_INPUT
);
sample
.
setProgress
(
ContractSampleStatusEnum
.
QUALITY_AUDIT
);
sample
.
setProgress
(
ContractSampleStatusEnum
.
QUALITY_AUDIT
);
contractSampleService
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
contractSampleIdList
));
contractSampleService
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
contractSampleIdList
));
contractSampleRecordService
.
record
(
contractSampleIdList
,
ContractSampleStatusEnum
.
QUALITY_AUDIT
,
ContractSampleStatusEnum
.
CHECK_RESULT_INPUT
,
0
,
"质量审核提交至验收结果录入"
,
account
);
contractSampleRecordService
.
record
(
contractSampleIdList
,
ContractSampleStatusEnum
.
QUALITY_AUDIT
,
ContractSampleStatusEnum
.
CHECK_RESULT_INPUT
,
0
,
"质量审核提交至验收结果录入"
,
account
);
}
}
}
}
return
true
;
return
true
;
}
}
...
@@ -134,60 +137,60 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
...
@@ -134,60 +137,60 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
@Override
@Override
public
List
<
EntrustSampleVO
>
obtainMakeInfo
(
Long
[]
ids
,
Account
account
)
{
public
List
<
EntrustSampleVO
>
obtainMakeInfo
(
Long
[]
ids
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要制备的样品"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要制备的样品"
);
List
<
EntrustSample
>
entrustSamples
=
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
List
<
EntrustSample
>
entrustSamples
=
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
entrustSamples
),
"请选择要制备的样品"
);
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
entrustSamples
),
"请选择要制备的样品"
);
List
<
Long
>
sampleIds
=
entrustSamples
.
stream
().
map
(
s
->
{
List
<
Long
>
sampleIds
=
entrustSamples
.
stream
().
map
(
s
->
{
return
s
.
getId
();
return
s
.
getId
();
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
in
(
"entrust_sample_id"
,
ids
));
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
in
(
"entrust_sample_id"
,
ids
));
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
itemList
),
"所选择的样品不含检测项目,无法制备"
);
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
itemList
),
"所选择的样品不含检测项目,无法制备"
);
Set
<
Long
>
setSampleIds
=
itemList
.
stream
().
map
(
i
->
{
Set
<
Long
>
setSampleIds
=
itemList
.
stream
().
map
(
i
->
{
return
i
.
getEntrustSampleId
();
return
i
.
getEntrustSampleId
();
}).
collect
(
Collectors
.
toSet
());
}).
collect
(
Collectors
.
toSet
());
if
(
setSampleIds
.
size
()!=
ids
.
length
)
{
if
(
setSampleIds
.
size
()
!=
ids
.
length
)
{
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
itemList
),
"所选择的样品有不含检测项目的,请确认"
);
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
itemList
),
"所选择的样品有不含检测项目的,请确认"
);
}
}
Map
<
Long
,
Map
<
Long
,
String
>>
sampleGroupMap
=
new
HashMap
<>();
Map
<
Long
,
Map
<
Long
,
String
>>
sampleGroupMap
=
new
HashMap
<>();
for
(
EntrustSampleItem
item
:
itemList
)
{
for
(
EntrustSampleItem
item
:
itemList
)
{
if
(
sampleGroupMap
.
containsKey
(
item
.
getEntrustSampleId
())){
if
(
sampleGroupMap
.
containsKey
(
item
.
getEntrustSampleId
()))
{
Map
<
Long
,
String
>
groupMap
=
sampleGroupMap
.
get
(
item
.
getEntrustSampleId
());
Map
<
Long
,
String
>
groupMap
=
sampleGroupMap
.
get
(
item
.
getEntrustSampleId
());
groupMap
.
put
(
item
.
getGroupId
(),
item
.
getGroupName
());
groupMap
.
put
(
item
.
getGroupId
(),
item
.
getGroupName
());
sampleGroupMap
.
put
(
item
.
getEntrustSampleId
(),
groupMap
);
sampleGroupMap
.
put
(
item
.
getEntrustSampleId
(),
groupMap
);
}
else
{
}
else
{
Map
<
Long
,
String
>
groupMap
=
new
HashMap
<>();
Map
<
Long
,
String
>
groupMap
=
new
HashMap
<>();
groupMap
.
put
(
item
.
getGroupId
(),
item
.
getGroupName
());
groupMap
.
put
(
item
.
getGroupId
(),
item
.
getGroupName
());
sampleGroupMap
.
put
(
item
.
getEntrustSampleId
(),
groupMap
);
sampleGroupMap
.
put
(
item
.
getEntrustSampleId
(),
groupMap
);
}
}
}
}
List
<
EntrustSampleVO
>
list
=
new
ArrayList
<>();
List
<
EntrustSampleVO
>
list
=
new
ArrayList
<>();
for
(
EntrustSample
sample
:
entrustSamples
)
{
for
(
EntrustSample
sample
:
entrustSamples
)
{
Map
<
Long
,
String
>
groupMap
=
sampleGroupMap
.
get
(
sample
.
getId
());
Map
<
Long
,
String
>
groupMap
=
sampleGroupMap
.
get
(
sample
.
getId
());
if
(
null
==
groupMap
){
if
(
null
==
groupMap
)
{
continue
;
continue
;
}
}
for
(
Map
.
Entry
<
Long
,
String
>
g
:
groupMap
.
entrySet
())
{
for
(
Map
.
Entry
<
Long
,
String
>
g
:
groupMap
.
entrySet
())
{
EntrustSampleVO
sampleVO
=
sample
.
convert
(
EntrustSampleVO
.
class
);
EntrustSampleVO
sampleVO
=
sample
.
convert
(
EntrustSampleVO
.
class
);
sampleVO
.
setId
(
null
);
sampleVO
.
setId
(
null
);
sampleVO
.
setGroupId
(
g
.
getKey
());
sampleVO
.
setGroupId
(
g
.
getKey
());
sampleVO
.
setGroupName
(
g
.
getValue
());
sampleVO
.
setGroupName
(
g
.
getValue
());
Set
<
String
>
itemNameSet
=
new
HashSet
<>();
Set
<
String
>
itemNameSet
=
new
HashSet
<>();
for
(
EntrustSampleItem
item
:
itemList
)
{
for
(
EntrustSampleItem
item
:
itemList
)
{
if
(
item
.
getEntrustSampleId
().
equals
(
sample
.
getId
())&&
item
.
getGroupId
().
equals
(
g
.
getKey
()))
{
if
(
item
.
getEntrustSampleId
().
equals
(
sample
.
getId
())
&&
item
.
getGroupId
().
equals
(
g
.
getKey
()))
{
itemNameSet
.
add
(
item
.
getName
());
itemNameSet
.
add
(
item
.
getName
());
}
}
}
}
sampleVO
.
setItemNames
(
StringHandleUtils
.
join
(
itemNameSet
));
sampleVO
.
setItemNames
(
StringHandleUtils
.
join
(
itemNameSet
));
sampleVO
.
setEntrustSampleId
(
sample
.
getId
());
sampleVO
.
setEntrustSampleId
(
sample
.
getId
());
...
@@ -199,399 +202,391 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
...
@@ -199,399 +202,391 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
@Override
@Override
public
Page
<
EntrustSampleVO
>
pageSampleReceive
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
public
Page
<
EntrustSampleVO
>
pageSampleReceive
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
return
page
.
setRecords
(
baseMapper
.
selectSampleReceiveList
(
page
,
entrustSample
));
return
page
.
setRecords
(
baseMapper
.
selectSampleReceiveList
(
page
,
entrustSample
));
}
}
@Override
@Override
public
Page
<
EntrustSampleVO
>
pageSampleByItem
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
public
Page
<
EntrustSampleVO
>
pageSampleByItem
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
if
(
null
==
entrustSample
.
getEntrustId
()){
if
(
null
==
entrustSample
.
getEntrustId
())
{
return
page
;
return
page
;
}
}
if
(
null
==
entrustSample
.
getItemStatus
()){
if
(
null
==
entrustSample
.
getItemStatus
())
{
return
page
;
return
page
;
}
}
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
eq
(
"status"
,
entrustSample
.
getItemStatus
()));
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
eq
(
"status"
,
entrustSample
.
getItemStatus
()));
if
(
CollectionUtils
.
isEmpty
(
itemList
)){
if
(
CollectionUtils
.
isEmpty
(
itemList
))
{
return
page
;
return
page
;
}
}
List
<
Long
>
sampleIdsList
=
itemList
.
stream
().
map
(
i
->
{
List
<
Long
>
sampleIdsList
=
itemList
.
stream
().
map
(
i
->
{
return
i
.
getEntrustSampleId
();
return
i
.
getEntrustSampleId
();
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
entrustSample
.
setIds
(
sampleIdsList
);
entrustSample
.
setIds
(
sampleIdsList
);
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
entrustSample
));
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
entrustSample
));
}
}
@Override
@Override
public
Page
<
EntrustSampleVO
>
pageSampleByItemHis
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
public
Page
<
EntrustSampleVO
>
pageSampleByItemHis
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
entrustSample
)
{
if
(
null
==
entrustSample
.
getEntrustId
()){
if
(
null
==
entrustSample
.
getEntrustId
())
{
return
page
;
return
page
;
}
}
if
(
CollectionUtils
.
isEmpty
(
entrustSample
.
getItemStatusList
())
)
{
if
(
CollectionUtils
.
isEmpty
(
entrustSample
.
getItemStatusList
())
)
{
return
page
;
return
page
;
}
}
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
in
(
"status"
,
entrustSample
.
getItemStatusList
()));
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
in
(
"status"
,
entrustSample
.
getItemStatusList
()));
if
(
CollectionUtils
.
isEmpty
(
itemList
)){
if
(
CollectionUtils
.
isEmpty
(
itemList
))
{
return
page
;
return
page
;
}
}
List
<
Long
>
sampleIdsList
=
itemList
.
stream
().
map
(
i
->
{
List
<
Long
>
sampleIdsList
=
itemList
.
stream
().
map
(
i
->
{
return
i
.
getEntrustSampleId
();
return
i
.
getEntrustSampleId
();
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
entrustSample
.
setIds
(
sampleIdsList
);
entrustSample
.
setIds
(
sampleIdsList
);
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
entrustSample
));
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
entrustSample
));
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
boolean
makeReport
(
ReportDTO
dto
,
Account
account
)
{
public
boolean
makeReport
(
ReportDTO
dto
,
Account
account
)
{
Long
[]
ids
=
dto
.
getSampleIds
();
Long
[]
ids
=
dto
.
getSampleIds
();
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要生成报告的样品"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要生成报告的样品"
);
Long
templateId
=
dto
.
getTemplateId
();
Long
templateId
=
dto
.
getTemplateId
();
RestAssert
.
fail
(
null
==
templateId
,
"请选择报告模板!"
);
RestAssert
.
fail
(
null
==
templateId
,
"请选择报告模板!"
);
List
<
EntrustReportRelSample
>
relSamples
=
entrustReportRelSampleService
.
list
(
Condition
.
create
().
in
(
"sample_id"
,
ids
));
List
<
EntrustReportRelSample
>
relSamples
=
entrustReportRelSampleService
.
list
(
Condition
.
create
().
in
(
"sample_id"
,
ids
));
if
(
CollectionUtils
.
isNotEmpty
(
relSamples
)){
if
(
CollectionUtils
.
isNotEmpty
(
relSamples
))
{
RestAssert
.
fail
(
"您选择的样品含有已经生成过报告的,请确认"
);
RestAssert
.
fail
(
"您选择的样品含有已经生成过报告的,请确认"
);
}
}
List
<
EntrustSample
>
sampleList
=
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
List
<
EntrustSample
>
sampleList
=
super
.
list
(
Condition
.
create
().
in
(
"id"
,
ids
));
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
sampleList
),
"样品不存在请确认!"
);
RestAssert
.
fail
(
CollectionUtils
.
isEmpty
(
sampleList
),
"样品不存在请确认!"
);
Long
entrustId
=
sampleList
.
get
(
0
).
getEntrustId
();
Long
entrustId
=
sampleList
.
get
(
0
).
getEntrustId
();
Entrust
entrust
=
entrustService
.
getById
(
entrustId
);
Entrust
entrust
=
entrustService
.
getById
(
entrustId
);
EntrustReportTemplate
sysFileTemplate
=
entrustReportTemplateService
.
getById
(
templateId
);
EntrustReportTemplate
sysFileTemplate
=
entrustReportTemplateService
.
getById
(
templateId
);
Set
<
String
>
sampleNameSet
=
new
HashSet
<>();
Set
<
String
>
sampleNameSet
=
new
HashSet
<>();
for
(
EntrustSample
sample
:
sampleList
)
{
for
(
EntrustSample
sample
:
sampleList
)
{
sampleNameSet
.
add
(
sample
.
getName
());
sampleNameSet
.
add
(
sample
.
getName
());
}
}
String
sampleName
=
StringHandleUtils
.
join
(
sampleNameSet
);
String
sampleName
=
StringHandleUtils
.
join
(
sampleNameSet
);
if
(
sysFileTemplate
.
getName
().
contains
(
".docx"
)){
if
(
sysFileTemplate
.
getObjectKey
().
contains
(
".docx"
))
{
RestAssert
.
fail
(
null
==
sysFileTemplate
,
"选择的报告模板不存在"
);
RestAssert
.
fail
(
null
==
sysFileTemplate
,
"选择的报告模板不存在"
);
String
sampleShape
=
sampleList
.
get
(
0
).
getSampleShape
();
String
sampleShape
=
sampleList
.
get
(
0
).
getSampleShape
();
Map
<
String
,
Object
>
contractMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
contractMap
=
new
HashMap
<>();
contractMap
.
put
(
"s"
,
entrust
);
contractMap
.
put
(
"s"
,
entrust
);
contractMap
.
put
(
"sampleName"
,
sampleName
);
contractMap
.
put
(
"sampleName"
,
sampleName
);
contractMap
.
put
(
"sampleShape"
,
sampleShape
);
contractMap
.
put
(
"sampleShape"
,
sampleShape
);
InputStream
io
=
ossClient
.
download
(
sysFileTemplate
.
getObjectKey
());
InputStream
io
=
ossClient
.
download
(
sysFileTemplate
.
getObjectKey
());
XWPFTemplate
xwpfTemplate
=
null
;
XWPFTemplate
xwpfTemplate
=
null
;
try
{
try
{
xwpfTemplate
=
XWPFTemplate
.
compile
(
io
).
setDefaultValue
(
"/"
).
render
(
contractMap
);
xwpfTemplate
=
XWPFTemplate
.
compile
(
io
).
setDefaultValue
(
"/"
).
render
(
contractMap
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"生成报告失败"
,
e
);
logger
.
error
(
"生成报告失败"
,
e
);
RestAssert
.
fail
(
"报告生成失败:"
+
e
.
getMessage
());
RestAssert
.
fail
(
"报告生成失败:"
+
e
.
getMessage
());
}
}
XWPFDocument
baseDoc
=
xwpfTemplate
.
getXWPFDocument
();
XWPFDocument
baseDoc
=
xwpfTemplate
.
getXWPFDocument
();
List
<
EntrustSampleItemVO
>
sampleItemVOList
=
entrustSampleItemService
.
listBySampleIds
(
ids
);
List
<
EntrustSampleItemVO
>
sampleItemVOList
=
entrustSampleItemService
.
listBySampleIds
(
ids
);
List
<
XWPFTable
>
tableList
=
baseDoc
.
getTables
();
List
<
XWPFTable
>
tableList
=
baseDoc
.
getTables
();
for
(
XWPFTable
xwpfTable
:
tableList
)
{
for
(
XWPFTable
xwpfTable
:
tableList
)
{
String
text
=
xwpfTable
.
getText
();
String
text
=
xwpfTable
.
getText
();
if
(
com
.
patzn
.
cloud
.
commons
.
toolkit
.
StringHandleUtils
.
containsString
(
text
,
"{name}"
,
"{sampleCode}"
,
"{agreedValue}"
,
"{testValue}"
))
{
if
(
com
.
patzn
.
cloud
.
commons
.
toolkit
.
StringHandleUtils
.
containsString
(
text
,
"{name}"
,
"{sampleCode}"
,
"{agreedValue}"
,
"{testValue}"
))
{
//检测内容
//检测内容
reportMakeTestContent
(
xwpfTable
,
sampleItemVOList
.
size
(),
1
,
sampleItemVOList
);
reportMakeTestContent
(
xwpfTable
,
sampleItemVOList
.
size
(),
1
,
sampleItemVOList
);
}
}
}
}
String
generated
=
entrust
.
getCode
();
String
generated
=
entrust
.
getCode
();
FileOutputStream
os
=
null
;
FileOutputStream
os
=
null
;
File
file
=
null
;
File
file
=
null
;
try
{
try
{
file
=
File
.
createTempFile
(
generated
,
".docx"
);
file
=
File
.
createTempFile
(
generated
,
".docx"
);
os
=
new
FileOutputStream
(
file
);
os
=
new
FileOutputStream
(
file
);
baseDoc
.
write
(
os
);
baseDoc
.
write
(
os
);
os
.
flush
();
os
.
flush
();
entrustReportService
.
uploadReportGenerateDocx
(
entrust
,
ids
,
account
,
StringHandleUtils
.
join
(
sampleNameSet
),
"报告生成"
,
file
);
entrustReportService
.
uploadReportGenerateDocx
(
entrust
,
ids
,
account
,
StringHandleUtils
.
join
(
sampleNameSet
),
"报告生成"
,
file
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
try
{
try
{
os
.
close
();
os
.
close
();
baseDoc
.
close
();
baseDoc
.
close
();
io
.
close
();
io
.
close
();
FileUtils
.
deleteFiles
(
file
);
FileUtils
.
deleteFiles
(
file
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
}
else
if
(
sysFileTemplate
.
getName
().
contains
(
".xlsx"
)){
}
else
if
(
sysFileTemplate
.
getObjectKey
().
contains
(
".xlsx"
))
{
List
<
EntrustSampleItemVO
>
sampleItemVOList
=
entrustSampleItemService
.
listBySampleIds
(
ids
);
List
<
EntrustSampleItemVO
>
sampleItemVOList
=
entrustSampleItemService
.
listBySampleIds
(
ids
);
List
<
EntrustSampleVO
>
sampleVOList
=
new
ArrayList
<>();
List
<
EntrustSampleVO
>
sampleVOList
=
new
ArrayList
<>();
for
(
EntrustSample
sample
:
sampleList
)
{
for
(
EntrustSample
sample
:
sampleList
)
{
EntrustSampleVO
vo
=
sample
.
convert
(
EntrustSampleVO
.
class
);
EntrustSampleVO
vo
=
sample
.
convert
(
EntrustSampleVO
.
class
);
List
<
EntrustSampleItemVO
>
sampleItemList
=
new
ArrayList
<>();
for
(
EntrustSampleItemVO
itemVO
:
sampleItemVOList
)
{
if
(
sample
.
getId
().
equals
(
itemVO
.
getEntrustSampleId
())){
sampleItemList
.
add
(
itemVO
);
}
}
vo
.
setItemVOList
(
sampleItemList
);
sampleVOList
.
add
(
vo
);
}
InputStream
io
=
ossClient
.
download
(
sysFileTemplate
.
getObjectKey
());
XSSFWorkbook
xssfWorkbook
=
null
;
try
{
xssfWorkbook
=
new
XSSFWorkbook
(
io
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
List
<
OriginalTemplateConfig
>
configList
=
originalTemplateConfigService
.
list
(
Condition
.
create
().
eq
(
"template_id"
,
templateId
));
OriginalUtil
.
doReplace
(
xssfWorkbook
,
entrust
);
XSSFSheet
sheetOne
=
xssfWorkbook
.
getSheetAt
(
0
);
String
sheetName
=
sheetOne
.
getSheetName
();
System
.
out
.
println
(
sheetName
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
Integer
beginRow
=
sysFileTemplate
.
getSampleBeginRow
();
int
sampleMergerNum
=
sysFileTemplate
.
getSampleMergerNum
();
int
templateSampleNum
=
sysFileTemplate
.
getTemplateSampleNum
();
if
(
templateSampleNum
>=
sampleVOList
.
size
()){
for
(
EntrustSampleVO
vo:
sampleVOList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
OriginalTemplateConfig
config:
configList
)
{
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
())){
continue
;
}
String
value
=
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
);
cell
.
setCellValue
(
value
);
}
beginRow
+=
sampleMergerNum
;
}
String
generated
=
entrust
.
getCode
();
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
file
=
File
.
createTempFile
(
generated
,
".docx"
);
os
=
new
FileOutputStream
(
file
);
xssfWorkbook
.
write
(
os
);
os
.
flush
();
entrustReportService
.
uploadReportGenerateDocx
(
entrust
,
ids
,
account
,
StringHandleUtils
.
join
(
sampleNameSet
),
"报告生成"
,
file
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
xssfWorkbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
io
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
FileUtils
.
deleteFiles
(
file
);
}
}
else
{
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
0
).
getCellStyle
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
insertCount
=
sampleVOList
.
size
()-
templateSampleNum
;
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
sheetOne
.
shiftRows
(
insertRow
,
sheetOne
.
getLastRowNum
(),
1
,
true
,
false
);
XSSFRow
row
=
sheetOne
.
createRow
(
insertRow
);
row
.
setHeight
(
zeroRow
.
getHeight
());
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
XSSFCell
xssfCell
=
row
.
createCell
(
j
);
xssfCell
.
setCellStyle
(
cellStyle
);
}
insertRow
++;
}
}
int
sn
=
1
;
for
(
EntrustSampleVO
vo:
sampleVOList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
OriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getColumnPlace
()){
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
cell
.
setCellValue
(
sn
);
}
else
{
cell
.
setCellValue
(
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
));
}
}
beginRow
+=
sampleMergerNum
;
sn
++;
}
for
(
OriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
()){
config
.
setMergeRowNum
(
1
);
}
if
(
null
==
config
.
getMergeBegin
()){
continue
;
}
if
(
null
==
config
.
getMergeEnd
()){
continue
;
}
int
step
=
config
.
getMergeRowNum
();
if
(
step
==
1
&&
config
.
getMergeEnd
()
==
config
.
getMergeBegin
()){
continue
;
}
if
(
null
!=
config
.
getColumnPlace
()
&&
null
!=
config
.
getMergeRowNum
()){
Integer
sampleBgMum
=
sysFileTemplate
.
getSampleBeginRow
()+
templateSampleNum
*
sampleMergerNum
;
Integer
sampleEnMum
=
sysFileTemplate
.
getSampleBeginRow
()+
sampleVOList
.
size
()*
sampleMergerNum
-
1
;
while
(
sampleBgMum
<=
sampleEnMum
)
{
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
step
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
sampleBgMum
=
sampleBgMum
+
step
;
}
}
}
}
String
generated
=
entrust
.
getCode
();
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
file
=
File
.
createTempFile
(
generated
,
".docx"
);
os
=
new
FileOutputStream
(
file
);
xssfWorkbook
.
write
(
os
);
os
.
flush
();
entrustReportService
.
uploadReportGenerateDocx
(
entrust
,
ids
,
account
,
StringHandleUtils
.
join
(
sampleNameSet
),
"报告生成"
,
file
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
xssfWorkbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
io
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
FileUtils
.
deleteFiles
(
file
);
}
}
List
<
EntrustSampleItemVO
>
sampleItemList
=
new
ArrayList
<>();
for
(
EntrustSampleItemVO
itemVO
:
sampleItemVOList
)
{
if
(
sample
.
getId
().
equals
(
itemVO
.
getEntrustSampleId
()))
{
sampleItemList
.
add
(
itemVO
);
}
}
vo
.
setItemVOList
(
sampleItemList
);
sampleVOList
.
add
(
vo
);
}
InputStream
io
=
ossClient
.
download
(
sysFileTemplate
.
getObjectKey
());
XSSFWorkbook
xssfWorkbook
=
null
;
try
{
xssfWorkbook
=
new
XSSFWorkbook
(
io
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
List
<
EntrustReportTemplateConfig
>
configList
=
entrustReportTemplateConfigService
.
list
(
Condition
.
create
().
eq
(
"template_id"
,
templateId
));
OriginalUtil
.
doReplace
(
xssfWorkbook
,
entrust
);
XSSFSheet
sheetOne
=
xssfWorkbook
.
getSheetAt
(
0
);
String
sheetName
=
sheetOne
.
getSheetName
();
System
.
out
.
println
(
sheetName
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
Integer
beginRow
=
sysFileTemplate
.
getSampleBeginRow
();
int
sampleMergerNum
=
sysFileTemplate
.
getSampleMergerNum
();
int
templateSampleNum
=
sysFileTemplate
.
getTemplateSampleNum
();
if
(
templateSampleNum
>=
sampleVOList
.
size
())
{
for
(
EntrustSampleVO
vo
:
sampleVOList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
()))
{
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
()))
{
continue
;
}
String
value
=
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
);
cell
.
setCellValue
(
value
);
}
beginRow
+=
sampleMergerNum
;
}
String
generated
=
entrust
.
getCode
();
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
file
=
File
.
createTempFile
(
generated
,
".xlsx"
);
os
=
new
FileOutputStream
(
file
);
xssfWorkbook
.
write
(
os
);
os
.
flush
();
entrustReportService
.
uploadReportGenerateDocx
(
entrust
,
ids
,
account
,
StringHandleUtils
.
join
(
sampleNameSet
),
"报告生成"
,
file
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
xssfWorkbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
io
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
FileUtils
.
deleteFiles
(
file
);
}
}
else
{
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
0
).
getCellStyle
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
insertCount
=
sampleVOList
.
size
()
-
templateSampleNum
;
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
sheetOne
.
shiftRows
(
insertRow
,
sheetOne
.
getLastRowNum
(),
1
,
true
,
false
);
XSSFRow
row
=
sheetOne
.
createRow
(
insertRow
);
row
.
setHeight
(
zeroRow
.
getHeight
());
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
XSSFCell
xssfCell
=
row
.
createCell
(
j
);
xssfCell
.
setCellStyle
(
cellStyle
);
}
insertRow
++;
}
}
int
sn
=
1
;
for
(
EntrustSampleVO
vo
:
sampleVOList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
if
(
null
==
config
.
getColumnPlace
())
{
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
()))
{
cell
.
setCellValue
(
sn
);
}
else
{
cell
.
setCellValue
(
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
));
}
}
beginRow
+=
sampleMergerNum
;
sn
++;
}
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
())
{
config
.
setMergeRowNum
(
1
);
}
if
(
null
==
config
.
getMergeBegin
())
{
continue
;
}
if
(
null
==
config
.
getMergeEnd
())
{
continue
;
}
int
step
=
config
.
getMergeRowNum
();
if
(
step
==
1
&&
config
.
getMergeEnd
()
==
config
.
getMergeBegin
())
{
continue
;
}
if
(
null
!=
config
.
getColumnPlace
()
&&
null
!=
config
.
getMergeRowNum
())
{
Integer
sampleBgMum
=
sysFileTemplate
.
getSampleBeginRow
()
+
templateSampleNum
*
sampleMergerNum
;
Integer
sampleEnMum
=
sysFileTemplate
.
getSampleBeginRow
()
+
sampleVOList
.
size
()
*
sampleMergerNum
-
1
;
while
(
sampleBgMum
<=
sampleEnMum
)
{
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
step
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
sampleBgMum
=
sampleBgMum
+
step
;
}
}
}
}
String
generated
=
entrust
.
getCode
();
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
file
=
File
.
createTempFile
(
generated
,
".xlsx"
);
os
=
new
FileOutputStream
(
file
);
xssfWorkbook
.
write
(
os
);
os
.
flush
();
entrustReportService
.
uploadReportGenerateDocx
(
entrust
,
ids
,
account
,
StringHandleUtils
.
join
(
sampleNameSet
),
"报告生成"
,
file
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
xssfWorkbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
io
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
FileUtils
.
deleteFiles
(
file
);
}
}
return
true
;
return
true
;
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
boolean
submitJudgeRegister
(
Long
[]
ids
,
Account
account
)
{
public
boolean
submitJudgeRegister
(
Long
[]
ids
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交的质量登记数据"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交的质量登记数据"
);
EntrustSample
sample
=
new
EntrustSample
();
EntrustSample
sample
=
new
EntrustSample
();
sample
.
setJudgeStatus
(
1
);
sample
.
setJudgeStatus
(
1
);
sample
.
setJudgeProgress
(
1
);
sample
.
setJudgeProgress
(
1
);
return
super
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
ids
));
return
super
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
ids
));
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
boolean
submitJudgeCheck
(
Long
[]
ids
,
Account
account
)
{
public
boolean
submitJudgeCheck
(
Long
[]
ids
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交的质量登记数据"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交的质量登记数据"
);
EntrustSample
sample
=
new
EntrustSample
();
EntrustSample
sample
=
new
EntrustSample
();
sample
.
setJudgeStatus
(
2
);
sample
.
setJudgeStatus
(
2
);
sample
.
setJudgeProgress
(
2
);
sample
.
setJudgeProgress
(
2
);
sample
.
setJudgeChecker
(
account
.
getUserName
());
sample
.
setJudgeChecker
(
account
.
getUserName
());
sample
.
setJudgeCheckerId
(
account
.
getUserId
());
sample
.
setJudgeCheckerId
(
account
.
getUserId
());
sample
.
setJudgeCheckTime
(
new
Date
());
sample
.
setJudgeCheckTime
(
new
Date
());
return
super
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
ids
));
return
super
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
ids
));
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
boolean
backJudgeCheck
(
Long
[]
ids
,
String
remark
,
Account
account
)
{
public
boolean
backJudgeCheck
(
Long
[]
ids
,
String
remark
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交的质量登记数据"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择要提交的质量登记数据"
);
EntrustSample
sample
=
new
EntrustSample
();
EntrustSample
sample
=
new
EntrustSample
();
sample
.
setJudgeStatus
(
0
);
sample
.
setJudgeStatus
(
0
);
sample
.
setJudgeProgress
(-
1
);
sample
.
setJudgeProgress
(-
1
);
sample
.
setJudgeChecker
(
account
.
getUserName
());
sample
.
setJudgeChecker
(
account
.
getUserName
());
sample
.
setJudgeCheckerId
(
account
.
getUserId
());
sample
.
setJudgeCheckerId
(
account
.
getUserId
());
sample
.
setJudgeCheckTime
(
new
Date
());
sample
.
setJudgeCheckTime
(
new
Date
());
return
super
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
ids
));
return
super
.
update
(
sample
,
Condition
.
create
().
in
(
"id"
,
ids
));
}
}
@Override
@Override
public
Page
<
EntrustSampleVO
>
pageBySampleLeft
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
sampleVO
)
{
public
Page
<
EntrustSampleVO
>
pageBySampleLeft
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
sampleVO
)
{
if
(
null
==
sampleVO
.
getEntrustId
()){
if
(
null
==
sampleVO
.
getEntrustId
())
{
return
page
;
return
page
;
}
}
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
eq
(
"status"
,
sampleVO
.
getItemStatus
()));
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
eq
(
"status"
,
sampleVO
.
getItemStatus
()));
if
(
CollectionUtils
.
isEmpty
(
itemList
)){
if
(
CollectionUtils
.
isEmpty
(
itemList
))
{
return
page
;
return
page
;
}
}
List
<
Long
>
sampleIds
=
new
ArrayList
<>();
List
<
Long
>
sampleIds
=
new
ArrayList
<>();
for
(
EntrustSampleItem
item
:
itemList
)
{
for
(
EntrustSampleItem
item
:
itemList
)
{
sampleIds
.
add
(
item
.
getEntrustSampleId
());
sampleIds
.
add
(
item
.
getEntrustSampleId
());
}
}
sampleVO
.
setIds
(
sampleIds
);
sampleVO
.
setIds
(
sampleIds
);
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
sampleVO
));
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
sampleVO
));
}
}
@Override
@Override
public
Page
<
EntrustSampleVO
>
pageBySampleLeftHis
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
sampleVO
)
{
public
Page
<
EntrustSampleVO
>
pageBySampleLeftHis
(
Page
<
EntrustSampleVO
>
page
,
EntrustSampleVO
sampleVO
)
{
if
(
null
==
sampleVO
.
getEntrustId
()){
if
(
null
==
sampleVO
.
getEntrustId
())
{
return
page
;
return
page
;
}
}
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
in
(
"status"
,
sampleVO
.
getItemStatusList
()));
List
<
EntrustSampleItem
>
itemList
=
entrustSampleItemService
.
list
(
Condition
.
create
().
in
(
"status"
,
sampleVO
.
getItemStatusList
()));
if
(
CollectionUtils
.
isEmpty
(
itemList
)){
if
(
CollectionUtils
.
isEmpty
(
itemList
))
{
return
page
;
return
page
;
}
}
List
<
Long
>
sampleIds
=
new
ArrayList
<>();
List
<
Long
>
sampleIds
=
new
ArrayList
<>();
for
(
EntrustSampleItem
item
:
itemList
)
{
for
(
EntrustSampleItem
item
:
itemList
)
{
sampleIds
.
add
(
item
.
getEntrustSampleId
());
sampleIds
.
add
(
item
.
getEntrustSampleId
());
}
}
sampleVO
.
setIds
(
sampleIds
);
sampleVO
.
setIds
(
sampleIds
);
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
sampleVO
));
return
page
.
setRecords
(
baseMapper
.
selectVOList
(
page
,
sampleVO
));
}
}
...
@@ -609,61 +604,62 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
...
@@ -609,61 +604,62 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
}
}
int
mergeIndex
=
1
;
int
mergeIndex
=
1
;
int
mergeNum
=
1
;
int
mergeNum
=
1
;
Map
<
Integer
,
Integer
>
mergeMap
=
new
HashMap
<>();
Map
<
Integer
,
Integer
>
mergeMap
=
new
HashMap
<>();
int
mergeIndexBath
=
1
;
int
mergeIndexBath
=
1
;
int
mergeNumBath
=
1
;
int
mergeNumBath
=
1
;
int
mergeCodeIndex
=
index
;
int
mergeCodeIndex
=
index
;
int
mergeCode
=
index
;
int
mergeCode
=
index
;
Map
<
Integer
,
Integer
>
mergeMapBath
=
new
HashMap
<>();
Map
<
Integer
,
Integer
>
mergeMapBath
=
new
HashMap
<>();
Map
<
Integer
,
Integer
>
mergeCodeMap
=
new
HashMap
<>();
Map
<
Integer
,
Integer
>
mergeCodeMap
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
rowLength
;
i
++)
{
for
(
int
i
=
0
;
i
<
rowLength
;
i
++)
{
fillTableData
(
xwpfTable
,
itemCellMap
,
index
+
i
,
objects
.
get
(
i
));
fillTableData
(
xwpfTable
,
itemCellMap
,
index
+
i
,
objects
.
get
(
i
));
if
(
i
>
0
)
{
if
(
i
>
0
)
{
Object
pre
=
objects
.
get
(
i
-
1
);
Object
pre
=
objects
.
get
(
i
-
1
);
Object
now
=
objects
.
get
(
i
);
Object
now
=
objects
.
get
(
i
);
String
value
=
StringHandleUtils
.
getFieldValueByFieldName
(
"sampleCode"
,
pre
);
String
value
=
StringHandleUtils
.
getFieldValueByFieldName
(
"sampleCode"
,
pre
);
String
preValue
=
StringHandleUtils
.
getFieldValueByFieldName
(
"sampleCode"
,
now
);
String
preValue
=
StringHandleUtils
.
getFieldValueByFieldName
(
"sampleCode"
,
now
);
if
(
value
.
equals
(
preValue
)){
if
(
value
.
equals
(
preValue
))
{
mergeNum
++;
mergeNum
++;
}
else
{
}
else
{
mergeMap
.
put
(
mergeIndex
,
mergeNum
);
mergeMap
.
put
(
mergeIndex
,
mergeNum
);
mergeIndex
=
mergeNum
+
1
;
mergeIndex
=
mergeNum
+
1
;
mergeNum
++;
mergeNum
++;
}
}
}
}
}
}
mergeMap
.
put
(
mergeIndex
,
mergeNum
);
mergeMap
.
put
(
mergeIndex
,
mergeNum
);
mergeMapBath
.
put
(
mergeIndexBath
,
mergeNumBath
);
mergeMapBath
.
put
(
mergeIndexBath
,
mergeNumBath
);
mergeCodeMap
.
put
(
mergeCodeIndex
,
mergeCode
);
mergeCodeMap
.
put
(
mergeCodeIndex
,
mergeCode
);
for
(
Map
.
Entry
<
Integer
,
Integer
>
e:
mergeMap
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
Integer
>
e
:
mergeMap
.
entrySet
())
{
mergeCellsVertically
(
xwpfTable
,
getKey
(
itemCellMap
,
"{sampleCode}"
),
e
.
getKey
(),
e
.
getValue
());
mergeCellsVertically
(
xwpfTable
,
getKey
(
itemCellMap
,
"{sampleCode}"
),
e
.
getKey
(),
e
.
getValue
());
}
}
}
}
public
static
Integer
getKey
(
Map
<
Integer
,
String
>
map
,
String
v
)
{
public
static
Integer
getKey
(
Map
<
Integer
,
String
>
map
,
String
v
)
{
Integer
key
;
Integer
key
;
for
(
Map
.
Entry
<
Integer
,
String
>
e:
map
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
String
>
e
:
map
.
entrySet
())
{
if
(
v
.
equals
(
e
.
getValue
())){
if
(
v
.
equals
(
e
.
getValue
()))
{
return
e
.
getKey
();
return
e
.
getKey
();
}
}
}
}
return
null
;
return
null
;
}
}
// word跨行并单元格
// word跨行并单元格
public
void
mergeCellsVertically
(
XWPFTable
table
,
Integer
c
,
int
fromRow
,
int
toRow
)
{
public
void
mergeCellsVertically
(
XWPFTable
table
,
Integer
c
,
int
fromRow
,
int
toRow
)
{
if
(
null
==
c
){
if
(
null
==
c
)
{
return
;
return
;
}
}
int
col
=
c
;
int
col
=
c
;
for
(
int
rowIndex
=
fromRow
;
rowIndex
<=
toRow
;
rowIndex
++)
{
for
(
int
rowIndex
=
fromRow
;
rowIndex
<=
toRow
;
rowIndex
++)
{
XWPFTableCell
cell
=
table
.
getRow
(
rowIndex
).
getCell
(
col
);
XWPFTableCell
cell
=
table
.
getRow
(
rowIndex
).
getCell
(
col
);
if
(
rowIndex
==
fromRow
)
{
if
(
rowIndex
==
fromRow
)
{
// The first merged cell is set with RESTART merge value
// The first merged cell is set with RESTART merge value
cell
.
getCTTc
().
addNewTcPr
().
addNewVMerge
().
setVal
(
STMerge
.
RESTART
);
cell
.
getCTTc
().
addNewTcPr
().
addNewVMerge
().
setVal
(
STMerge
.
RESTART
);
}
else
{
}
else
{
...
@@ -674,10 +670,10 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
...
@@ -674,10 +670,10 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
}
}
public
void
mergeCellsHorizontal
(
XWPFTable
table
,
int
row
,
int
fromCell
,
int
toCell
)
{
public
void
mergeCellsHorizontal
(
XWPFTable
table
,
int
row
,
int
fromCell
,
int
toCell
)
{
for
(
int
cellIndex
=
fromCell
;
cellIndex
<=
toCell
;
cellIndex
++)
{
for
(
int
cellIndex
=
fromCell
;
cellIndex
<=
toCell
;
cellIndex
++)
{
XWPFTableCell
cell
=
table
.
getRow
(
row
).
getCell
(
cellIndex
);
XWPFTableCell
cell
=
table
.
getRow
(
row
).
getCell
(
cellIndex
);
if
(
cellIndex
==
fromCell
)
{
if
(
cellIndex
==
fromCell
)
{
// The first merged cell is set with RESTART merge value
// The first merged cell is set with RESTART merge value
cell
.
getCTTc
().
addNewTcPr
().
addNewHMerge
().
setVal
(
STMerge
.
RESTART
);
cell
.
getCTTc
().
addNewTcPr
().
addNewHMerge
().
setVal
(
STMerge
.
RESTART
);
}
else
{
}
else
{
...
...
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