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
7aae38b4
Commit
7aae38b4
authored
Jul 14, 2021
by
ghxdhr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生成原始记录
parent
d91db76f
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
394 additions
and
18 deletions
+394
-18
EntrustSampleItemController.java
...ice/lims/hmhj/controller/EntrustSampleItemController.java
+2
-2
MoreItemMoreOperation.java
...oud/service/lims/hmhj/original/MoreItemMoreOperation.java
+32
-0
MoreItemOperation.java
...n/cloud/service/lims/hmhj/original/MoreItemOperation.java
+32
-0
SingleSheetLittleOperation.java
...ervice/lims/hmhj/original/SingleSheetLittleOperation.java
+32
-0
SingleSheetMoreItemOperation.java
...vice/lims/hmhj/original/SingleSheetMoreItemOperation.java
+167
-0
SingleSheetMoreOperation.java
.../service/lims/hmhj/original/SingleSheetMoreOperation.java
+35
-0
IEntrustSampleItemService.java
.../service/lims/hmhj/service/IEntrustSampleItemService.java
+1
-1
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+76
-13
OriginalTemplateServiceImpl.java
...e/lims/hmhj/service/impl/OriginalTemplateServiceImpl.java
+2
-2
20210714新增视图.sql
src/test/java/resources/db_sql/hmhj/v147/20210714新增视图.sql
+7
-0
20210714模板增加字段.sql
src/test/java/resources/db_sql/hmhj/v147/20210714模板增加字段.sql
+8
-0
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/controller/EntrustSampleItemController.java
View file @
7aae38b4
...
...
@@ -566,8 +566,8 @@ public class EntrustSampleItemController extends ServiceController {
@ApiOperation
(
value
=
"填写原始记录"
,
notes
=
"填写原始记录"
)
@PostMapping
(
"/save_excel_original_record"
)
public
RestResult
<
OriginalRecord
>
saveExcelOriginalRecord
(
@RequestParam
(
"ids"
)
Long
[]
ids
,
@RequestParam
(
"templateId"
)
Long
templateId
)
{
return
success
(
entrustSampleItemService
.
saveExcelOriginalRecord
(
ids
,
templateId
,
getAccount
()));
public
RestResult
<
OriginalRecord
>
saveExcelOriginalRecord
(
@RequestParam
(
"ids"
)
Long
[]
ids
,
@RequestParam
(
"templateId"
)
Long
templateId
,
@RequestParam
(
"entrustCode"
)
String
entrustCode
)
{
return
success
(
entrustSampleItemService
.
saveExcelOriginalRecord
(
ids
,
templateId
,
getAccount
()
,
entrustCode
));
}
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/original/MoreItemMoreOperation.java
View file @
7aae38b4
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.google.common.collect.Lists
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
...
...
@@ -62,14 +63,45 @@ public class MoreItemMoreOperation implements Operation {
for
(
EntrustSampleVO
vo:
sampleVOListIndex
)
{
XSSFRow
xssfRow
=
sheetIndex
.
getRow
(
beginRow
);
XSSFRow
xssfRowTwo
=
null
;
XSSFRow
xssfRowThree
=
null
;
if
(
sampleMergerNum
==
2
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
}
if
(
sampleMergerNum
==
3
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
xssfRowThree
=
sheetOne
.
getRow
(
beginRow
+
2
);
}
for
(
OriginalTemplateConfig
config:
configList
)
{
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
XSSFCell
cell2
=
null
;
XSSFCell
cell3
=
null
;
if
(
null
!=
xssfRowTwo
)
{
cell2
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
null
!=
xssfRowThree
)
{
cell3
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
())){
continue
;
}
if
(
config
.
getDataAttribute
().
startsWith
(
"clc."
))
{
String
mapKey
=
config
.
getDataAttribute
().
substring
(
4
);
if
(
CollectionUtils
.
isNotEmpty
(
vo
.
getCollectionDataList
()))
{
cell
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
0
).
get
(
mapKey
));
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
cell2
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
));
}
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
cell3
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
));
}
}
continue
;
}
cell
.
setCellValue
(
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
));
}
beginRow
+=
sampleMergerNum
;
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/original/MoreItemOperation.java
View file @
7aae38b4
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig
;
...
...
@@ -39,14 +40,45 @@ public class MoreItemOperation implements Operation {
int
templateSampleNum
=
template
.
getTemplateSampleNum
();
for
(
EntrustSampleVO
vo:
voList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFRow
xssfRowTwo
=
null
;
XSSFRow
xssfRowThree
=
null
;
if
(
sampleMergerNum
==
2
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
}
if
(
sampleMergerNum
==
3
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
xssfRowThree
=
sheetOne
.
getRow
(
beginRow
+
2
);
}
for
(
OriginalTemplateConfig
config:
configList
)
{
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
XSSFCell
cell2
=
null
;
XSSFCell
cell3
=
null
;
if
(
null
!=
xssfRowTwo
)
{
cell2
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
null
!=
xssfRowThree
)
{
cell3
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
())){
continue
;
}
if
(
config
.
getDataAttribute
().
startsWith
(
"clc."
))
{
String
mapKey
=
config
.
getDataAttribute
().
substring
(
4
);
if
(
CollectionUtils
.
isNotEmpty
(
vo
.
getCollectionDataList
()))
{
cell
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
0
).
get
(
mapKey
));
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
cell2
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
));
}
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
cell3
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
));
}
}
continue
;
}
String
value
=
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
);
cell
.
setCellValue
(
value
);
}
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetLittleOperation.java
View file @
7aae38b4
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig
;
...
...
@@ -43,14 +44,45 @@ public class SingleSheetLittleOperation implements Operation {
int
templateSampleNum
=
template
.
getTemplateSampleNum
();
for
(
EntrustSampleItemVO
vo:
voList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFRow
xssfRowTwo
=
null
;
XSSFRow
xssfRowThree
=
null
;
if
(
sampleMergerNum
==
2
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
}
if
(
sampleMergerNum
==
3
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
xssfRowThree
=
sheetOne
.
getRow
(
beginRow
+
2
);
}
for
(
OriginalTemplateConfig
config:
configList
)
{
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
XSSFCell
cell2
=
null
;
XSSFCell
cell3
=
null
;
if
(
null
!=
xssfRowTwo
)
{
cell2
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
null
!=
xssfRowThree
)
{
cell3
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
())){
continue
;
}
if
(
config
.
getDataAttribute
().
startsWith
(
"clc."
))
{
String
mapKey
=
config
.
getDataAttribute
().
substring
(
4
);
if
(
CollectionUtils
.
isNotEmpty
(
vo
.
getCollectionDataList
()))
{
cell
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
0
).
get
(
mapKey
));
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
cell2
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
));
}
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
cell3
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
));
}
}
continue
;
}
String
value
=
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
config
.
getDataAttribute
(),
vo
);
cell
.
setCellValue
(
value
);
}
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetMoreItemOperation.java
0 → 100644
View file @
7aae38b4
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig
;
import
com.patzn.cloud.service.hmhj.vo.EntrustSampleVO
;
import
com.patzn.cloud.service.lims.common.StringHandleUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.xssf.usermodel.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
public
class
SingleSheetMoreItemOperation
implements
Operation
{
private
OriginalTemplate
template
;
private
List
<
EntrustSampleVO
>
voList
;
private
Entrust
entrust
;
private
List
<
OriginalTemplateConfig
>
configList
;
private
XSSFWorkbook
xssfWorkbook
;
private
String
collectionDatePrefix
=
"clc."
;
private
HashMap
<
Long
,
Map
<
String
,
String
>>
sampleIdMap
=
new
HashMap
<>();;
public
SingleSheetMoreItemOperation
(
OriginalTemplate
template
,
List
<
EntrustSampleVO
>
voList
,
Entrust
entrust
,
List
<
OriginalTemplateConfig
>
configList
,
XSSFWorkbook
xssfWorkbook
)
{
this
.
template
=
template
;
this
.
voList
=
voList
;
this
.
entrust
=
entrust
;
this
.
configList
=
configList
;
this
.
xssfWorkbook
=
xssfWorkbook
;
dealCollectionData
(
voList
,
configList
);
}
private
void
dealCollectionData
(
List
<
EntrustSampleVO
>
voList
,
List
<
OriginalTemplateConfig
>
configList
)
{
/* 处理配置项的值 */
List
<
String
>
dataAtrrs
=
configList
.
stream
().
filter
(
config
->
config
.
getDataAttribute
()
!=
null
&&
config
.
getDataAttribute
().
startsWith
(
collectionDatePrefix
))
.
map
(
config
->
config
.
getDataAttribute
().
substring
(
collectionDatePrefix
.
length
()))
.
collect
(
Collectors
.
toList
());
for
(
EntrustSampleVO
vo
:
voList
)
{
if
(
null
!=
vo
.
getCollectionDataList
())
{
for
(
Map
<
String
,
String
>
map
:
vo
.
getCollectionDataList
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
map
.
entrySet
())
{
if
(
dataAtrrs
.
contains
(
entry
.
getKey
()))
{
HashMap
<
String
,
String
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
if
(
sampleIdMap
.
containsKey
(
vo
.
getId
()))
{
sampleIdMap
.
get
(
vo
.
getId
()).
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
else
{
sampleIdMap
.
put
(
vo
.
getId
(),
dataMap
);
}
}
}
}
}
}
}
@Override
public
void
doMakeOriginal
()
{
OriginalUtil
.
doReplace
(
xssfWorkbook
,
entrust
);
XSSFSheet
sheetOne
=
xssfWorkbook
.
getSheetAt
(
0
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
Integer
beginRow
=
template
.
getSampleBeginRow
();
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
templateSampleNum
=
template
.
getTemplateSampleNum
();
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
0
).
getCellStyle
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
insertCount
=
voList
.
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:
voList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFRow
xssfRowTwo
=
null
;
XSSFRow
xssfRowThree
=
null
;
if
(
sampleMergerNum
==
2
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
}
if
(
sampleMergerNum
==
3
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
xssfRowThree
=
sheetOne
.
getRow
(
beginRow
+
2
);
}
for
(
OriginalTemplateConfig
config:
configList
)
{
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
XSSFCell
cell2
=
null
;
XSSFCell
cell3
=
null
;
if
(
null
!=
xssfRowTwo
)
{
cell2
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
null
!=
xssfRowThree
)
{
cell3
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
())){
continue
;
}
if
(
config
.
getDataAttribute
().
startsWith
(
collectionDatePrefix
))
{
String
mapKey
=
config
.
getDataAttribute
().
substring
(
4
);
if
(
sampleIdMap
.
get
(
vo
.
getId
()).
size
()
>
0
)
{
cell
.
setCellValue
(
sampleIdMap
.
get
(
vo
.
getId
()).
get
(
mapKey
));
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
cell2
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
));
}
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
cell3
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
));
}
}
continue
;
}
String
value
=
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
config
.
getDataAttribute
(),
vo
);
cell
.
setCellValue
(
value
);
}
beginRow
+=
sampleMergerNum
;
sn
++;
}
Integer
sampleBgMum
=
template
.
getSampleBeginRow
();
for
(
OriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
()){
config
.
setMergeRowNum
(
1
);
}
String
formula
=
config
.
getFormula
();
if
(
StringUtils
.
isBlank
(
formula
)){
continue
;
}
Integer
columnPlace
=
config
.
getColumnPlace
();
if
(
null
==
config
.
getColumnPlace
()){
continue
;
}
if
(
null
==
config
.
getMergeRowNum
()){
continue
;
}
Integer
mergeRowNum
=
config
.
getMergeRowNum
();
int
formulaNum
=
template
.
getSampleBeginRow
()+
sampleMergerNum
*
templateSampleNum
-
1
;
for
(
int
i
=
sampleBgMum
;
i
<=
formulaNum
;
i
+=
mergeRowNum
)
{
XSSFRow
row
=
sheetOne
.
getRow
(
i
);
XSSFCell
cell
=
row
.
getCell
(
columnPlace
);
cell
.
setCellFormula
(
OriginalUtil
.
initFormula
(
formula
,
i
));
}
}
}
}
\ No newline at end of file
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetMoreOperation.java
View file @
7aae38b4
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig
;
...
...
@@ -62,17 +63,51 @@ public class SingleSheetMoreOperation implements Operation {
for
(
EntrustSampleItemVO
vo:
voList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFRow
xssfRowTwo
=
null
;
XSSFRow
xssfRowThree
=
null
;
if
(
sampleMergerNum
==
2
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
}
if
(
sampleMergerNum
==
3
)
{
xssfRowTwo
=
sheetOne
.
getRow
(
beginRow
+
1
);
xssfRowThree
=
sheetOne
.
getRow
(
beginRow
+
2
);
}
for
(
OriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getColumnPlace
()){
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
XSSFCell
cell2
=
null
;
XSSFCell
cell3
=
null
;
if
(
null
!=
xssfRowTwo
)
{
cell2
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
null
!=
xssfRowThree
)
{
cell3
=
xssfRowTwo
.
getCell
(
config
.
getColumnPlace
());
}
if
(
null
==
config
.
getDataAttribute
())
{
continue
;
}
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
cell
.
setCellValue
(
sn
);
}
else
if
(
config
.
getDataAttribute
().
startsWith
(
"clc."
))
{
String
mapKey
=
config
.
getDataAttribute
().
substring
(
4
);
if
(
CollectionUtils
.
isNotEmpty
(
vo
.
getCollectionDataList
()))
{
cell
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
0
).
get
(
mapKey
));
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
cell2
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
));
}
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
cell3
.
setCellValue
(
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
));
}
}
continue
;
}
else
{
cell
.
setCellValue
(
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
config
.
getDataAttribute
(),
vo
));
}
}
beginRow
+=
sampleMergerNum
;
sn
++;
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IEntrustSampleItemService.java
View file @
7aae38b4
...
...
@@ -54,7 +54,7 @@ public interface IEntrustSampleItemService extends IBaseService<EntrustSampleIte
List
<
EntrustSampleItemVO
>
listBySampleIdsAndIds
(
Long
[]
ids
,
Long
[]
itemIds
);
OriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
);
OriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
,
String
entrustCode
);
boolean
deviateApply
(
Long
[]
ids
,
ItemDeviate
deviate
,
Account
account
);
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
7aae38b4
...
...
@@ -6,10 +6,7 @@ import com.google.common.collect.Lists;
import
com.patzn.cloud.commons.api.RestAssert
;
import
com.patzn.cloud.commons.controller.Account
;
import
com.patzn.cloud.commons.controller.LoginHelper
;
import
com.patzn.cloud.commons.toolkit.DateUtils
;
import
com.patzn.cloud.commons.toolkit.FileUtils
;
import
com.patzn.cloud.commons.toolkit.MapMergeUtils
;
import
com.patzn.cloud.commons.toolkit.TimeWatch
;
import
com.patzn.cloud.commons.toolkit.*
;
import
com.patzn.cloud.feign.lims.base.client.LmsUserRelGroupClient
;
import
com.patzn.cloud.oss.starter.OssClient
;
import
com.patzn.cloud.oss.starter.OssFileResult
;
...
...
@@ -23,6 +20,7 @@ import com.patzn.cloud.service.hmhj.vo.*;
import
com.patzn.cloud.service.lims.base.entity.LmsUserRelGroup
;
import
com.patzn.cloud.service.lims.base.vo.GroupUserVO
;
import
com.patzn.cloud.service.lims.base.vo.LmsUserRelGroupVO
;
import
com.patzn.cloud.service.lims.collection.entity.LmsOriginalRecordInfo
;
import
com.patzn.cloud.service.lims.common.CompareUtils
;
import
com.patzn.cloud.service.lims.hmhj.common.EntrustFlowUtils
;
import
com.patzn.cloud.service.lims.hmhj.common.HSSFWorkbookUtil
;
...
...
@@ -113,6 +111,8 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Value
(
"${libreOffice.url}"
)
private
String
libreOfficeUrl
;
@Autowired
private
ILmsOriginalRecordInfoService
originalRecordInfoService
;
@Override
public
Page
<
EntrustSampleItem
>
page
(
Page
<
EntrustSampleItem
>
page
,
EntrustSampleItem
entrustSampleItem
)
{
...
...
@@ -459,7 +459,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
@Override
public
OriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
)
{
public
OriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
,
String
entrustCode
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择试验项目!"
);
RestAssert
.
fail
(
null
==
templateId
,
"请选择原始记录模板"
);
OriginalTemplate
template
=
originalTemplateService
.
getById
(
templateId
);
...
...
@@ -508,27 +508,37 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
sampleVOList
.
add
(
vo
);
}
/* 获取采集数据,并保存到SampleVO中 */
getCollectionData
(
null
,
sampleVOList
,
entrustCode
);
if
(
null
==
template
.
getSampleBeginRow
()
||
null
==
template
.
getSampleMergerNum
()
||
null
==
template
.
getTemplateSampleNum
())
{
return
null
;
}
if
(
voList
.
size
()
<
template
.
getTemplateSampleNum
())
{
MoreItemOperation
moreItemOperation
=
new
MoreItemOperation
(
template
,
sampleVOList
,
entrust
,
configList
,
xssfWorkbook
);
moreItemOperation
.
doMakeOriginal
();
}
else
{
MoreItemMoreOperation
moreItemOperation
=
new
MoreItemMoreOperation
(
template
,
sampleVOList
,
entrust
,
configList
,
xssfWorkbook
);
moreItemOperation
.
doMakeOriginal
();
}
// if (voList.size() < template.getTemplateSampleNum()) {
// MoreItemOperation moreItemOperation = new MoreItemOperation(template, sampleVOList, entrust, configList, xssfWorkbook);
// moreItemOperation.doMakeOriginal();
//
// } else {
// MoreItemMoreOperation moreItemOperation = new MoreItemMoreOperation(template, sampleVOList, entrust, configList, xssfWorkbook);
// moreItemOperation.doMakeOriginal();
/* 多个检测项目放在一个sheet中,一个样品一条记录 */
SingleSheetMoreItemOperation
operation
=
new
SingleSheetMoreItemOperation
(
template
,
sampleVOList
,
entrust
,
configList
,
xssfWorkbook
);
operation
.
doMakeOriginal
();
// }
}
else
{
/* 获取采集到的数据 */
getCollectionData
(
voList
,
null
,
entrustCode
);
if
(
CollectionUtils
.
isNotEmpty
(
voList
))
{
mapReplace
.
put
(
"#{sampleFrom}"
,
voList
.
get
(
0
).
getSampleFrom
());
mapReplace
.
put
(
"#{sampleName}"
,
voList
.
get
(
0
).
getSampleName
());
}
OriginalFactory
factory
=
new
OriginalFactory
(
template
,
voList
,
entrust
,
configList
,
xssfWorkbook
);
Operation
operation
=
factory
.
getOperation
();
if
(
null
!=
operation
)
{
operation
.
doMakeOriginal
();
...
...
@@ -578,6 +588,59 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return
objectKey
;
}
private
void
getCollectionData
(
List
<
EntrustSampleItemVO
>
itemVOListList
,
List
<
EntrustSampleVO
>
sampleVOList
,
String
entrustCode
)
{
/* 拿到所有样品的编号 */
Set
<
String
>
numSet
=
new
HashSet
<>();
if
(
itemVOListList
!=
null
)
{
numSet
=
itemVOListList
.
stream
().
map
(
vo
->
vo
.
getSampleCode
()).
collect
(
Collectors
.
toSet
());
}
if
(
sampleVOList
!=
null
)
{
numSet
=
sampleVOList
.
stream
().
map
(
vo
->
vo
.
getCode
()).
collect
(
Collectors
.
toSet
());
}
/* 通过样品编号拿到所有的采集数据 */
List
<
LmsOriginalRecordInfo
>
records
=
originalRecordInfoService
.
list
(
Condition
.
create
().
in
(
"sample_num"
,
numSet
).
eq
(
"contract_code"
,
entrustCode
));
/* 按照样品编号和项目分开,来存放采集到的数据 record的data */
HashMap
<
String
,
List
<
String
>>
mapByNumItemName
=
new
HashMap
<>();
for
(
LmsOriginalRecordInfo
record
:
records
)
{
MapMergeUtils
.
getorCreateMapArrayList
(
record
.
getSampleNum
(),
mapByNumItemName
,
record
.
getData
());
}
/* 设置采集数据的Map -- itemVo */
if
(
itemVOListList
!=
null
)
{
itemVOListList
.
stream
().
forEach
(
vo
->
{
List
<
String
>
datas
=
mapByNumItemName
.
get
(
vo
.
getSampleCode
());
if
(
CollectionUtils
.
isNotEmpty
(
datas
))
{
ArrayList
<
Map
<
String
,
String
>>
maps
=
new
ArrayList
<>(
4
);
for
(
String
data
:
datas
)
{
maps
.
add
(
toStringStringMap
(
data
));
}
vo
.
setCollectionDataList
(
maps
);
}
});
}
/* sampleVo */
if
(
sampleVOList
!=
null
)
{
sampleVOList
.
stream
().
forEach
(
vo
->
{
List
<
String
>
datas
=
mapByNumItemName
.
get
(
vo
.
getCode
());
if
(
CollectionUtils
.
isNotEmpty
(
datas
))
{
ArrayList
<
Map
<
String
,
String
>>
maps
=
new
ArrayList
<>(
4
);
for
(
String
data
:
datas
)
{
maps
.
add
(
toStringStringMap
(
data
));
}
vo
.
setCollectionDataList
(
maps
);
}
});
}
}
public
static
Map
<
String
,
String
>
toStringStringMap
(
String
jsonString
)
{
HashMap
<
String
,
String
>
stringStringHashMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
stringObjectMap
=
JsonUtils
.
exchange
(
jsonString
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
stringObjectMap
.
entrySet
())
{
stringStringHashMap
.
put
(
entry
.
getKey
(),(
String
)
entry
.
getValue
());
}
return
stringStringHashMap
;
}
@Override
public
boolean
deviateApply
(
Long
[]
ids
,
ItemDeviate
deviate
,
Account
account
)
{
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选需要偏离审批的检测项目"
);
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/OriginalTemplateServiceImpl.java
View file @
7aae38b4
...
...
@@ -180,7 +180,7 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
if
(
null
==
moreSheet
||
0
==
moreSheet
)
{
int
sampleBeginRow
=
template
.
getSampleBeginRow
();
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
lastRowNum
=
sheet
.
getLastRowNum
();
int
lastRowNum
=
sheet
.
getLastRowNum
()
-
template
.
getTailNum
()
-
1
;
Integer
samplePos
=
null
;
...
...
@@ -325,7 +325,7 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
XSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
k
);
int
sampleBeginRow
=
template
.
getSampleBeginRow
();
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
lastRowNum
=
sheet
.
getLastRowNum
();
int
lastRowNum
=
sheet
.
getLastRowNum
()
-
template
.
getTailNum
()
-
1
;
Integer
sampleCol
=
null
;
...
...
src/test/java/resources/db_sql/hmhj/v147/20210714新增视图.sql
0 → 100644
View file @
7aae38b4
-- ghx
-- ghx
CREATE
OR
replace
VIEW
"public"
.
"v_lms_user_group"
AS
SELECT
ug
.
group_id
,
ug
.
user_id
,
ug
.
realname
FROM
dblink
((
func_db_info
(
'dev_lims'
::
character
varying
))::
text
,
'select user_id,group_id,realname from lms_user_rel_group'
::
text
)
ug
(
user_id
bigint
,
group_id
bigint
,
realname
character
varying
);
src/test/java/resources/db_sql/hmhj/v147/20210714模板增加字段.sql
0 → 100644
View file @
7aae38b4
-- ghx
-- ghx
ALTER
TABLE
"public"
.
"original_template"
ADD
COLUMN
"tail_num"
int2
;
COMMENT
ON
COLUMN
"public"
.
"original_template"
.
"tail_num"
IS
'尾行数'
;
\ No newline at end of file
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