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
25b9c03a
Commit
25b9c03a
authored
Aug 08, 2025
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增获取es和数据库数据差异接口
parent
df850471
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
3 deletions
+108
-3
ComprehensiveStatisticalAnalysisController.java
...ontroller/ComprehensiveStatisticalAnalysisController.java
+16
-0
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+92
-3
No files found.
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/controller/ComprehensiveStatisticalAnalysisController.java
View file @
25b9c03a
...
@@ -508,4 +508,20 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
...
@@ -508,4 +508,20 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
public
ResponseModel
<
Object
>
updateDataByOrgBranchCode
(
@RequestParam
(
value
=
"code"
)
String
code
,
@RequestParam
(
value
=
"limit"
)
Integer
limit
)
{
public
ResponseModel
<
Object
>
updateDataByOrgBranchCode
(
@RequestParam
(
value
=
"code"
)
String
code
,
@RequestParam
(
value
=
"limit"
)
Integer
limit
)
{
return
ResponseHelper
.
buildResponse
(
statisticalAnalysisService
.
updateDataByOrgBranchCode
(
code
,
limit
));
return
ResponseHelper
.
buildResponse
(
statisticalAnalysisService
.
updateDataByOrgBranchCode
(
code
,
limit
));
}
}
/**
* @param
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/getDataDifference"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"获取es和数据库数据差异"
,
notes
=
"获取es和数据库数据差异"
)
public
ResponseModel
<
Object
>
getDataDifference
(
@RequestParam
(
value
=
"code"
)
String
code
)
{
return
ResponseHelper
.
buildResponse
(
statisticalAnalysisService
.
getDataDifference
(
code
));
}
}
}
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 @
25b9c03a
...
@@ -33,8 +33,14 @@ import com.yeejoin.amos.boot.module.statistics.api.vo.CompanyInfoVo;
...
@@ -33,8 +33,14 @@ import com.yeejoin.amos.boot.module.statistics.api.vo.CompanyInfoVo;
import
com.yeejoin.amos.boot.module.statistics.api.vo.EquipInfoVo
;
import
com.yeejoin.amos.boot.module.statistics.api.vo.EquipInfoVo
;
import
com.yeejoin.amos.boot.module.statistics.api.vo.PersonVo
;
import
com.yeejoin.amos.boot.module.statistics.api.vo.PersonVo
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel
;
import
com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
...
@@ -63,6 +69,7 @@ import org.springframework.core.io.Resource;
...
@@ -63,6 +69,7 @@ import org.springframework.core.io.Resource;
import
org.springframework.data.elasticsearch.annotations.FieldType
;
import
org.springframework.data.elasticsearch.annotations.FieldType
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
...
@@ -129,6 +136,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -129,6 +136,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private
final
EsEquipmentDao
esEquipmentDao
;
private
final
EsEquipmentDao
esEquipmentDao
;
private
final
IdxBizJgUseInfoMapper
idxBizJgUseInfoMapper
;
private
final
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
;
private
final
TzsUserInfoMapper
tzsUserInfoMapper
;
private
final
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
Runtime
.
getRuntime
().
availableProcessors
());
private
final
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
Runtime
.
getRuntime
().
availableProcessors
());
...
@@ -4099,10 +4110,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -4099,10 +4110,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
}
}
//4、是50*X的进行es和数据库的双向修改/不是50*X的只需要做数据库修改
//4、是50*X的进行es和数据库的双向修改/不是50*X的只需要做数据库修改
if
(!
ObjectUtils
.
isEmpty
(
allNotDateList
))
{
if
(!
ObjectUtils
.
isEmpty
(
allNotDateList
))
{
tzsCustomFilterMapper
.
setOrgBranchCodeIsNullByRecords
(
allNotDateList
);
tzsCustomFilterMapper
.
setOrgBranchCodeIsNullByRecords
(
allNotDateList
);
Iterable
<
ESEquipmentInfo
>
allById
=
esEquipmentDao
.
findAllById
(
allNotDateList
);
Iterable
<
ESEquipmentInfo
>
allById
=
esEquipmentDao
.
findAllById
(
allNotDateList
);
if
(!
ObjectUtils
.
isEmpty
(
allById
))
{
if
(!
ObjectUtils
.
isEmpty
(
allById
))
{
for
(
ESEquipmentInfo
esEquipmentInfo
:
allById
)
{
for
(
ESEquipmentInfo
esEquipmentInfo
:
allById
)
{
esEquipmentInfo
.
setORG_BRANCH_CODE
(
""
);
esEquipmentInfo
.
setORG_BRANCH_CODE
(
""
);
}
}
...
@@ -4110,7 +4121,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -4110,7 +4121,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
esEquipmentDao
.
saveAll
(
allById
);
esEquipmentDao
.
saveAll
(
allById
);
}
}
// 修改为es中的数据
// 修改为es中的数据
if
(!
ObjectUtils
.
isEmpty
(
dataList
))
{
if
(!
ObjectUtils
.
isEmpty
(
dataList
))
{
tzsCustomFilterMapper
.
updateOrgBranchCodeByRecords
(
dataList
);
tzsCustomFilterMapper
.
updateOrgBranchCodeByRecords
(
dataList
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -4118,4 +4129,81 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -4118,4 +4129,81 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
return
records
;
return
records
;
}
}
public
Object
getDataDifference
(
String
code
)
{
List
<
String
>
dataBase
=
new
ArrayList
<>();
List
<
String
>
esData
=
new
ArrayList
<>();
String
index
=
StatisticalAnalysisEnum
.
getKey
.
get
(
code
);
List
<
String
>
dataBaseAllList
=
new
ArrayList
<>();
List
<
String
>
esAllList
=
new
ArrayList
<>();
if
(
code
.
equals
(
StatisticalAnalysisEnum
.
equip
.
getCode
()))
{
LambdaQueryWrapper
<
IdxBizJgUseInfo
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
lambdaQueryWrapper
.
select
(
IdxBizJgUseInfo:
:
getRecord
);
List
<
IdxBizJgUseInfo
>
list
=
idxBizJgUseInfoMapper
.
selectList
(
lambdaQueryWrapper
);
dataBaseAllList
=
list
.
stream
().
map
(
IdxBizJgUseInfo:
:
getRecord
).
collect
(
Collectors
.
toList
());
}
else
if
(
code
.
equals
(
StatisticalAnalysisEnum
.
company
.
getCode
()))
{
LambdaQueryWrapper
<
TzBaseEnterpriseInfo
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
lambdaQueryWrapper
.
select
(
TzBaseEnterpriseInfo:
:
getUseCode
);
lambdaQueryWrapper
.
eq
(
TzBaseEnterpriseInfo:
:
getIsDelete
,
Boolean
.
FALSE
);
List
<
TzBaseEnterpriseInfo
>
list
=
tzBaseEnterpriseInfoMapper
.
selectList
(
lambdaQueryWrapper
);
dataBaseAllList
=
list
.
stream
().
map
(
TzBaseEnterpriseInfo:
:
getUseCode
).
collect
(
Collectors
.
toList
());
}
else
if
(
code
.
equals
(
StatisticalAnalysisEnum
.
person
.
getCode
()))
{
LambdaQueryWrapper
<
TzsUserInfo
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
lambdaQueryWrapper
.
select
(
TzsUserInfo:
:
getCertificateNum
);
lambdaQueryWrapper
.
eq
(
TzsUserInfo:
:
getIsDelete
,
Boolean
.
FALSE
);
lambdaQueryWrapper
.
isNotNull
(
TzsUserInfo:
:
getCertificateNum
);
List
<
TzsUserInfo
>
tzsUserInfos
=
tzsUserInfoMapper
.
selectList
(
lambdaQueryWrapper
);
dataBaseAllList
=
tzsUserInfos
.
stream
().
map
(
TzsUserInfo:
:
getCertificateNum
).
collect
(
Collectors
.
toList
());
}
SearchRequest
request
=
new
SearchRequest
();
request
.
indices
(
index
);
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
trackTotalHits
(
true
);
builder
.
from
(
0
);
builder
.
size
(
10000000
);
request
.
source
(
builder
);
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
hit
);
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
if
(
code
.
equals
(
StatisticalAnalysisEnum
.
equip
.
getCode
()))
{
esAllList
.
add
(
dto
.
getString
(
"id"
));
}
else
if
(
code
.
equals
(
StatisticalAnalysisEnum
.
company
.
getCode
()))
{
esAllList
.
add
(
dto
.
getString
(
"useCode"
));
}
else
if
(
code
.
equals
(
StatisticalAnalysisEnum
.
person
.
getCode
()))
{
esAllList
.
add
(
dto
.
getString
(
"certificateNum"
));
}
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
StopWatch
watch1
=
new
StopWatch
();
watch1
.
start
();
esData
=
findElementsInANotInB
(
esAllList
,
dataBaseAllList
);
watch1
.
stop
();
log
.
warn
(
"对比elementsInANotInB数据耗时:{}s"
,
watch1
.
getTotalTimeSeconds
());
StopWatch
watch2
=
new
StopWatch
();
watch2
.
start
();
dataBase
=
findElementsInANotInB
(
dataBaseAllList
,
esAllList
);
watch2
.
stop
();
log
.
warn
(
"对比elementsInBNotInA数据耗时:{}s"
,
watch2
.
getTotalTimeSeconds
());
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"dataBase"
,
dataBase
);
result
.
put
(
"esData"
,
esData
);
return
result
;
}
// 找出AList中不在BList中的元素
public
static
List
<
String
>
findElementsInANotInB
(
List
<
String
>
listA
,
List
<
String
>
listB
)
{
Set
<
String
>
bSet
=
Collections
.
synchronizedSet
(
new
HashSet
<>(
listB
));
return
listA
.
parallelStream
()
.
filter
(
element
->
!
bSet
.
contains
(
element
))
.
collect
(
Collectors
.
toList
());
}
}
}
\ No newline at end of file
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