Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
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
liyuan
byit-myth-job
Commits
25014132
Commit
25014132
authored
Dec 24, 2019
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码重构】日志操作
parent
da0171a4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
50 additions
and
10 deletions
+50
-10
JobTaskRunLogService.java
.../src/main/java/com/byit/service/JobTaskRunLogService.java
+7
-0
JobTaskRunLogServiceImpl.java
.../java/com/byit/service/impl/JobTaskRunLogServiceImpl.java
+14
-1
JobTaskScheduleServiceImpl.java
...ava/com/byit/service/impl/JobTaskScheduleServiceImpl.java
+9
-1
JobTaskServiceImpl.java
...c/main/java/com/byit/service/impl/JobTaskServiceImpl.java
+4
-0
JavaBeanJobTask.java
...min-core/src/main/java/com/byit/task/JavaBeanJobTask.java
+7
-5
JobScheduleHelper.java
...core/src/main/java/com/byit/thread/JobScheduleHelper.java
+1
-1
LogCallbackThread.java
...core/src/main/java/com/byit/thread/LogCallbackThread.java
+1
-1
JobTaskRunLogMapper.xml
...in-core/src/main/resources/mapper/JobTaskRunLogMapper.xml
+1
-1
DispatchResponseDto.java
...n/src/main/java/com/byit/job/dto/DispatchResponseDto.java
+6
-0
No files found.
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/JobTaskRunLogService.java
View file @
25014132
...
@@ -22,4 +22,11 @@ public interface JobTaskRunLogService {
...
@@ -22,4 +22,11 @@ public interface JobTaskRunLogService {
* @return
* @return
*/
*/
int
saveJobTaskRunLog
(
JobTaskRunLog
jobTaskRunLog
);
int
saveJobTaskRunLog
(
JobTaskRunLog
jobTaskRunLog
);
/**
* 修改数据
* @param jobTaskRunLog
* @return
*/
int
updateJobTaskRunLog
(
JobTaskRunLog
jobTaskRunLog
);
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/JobTaskRunLogServiceImpl.java
View file @
25014132
...
@@ -5,6 +5,8 @@ import com.byit.model.JobTaskRunLog;
...
@@ -5,6 +5,8 @@ import com.byit.model.JobTaskRunLog;
import
com.byit.service.JobTaskRunLogService
;
import
com.byit.service.JobTaskRunLogService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
/**
/**
* @program: byit-myth-job->JobTaskRunLogServiceImpl
* @program: byit-myth-job->JobTaskRunLogServiceImpl
...
@@ -13,12 +15,18 @@ import org.springframework.stereotype.Service;
...
@@ -13,12 +15,18 @@ import org.springframework.stereotype.Service;
* @date: 2019/12/20 19:43
* @date: 2019/12/20 19:43
**/
**/
@Service
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
JobTaskRunLogServiceImpl
implements
JobTaskRunLogService
{
public
class
JobTaskRunLogServiceImpl
implements
JobTaskRunLogService
{
private
final
JobTaskRunLogMapper
jobTaskRunLogMapper
;
@Autowired
@Autowired
private
JobTaskRunLogMapper
jobTaskRunLogMapper
;
public
JobTaskRunLogServiceImpl
(
JobTaskRunLogMapper
jobTaskRunLogMapper
)
{
this
.
jobTaskRunLogMapper
=
jobTaskRunLogMapper
;
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
SUPPORTS
)
public
JobTaskRunLog
findJobTaskRunLogById
(
Integer
id
)
{
public
JobTaskRunLog
findJobTaskRunLogById
(
Integer
id
)
{
return
jobTaskRunLogMapper
.
getById
(
id
);
return
jobTaskRunLogMapper
.
getById
(
id
);
}
}
...
@@ -27,4 +35,9 @@ public class JobTaskRunLogServiceImpl implements JobTaskRunLogService {
...
@@ -27,4 +35,9 @@ public class JobTaskRunLogServiceImpl implements JobTaskRunLogService {
public
int
saveJobTaskRunLog
(
JobTaskRunLog
jobTaskRunLog
)
{
public
int
saveJobTaskRunLog
(
JobTaskRunLog
jobTaskRunLog
)
{
return
jobTaskRunLogMapper
.
insertSelective
(
jobTaskRunLog
);
return
jobTaskRunLogMapper
.
insertSelective
(
jobTaskRunLog
);
}
}
@Override
public
int
updateJobTaskRunLog
(
JobTaskRunLog
jobTaskRunLog
)
{
return
jobTaskRunLogMapper
.
updateByIdSelective
(
jobTaskRunLog
);
}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/JobTaskScheduleServiceImpl.java
View file @
25014132
...
@@ -5,6 +5,8 @@ import com.byit.model.JobTaskSchedule;
...
@@ -5,6 +5,8 @@ import com.byit.model.JobTaskSchedule;
import
com.byit.service.JobTaskScheduleService
;
import
com.byit.service.JobTaskScheduleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.List
;
...
@@ -15,16 +17,22 @@ import java.util.List;
...
@@ -15,16 +17,22 @@ import java.util.List;
* @date: 2019/12/20 17:32
* @date: 2019/12/20 17:32
**/
**/
@Service
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
JobTaskScheduleServiceImpl
implements
JobTaskScheduleService
{
public
class
JobTaskScheduleServiceImpl
implements
JobTaskScheduleService
{
private
final
JobTaskScheduleMapper
jobTaskScheduleMapper
;
@Autowired
@Autowired
private
JobTaskScheduleMapper
jobTaskScheduleMapper
;
public
JobTaskScheduleServiceImpl
(
JobTaskScheduleMapper
jobTaskScheduleMapper
)
{
this
.
jobTaskScheduleMapper
=
jobTaskScheduleMapper
;
}
/**
/**
* 查询五秒的数据
* 查询五秒的数据
* @param maxNextTime
* @param maxNextTime
* @return
* @return
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
SUPPORTS
)
@Override
@Override
public
List
<
JobTaskSchedule
>
findJobTaskScheduleByTriggerNextTimeLessThanEqual
(
long
maxNextTime
)
{
public
List
<
JobTaskSchedule
>
findJobTaskScheduleByTriggerNextTimeLessThanEqual
(
long
maxNextTime
)
{
return
jobTaskScheduleMapper
.
findJobTaskScheduleByTriggerNextTimeLessThanEqual
(
maxNextTime
);
return
jobTaskScheduleMapper
.
findJobTaskScheduleByTriggerNextTimeLessThanEqual
(
maxNextTime
);
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/JobTaskServiceImpl.java
View file @
25014132
...
@@ -5,6 +5,8 @@ import com.byit.model.JobTask;
...
@@ -5,6 +5,8 @@ import com.byit.model.JobTask;
import
com.byit.service.JobTaskService
;
import
com.byit.service.JobTaskService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.List
;
...
@@ -15,6 +17,7 @@ import java.util.List;
...
@@ -15,6 +17,7 @@ import java.util.List;
* @date: 2019/12/20 15:13
* @date: 2019/12/20 15:13
**/
**/
@Service
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
JobTaskServiceImpl
implements
JobTaskService
{
public
class
JobTaskServiceImpl
implements
JobTaskService
{
private
final
JobTaskMapper
jobTaskMapper
;
private
final
JobTaskMapper
jobTaskMapper
;
...
@@ -28,6 +31,7 @@ public class JobTaskServiceImpl implements JobTaskService {
...
@@ -28,6 +31,7 @@ public class JobTaskServiceImpl implements JobTaskService {
* @param maxNextTime 预读数值
* @param maxNextTime 预读数值
* @return 返回的是七秒内将要执行的数据
* @return 返回的是七秒内将要执行的数据
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
SUPPORTS
)
@Override
@Override
public
List
<
JobTask
>
findJobTaskByTriggerNextTimeLessThanEqual
(
long
maxNextTime
)
{
public
List
<
JobTask
>
findJobTaskByTriggerNextTimeLessThanEqual
(
long
maxNextTime
)
{
return
jobTaskMapper
.
findJobTaskByTriggerNextTimeLessThanEqual
(
maxNextTime
);
return
jobTaskMapper
.
findJobTaskByTriggerNextTimeLessThanEqual
(
maxNextTime
);
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/task/JavaBeanJobTask.java
View file @
25014132
...
@@ -48,17 +48,18 @@ public class JavaBeanJobTask implements TimerTask {
...
@@ -48,17 +48,18 @@ public class JavaBeanJobTask implements TimerTask {
adminSenPluginDto
.
setLogId
(
mythJobTaskSchedule
.
getLogId
());
adminSenPluginDto
.
setLogId
(
mythJobTaskSchedule
.
getLogId
());
//这里获取的是调度结果
//这里获取的是调度结果
String
result
=
HttpUtil
.
post
(
url
,
JSON
.
toJSONString
(
adminSenPluginDto
),
10
*
1000
);
String
result
=
HttpUtil
.
post
(
url
,
JSON
.
toJSONString
(
adminSenPluginDto
),
10
*
1000
);
DispatchResponseDto
dispatchResponseDto
=
JSON
.
parseObject
(
result
,
DispatchResponseDto
.
class
);
//修改调度结果
//修改调度结果
saveLog
(
mythJobTaskSchedule
,
url
,
result
);
saveLog
(
mythJobTaskSchedule
,
url
,
result
);
log
.
debug
(
"---------------{}------------"
,
result
);
log
.
debug
(
"---------------{}------------"
,
result
);
}
catch
(
PluginException
ignored
){
}
catch
(
PluginException
ignored
){
saveLog
(
mythJobTaskSchedule
,
""
,
ignored
.
getMessage
());
DispatchResponseDto
dispatchResponseDto
=
DispatchResponseDto
.
builder
().
code
(
ignored
.
getIEnum
(
).
getCode
(
)).
msg
(
ignored
.
getIEnum
(
).
getMsg
(
)).
build
(
);
saveLog
(
mythJobTaskSchedule
,
""
,
JSON
.
toJSONString
(
dispatchResponseDto
));
log
.
error
(
"-------------通讯异常:{},{}"
,
ignored
.
getIEnum
().
getCode
(),
ignored
.
getIEnum
().
getMsg
());
log
.
error
(
"-------------通讯异常:{},{}"
,
ignored
.
getIEnum
().
getCode
(),
ignored
.
getIEnum
().
getMsg
());
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
saveLog
(
mythJobTaskSchedule
,
""
,
"未知错误!!"
);
DispatchResponseDto
dispatchResponseDto
=
DispatchResponseDto
.
builder
().
code
(
"500"
).
msg
(
"未知错误"
).
build
(
);
saveLog
(
mythJobTaskSchedule
,
""
,
JSON
.
toJSONString
(
dispatchResponseDto
));
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
...
@@ -66,16 +67,17 @@ public class JavaBeanJobTask implements TimerTask {
...
@@ -66,16 +67,17 @@ public class JavaBeanJobTask implements TimerTask {
private
void
saveLog
(
JobTaskSchedule
mythJobTaskSchedule
,
String
url
,
String
result
){
private
void
saveLog
(
JobTaskSchedule
mythJobTaskSchedule
,
String
url
,
String
result
){
DispatchResponseDto
dispatchResponseDto
=
JSON
.
parseObject
(
result
,
DispatchResponseDto
.
class
);
DispatchResponseDto
dispatchResponseDto
=
JSON
.
parseObject
(
result
,
DispatchResponseDto
.
class
);
JobTaskRunLogServiceImpl
mythJ
obTaskRunLogService
=
SpringUtil
.
getBean
(
JobTaskRunLogServiceImpl
.
class
);
JobTaskRunLogServiceImpl
j
obTaskRunLogService
=
SpringUtil
.
getBean
(
JobTaskRunLogServiceImpl
.
class
);
JobTaskRunLog
jobTaskRunLog
=
new
JobTaskRunLog
();
JobTaskRunLog
jobTaskRunLog
=
new
JobTaskRunLog
();
jobTaskRunLog
.
setLogId
(
mythJobTaskSchedule
.
getLogId
());
jobTaskRunLog
.
setLogId
(
mythJobTaskSchedule
.
getLogId
());
//版本id需要查验
//版本id需要查验
//还需要携带版本的名字
//还需要携带版本的名字
jobTaskRunLog
.
setRunType
(
"2"
);
jobTaskRunLog
.
setRunType
(
"2"
);
jobTaskRunLog
.
setJobType
(
"BEAN"
);
jobTaskRunLog
.
setLocalNodeHandlerName
(
mythJobTaskSchedule
.
getLocalNodeHandlerName
());
jobTaskRunLog
.
setLocalNodeHandlerName
(
mythJobTaskSchedule
.
getLocalNodeHandlerName
());
jobTaskRunLog
.
setTriggerTime
(
new
Date
());
jobTaskRunLog
.
setTriggerTime
(
new
Date
());
jobTaskRunLog
.
setTriggerCode
(
dispatchResponseDto
.
getCode
());
jobTaskRunLog
.
setTriggerCode
(
dispatchResponseDto
.
getCode
());
jobTaskRunLog
.
setTriggerMsg
(
dispatchResponseDto
.
getMsg
());
jobTaskRunLog
.
setTriggerMsg
(
dispatchResponseDto
.
getMsg
());
mythJobTaskRunLogService
.
sav
eJobTaskRunLog
(
jobTaskRunLog
);
jobTaskRunLogService
.
updat
eJobTaskRunLog
(
jobTaskRunLog
);
}
}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/JobScheduleHelper.java
View file @
25014132
...
@@ -246,7 +246,7 @@ public class JobScheduleHelper{
...
@@ -246,7 +246,7 @@ public class JobScheduleHelper{
Integer
logId
=
saveLog
(
mythJobTaskSchedule
);
Integer
logId
=
saveLog
(
mythJobTaskSchedule
);
mythJobTaskSchedule
.
setLogId
(
logId
);
mythJobTaskSchedule
.
setLogId
(
logId
);
JavaBeanJobTask
javaBeanJobTask
=
new
JavaBeanJobTask
(
mythJobTaskSchedule
);
JavaBeanJobTask
javaBeanJobTask
=
new
JavaBeanJobTask
(
mythJobTaskSchedule
);
jobTaskScheduleService
.
delete
(
mythJobTaskSchedule
.
get
Node
Id
());
jobTaskScheduleService
.
delete
(
mythJobTaskSchedule
.
getId
());
WorkRoulette
.
addJob
(
javaBeanJobTask
,
mythJobTaskSchedule
.
getTriggerNextTime
());
WorkRoulette
.
addJob
(
javaBeanJobTask
,
mythJobTaskSchedule
.
getTriggerNextTime
());
}
}
});
});
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/LogCallbackThread.java
View file @
25014132
...
@@ -30,6 +30,6 @@ public class LogCallbackThread implements Runnable {
...
@@ -30,6 +30,6 @@ public class LogCallbackThread implements Runnable {
jobTaskRunLog
.
setRunTime
(
jobRunResultDto
.
getEndTime
());
jobTaskRunLog
.
setRunTime
(
jobRunResultDto
.
getEndTime
());
jobTaskRunLog
.
setRunCode
(
jobRunResultDto
.
getReturnResult
().
getCode
());
jobTaskRunLog
.
setRunCode
(
jobRunResultDto
.
getReturnResult
().
getCode
());
jobTaskRunLog
.
setRunMsg
(
jobRunResultDto
.
getReturnResult
().
getMsg
());
jobTaskRunLog
.
setRunMsg
(
jobRunResultDto
.
getReturnResult
().
getMsg
());
mythJobTaskRunLogService
.
sav
eJobTaskRunLog
(
jobTaskRunLog
);
mythJobTaskRunLogService
.
updat
eJobTaskRunLog
(
jobTaskRunLog
);
}
}
}
}
byit-myth-core/myth-admin-core/src/main/resources/mapper/JobTaskRunLogMapper.xml
View file @
25014132
...
@@ -63,7 +63,7 @@
...
@@ -63,7 +63,7 @@
)
)
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.byit.model.JobTaskRunLog"
useGeneratedKeys=
"true"
keyProperty=
"
i
d"
keyColumn=
"log_id"
>
<insert
id=
"insertSelective"
parameterType=
"com.byit.model.JobTaskRunLog"
useGeneratedKeys=
"true"
keyProperty=
"
logI
d"
keyColumn=
"log_id"
>
insert into job_task_run_log
insert into job_task_run_log
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"logId != null"
>
<if
test=
"logId != null"
>
...
...
byit-myth-core/myth-core-common/src/main/java/com/byit/job/dto/DispatchResponseDto.java
View file @
25014132
package
com
.
byit
.
job
.
dto
;
package
com
.
byit
.
job
.
dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
/**
* @program: byit-myth-job->DispatchResponseDto
* @program: byit-myth-job->DispatchResponseDto
...
@@ -9,6 +12,9 @@ import lombok.Data;
...
@@ -9,6 +12,9 @@ import lombok.Data;
* @date: 2019/12/23 11:12
* @date: 2019/12/23 11:12
**/
**/
@Data
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
DispatchResponseDto
{
public
class
DispatchResponseDto
{
private
String
code
;
private
String
code
;
private
String
msg
;
private
String
msg
;
...
...
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