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
189aeac5
Commit
189aeac5
authored
Nov 05, 2025
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(jg): 优化电梯数据保存逻辑与错误处理
- 增加对设备是否已登记的判断逻辑,避免重复历史登记 - 异常处理中增加堆栈信息记录,便于问题定位 - 保存失败时记录 traceInfo 信息到错误日志中 - 在异常信息中追加 record ID,方便追踪具体出错数据 - 修复历史登记判断逻辑,确保只对未登记设备执行历史登记操作
parent
48ff192d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
24 deletions
+49
-24
XiAnDataDockServiceImpl.java
...oin/amos/api/openapi/service/XiAnDataDockServiceImpl.java
+4
-4
ExcelImportErrorLogDto.java
...os/boot/module/common/api/dto/ExcelImportErrorLogDto.java
+3
-0
DataDockServiceImpl.java
.../boot/module/jg/biz/service/impl/DataDockServiceImpl.java
+42
-20
No files found.
amos-boot-data/amos-boot-data-openapi/src/main/java/com/yeejoin/amos/api/openapi/service/XiAnDataDockServiceImpl.java
View file @
189aeac5
...
...
@@ -775,11 +775,11 @@ public class XiAnDataDockServiceImpl {
*
* @param elevatorExcelDtos
*/
public
Map
<
String
,
String
>
batchSaveElevatorData
(
List
<
XiAnElevatorExcelDto
>
elevatorExcelDtos
)
{
public
Map
<
String
,
Object
>
batchSaveElevatorData
(
List
<
XiAnElevatorExcelDto
>
elevatorExcelDtos
)
{
log
.
info
(
"解析成功,准备上传数据,条数:{}"
,
elevatorExcelDtos
.
size
());
int
batchSize
=
1000
;
int
totalSize
=
elevatorExcelDtos
.
size
();
Map
<
String
,
String
>
rMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
rMap
=
new
HashMap
<>();
// 主线程中获取登录信息传递到异步线程中
RequestContextWrapper
contextWrapper
=
RequestContextWrapper
.
capture
();
Set
<
String
>
importResult
=
ConcurrentHashMap
.
newKeySet
();
// 使用线程安全的Set
...
...
@@ -817,8 +817,8 @@ public class XiAnDataDockServiceImpl {
// 等待所有异步任务完成
CompletableFuture
.
allOf
(
futures
.
toArray
(
new
CompletableFuture
[
0
])).
join
();
if
(!
ValidationUtil
.
isEmpty
(
importResult
))
{
rMap
.
put
(
"message"
,
"设备已做过后续业务或被编辑,更新失败:["
+
String
.
join
(
","
,
importResult
)
+
"]"
);
log
.
info
(
"
设备已做过后续业务或被编辑,更新失败:[{}"
,
String
.
join
(
","
,
importResult
)
+
"]"
);
rMap
.
put
(
"message"
,
importResult
);
log
.
info
(
"
更新失败:{}"
,
importResult
);
return
rMap
;
}
log
.
info
(
"设备保存成功"
);
...
...
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/ExcelImportErrorLogDto.java
View file @
189aeac5
...
...
@@ -26,4 +26,7 @@ public class ExcelImportErrorLogDto {
@Field
(
type
=
FieldType
.
Text
)
private
String
errorInfo
;
@Field
(
type
=
FieldType
.
Text
)
private
String
traceInfo
;
}
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/DataDockServiceImpl.java
View file @
189aeac5
...
...
@@ -16,6 +16,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
com.yeejoin.amos.boot.biz.common.bo.CompanyBo
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
...
...
@@ -514,11 +515,11 @@ public class DataDockServiceImpl {
* @param record
*/
private
void
saveSupervisionInfo
(
Map
<
String
,
Object
>
equ
,
String
record
)
{
log
.
error
(
"数据===>{}"
,
toJSONString
(
equ
));
log
.
info
(
"数据===>{}"
,
toJSONString
(
equ
));
IdxBizJgSupervisionInfo
oldSupervisionInfo
=
idxBizJgSupervisionInfoService
.
lambdaQuery
()
.
eq
(
IdxBizJgSupervisionInfo:
:
getRecord
,
record
).
one
();
IdxBizJgSupervisionInfo
supervisionInfo
=
JSON
.
parseObject
(
toJSONString
(
equ
),
IdxBizJgSupervisionInfo
.
class
);
log
.
error
(
"数据===hou>{}"
,
toJSONString
(
supervisionInfo
));
log
.
info
(
"数据===hou>{}"
,
toJSONString
(
supervisionInfo
));
if
(!
ValidationUtil
.
isEmpty
(
supervisionInfo
))
{
if
(!
ValidationUtil
.
isEmpty
(
oldSupervisionInfo
))
{
supervisionInfo
.
setSequenceNbr
(
oldSupervisionInfo
.
getSequenceNbr
());
...
...
@@ -2622,17 +2623,19 @@ public class DataDockServiceImpl {
@GlobalTransactional
(
rollbackFor
=
Exception
.
class
)
public
Set
<
String
>
saveElevatorData
(
List
<
Map
<
String
,
Object
>>
equLists
)
{
RequestContextWrapper
contextWrapper
=
RequestContextWrapper
.
capture
();
Set
<
String
>
recordSet
=
new
HashSet
<>
();
Set
<
String
>
inUseRecordSet
=
new
HashSet
<>
();
Set
<
String
>
recordSet
=
Sets
.
newConcurrentHashSet
();
Set
<
String
>
inUseRecordSet
=
Sets
.
newConcurrentHashSet
();
try
{
CompletableFuture
.
allOf
(
equLists
.
parallelStream
().
map
(
equ
->
CompletableFuture
.
runAsync
(()
->
{
contextWrapper
.
apply
();
String
record
=
saveElevatorDataInTransaction
(
equ
,
"jg_his_xa"
,
null
);
if
(
inUseError
.
equals
(
record
))
{
inUseRecordSet
.
add
(
equ
.
get
(
"record"
).
toString
());
}
else
{
recordSet
.
add
(
record
);
Object
resultObj
=
saveElevatorDataInTransaction
(
equ
,
"jg_his_xa"
,
null
);
if
(
resultObj
instanceof
String
)
{
recordSet
.
add
(
resultObj
.
toString
());
}
if
(
resultObj
instanceof
Map
)
{
Map
<
String
,
Object
>
result
=
(
Map
<
String
,
Object
>)
resultObj
;
inUseRecordSet
.
add
(
JSONObject
.
toJSONString
(
result
));
}
},
executorService
)).
toArray
(
CompletableFuture
[]::
new
)
).
join
();
...
...
@@ -2650,7 +2653,8 @@ public class DataDockServiceImpl {
}
@GlobalTransactional
(
rollbackFor
=
Exception
.
class
)
public
String
saveElevatorDataInTransaction
(
Map
<
String
,
Object
>
equ
,
String
dataSource
,
String
remark
)
{
public
Object
saveElevatorDataInTransaction
(
Map
<
String
,
Object
>
equ
,
String
dataSource
,
String
remark
)
{
Map
<
String
,
String
>
errorResult
=
Maps
.
newConcurrentMap
();
String
record
=
Optional
.
ofNullable
(
equ
.
get
(
"record"
)).
map
(
String:
:
valueOf
).
orElse
(
UUID
.
randomUUID
().
toString
());
String
equList
=
Optional
.
ofNullable
(
equ
.
get
(
"equList"
)).
map
(
String:
:
valueOf
).
orElse
(
""
);
String
businessId
=
Optional
.
ofNullable
(
equ
.
get
(
"businessId"
)).
map
(
String:
:
valueOf
).
orElse
(
""
);
...
...
@@ -2661,9 +2665,17 @@ public class DataDockServiceImpl {
// 判断设备是否已经做过除历史登记外的其他业务,如果做了其他业务则不能更新并记录反馈
Integer
useCount
=
commonMapper
.
countEquipInUseTimesForXaElevator
(
record
);
if
(
useCount
>
0
)
{
return
inUseError
;
errorResult
.
put
(
"id"
,
record
);
errorResult
.
put
(
"type"
,
"inUse"
);
errorResult
.
put
(
"msg"
,
inUseError
);
return
errorResult
;
}
// 判断是否做过历史登记
boolean
isRegistered
=
true
;
Map
<
String
,
Object
>
useRegistrationMap
=
jgUseRegistrationServiceImpl
.
getJgUseRegistrationMapper
().
getUseRegistrationDetail
(
record
);
if
(
ValidationUtil
.
isEmpty
(
useRegistrationMap
)
||
ValidationUtil
.
isEmpty
(
useRegistrationMap
.
get
(
"UseRegistratSequenceNbr"
)))
{
isRegistered
=
false
;
}
IdxBizJgUseInfo
oldUseInfo
=
idxBizJgUseInfoService
.
getOne
(
new
QueryWrapper
<
IdxBizJgUseInfo
>().
eq
(
"record"
,
record
));
IdxBizJgRegisterInfo
oldRegisterInfo
=
idxBizJgRegisterInfoService
.
getOne
(
new
QueryWrapper
<
IdxBizJgRegisterInfo
>().
eq
(
"record"
,
record
));
IdxBizJgUseInfo
useInfo
=
saveUseInfo
(
equ
,
record
,
dataSource
,
remark
,
null
);
saveDesignInfo
(
equ
,
record
);
...
...
@@ -2678,12 +2690,12 @@ public class DataDockServiceImpl {
saveEquInfoToEs
(
record
,
isCompleteXa
);
this
.
saveInstallInfo
(
equ
);
//安装信息
this
.
historyEquUpdateMaintenanceInfo
(
equ
);
//维保信息
//
oldUseInfo为空表示是新设备,新设备如果有使用登记证号则做历史登记,否则只进行上面的设备信息更新
if
(!
useRegistrationCode
.
isEmpty
()
&&
ValidationUtil
.
isEmpty
(
oldUseInfo
)
)
{
//
isRegistered=false是未做过登记设备,且有使用登记证号则做历史登记
if
(!
ValidationUtil
.
isEmpty
(
useRegistrationCode
)
&&
!
isRegistered
)
{
this
.
handleHistoryEquip
(
equ
);
//历史登记
}
//
oldUseInfo不为空表示是平台已有设备,已有历史设备则更新历史单据
信息。
if
(
!
ValidationUtil
.
isEmpty
(
oldUseInfo
)
)
{
//
isRegistered=true表示已做过历史平台登记,则需更新历史单据等
信息。
if
(
isRegistered
)
{
updateHistoryInfo
(
equ
,
registerInfo
,
otherInfo
,
oldRegisterInfo
,
useInfo
);
}
}
else
if
(!
businessId
.
isEmpty
())
{
...
...
@@ -2699,14 +2711,24 @@ public class DataDockServiceImpl {
}
return
record
;
}
catch
(
Exception
e
)
{
// esEquipmentCategory.deleteById(record);
String
traceInfo
=
Arrays
.
stream
(
e
.
getStackTrace
()).
filter
(
x
->
x
.
getClassName
().
contains
(
"com.yeejoin"
)).
map
(
x
->
x
.
getClassName
()
+
"."
+
x
.
getMethodName
()
+
":"
+
x
.
getLineNumber
()).
collect
(
Collectors
.
toList
()).
toString
();
esEquipmentCategory
.
deleteById
(
record
);
// superviseInfoMapper.deleteDataAll(Collections.singletonList(record));
ExcelImportErrorLogDto
errorLogDto
=
JSON
.
parseObject
(
toJSONString
(
equ
),
ExcelImportErrorLogDto
.
class
);
errorLogDto
.
setErrorInfo
(
e
.
getMessage
());
errorLogDto
.
setTraceInfo
(
traceInfo
);
excelImportErrorLogDao
.
save
(
errorLogDto
);
String
errorMessage
=
e
.
getMessage
();
if
(
errorMessage
==
null
)
{
errorMessage
=
"Unknown error occurred: "
+
e
.
getClass
().
getName
();
}
log
.
error
(
"{}数据:保存时出现异常,对应数据:{}"
,
dataSource
,
toJSONString
(
equ
),
e
);
log
.
error
(
"==========================西安电梯数据:保存时出现异常,对应数据:{}=========================="
,
record
);
throw
new
RuntimeException
(
"保存电梯数据失败:"
+
e
.
getMessage
());
errorResult
.
put
(
"id"
,
record
);
errorResult
.
put
(
"type"
,
"error"
);
errorResult
.
put
(
"msg"
,
errorMessage
);
errorResult
.
put
(
"traceInfo"
,
traceInfo
);
return
errorResult
;
}
}
...
...
@@ -3046,7 +3068,7 @@ public class DataDockServiceImpl {
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
this
.
rollBackForDelRedisData
();
throw
new
BadRequest
(
e
.
getMessage
());
throw
new
BadRequest
(
e
.
getMessage
()
+
"["
+
map
.
get
(
"record"
)
+
"]"
);
}
finally
{
FlowingEquipRedisContext
.
clean
();
}
...
...
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