Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
c85952d3
Commit
c85952d3
authored
Nov 17, 2025
by
刘林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:(大屏):综合查询导出优化
parent
8cc27be1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
41 deletions
+105
-41
DataHandlerServiceImpl.java
...ot/module/jg/biz/service/impl/DataHandlerServiceImpl.java
+0
-0
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+105
-41
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/DataHandlerServiceImpl.java
View file @
c85952d3
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/service/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
View file @
c85952d3
...
...
@@ -2,6 +2,10 @@ package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -11,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.yeejoin.amos.boot.biz.common.annotation.TechnicalParameter
;
import
com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper
;
import
com.yeejoin.amos.boot.biz.common.dto.ByteArrayMultipartFile
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
com.yeejoin.amos.boot.biz.common.entity.DataDictionary
;
import
com.yeejoin.amos.boot.biz.common.excel.ExcelUtil
;
...
...
@@ -80,9 +85,11 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import
org.typroject.tyboot.core.foundation.exception.BaseException
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.io.File
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
...
...
@@ -94,7 +101,6 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.function.BiConsumer
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
static
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
biz
.
service
.
impl
.
TZSCommonServiceImpl
.*;
import
static
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
existsQuery
;
...
...
@@ -2697,51 +2703,109 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
private
static
MultipartFile
getEquipMultipartFile
(
JSONArray
records
,
String
fileName
,
String
sheetName
)
{
MultipartFile
templateExcelFile
;
List
<
EquipInfoVo
>
exportData
=
new
ArrayList
<>();
records
.
forEach
(
obj
->
{
JSONObject
equip
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
obj
));
EquipInfoVo
equipInfoVo
=
new
EquipInfoVo
();
BeanUtil
.
copyProperties
(
equip
,
equipInfoVo
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
// 最新一条检验信息
if
(!
equip
.
getJSONArray
(
"inspections"
).
isEmpty
())
{
JSONObject
inspection
=
equip
.
getJSONArray
(
"inspections"
).
getJSONObject
(
0
);
BeanUtil
.
copyProperties
(
inspection
,
equipInfoVo
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
}
// 最新一条维保信息
if
(!
equip
.
getJSONArray
(
"maintenances"
).
isEmpty
())
{
JSONObject
maintenances
=
equip
.
getJSONArray
(
"maintenances"
).
getJSONObject
(
0
);
BeanUtil
.
copyProperties
(
maintenances
,
equipInfoVo
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
}
Optional
.
of
(
equip
)
.
filter
(
e
->
"3000"
.
equals
(
String
.
valueOf
(
e
.
get
(
"EQU_LIST_CODE"
))))
.
filter
(
e
->
String
.
valueOf
(
e
.
get
(
"DATA_SOURCE"
)).
contains
(
"jg_his_xa"
))
.
map
(
e
->
String
.
valueOf
(
e
.
get
(
"SEQUENCE_NBR"
)))
.
ifPresent
(
equipInfoVo:
:
setRECORD
);
// 临时文件
File
tempFile
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
fileName
+
".xlsx"
);
ExcelWriter
excelWriter
=
null
;
try
{
excelWriter
=
EasyExcel
.
write
(
tempFile
,
EquipInfoVo
.
class
)
.
excelType
(
ExcelTypeEnum
.
XLSX
)
.
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
sheetName
).
build
();
List
<
EquipInfoVo
>
batchData
=
new
ArrayList
<>(
1000
);
// 每批 1000 条
for
(
Object
record
:
records
)
{
JSONObject
equip
=
(
JSONObject
)
record
;
Map
<
String
,
Object
>
combinedMap
=
new
HashMap
<>();
// 基础字段
equip
.
forEach
((
k
,
v
)
->
combinedMap
.
put
(
k
,
v
!=
null
?
String
.
valueOf
(
v
)
:
null
));
// 最新检验
JSONArray
inspections
=
equip
.
getJSONArray
(
"inspections"
);
if
(
inspections
!=
null
&&
!
inspections
.
isEmpty
())
{
JSONObject
inspection
=
inspections
.
getJSONObject
(
0
);
inspection
.
forEach
((
k
,
v
)
->
combinedMap
.
put
(
k
,
v
!=
null
?
String
.
valueOf
(
v
)
:
null
));
}
// 最新维保
JSONArray
maintenances
=
equip
.
getJSONArray
(
"maintenances"
);
if
(
maintenances
!=
null
&&
!
maintenances
.
isEmpty
())
{
JSONObject
maintenance
=
maintenances
.
getJSONObject
(
0
);
maintenance
.
forEach
((
k
,
v
)
->
combinedMap
.
put
(
k
,
v
!=
null
?
String
.
valueOf
(
v
)
:
null
));
}
// RECORD 特殊逻辑
if
(
"3000"
.
equals
(
String
.
valueOf
(
equip
.
get
(
"EQU_LIST_CODE"
)))
&&
String
.
valueOf
(
equip
.
get
(
"DATA_SOURCE"
)).
contains
(
"jg_his_xa"
))
{
combinedMap
.
put
(
"RECORD"
,
String
.
valueOf
(
equip
.
get
(
"SEQUENCE_NBR"
)));
}
// 技术参数
JSONArray
techParams
=
equip
.
getJSONArray
(
"techParams"
);
if
(
techParams
!=
null
&&
!
techParams
.
isEmpty
())
{
JSONObject
paramsJson
=
new
JSONObject
();
equip
.
getJSONArray
(
"techParams"
).
forEach
(
techParam
->
{
ESEquipmentInfo
.
TechParam
techParamItem
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
techParam
),
ESEquipmentInfo
.
TechParam
.
class
);
Optional
.
ofNullable
(
techParamItem
.
getParamKey
()).
ifPresent
(
key
->
Stream
.
of
(
Optional
.
ofNullable
(
techParamItem
.
getBoolValue
()),
Optional
.
ofNullable
(
techParamItem
.
getDateValue
()),
Optional
.
ofNullable
(
techParamItem
.
getLongValue
()),
Optional
.
ofNullable
(
techParamItem
.
getStrValue
()),
Optional
.
ofNullable
(
techParamItem
.
getDoubleValue
())
)
.
filter
(
Optional:
:
isPresent
)
.
findFirst
()
.
ifPresent
(
value
->
paramsJson
.
put
(
key
,
value
.
get
())));
});
BeanUtil
.
copyProperties
(
paramsJson
,
equipInfoVo
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
for
(
int
k
=
0
;
k
<
techParams
.
size
();
k
++)
{
JSONObject
param
=
techParams
.
getJSONObject
(
k
);
String
key
=
param
.
getString
(
"paramKey"
);
if
(
key
==
null
)
continue
;
Object
value
=
param
.
getOrDefault
(
"strValue"
,
param
.
getOrDefault
(
"boolValue"
,
param
.
getOrDefault
(
"dateValue"
,
param
.
getOrDefault
(
"longValue"
,
param
.
get
(
"doubleValue"
)))));
if
(
value
!=
null
)
{
combinedMap
.
put
(
key
,
String
.
valueOf
(
value
));
}
}
exportData
.
add
(
equipInfoVo
);
}
// Map → VO,并过滤非法日期
EquipInfoVo
vo
=
new
EquipInfoVo
();
combinedMap
.
replaceAll
((
k
,
v
)
->
{
if
(
v
!=
null
&&
v
.
toString
().
startsWith
(
"-0001"
))
return
null
;
// 过滤非法日期
return
v
;
});
templateExcelFile
=
ExcelUtil
.
createTemplateExcelFile
(
fileName
,
sheetName
,
exportData
,
EquipInfoVo
.
class
,
null
,
false
);
return
templateExcelFile
;
BeanUtil
.
copyProperties
(
combinedMap
,
vo
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
batchData
.
add
(
vo
);
// 批量写入
if
(
batchData
.
size
()
>=
1000
)
{
excelWriter
.
write
(
batchData
,
writeSheet
);
batchData
.
clear
();
}
}
// 写入剩余数据
if
(!
batchData
.
isEmpty
())
{
excelWriter
.
write
(
batchData
,
writeSheet
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"生成Excel失败"
,
e
);
}
finally
{
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
}
// 返回 MultipartFile
try
{
return
new
ByteArrayMultipartFile
(
fileName
,
fileName
+
".xlsx"
,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
,
Files
.
readAllBytes
(
tempFile
.
toPath
())
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"Excel文件读取失败"
,
e
);
}
finally
{
tempFile
.
delete
();
}
}
private
static
MultipartFile
getCompanyMultipartFile
(
JSONArray
records
,
String
fileName
,
String
sheetName
)
{
...
...
@@ -2751,7 +2815,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String
jsonString
=
JSON
.
toJSONString
(
company
);
CompanyInfoVo
companyInfoVo
=
JSONObject
.
parseObject
(
jsonString
,
CompanyInfoVo
.
class
);
JSONArray
licenses
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
JSON
.
parseObject
(
jsonString
).
get
(
"licenses"
)));
if
(!
licenses
.
isEmpty
(
))
{
if
(!
ObjectUtils
.
isEmpty
(
licenses
))
{
licenses
.
forEach
(
lic
->
{
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
lic
));
CompanyInfoVo
temp
=
jsonObject
.
toJavaObject
(
CompanyInfoVo
.
class
);
...
...
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