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
ea9231fd
Commit
ea9231fd
authored
Dec 07, 2023
by
suhuiguang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop_tzs_register' of…
Merge branch 'develop_tzs_register' of
http://36.40.66.175:5000/moa/amos-boot-biz
into develop_tzs_register
parents
cad6c711
ba9ca9d0
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
39 deletions
+130
-39
PlanMapper.java
...m/yeejoin/amos/patrol/business/dao/mapper/PlanMapper.java
+2
-0
PlanTaskDetailMapper.java
...amos/patrol/business/dao/mapper/PlanTaskDetailMapper.java
+3
-0
RoutePointItemMapper.java
...amos/patrol/business/dao/mapper/RoutePointItemMapper.java
+1
-0
PlanTaskServiceImpl.java
...mos/patrol/business/service/impl/PlanTaskServiceImpl.java
+92
-38
RouteServiceImpl.java
...n/amos/patrol/business/service/impl/RouteServiceImpl.java
+5
-1
dbTemplate_plan.xml
...trol-biz/src/main/resources/db/mapper/dbTemplate_plan.xml
+8
-0
plan_task_detail.xml
...rol-biz/src/main/resources/db/mapper/plan_task_detail.xml
+9
-0
routePointItemMapper.xml
...biz/src/main/resources/db/mapper/routePointItemMapper.xml
+10
-0
No files found.
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dao/mapper/PlanMapper.java
View file @
ea9231fd
...
...
@@ -60,4 +60,6 @@ public interface PlanMapper extends BaseMapper {
void
initUpdatePlanNextGenDate
();
Plan
getPlan
(
String
planId
);
int
checkData
(
@Param
(
"planId"
)
Long
planId
);
}
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dao/mapper/PlanTaskDetailMapper.java
View file @
ea9231fd
package
com
.
yeejoin
.
amos
.
patrol
.
business
.
dao
.
mapper
;
import
com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto
;
import
com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -14,4 +15,6 @@ public interface PlanTaskDetailMapper extends BaseMapper {
List
<
PlanTaskDetail
>
findAllByIdInAndStatus
(
@Param
(
"planTaskIds"
)
List
<
Long
>
planTaskNo
,
@Param
(
"status"
)
String
status
);
List
<
ESTaskDetailDto
>
findAllByTaskNos
(
@Param
(
"ids"
)
String
ids
);
}
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dao/mapper/RoutePointItemMapper.java
View file @
ea9231fd
...
...
@@ -26,4 +26,5 @@ public interface RoutePointItemMapper extends BaseMapper {
*/
HashMap
<
String
,
String
>
getEquipByCode
(
String
equipCode
);
int
delRoutePointItemInExclude
(
@Param
(
"routePointId"
)
Long
routePointId
,
@Param
(
"inputItemIds"
)
List
<
Long
>
inputItemIds
);
}
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/business/service/impl/PlanTaskServiceImpl.java
View file @
ea9231fd
...
...
@@ -438,7 +438,10 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if
(
plan
==
null
)
{
throw
new
YeeException
(
"计划不存在"
);
}
// 校验计划数据是否异常
if
(!
checkData
(
plan
.
getId
())){
throw
new
YeeException
(
"计划数据异常!"
);
}
//2.数据必输校验,不满足直接return,不再向下进行
Boolean
fileFlag
=
PlanTaskUtil
.
checkMustFile
(
plan
);
if
(!
fileFlag
)
{
...
...
@@ -456,19 +459,61 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return
;
}
//
3.删除planTask表,按照计划id+日期
List
<
ESPlanTaskListDto
>
oldEsPlanTaskListDtos
=
deletePlanTaskAndDet
(
param
);
//
4.删除对应es中数据
CompletableFuture
.
runAsync
(()
->
deleteEsData
(
param
)
);
//5.执行数据生成(具体时间 + 人员)
List
<
HashMap
<
String
,
Object
>>
list
=
genAllExeDate
(
plan
,
vo
,
XJConstant
.
REGEN_FLAG
);
//6.插入planTask及planTaskDetail
insertPlanTaskAndDetNew
(
list
,
plan
,
flag
,
new
Date
()
,
oldEsPlanTaskListDtos
);
insertPlanTaskAndDetNew
(
list
,
plan
,
flag
,
new
Date
());
// 更新统计表
taskStaticExecution
(
null
);
}
private
void
deleteEsData
(
HashMap
<
String
,
Object
>
param
)
{
//删除planTask表,按照计划id+日期
List
<
ESPlanTaskListDto
>
oldEsPlanTaskListDtos
=
deletePlanTaskAndDet
(
param
);
//删除planTaskDetail表
List
<
String
>
planTaskIds
=
oldEsPlanTaskListDtos
.
stream
().
map
(
ESPlanTaskListDto:
:
getPlanTaskId
).
collect
(
Collectors
.
toList
());
if
(!
ValidationUtil
.
isEmpty
(
planTaskIds
))
{
if
(
planTaskIds
.
size
()
>
5000
)
{
int
index
=
5000
;
for
(
int
i
=
0
;
i
<
planTaskIds
.
size
();
i
+=
5000
)
{
if
(
i
+
5000
>
planTaskIds
.
size
())
{
index
=
planTaskIds
.
size
()
-
i
;
}
List
<
String
>
newList
=
planTaskIds
.
subList
(
i
,
i
+
index
);
String
ids
=
newList
.
stream
().
collect
(
Collectors
.
joining
(
"','"
,
"('"
,
"')"
));
List
<
ESTaskDetailDto
>
maps
=
planTaskDetailMapper
.
findAllByTaskNos
(
ids
);
esTaskDetail
.
deleteAll
(
maps
);
}
}
else
{
String
ids
=
planTaskIds
.
stream
().
collect
(
Collectors
.
joining
(
"','"
,
"('"
,
"')"
));
List
<
ESTaskDetailDto
>
maps
=
planTaskDetailMapper
.
findAllByTaskNos
(
ids
);
esTaskDetail
.
deleteAll
(
maps
);
}
}
if
(!
ValidationUtil
.
isEmpty
(
oldEsPlanTaskListDtos
))
{
if
(
oldEsPlanTaskListDtos
.
size
()
>
5000
)
{
int
index
=
5000
;
for
(
int
i
=
0
;
i
<
oldEsPlanTaskListDtos
.
size
();
i
+=
5000
)
{
if
(
i
+
5000
>
oldEsPlanTaskListDtos
.
size
())
{
index
=
oldEsPlanTaskListDtos
.
size
()
-
i
;
}
List
<
ESPlanTaskListDto
>
newList
=
oldEsPlanTaskListDtos
.
subList
(
i
,
i
+
index
);
esPlanTaskList
.
deleteAll
(
newList
);
}
}
else
{
esPlanTaskList
.
deleteAll
(
oldEsPlanTaskListDtos
);
}
}
}
private
void
notifyBusinessRefresh
(
String
type
)
{
try
{
...
...
@@ -647,6 +692,16 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
/**
* 校验计划数据是否异常
* @return
*/
private
Boolean
checkData
(
Long
planId
)
{
if
(
planMapper
.
checkData
(
planId
)
>
0
)
{
return
true
;
}
return
false
;
}
/**
* 自动任务执行
*/
@Override
...
...
@@ -668,6 +723,10 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
//2.循环遍历执行
HashMap
<
String
,
Object
>
paramMap
=
new
HashMap
<
String
,
Object
>();
for
(
Plan
plan
:
planList
)
{
// 校验计划数据是否异常
if
(!
checkData
(
plan
.
getId
())){
continue
;
}
// tzs修改为查询用户组id
if
(
StringUtils
.
isEmpty
(
plan
.
getUserGroupId
()))
continue
;
...
...
@@ -716,7 +775,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
//2.5.插入planTask及planTaskDetail
insertPlanTaskAndDetNew
(
list
,
plan
,
XJConstant
.
SCHED_FLAG
,
now
,
null
);
insertPlanTaskAndDetNew
(
list
,
plan
,
XJConstant
.
SCHED_FLAG
,
now
);
// 更新统计表
taskStaticExecution
(
null
);
...
...
@@ -868,7 +927,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
* @param plan
* @param flag 是否初始状态0-初始 1-非初始
*/
public
void
insertPlanTaskAndDetNew
(
List
<
HashMap
<
String
,
Object
>>
list
,
Plan
plan
,
String
flag
,
Date
now
,
List
<
ESPlanTaskListDto
>
oldEsPlanTaskListDtos
)
{
public
void
insertPlanTaskAndDetNew
(
List
<
HashMap
<
String
,
Object
>>
list
,
Plan
plan
,
String
flag
,
Date
now
)
{
if
(
list
==
null
||
list
.
size
()
<=
0
)
{
HashMap
<
String
,
Object
>
paramMap
=
new
HashMap
<
String
,
Object
>();
paramMap
.
put
(
"id"
,
plan
.
getId
());
...
...
@@ -1008,7 +1067,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
//存在事物,在事务提交之后执行
asyncSaveEs
(
planTaskDetails
,
esPlanTaskListDtos
,
oldEsPlanTaskListDtos
);
asyncSaveEs
(
planTaskDetails
,
esPlanTaskListDtos
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -1018,18 +1077,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
}
private
void
asyncSaveEs
(
Iterable
<
PlanTaskDetail
>
planTaskDetails
,
List
<
ESPlanTaskListDto
>
esPlanTaskListDtos
,
List
<
ESPlanTaskListDto
>
oldEsPlanTaskListDtos
)
{
private
void
asyncSaveEs
(
Iterable
<
PlanTaskDetail
>
planTaskDetails
,
List
<
ESPlanTaskListDto
>
esPlanTaskListDtos
)
{
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronizationAdapter
()
{
@Override
public
void
afterCommit
()
{
//异步存储任务和任务详情到es
asyncSavePlanTaskAndDetailListToEs
(
planTaskDetails
,
esPlanTaskListDtos
,
oldEsPlanTaskListDtos
);
asyncSavePlanTaskAndDetailListToEs
(
planTaskDetails
,
esPlanTaskListDtos
);
}
});
}
@Async
public
void
asyncSavePlanTaskAndDetailListToEs
(
Iterable
<
PlanTaskDetail
>
planTaskDetails
,
List
<
ESPlanTaskListDto
>
esPlanTaskListDtos
,
List
<
ESPlanTaskListDto
>
oldEsPlanTaskListDtos
)
{
public
void
asyncSavePlanTaskAndDetailListToEs
(
Iterable
<
PlanTaskDetail
>
planTaskDetails
,
List
<
ESPlanTaskListDto
>
esPlanTaskListDtos
)
{
log
.
info
(
"异步存储任务和任务详情到es"
);
Plan
plan
=
planMapper
.
getPlan
(
esPlanTaskListDtos
.
get
(
0
).
getPlanId
());
StopWatch
stopWatch
=
new
StopWatch
();
...
...
@@ -1071,14 +1130,28 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
Map
<
String
,
List
<
AppCheckInputRespone
>>
collect2
=
pointInputs
.
stream
().
collect
(
Collectors
.
groupingBy
(
AppCheckInputRespone:
:
getPointId
));
for
(
Map
<
String
,
String
>
excludeItem
:
excludeItems
)
{
String
[]
exclude_items
=
excludeItem
.
get
(
"exclude_items"
).
split
(
","
);
List
<
AppCheckInputRespone
>
appCheckInputRespones
=
collect2
.
get
(
String
.
valueOf
(
excludeItem
.
get
(
"point_id"
)));
if
(
excludeItem
.
containsKey
(
"exclude_items"
)
&&
!
ObjectUtils
.
isEmpty
(
excludeItem
.
get
(
"exclude_items"
))){
String
[]
exclude_items
=
excludeItem
.
get
(
"exclude_items"
).
split
(
","
);
List
<
AppCheckInputRespone
>
appCheckInputRespones1
=
new
ArrayList
<>();
for
(
String
exclude_item
:
exclude_items
)
{
appCheckInputRespones1
.
add
(
appCheckInputRespones
.
stream
().
filter
(
x
->
x
.
getPointInputItemId
().
equals
(
exclude_item
)).
collect
(
Collectors
.
toList
()).
get
(
0
));
List
<
AppCheckInputRespone
>
collect
=
appCheckInputRespones
.
stream
().
filter
(
x
->
x
.
getPointInputItemId
().
equals
(
exclude_item
)).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
collect
)
&&
!
ObjectUtils
.
isEmpty
(
collect
.
get
(
0
))){
continue
;
}
appCheckInputRespones1
.
add
(
collect
.
get
(
0
));
}
appCheckInputRespones
.
removeAll
(
appCheckInputRespones1
);
}
collect2
.
put
(
String
.
valueOf
(
excludeItem
.
get
(
"point_id"
)),
appCheckInputRespones
);
// String[] exclude_items = excludeItem.get("exclude_items").split(",");
// List<AppCheckInputRespone> appCheckInputRespones = collect2.get(String.valueOf(excludeItem.get("point_id")));
// List<AppCheckInputRespone> appCheckInputRespones1 = new ArrayList<>();
// for (String exclude_item : exclude_items) {
// appCheckInputRespones1.add(appCheckInputRespones.stream().filter(x -> x.getPointInputItemId().equals(exclude_item)).collect(Collectors.toList()).get(0));
// }
// appCheckInputRespones.removeAll(appCheckInputRespones1);
// collect2.put(String.valueOf(excludeItem.get("point_id")), appCheckInputRespones);
}
for
(
ESTaskDetailDto
esTaskDetailDto
:
esTaskDetailDtos
)
{
...
...
@@ -1184,7 +1257,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
log
.
info
(
"esPlanTaskListDtos数据组装,耗时:{} 秒"
,
stopWatch6
.
getTotalTimeSeconds
());
StopWatch
stopWatch7
=
new
StopWatch
();
stopWatch7
.
start
();
saveEsPlanTaskList
(
esPlanTaskListDtos
,
oldEsPlanTaskListDtos
);
saveEsPlanTaskList
(
esPlanTaskListDtos
);
stopWatch7
.
stop
();
log
.
info
(
"任务存入es,耗时:{} 秒"
,
stopWatch7
.
getTotalTimeSeconds
());
}
...
...
@@ -1210,22 +1283,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
public
void
saveEsPlanTaskList
(
List
<
ESPlanTaskListDto
>
esPlanTaskListDtos
,
List
<
ESPlanTaskListDto
>
oldEsPlanTaskListDtos
)
{
if
(!
ValidationUtil
.
isEmpty
(
oldEsPlanTaskListDtos
))
{
if
(
oldEsPlanTaskListDtos
.
size
()
>
5000
)
{
int
index
=
5000
;
for
(
int
i
=
0
;
i
<
oldEsPlanTaskListDtos
.
size
();
i
+=
5000
)
{
if
(
i
+
5000
>
oldEsPlanTaskListDtos
.
size
())
{
index
=
oldEsPlanTaskListDtos
.
size
()
-
i
;
}
List
<
ESPlanTaskListDto
>
newList
=
oldEsPlanTaskListDtos
.
subList
(
i
,
i
+
index
);
esPlanTaskList
.
deleteAll
(
newList
);
}
}
else
{
esPlanTaskList
.
deleteAll
(
oldEsPlanTaskListDtos
);
}
}
public
void
saveEsPlanTaskList
(
List
<
ESPlanTaskListDto
>
esPlanTaskListDtos
)
{
if
(!
ValidationUtil
.
isEmpty
(
esPlanTaskListDtos
))
{
if
(
esPlanTaskListDtos
.
size
()
>
5000
)
{
int
index
=
5000
;
...
...
@@ -1831,21 +1889,17 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
meBuilder
.
must
(
QueryBuilders
.
wildcardQuery
(
"userId"
,
"*"
+
test
+
"*"
));
boolMust
.
must
(
meBuilder
);
}
if
(!
ObjectUtils
.
isEmpty
(
params
.
get
(
"orgCode"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
params
.
get
(
"finishStatus"
)))
{
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
query
.
must
(
QueryBuilders
.
matchPhraseQuery
(
"
orgCode"
,
"*"
+
params
.
get
(
"orgCode
"
)
+
"*"
));
query
.
must
(
QueryBuilders
.
matchPhraseQuery
(
"
finishStatus"
,
"*"
+
params
.
get
(
"finishStatus
"
)
+
"*"
));
boolMust
.
must
(
query
);
}
if
(!
ObjectUtils
.
isEmpty
(
params
.
get
(
"
finishStatus
"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
params
.
get
(
"
type
"
)))
{
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
query
.
must
(
QueryBuilders
.
matchPhraseQuery
(
"
finishStatus"
,
"*"
+
params
.
get
(
"finishStatus
"
)
+
"*"
));
query
.
must
(
QueryBuilders
.
matchPhraseQuery
(
"
type"
,
"*"
+
params
.
get
(
"type
"
)
+
"*"
));
boolMust
.
must
(
query
);
}
// if (!ObjectUtils.isEmpty(params.get("type"))) {
// BoolQueryBuilder query = QueryBuilders.boolQuery();
// query.must(QueryBuilders.matchPhraseQuery("type", "*" + params.get("type") + "*"));
// boolMust.must(query);
// }
if
(!
ObjectUtils
.
isEmpty
(
params
.
get
(
"startTime"
)))
{
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
...
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/business/service/impl/RouteServiceImpl.java
View file @
ea9231fd
...
...
@@ -573,7 +573,11 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement
// }
// });
// List<Long> lastList = Stream.concat(otherClassify.stream(), inputItemIds.stream()).distinct().collect(Collectors.toList());
RoutePoint
.
setExcludeItems
(
StringUtils
.
join
(
inputItemIds
,
","
));
List
<
Long
>
itemIds
=
inputItemIds
.
stream
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
//保存到route_point的exclude_items字段
RoutePoint
.
setExcludeItems
(
StringUtils
.
join
(
itemIds
,
","
));
//删除route_point_item的多余关联项
routePointItemMapper
.
delRoutePointItemInExclude
(
RoutePoint
.
getId
(),
itemIds
);
// }
// else {
// RoutePoint.setExcludeItems(StringUtils.join(inputItemIds.toArray(),","));
...
...
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/resources/db/mapper/dbTemplate_plan.xml
View file @
ea9231fd
...
...
@@ -174,4 +174,11 @@
<select
id=
"getPlan"
resultType=
"com.yeejoin.amos.patrol.dao.entity.Plan"
>
select * from p_plan where id = #{planId}
</select>
<select
id=
"checkData"
resultType=
"java.lang.Integer"
>
SELECT count(1) FROM "p_plan" plan
INNER JOIN p_route_point route on plan.route_id = route.route_id
INNER JOIN p_point_inputitem item on route.point_id = item.point_id
WHERE plan.id = #{planId}
</select>
</mapper>
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/resources/db/mapper/plan_task_detail.xml
View file @
ea9231fd
...
...
@@ -30,4 +30,12 @@
pptd.task_no in
<foreach
collection=
"planTaskIds"
item=
"planTaskId"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{planTaskId}
</foreach>
and pptd.status = #{status}
</select>
<select
id=
"findAllByTaskNos"
resultType=
"com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail"
>
select
pptd.id
from
"p_plan_task_detail" pptd
where
pptd.task_no in #{ids}
</select>
</mapper>
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/resources/db/mapper/routePointItemMapper.xml
View file @
ea9231fd
...
...
@@ -76,6 +76,16 @@
delete from p_route_point WHERE point_id = #{pointId} and route_id = #{routeId}
</delete>
<delete
id=
"delRoutePointItemInExclude"
>
delete from p_route_point_item
WHERE route_point_id = #{routePointId}
and point_input_item_id in
<foreach
collection=
"inputItemIds"
item=
"item"
index=
"index"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</delete>
<insert
id=
"insertRoutePointItem"
>
insert into p_route_point_item
(id, route_point_id, order_no, point_input_item_id, creator_id, create_date, point_classify_id, basis_json)
...
...
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