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
d95a7b39
Commit
d95a7b39
authored
Nov 08, 2023
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
巡检定时器修改
parent
c4a59042
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
57 deletions
+96
-57
PlanTask.java
...ain/java/com/yeejoin/amos/patrol/dao/entity/PlanTask.java
+1
-1
PlanTaskMapper.java
...ejoin/amos/patrol/business/dao/mapper/PlanTaskMapper.java
+6
-2
IPlanTaskDao.java
...oin/amos/patrol/business/dao/repository/IPlanTaskDao.java
+9
-0
PlanTaskServiceImpl.java
...mos/patrol/business/service/impl/PlanTaskServiceImpl.java
+5
-13
JobService.java
.../main/java/com/yeejoin/amos/patrol/quartz/JobService.java
+52
-41
dbTemplate_plan_task.xml
...biz/src/main/resources/db/mapper/dbTemplate_plan_task.xml
+23
-0
No files found.
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-api/src/main/java/com/yeejoin/amos/patrol/dao/entity/PlanTask.java
View file @
d95a7b39
...
...
@@ -42,7 +42,7 @@ public class PlanTask extends BasicEntity {
@Column
(
name
=
"finish_num"
)
private
int
finishNum
;
/**
* 完成状态:0-尚未开始;1-正在进行;2-已经结束;3-超时漏检
;4-已完成
* 完成状态:0-尚未开始;1-正在进行;2-已经结束;3-超时漏检
*/
@Column
(
name
=
"finish_status"
)
private
int
finishStatus
;
...
...
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dao/mapper/PlanTaskMapper.java
View file @
d95a7b39
...
...
@@ -94,7 +94,7 @@ public interface PlanTaskMapper extends BaseMapper {
* @param planTaskId
* @return
*/
List
<
PlanTaskPointInputItemBo
>
getPlanTaskPointInputItemByPlanTaskId
(
@Param
(
value
=
"planTaskId"
)
Long
planTaskId
,
@Param
(
value
=
"planTaskDetailStatus"
)
String
planTaskDetailStatus
);
List
<
PlanTaskPointInputItemBo
>
getPlanTaskPointInputItemByPlanTaskId
(
@Param
(
value
=
"planTaskId"
)
Long
planTaskId
,
@Param
(
value
=
"planTaskDetailStatus"
)
String
planTaskDetailStatus
);
/**
* 条件查询数据
...
...
@@ -139,7 +139,7 @@ public interface PlanTaskMapper extends BaseMapper {
* @param pointId
* @return
*/
PointCheckDetailBo
getPointPlanTaskInfo
(
@Param
(
"planTaskId"
)
Long
planTaskId
,
@Param
(
"pointId"
)
Long
pointId
);
PointCheckDetailBo
getPointPlanTaskInfo
(
@Param
(
"planTaskId"
)
Long
planTaskId
,
@Param
(
"pointId"
)
Long
pointId
);
/**
* 根据路线id和点id获取该点的检查项
...
...
@@ -224,4 +224,8 @@ public interface PlanTaskMapper extends BaseMapper {
Map
<
String
,
Object
>
queryPatrolInfoList
(
@Param
(
value
=
"bizOrgCode"
)
String
bizOrgCode
,
@Param
(
value
=
"startDate"
)
Date
startDate
,
@Param
(
value
=
"endDate"
)
Date
endDate
);
Map
<
String
,
Object
>
queryPatrolEquipInfo
(
@Param
(
value
=
"bizOrgCode"
)
String
bizOrgCode
,
@Param
(
value
=
"startDate"
)
Date
startDate
,
@Param
(
value
=
"endDate"
)
Date
endDate
);
List
<
Long
>
getPlanTaskListByPlanId
(
long
planId
,
int
finishStatus
);
void
updatePlanTaskByPlanId
(
List
<
Long
>
ids
,
int
finishStatus
);
}
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dao/repository/IPlanTaskDao.java
View file @
d95a7b39
...
...
@@ -55,4 +55,13 @@ public interface IPlanTaskDao extends BaseDao<PlanTask, Long> {
List
<
PlanTask
>
findByPlanId
(
Long
planId
);
PlanTask
findByUserIdAndBeginTimeAndEndTimeAndPlanIdAndRouteId
(
String
userId
,
String
startTime
,
String
endTime
,
long
id
,
long
routeId
);
@Modifying
@Transactional
@Query
(
value
=
"update p_plan_task set finish_status = (?2) where plan_id in (?1)"
,
nativeQuery
=
true
)
void
updatePlanTaskFinishStatus
(
List
<
Long
>
collect
,
int
value
);
@Modifying
@Transactional
@Query
(
value
=
"update p_plan_task_detail set is_finish = (?2) where plan_id in (?1)"
,
nativeQuery
=
true
)
void
updatePlanTaskDetailFinishStatus
(
List
<
Long
>
collect
,
int
value
);
}
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 @
d95a7b39
...
...
@@ -731,6 +731,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
List
<
PlanTask
>
planTaskList
=
new
ArrayList
<>();
List
<
PlanTaskDetail
>
planTaskDetailListSync
=
new
ArrayList
<>();
PlanTask
planTask
=
new
PlanTask
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
startTime
=
list
.
get
(
i
).
get
(
"BEGIN_TIME"
).
toString
();
...
...
@@ -741,11 +742,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
String
orgCode
=
list
.
get
(
i
).
get
(
"ORG_CODE"
)
==
null
?
"-1"
:
String
.
valueOf
(
list
.
get
(
i
).
get
(
"ORG_CODE"
));
String
unitCode
=
list
.
get
(
i
).
get
(
"UNIT_CODE"
)
==
null
?
"-1"
:
String
.
valueOf
(
list
.
get
(
i
).
get
(
"UNIT_CODE"
));
PlanTask
planTask
=
iplanTaskDao
.
findByUserIdAndBeginTimeAndEndTimeAndPlanIdAndRouteId
(
userId
,
startTime
,
endTime
,
plan
.
getId
(),
plan
.
getRouteId
());
planTask
=
iplanTaskDao
.
findByUserIdAndBeginTimeAndEndTimeAndPlanIdAndRouteId
(
userId
,
startTime
,
endTime
,
plan
.
getId
(),
plan
.
getRouteId
());
if
(
planTask
!=
null
)
{
continue
;
}
planTask
=
new
PlanTask
();
//
planTask = new PlanTask();
//修改巡检p_plan_task orgcode为执行人的org_code -- add by wujunkai 20201216
planTask
.
setOrgCode
(
orgCode
);
...
...
@@ -813,11 +814,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
planTaskDetail
.
saveAndFlush
(
planTaskDetailInstance
);
planTaskDetailListSync
.
add
(
planTaskDetailInstance
);
}
}
// 定时任务监控
log
.
error
(
"计划重做开始添加定时任务监控========"
);
jobService
.
planTaskAddJob
(
planTask
);
planTaskList
.
add
(
planTask
);
}
// 3.如果为自动任务调用,则更新id,如果重做或且下次时间大于等于明天,则更新planTaskId到plan表
Date
genDate
=
DateUtil
.
str2Date
(
list
.
get
(
list
.
size
()
-
1
).
get
(
"NEXT_GEN_DATE"
).
toString
(),
"yyyy-MM-dd"
);
//下次生成日期
...
...
@@ -838,15 +839,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap
.
put
(
"next_gen_date"
,
DateUtil
.
formatDatrToStr
(
now
,
"yyyy-MM-dd"
));
}
planMapper
.
updPlanStatusOrGenDate
(
paramMap
);
// 更新下次任务生成日期
// 巡检站端与中心级数据同步
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
// @Override
// public void afterCommit() {
// // 事物提交后业务逻辑
// patrolDataSyncService.planTaskDataSync(planTaskList);
// patrolDataSyncService.planTaskDetailDataSync(planTaskDetailListSync);
// }
// });
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
...
...
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/java/com/yeejoin/amos/patrol/quartz/JobService.java
View file @
d95a7b39
...
...
@@ -21,6 +21,7 @@ import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import
com.yeejoin.amos.patrol.business.param.MsgConfigParam
;
import
com.yeejoin.amos.patrol.business.service.intfc.IMessageService
;
import
com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService
;
import
com.yeejoin.amos.patrol.business.service.intfc.IPlanTaskService
;
import
com.yeejoin.amos.patrol.business.util.DateUtil
;
import
com.yeejoin.amos.patrol.business.util.Toke
;
import
com.yeejoin.amos.patrol.common.enums.*
;
...
...
@@ -40,12 +41,15 @@ import org.springframework.transaction.support.TransactionSynchronization;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
yeejoin
.
amos
.
patrol
.
common
.
enums
.
NotifyBusinessTypeEum
.
planTask
;
@Service
(
"jobService"
)
public
class
JobService
implements
IJobService
{
...
...
@@ -56,6 +60,8 @@ public class JobService implements IJobService {
@Autowired
private
IPlanTaskDao
iPlanTaskDao
;
@Autowired
private
IPlanDao
planDao
;
@Autowired
private
IPlanTaskDetailDao
iPlanTaskDetailDao
;
...
...
@@ -511,33 +517,33 @@ public class JobService implements IJobService {
int
status
=
planTask
.
getFinishStatus
();
if
(
PlanTaskFinishStatusEnum
.
NOTSTARTED
.
getValue
()
==
status
)
{
addJob
(
"planTask"
,
XJConstant
.
STATUS_MONITOR_START
,
planTask
.
getId
(),
beginTime
);
// 添加监控任务开始时间定时任务
addJob
(
"planTask"
,
XJConstant
.
STATUS_MONITOR_START
,
planTask
.
get
Plan
Id
(),
beginTime
);
// 添加监控任务开始时间定时任务
}
if
(
PlanTaskFinishStatusEnum
.
NOTSTARTED
.
getValue
()
==
status
||
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
()
==
status
)
{
addJob
(
"planTask"
,
XJConstant
.
STATUS_MONITOR_END
,
planTask
.
getId
(),
endTime
);
// 添加监控任务开始结束定时任务
}
// 查询需要推送消息提醒
List
<
MsgConfigParam
>
configParam
=
msgMapper
.
getPlanTaskMsgConfigByUserIdAndStatus
(
planTask
.
getUserId
().
split
(
","
),
"True"
);
if
(!
configParam
.
isEmpty
())
{
configParam
.
forEach
(
config
->
{
String
jobType
=
""
;
Date
time
=
new
Date
();
int
minute
=
Integer
.
valueOf
(
config
.
getValue
());
long
tempTime
=
minute
*
60
*
1000
;
if
(
MsgSubscribeTypeEnum
.
PLANWARN
.
getName
().
equals
(
config
.
getMsgType
()))
{
time
=
new
Date
(
beginTime
.
getTime
()
-
tempTime
);
jobType
=
XJConstant
.
PLAN_TASK_WARN_MSG_PUSH
+
"-"
+
config
.
getUserId
();
}
else
if
(
MsgSubscribeTypeEnum
.
PLANBEGIN
.
getName
().
equals
(
config
.
getMsgType
()))
{
time
=
new
Date
(
beginTime
.
getTime
()
+
tempTime
);
jobType
=
XJConstant
.
PLAN_TASK_BEGIN_MSG_PUSH
+
"-"
+
config
.
getUserId
();
}
else
if
(
MsgSubscribeTypeEnum
.
PLANEND
.
getName
().
equals
(
config
.
getMsgType
()))
{
time
=
new
Date
(
endTime
.
getTime
()
+
tempTime
);
jobType
=
XJConstant
.
PLAN_TASK_END_MSG_PUSH
+
"-"
+
config
.
getUserId
();
}
addJob
(
"planTask"
,
jobType
,
planTask
.
getId
(),
time
);
});
}
addJob
(
"planTask"
,
XJConstant
.
STATUS_MONITOR_END
,
planTask
.
get
Plan
Id
(),
endTime
);
// 添加监控任务开始结束定时任务
}
//
// 查询需要推送消息提醒
//
List<MsgConfigParam> configParam = msgMapper.getPlanTaskMsgConfigByUserIdAndStatus(planTask.getUserId().split(","), "True");
//
if (!configParam.isEmpty()) {
//
configParam.forEach(config -> {
//
String jobType = "";
//
Date time = new Date();
//
int minute = Integer.valueOf(config.getValue());
//
long tempTime = minute * 60 * 1000;
//
if (MsgSubscribeTypeEnum.PLANWARN.getName().equals(config.getMsgType())) {
//
time = new Date(beginTime.getTime() - tempTime);
//
jobType = XJConstant.PLAN_TASK_WARN_MSG_PUSH + "-" + config.getUserId();
//
} else if (MsgSubscribeTypeEnum.PLANBEGIN.getName().equals(config.getMsgType())) {
//
time = new Date(beginTime.getTime() + tempTime);
//
jobType = XJConstant.PLAN_TASK_BEGIN_MSG_PUSH + "-" + config.getUserId();
//
} else if (MsgSubscribeTypeEnum.PLANEND.getName().equals(config.getMsgType())) {
//
time = new Date(endTime.getTime() + tempTime);
//
jobType = XJConstant.PLAN_TASK_END_MSG_PUSH + "-" + config.getUserId();
//
}
//
addJob("planTask", jobType, planTask.getId(), time);
//
});
//
}
}
else
{
updatePlanTaskStatus
(
planTask
,
PlanTaskFinishStatusEnum
.
OVERTIME
.
getValue
());
...
...
@@ -550,28 +556,33 @@ public class JobService implements IJobService {
@Override
@Transactional
public
void
planTaskJobPerform
(
long
planTaskId
,
String
jobType
,
String
jobName
)
{
public
void
planTaskJobPerform
(
long
planId
,
String
jobType
,
String
jobName
)
{
if
(
planDao
.
existsById
(
planId
))
{
List
<
Long
>
notStartPlanTaskList
=
planTaskMapper
.
getPlanTaskListByPlanId
(
planId
,
PlanTaskFinishStatusEnum
.
NOTSTARTED
.
getValue
());
List
<
Long
>
StartPlanTaskList
=
planTaskMapper
.
getPlanTaskListByPlanId
(
planId
,
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
());
if
(
iPlanTaskDao
.
existsById
(
planTaskId
))
{
PlanTask
planTask
=
iPlanTaskDao
.
findById
(
planTaskId
).
get
();
log
.
error
(
"开始执行定时任务添加的任务==========>>{}"
,
JSON
.
toJSONString
(
planTask
));
if
(
XJConstant
.
STATUS_MONITOR_START
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
NOTSTARTED
.
getValue
()
==
planTask
.
getFinishStatus
())
{
planTask
.
setFinishStatus
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
());
iPlanTaskDao
.
save
(
planTask
);
if
(
planTask
!=
null
)
{
PlanTaskSyncBo
planTaskSyncBo
=
buildPlanTaskBo
(
planTask
);
String
message
=
buildSyncMessage
(
PatrolDataSyncTopicEnum
.
PLAN_TASK
.
getTopic
(),
planTaskSyncBo
);
webMqttComponent
.
publish
(
PatrolDataSyncTopicEnum
.
EQM_PATROL_CREATED
.
getTopic
(),
message
);
}
if
(!
ValidationUtil
.
isEmpty
(
notStartPlanTaskList
))
{
planTaskMapper
.
updatePlanTaskByPlanId
(
notStartPlanTaskList
,
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
());
}
}
else
if
(
XJConstant
.
STATUS_MONITOR_END
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
()
==
planTask
.
getFinishStatus
())
{
updatePlanTaskStatus
(
planTask
,
PlanTaskFinishStatusEnum
.
OVERTIME
.
getValue
());
if
(!
ValidationUtil
.
isEmpty
(
StartPlanTaskList
))
{
planTaskMapper
.
updatePlanTaskByPlanId
(
StartPlanTaskList
,
PlanTaskFinishStatusEnum
.
OVERTIME
.
getValue
());
for
(
Long
id
:
StartPlanTaskList
)
{
List
<
PlanTaskDetail
>
planTaskDetails
=
iPlanTaskDetailDao
.
findAllByTaskNoAndStatus
(
id
,
PlanTaskDetailStatusEnum
.
NOTSTARTED
.
getValue
());
if
(!
planTaskDetails
.
isEmpty
())
{
planTaskDetails
.
stream
().
forEach
(
action
->
{
action
.
setIsFinish
(
PlanTaskDetailIsFinishEnum
.
OVERTIME
.
getValue
());
action
.
setStatus
(
PlanTaskDetailStatusEnum
.
OMISSION
.
getValue
());
iPlanTaskDetailDao
.
saveAndFlush
(
action
);
});
}
}
// iPlanTaskDao.updatePlanTaskDetailFinishStatus(collect,PlanTaskFinishStatusEnum.UNDERWAY.getValue());
// updatePlanTaskStatus(planTask, PlanTaskFinishStatusEnum.OVERTIME.getValue());
}
}
else
{
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushPlanTaskMessage
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
planTask
,
jobType
);
}
}
removeJob
(
jobName
);
...
...
amos-boot-system-tzs/amos-boot-module-tzspatrol/amos-boot-module-tzspatrol-biz/src/main/resources/db/mapper/dbTemplate_plan_task.xml
View file @
d95a7b39
...
...
@@ -1572,4 +1572,26 @@
</where>
) temp
</select>
<select
id=
"getPlanTaskListByPlanId"
resultType=
"java.lang.Long"
>
SELECT
*
FROM
"p_plan_task"
WHERE
plan_id = #{planId}
AND finish_status = #{finishStatus}
</select>
<update
id=
"updatePlanTaskByPlanId"
>
update
"p_plan_task"
set
finish_status = #{finishStatus}
where
id in
<foreach
item=
"id"
collection=
"ids"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</update>
</mapper>
\ 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