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
c14c28cc
Commit
c14c28cc
authored
Aug 04, 2025
by
刘林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(jg):删除不是已认领的数据接口
parent
f1f1879b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
3 deletions
+98
-3
DataHandlerController.java
.../boot/module/jg/biz/controller/DataHandlerController.java
+12
-0
DataHandlerServiceImpl.java
...ot/module/jg/biz/service/impl/DataHandlerServiceImpl.java
+86
-3
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/controller/DataHandlerController.java
View file @
c14c28cc
...
...
@@ -283,4 +283,15 @@ public class DataHandlerController extends BaseController {
return
ResponseHelper
.
buildResponse
(
dataHandlerService
.
initFactoryCarNumber2Es
());
}
/**
* @apiNote 删除ES和数据库中状态≠已认领的设备
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"PUT"
,
value
=
"删除ES和数据库中状态≠已认领的设备(备份后谨慎操作,不可恢复)"
,
notes
=
"删除ES和数据库中状态≠已认领的设备(备份后谨慎操作,不可恢复)"
)
@PutMapping
(
value
=
"/equip/deleteEquipWithStatusNotInClaimed"
)
public
ResponseModel
<
Integer
>
deleteEquipWithStatusNotInClaimed
(
@RequestParam
(
value
=
"indices"
,
defaultValue
=
"idx_biz_view_jg_all"
)
String
indices
)
{
return
ResponseHelper
.
buildResponse
(
dataHandlerService
.
deleteEquipWithStatusNotInClaimed
(
indices
));
}
}
\ No newline at end of file
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 @
c14c28cc
...
...
@@ -53,6 +53,8 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -60,7 +62,7 @@ import org.springframework.util.ObjectUtils;
import
org.springframework.util.StopWatch
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.sql.Timestamp
;
...
...
@@ -72,7 +74,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
static
com
.
alibaba
.
fastjson
.
JSON
.
toJSONString
;
import
static
com
.
yeejoin
.
amos
.
boot
.
module
.
jg
.
biz
.
service
.
impl
.
JgInstallationNoticeServiceImpl
.
CONSTRUCTION_TYPE
;
import
static
com
.
yeejoin
.
amos
.
boot
.
module
.
jg
.
biz
.
service
.
impl
.
JgInstallationNoticeServiceImpl
.
CONSTRUCTION_TYPE_NAME
;
...
...
@@ -84,7 +85,12 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNot
@Service
@RequiredArgsConstructor
public
class
DataHandlerServiceImpl
{
public
static
final
String
IDX_BIZ_VIEW_JG_ALL
=
"idx_biz_view_jg_all"
;
public
static
final
String
IDX_BIZ_EQUIPMENT_INFO
=
"idx_biz_equipment_info"
;
public
static
final
String
STATUS
=
"STATUS"
;
public
static
final
String
record
=
"record"
;
public
static
final
String
SEQUENCE_NBR
=
"SEQUENCE_NBR"
;
private
static
final
int
BATCH_SIZE
=
1000
;
private
final
ObjectMapper
objectMapper
;
private
final
JgRegistrationHistoryServiceImpl
registrationHistoryService
;
private
final
JgInstallationNoticeServiceImpl
installationNoticeService
;
...
...
@@ -143,6 +149,10 @@ public class DataHandlerServiceImpl {
private
final
IdxBizJgRegisterInfoMapper
registerInfoMapper
;
private
final
JgUseRegistrationManageServiceImpl
registrationManageService
;
private
final
SuperviseInfoMapper
superviseInfoMapper
;
/**
* 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式
...
...
@@ -1824,4 +1834,77 @@ public class DataHandlerServiceImpl {
watch
.
stop
();
log
.
info
(
"增量添加ORG_BRANCH_CODE为50X综合搜索数据-设备信息入库结束,耗时:{}秒"
,
watch
.
getTotalTimeSeconds
());
}
public
Integer
deleteEquipWithStatusNotInClaimed
(
String
indices
)
{
if
(!
Arrays
.
asList
(
IDX_BIZ_VIEW_JG_ALL
,
IDX_BIZ_EQUIPMENT_INFO
).
contains
(
indices
))
{
throw
new
IllegalArgumentException
(
"非法索引名,只允许使用 idx_biz_view_jg_all 或 idx_biz_equipment_info"
);
}
List
<
String
>
records
=
new
ArrayList
<>();
if
(
IDX_BIZ_VIEW_JG_ALL
.
equals
(
indices
))
{
List
<
ESEquipmentCategoryDto
>
esList
=
queryUnclaimedEquipments
(
indices
,
ESEquipmentCategoryDto
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
esList
))
{
records
=
extractSequenceNbr
(
esList
);
esEquipmentCategory
.
deleteAll
(
esList
);
}
}
else
{
List
<
ESEquipmentInfo
>
esList
=
queryUnclaimedEquipments
(
indices
,
ESEquipmentInfo
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
esList
))
{
records
=
extractSequenceNbr
(
esList
);
esEquipmentDao
.
deleteAll
(
esList
);
}
}
if
(
records
.
isEmpty
())
{
return
0
;
}
List
<
List
<
String
>>
allDataList
=
Lists
.
partition
(
records
,
BATCH_SIZE
);
for
(
List
<
String
>
tempDataList
:
allDataList
)
{
if
(!
CollectionUtils
.
isEmpty
(
tempDataList
))
{
superviseInfoMapper
.
deleteDataAll
(
tempDataList
);
}
}
return
records
.
size
();
}
private
<
T
>
List
<
T
>
queryUnclaimedEquipments
(
String
index
,
Class
<
T
>
clazz
)
{
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
statusFilter
=
QueryBuilders
.
boolQuery
()
.
should
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
termQuery
(
STATUS
,
"已认领"
)))
.
should
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
STATUS
)))
.
should
(
QueryBuilders
.
termQuery
(
STATUS
,
""
))
.
minimumShouldMatch
(
1
);
boolQuery
.
must
(
statusFilter
);
try
{
return
registrationManageService
.
searchResponse
(
index
,
boolQuery
,
hit
->
{
JSONObject
json
=
JSONObject
.
parseObject
(
hit
.
getSourceAsString
(),
JSONObject
.
class
);
json
.
put
(
SEQUENCE_NBR
,
Objects
.
toString
(
json
.
get
(
SEQUENCE_NBR
),
""
));
return
json
.
toJavaObject
(
clazz
);
}
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"查询未认领设备异常:"
,
ex
);
return
Collections
.
emptyList
();
}
}
private
<
T
>
List
<
String
>
extractSequenceNbr
(
List
<
T
>
list
)
{
return
list
.
stream
()
.
map
(
item
->
{
try
{
Method
method
=
item
.
getClass
().
getMethod
(
"getSEQUENCE_NBR"
);
Object
value
=
method
.
invoke
(
item
);
return
Objects
.
toString
(
value
,
null
);
}
catch
(
Exception
e
)
{
log
.
warn
(
"反射获取 SEQUENCE_NBR 失败"
,
e
);
return
null
;
}
})
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
}
}
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