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
940860c8
Commit
940860c8
authored
Jun 08, 2022
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改霍煤因特殊字符没有写入报告文件问题;
parent
95b4394e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
139 deletions
+12
-139
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+12
-139
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
940860c8
...
...
@@ -1448,13 +1448,12 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
handleSampleBrand
(
ids
,
finalSampleBrandMap
,
false
);
// 处理一级编码的报告文件
handleSampleBrand
(
ids
,
finalSampleBrandMap
,
true
);
});
executor1
.
execute
(()
->
{
// 针对铝成品和原铝进行发送ERP数据处理
logger
.
error
(
"{}开始执行发送ERP请求:---->ERP---"
,
DateUtils
.
toYearMonthDayTime
(
new
Date
()));
sendTestDataToErp
(
Arrays
.
asList
(
ids
),
finalSampleBrandMap
);
});
logger
.
error
(
"======================质量判定结束========================"
);
return
true
;
}
...
...
@@ -1658,141 +1657,6 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return
StringUtils
.
isBlank
(
value
)
?
""
:
value
.
trim
();
}
/**
* 牌号处理
*
* @param ids
*/
private
void
handleSampleBrand
(
Long
[]
ids
,
Boolean
isOther
)
{
if
(
null
==
ids
||
0
==
ids
.
length
)
{
return
;
}
List
<
ReportSampleVO
>
reportSampleList
=
entrustSampleService
.
getReportBrands
(
ids
);
if
(
CollectionUtils
.
isEmpty
(
reportSampleList
))
{
return
;
}
Boolean
finalIsOther
=
null
!=
isOther
&&
isOther
;
List
<
EntrustReport
>
reportList
=
new
ArrayList
<>();
// objectKey data
Map
<
String
,
Long
>
objReportMap
=
reportSampleList
.
stream
().
collect
(
Collectors
.
toMap
(
t
->
{
return
finalIsOther
?
t
.
getOtherObjectKey
()
:
t
.
getObjectKey
();
},
ReportSampleVO:
:
getReportId
,
(
v1
,
v2
)
->
v1
));
for
(
Map
.
Entry
<
String
,
Long
>
entry
:
objReportMap
.
entrySet
())
{
EntrustReport
entrustReport
=
new
EntrustReport
();
String
objectKey
=
entry
.
getKey
();
Long
reportId
=
entry
.
getValue
();
entrustReport
.
setId
(
reportId
);
Map
<
String
,
String
>
sampleMap
=
null
;
// 根据是否一级编码确定使用得objectKey
if
(
finalIsOther
)
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
t
.
getOtherObjectKey
().
equals
(
objectKey
)).
collect
(
Collectors
.
toMap
(
ReportSampleVO:
:
getFirstCode
,
ReportSampleVO:
:
getSampleGrading
));
}
else
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
t
.
getObjectKey
().
equals
(
objectKey
)).
collect
(
Collectors
.
toMap
(
t
->
{
if
(
StringUtils
.
isNotBlank
(
t
.
getThirdCode
()))
{
return
t
.
getThirdCode
();
}
else
if
(
StringUtils
.
isNotBlank
(
t
.
getSecondCode
()))
{
return
t
.
getSecondCode
();
}
return
t
.
getFirstCode
();
},
ReportSampleVO:
:
getSampleGrading
));
}
if
(
StringUtils
.
isBlank
(
objectKey
))
{
continue
;
}
InputStream
io
=
ossClient
.
download
(
objectKey
);
//结果回调
XSSFWorkbook
xssfWorkbook
=
null
;
try
{
xssfWorkbook
=
new
XSSFWorkbook
(
io
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
.
getCause
());
continue
;
}
XSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
0
);
int
rowNum
=
sheet
.
getLastRowNum
();
// 默认开始行为:5,单元格序号为:-1
int
startRow
=
5
,
sampleCodePos
=
-
1
,
sampleBrandPos
=
-
1
;
flag:
for
(
int
i
=
1
;
i
<
rowNum
;
i
++)
{
startRow
=
i
;
XSSFRow
xssfRow
=
sheet
.
getRow
(
i
);
for
(
int
j
=
0
;
j
<
xssfRow
.
getLastCellNum
();
j
++)
{
String
title
=
getCellValue
(
xssfRow
,
j
);
if
(
"试样编号"
.
equals
(
title
))
{
sampleCodePos
=
j
;
}
if
(
"牌号"
.
equals
(
title
))
{
sampleBrandPos
=
j
;
break
flag
;
}
}
}
// 若循环无牌号,那么跳过本次循环的原始记录
if
(-
1
==
sampleBrandPos
)
{
continue
;
}
for
(
int
i
=
startRow
+
1
;
i
<
rowNum
;
i
++)
{
XSSFRow
xssfRow
=
sheet
.
getRow
(
i
);
String
sampleCode
=
getCellValue
(
xssfRow
,
sampleCodePos
);
if
(
StringUtils
.
isBlank
(
sampleCode
))
{
continue
;
}
String
sampleGrading
=
sampleMap
.
get
(
sampleCode
);
if
(
StringUtils
.
isNotBlank
(
sampleGrading
))
{
xssfRow
.
getCell
(
sampleBrandPos
).
setCellValue
(
sampleGrading
);
}
}
FileOutputStream
os
=
null
;
File
file
=
null
;
String
generated
=
"报告记录修改"
;
try
{
file
=
File
.
createTempFile
(
generated
,
".xlsx"
);
os
=
new
FileOutputStream
(
file
);
xssfWorkbook
.
write
(
os
);
os
.
flush
();
OssFileResult
fileResult
=
ossClient
.
upload
(
file
);
if
(
null
!=
fileResult
)
{
if
(
finalIsOther
)
{
entrustReport
.
setOtherObjectKey
(
fileResult
.
getObjectKey
());
}
else
{
entrustReport
.
setObjectKey
(
fileResult
.
getObjectKey
());
}
reportList
.
add
(
entrustReport
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"Exception 报错"
+
e
.
getMessage
());
e
.
printStackTrace
();
}
finally
{
try
{
os
.
close
();
xssfWorkbook
.
close
();
io
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
FileUtils
.
deleteFiles
(
file
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
reportList
))
{
entrustReportService
.
updateBatchById
(
reportList
);
// Long[] reportIds = reportList.stream().map(EntrustReport::getId).collect(Collectors.toList()).toArray(new Long[reportList.size()]);
// 重新生成pdf文件
// entrustReportService.changeExcelReportToPdf(reportIds);
}
}
@Override
public
List
<
EntrustSampleItemVO
>
listMinStatusBySampleIds
(
List
<
Long
>
sampleIds
)
{
return
baseMapper
.
selectMinStatusBySampleIds
(
sampleIds
);
...
...
@@ -2102,6 +1966,15 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return
baseMapper
.
updateSampleRetakeInfoByEntrustId
(
entrustId
);
}
private
String
getHandleValue
(
String
s
,
String
def
)
{
def
=
null
==
def
?
""
:
def
;
return
StringUtils
.
isBlank
(
s
)
?
def
:
s
;
}
private
String
getHandleValue
(
String
s
)
{
return
getHandleValue
(
s
,
""
);
}
protected
void
handleSampleBrand
(
Long
[]
ids
,
Map
<
Long
,
String
>
brandMap
,
boolean
isOther
)
{
// 对数据处理
if
(
ArrayUtils
.
isEmpty
(
ids
)
||
MapUtils
.
isEmpty
(
brandMap
))
{
...
...
@@ -2136,7 +2009,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
// 根据是否一级编码确定使用得objectKey
if
(
finalIsOther
)
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
Objects
.
equals
(
t
.
getOtherObjectKey
(),
objectKey
))
.
collect
(
Collectors
.
toMap
(
ReportSampleVO:
:
getFirstCode
,
ReportSampleVO:
:
getSampleGrading
));
.
collect
(
Collectors
.
toMap
(
ReportSampleVO:
:
getFirstCode
,
t
->
getHandleValue
(
t
.
getSampleGrading
())
));
}
else
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
Objects
.
equals
(
objectKey
,
t
.
getObjectKey
()))
.
collect
(
Collectors
.
toMap
(
t
->
{
...
...
@@ -2146,7 +2019,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return
t
.
getSecondCode
();
}
return
t
.
getFirstCode
();
},
ReportSampleVO:
:
getSampleGrading
)
},
v
->
getHandleValue
(
v
.
getSampleGrading
())
)
);
}
...
...
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