mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
🎨 Improving structure / format of the code. 格式化代码
This commit is contained in:
parent
3c2bd9ce53
commit
c4483ebb11
File diff suppressed because it is too large
Load Diff
@ -45,33 +45,33 @@ import org.springframework.context.annotation.Scope;
|
|||||||
@AutoConfigureBefore(SentinelFeignAutoConfiguration.class)
|
@AutoConfigureBefore(SentinelFeignAutoConfiguration.class)
|
||||||
public class PigFeignAutoConfiguration {
|
public class PigFeignAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@ConditionalOnProperty(name = "feign.sentinel.enabled")
|
@ConditionalOnProperty(name = "feign.sentinel.enabled")
|
||||||
public Feign.Builder feignSentinelBuilder() {
|
public Feign.Builder feignSentinelBuilder() {
|
||||||
return PigSentinelFeign.builder();
|
return PigSentinelFeign.builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public BlockExceptionHandler blockExceptionHandler(ObjectMapper objectMapper) {
|
public BlockExceptionHandler blockExceptionHandler(ObjectMapper objectMapper) {
|
||||||
return new PigUrlBlockHandler(objectMapper);
|
return new PigUrlBlockHandler(objectMapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public RequestOriginParser requestOriginParser() {
|
public RequestOriginParser requestOriginParser() {
|
||||||
return new PigHeaderRequestOriginParser();
|
return new PigHeaderRequestOriginParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add http connection close header
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public PigFeignRequestCloseInterceptor pigFeignRequestCloseInterceptor() {
|
||||||
|
return new PigFeignRequestCloseInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* add http connection close header
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public PigFeignRequestCloseInterceptor pigFeignRequestCloseInterceptor() {
|
|
||||||
return new PigFeignRequestCloseInterceptor();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@ import org.springframework.http.HttpHeaders;
|
|||||||
*/
|
*/
|
||||||
public class PigFeignRequestCloseInterceptor implements RequestInterceptor {
|
public class PigFeignRequestCloseInterceptor implements RequestInterceptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set connection close
|
* set connection close
|
||||||
*
|
* @param template
|
||||||
* @param template
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public void apply(feign.RequestTemplate template) {
|
||||||
public void apply(feign.RequestTemplate template) {
|
template.header(HttpHeaders.CONNECTION, "close");
|
||||||
template.header(HttpHeaders.CONNECTION, "close");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -46,56 +46,59 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class SqlFilterArgumentResolver implements HandlerMethodArgumentResolver {
|
public class SqlFilterArgumentResolver implements HandlerMethodArgumentResolver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断Controller是否包含page 参数
|
* 判断Controller是否包含page 参数
|
||||||
*
|
* @param parameter 参数
|
||||||
* @param parameter 参数
|
* @return 是否过滤
|
||||||
* @return 是否过滤
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public boolean supportsParameter(MethodParameter parameter) {
|
||||||
public boolean supportsParameter(MethodParameter parameter) {
|
return parameter.getParameterType().equals(Page.class);
|
||||||
return parameter.getParameterType().equals(Page.class);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parameter 入参集合
|
* @param parameter 入参集合
|
||||||
* @param mavContainer model 和 view
|
* @param mavContainer model 和 view
|
||||||
* @param webRequest web相关
|
* @param webRequest web相关
|
||||||
* @param binderFactory 入参解析
|
* @param binderFactory 入参解析
|
||||||
* @return 检查后新的page对象
|
* @return 检查后新的page对象
|
||||||
* <p>
|
* <p>
|
||||||
* page 只支持查询 GET .如需解析POST获取请求报文体处理
|
* page 只支持查询 GET .如需解析POST获取请求报文体处理
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
|
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
|
||||||
|
|
||||||
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
|
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
|
||||||
|
|
||||||
String[] ascs = request.getParameterValues("ascs");
|
String[] ascs = request.getParameterValues("ascs");
|
||||||
String[] descs = request.getParameterValues("descs");
|
String[] descs = request.getParameterValues("descs");
|
||||||
String current = request.getParameter("current");
|
String current = request.getParameter("current");
|
||||||
String size = request.getParameter("size");
|
String size = request.getParameter("size");
|
||||||
|
|
||||||
Page<?> page = new Page<>();
|
Page<?> page = new Page<>();
|
||||||
if (StrUtil.isNotBlank(current)) {
|
if (StrUtil.isNotBlank(current)) {
|
||||||
page.setCurrent(Long.parseLong(current));
|
page.setCurrent(Long.parseLong(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(size)) {
|
if (StrUtil.isNotBlank(size)) {
|
||||||
page.setSize(Long.parseLong(size));
|
page.setSize(Long.parseLong(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OrderItem> orderItemList = new ArrayList<>();
|
List<OrderItem> orderItemList = new ArrayList<>();
|
||||||
Optional.ofNullable(ascs)
|
Optional.ofNullable(ascs)
|
||||||
.ifPresent(s -> orderItemList.addAll(
|
.ifPresent(s -> orderItemList.addAll(Arrays.stream(s)
|
||||||
Arrays.stream(s).filter(asc -> !SqlInjectionUtils.check(asc)).map(OrderItem::asc).collect(Collectors.toList())));
|
.filter(asc -> !SqlInjectionUtils.check(asc))
|
||||||
Optional.ofNullable(descs)
|
.map(OrderItem::asc)
|
||||||
.ifPresent(s -> orderItemList.addAll(
|
.collect(Collectors.toList())));
|
||||||
Arrays.stream(s).filter(desc -> !SqlInjectionUtils.check(desc)).map(OrderItem::desc).collect(Collectors.toList())));
|
Optional.ofNullable(descs)
|
||||||
page.addOrder(orderItemList);
|
.ifPresent(s -> orderItemList.addAll(Arrays.stream(s)
|
||||||
|
.filter(desc -> !SqlInjectionUtils.check(desc))
|
||||||
|
.map(OrderItem::desc)
|
||||||
|
.collect(Collectors.toList())));
|
||||||
|
page.addOrder(orderItemList);
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,62 +21,58 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||||||
@EnableConfigurationProperties(GatewayConfigProperties.class)
|
@EnableConfigurationProperties(GatewayConfigProperties.class)
|
||||||
public class GatewayConfiguration {
|
public class GatewayConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建密码解码器过滤器
|
* 创建密码解码器过滤器
|
||||||
*
|
* @param modifyRequestBodyGatewayFilterFactory 修改请求体网关过滤器工厂
|
||||||
* @param modifyRequestBodyGatewayFilterFactory 修改请求体网关过滤器工厂
|
* @param configProperties 配置属性
|
||||||
* @param configProperties 配置属性
|
* @return 密码解码器过滤器
|
||||||
* @return 密码解码器过滤器
|
*/
|
||||||
*/
|
@Bean
|
||||||
@Bean
|
public PasswordDecoderFilter passwordDecoderFilter(
|
||||||
public PasswordDecoderFilter passwordDecoderFilter(
|
ModifyRequestBodyGatewayFilterFactory modifyRequestBodyGatewayFilterFactory,
|
||||||
ModifyRequestBodyGatewayFilterFactory modifyRequestBodyGatewayFilterFactory,
|
GatewayConfigProperties configProperties) {
|
||||||
GatewayConfigProperties configProperties) {
|
return new PasswordDecoderFilter(modifyRequestBodyGatewayFilterFactory, configProperties);
|
||||||
return new PasswordDecoderFilter(modifyRequestBodyGatewayFilterFactory, configProperties);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建PigRequest全局过滤器
|
* 创建PigRequest全局过滤器
|
||||||
*
|
* @return PigRequest全局过滤器
|
||||||
* @return PigRequest全局过滤器
|
*/
|
||||||
*/
|
@Bean
|
||||||
@Bean
|
public PigRequestGlobalFilter pigRequestGlobalFilter() {
|
||||||
public PigRequestGlobalFilter pigRequestGlobalFilter() {
|
return new PigRequestGlobalFilter();
|
||||||
return new PigRequestGlobalFilter();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建验证码网关过滤器
|
* 创建验证码网关过滤器
|
||||||
*
|
* @param configProperties 配置属性
|
||||||
* @param configProperties 配置属性
|
* @param redisTemplate Redis模板
|
||||||
* @param redisTemplate Redis模板
|
* @return 验证码网关过滤器
|
||||||
* @return 验证码网关过滤器
|
*/
|
||||||
*/
|
@Bean
|
||||||
@Bean
|
public ValidateCodeGatewayFilter validateCodeGatewayFilter(GatewayConfigProperties configProperties,
|
||||||
public ValidateCodeGatewayFilter validateCodeGatewayFilter(GatewayConfigProperties configProperties, RedisTemplate redisTemplate) {
|
RedisTemplate redisTemplate) {
|
||||||
return new ValidateCodeGatewayFilter(configProperties, redisTemplate);
|
return new ValidateCodeGatewayFilter(configProperties, redisTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建全局异常处理程序
|
* 创建全局异常处理程序
|
||||||
*
|
* @param objectMapper 对象映射器
|
||||||
* @param objectMapper 对象映射器
|
* @return 全局异常处理程序
|
||||||
* @return 全局异常处理程序
|
*/
|
||||||
*/
|
@Bean
|
||||||
@Bean
|
public GlobalExceptionHandler globalExceptionHandler(ObjectMapper objectMapper) {
|
||||||
public GlobalExceptionHandler globalExceptionHandler(ObjectMapper objectMapper) {
|
return new GlobalExceptionHandler(objectMapper);
|
||||||
return new GlobalExceptionHandler(objectMapper);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建图片验证码处理器
|
* 创建图片验证码处理器
|
||||||
*
|
* @param redisTemplate Redis模板
|
||||||
* @param redisTemplate Redis模板
|
* @return 图片验证码处理器
|
||||||
* @return 图片验证码处理器
|
*/
|
||||||
*/
|
@Bean
|
||||||
@Bean
|
public ImageCodeHandler imageCodeHandler(RedisTemplate redisTemplate) {
|
||||||
public ImageCodeHandler imageCodeHandler(RedisTemplate redisTemplate) {
|
return new ImageCodeHandler(redisTemplate);
|
||||||
return new ImageCodeHandler(redisTemplate);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
// 根据数据权限查询全部的用户信息
|
// 根据数据权限查询全部的用户信息
|
||||||
List<UserVO> voList = baseMapper.selectVoList(userDTO);
|
List<UserVO> voList = baseMapper.selectVoList(userDTO);
|
||||||
// 转换成execl 对象输出
|
// 转换成execl 对象输出
|
||||||
return voList.stream().map(userVO -> {
|
return voList.stream().map(userVO -> {
|
||||||
UserExcelVO excelVO = new UserExcelVO();
|
UserExcelVO excelVO = new UserExcelVO();
|
||||||
BeanUtils.copyProperties(userVO, excelVO);
|
BeanUtils.copyProperties(userVO, excelVO);
|
||||||
String roleNameList = userVO.getRoleList()
|
String roleNameList = userVO.getRoleList()
|
||||||
|
@ -69,8 +69,7 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务分页查询
|
* 定时任务分页查询
|
||||||
*
|
* @param page 分页对象
|
||||||
* @param page 分页对象
|
|
||||||
* @param sysJob 定时任务调度表
|
* @param sysJob 定时任务调度表
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@ -78,17 +77,16 @@ public class SysJobController {
|
|||||||
@Operation(description = "分页定时业务查询")
|
@Operation(description = "分页定时业务查询")
|
||||||
public R getSysJobPage(Page page, SysJob sysJob) {
|
public R getSysJobPage(Page page, SysJob sysJob) {
|
||||||
LambdaQueryWrapper<SysJob> wrapper = Wrappers.<SysJob>lambdaQuery()
|
LambdaQueryWrapper<SysJob> wrapper = Wrappers.<SysJob>lambdaQuery()
|
||||||
.like(StrUtil.isNotBlank(sysJob.getJobName()), SysJob::getJobName, sysJob.getJobName())
|
.like(StrUtil.isNotBlank(sysJob.getJobName()), SysJob::getJobName, sysJob.getJobName())
|
||||||
.like(StrUtil.isNotBlank(sysJob.getJobGroup()), SysJob::getJobGroup, sysJob.getJobGroup())
|
.like(StrUtil.isNotBlank(sysJob.getJobGroup()), SysJob::getJobGroup, sysJob.getJobGroup())
|
||||||
.eq(StrUtil.isNotBlank(sysJob.getJobStatus()), SysJob::getJobStatus, sysJob.getJobGroup())
|
.eq(StrUtil.isNotBlank(sysJob.getJobStatus()), SysJob::getJobStatus, sysJob.getJobGroup())
|
||||||
.eq(StrUtil.isNotBlank(sysJob.getJobExecuteStatus()), SysJob::getJobExecuteStatus,
|
.eq(StrUtil.isNotBlank(sysJob.getJobExecuteStatus()), SysJob::getJobExecuteStatus,
|
||||||
sysJob.getJobExecuteStatus());
|
sysJob.getJobExecuteStatus());
|
||||||
return R.ok(sysJobService.page(page, wrapper));
|
return R.ok(sysJobService.page(page, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id查询定时任务
|
* 通过id查询定时任务
|
||||||
*
|
|
||||||
* @param id id
|
* @param id id
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@ -100,7 +98,6 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增定时任务,默认新增状态为1已发布
|
* 新增定时任务,默认新增状态为1已发布
|
||||||
*
|
|
||||||
* @param sysJob 定时任务调度表
|
* @param sysJob 定时任务调度表
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@ -109,13 +106,8 @@ public class SysJobController {
|
|||||||
@PreAuthorize("@pms.hasPermission('job_sys_job_add')")
|
@PreAuthorize("@pms.hasPermission('job_sys_job_add')")
|
||||||
@Operation(description = "新增定时任务")
|
@Operation(description = "新增定时任务")
|
||||||
public R save(@RequestBody SysJob sysJob) {
|
public R save(@RequestBody SysJob sysJob) {
|
||||||
long count = sysJobService
|
long count = sysJobService.count(
|
||||||
.count(Wrappers.query(
|
Wrappers.query(SysJob.builder().jobName(sysJob.getJobName()).jobGroup(sysJob.getJobGroup()).build()));
|
||||||
SysJob.builder()
|
|
||||||
.jobName(sysJob.getJobName())
|
|
||||||
.jobGroup(sysJob.getJobGroup())
|
|
||||||
.build()
|
|
||||||
));
|
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
return R.failed("任务重复,请检查此组内是否已包含同名任务");
|
return R.failed("任务重复,请检查此组内是否已包含同名任务");
|
||||||
@ -127,7 +119,6 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改定时任务
|
* 修改定时任务
|
||||||
*
|
|
||||||
* @param sysJob 定时任务调度表
|
* @param sysJob 定时任务调度表
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@ -139,10 +130,11 @@ public class SysJobController {
|
|||||||
sysJob.setUpdateBy(SecurityUtils.getUser().getUsername());
|
sysJob.setUpdateBy(SecurityUtils.getUser().getUsername());
|
||||||
SysJob querySysJob = this.sysJobService.getById(sysJob.getJobId());
|
SysJob querySysJob = this.sysJobService.getById(sysJob.getJobId());
|
||||||
if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(querySysJob.getJobStatus())) {
|
if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(querySysJob.getJobStatus())) {
|
||||||
//如修改暂停的需更新调度器
|
// 如修改暂停的需更新调度器
|
||||||
this.taskUtil.addOrUpateJob(sysJob, scheduler);
|
this.taskUtil.addOrUpateJob(sysJob, scheduler);
|
||||||
sysJobService.updateById(sysJob);
|
sysJobService.updateById(sysJob);
|
||||||
} else if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
}
|
||||||
|
else if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
||||||
sysJobService.updateById(sysJob);
|
sysJobService.updateById(sysJob);
|
||||||
}
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
@ -150,7 +142,6 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除定时任务
|
* 通过id删除定时任务
|
||||||
*
|
|
||||||
* @param id id
|
* @param id id
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@ -163,7 +154,8 @@ public class SysJobController {
|
|||||||
if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(querySysJob.getJobStatus())) {
|
if (PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(querySysJob.getJobStatus())) {
|
||||||
this.taskUtil.removeJob(querySysJob, scheduler);
|
this.taskUtil.removeJob(querySysJob, scheduler);
|
||||||
this.sysJobService.removeById(id);
|
this.sysJobService.removeById(id);
|
||||||
} else if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
}
|
||||||
|
else if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
||||||
this.sysJobService.removeById(id);
|
this.sysJobService.removeById(id);
|
||||||
}
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
@ -171,7 +163,6 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂停全部定时任务
|
* 暂停全部定时任务
|
||||||
*
|
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@SysLog("暂停全部定时任务")
|
@SysLog("暂停全部定时任务")
|
||||||
@ -184,19 +175,19 @@ public class SysJobController {
|
|||||||
new LambdaQueryWrapper<SysJob>().eq(SysJob::getJobStatus, PigQuartzEnum.JOB_STATUS_RUNNING.getType()));
|
new LambdaQueryWrapper<SysJob>().eq(SysJob::getJobStatus, PigQuartzEnum.JOB_STATUS_RUNNING.getType()));
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
return R.ok("无正在运行定时任务");
|
return R.ok("无正在运行定时任务");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// 更新定时任务状态条件,运行状态2更新为暂停状态3
|
// 更新定时任务状态条件,运行状态2更新为暂停状态3
|
||||||
this.sysJobService.update(
|
this.sysJobService.update(
|
||||||
SysJob.builder().jobStatus(PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType()).build(),
|
SysJob.builder().jobStatus(PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType()).build(),
|
||||||
new UpdateWrapper<SysJob>().lambda().eq(SysJob::getJobStatus,
|
new UpdateWrapper<SysJob>().lambda()
|
||||||
PigQuartzEnum.JOB_STATUS_RUNNING.getType()));
|
.eq(SysJob::getJobStatus, PigQuartzEnum.JOB_STATUS_RUNNING.getType()));
|
||||||
return R.ok("暂停成功");
|
return R.ok("暂停成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动全部定时任务
|
* 启动全部定时任务
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@SysLog("启动全部暂停的定时任务")
|
@SysLog("启动全部暂停的定时任务")
|
||||||
@ -206,16 +197,14 @@ public class SysJobController {
|
|||||||
public R startJobs() {
|
public R startJobs() {
|
||||||
// 更新定时任务状态条件,暂停状态3更新为运行状态2
|
// 更新定时任务状态条件,暂停状态3更新为运行状态2
|
||||||
this.sysJobService.update(SysJob.builder().jobStatus(PigQuartzEnum.JOB_STATUS_RUNNING.getType()).build(),
|
this.sysJobService.update(SysJob.builder().jobStatus(PigQuartzEnum.JOB_STATUS_RUNNING.getType()).build(),
|
||||||
new UpdateWrapper<SysJob>().lambda().eq(SysJob::getJobStatus,
|
new UpdateWrapper<SysJob>().lambda()
|
||||||
PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType()));
|
.eq(SysJob::getJobStatus, PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType()));
|
||||||
taskUtil.startJobs(scheduler);
|
taskUtil.startJobs(scheduler);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新全部定时任务
|
* 刷新全部定时任务 暂停和运行的添加到调度器其他状态从调度器移除
|
||||||
* 暂停和运行的添加到调度器其他状态从调度器移除
|
|
||||||
*
|
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@SysLog("刷新全部定时任务")
|
@SysLog("刷新全部定时任务")
|
||||||
@ -227,7 +216,8 @@ public class SysJobController {
|
|||||||
if (PigQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus())
|
if (PigQuartzEnum.JOB_STATUS_RUNNING.getType().equals(sysjob.getJobStatus())
|
||||||
|| PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) {
|
|| PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType().equals(sysjob.getJobStatus())) {
|
||||||
taskUtil.addOrUpateJob(sysjob, scheduler);
|
taskUtil.addOrUpateJob(sysjob, scheduler);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
taskUtil.removeJob(sysjob, scheduler);
|
taskUtil.removeJob(sysjob, scheduler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -236,7 +226,6 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动定时任务
|
* 启动定时任务
|
||||||
*
|
|
||||||
* @param jobId 任务id
|
* @param jobId 任务id
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@ -250,7 +239,7 @@ public class SysJobController {
|
|||||||
return R.failed("无此定时任务,请确认");
|
return R.failed("无此定时任务,请确认");
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果定时任务不存在,强制状态为1已发布
|
// 如果定时任务不存在,强制状态为1已发布
|
||||||
if (!scheduler.checkExists(TaskUtil.getJobKey(querySysJob))) {
|
if (!scheduler.checkExists(TaskUtil.getJobKey(querySysJob))) {
|
||||||
querySysJob.setJobStatus(PigQuartzEnum.JOB_STATUS_RELEASE.getType());
|
querySysJob.setJobStatus(PigQuartzEnum.JOB_STATUS_RELEASE.getType());
|
||||||
log.warn("定时任务不在quartz中,任务id:{},强制状态为已发布并加入调度器", jobId);
|
log.warn("定时任务不在quartz中,任务id:{},强制状态为已发布并加入调度器", jobId);
|
||||||
@ -258,18 +247,18 @@ public class SysJobController {
|
|||||||
|
|
||||||
if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
if (PigQuartzEnum.JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
||||||
taskUtil.addOrUpateJob(querySysJob, scheduler);
|
taskUtil.addOrUpateJob(querySysJob, scheduler);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
taskUtil.resumeJob(querySysJob, scheduler);
|
taskUtil.resumeJob(querySysJob, scheduler);
|
||||||
}
|
}
|
||||||
// 更新定时任务状态为运行状态2
|
// 更新定时任务状态为运行状态2
|
||||||
this.sysJobService.updateById(
|
this.sysJobService
|
||||||
SysJob.builder().jobId(jobId).jobStatus(PigQuartzEnum.JOB_STATUS_RUNNING.getType()).build());
|
.updateById(SysJob.builder().jobId(jobId).jobStatus(PigQuartzEnum.JOB_STATUS_RUNNING.getType()).build());
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动定时任务
|
* 启动定时任务
|
||||||
*
|
|
||||||
* @param jobId 任务id
|
* @param jobId 任务id
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@ -280,7 +269,7 @@ public class SysJobController {
|
|||||||
public R runJob(@PathVariable("id") Long jobId) throws SchedulerException {
|
public R runJob(@PathVariable("id") Long jobId) throws SchedulerException {
|
||||||
SysJob querySysJob = this.sysJobService.getById(jobId);
|
SysJob querySysJob = this.sysJobService.getById(jobId);
|
||||||
|
|
||||||
//执行定时任务前判定任务是否在quartz中
|
// 执行定时任务前判定任务是否在quartz中
|
||||||
if (!scheduler.checkExists(TaskUtil.getJobKey(querySysJob))) {
|
if (!scheduler.checkExists(TaskUtil.getJobKey(querySysJob))) {
|
||||||
querySysJob.setJobStatus(PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType());
|
querySysJob.setJobStatus(PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType());
|
||||||
log.warn("立刻执行定时任务-定时任务不在quartz中,任务id:{},强制状态为暂停并加入调度器", jobId);
|
log.warn("立刻执行定时任务-定时任务不在quartz中,任务id:{},强制状态为暂停并加入调度器", jobId);
|
||||||
@ -292,7 +281,6 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂停定时任务
|
* 暂停定时任务
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@SysLog("暂停定时任务")
|
@SysLog("暂停定时任务")
|
||||||
@ -302,15 +290,16 @@ public class SysJobController {
|
|||||||
public R shutdownJob(@PathVariable("id") Long id) {
|
public R shutdownJob(@PathVariable("id") Long id) {
|
||||||
SysJob querySysJob = this.sysJobService.getById(id);
|
SysJob querySysJob = this.sysJobService.getById(id);
|
||||||
// 更新定时任务状态条件,运行状态2更新为暂停状态3
|
// 更新定时任务状态条件,运行状态2更新为暂停状态3
|
||||||
this.sysJobService.updateById(SysJob.builder().jobId(querySysJob.getJobId())
|
this.sysJobService.updateById(SysJob.builder()
|
||||||
.jobStatus(PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType()).build());
|
.jobId(querySysJob.getJobId())
|
||||||
|
.jobStatus(PigQuartzEnum.JOB_STATUS_NOT_RUNNING.getType())
|
||||||
|
.build());
|
||||||
taskUtil.pauseJob(querySysJob, scheduler);
|
taskUtil.pauseJob(querySysJob, scheduler);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 唯一标识查询定时执行日志
|
* 唯一标识查询定时执行日志
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/job-log")
|
@GetMapping("/job-log")
|
||||||
@ -321,20 +310,18 @@ public class SysJobController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检验任务名称和任务组联合是否唯一
|
* 检验任务名称和任务组联合是否唯一
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/is-valid-task-name")
|
@GetMapping("/is-valid-task-name")
|
||||||
@Operation(description = "检验任务名称和任务组联合是否唯一")
|
@Operation(description = "检验任务名称和任务组联合是否唯一")
|
||||||
public R isValidTaskName(@RequestParam String jobName, @RequestParam String jobGroup) {
|
public R isValidTaskName(@RequestParam String jobName, @RequestParam String jobGroup) {
|
||||||
return this.sysJobService
|
return this.sysJobService
|
||||||
.count(Wrappers.query(SysJob.builder().jobName(jobName).jobGroup(jobGroup).build())) > 0
|
.count(Wrappers.query(SysJob.builder().jobName(jobName).jobGroup(jobGroup).build())) > 0
|
||||||
? R.failed("任务重复,请检查此组内是否已包含同名任务") : R.ok();
|
? R.failed("任务重复,请检查此组内是否已包含同名任务") : R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出任务
|
* 导出任务
|
||||||
*
|
|
||||||
* @param sysJob
|
* @param sysJob
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user