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
6db7fd84
Commit
6db7fd84
authored
Sep 02, 2025
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(amos-boot-module-tcm): 重构企业信息更新逻辑- 新增更新企业信息和设备信息的方法
- 优化数据处理流程,提高代码复用性- 改进日志记录,增加详细的信息输出 - 注释掉数据刷新事件的调用,留待后续处理
parent
ca9c7553
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
21 deletions
+63
-21
TzBaseEnterpriseInfoServiceImpl.java
...tcm/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+63
-21
No files found.
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
6db7fd84
...
...
@@ -19,8 +19,12 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant
;
import
com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory
;
import
com.yeejoin.amos.boot.module.common.api.dao.EsBaseEnterpriseInfoDao
;
import
com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao
;
import
com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.UserPermissionDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo
;
import
com.yeejoin.amos.boot.module.common.api.entity.EsBaseEnterpriseInfo
;
import
com.yeejoin.amos.boot.module.common.api.enums.UnitDataSourceEnum
;
import
com.yeejoin.amos.boot.module.common.biz.event.CommonPublisher
;
import
com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent
;
...
...
@@ -74,6 +78,8 @@ import java.nio.charset.StandardCharsets;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.BiConsumer
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -137,6 +143,12 @@ public class TzBaseEnterpriseInfoServiceImpl
@Autowired
private
ESEquipmentCategory
esEquipmentCategory
;
@Autowired
private
EsEquipmentDao
esEquipmentDao
;
@Autowired
private
EsBaseEnterpriseInfoDao
esBaseEnterpriseInfoDao
;
private
static
final
Map
<
String
,
String
>
JYJC_CERT_MAP
=
new
HashMap
<>();
@Autowired
...
...
@@ -1471,11 +1483,15 @@ public class TzBaseEnterpriseInfoServiceImpl
log
.
info
(
"end-查询旧属地监管部门orgCode对应的所有设备equipmentRecordList:{},companySeqList:{}"
,
equipmentRecordList
.
size
(),
companySeqList
.
size
());
// 4. 更新idx_biz_view_jg_all es设备信息
updateEquipmentJgAllEs
(
newOrgCode
,
oldOrgCode
,
equipmentRecordList
,
newModel
.
getString
(
"companyName"
));
// 5. 发送数据刷新事件 - 内存分页处理
// 处理企业数据
publishDataRefreshEvents
(
companySeqList
,
DataRefreshEvent
.
DataType
.
enterprise
,
1000
);
// 处理设备数据
publishDataRefreshEvents
(
equipmentRecordList
,
DataRefreshEvent
.
DataType
.
equipment
,
1000
);
// 5. 更新idx_biz_enterprise_info es企业信息
updateEnterpriseInfoEs
(
newOrgCode
,
oldOrgCode
,
companySeqList
);
// 6. 更新idx_biz_equipment_info es设备信息
updateEquipmentInfoEs
(
newOrgCode
,
oldOrgCode
,
equipmentRecordList
);
// // 5. 发送数据刷新事件 - 内存分页处理
// // 处理企业数据
// publishDataRefreshEvents(companySeqList, DataRefreshEvent.DataType.enterprise, 1000);
// // 处理设备数据
// publishDataRefreshEvents(equipmentRecordList, DataRefreshEvent.DataType.equipment, 1000);
}
}
catch
(
Exception
e
)
{
willInfo
(
"refreshCompanyOrgCode"
,
dataResult
,
"orgCodeUpdate"
,
e
);
...
...
@@ -1484,32 +1500,58 @@ public class TzBaseEnterpriseInfoServiceImpl
log
.
info
(
"刷新单位orgCode结束"
);
}
private
void
updateEquipment
JgAllEs
(
String
newOrgCode
,
String
oldOrgCode
,
List
<
String
>
equipmentRecordList
,
String
supervisionName
)
{
log
.
info
(
"开始更新idx_biz_
view_jg_all
es设备属地监管部门信息,新orgCode{}, 旧orgCode:{}"
,
newOrgCode
,
oldOrgCode
);
private
void
updateEquipment
InfoEs
(
String
newOrgCode
,
String
oldOrgCode
,
List
<
String
>
equipmentRecordList
)
{
log
.
info
(
"开始更新idx_biz_
equipment_info
es设备属地监管部门信息,新orgCode{}, 旧orgCode:{}"
,
newOrgCode
,
oldOrgCode
);
if
(!
ValidationUtil
.
isEmpty
(
equipmentRecordList
))
{
log
.
info
(
"待更新equipmentRecordList数量:{}"
,
equipmentRecordList
.
size
());
updateEsInfo
(
newOrgCode
,
oldOrgCode
,
equipmentRecordList
,
esEquipmentDao:
:
findAllById
,
ESEquipmentInfo:
:
setORG_BRANCH_CODE
,
ESEquipmentInfo:
:
getORG_BRANCH_CODE
,
esEquipmentDao:
:
saveAll
);
}
log
.
info
(
"更新idx_biz_equipment_info es设备属地监管部门信息结束"
);
}
private
void
updateEnterpriseInfoEs
(
String
newOrgCode
,
String
oldOrgCode
,
List
<
String
>
companySeqList
)
{
log
.
info
(
"开始更新idx_biz_enterprise_info es企业属地监管部门信息,新orgCode{}, 旧orgCode:{}"
,
newOrgCode
,
oldOrgCode
);
if
(!
ValidationUtil
.
isEmpty
(
companySeqList
))
{
updateEsInfo
(
newOrgCode
,
oldOrgCode
,
companySeqList
,
esBaseEnterpriseInfoDao:
:
findAllById
,
EsBaseEnterpriseInfo:
:
setSuperviseOrgCode
,
EsBaseEnterpriseInfo:
:
getSuperviseOrgCode
,
esBaseEnterpriseInfoDao:
:
saveAll
);
}
log
.
info
(
"更新idx_biz_enterprise_info es设备属地监管部门信息结束"
);
}
private
<
T
>
void
updateEsInfo
(
String
newOrgCode
,
String
oldOrgCode
,
List
<
String
>
recordList
,
Function
<
List
<
String
>,
Iterable
<
T
>>
findAllByIdFunc
,
BiConsumer
<
T
,
String
>
updateOrgCodeFunc
,
Function
<
T
,
String
>
getOrgCodeFunc
,
Consumer
<
List
<
T
>>
saveAllFunc
)
{
log
.
info
(
"待更新es recordList数量:{}"
,
recordList
.
size
());
int
batchSize
=
1000
;
for
(
int
i
=
0
;
i
<
equipmentR
ecordList
.
size
();
i
+=
batchSize
)
{
int
endIndex
=
Math
.
min
(
i
+
batchSize
,
equipmentR
ecordList
.
size
());
List
<
String
>
subList
=
equipmentR
ecordList
.
subList
(
i
,
endIndex
);
for
(
int
i
=
0
;
i
<
r
ecordList
.
size
();
i
+=
batchSize
)
{
int
endIndex
=
Math
.
min
(
i
+
batchSize
,
r
ecordList
.
size
());
List
<
String
>
subList
=
r
ecordList
.
subList
(
i
,
endIndex
);
Iterable
<
ESEquipmentCategoryDto
>
equipmentCategoryIterator
=
esEquipmentCategory
.
findAllById
(
subList
);
List
<
ESEquipmentCategoryDto
>
updatedCategories
=
new
ArrayList
<>();
Iterable
<
T
>
recordIterator
=
findAllByIdFunc
.
apply
(
subList
);
List
<
T
>
updatedRecord
=
new
ArrayList
<>();
equipmentCategoryIterator
.
forEach
(
equipmentCategory
->
{
if
(
ValidationUtil
.
isEmpty
(
equipmentCategory
.
getOrgBranchCode
()))
{
equipmentCategory
.
setOrgBranchCode
(
newOrgCode
);
// 补偿旧数据es属地监管部门为空,则用数据库中设备属地监管部门更新
recordIterator
.
forEach
(
record
->
{
String
equipOrgBranchCode
=
getOrgCodeFunc
.
apply
(
record
);
if
(
ValidationUtil
.
isEmpty
(
equipOrgBranchCode
))
{
updateOrgCodeFunc
.
accept
(
record
,
newOrgCode
);
// 补偿旧数据es属地监管部门为空,则用数据库中设备属地监管部门更新
}
else
{
equipmentCategory
.
setOrgBranchCode
(
equipmentCategory
.
getOrgBranchCode
().
replace
(
oldOrgCode
,
newOrgCode
));
String
updatedOrgCode
=
equipOrgBranchCode
.
replace
(
oldOrgCode
,
newOrgCode
);
updateOrgCodeFunc
.
accept
(
record
,
updatedOrgCode
);
}
updatedCategories
.
add
(
equipmentCategory
);
updatedRecord
.
add
(
record
);
});
if
(!
updatedCategories
.
isEmpty
())
{
log
.
info
(
"待更新updatedCategories数量:{}"
,
updatedCategories
.
size
());
esEquipmentCategory
.
saveAll
(
updatedCategories
);
if
(!
updatedRecord
.
isEmpty
())
{
log
.
info
(
"待更新updatedRecord数量:{}"
,
updatedRecord
.
size
());
saveAllFunc
.
accept
(
updatedRecord
);
}
}
}
private
void
updateEquipmentJgAllEs
(
String
newOrgCode
,
String
oldOrgCode
,
List
<
String
>
equipmentRecordList
,
String
supervisionName
)
{
log
.
info
(
"开始更新idx_biz_view_jg_all es设备属地监管部门信息,新orgCode{}, 旧orgCode:{}"
,
newOrgCode
,
oldOrgCode
);
if
(!
ValidationUtil
.
isEmpty
(
equipmentRecordList
))
{
updateEsInfo
(
newOrgCode
,
oldOrgCode
,
equipmentRecordList
,
esEquipmentCategory:
:
findAllById
,
ESEquipmentCategoryDto:
:
setOrgBranchCode
,
ESEquipmentCategoryDto:
:
getOrgBranchCode
,
esEquipmentCategory:
:
saveAll
);
}
// 根据旧属地监管部门orgCode查找es对应设备,更新数据库中设备属地字段
List
<
ESEquipmentCategoryDto
>
esEquipmentCategoryList
=
esEquipmentCategory
.
findByOrgBranchCodeKeywordStartingWith
(
oldOrgCode
);
...
...
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