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
0b6225ae
Commit
0b6225ae
authored
Mar 31, 2025
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(amos-boot-module-jg): 优化设备问题处理逻辑- 修复了设备问题处理时的状态更新逻辑
- 优化了代码结构,提高了可读性和可维护性 - 添加了日志记录,便于问题排查 -优化了 SQL 查询,提高了查询效率
parent
ce7ba6ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
16 deletions
+65
-16
CommonMapper.xml
...-module-jg-api/src/main/resources/mapper/CommonMapper.xml
+1
-1
EquipmentProblemStrategy.java
...ule/jg/biz/handler/strategy/EquipmentProblemStrategy.java
+64
-15
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/resources/mapper/CommonMapper.xml
View file @
0b6225ae
...
@@ -2697,7 +2697,7 @@
...
@@ -2697,7 +2697,7 @@
LEFT JOIN idx_biz_jg_supervision_info si on si."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_supervision_info si on si."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_factory_info fi on fi."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_factory_info fi on fi."RECORD" = ui."RECORD"
WHERE ui."USE_DATE" is not null and ui."IS_INTO_MANAGEMENT" = true and ri."EQU_LIST" = '2000' and di."DESIGN_USE_DATE" is not null
WHERE ui."USE_DATE" is not null and ui."IS_INTO_MANAGEMENT" = true and ri."EQU_LIST" = '2000' and di."DESIGN_USE_DATE" is not null
and ui."USE_DATE" not in ('null','不详','/') and di."DESIGN_USE_DATE" not in ('null','不详','/') and di.
OVER_DESIGN_REG_NUM
= 0
and ui."USE_DATE" not in ('null','不详','/') and di."DESIGN_USE_DATE" not in ('null','不详','/') and di.
"OVER_DESIGN_REG_NUM"
= 0
) t where t.isExpired = true
) t where t.isExpired = true
UNION ALL
UNION ALL
select * from (
select * from (
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/handler/strategy/EquipmentProblemStrategy.java
View file @
0b6225ae
...
@@ -11,15 +11,17 @@ import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgOtherInfoService
...
@@ -11,15 +11,17 @@ import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgOtherInfoService
import
com.yeejoin.amos.boot.module.jg.biz.service.impl.SafetyProblemTracingServiceImpl
;
import
com.yeejoin.amos.boot.module.jg.biz.service.impl.SafetyProblemTracingServiceImpl
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgOtherInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgOtherInfo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.util.
List
;
import
java.util.
*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Component
(
"equipmentProblemStrategy"
)
@Component
(
"equipmentProblemStrategy"
)
@RequiredArgsConstructor
@RequiredArgsConstructor
@Slf4j
public
class
EquipmentProblemStrategy
implements
ProblemHandleStrategy
{
public
class
EquipmentProblemStrategy
implements
ProblemHandleStrategy
{
private
final
SafetyProblemTracingServiceImpl
safetyProblemTracingService
;
private
final
SafetyProblemTracingServiceImpl
safetyProblemTracingService
;
...
@@ -29,21 +31,68 @@ public class EquipmentProblemStrategy implements ProblemHandleStrategy {
...
@@ -29,21 +31,68 @@ public class EquipmentProblemStrategy implements ProblemHandleStrategy {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
handleProblem
(
JSONArray
jsonArray
,
SafetyProblemTypeEnum
problemTypeEnum
)
{
public
void
handleProblem
(
JSONArray
jsonArray
,
SafetyProblemTypeEnum
problemTypeEnum
)
{
List
<
String
>
equipRecords
=
jsonArray
.
stream
().
map
(
obj
->
JSONObject
.
parseObject
(
obj
.
toString
()).
getString
(
"record"
)).
collect
(
Collectors
.
toList
());
if
(
ValidationUtil
.
isEmpty
(
jsonArray
))
{
if
(!
ValidationUtil
.
isEmpty
(
equipRecords
))
{
return
;
safetyProblemTracingService
.
lambdaUpdate
()
}
.
set
(
SafetyProblemTracing:
:
getProblemStatusCode
,
SafetyProblemStatusEnum
.
HANDLED
.
getCode
())
log
.
info
(
"安全追溯-设备问题处理接收数据:---> {}"
,
jsonArray
);
.
set
(
SafetyProblemTracing:
:
getProblemStatus
,
SafetyProblemStatusEnum
.
HANDLED
.
getName
())
List
<
String
>
equipRecords
=
jsonArray
.
stream
()
.
in
(
SafetyProblemTracing:
:
getSourceId
,
equipRecords
)
.
map
(
obj
->
JSONObject
.
parseObject
(
obj
.
toString
()).
getString
(
"record"
))
.
eq
(
SafetyProblemTracing:
:
getProblemTypeCode
,
problemTypeEnum
.
getCode
()).
update
();
.
collect
(
Collectors
.
toList
());
idxBizJgOtherInfoService
.
lambdaUpdate
().
set
(
IdxBizJgOtherInfo:
:
getStatus
,
SafetyProblemStatusEnum
.
HANDLED
.
getCode
())
if
(
ValidationUtil
.
isEmpty
(
equipRecords
))
{
.
in
(
IdxBizJgOtherInfo:
:
getRecord
,
equipRecords
).
update
();
return
;
Iterable
<
ESEquipmentCategoryDto
>
equipEsDtoIter
=
esEquipmentCategory
.
findAllById
(
equipRecords
);
}
for
(
ESEquipmentCategoryDto
equipEsDto
:
equipEsDtoIter
)
{
log
.
info
(
"安全追溯-设备问题处理设备record:---> {}"
,
equipRecords
);
equipEsDto
.
setProblemStatus
(
SafetyProblemStatusEnum
.
HANDLED
.
getCode
());
}
// 更新问题状态为已处理
esEquipmentCategory
.
saveAll
(
equipEsDtoIter
);
safetyProblemTracingService
.
lambdaUpdate
()
.
set
(
SafetyProblemTracing:
:
getProblemStatusCode
,
SafetyProblemStatusEnum
.
HANDLED
.
getCode
())
.
set
(
SafetyProblemTracing:
:
getProblemStatus
,
SafetyProblemStatusEnum
.
HANDLED
.
getName
())
.
in
(
SafetyProblemTracing:
:
getSourceId
,
equipRecords
)
.
eq
(
SafetyProblemTracing:
:
getProblemTypeCode
,
problemTypeEnum
.
getCode
())
.
update
();
// 查询仍存在未处理问题的设备
Set
<
String
>
problemEquipIds
=
safetyProblemTracingService
.
lambdaQuery
()
.
select
(
SafetyProblemTracing:
:
getSourceId
)
.
in
(
SafetyProblemTracing:
:
getSourceId
,
equipRecords
)
.
eq
(
SafetyProblemTracing:
:
getProblemStatusCode
,
SafetyProblemStatusEnum
.
UNHANDLED
.
getCode
())
.
list
().
stream
().
map
(
SafetyProblemTracing:
:
getSourceId
).
collect
(
Collectors
.
toCollection
(
HashSet:
:
new
));
// 确定无未处理问题的设备列表
List
<
String
>
resolvedRecords
=
equipRecords
.
stream
()
.
filter
(
record
->
!
problemEquipIds
.
contains
(
record
))
.
collect
(
Collectors
.
toCollection
(
ArrayList:
:
new
));
// 更新无未处理问题的设备状态
if
(!
ValidationUtil
.
isEmpty
(
resolvedRecords
))
{
log
.
info
(
"可更新状态的设备record:---> {}"
,
resolvedRecords
);
updateOtherTableAndES
(
resolvedRecords
);
}
log
.
info
(
"安全追溯-设备问题处理完成!"
);
}
/**
* 更新Other表和ES状态(提取公共方法)
*/
private
void
updateOtherTableAndES
(
List
<
String
>
records
)
{
// 更新Other表
idxBizJgOtherInfoService
.
lambdaUpdate
()
.
set
(
IdxBizJgOtherInfo:
:
getStatus
,
SafetyProblemStatusEnum
.
HANDLED
.
getCode
())
.
in
(
IdxBizJgOtherInfo:
:
getRecord
,
records
)
.
update
();
// 更新ES状态(添加异常处理)
try
{
Iterable
<
ESEquipmentCategoryDto
>
esEquipmentIter
=
esEquipmentCategory
.
findAllById
(
records
);
esEquipmentIter
.
forEach
(
dto
->
dto
.
setProblemStatus
(
SafetyProblemStatusEnum
.
HANDLED
.
getCode
()));
esEquipmentCategory
.
saveAll
(
esEquipmentIter
);
log
.
info
(
"ES状态更新成功,记录数:{}"
,
records
.
size
());
}
catch
(
Exception
e
)
{
log
.
error
(
"ES状态更新失败,设备record:{},错误原因:{}"
,
records
,
e
.
getMessage
(),
e
);
}
}
}
}
}
}
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