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
e7263365
Commit
e7263365
authored
Jun 18, 2022
by
zhangsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
巡检发送消息改为单独的定时任务
parent
3480f6ec
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
2 deletions
+100
-2
PlanTaskController.java
...n/amos/patrol/business/controller/PlanTaskController.java
+26
-0
PlanTaskMapper.java
...ejoin/amos/patrol/business/dao/mapper/PlanTaskMapper.java
+4
-0
PlanTaskServiceImpl.java
...mos/patrol/business/service/impl/PlanTaskServiceImpl.java
+37
-2
IPlanTaskService.java
.../amos/patrol/business/service/intfc/IPlanTaskService.java
+7
-0
dbTemplate_plan_task.xml
...rol/src/main/resources/db/mapper/dbTemplate_plan_task.xml
+26
-0
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/controller/PlanTaskController.java
View file @
e7263365
...
@@ -220,6 +220,32 @@ public class PlanTaskController extends AbstractBaseController {
...
@@ -220,6 +220,32 @@ public class PlanTaskController extends AbstractBaseController {
}
}
/**
/**
* 定时任务推送巡检待办任务消息
*/
@Scheduled
(
cron
=
"${jobs.cron}"
)
public
void
taskMessage
()
{
planTaskService
.
taskMessage
(
null
);
}
/**
* 模拟发送巡检待办任务消息定时任务
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"模拟发送巡检待办任务消息定时任务"
,
notes
=
"模拟发送巡检待办任务消息定时任务"
)
@RequestMapping
(
value
=
"/taskMessage"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
taskMessage
(
@ApiParam
(
value
=
"跑批日期格式yyyyMMdd"
,
required
=
false
)
@RequestParam
(
required
=
false
)
String
runDate
)
{
try
{
planTaskService
.
taskMessage
(
runDate
);
return
CommonResponseUtil
.
success
();
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
CommonResponseUtil
.
failure
();
}
}
/**
* 模拟定时任务调起服务
* 模拟定时任务调起服务
*
*
* @return
* @return
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dao/mapper/PlanTaskMapper.java
View file @
e7263365
package
com
.
yeejoin
.
amos
.
patrol
.
business
.
dao
.
mapper
;
package
com
.
yeejoin
.
amos
.
patrol
.
business
.
dao
.
mapper
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
com.yeejoin.amos.patrol.dao.entity.Plan
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo
;
import
com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo
;
...
@@ -185,5 +187,7 @@ public interface PlanTaskMapper extends BaseMapper {
...
@@ -185,5 +187,7 @@ public interface PlanTaskMapper extends BaseMapper {
List
<
Map
<
String
,
Object
>>
queryTimeAxis
(
HashMap
<
String
,
Object
>
params
);
List
<
Map
<
String
,
Object
>>
queryTimeAxis
(
HashMap
<
String
,
Object
>
params
);
List
<
Plan
>
getPlanIdsByDate
(
@Param
(
"date"
)
Date
date
);
List
<
PlanTask
>
getPlanTaskList
(
@Param
(
"date"
)
Date
date
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/service/impl/PlanTaskServiceImpl.java
View file @
e7263365
...
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
...
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Joiner
;
import
com.yeejoin.amos.boot.biz.common.constants.RuleConstant
;
import
com.yeejoin.amos.boot.biz.common.constants.RuleConstant
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.DepartmentModel
;
import
com.yeejoin.amos.feign.privilege.model.DepartmentModel
;
...
@@ -116,6 +117,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
...
@@ -116,6 +117,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Autowired
@Autowired
private
RuleTrigger
ruleTrigger
;
private
RuleTrigger
ruleTrigger
;
@Autowired
RedisUtils
redisUtils
;
private
final
String
PATROL_PLAN_TASK_KEY
=
"PATROL_PLAN_ID:"
;
private
final
String
packageId
=
"消息/addCheckRule"
;
private
final
String
packageId
=
"消息/addCheckRule"
;
private
final
String
msgType
=
"patrolSystem"
;
private
final
String
msgType
=
"patrolSystem"
;
private
final
String
APP
=
"APP"
;
private
final
String
APP
=
"APP"
;
...
@@ -713,8 +719,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
...
@@ -713,8 +719,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
planTask
.
setEndTime
(
endTime
);
planTask
.
setEndTime
(
endTime
);
// 1.保存执行数据主表
// 1.保存执行数据主表
iplanTaskDao
.
saveAndFlush
(
planTask
);
iplanTaskDao
.
saveAndFlush
(
planTask
);
// 发送APP待办消息
// 发送APP待办消息
(20220617 改为定时任务发送消息)
sendMessage
(
plan
,
planTask
);
//
sendMessage(plan, planTask);
String
executorId
=
planTask
.
getUserId
();
String
executorId
=
planTask
.
getUserId
();
long
planId
=
planTask
.
getId
();
long
planId
=
planTask
.
getId
();
for
(
int
i1
=
0
;
i1
<
pointIdList
.
size
();
i1
++)
{
for
(
int
i1
=
0
;
i1
<
pointIdList
.
size
();
i1
++)
{
...
@@ -765,6 +771,35 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
...
@@ -765,6 +771,35 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
}
//bug 5980 待办任务消息应只触发执行中的任务,漏检的任务和未开始的任务不需要触发待办任务消息.
@Override
@Transactional
public
void
taskMessage
(
String
runDate
)
{
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
//1.扫描plan表查询,需要生成执行数据的任务信息,无则return
Date
now
=
new
Date
();
//今天
String
format
=
df
.
format
(
now
);
if
(
runDate
!=
null
)
{
//上送则已上送的为准
runDate
=
runDate
+
" "
+
format
;
now
=
DateUtil
.
str2Date
(
runDate
,
"yyyyMMdd HH:mm:ss"
);
}
List
<
Plan
>
planIdsByDate
=
planTaskMapper
.
getPlanIdsByDate
(
now
);
List
<
PlanTask
>
planTaskList
=
planTaskMapper
.
getPlanTaskList
(
now
);
Map
<
Long
,
Plan
>
collect
=
planIdsByDate
.
stream
().
collect
(
Collectors
.
toMap
(
Plan:
:
getId
,
t
->
t
));
for
(
PlanTask
planTask
:
planTaskList
)
{
if
(!
redisUtils
.
hasKey
(
PATROL_PLAN_TASK_KEY
+
planTask
.
getId
()))
{
try
{
sendMessage
(
collect
.
get
(
planTask
.
getPlanId
()),
planTask
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
redisUtils
.
set
(
PATROL_PLAN_TASK_KEY
+
planTask
.
getId
(),
1
,
(
long
)
collect
.
get
(
planTask
.
getPlanId
()).
getDuration
()
*
60
);
}
}
}
public
void
sendMessage
(
Plan
plan
,
PlanTask
planTask
)
throws
Exception
{
public
void
sendMessage
(
Plan
plan
,
PlanTask
planTask
)
throws
Exception
{
MsgRo
msgRo
=
new
MsgRo
();
MsgRo
msgRo
=
new
MsgRo
();
// 标题
// 标题
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/service/intfc/IPlanTaskService.java
View file @
e7263365
...
@@ -46,6 +46,13 @@ public interface IPlanTaskService {
...
@@ -46,6 +46,13 @@ public interface IPlanTaskService {
void
taskExecution
(
String
runDate
);
void
taskExecution
(
String
runDate
);
/**
/**
* 定时任务发送消息执行中的消息
*
* @param runDate
*/
void
taskMessage
(
String
runDate
);
/**
* 根据路线id获取关联的所有计划任务
* 根据路线id获取关联的所有计划任务
*
*
* @param routeId
* @param routeId
...
...
amos-boot-system-patrol/src/main/resources/db/mapper/dbTemplate_plan_task.xml
View file @
e7263365
...
@@ -974,4 +974,29 @@
...
@@ -974,4 +974,29 @@
ORDER BY
ORDER BY
ppk.begin_time DESC LIMIT 60
ppk.begin_time DESC LIMIT 60
</select>
</select>
<select
id=
"getPlanIdsByDate"
resultType=
"com.yeejoin.amos.patrol.dao.entity.Plan"
>
select *
from p_plan
where id in (
select plan_id
from p_plan_task
where
begin_time
<
= #{date,jdbcType=TIMESTAMP}
and end_time
>
#{date,jdbcType=TIMESTAMP}
and finish_status in (0, 1)
and status = 0
group by plan_id
)
</select>
<select
id=
"getPlanTaskList"
resultType=
"com.yeejoin.amos.patrol.dao.entity.PlanTask"
>
select *
from p_plan_task
where
begin_time
<
= #{date,jdbcType=TIMESTAMP}
and end_time
>
#{date,jdbcType=TIMESTAMP}
and finish_status in (0, 1)
and status = 0
</select>
</mapper>
</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