mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-24 14:26:40 +08:00
v3.12【新增】标签页Chome模式;【优化】优化很多细节
This commit is contained in:
parent
29064c176f
commit
db5e0062a0
35
smart-admin-api-java17-springboot3/.gitignore
vendored
35
smart-admin-api-java17-springboot3/.gitignore
vendored
@ -1,35 +0,0 @@
|
|||||||
HELP.md
|
|
||||||
target/
|
|
||||||
|
|
||||||
velocity.log
|
|
||||||
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
@ -52,6 +52,15 @@ public class AdminSmartJobController extends SupportBaseController {
|
|||||||
return jobService.queryJob(queryForm);
|
return jobService.queryJob(queryForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "定时任务-添加任务 @huke")
|
||||||
|
@PostMapping("/job/add")
|
||||||
|
@RepeatSubmit
|
||||||
|
public ResponseDTO<String> addJob(@RequestBody @Valid SmartJobAddForm addForm) {
|
||||||
|
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||||
|
addForm.setUpdateName(requestUser.getUserName());
|
||||||
|
return jobService.addJob(addForm);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "定时任务-更新-任务信息 @huke")
|
@Operation(summary = "定时任务-更新-任务信息 @huke")
|
||||||
@PostMapping("/job/update")
|
@PostMapping("/job/update")
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@ -70,6 +79,13 @@ public class AdminSmartJobController extends SupportBaseController {
|
|||||||
return jobService.updateJobEnabled(updateForm);
|
return jobService.updateJobEnabled(updateForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "定时任务-删除 @zhuoda")
|
||||||
|
@GetMapping("/job/delete")
|
||||||
|
@RepeatSubmit
|
||||||
|
public ResponseDTO<String> deleteJob(@RequestParam Integer jobId) {
|
||||||
|
return jobService.deleteJob(jobId, SmartRequestUtil.getRequestUser());
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "定时任务-执行记录-分页查询 @huke")
|
@Operation(summary = "定时任务-执行记录-分页查询 @huke")
|
||||||
@PostMapping("/job/log/query")
|
@PostMapping("/job/log/query")
|
||||||
public ResponseDTO<PageResult<SmartJobLogVO>> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) {
|
public ResponseDTO<PageResult<SmartJobLogVO>> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) {
|
||||||
|
@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.annotation.DbType;
|
|||||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.base.common.domain.DataScopePlugin;
|
import net.lab1024.sa.base.common.domain.DataScopePlugin;
|
||||||
import net.lab1024.sa.base.handler.MybatisPlusFillHandler;
|
import net.lab1024.sa.base.handler.MybatisPlusFillHandler;
|
||||||
@ -25,6 +24,7 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
@ -92,10 +92,10 @@ public class DataSourceConfig {
|
|||||||
@Value("${spring.datasource.druid.method.pointcut}")
|
@Value("${spring.datasource.druid.method.pointcut}")
|
||||||
String methodPointcut;
|
String methodPointcut;
|
||||||
|
|
||||||
@Resource
|
@jakarta.annotation.Resource
|
||||||
private MybatisPlusInterceptor paginationInterceptor;
|
private MybatisPlusInterceptor paginationInterceptor;
|
||||||
|
|
||||||
@Resource
|
@jakarta.annotation.Resource
|
||||||
private DataScopePlugin dataScopePlugin;
|
private DataScopePlugin dataScopePlugin;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -136,7 +136,7 @@ public class DataSourceConfig {
|
|||||||
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
|
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
|
||||||
factoryBean.setDataSource(druidDataSource());
|
factoryBean.setDataSource(druidDataSource());
|
||||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
org.springframework.core.io.Resource[] resources = resolver.getResources("classpath*:/mapper/**/*.xml");
|
Resource[] resources = resolver.getResources("classpath*:/mapper/**/*.xml");
|
||||||
factoryBean.setMapperLocations(resources);
|
factoryBean.setMapperLocations(resources);
|
||||||
|
|
||||||
// 设置 MyBatis-Plus 分页插件 注意此处myBatisPlugin一定要放在后面
|
// 设置 MyBatis-Plus 分页插件 注意此处myBatisPlugin一定要放在后面
|
||||||
|
@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Json 序列化配置
|
* json 序列化配置
|
||||||
*
|
*
|
||||||
* @Author 1024创新实验室-主任: 卓大
|
* @Author 1024创新实验室-主任: 卓大
|
||||||
* @Date 2017-11-28 15:21:10
|
* @Date 2017-11-28 15:21:10
|
||||||
|
@ -33,7 +33,7 @@ public class RedisConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<String, Object> redisTemplate() {
|
public RedisTemplate<String, Object> redisTemplate() {
|
||||||
|
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
|
||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
om.registerModule(new JavaTimeModule())
|
om.registerModule(new JavaTimeModule())
|
||||||
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||||
@ -41,10 +41,11 @@ public class RedisConfig {
|
|||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(om, Object.class);
|
|
||||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
// enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping
|
// enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping
|
||||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||||
|
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||||
template.setConnectionFactory(factory);
|
template.setConnectionFactory(factory);
|
||||||
template.setKeySerializer(new StringRedisSerializer());
|
template.setKeySerializer(new StringRedisSerializer());
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package net.lab1024.sa.base.config;
|
package net.lab1024.sa.base.config;
|
||||||
|
|
||||||
import cn.dev33.satoken.config.SaTokenConfig;
|
import cn.dev33.satoken.config.SaTokenConfig;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService;
|
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 三级等保配置初始化后最低活跃频率全局配置
|
* 三级等保配置初始化后最低活跃频率全局配置
|
||||||
@ -26,6 +25,7 @@ public class TokenConfig {
|
|||||||
// 此配置会覆盖 sa-base.yaml 中的配置
|
// 此配置会覆盖 sa-base.yaml 中的配置
|
||||||
@Resource
|
@Resource
|
||||||
public void configSaToken(SaTokenConfig config) {
|
public void configSaToken(SaTokenConfig config) {
|
||||||
|
|
||||||
config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds());
|
config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition;
|
||||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
|
|
||||||
@ -47,11 +48,12 @@ public class UrlConfig {
|
|||||||
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
|
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
|
||||||
for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map.entrySet()) {
|
for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map.entrySet()) {
|
||||||
RequestMappingInfo requestMappingInfo = entry.getKey();
|
RequestMappingInfo requestMappingInfo = entry.getKey();
|
||||||
if(requestMappingInfo.getPatternsCondition() == null){
|
PathPatternsRequestCondition pathPatternsCondition = requestMappingInfo.getPathPatternsCondition();
|
||||||
|
if(pathPatternsCondition == null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> urls = requestMappingInfo.getPatternsCondition().getPatterns();
|
Set<String> urls = pathPatternsCondition.getPatternValues();
|
||||||
if (CollectionUtils.isEmpty(urls)) {
|
if (CollectionUtils.isEmpty(urls)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,10 @@ public class CaptchaService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DefaultKaptcha defaultKaptcha;
|
private DefaultKaptcha defaultKaptcha;
|
||||||
@Autowired
|
|
||||||
|
@Resource
|
||||||
private SystemEnvironment systemEnvironment;
|
private SystemEnvironment systemEnvironment;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import java.util.stream.Collectors;
|
|||||||
* @Date 2022/9/29 17:20:41
|
* @Date 2022/9/29 17:20:41
|
||||||
* @Wechat zhuoda1024
|
* @Wechat zhuoda1024
|
||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EntityVariableService extends CodeGenerateBaseVariableService {
|
public class EntityVariableService extends CodeGenerateBaseVariableService {
|
||||||
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
* @Date 2022/5/26 19:40:55
|
* @Date 2022/5/26 19:40:55
|
||||||
* @Wechat zhuoda1024
|
* @Wechat zhuoda1024
|
||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DictService {
|
public class DictService {
|
||||||
@ -39,10 +39,6 @@ public class DictService {
|
|||||||
private DictValueDao dictValueDao;
|
private DictValueDao dictValueDao;
|
||||||
@Resource
|
@Resource
|
||||||
private DictCacheService dictCacheService;
|
private DictCacheService dictCacheService;
|
||||||
/**
|
|
||||||
* CODE锁
|
|
||||||
*/
|
|
||||||
private static final Interner<String> CODE_POOL = Interners.newWeakInterner();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,15 +47,15 @@ public class DictService {
|
|||||||
* @param keyAddForm
|
* @param keyAddForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
|
public synchronized ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
|
||||||
synchronized (CODE_POOL.intern(keyAddForm.getKeyCode())) {
|
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
|
if (dictKeyEntity != null) {
|
||||||
if (dictKeyEntity != null) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
|
|
||||||
dictKeyDao.insert(dictKeyEntity);
|
|
||||||
}
|
}
|
||||||
|
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
|
||||||
|
dictKeyDao.insert(dictKeyEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,15 +65,15 @@ public class DictService {
|
|||||||
* @param valueAddForm
|
* @param valueAddForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
|
public synchronized ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
|
||||||
synchronized (CODE_POOL.intern(valueAddForm.getValueCode())) {
|
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false);
|
||||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false);
|
if (dictValueEntity != null) {
|
||||||
if (dictValueEntity != null) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
|
|
||||||
dictValueDao.insert(dictValueEntity);
|
|
||||||
}
|
}
|
||||||
|
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
|
||||||
|
dictValueDao.insert(dictValueEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,15 +83,15 @@ public class DictService {
|
|||||||
* @param keyUpdateForm
|
* @param keyUpdateForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
|
public synchronized ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
|
||||||
synchronized (CODE_POOL.intern(keyUpdateForm.getKeyCode())) {
|
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
|
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
|
||||||
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
|
|
||||||
dictKeyDao.updateById(dictKeyUpdateEntity);
|
|
||||||
}
|
}
|
||||||
|
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
|
||||||
|
dictKeyDao.updateById(dictKeyUpdateEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,19 +101,19 @@ public class DictService {
|
|||||||
* @param valueUpdateForm
|
* @param valueUpdateForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
|
public synchronized ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId());
|
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId());
|
||||||
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) {
|
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) {
|
||||||
return ResponseDTO.userErrorParam("key不能存在");
|
return ResponseDTO.userErrorParam("key不能存在");
|
||||||
}
|
}
|
||||||
synchronized (CODE_POOL.intern(valueUpdateForm.getValueCode())) {
|
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false);
|
||||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false);
|
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
|
||||||
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
|
|
||||||
dictValueDao.updateById(dictValueUpdateEntity);
|
|
||||||
}
|
}
|
||||||
|
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
|
||||||
|
dictValueDao.updateById(dictValueUpdateEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,11 +123,13 @@ public class DictService {
|
|||||||
* @param keyIdList
|
* @param keyIdList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
public synchronized ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
||||||
if (CollectionUtils.isEmpty(keyIdList)) {
|
if (CollectionUtils.isEmpty(keyIdList)) {
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,11 +139,13 @@ public class DictService {
|
|||||||
* @param valueIdList
|
* @param valueIdList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
public synchronized ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
||||||
if (CollectionUtils.isEmpty(valueIdList)) {
|
if (CollectionUtils.isEmpty(valueIdList)) {
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||||
import net.lab1024.sa.base.common.domain.PageResult;
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
|
import net.lab1024.sa.base.common.domain.RequestUser;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||||
@ -125,27 +126,61 @@ public class SmartJobService {
|
|||||||
return ResponseDTO.ok(pageResult);
|
return ResponseDTO.ok(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加定时任务
|
||||||
|
*
|
||||||
|
* @param addForm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public synchronized ResponseDTO<String> addJob(SmartJobAddForm addForm) {
|
||||||
|
// 校验参数
|
||||||
|
ResponseDTO<String> checkRes = this.checkParam(addForm);
|
||||||
|
if (!checkRes.getOk()) {
|
||||||
|
return checkRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验重复的执行类
|
||||||
|
SmartJobEntity existJobClass = jobDao.selectByJobClass(addForm.getJobClass());
|
||||||
|
if (null != existJobClass && !existJobClass.getDeletedFlag()) {
|
||||||
|
return ResponseDTO.userErrorParam("已经存在相同的执行类");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加数据
|
||||||
|
SmartJobEntity jobEntity = SmartBeanUtil.copy(addForm, SmartJobEntity.class);
|
||||||
|
jobDao.insert(jobEntity);
|
||||||
|
|
||||||
|
// 更新执行端
|
||||||
|
SmartJobMsg jobMsg = new SmartJobMsg();
|
||||||
|
jobMsg.setJobId(jobEntity.getJobId());
|
||||||
|
jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB);
|
||||||
|
jobMsg.setUpdateName(addForm.getUpdateName());
|
||||||
|
jobClientManager.publishToClient(jobMsg);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新定时任务
|
* 更新定时任务
|
||||||
*
|
*
|
||||||
* @param updateForm
|
* @param updateForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> updateJob(SmartJobUpdateForm updateForm) {
|
public synchronized ResponseDTO<String> updateJob(SmartJobUpdateForm updateForm) {
|
||||||
// 校验参数
|
// 校验参数
|
||||||
Integer jobId = updateForm.getJobId();
|
Integer jobId = updateForm.getJobId();
|
||||||
SmartJobEntity jobEntity = jobDao.selectById(jobId);
|
SmartJobEntity jobEntity = jobDao.selectById(jobId);
|
||||||
if (null == jobEntity) {
|
if (null == jobEntity) {
|
||||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
}
|
}
|
||||||
// 校验触发时间配置
|
|
||||||
String triggerType = updateForm.getTriggerType();
|
ResponseDTO<String> checkRes = this.checkParam(updateForm);
|
||||||
String triggerValue = updateForm.getTriggerValue();
|
if (!checkRes.getOk()) {
|
||||||
if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) {
|
return checkRes;
|
||||||
return ResponseDTO.userErrorParam("cron表达式错误");
|
|
||||||
}
|
}
|
||||||
if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) {
|
|
||||||
return ResponseDTO.userErrorParam("固定间隔错误:整数且大于0");
|
// 校验重复的执行类
|
||||||
|
SmartJobEntity existJobClass = jobDao.selectByJobClass(updateForm.getJobClass());
|
||||||
|
if (null != existJobClass && !existJobClass.getDeletedFlag() && !existJobClass.getJobId().equals(jobId)) {
|
||||||
|
return ResponseDTO.userErrorParam("已经存在相同的执行类");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新数据
|
// 更新数据
|
||||||
@ -161,6 +196,27 @@ public class SmartJobService {
|
|||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验参数
|
||||||
|
* 如需其他校验,请自行添加校验逻辑
|
||||||
|
*
|
||||||
|
* @param addForm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ResponseDTO<String> checkParam(SmartJobAddForm addForm) {
|
||||||
|
// 校验触发时间配置
|
||||||
|
String triggerType = addForm.getTriggerType();
|
||||||
|
String triggerValue = addForm.getTriggerValue();
|
||||||
|
if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) {
|
||||||
|
return ResponseDTO.userErrorParam("cron表达式错误");
|
||||||
|
}
|
||||||
|
if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) {
|
||||||
|
return ResponseDTO.userErrorParam("固定间隔配置错误:必须是大于0的整数");
|
||||||
|
}
|
||||||
|
// 校验job class
|
||||||
|
return SmartJobUtil.checkJobClass(addForm.getJobClass());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新定时任务-是否开启
|
* 更新定时任务-是否开启
|
||||||
*
|
*
|
||||||
@ -218,28 +274,23 @@ public class SmartJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增定时任务
|
* 移除定时任务
|
||||||
* ps:目前没有业务场景需要通过接口 添加任务
|
* 物理删除
|
||||||
* 因为新增定时任务无论如何都需要 手动编码
|
|
||||||
* 需要时手动给数据库增加一条就行
|
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* @author huke
|
* @author huke
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> addJob() {
|
public synchronized ResponseDTO<String> deleteJob(Integer jobId, RequestUser requestUser) {
|
||||||
return ResponseDTO.userErrorParam("暂未支持");
|
// 删除任务
|
||||||
|
jobDao.updateDeletedFlag(jobId, Boolean.TRUE);
|
||||||
|
|
||||||
|
// 更新执行端
|
||||||
|
SmartJobMsg jobMsg = new SmartJobMsg();
|
||||||
|
jobMsg.setJobId(jobId);
|
||||||
|
jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB);
|
||||||
|
jobMsg.setUpdateName(requestUser.getUserName());
|
||||||
|
jobClientManager.publishToClient(jobMsg);
|
||||||
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除定时任务
|
|
||||||
* ps:目前没有业务场景需要通过接口移除,理由同 {@link SmartJobService#addJob},
|
|
||||||
* 彻底移除始终都需要手动删除代码
|
|
||||||
* 如果只是想暂停任务执行,可以调用 {@link SmartJobService#updateJobEnabled}
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @author huke
|
|
||||||
*/
|
|
||||||
public ResponseDTO<String> delJob() {
|
|
||||||
return ResponseDTO.userErrorParam("暂未支持");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package net.lab1024.sa.base.module.support.job.api.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||||
|
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||||
|
import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务 添加
|
||||||
|
*
|
||||||
|
* @author huke
|
||||||
|
* @date 2024/12/19 19:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmartJobAddForm {
|
||||||
|
|
||||||
|
@Schema(description = "任务名称")
|
||||||
|
@NotBlank(message = "任务名称不能为空")
|
||||||
|
@Length(max = 100, message = "任务名称最多100字符")
|
||||||
|
private String jobName;
|
||||||
|
|
||||||
|
@Schema(description = "任务执行类")
|
||||||
|
@NotBlank(message = "任务执行类不能为空")
|
||||||
|
@Length(max = 200, message = "任务执行类最多200字符")
|
||||||
|
private String jobClass;
|
||||||
|
|
||||||
|
@SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class)
|
||||||
|
@CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误")
|
||||||
|
private String triggerType;
|
||||||
|
|
||||||
|
@Schema(description = "触发配置")
|
||||||
|
@NotBlank(message = "触发配置不能为空")
|
||||||
|
@Length(max = 100, message = "触发配置最多100字符")
|
||||||
|
private String triggerValue;
|
||||||
|
|
||||||
|
@Schema(description = "定时任务参数|可选")
|
||||||
|
@Length(max = 1000, message = "定时任务参数最多1000字符")
|
||||||
|
private String param;
|
||||||
|
|
||||||
|
@Schema(description = "是否开启")
|
||||||
|
@NotNull(message = "是否开启不能为空")
|
||||||
|
private Boolean enabledFlag;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
@Length(max = 250, message = "任务备注最多250字符")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@NotNull(message = "排序不能为空")
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String updateName;
|
||||||
|
}
|
@ -27,4 +27,7 @@ public class SmartJobQueryForm extends PageParam {
|
|||||||
|
|
||||||
@Schema(description = "是否启用|可选")
|
@Schema(description = "是否启用|可选")
|
||||||
private Boolean enabledFlag;
|
private Boolean enabledFlag;
|
||||||
|
|
||||||
|
@Schema(description = "是否删除|可选")
|
||||||
|
private Boolean deletedFlag;
|
||||||
}
|
}
|
||||||
|
@ -16,47 +16,9 @@ import org.hibernate.validator.constraints.Length;
|
|||||||
* @date 2024/6/17 21:30
|
* @date 2024/6/17 21:30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class SmartJobUpdateForm {
|
public class SmartJobUpdateForm extends SmartJobAddForm {
|
||||||
|
|
||||||
@Schema(description = "任务id")
|
@Schema(description = "任务id")
|
||||||
@NotNull(message = "任务id不能为空")
|
@NotNull(message = "任务id不能为空")
|
||||||
private Integer jobId;
|
private Integer jobId;
|
||||||
|
|
||||||
@Schema(description = "任务名称")
|
|
||||||
@NotBlank(message = "任务名称不能为空")
|
|
||||||
@Length(max = 100, message = "任务名称最多100字符")
|
|
||||||
private String jobName;
|
|
||||||
|
|
||||||
@Schema(description = "任务执行类")
|
|
||||||
@NotBlank(message = "任务执行类不能为空")
|
|
||||||
@Length(max = 200, message = "任务执行类最多200字符")
|
|
||||||
private String jobClass;
|
|
||||||
|
|
||||||
@SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class)
|
|
||||||
@CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误")
|
|
||||||
private String triggerType;
|
|
||||||
|
|
||||||
@Schema(description = "触发配置")
|
|
||||||
@NotBlank(message = "触发配置不能为空")
|
|
||||||
@Length(max = 100, message = "触发配置最多100字符")
|
|
||||||
private String triggerValue;
|
|
||||||
|
|
||||||
@Schema(description = "定时任务参数|可选")
|
|
||||||
@Length(max = 1000, message = "定时任务参数最多1000字符")
|
|
||||||
private String param;
|
|
||||||
|
|
||||||
@Schema(description = "是否开启")
|
|
||||||
@NotNull(message = "是否开启不能为空")
|
|
||||||
private Boolean enabledFlag;
|
|
||||||
|
|
||||||
@Schema(description = "备注")
|
|
||||||
@Length(max = 250, message = "任务备注最多250字符")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
@NotNull(message = "排序不能为空")
|
|
||||||
@Schema(description = "排序")
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
@Schema(hidden = true)
|
|
||||||
private String updateName;
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.lab1024.sa.base.module.support.job.constant;
|
package net.lab1024.sa.base.module.support.job.constant;
|
||||||
|
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.sa.base.module.support.job.core.SmartJob;
|
||||||
import org.springframework.scheduling.support.CronExpression;
|
import org.springframework.scheduling.support.CronExpression;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
@ -98,7 +100,7 @@ public class SmartJobUtil {
|
|||||||
} else if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType)) {
|
} else if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType)) {
|
||||||
Integer fixedDelay = getFixedDelayVal(triggerVal);
|
Integer fixedDelay = getFixedDelayVal(triggerVal);
|
||||||
LocalDateTime startTime = null == lastExecuteTime || lastExecuteTime.plusSeconds(fixedDelay).isBefore(nowTime)
|
LocalDateTime startTime = null == lastExecuteTime || lastExecuteTime.plusSeconds(fixedDelay).isBefore(nowTime)
|
||||||
? nowTime : lastExecuteTime;
|
? nowTime : lastExecuteTime;
|
||||||
nextTimeList = SmartJobUtil.queryNextTime(fixedDelay, startTime, num);
|
nextTimeList = SmartJobUtil.queryNextTime(fixedDelay, startTime, num);
|
||||||
}
|
}
|
||||||
return nextTimeList;
|
return nextTimeList;
|
||||||
@ -174,6 +176,24 @@ public class SmartJobUtil {
|
|||||||
return runtime.getName().split("@")[0];
|
return runtime.getName().split("@")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据className 判断job class
|
||||||
|
*/
|
||||||
|
public static ResponseDTO<String> checkJobClass(String className) {
|
||||||
|
try {
|
||||||
|
Class<?> aClass = Class.forName(className);
|
||||||
|
// 判断是否实现了 SmartJob
|
||||||
|
if (!SmartJob.class.isAssignableFrom(aClass)) {
|
||||||
|
return ResponseDTO.userErrorParam(className + " 执行类没有实现 SmartJob 接口");
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return ResponseDTO.userErrorParam("没有在代码中发现执行类:" + className);
|
||||||
|
}
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LocalDateTime startTime = LocalDateTime.now();
|
LocalDateTime startTime = LocalDateTime.now();
|
||||||
List<LocalDateTime> timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3);
|
List<LocalDateTime> timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3);
|
||||||
@ -184,5 +204,7 @@ public class SmartJobUtil {
|
|||||||
|
|
||||||
System.out.println("project path ->" + getProgramPath());
|
System.out.println("project path ->" + getProgramPath());
|
||||||
System.out.println("project process id ->" + getProcessId());
|
System.out.println("project process id ->" + getProcessId());
|
||||||
|
ResponseDTO<String> res = checkJobClass("net.lab1024.sa.base.module.support.job.sample.SmartJobSample1");
|
||||||
|
System.out.println(res.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,10 @@ public class SmartJobLauncher {
|
|||||||
if (!jobEntity.getEnabledFlag()) {
|
if (!jobEntity.getEnabledFlag()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// 任务删除
|
||||||
|
if (jobEntity.getDeletedFlag()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 查找任务实现类
|
// 查找任务实现类
|
||||||
SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass());
|
SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass());
|
||||||
if (null == jobImpl) {
|
if (null == jobImpl) {
|
||||||
@ -135,6 +139,7 @@ public class SmartJobLauncher {
|
|||||||
private static boolean isNeedUpdate(SmartJobEntity oldJob, SmartJobEntity newJob) {
|
private static boolean isNeedUpdate(SmartJobEntity oldJob, SmartJobEntity newJob) {
|
||||||
// cron为空时 fixedDelay 才有意义
|
// cron为空时 fixedDelay 才有意义
|
||||||
return !Objects.equals(oldJob.getEnabledFlag(), newJob.getEnabledFlag())
|
return !Objects.equals(oldJob.getEnabledFlag(), newJob.getEnabledFlag())
|
||||||
|
|| !Objects.equals(oldJob.getDeletedFlag(), newJob.getDeletedFlag())
|
||||||
|| !Objects.equals(oldJob.getTriggerType(), newJob.getTriggerType())
|
|| !Objects.equals(oldJob.getTriggerType(), newJob.getTriggerType())
|
||||||
|| !Objects.equals(oldJob.getTriggerValue(), newJob.getTriggerValue())
|
|| !Objects.equals(oldJob.getTriggerValue(), newJob.getTriggerValue())
|
||||||
|| !Objects.equals(oldJob.getJobClass(), newJob.getJobClass());
|
|| !Objects.equals(oldJob.getJobClass(), newJob.getJobClass());
|
||||||
|
@ -29,4 +29,20 @@ public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SmartJobVO> query(Page<?> page, @Param("query") SmartJobQueryForm queryForm);
|
List<SmartJobVO> query(Page<?> page, @Param("query") SmartJobQueryForm queryForm);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 假删除
|
||||||
|
*
|
||||||
|
* @param jobId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void updateDeletedFlag(@Param("jobId") Integer jobId, @Param("deletedFlag") Boolean deletedFlag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 任务class 查找
|
||||||
|
*
|
||||||
|
* @param jobClass
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SmartJobEntity selectByJobClass(@Param("jobClass") String jobClass);
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,11 @@ public class SmartJobEntity {
|
|||||||
*/
|
*/
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
private Boolean deletedFlag;
|
||||||
|
|
||||||
private String updateName;
|
private String updateName;
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
@ -6,6 +6,8 @@ import freemarker.cache.StringTemplateLoader;
|
|||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.mail.MessagingException;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.domain.SystemEnvironment;
|
import net.lab1024.sa.base.common.domain.SystemEnvironment;
|
||||||
@ -23,8 +25,6 @@ import org.springframework.mail.javamail.JavaMailSender;
|
|||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import jakarta.mail.MessagingException;
|
|
||||||
import jakarta.mail.internet.MimeMessage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
@ -2,9 +2,11 @@ package net.lab1024.sa.base.module.support.reload.core;
|
|||||||
|
|
||||||
|
|
||||||
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadItem;
|
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadItem;
|
||||||
|
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadObject;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadResult;
|
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadResult;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,21 +16,29 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* @Date 2015-03-02 19:11:52
|
* @Date 2015-03-02 19:11:52
|
||||||
* @Wechat zhuoda1024
|
* @Wechat zhuoda1024
|
||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSmartReloadCommand {
|
public abstract class AbstractSmartReloadCommand {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前ReloadItem的存储器
|
* 当前ReloadItem的存储器
|
||||||
*/
|
*/
|
||||||
private static final ConcurrentHashMap<String, String> TAG_IDENTIFIER_MAP = new ConcurrentHashMap<>();
|
private ConcurrentHashMap<String, String> tagIdentifierMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private SmartReloadManager smartReloadManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void setReloadManager(SmartReloadManager smartReloadManager) {
|
||||||
|
this.smartReloadManager = smartReloadManager;
|
||||||
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
List<SmartReloadItem> smartReloadItems = this.readReloadItem();
|
List<SmartReloadItem> smartReloadItems = this.readReloadItem();
|
||||||
if (smartReloadItems != null) {
|
if (smartReloadItems != null) {
|
||||||
for (SmartReloadItem smartReloadItem : smartReloadItems) {
|
for (SmartReloadItem smartReloadItem : smartReloadItems) {
|
||||||
TAG_IDENTIFIER_MAP.put(smartReloadItem.getTag(), smartReloadItem.getIdentification());
|
tagIdentifierMap.put(smartReloadItem.getTag(), smartReloadItem.getIdentification());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +67,7 @@ public abstract class AbstractSmartReloadCommand {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ConcurrentHashMap<String, String> getTagIdentifierMap() {
|
public ConcurrentHashMap<String, String> getTagIdentifierMap() {
|
||||||
return TAG_IDENTIFIER_MAP;
|
return tagIdentifierMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,6 +77,20 @@ public abstract class AbstractSmartReloadCommand {
|
|||||||
* @param identification
|
* @param identification
|
||||||
*/
|
*/
|
||||||
public void putIdentifierMap(String tag, String identification) {
|
public void putIdentifierMap(String tag, String identification) {
|
||||||
TAG_IDENTIFIER_MAP.put(tag, identification);
|
tagIdentifierMap.put(tag, identification);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取重载对象
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SmartReloadObject reloadObject(String tag) {
|
||||||
|
if (this.smartReloadManager == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Map<String, SmartReloadObject> reloadObjectMap = smartReloadManager.reloadObjectMap();
|
||||||
|
return reloadObjectMap.get(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
package net.lab1024.sa.base.module.support.reload.core;
|
package net.lab1024.sa.base.module.support.reload.core;
|
||||||
|
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
import jakarta.annotation.PreDestroy;
|
import jakarta.annotation.PreDestroy;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadObject;
|
import net.lab1024.sa.base.module.support.reload.core.domain.SmartReloadObject;
|
||||||
import net.lab1024.sa.base.module.support.reload.core.thread.SmartReloadRunnable;
|
import net.lab1024.sa.base.module.support.reload.core.thread.SmartReloadRunnable;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
@ -32,7 +36,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SmartReloadManager implements ApplicationListener<ContextRefreshedEvent> {
|
public class SmartReloadManager implements BeanPostProcessor {
|
||||||
|
|
||||||
|
private static final String THREAD_NAME_PREFIX = "smart-reload";
|
||||||
|
private static final int THREAD_COUNT = 1;
|
||||||
|
|
||||||
@Value("${reload.interval-seconds}")
|
@Value("${reload.interval-seconds}")
|
||||||
private Integer intervalSeconds;
|
private Integer intervalSeconds;
|
||||||
@ -40,27 +47,13 @@ public class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
|||||||
@Resource
|
@Resource
|
||||||
private AbstractSmartReloadCommand reloadCommand;
|
private AbstractSmartReloadCommand reloadCommand;
|
||||||
|
|
||||||
private final static Map<String, SmartReloadObject> RELOAD_OBJECT_MAP = new ConcurrentHashMap<>();
|
private final Map<String, SmartReloadObject> reloadObjectMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private ScheduledThreadPoolExecutor threadPoolExecutor;
|
private ScheduledThreadPoolExecutor threadPoolExecutor;
|
||||||
|
|
||||||
private static final String THREAD_NAME_PREFIX = "smart-reload";
|
|
||||||
|
|
||||||
private static final int THREAD_COUNT = 1;
|
|
||||||
|
|
||||||
private ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
||||||
this.applicationContext = event.getApplicationContext();
|
|
||||||
|
|
||||||
// 初始化
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
this.registerReloadBean();
|
|
||||||
|
|
||||||
if (threadPoolExecutor != null) {
|
if (threadPoolExecutor != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,8 +66,10 @@ public class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
|||||||
return t;
|
return t;
|
||||||
});
|
});
|
||||||
this.threadPoolExecutor.scheduleWithFixedDelay(new SmartReloadRunnable(this.reloadCommand), 10, this.intervalSeconds, TimeUnit.SECONDS);
|
this.threadPoolExecutor.scheduleWithFixedDelay(new SmartReloadRunnable(this.reloadCommand), 10, this.intervalSeconds, TimeUnit.SECONDS);
|
||||||
|
this.reloadCommand.setReloadManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
if (this.threadPoolExecutor != null) {
|
if (this.threadPoolExecutor != null) {
|
||||||
@ -83,28 +78,24 @@ public class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册 reload bean
|
@Override
|
||||||
*/
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||||
public void registerReloadBean() {
|
Method[] methods = ReflectionUtils.getAllDeclaredMethods(bean.getClass());
|
||||||
// 遍历所有Bean
|
for (Method method : methods) {
|
||||||
String[] beanNames = applicationContext.getBeanDefinitionNames();
|
SmartReload smartReload = method.getAnnotation(SmartReload.class);
|
||||||
for (String beanName : beanNames) {
|
if (smartReload == null) {
|
||||||
Object bean = applicationContext.getBean(beanName);
|
continue;
|
||||||
ReflectionUtils.doWithMethods(bean.getClass(), method -> {
|
}
|
||||||
SmartReload smartReload = method.getAnnotation(SmartReload.class);
|
int paramCount = method.getParameterCount();
|
||||||
if (smartReload == null) {
|
if (paramCount > 1) {
|
||||||
return;
|
log.error("<<SmartReloadManager>> register tag reload : " + smartReload.value() + " , param count cannot greater than one !");
|
||||||
}
|
continue;
|
||||||
int paramCount = method.getParameterCount();
|
}
|
||||||
if (paramCount > 1) {
|
String reloadTag = smartReload.value();
|
||||||
log.error("<<SmartReloadManager>> register tag reload : " + smartReload.value() + " , param count cannot greater than one !");
|
this.register(reloadTag, new SmartReloadObject(bean, method));
|
||||||
return;
|
|
||||||
}
|
|
||||||
String reloadTag = smartReload.value();
|
|
||||||
this.register(reloadTag, new SmartReloadObject(bean, method));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,10 +105,10 @@ public class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
|||||||
* @param smartReloadObject
|
* @param smartReloadObject
|
||||||
*/
|
*/
|
||||||
private void register(String tag, SmartReloadObject smartReloadObject) {
|
private void register(String tag, SmartReloadObject smartReloadObject) {
|
||||||
if (RELOAD_OBJECT_MAP.containsKey(tag)) {
|
if (reloadObjectMap.containsKey(tag)) {
|
||||||
log.error("<<SmartReloadManager>> register duplicated tag reload : " + tag + " , and it will be cover!");
|
log.error("<<SmartReloadManager>> register duplicated tag reload : " + tag + " , and it will be cover!");
|
||||||
}
|
}
|
||||||
RELOAD_OBJECT_MAP.put(tag, smartReloadObject);
|
reloadObjectMap.put(tag, smartReloadObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +116,9 @@ public class SmartReloadManager implements ApplicationListener<ContextRefreshedE
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static SmartReloadObject getReloadObject(String tag) {
|
public Map<String, SmartReloadObject> reloadObjectMap() {
|
||||||
return RELOAD_OBJECT_MAP.get(tag);
|
return this.reloadObjectMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,17 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* @Date 2015-03-02 19:11:52
|
* @Date 2015-03-02 19:11:52
|
||||||
* @Wechat zhuoda1024
|
* @Wechat zhuoda1024
|
||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SmartReloadRunnable implements Runnable {
|
public class SmartReloadRunnable implements Runnable {
|
||||||
|
|
||||||
private final AbstractSmartReloadCommand reloadCommand;
|
private AbstractSmartReloadCommand abstractSmartReloadCommand;
|
||||||
|
|
||||||
private boolean isInit = false;
|
private boolean isInit = false;
|
||||||
|
|
||||||
public SmartReloadRunnable(AbstractSmartReloadCommand reloadCommand) {
|
public SmartReloadRunnable(AbstractSmartReloadCommand abstractSmartReloadCommand) {
|
||||||
this.reloadCommand = reloadCommand;
|
this.abstractSmartReloadCommand = abstractSmartReloadCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,23 +47,23 @@ public class SmartReloadRunnable implements Runnable {
|
|||||||
*/
|
*/
|
||||||
private void doTask() {
|
private void doTask() {
|
||||||
if (!isInit) {
|
if (!isInit) {
|
||||||
this.reloadCommand.init();
|
this.abstractSmartReloadCommand.init();
|
||||||
isInit = true;
|
isInit = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SmartReloadItem> smartReloadItemList = this.reloadCommand.readReloadItem();
|
List<SmartReloadItem> smartReloadItemList = this.abstractSmartReloadCommand.readReloadItem();
|
||||||
ConcurrentHashMap<String, String> tagIdentifierMap = this.reloadCommand.getTagIdentifierMap();
|
ConcurrentHashMap<String, String> tagIdentifierMap = this.abstractSmartReloadCommand.getTagIdentifierMap();
|
||||||
for (SmartReloadItem smartReloadItem : smartReloadItemList) {
|
for (SmartReloadItem smartReloadItem : smartReloadItemList) {
|
||||||
String tag = smartReloadItem.getTag();
|
String tag = smartReloadItem.getTag();
|
||||||
String tagIdentifier = smartReloadItem.getIdentification();
|
String tagIdentifier = smartReloadItem.getIdentification();
|
||||||
String preTagChangeIdentifier = tagIdentifierMap.get(tag);
|
String preTagChangeIdentifier = tagIdentifierMap.get(tag);
|
||||||
// 数据不一致
|
// 数据不一致
|
||||||
if (preTagChangeIdentifier == null || !preTagChangeIdentifier.equals(tagIdentifier)) {
|
if (preTagChangeIdentifier == null || !preTagChangeIdentifier.equals(tagIdentifier)) {
|
||||||
this.reloadCommand.putIdentifierMap(tag, tagIdentifier);
|
this.abstractSmartReloadCommand.putIdentifierMap(tag, tagIdentifier);
|
||||||
// 执行重新加载此项的动作
|
// 执行重新加载此项的动作
|
||||||
SmartReloadResult smartReloadResult = this.doReload(smartReloadItem);
|
SmartReloadResult smartReloadResult = this.doReload(smartReloadItem);
|
||||||
this.reloadCommand.handleReloadResult(smartReloadResult);
|
this.abstractSmartReloadCommand.handleReloadResult(smartReloadResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class SmartReloadRunnable implements Runnable {
|
|||||||
*/
|
*/
|
||||||
private SmartReloadResult doReload(SmartReloadItem smartReloadItem) {
|
private SmartReloadResult doReload(SmartReloadItem smartReloadItem) {
|
||||||
SmartReloadResult result = new SmartReloadResult();
|
SmartReloadResult result = new SmartReloadResult();
|
||||||
SmartReloadObject smartReloadObject = SmartReloadManager.getReloadObject(smartReloadItem.getTag());
|
SmartReloadObject smartReloadObject = this.abstractSmartReloadCommand.reloadObject(smartReloadItem.getTag());
|
||||||
try {
|
try {
|
||||||
if (smartReloadObject == null) {
|
if (smartReloadObject == null) {
|
||||||
result.setResult(false);
|
result.setResult(false);
|
||||||
|
@ -5,6 +5,8 @@ import net.lab1024.sa.base.common.domain.ResponseDTO;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 三级等保 文件上传 相关
|
* 三级等保 文件上传 相关
|
||||||
*
|
*
|
||||||
|
@ -49,5 +49,4 @@ public interface ${name.upperCamel}Dao extends BaseMapper<${name.upperCamel}Enti
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
tables.create_time,
|
tables.create_time,
|
||||||
tables.update_time,
|
tables.update_time,
|
||||||
t_code_generator_config.update_time configTime
|
t_code_generator_config.update_time configTime
|
||||||
from information_schema.tables
|
from information_schema.tables tables
|
||||||
left join t_code_generator_config on tables.table_name = t_code_generator_config.table_name
|
left join t_code_generator_config on tables.table_name = t_code_generator_config.table_name
|
||||||
where tables.table_schema = (select database())
|
where tables.table_schema = (select database())
|
||||||
<if test="queryForm.tableNameKeywords != null and queryForm.tableNameKeywords != ''">
|
<if test="queryForm.tableNameKeywords != null and queryForm.tableNameKeywords != ''">
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="net.lab1024.sa.base.module.support.job.repository.SmartJobDao">
|
<mapper namespace="net.lab1024.sa.base.module.support.job.repository.SmartJobDao">
|
||||||
|
|
||||||
|
<update id="updateDeletedFlag">
|
||||||
|
update t_smart_job
|
||||||
|
set deleted_flag = #{deletedFlag}
|
||||||
|
where job_id = #{jobId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<!-- 定时任务-分页查询 -->
|
<!-- 定时任务-分页查询 -->
|
||||||
<select id="query" resultType="net.lab1024.sa.base.module.support.job.api.domain.SmartJobVO">
|
<select id="query" resultType="net.lab1024.sa.base.module.support.job.api.domain.SmartJobVO">
|
||||||
SELECT *
|
SELECT *
|
||||||
@ -19,10 +25,19 @@
|
|||||||
<if test="query.enabledFlag != null">
|
<if test="query.enabledFlag != null">
|
||||||
AND enabled_flag = #{query.enabledFlag}
|
AND enabled_flag = #{query.enabledFlag}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="query.deletedFlag != null">
|
||||||
|
AND deleted_flag = #{query.deletedFlag}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
<if test="query.sortItemList == null or query.sortItemList.size == 0">
|
<if test="query.sortItemList == null or query.sortItemList.size == 0">
|
||||||
ORDER BY sort ASC,job_id DESC
|
ORDER BY sort ASC,job_id DESC
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByJobClass" resultType="net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity">
|
||||||
|
SELECT *
|
||||||
|
FROM t_smart_job
|
||||||
|
WHERE job_class = #{jobClass}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -53,6 +53,15 @@ public class AdminSmartJobController extends SupportBaseController {
|
|||||||
return jobService.queryJob(queryForm);
|
return jobService.queryJob(queryForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "定时任务-添加任务 @huke")
|
||||||
|
@PostMapping("/job/add")
|
||||||
|
@RepeatSubmit
|
||||||
|
public ResponseDTO<String> addJob(@RequestBody @Valid SmartJobAddForm addForm) {
|
||||||
|
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||||
|
addForm.setUpdateName(requestUser.getUserName());
|
||||||
|
return jobService.addJob(addForm);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "定时任务-更新-任务信息 @huke")
|
@Operation(summary = "定时任务-更新-任务信息 @huke")
|
||||||
@PostMapping("/job/update")
|
@PostMapping("/job/update")
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@ -71,6 +80,13 @@ public class AdminSmartJobController extends SupportBaseController {
|
|||||||
return jobService.updateJobEnabled(updateForm);
|
return jobService.updateJobEnabled(updateForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "定时任务-删除 @zhuoda")
|
||||||
|
@GetMapping("/job/delete")
|
||||||
|
@RepeatSubmit
|
||||||
|
public ResponseDTO<String> deleteJob(@RequestParam Integer jobId) {
|
||||||
|
return jobService.deleteJob(jobId, SmartRequestUtil.getRequestUser());
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "定时任务-执行记录-分页查询 @huke")
|
@Operation(summary = "定时任务-执行记录-分页查询 @huke")
|
||||||
@PostMapping("/job/log/query")
|
@PostMapping("/job/log/query")
|
||||||
public ResponseDTO<PageResult<SmartJobLogVO>> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) {
|
public ResponseDTO<PageResult<SmartJobLogVO>> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) {
|
||||||
|
@ -9,10 +9,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
|
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
|
||||||
import net.lab1024.sa.base.common.domain.RequestUrlVO;
|
import net.lab1024.sa.base.common.domain.RequestUrlVO;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition;
|
||||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
|
|
||||||
@ -21,7 +21,6 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* url配置
|
* url配置
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package net.lab1024.sa.base.module.support.dict.service;
|
package net.lab1024.sa.base.module.support.dict.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.common.collect.Interner;
|
|
||||||
import com.google.common.collect.Interners;
|
|
||||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||||
import net.lab1024.sa.base.common.domain.PageResult;
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
@ -28,7 +26,7 @@ import java.util.List;
|
|||||||
* @Date 2022/5/26 19:40:55
|
* @Date 2022/5/26 19:40:55
|
||||||
* @Wechat zhuoda1024
|
* @Wechat zhuoda1024
|
||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DictService {
|
public class DictService {
|
||||||
@ -39,10 +37,6 @@ public class DictService {
|
|||||||
private DictValueDao dictValueDao;
|
private DictValueDao dictValueDao;
|
||||||
@Resource
|
@Resource
|
||||||
private DictCacheService dictCacheService;
|
private DictCacheService dictCacheService;
|
||||||
/**
|
|
||||||
* CODE锁
|
|
||||||
*/
|
|
||||||
private static final Interner<String> CODE_POOL = Interners.newWeakInterner();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,15 +45,15 @@ public class DictService {
|
|||||||
* @param keyAddForm
|
* @param keyAddForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
|
public synchronized ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
|
||||||
synchronized (CODE_POOL.intern(keyAddForm.getKeyCode())) {
|
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
|
if (dictKeyEntity != null) {
|
||||||
if (dictKeyEntity != null) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
|
|
||||||
dictKeyDao.insert(dictKeyEntity);
|
|
||||||
}
|
}
|
||||||
|
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
|
||||||
|
dictKeyDao.insert(dictKeyEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,15 +63,15 @@ public class DictService {
|
|||||||
* @param valueAddForm
|
* @param valueAddForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
|
public synchronized ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
|
||||||
synchronized (CODE_POOL.intern(valueAddForm.getValueCode())) {
|
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false);
|
||||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false);
|
if (dictValueEntity != null) {
|
||||||
if (dictValueEntity != null) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
|
|
||||||
dictValueDao.insert(dictValueEntity);
|
|
||||||
}
|
}
|
||||||
|
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
|
||||||
|
dictValueDao.insert(dictValueEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,15 +81,15 @@ public class DictService {
|
|||||||
* @param keyUpdateForm
|
* @param keyUpdateForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
|
public synchronized ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
|
||||||
synchronized (CODE_POOL.intern(keyUpdateForm.getKeyCode())) {
|
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
|
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
|
||||||
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
|
|
||||||
dictKeyDao.updateById(dictKeyUpdateEntity);
|
|
||||||
}
|
}
|
||||||
|
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
|
||||||
|
dictKeyDao.updateById(dictKeyUpdateEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,19 +99,19 @@ public class DictService {
|
|||||||
* @param valueUpdateForm
|
* @param valueUpdateForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
|
public synchronized ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId());
|
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId());
|
||||||
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) {
|
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) {
|
||||||
return ResponseDTO.userErrorParam("key不能存在");
|
return ResponseDTO.userErrorParam("key不能存在");
|
||||||
}
|
}
|
||||||
synchronized (CODE_POOL.intern(valueUpdateForm.getValueCode())) {
|
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false);
|
||||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false);
|
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
|
||||||
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
|
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
|
|
||||||
dictValueDao.updateById(dictValueUpdateEntity);
|
|
||||||
}
|
}
|
||||||
|
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
|
||||||
|
dictValueDao.updateById(dictValueUpdateEntity);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,11 +121,13 @@ public class DictService {
|
|||||||
* @param keyIdList
|
* @param keyIdList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
public synchronized ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
||||||
if (CollectionUtils.isEmpty(keyIdList)) {
|
if (CollectionUtils.isEmpty(keyIdList)) {
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,11 +137,13 @@ public class DictService {
|
|||||||
* @param valueIdList
|
* @param valueIdList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
public synchronized ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
||||||
if (CollectionUtils.isEmpty(valueIdList)) {
|
if (CollectionUtils.isEmpty(valueIdList)) {
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
||||||
|
//刷新缓存
|
||||||
|
dictCacheService.cacheRefresh();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||||
import net.lab1024.sa.base.common.domain.PageResult;
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
|
import net.lab1024.sa.base.common.domain.RequestUser;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||||
@ -16,7 +17,6 @@ import net.lab1024.sa.base.module.support.job.repository.SmartJobLogDao;
|
|||||||
import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity;
|
import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity;
|
||||||
import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobLogEntity;
|
import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobLogEntity;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -126,27 +126,61 @@ public class SmartJobService {
|
|||||||
return ResponseDTO.ok(pageResult);
|
return ResponseDTO.ok(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加定时任务
|
||||||
|
*
|
||||||
|
* @param addForm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public synchronized ResponseDTO<String> addJob(SmartJobAddForm addForm) {
|
||||||
|
// 校验参数
|
||||||
|
ResponseDTO<String> checkRes = this.checkParam(addForm);
|
||||||
|
if (!checkRes.getOk()) {
|
||||||
|
return checkRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验重复的执行类
|
||||||
|
SmartJobEntity existJobClass = jobDao.selectByJobClass(addForm.getJobClass());
|
||||||
|
if (null != existJobClass && !existJobClass.getDeletedFlag()) {
|
||||||
|
return ResponseDTO.userErrorParam("已经存在相同的执行类");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加数据
|
||||||
|
SmartJobEntity jobEntity = SmartBeanUtil.copy(addForm, SmartJobEntity.class);
|
||||||
|
jobDao.insert(jobEntity);
|
||||||
|
|
||||||
|
// 更新执行端
|
||||||
|
SmartJobMsg jobMsg = new SmartJobMsg();
|
||||||
|
jobMsg.setJobId(jobEntity.getJobId());
|
||||||
|
jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB);
|
||||||
|
jobMsg.setUpdateName(addForm.getUpdateName());
|
||||||
|
jobClientManager.publishToClient(jobMsg);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新定时任务
|
* 更新定时任务
|
||||||
*
|
*
|
||||||
* @param updateForm
|
* @param updateForm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> updateJob(SmartJobUpdateForm updateForm) {
|
public synchronized ResponseDTO<String> updateJob(SmartJobUpdateForm updateForm) {
|
||||||
// 校验参数
|
// 校验参数
|
||||||
Integer jobId = updateForm.getJobId();
|
Integer jobId = updateForm.getJobId();
|
||||||
SmartJobEntity jobEntity = jobDao.selectById(jobId);
|
SmartJobEntity jobEntity = jobDao.selectById(jobId);
|
||||||
if (null == jobEntity) {
|
if (null == jobEntity) {
|
||||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
}
|
}
|
||||||
// 校验触发时间配置
|
|
||||||
String triggerType = updateForm.getTriggerType();
|
ResponseDTO<String> checkRes = this.checkParam(updateForm);
|
||||||
String triggerValue = updateForm.getTriggerValue();
|
if (!checkRes.getOk()) {
|
||||||
if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) {
|
return checkRes;
|
||||||
return ResponseDTO.userErrorParam("cron表达式错误");
|
|
||||||
}
|
}
|
||||||
if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) {
|
|
||||||
return ResponseDTO.userErrorParam("固定间隔错误:整数且大于0");
|
// 校验重复的执行类
|
||||||
|
SmartJobEntity existJobClass = jobDao.selectByJobClass(updateForm.getJobClass());
|
||||||
|
if (null != existJobClass && !existJobClass.getDeletedFlag() && !existJobClass.getJobId().equals(jobId)) {
|
||||||
|
return ResponseDTO.userErrorParam("已经存在相同的执行类");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新数据
|
// 更新数据
|
||||||
@ -162,6 +196,27 @@ public class SmartJobService {
|
|||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验参数
|
||||||
|
* 如需其他校验,请自行添加校验逻辑
|
||||||
|
*
|
||||||
|
* @param addForm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ResponseDTO<String> checkParam(SmartJobAddForm addForm) {
|
||||||
|
// 校验触发时间配置
|
||||||
|
String triggerType = addForm.getTriggerType();
|
||||||
|
String triggerValue = addForm.getTriggerValue();
|
||||||
|
if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) {
|
||||||
|
return ResponseDTO.userErrorParam("cron表达式错误");
|
||||||
|
}
|
||||||
|
if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) {
|
||||||
|
return ResponseDTO.userErrorParam("固定间隔配置错误:必须是大于0的整数");
|
||||||
|
}
|
||||||
|
// 校验job class
|
||||||
|
return SmartJobUtil.checkJobClass(addForm.getJobClass());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新定时任务-是否开启
|
* 更新定时任务-是否开启
|
||||||
*
|
*
|
||||||
@ -219,28 +274,23 @@ public class SmartJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增定时任务
|
* 移除定时任务
|
||||||
* ps:目前没有业务场景需要通过接口 添加任务
|
* 物理删除
|
||||||
* 因为新增定时任务无论如何都需要 手动编码
|
|
||||||
* 需要时手动给数据库增加一条就行
|
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* @author huke
|
* @author huke
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<String> addJob() {
|
public synchronized ResponseDTO<String> deleteJob(Integer jobId, RequestUser requestUser) {
|
||||||
return ResponseDTO.userErrorParam("暂未支持");
|
// 删除任务
|
||||||
|
jobDao.updateDeletedFlag(jobId, Boolean.TRUE);
|
||||||
|
|
||||||
|
// 更新执行端
|
||||||
|
SmartJobMsg jobMsg = new SmartJobMsg();
|
||||||
|
jobMsg.setJobId(jobId);
|
||||||
|
jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB);
|
||||||
|
jobMsg.setUpdateName(requestUser.getUserName());
|
||||||
|
jobClientManager.publishToClient(jobMsg);
|
||||||
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除定时任务
|
|
||||||
* ps:目前没有业务场景需要通过接口移除,理由同 {@link SmartJobService#addJob},
|
|
||||||
* 彻底移除始终都需要手动删除代码
|
|
||||||
* 如果只是想暂停任务执行,可以调用 {@link SmartJobService#updateJobEnabled}
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @author huke
|
|
||||||
*/
|
|
||||||
public ResponseDTO<String> delJob() {
|
|
||||||
return ResponseDTO.userErrorParam("暂未支持");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package net.lab1024.sa.base.module.support.job.api.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||||
|
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||||
|
import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务 添加
|
||||||
|
*
|
||||||
|
* @author huke
|
||||||
|
* @date 2024/12/19 19:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmartJobAddForm {
|
||||||
|
|
||||||
|
@Schema(description = "任务名称")
|
||||||
|
@NotBlank(message = "任务名称不能为空")
|
||||||
|
@Length(max = 100, message = "任务名称最多100字符")
|
||||||
|
private String jobName;
|
||||||
|
|
||||||
|
@Schema(description = "任务执行类")
|
||||||
|
@NotBlank(message = "任务执行类不能为空")
|
||||||
|
@Length(max = 200, message = "任务执行类最多200字符")
|
||||||
|
private String jobClass;
|
||||||
|
|
||||||
|
@SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class)
|
||||||
|
@CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误")
|
||||||
|
private String triggerType;
|
||||||
|
|
||||||
|
@Schema(description = "触发配置")
|
||||||
|
@NotBlank(message = "触发配置不能为空")
|
||||||
|
@Length(max = 100, message = "触发配置最多100字符")
|
||||||
|
private String triggerValue;
|
||||||
|
|
||||||
|
@Schema(description = "定时任务参数|可选")
|
||||||
|
@Length(max = 1000, message = "定时任务参数最多1000字符")
|
||||||
|
private String param;
|
||||||
|
|
||||||
|
@Schema(description = "是否开启")
|
||||||
|
@NotNull(message = "是否开启不能为空")
|
||||||
|
private Boolean enabledFlag;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
@Length(max = 250, message = "任务备注最多250字符")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@NotNull(message = "排序不能为空")
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String updateName;
|
||||||
|
}
|
@ -27,4 +27,7 @@ public class SmartJobQueryForm extends PageParam {
|
|||||||
|
|
||||||
@Schema(description = "是否启用|可选")
|
@Schema(description = "是否启用|可选")
|
||||||
private Boolean enabledFlag;
|
private Boolean enabledFlag;
|
||||||
|
|
||||||
|
@Schema(description = "是否删除|可选")
|
||||||
|
private Boolean deletedFlag;
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,7 @@ package net.lab1024.sa.base.module.support.job.api.domain;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
|
||||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
|
||||||
import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum;
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,47 +12,9 @@ import javax.validation.constraints.NotNull;
|
|||||||
* @date 2024/6/17 21:30
|
* @date 2024/6/17 21:30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class SmartJobUpdateForm {
|
public class SmartJobUpdateForm extends SmartJobAddForm {
|
||||||
|
|
||||||
@Schema(description = "任务id")
|
@Schema(description = "任务id")
|
||||||
@NotNull(message = "任务id不能为空")
|
@NotNull(message = "任务id不能为空")
|
||||||
private Integer jobId;
|
private Integer jobId;
|
||||||
|
|
||||||
@Schema(description = "任务名称")
|
|
||||||
@NotBlank(message = "任务名称不能为空")
|
|
||||||
@Length(max = 100, message = "任务名称最多100字符")
|
|
||||||
private String jobName;
|
|
||||||
|
|
||||||
@Schema(description = "任务执行类")
|
|
||||||
@NotBlank(message = "任务执行类不能为空")
|
|
||||||
@Length(max = 200, message = "任务执行类最多200字符")
|
|
||||||
private String jobClass;
|
|
||||||
|
|
||||||
@SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class)
|
|
||||||
@CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误")
|
|
||||||
private String triggerType;
|
|
||||||
|
|
||||||
@Schema(description = "触发配置")
|
|
||||||
@NotBlank(message = "触发配置不能为空")
|
|
||||||
@Length(max = 100, message = "触发配置最多100字符")
|
|
||||||
private String triggerValue;
|
|
||||||
|
|
||||||
@Schema(description = "定时任务参数|可选")
|
|
||||||
@Length(max = 1000, message = "定时任务参数最多1000字符")
|
|
||||||
private String param;
|
|
||||||
|
|
||||||
@Schema(description = "是否开启")
|
|
||||||
@NotNull(message = "是否开启不能为空")
|
|
||||||
private Boolean enabledFlag;
|
|
||||||
|
|
||||||
@Schema(description = "备注")
|
|
||||||
@Length(max = 250, message = "任务备注最多250字符")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
@NotNull(message = "排序不能为空")
|
|
||||||
@Schema(description = "排序")
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
@Schema(hidden = true)
|
|
||||||
private String updateName;
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.lab1024.sa.base.module.support.job.constant;
|
package net.lab1024.sa.base.module.support.job.constant;
|
||||||
|
|
||||||
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.sa.base.module.support.job.core.SmartJob;
|
||||||
import org.springframework.scheduling.support.CronExpression;
|
import org.springframework.scheduling.support.CronExpression;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
@ -98,7 +100,7 @@ public class SmartJobUtil {
|
|||||||
} else if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType)) {
|
} else if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType)) {
|
||||||
Integer fixedDelay = getFixedDelayVal(triggerVal);
|
Integer fixedDelay = getFixedDelayVal(triggerVal);
|
||||||
LocalDateTime startTime = null == lastExecuteTime || lastExecuteTime.plusSeconds(fixedDelay).isBefore(nowTime)
|
LocalDateTime startTime = null == lastExecuteTime || lastExecuteTime.plusSeconds(fixedDelay).isBefore(nowTime)
|
||||||
? nowTime : lastExecuteTime;
|
? nowTime : lastExecuteTime;
|
||||||
nextTimeList = SmartJobUtil.queryNextTime(fixedDelay, startTime, num);
|
nextTimeList = SmartJobUtil.queryNextTime(fixedDelay, startTime, num);
|
||||||
}
|
}
|
||||||
return nextTimeList;
|
return nextTimeList;
|
||||||
@ -174,6 +176,24 @@ public class SmartJobUtil {
|
|||||||
return runtime.getName().split("@")[0];
|
return runtime.getName().split("@")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据className 判断job class
|
||||||
|
*/
|
||||||
|
public static ResponseDTO<String> checkJobClass(String className) {
|
||||||
|
try {
|
||||||
|
Class<?> aClass = Class.forName(className);
|
||||||
|
// 判断是否实现了 SmartJob
|
||||||
|
if (!SmartJob.class.isAssignableFrom(aClass)) {
|
||||||
|
return ResponseDTO.userErrorParam(className + " 执行类没有实现 SmartJob 接口");
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return ResponseDTO.userErrorParam("没有在代码中发现执行类:" + className);
|
||||||
|
}
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LocalDateTime startTime = LocalDateTime.now();
|
LocalDateTime startTime = LocalDateTime.now();
|
||||||
List<LocalDateTime> timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3);
|
List<LocalDateTime> timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3);
|
||||||
@ -184,5 +204,7 @@ public class SmartJobUtil {
|
|||||||
|
|
||||||
System.out.println("project path ->" + getProgramPath());
|
System.out.println("project path ->" + getProgramPath());
|
||||||
System.out.println("project process id ->" + getProcessId());
|
System.out.println("project process id ->" + getProcessId());
|
||||||
|
ResponseDTO<String> res = checkJobClass("net.lab1024.sa.base.module.support.job.sample.SmartJobSample1");
|
||||||
|
System.out.println(res.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,10 @@ public class SmartJobLauncher {
|
|||||||
if (!jobEntity.getEnabledFlag()) {
|
if (!jobEntity.getEnabledFlag()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// 任务删除
|
||||||
|
if (jobEntity.getDeletedFlag()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 查找任务实现类
|
// 查找任务实现类
|
||||||
SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass());
|
SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass());
|
||||||
if (null == jobImpl) {
|
if (null == jobImpl) {
|
||||||
@ -135,6 +139,7 @@ public class SmartJobLauncher {
|
|||||||
private static boolean isNeedUpdate(SmartJobEntity oldJob, SmartJobEntity newJob) {
|
private static boolean isNeedUpdate(SmartJobEntity oldJob, SmartJobEntity newJob) {
|
||||||
// cron为空时 fixedDelay 才有意义
|
// cron为空时 fixedDelay 才有意义
|
||||||
return !Objects.equals(oldJob.getEnabledFlag(), newJob.getEnabledFlag())
|
return !Objects.equals(oldJob.getEnabledFlag(), newJob.getEnabledFlag())
|
||||||
|
|| !Objects.equals(oldJob.getDeletedFlag(), newJob.getDeletedFlag())
|
||||||
|| !Objects.equals(oldJob.getTriggerType(), newJob.getTriggerType())
|
|| !Objects.equals(oldJob.getTriggerType(), newJob.getTriggerType())
|
||||||
|| !Objects.equals(oldJob.getTriggerValue(), newJob.getTriggerValue())
|
|| !Objects.equals(oldJob.getTriggerValue(), newJob.getTriggerValue())
|
||||||
|| !Objects.equals(oldJob.getJobClass(), newJob.getJobClass());
|
|| !Objects.equals(oldJob.getJobClass(), newJob.getJobClass());
|
||||||
|
@ -29,4 +29,20 @@ public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SmartJobVO> query(Page<?> page, @Param("query") SmartJobQueryForm queryForm);
|
List<SmartJobVO> query(Page<?> page, @Param("query") SmartJobQueryForm queryForm);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 假删除
|
||||||
|
*
|
||||||
|
* @param jobId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void updateDeletedFlag(@Param("jobId") Integer jobId, @Param("deletedFlag") Boolean deletedFlag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 任务class 查找
|
||||||
|
*
|
||||||
|
* @param jobClass
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SmartJobEntity selectByJobClass(@Param("jobClass") String jobClass);
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,11 @@ public class SmartJobEntity {
|
|||||||
*/
|
*/
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
private Boolean deletedFlag;
|
||||||
|
|
||||||
private String updateName;
|
private String updateName;
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="net.lab1024.sa.base.module.support.job.repository.SmartJobDao">
|
<mapper namespace="net.lab1024.sa.base.module.support.job.repository.SmartJobDao">
|
||||||
|
|
||||||
|
<update id="updateDeletedFlag">
|
||||||
|
update t_smart_job
|
||||||
|
set deleted_flag = #{deletedFlag}
|
||||||
|
where job_id = #{jobId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<!-- 定时任务-分页查询 -->
|
<!-- 定时任务-分页查询 -->
|
||||||
<select id="query" resultType="net.lab1024.sa.base.module.support.job.api.domain.SmartJobVO">
|
<select id="query" resultType="net.lab1024.sa.base.module.support.job.api.domain.SmartJobVO">
|
||||||
SELECT *
|
SELECT *
|
||||||
@ -19,10 +25,19 @@
|
|||||||
<if test="query.enabledFlag != null">
|
<if test="query.enabledFlag != null">
|
||||||
AND enabled_flag = #{query.enabledFlag}
|
AND enabled_flag = #{query.enabledFlag}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="query.deletedFlag != null">
|
||||||
|
AND deleted_flag = #{query.deletedFlag}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
<if test="query.sortItemList == null or query.sortItemList.size == 0">
|
<if test="query.sortItemList == null or query.sortItemList.size == 0">
|
||||||
ORDER BY sort ASC,job_id DESC
|
ORDER BY sort ASC,job_id DESC
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByJobClass" resultType="net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity">
|
||||||
|
SELECT *
|
||||||
|
FROM t_smart_job
|
||||||
|
WHERE job_class = #{jobClass}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -19,6 +19,10 @@ export const jobApi = {
|
|||||||
executeJob: (param) => {
|
executeJob: (param) => {
|
||||||
return postRequest('/support/job/execute', param);
|
return postRequest('/support/job/execute', param);
|
||||||
},
|
},
|
||||||
|
// 定时任务-新增-任务信息 @huke
|
||||||
|
addJob: (param) => {
|
||||||
|
return postRequest('/support/job/add', param);
|
||||||
|
},
|
||||||
// 定时任务-更新-任务信息 @huke
|
// 定时任务-更新-任务信息 @huke
|
||||||
updateJob: (param) => {
|
updateJob: (param) => {
|
||||||
return postRequest('/support/job/update', param);
|
return postRequest('/support/job/update', param);
|
||||||
@ -31,4 +35,8 @@ export const jobApi = {
|
|||||||
queryJobLog: (param) => {
|
queryJobLog: (param) => {
|
||||||
return postRequest('/support/job/log/query', param);
|
return postRequest('/support/job/log/query', param);
|
||||||
},
|
},
|
||||||
|
// 定时任务-删除 @zhuoda
|
||||||
|
deleteJob: (param) => {
|
||||||
|
return getRequest(`/support/job/delete?jobId=${param}`);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -31,8 +31,8 @@ export const PAGE_TAG_ENUM = {
|
|||||||
value: 'antd',
|
value: 'antd',
|
||||||
desc: 'Ant Design',
|
desc: 'Ant Design',
|
||||||
},
|
},
|
||||||
NAIVE: {
|
CHROME: {
|
||||||
value: 'naive',
|
value: 'chrome',
|
||||||
desc: 'NAIVE',
|
desc: 'Chrome',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -73,8 +73,8 @@
|
|||||||
<a-form-item :label="$t('setting.pagetag.style')">
|
<a-form-item :label="$t('setting.pagetag.style')">
|
||||||
<a-radio-group v-model:value="formState.pageTagStyle" button-style="solid" @change="changePageTagStyle">
|
<a-radio-group v-model:value="formState.pageTagStyle" button-style="solid" @change="changePageTagStyle">
|
||||||
<a-radio-button value="default">默认</a-radio-button>
|
<a-radio-button value="default">默认</a-radio-button>
|
||||||
<a-radio-button value="antd">ANTD</a-radio-button>
|
<a-radio-button value="antd">Ant</a-radio-button>
|
||||||
<a-radio-button value="naive">NAIVE</a-radio-button>
|
<a-radio-button value="chrome">Chrome</a-radio-button>
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="$t('setting.pagetag')">
|
<a-form-item :label="$t('setting.pagetag')">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
* 使用naiveUI <a-tabs> 组件
|
* chrome样式 <a-tabs> 组件
|
||||||
*
|
*
|
||||||
* @Author: 1024创新实验室-主任:卓大
|
* @Author: 1024创新实验室-主任:卓大
|
||||||
* @Date: 2024-11-27 20:29:12
|
* @Date: 2024-11-27 20:29:12
|
||||||
@ -212,7 +212,7 @@ const borderRadius = 8 + 'px';
|
|||||||
}
|
}
|
||||||
&:nth-last-child(2) {
|
&:nth-last-child(2) {
|
||||||
margin-right: 0 !important;
|
margin-right: 0 !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.smart-page-tag-content {
|
.smart-page-tag-content {
|
||||||
@ -227,7 +227,7 @@ const borderRadius = 8 + 'px';
|
|||||||
right: 9px;
|
right: 9px;
|
||||||
z-index: -2;
|
z-index: -2;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
background: #666;
|
background: #eeeeee;
|
||||||
}
|
}
|
||||||
.smart-page-tag-icon{
|
.smart-page-tag-icon{
|
||||||
margin-right:5px;
|
margin-right:5px;
|
@ -11,7 +11,7 @@
|
|||||||
<div id="smartAdminPageTag">
|
<div id="smartAdminPageTag">
|
||||||
<DefaultTab v-if="pageTagStyle === PAGE_TAG_ENUM.DEFAULT.value" />
|
<DefaultTab v-if="pageTagStyle === PAGE_TAG_ENUM.DEFAULT.value" />
|
||||||
<AntdTab v-if="pageTagStyle === PAGE_TAG_ENUM.ANTD.value" />
|
<AntdTab v-if="pageTagStyle === PAGE_TAG_ENUM.ANTD.value" />
|
||||||
<NaiveTab v-if="pageTagStyle === PAGE_TAG_ENUM.NAIVE.value" />
|
<ChromeTab v-if="pageTagStyle === PAGE_TAG_ENUM.CHROME.value" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -20,7 +20,7 @@
|
|||||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||||
import DefaultTab from './components/default-tab.vue';
|
import DefaultTab from './components/default-tab.vue';
|
||||||
import AntdTab from './components/antd-tab.vue';
|
import AntdTab from './components/antd-tab.vue';
|
||||||
import NaiveTab from './components/naive-tab.vue';
|
import ChromeTab from './components/chrome-tab.vue';
|
||||||
import { PAGE_TAG_ENUM } from '/@/constants/layout-const.js';
|
import { PAGE_TAG_ENUM } from '/@/constants/layout-const.js';
|
||||||
|
|
||||||
const pageTagStyle = computed(() => useAppConfigStore().$state.pageTagStyle);
|
const pageTagStyle = computed(() => useAppConfigStore().$state.pageTagStyle);
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
import watermark from '../lib/smart-watermark';
|
import watermark from '../lib/smart-watermark';
|
||||||
import { useUserStore } from '/@/store/modules/system/user';
|
import { useUserStore } from '/@/store/modules/system/user';
|
||||||
import HeaderAvatar from './components/header-user-space/header-avatar.vue';
|
import HeaderAvatar from './components/header-user-space/header-avatar.vue';
|
||||||
|
import { LAYOUT_ELEMENT_IDS } from '/@/layout/layout-const';
|
||||||
|
|
||||||
const websiteName = computed(() => useAppConfigStore().websiteName);
|
const websiteName = computed(() => useAppConfigStore().websiteName);
|
||||||
const windowHeight = window.innerHeight;
|
const windowHeight = window.innerHeight;
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
<a-tag v-show="!text" color="success">未删除</a-tag>
|
<a-tag v-show="!text" color="success">未删除</a-tag>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="column.dataIndex === 'action'">
|
<template v-else-if="column.dataIndex === 'action'">
|
||||||
<div class="smart-table-operate">
|
<div class="smart-table-operate" v-if="!record.deletedFlag">
|
||||||
<a-button type="link" @click="addOrUpdate(record.noticeId)" v-privilege="'oa:notice:update'">编辑</a-button>
|
<a-button type="link" @click="addOrUpdate(record.noticeId)" v-privilege="'oa:notice:update'">编辑</a-button>
|
||||||
<a-button type="link" @click="onDelete(record.noticeId)" v-privilege="'oa:notice:delete'" danger>删除</a-button>
|
<a-button type="link" @click="onDelete(record.noticeId)" v-privilege="'oa:notice:delete'" danger>删除</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<!--
|
<!--
|
||||||
* 代码生成 配置信息
|
* 代码生成 配置信息
|
||||||
*
|
*
|
||||||
* @Author: 1024创新实验室-主任:卓大
|
* @Author: 1024创新实验室-主任:卓大
|
||||||
* @Date: 2022-09-22 21:50:41
|
* @Date: 2022-09-22 21:50:41
|
||||||
* @Wechat: zhuda1024
|
* @Wechat: zhuda1024
|
||||||
* @Email: lab1024@163.com
|
* @Email: lab1024@163.com
|
||||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<a-alert
|
<a-alert
|
||||||
@ -76,7 +76,7 @@
|
|||||||
<pre class="preview-block">
|
<pre class="preview-block">
|
||||||
<!--
|
<!--
|
||||||
* {{ formData.description }}
|
* {{ formData.description }}
|
||||||
*
|
*
|
||||||
* @Author: {{ formData.frontAuthor }}
|
* @Author: {{ formData.frontAuthor }}
|
||||||
* @Date: {{ formData.frontDate }}
|
* @Date: {{ formData.frontDate }}
|
||||||
* @Copyright {{ formData.copyright }}
|
* @Copyright {{ formData.copyright }}
|
||||||
@ -182,7 +182,7 @@
|
|||||||
//命名
|
//命名
|
||||||
let removePrefixTableName = tableInfo.tableName;
|
let removePrefixTableName = tableInfo.tableName;
|
||||||
if (_.startsWith(tableInfo.tableName, tablePrefix.value)) {
|
if (_.startsWith(tableInfo.tableName, tablePrefix.value)) {
|
||||||
removePrefixTableName = _.trim(removePrefixTableName, tablePrefix.value);
|
removePrefixTableName = _.trimStart(removePrefixTableName, tablePrefix.value);
|
||||||
}
|
}
|
||||||
formData.moduleName = basic && basic.moduleName ? basic.moduleName : removePrefixTableName;
|
formData.moduleName = basic && basic.moduleName ? basic.moduleName : removePrefixTableName;
|
||||||
formData.moduleName = convertUpperCamel(formData.moduleName);
|
formData.moduleName = convertUpperCamel(formData.moduleName);
|
||||||
|
@ -0,0 +1,283 @@
|
|||||||
|
<!--
|
||||||
|
* 已删除的 JOB 列表
|
||||||
|
* @Author: zhuoda
|
||||||
|
* @Date: 2025/01/05
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<a-form class="smart-query-form">
|
||||||
|
<a-row class="smart-query-form-row">
|
||||||
|
<a-form-item label="关键字" class="smart-query-form-item">
|
||||||
|
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="触发类型" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 155px" v-model:value="queryForm.triggerType" placeholder="请选择触发类型" allowClear>
|
||||||
|
<a-select-option v-for="item in $smartEnumPlugin.getValueDescList('TRIGGER_TYPE_ENUM')" :key="item.value" :value="item.value">
|
||||||
|
{{ item.desc }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="状态" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 150px" v-model:value="queryForm.enabledFlag" placeholder="请选择状态" allowClear>
|
||||||
|
<a-select-option :key="1"> 开启 </a-select-option>
|
||||||
|
<a-select-option :key="0"> 停止 </a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item class="smart-query-form-item smart-margin-left10">
|
||||||
|
<a-button-group>
|
||||||
|
<a-button type="primary" @click="onSearch" v-privilege="'support:job:query'">
|
||||||
|
<template #icon>
|
||||||
|
<ReloadOutlined />
|
||||||
|
</template>
|
||||||
|
查询
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="resetQuery" v-privilege="'support:job:query'">
|
||||||
|
<template #icon>
|
||||||
|
<SearchOutlined />
|
||||||
|
</template>
|
||||||
|
重置
|
||||||
|
</a-button>
|
||||||
|
</a-button-group>
|
||||||
|
</a-form-item>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
|
||||||
|
<a-flex align="end" vertical>
|
||||||
|
<div class="smart-table-setting-block smart-margin-bottom10">
|
||||||
|
<TableOperator
|
||||||
|
class="smart-margin-bottom5 pull-right"
|
||||||
|
v-model="columns"
|
||||||
|
:tableId="TABLE_ID_CONST.SUPPORT.JOB"
|
||||||
|
:refresh="queryJobList"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-flex>
|
||||||
|
|
||||||
|
<a-table
|
||||||
|
:scroll="{ x: 1800 }"
|
||||||
|
size="small"
|
||||||
|
:loading="tableLoading"
|
||||||
|
bordered
|
||||||
|
:dataSource="tableData"
|
||||||
|
:columns="columns"
|
||||||
|
rowKey="jobId"
|
||||||
|
:pagination="false"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ record, column }">
|
||||||
|
<template v-if="column.dataIndex === 'jobClass'">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>{{ record.jobClass }}</template>
|
||||||
|
{{ handleJobClass(record.jobClass) }}
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'triggerType'">
|
||||||
|
<a-tag v-if="record.triggerType === TRIGGER_TYPE_ENUM.CRON.value" color="success">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
|
<a-tag v-else-if="record.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value" color="processing">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
|
<a-tag v-else color="pink">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'lastJob'">
|
||||||
|
<div v-if="record.lastJobLog">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>{{ handleExecuteResult(record.lastJobLog.executeResult) }}</template>
|
||||||
|
<CheckOutlined v-if="record.lastJobLog.successFlag" style="color: #39c710" />
|
||||||
|
<WarningOutlined v-else style="color: #f50" />
|
||||||
|
{{ record.lastJobLog.executeStartTime }}
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'nextJob'">
|
||||||
|
<a-tooltip v-if="record.enabledFlag && record.nextJobExecuteTimeList">
|
||||||
|
<template #title>
|
||||||
|
<div>下次执行(预估时间)</div>
|
||||||
|
<div v-for="item in record.nextJobExecuteTimeList" :key="item">{{ item }}</div>
|
||||||
|
</template>
|
||||||
|
{{ record.nextJobExecuteTimeList[0] }}
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'enabledFlag'">
|
||||||
|
<a-switch checked-children="已启用" un-checked-children="已禁用" v-model:checked="record.enabledFlag" disabled :loading="record.enabledLoading" />
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'action'">
|
||||||
|
<div class="smart-table-operate">
|
||||||
|
<a-button v-privilege="'support:job:log:query'" @click="openJobLogModal(record.jobId, record.jobName)" type="link">记录</a-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
|
||||||
|
<div class="smart-query-table-page">
|
||||||
|
<a-pagination
|
||||||
|
showSizeChanger
|
||||||
|
showQuickJumper
|
||||||
|
show-less-items
|
||||||
|
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||||
|
:defaultPageSize="queryForm.pageSize"
|
||||||
|
v-model:current="queryForm.pageNum"
|
||||||
|
v-model:pageSize="queryForm.pageSize"
|
||||||
|
:total="total"
|
||||||
|
@change="queryJobList"
|
||||||
|
@showSizeChange="queryJobList"
|
||||||
|
:show-total="(total) => `共${total}条`"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 记录 -->
|
||||||
|
<JobLogListModal ref="jobLogModal" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
import { jobApi } from '/@/api/support/job-api';
|
||||||
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||||
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
|
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
||||||
|
import JobLogListModal from './job-log-list-modal.vue';
|
||||||
|
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const.js";
|
||||||
|
import TableOperator from "/@/components/support/table-operator/index.vue";
|
||||||
|
|
||||||
|
const columns = ref([
|
||||||
|
{
|
||||||
|
title: 'id',
|
||||||
|
width: 50,
|
||||||
|
dataIndex: 'jobId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '任务名称',
|
||||||
|
dataIndex: 'jobName',
|
||||||
|
minWidth: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '执行类',
|
||||||
|
dataIndex: 'jobClass',
|
||||||
|
minWidth: 180,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '触发类型',
|
||||||
|
dataIndex: 'triggerType',
|
||||||
|
width: 110,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '触发配置',
|
||||||
|
dataIndex: 'triggerValue',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '上次执行',
|
||||||
|
width: 180,
|
||||||
|
dataIndex: 'lastJob',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '下次执行',
|
||||||
|
width: 150,
|
||||||
|
dataIndex: 'nextJob',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '启用状态',
|
||||||
|
dataIndex: 'enabledFlag',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '执行参数',
|
||||||
|
dataIndex: 'param',
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '任务描述',
|
||||||
|
dataIndex: 'remark',
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序',
|
||||||
|
dataIndex: 'sort',
|
||||||
|
width: 65,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新人',
|
||||||
|
dataIndex: 'updateName',
|
||||||
|
width: 90,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
dataIndex: 'updateTime',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
dataIndex: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 70,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ---------------- 查询数据 -----------------------
|
||||||
|
|
||||||
|
const queryFormState = {
|
||||||
|
searchWord: '',
|
||||||
|
enabledFlag: null,
|
||||||
|
triggerType: null,
|
||||||
|
deletedFlag: true,
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
};
|
||||||
|
const queryForm = reactive({ ...queryFormState });
|
||||||
|
|
||||||
|
const tableLoading = ref(false);
|
||||||
|
const tableData = ref([]);
|
||||||
|
const total = ref(0);
|
||||||
|
|
||||||
|
function resetQuery() {
|
||||||
|
Object.assign(queryForm, queryFormState);
|
||||||
|
queryJobList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSearch() {
|
||||||
|
queryForm.pageNum = 1;
|
||||||
|
queryJobList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理执行类展示 默认返回类
|
||||||
|
function handleJobClass(jobClass) {
|
||||||
|
return jobClass.split('.').pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上次处理结果展示
|
||||||
|
function handleExecuteResult(result) {
|
||||||
|
let num = 400;
|
||||||
|
return result ? result.substring(0, num) + (result.length > num ? ' ...' : '') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function queryJobList() {
|
||||||
|
try {
|
||||||
|
tableLoading.value = true;
|
||||||
|
let responseModel = await jobApi.queryJob(queryForm);
|
||||||
|
const list = responseModel.data.list;
|
||||||
|
total.value = responseModel.data.total;
|
||||||
|
tableData.value = list;
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
} finally {
|
||||||
|
tableLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(queryJobList);
|
||||||
|
|
||||||
|
// 查询任务详情
|
||||||
|
async function queryJobInfo(jobId) {
|
||||||
|
try {
|
||||||
|
let res = await jobApi.queryJobInfo(jobId);
|
||||||
|
return res.data;
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------ 执行记录 -------------------------------------
|
||||||
|
const jobLogModal = ref();
|
||||||
|
function openJobLogModal(jobId, name) {
|
||||||
|
jobLogModal.value.show(jobId, name);
|
||||||
|
}
|
||||||
|
</script>
|
@ -6,47 +6,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- 编辑 -->
|
<!-- 编辑 -->
|
||||||
<a-modal :open="updateModalShow" :width="650" title="编辑" ok-text="确认" cancel-text="取消" @cancel="closeUpdateModal" @ok="confirmUpdateJob">
|
<a-modal :open="updateModalShow" :width="650" :title="isAdd ? '添加':'编辑'" ok-text="确认" cancel-text="取消" @cancel="closeUpdateModal" @ok="confirmUpdateJob">
|
||||||
<a-form ref="updateFormRef" :model="updateForm" :rules="updateRules" :label-col="{ span: 4 }">
|
<a-form ref="updateFormRef" :model="updateForm" :rules="updateRules" :label-col="{ span: 4 }">
|
||||||
<a-form-item label="任务名称" name="jobName">
|
<a-form-item label="任务名称" name="jobName">
|
||||||
<a-input placeholder="请输入任务名称" v-model:value="updateForm.jobName" :maxlength="100" :showCount="true" />
|
<a-input placeholder="请输入任务名称" v-model:value="updateForm.jobName" :maxlength="100" :showCount="true" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="任务描述" name="remark">
|
<a-form-item label="任务描述" name="remark">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 2, maxRows: 4 }"
|
:auto-size="{ minRows: 2, maxRows: 4 }"
|
||||||
v-model:value="updateForm.remark"
|
v-model:value="updateForm.remark"
|
||||||
placeholder="(可选)请输入任务备注描述"
|
placeholder="(可选)请输入任务备注描述"
|
||||||
:maxlength="250"
|
:maxlength="250"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="排序" name="sort">
|
<a-form-item label="排序" name="sort">
|
||||||
<a-input-number
|
<a-input-number
|
||||||
v-model:value="updateForm.sort"
|
v-model:value="updateForm.sort"
|
||||||
:min="-99999999"
|
:min="-99999999"
|
||||||
:max="99999999"
|
:max="99999999"
|
||||||
:precision="0"
|
:precision="0"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
placeholder="值越小越靠前"
|
placeholder="值越小越靠前"
|
||||||
>
|
>
|
||||||
</a-input-number>
|
</a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="执行类" name="jobClass">
|
<a-form-item label="执行类" name="jobClass">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 2, maxRows: 4 }"
|
:auto-size="{ minRows: 2, maxRows: 4 }"
|
||||||
v-model:value="updateForm.jobClass"
|
v-model:value="updateForm.jobClass"
|
||||||
placeholder="示例:net.lab1024.sa.base.module.support.job.sample.SmartJobSample1"
|
placeholder="示例:net.lab1024.sa.base.module.support.job.sample.SmartJobSample1"
|
||||||
:maxlength="200"
|
:maxlength="200"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="任务参数" name="param">
|
<a-form-item label="任务参数" name="param">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 3, maxRows: 6 }"
|
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||||||
v-model:value="updateForm.param"
|
v-model:value="updateForm.param"
|
||||||
placeholder="(可选)请输入任务执行参数"
|
placeholder="(可选)请输入任务执行参数"
|
||||||
:maxlength="1000"
|
:maxlength="1000"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="触发类型" name="triggerType">
|
<a-form-item label="触发类型" name="triggerType">
|
||||||
@ -57,19 +57,18 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="触发时间" name="triggerTime">
|
<a-form-item label="触发时间" name="triggerTime">
|
||||||
<a-input
|
<a-input
|
||||||
v-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.CRON.value"
|
v-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.CRON.value"
|
||||||
placeholder="示例:10 15 0/1 * * *"
|
placeholder="示例:10 15 0/1 * * *"
|
||||||
v-model:value="updateForm.cron"
|
v-model:value="updateForm.cron"
|
||||||
:maxlength="100"
|
:maxlength="100"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
<a-input-number
|
<a-input-number
|
||||||
v-else-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value"
|
v-else-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value"
|
||||||
v-model:value="updateForm.fixedDelay"
|
v-model:value="updateForm.fixedDelay"
|
||||||
:min="1"
|
:min="1"
|
||||||
:max="100000000"
|
:max="100000000"
|
||||||
:precision="0"
|
:precision="0"
|
||||||
:defaultValue="100"
|
|
||||||
>
|
>
|
||||||
<template #addonBefore>每隔</template>
|
<template #addonBefore>每隔</template>
|
||||||
<template #addonAfter>秒</template>
|
<template #addonAfter>秒</template>
|
||||||
@ -83,13 +82,13 @@
|
|||||||
|
|
||||||
<!-- 立即执行 -->
|
<!-- 立即执行 -->
|
||||||
<a-modal
|
<a-modal
|
||||||
:open="executeModalShow"
|
:open="executeModalShow"
|
||||||
:width="650"
|
:width="650"
|
||||||
title="执行任务"
|
title="执行任务"
|
||||||
ok-text="执行"
|
ok-text="执行"
|
||||||
cancel-text="取消"
|
cancel-text="取消"
|
||||||
@cancel="closeExecuteModal"
|
@cancel="closeExecuteModal"
|
||||||
@ok="confirmExecuteJob"
|
@ok="confirmExecuteJob"
|
||||||
>
|
>
|
||||||
<br />
|
<br />
|
||||||
<a-alert type="info" show-icon style="margin-left: 25px">
|
<a-alert type="info" show-icon style="margin-left: 25px">
|
||||||
@ -105,11 +104,11 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="任务参数" name="param">
|
<a-form-item label="任务参数" name="param">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 3, maxRows: 6 }"
|
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||||||
v-model:value="executeForm.param"
|
v-model:value="executeForm.param"
|
||||||
placeholder="(可选)请输入任务执行参数"
|
placeholder="(可选)请输入任务执行参数"
|
||||||
:maxlength="1000"
|
:maxlength="1000"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
@ -117,42 +116,46 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { jobApi } from '/@/api/support/job-api';
|
import { jobApi } from '/@/api/support/job-api';
|
||||||
import { smartSentry } from '/@/lib/smart-sentry';
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
import { SmartLoading } from '/@/components/framework/smart-loading/index.js';
|
import { SmartLoading } from '/@/components/framework/smart-loading/index.js';
|
||||||
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
||||||
|
|
||||||
// emit
|
// emit
|
||||||
const emit = defineEmits(['reloadList']);
|
const emit = defineEmits(['reloadList']);
|
||||||
|
|
||||||
const updateModalShow = ref(false);
|
const isAdd = ref(false);
|
||||||
const updateFormRef = ref();
|
const updateModalShow = ref(false);
|
||||||
|
const updateFormRef = ref();
|
||||||
|
|
||||||
const updateFormDefault = {
|
const updateFormDefault = {
|
||||||
jobId: null,
|
jobId: null,
|
||||||
jobName: '',
|
jobName: '',
|
||||||
jobClass: '',
|
jobClass: '',
|
||||||
triggerType: null,
|
triggerType: TRIGGER_TYPE_ENUM.CRON.value,
|
||||||
triggerValue: null,
|
triggerValue: null,
|
||||||
cron: '',
|
cron: '',
|
||||||
fixedDelay: null,
|
fixedDelay: null,
|
||||||
param: '',
|
param: '',
|
||||||
enabledFlag: false,
|
enabledFlag: false,
|
||||||
remark: '',
|
remark: '',
|
||||||
sort: null,
|
sort: null,
|
||||||
};
|
};
|
||||||
let updateForm = reactive({ ...updateFormDefault });
|
let updateForm = reactive({ ...updateFormDefault });
|
||||||
const updateRules = {
|
const updateRules = {
|
||||||
jobName: [{ required: true, message: '请输入任务名称' }],
|
jobName: [{ required: true, message: '请输入任务名称' }],
|
||||||
jobClass: [{ required: true, message: '请输入执行类' }],
|
jobClass: [{ required: true, message: '请输入执行类' }],
|
||||||
triggerType: [{ required: true, message: '请选择触发类型' }],
|
triggerType: [{ required: true, message: '请选择触发类型' }],
|
||||||
sort: [{ required: true, message: '请输入排序' }],
|
sort: [{ required: true, message: '请输入排序' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开编辑弹框
|
// 打开编辑弹框
|
||||||
function openUpdateModal(record) {
|
function openUpdateModal(record) {
|
||||||
|
isAdd.value = null == record;
|
||||||
|
// 更新
|
||||||
|
if(!isAdd.value){
|
||||||
Object.assign(updateForm, record);
|
Object.assign(updateForm, record);
|
||||||
if (TRIGGER_TYPE_ENUM.CRON.value === record.triggerType) {
|
if (TRIGGER_TYPE_ENUM.CRON.value === record.triggerType) {
|
||||||
updateForm.cron = record.triggerValue;
|
updateForm.cron = record.triggerValue;
|
||||||
@ -160,30 +163,43 @@
|
|||||||
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === record.triggerType) {
|
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === record.triggerType) {
|
||||||
updateForm.fixedDelay = record.triggerValue;
|
updateForm.fixedDelay = record.triggerValue;
|
||||||
}
|
}
|
||||||
updateModalShow.value = true;
|
|
||||||
}
|
}
|
||||||
|
updateModalShow.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 关闭编辑弹框
|
// 关闭编辑弹框
|
||||||
function closeUpdateModal() {
|
function closeUpdateModal() {
|
||||||
Object.assign(updateForm, updateFormDefault);
|
Object.assign(updateForm, updateFormDefault);
|
||||||
updateModalShow.value = false;
|
updateModalShow.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确认更新
|
// 确认更新
|
||||||
async function confirmUpdateJob() {
|
async function confirmUpdateJob() {
|
||||||
updateFormRef.value
|
updateFormRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
SmartLoading.show();
|
|
||||||
if (TRIGGER_TYPE_ENUM.CRON.value === updateForm.triggerType) {
|
if (TRIGGER_TYPE_ENUM.CRON.value === updateForm.triggerType) {
|
||||||
updateForm.triggerValue = updateForm.cron;
|
updateForm.triggerValue = updateForm.cron;
|
||||||
}
|
}
|
||||||
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === updateForm.triggerType) {
|
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === updateForm.triggerType) {
|
||||||
updateForm.triggerValue = updateForm.fixedDelay;
|
updateForm.triggerValue = updateForm.fixedDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!updateForm.triggerValue){
|
||||||
|
message.error('请填写 触发时间');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await jobApi.updateJob(updateForm);
|
SmartLoading.show();
|
||||||
message.success('更新成功');
|
if(isAdd.value){
|
||||||
|
await jobApi.addJob(updateForm)
|
||||||
|
message.success('添加成功');
|
||||||
|
}else {
|
||||||
|
await jobApi.updateJob(updateForm);
|
||||||
|
message.success('更新成功');
|
||||||
|
}
|
||||||
closeUpdateModal();
|
closeUpdateModal();
|
||||||
emit('reloadList');
|
emit('reloadList');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -196,53 +212,53 @@
|
|||||||
console.log('error', error);
|
console.log('error', error);
|
||||||
message.error('参数验证错误,请检查表单数据');
|
message.error('参数验证错误,请检查表单数据');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------ 执行任务 -------------------------------------
|
||||||
|
const executeModalShow = ref(false);
|
||||||
|
const executeFormDefault = {
|
||||||
|
jobId: null,
|
||||||
|
jobName: '',
|
||||||
|
jobClass: '',
|
||||||
|
param: null,
|
||||||
|
};
|
||||||
|
let executeForm = reactive({ ...executeFormDefault });
|
||||||
|
|
||||||
|
// 打开执行弹框
|
||||||
|
function openExecuteModal(record) {
|
||||||
|
Object.assign(executeForm, record);
|
||||||
|
executeModalShow.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭执行弹框
|
||||||
|
function closeExecuteModal() {
|
||||||
|
Object.assign(executeForm, executeFormDefault);
|
||||||
|
executeModalShow.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认执行
|
||||||
|
async function confirmExecuteJob() {
|
||||||
|
try {
|
||||||
|
let executeParam = {
|
||||||
|
jobId: executeForm.jobId,
|
||||||
|
param: executeForm.param,
|
||||||
|
};
|
||||||
|
await jobApi.executeJob(executeParam);
|
||||||
|
// loading 延迟后再提示刷新
|
||||||
|
SmartLoading.show();
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
message.success('执行成功');
|
||||||
|
closeExecuteModal();
|
||||||
|
emit('reloadList');
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------ 执行任务 -------------------------------------
|
defineExpose({
|
||||||
const executeModalShow = ref(false);
|
openUpdateModal,
|
||||||
const executeFormDefault = {
|
openExecuteModal,
|
||||||
jobId: null,
|
});
|
||||||
jobName: '',
|
|
||||||
jobClass: '',
|
|
||||||
param: null,
|
|
||||||
};
|
|
||||||
let executeForm = reactive({ ...executeFormDefault });
|
|
||||||
|
|
||||||
// 打开执行弹框
|
|
||||||
function openExecuteModal(record) {
|
|
||||||
Object.assign(executeForm, record);
|
|
||||||
executeModalShow.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭执行弹框
|
|
||||||
function closeExecuteModal() {
|
|
||||||
Object.assign(executeForm, executeFormDefault);
|
|
||||||
executeModalShow.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 确认执行
|
|
||||||
async function confirmExecuteJob() {
|
|
||||||
try {
|
|
||||||
let executeParam = {
|
|
||||||
jobId: executeForm.jobId,
|
|
||||||
param: executeForm.param,
|
|
||||||
};
|
|
||||||
await jobApi.executeJob(executeParam);
|
|
||||||
// loading 延迟后再提示刷新
|
|
||||||
SmartLoading.show();
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
||||||
message.success('执行成功');
|
|
||||||
closeExecuteModal();
|
|
||||||
emit('reloadList');
|
|
||||||
} catch (e) {
|
|
||||||
smartSentry.captureError(e);
|
|
||||||
} finally {
|
|
||||||
SmartLoading.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
openUpdateModal,
|
|
||||||
openExecuteModal,
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,122 +5,143 @@
|
|||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<a-form class="smart-query-form">
|
|
||||||
<a-row class="smart-query-form-row">
|
|
||||||
<a-form-item label="关键字" class="smart-query-form-item">
|
|
||||||
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="触发类型" class="smart-query-form-item">
|
|
||||||
<a-select style="width: 155px" v-model:value="queryForm.triggerType" placeholder="请选择触发类型" allowClear>
|
|
||||||
<a-select-option v-for="item in $smartEnumPlugin.getValueDescList('TRIGGER_TYPE_ENUM')" :key="item.value" :value="item.value">
|
|
||||||
{{ item.desc }}
|
|
||||||
</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="状态" class="smart-query-form-item">
|
|
||||||
<a-select style="width: 150px" v-model:value="queryForm.enabledFlag" placeholder="请选择状态" allowClear>
|
|
||||||
<a-select-option :key="1"> 开启 </a-select-option>
|
|
||||||
<a-select-option :key="0"> 停止 </a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
|
|
||||||
<a-form-item class="smart-query-form-item smart-margin-left10">
|
|
||||||
<a-button-group>
|
|
||||||
<a-button type="primary" @click="onSearch" v-privilege="'support:job:query'">
|
|
||||||
<template #icon>
|
|
||||||
<ReloadOutlined />
|
|
||||||
</template>
|
|
||||||
查询
|
|
||||||
</a-button>
|
|
||||||
<a-button @click="resetQuery" v-privilege="'support:job:query'">
|
|
||||||
<template #icon>
|
|
||||||
<SearchOutlined />
|
|
||||||
</template>
|
|
||||||
重置
|
|
||||||
</a-button>
|
|
||||||
</a-button-group>
|
|
||||||
</a-form-item>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
|
|
||||||
<a-card size="small" :bordered="false" :hoverable="true">
|
<a-card size="small" :bordered="false" :hoverable="true">
|
||||||
<a-row justify="end">
|
<a-tabs v-model:activeKey="activeKey">
|
||||||
<TableOperator class="smart-margin-bottom5" v-model="columns" :tableId="TABLE_ID_CONST.SUPPORT.JOB" :refresh="queryJobList" />
|
<a-tab-pane key="1" tab="有效任务">
|
||||||
</a-row>
|
<a-form class="smart-query-form">
|
||||||
|
<a-row class="smart-query-form-row">
|
||||||
|
<a-form-item label="关键字" class="smart-query-form-item">
|
||||||
|
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="触发类型" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 155px" v-model:value="queryForm.triggerType" placeholder="请选择触发类型" allowClear>
|
||||||
|
<a-select-option v-for="item in $smartEnumPlugin.getValueDescList('TRIGGER_TYPE_ENUM')" :key="item.value" :value="item.value">
|
||||||
|
{{ item.desc }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="状态" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 150px" v-model:value="queryForm.enabledFlag" placeholder="请选择状态" allowClear>
|
||||||
|
<a-select-option :key="1"> 开启 </a-select-option>
|
||||||
|
<a-select-option :key="0"> 停止 </a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
<a-table
|
<a-form-item class="smart-query-form-item smart-margin-left10">
|
||||||
:scroll="{ x: 1800 }"
|
<a-button-group>
|
||||||
size="small"
|
<a-button type="primary" @click="onSearch" v-privilege="'support:job:query'">
|
||||||
:loading="tableLoading"
|
<template #icon>
|
||||||
bordered
|
<ReloadOutlined />
|
||||||
:dataSource="tableData"
|
</template>
|
||||||
:columns="columns"
|
查询
|
||||||
rowKey="jobId"
|
</a-button>
|
||||||
:pagination="false"
|
<a-button @click="resetQuery" v-privilege="'support:job:query'">
|
||||||
>
|
<template #icon>
|
||||||
<template #bodyCell="{ record, column }">
|
<SearchOutlined />
|
||||||
<template v-if="column.dataIndex === 'jobClass'">
|
</template>
|
||||||
<a-tooltip>
|
重置
|
||||||
<template #title>{{ record.jobClass }}</template>
|
</a-button>
|
||||||
{{ handleJobClass(record.jobClass) }}
|
</a-button-group>
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
<a-button class="smart-margin-left20" type="primary" @click="openUpdateModal()" v-privilege="'support:job:add'">
|
||||||
<template v-if="column.dataIndex === 'triggerType'">
|
<template #icon>
|
||||||
<a-tag v-if="record.triggerType === TRIGGER_TYPE_ENUM.CRON.value" color="success">{{ record.triggerTypeDesc }}</a-tag>
|
<plus-outlined />
|
||||||
<a-tag v-else-if="record.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value" color="processing">{{ record.triggerTypeDesc }}</a-tag>
|
</template>
|
||||||
<a-tag v-else color="pink">{{ record.triggerTypeDesc }}</a-tag>
|
添加任务
|
||||||
</template>
|
</a-button>
|
||||||
<template v-if="column.dataIndex === 'lastJob'">
|
</a-form-item>
|
||||||
<div v-if="record.lastJobLog">
|
</a-row>
|
||||||
<a-tooltip>
|
</a-form>
|
||||||
<template #title>{{ handleExecuteResult(record.lastJobLog.executeResult) }}</template>
|
<a-flex align="end" vertical>
|
||||||
<CheckOutlined v-if="record.lastJobLog.successFlag" style="color: #39c710" />
|
<div class="smart-table-setting-block smart-margin-bottom10">
|
||||||
<WarningOutlined v-else style="color: #f50" />
|
<TableOperator
|
||||||
{{ record.lastJobLog.executeStartTime }}
|
class="smart-margin-bottom5 pull-right"
|
||||||
</a-tooltip>
|
v-model="columns"
|
||||||
|
:tableId="TABLE_ID_CONST.SUPPORT.JOB"
|
||||||
|
:refresh="queryJobList"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</a-flex>
|
||||||
<template v-if="column.dataIndex === 'nextJob'">
|
|
||||||
<a-tooltip v-if="record.enabledFlag && record.nextJobExecuteTimeList">
|
<a-table
|
||||||
<template #title>
|
:scroll="{ x: 1800 }"
|
||||||
<div>下次执行(预估时间)</div>
|
size="small"
|
||||||
<div v-for="item in record.nextJobExecuteTimeList" :key="item">{{ item }}</div>
|
:loading="tableLoading"
|
||||||
|
bordered
|
||||||
|
:dataSource="tableData"
|
||||||
|
:columns="columns"
|
||||||
|
rowKey="jobId"
|
||||||
|
:pagination="false"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ record, column }">
|
||||||
|
<template v-if="column.dataIndex === 'jobClass'">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>{{ record.jobClass }}</template>
|
||||||
|
{{ handleJobClass(record.jobClass) }}
|
||||||
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
{{ record.nextJobExecuteTimeList[0] }}
|
<template v-if="column.dataIndex === 'triggerType'">
|
||||||
</a-tooltip>
|
<a-tag v-if="record.triggerType === TRIGGER_TYPE_ENUM.CRON.value" color="success">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
</template>
|
<a-tag v-else-if="record.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value" color="processing">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
<template v-if="column.dataIndex === 'enabledFlag'">
|
<a-tag v-else color="pink">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
<a-switch
|
</template>
|
||||||
v-model:checked="record.enabledFlag"
|
<template v-if="column.dataIndex === 'lastJob'">
|
||||||
@change="(checked) => handleEnabledUpdate(checked, record)"
|
<div v-if="record.lastJobLog">
|
||||||
:loading="record.enabledLoading"
|
<a-tooltip>
|
||||||
|
<template #title>{{ handleExecuteResult(record.lastJobLog.executeResult) }}</template>
|
||||||
|
<CheckOutlined v-if="record.lastJobLog.successFlag" style="color: #39c710" />
|
||||||
|
<WarningOutlined v-else style="color: #f50" />
|
||||||
|
{{ record.lastJobLog.executeStartTime }}
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'nextJob'">
|
||||||
|
<a-tooltip v-if="record.enabledFlag && record.nextJobExecuteTimeList">
|
||||||
|
<template #title>
|
||||||
|
<div>下次执行(预估时间)</div>
|
||||||
|
<div v-for="item in record.nextJobExecuteTimeList" :key="item">{{ item }}</div>
|
||||||
|
</template>
|
||||||
|
{{ record.nextJobExecuteTimeList[0] }}
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'enabledFlag'">
|
||||||
|
<a-switch
|
||||||
|
v-model:checked="record.enabledFlag"
|
||||||
|
checked-children="已启用" un-checked-children="已禁用"
|
||||||
|
@change="(checked) => handleEnabledUpdate(checked, record)"
|
||||||
|
:loading="record.enabledLoading"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'action'">
|
||||||
|
<div class="smart-table-operate">
|
||||||
|
<a-button v-privilege="'support:job:update'" @click="openUpdateModal(record)" type="link">编辑</a-button>
|
||||||
|
<a-button v-privilege="'support:job:execute'" type="link" @click="openExecuteModal(record)">执行</a-button>
|
||||||
|
<a-button v-privilege="'support:job:log:query'" @click="openJobLogModal(record.jobId, record.jobName)" type="link">记录</a-button>
|
||||||
|
<a-button danger v-privilege="'support:job:log:delete'" @click="confirmDelete(record.jobId, record.jobName)" type="link">删除</a-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
<div class="smart-query-table-page">
|
||||||
|
<a-pagination
|
||||||
|
showSizeChanger
|
||||||
|
showQuickJumper
|
||||||
|
show-less-items
|
||||||
|
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||||
|
:defaultPageSize="queryForm.pageSize"
|
||||||
|
v-model:current="queryForm.pageNum"
|
||||||
|
v-model:pageSize="queryForm.pageSize"
|
||||||
|
:total="total"
|
||||||
|
@change="queryJobList"
|
||||||
|
@showSizeChange="queryJobList"
|
||||||
|
:show-total="(total) => `共${total}条`"
|
||||||
/>
|
/>
|
||||||
</template>
|
</div>
|
||||||
<template v-if="column.dataIndex === 'action'">
|
</a-tab-pane>
|
||||||
<div class="smart-table-operate">
|
<a-tab-pane key="2" tab="已删除任务"><DeletedJobList /></a-tab-pane>
|
||||||
<a-button v-privilege="'support:job:update'" @click="openUpdateModal(record)" type="link">编辑</a-button>
|
</a-tabs>
|
||||||
<a-button v-privilege="'support:job:execute'" type="link" @click="openExecuteModal(record)">执行</a-button>
|
|
||||||
<a-button v-privilege="'support:job:log:query'" @click="openJobLogModal(record.jobId, record.jobName)" type="link">记录</a-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</a-table>
|
|
||||||
|
|
||||||
<div class="smart-query-table-page">
|
|
||||||
<a-pagination
|
|
||||||
showSizeChanger
|
|
||||||
showQuickJumper
|
|
||||||
show-less-items
|
|
||||||
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
|
||||||
:defaultPageSize="queryForm.pageSize"
|
|
||||||
v-model:current="queryForm.pageNum"
|
|
||||||
v-model:pageSize="queryForm.pageSize"
|
|
||||||
:total="total"
|
|
||||||
@change="queryJobList"
|
|
||||||
@showSizeChange="queryJobList"
|
|
||||||
:show-total="(total) => `共${total}条`"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</a-card>
|
</a-card>
|
||||||
|
|
||||||
<!-- 表单操作 -->
|
<!-- 表单操作 -->
|
||||||
@ -131,17 +152,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { message } from 'ant-design-vue';
|
import {message, Modal} from 'ant-design-vue';
|
||||||
import { onMounted, reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import { jobApi } from '/@/api/support/job-api';
|
import { jobApi } from '/@/api/support/job-api';
|
||||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||||
import { smartSentry } from '/@/lib/smart-sentry';
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
import TableOperator from '/@/components/support/table-operator/index.vue';
|
||||||
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
|
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
|
||||||
import { useRouter } from 'vue-router';
|
import DeletedJobList from './components/deleted-job-list.vue';
|
||||||
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
||||||
import JobFormModal from './components/job-form-modal.vue';
|
import JobFormModal from './components/job-form-modal.vue';
|
||||||
import JobLogListModal from './components/job-log-list-modal.vue';
|
import JobLogListModal from './components/job-log-list-modal.vue';
|
||||||
|
import {SmartLoading} from "/@/components/framework/smart-loading/index.js";
|
||||||
|
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{
|
{
|
||||||
@ -182,9 +204,9 @@
|
|||||||
dataIndex: 'nextJob',
|
dataIndex: 'nextJob',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '启用状态',
|
||||||
dataIndex: 'enabledFlag',
|
dataIndex: 'enabledFlag',
|
||||||
width: 80,
|
width: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '执行参数',
|
title: '执行参数',
|
||||||
@ -215,7 +237,7 @@
|
|||||||
title: '操作',
|
title: '操作',
|
||||||
dataIndex: 'action',
|
dataIndex: 'action',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 130,
|
width: 170,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -225,6 +247,7 @@
|
|||||||
searchWord: '',
|
searchWord: '',
|
||||||
enabledFlag: null,
|
enabledFlag: null,
|
||||||
triggerType: null,
|
triggerType: null,
|
||||||
|
deletedFlag: false,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
};
|
};
|
||||||
@ -249,7 +272,7 @@
|
|||||||
return jobClass.split('.').pop();
|
return jobClass.split('.').pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上次处理结果展示 最多展示300
|
// 上次处理结果展示
|
||||||
function handleExecuteResult(result) {
|
function handleExecuteResult(result) {
|
||||||
let num = 400;
|
let num = 400;
|
||||||
return result ? result.substring(0, num) + (result.length > num ? ' ...' : '') : '';
|
return result ? result.substring(0, num) + (result.length > num ? ' ...' : '') : '';
|
||||||
@ -308,6 +331,35 @@
|
|||||||
jobLogModal.value.show(jobId, name);
|
jobLogModal.value.show(jobId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------ 删除操作 -------------------------------------
|
||||||
|
|
||||||
|
function confirmDelete(jobId, jobName){
|
||||||
|
Modal.confirm({
|
||||||
|
title: '警告',
|
||||||
|
content: `确定要删除【${jobName}】任务吗?`,
|
||||||
|
okText: '删除',
|
||||||
|
okType: 'danger',
|
||||||
|
onOk() {
|
||||||
|
deleteJob(jobId);
|
||||||
|
},
|
||||||
|
cancelText: '取消',
|
||||||
|
onCancel() {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteJob(jobId){
|
||||||
|
try{
|
||||||
|
SmartLoading.show();
|
||||||
|
await jobApi.deleteJob(jobId);
|
||||||
|
message.success('删除成功!');
|
||||||
|
queryJobList();
|
||||||
|
}catch (e){
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
}finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------ 表单操作 -------------------------------------
|
// ------------------------------------ 表单操作 -------------------------------------
|
||||||
const jobFormModal = ref();
|
const jobFormModal = ref();
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ export const jobApi = {
|
|||||||
executeJob: (param) => {
|
executeJob: (param) => {
|
||||||
return postRequest('/support/job/execute', param);
|
return postRequest('/support/job/execute', param);
|
||||||
},
|
},
|
||||||
|
// 定时任务-新增-任务信息 @huke
|
||||||
|
addJob: (param) => {
|
||||||
|
return postRequest('/support/job/add', param);
|
||||||
|
},
|
||||||
// 定时任务-更新-任务信息 @huke
|
// 定时任务-更新-任务信息 @huke
|
||||||
updateJob: (param) => {
|
updateJob: (param) => {
|
||||||
return postRequest('/support/job/update', param);
|
return postRequest('/support/job/update', param);
|
||||||
@ -31,4 +35,8 @@ export const jobApi = {
|
|||||||
queryJobLog: (param) => {
|
queryJobLog: (param) => {
|
||||||
return postRequest('/support/job/log/query', param);
|
return postRequest('/support/job/log/query', param);
|
||||||
},
|
},
|
||||||
|
// 定时任务-删除 @zhuoda
|
||||||
|
deleteJob: (param) => {
|
||||||
|
return getRequest(`/support/job/delete?jobId=${param}`);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -34,8 +34,8 @@ export const PAGE_TAG_ENUM: SmartEnum<string> = {
|
|||||||
value: 'antd',
|
value: 'antd',
|
||||||
desc: 'Ant Design',
|
desc: 'Ant Design',
|
||||||
},
|
},
|
||||||
NAIVE: {
|
CHROME: {
|
||||||
value: 'naive',
|
value: 'chrome',
|
||||||
desc: 'NAIVE',
|
desc: 'Chrome',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -73,8 +73,8 @@
|
|||||||
<a-form-item :label="$t('setting.pagetag.style')">
|
<a-form-item :label="$t('setting.pagetag.style')">
|
||||||
<a-radio-group v-model:value="formState.pageTagStyle" button-style="solid" @change="changePageTagStyle">
|
<a-radio-group v-model:value="formState.pageTagStyle" button-style="solid" @change="changePageTagStyle">
|
||||||
<a-radio-button value="default">默认</a-radio-button>
|
<a-radio-button value="default">默认</a-radio-button>
|
||||||
<a-radio-button value="antd">ANTD</a-radio-button>
|
<a-radio-button value="antd">Ant</a-radio-button>
|
||||||
<a-radio-button value="naive">NAIVE</a-radio-button>
|
<a-radio-button value="chrome">Chrome</a-radio-button>
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="$t('setting.pagetag')">
|
<a-form-item :label="$t('setting.pagetag')">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
* 使用naiveUI <a-tabs> 组件
|
* chrome样式 <a-tabs> 组件
|
||||||
*
|
*
|
||||||
* @Author: 1024创新实验室-主任:卓大
|
* @Author: 1024创新实验室-主任:卓大
|
||||||
* @Date: 2024-11-27 20:29:12
|
* @Date: 2024-11-27 20:29:12
|
||||||
@ -51,88 +51,88 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { AppstoreOutlined, CloseOutlined } from '@ant-design/icons-vue';
|
import { AppstoreOutlined, CloseOutlined } from '@ant-design/icons-vue';
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||||
import { useUserStore } from '/@/store/modules/system/user';
|
import { useUserStore } from '/@/store/modules/system/user';
|
||||||
import { theme } from 'ant-design-vue';
|
import { theme } from 'ant-design-vue';
|
||||||
|
|
||||||
//标签页 是否显示
|
//标签页 是否显示
|
||||||
const pageTagFlag = computed(() => useAppConfigStore().$state.pageTagFlag);
|
const pageTagFlag = computed(() => useAppConfigStore().$state.pageTagFlag);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const mode = ref('top');
|
const mode = ref('top');
|
||||||
const tagNav = computed(() => useUserStore().getTagNav || []);
|
const tagNav = computed(() => useUserStore().getTagNav || []);
|
||||||
const selectedKey = ref(route.name);
|
const selectedKey = ref(route.name);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route.name,
|
() => route.name,
|
||||||
(newValue, oldValue) => {
|
(newValue, oldValue) => {
|
||||||
selectedKey.value = newValue;
|
selectedKey.value = newValue;
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
//选择某个标签页
|
//选择某个标签页
|
||||||
function selectTab(name) {
|
function selectTab(name) {
|
||||||
if (selectedKey.value === name) {
|
if (selectedKey.value === name) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
// 寻找tag
|
|
||||||
let tag = tagNav.value.find((e) => e.menuName === name);
|
|
||||||
if (!tag) {
|
|
||||||
router.push({ name: HOME_PAGE_NAME });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// router.push({ name, query: Object.assign({ _keepAlive: 1 }, tag.menuQuery) });
|
|
||||||
router.push({ name, query: tag.menuQuery });
|
|
||||||
}
|
}
|
||||||
|
// 寻找tag
|
||||||
|
let tag = tagNav.value.find((e) => e.menuName === name);
|
||||||
|
if (!tag) {
|
||||||
|
router.push({ name: HOME_PAGE_NAME });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// router.push({ name, query: Object.assign({ _keepAlive: 1 }, tag.menuQuery) });
|
||||||
|
router.push({ name, query: tag.menuQuery });
|
||||||
|
}
|
||||||
|
|
||||||
//通过菜单关闭
|
//通过菜单关闭
|
||||||
function closeByMenu(closeAll) {
|
function closeByMenu(closeAll) {
|
||||||
let find = tagNav.value.find((e) => e.menuName === selectedKey.value);
|
let find = tagNav.value.find((e) => e.menuName === selectedKey.value);
|
||||||
if (!find || closeAll) {
|
if (!find || closeAll) {
|
||||||
closeTag(null, true);
|
closeTag(null, true);
|
||||||
|
} else {
|
||||||
|
closeTag(find, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//直接关闭
|
||||||
|
function closeTag(item, closeAll) {
|
||||||
|
// 关闭单个tag
|
||||||
|
if (item && !closeAll) {
|
||||||
|
let goName = HOME_PAGE_NAME;
|
||||||
|
let goQuery = undefined;
|
||||||
|
if (item.fromMenuName && item.fromMenuName !== item.menuName && tagNav.value.some((e) => e.menuName === item.fromMenuName)) {
|
||||||
|
goName = item.fromMenuName;
|
||||||
|
goQuery = item.fromMenuQuery;
|
||||||
} else {
|
} else {
|
||||||
closeTag(find, true);
|
// 查询左侧tag
|
||||||
}
|
let index = tagNav.value.findIndex((e) => e.menuName === item.menuName);
|
||||||
}
|
if (index > 0) {
|
||||||
|
|
||||||
//直接关闭
|
|
||||||
function closeTag(item, closeAll) {
|
|
||||||
// 关闭单个tag
|
|
||||||
if (item && !closeAll) {
|
|
||||||
let goName = HOME_PAGE_NAME;
|
|
||||||
let goQuery = undefined;
|
|
||||||
if (item.fromMenuName && item.fromMenuName !== item.menuName && tagNav.value.some((e) => e.menuName === item.fromMenuName)) {
|
|
||||||
goName = item.fromMenuName;
|
|
||||||
goQuery = item.fromMenuQuery;
|
|
||||||
} else {
|
|
||||||
// 查询左侧tag
|
// 查询左侧tag
|
||||||
let index = tagNav.value.findIndex((e) => e.menuName === item.menuName);
|
let leftTagNav = tagNav.value[index - 1];
|
||||||
if (index > 0) {
|
goName = leftTagNav.menuName;
|
||||||
// 查询左侧tag
|
goQuery = leftTagNav.menuQuery;
|
||||||
let leftTagNav = tagNav.value[index - 1];
|
|
||||||
goName = leftTagNav.menuName;
|
|
||||||
goQuery = leftTagNav.menuQuery;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// router.push({ name: goName, query: Object.assign({ _keepAlive: 1 }, goQuery) });
|
|
||||||
router.push({ name: goName, query: goQuery });
|
|
||||||
} else if (!item && closeAll) {
|
|
||||||
// 关闭所有tag
|
|
||||||
router.push({ name: HOME_PAGE_NAME });
|
|
||||||
}
|
}
|
||||||
// 关闭其他tag不做处理 直接调用closeTagNav
|
// router.push({ name: goName, query: Object.assign({ _keepAlive: 1 }, goQuery) });
|
||||||
useUserStore().closeTagNav(item ? item.menuName : null, closeAll);
|
router.push({ name: goName, query: goQuery });
|
||||||
|
} else if (!item && closeAll) {
|
||||||
|
// 关闭所有tag
|
||||||
|
router.push({ name: HOME_PAGE_NAME });
|
||||||
}
|
}
|
||||||
|
// 关闭其他tag不做处理 直接调用closeTagNav
|
||||||
|
useUserStore().closeTagNav(item ? item.menuName : null, closeAll);
|
||||||
|
}
|
||||||
|
|
||||||
const { useToken } = theme;
|
const { useToken } = theme;
|
||||||
const { token } = useToken();
|
const { token } = useToken();
|
||||||
const borderRadius = token.value.borderRadius + 'px';
|
const borderRadius = 8 + 'px';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@ -212,7 +212,7 @@
|
|||||||
}
|
}
|
||||||
&:nth-last-child(2) {
|
&:nth-last-child(2) {
|
||||||
margin-right: 0 !important;
|
margin-right: 0 !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.smart-page-tag-content {
|
.smart-page-tag-content {
|
||||||
@ -227,7 +227,7 @@
|
|||||||
right: 9px;
|
right: 9px;
|
||||||
z-index: -2;
|
z-index: -2;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
background: #666;
|
background: #eeeeee;
|
||||||
}
|
}
|
||||||
.smart-page-tag-icon{
|
.smart-page-tag-icon{
|
||||||
margin-right:5px;
|
margin-right:5px;
|
@ -11,7 +11,7 @@
|
|||||||
<div id="smartAdminPageTag">
|
<div id="smartAdminPageTag">
|
||||||
<DefaultTab v-if="pageTagStyle === PAGE_TAG_ENUM.DEFAULT.value" />
|
<DefaultTab v-if="pageTagStyle === PAGE_TAG_ENUM.DEFAULT.value" />
|
||||||
<AntdTab v-if="pageTagStyle === PAGE_TAG_ENUM.ANTD.value" />
|
<AntdTab v-if="pageTagStyle === PAGE_TAG_ENUM.ANTD.value" />
|
||||||
<NaiveTab v-if="pageTagStyle === PAGE_TAG_ENUM.NAIVE.value" />
|
<ChromeTab v-if="pageTagStyle === PAGE_TAG_ENUM.CHROME.value" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -20,7 +20,7 @@
|
|||||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||||
import DefaultTab from './components/default-tab.vue';
|
import DefaultTab from './components/default-tab.vue';
|
||||||
import AntdTab from './components/antd-tab.vue';
|
import AntdTab from './components/antd-tab.vue';
|
||||||
import NaiveTab from './components/naive-tab.vue';
|
import ChromeTab from './components/chrome-tab.vue';
|
||||||
import { PAGE_TAG_ENUM } from '/@/constants/layout-const.js';
|
import { PAGE_TAG_ENUM } from '/@/constants/layout-const.js';
|
||||||
|
|
||||||
const pageTagStyle = computed(() => useAppConfigStore().$state.pageTagStyle);
|
const pageTagStyle = computed(() => useAppConfigStore().$state.pageTagStyle);
|
||||||
|
@ -14,23 +14,25 @@
|
|||||||
<span class="ant-menu">{{ topMenu.menuName }}</span>
|
<span class="ant-menu">{{ topMenu.menuName }}</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- 次级菜单展示 -->
|
<!-- 次级菜单展示 -->
|
||||||
<a-menu :selectedKeys="selectedKeys" :openKeys="openKeys" mode="inline">
|
<div class="bottom-menu">
|
||||||
<template v-for="item in topMenu.children" :key="item.menuId">
|
<a-menu :selectedKeys="selectedKeys" :openKeys="openKeys" mode="inline">
|
||||||
<template v-if="item.visibleFlag">
|
<template v-for="item in topMenu.children" :key="item.menuId">
|
||||||
<template v-if="$lodash.isEmpty(item.children)">
|
<template v-if="item.visibleFlag">
|
||||||
<a-menu-item :key="item.menuId.toString()" @click="turnToPage(item)">
|
<template v-if="$lodash.isEmpty(item.children)">
|
||||||
<template #icon v-if="item.icon">
|
<a-menu-item :key="item.menuId.toString()" @click="turnToPage(item)">
|
||||||
<component :is="$antIcons[item.icon]" />
|
<template #icon v-if="item.icon">
|
||||||
</template>
|
<component :is="$antIcons[item.icon]" />
|
||||||
{{ item.menuName }}
|
</template>
|
||||||
</a-menu-item>
|
{{ item.menuName }}
|
||||||
</template>
|
</a-menu-item>
|
||||||
<template v-else>
|
</template>
|
||||||
<SubMenu :menu-info="item" :key="item.menuId" @turnToPage="turnToPage" />
|
<template v-else>
|
||||||
|
<SubMenu :menu-info="item" :key="item.menuId" @turnToPage="turnToPage" />
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</a-menu>
|
||||||
</a-menu>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -84,10 +86,15 @@
|
|||||||
</script>
|
</script>
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.recursion-container {
|
.recursion-container {
|
||||||
height: 100%;
|
height: 100vh;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
}
|
}
|
||||||
|
.bottom-menu{
|
||||||
|
overflow: auto;
|
||||||
|
display: flex;
|
||||||
|
height: 90%;
|
||||||
|
color: #515a6e;
|
||||||
|
}
|
||||||
.top-menu {
|
.top-menu {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
import watermark from '../lib/smart-watermark';
|
import watermark from '../lib/smart-watermark';
|
||||||
import { useUserStore } from '/@/store/modules/system/user';
|
import { useUserStore } from '/@/store/modules/system/user';
|
||||||
import HeaderAvatar from './components/header-user-space/header-avatar.vue';
|
import HeaderAvatar from './components/header-user-space/header-avatar.vue';
|
||||||
|
import { LAYOUT_ELEMENT_IDS } from '/@/layout/layout-const';
|
||||||
|
|
||||||
const websiteName = computed(() => useAppConfigStore().websiteName);
|
const websiteName = computed(() => useAppConfigStore().websiteName);
|
||||||
const windowHeight = window.innerHeight;
|
const windowHeight = window.innerHeight;
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-layout class="admin-layout" style="min-height: 100%">
|
<a-layout class="admin-layout" style="min-height: 100%">
|
||||||
<!-- 侧边菜单 side-menu -->
|
<!-- 侧边菜单 side-menu -->
|
||||||
<a-layout-sider
|
<a-layout-sider :id="LAYOUT_ELEMENT_IDS.menu" class="side-menu" :width="sideMenuWidth" :collapsed="collapsed" :theme="theme" v-show="!fullScreenFlag">
|
||||||
:id="LAYOUT_ELEMENT_IDS.menu"
|
|
||||||
class="side-menu"
|
|
||||||
:width="sideMenuWidth"
|
|
||||||
:collapsed="collapsed"
|
|
||||||
:theme="theme"
|
|
||||||
v-show="!fullScreenFlag"
|
|
||||||
>
|
|
||||||
<!-- 左侧菜单 -->
|
<!-- 左侧菜单 -->
|
||||||
<SideMenu :collapsed="collapsed" />
|
<SideMenu :collapsed="collapsed" />
|
||||||
</a-layout-sider>
|
</a-layout-sider>
|
||||||
|
@ -0,0 +1,283 @@
|
|||||||
|
<!--
|
||||||
|
* 已删除的 JOB 列表
|
||||||
|
* @Author: zhuoda
|
||||||
|
* @Date: 2025/01/05
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<a-form class="smart-query-form">
|
||||||
|
<a-row class="smart-query-form-row">
|
||||||
|
<a-form-item label="关键字" class="smart-query-form-item">
|
||||||
|
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="触发类型" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 155px" v-model:value="queryForm.triggerType" placeholder="请选择触发类型" allowClear>
|
||||||
|
<a-select-option v-for="item in $smartEnumPlugin.getValueDescList('TRIGGER_TYPE_ENUM')" :key="item.value" :value="item.value">
|
||||||
|
{{ item.desc }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="状态" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 150px" v-model:value="queryForm.enabledFlag" placeholder="请选择状态" allowClear>
|
||||||
|
<a-select-option :key="1"> 开启 </a-select-option>
|
||||||
|
<a-select-option :key="0"> 停止 </a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item class="smart-query-form-item smart-margin-left10">
|
||||||
|
<a-button-group>
|
||||||
|
<a-button type="primary" @click="onSearch" v-privilege="'support:job:query'">
|
||||||
|
<template #icon>
|
||||||
|
<ReloadOutlined />
|
||||||
|
</template>
|
||||||
|
查询
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="resetQuery" v-privilege="'support:job:query'">
|
||||||
|
<template #icon>
|
||||||
|
<SearchOutlined />
|
||||||
|
</template>
|
||||||
|
重置
|
||||||
|
</a-button>
|
||||||
|
</a-button-group>
|
||||||
|
</a-form-item>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
|
||||||
|
<a-flex align="end" vertical>
|
||||||
|
<div class="smart-table-setting-block smart-margin-bottom10">
|
||||||
|
<TableOperator
|
||||||
|
class="smart-margin-bottom5 pull-right"
|
||||||
|
v-model="columns"
|
||||||
|
:tableId="TABLE_ID_CONST.SUPPORT.JOB"
|
||||||
|
:refresh="queryJobList"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-flex>
|
||||||
|
|
||||||
|
<a-table
|
||||||
|
:scroll="{ x: 1800 }"
|
||||||
|
size="small"
|
||||||
|
:loading="tableLoading"
|
||||||
|
bordered
|
||||||
|
:dataSource="tableData"
|
||||||
|
:columns="columns"
|
||||||
|
rowKey="jobId"
|
||||||
|
:pagination="false"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ record, column }">
|
||||||
|
<template v-if="column.dataIndex === 'jobClass'">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>{{ record.jobClass }}</template>
|
||||||
|
{{ handleJobClass(record.jobClass) }}
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'triggerType'">
|
||||||
|
<a-tag v-if="record.triggerType === TRIGGER_TYPE_ENUM.CRON.value" color="success">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
|
<a-tag v-else-if="record.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value" color="processing">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
|
<a-tag v-else color="pink">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'lastJob'">
|
||||||
|
<div v-if="record.lastJobLog">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>{{ handleExecuteResult(record.lastJobLog.executeResult) }}</template>
|
||||||
|
<CheckOutlined v-if="record.lastJobLog.successFlag" style="color: #39c710" />
|
||||||
|
<WarningOutlined v-else style="color: #f50" />
|
||||||
|
{{ record.lastJobLog.executeStartTime }}
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'nextJob'">
|
||||||
|
<a-tooltip v-if="record.enabledFlag && record.nextJobExecuteTimeList">
|
||||||
|
<template #title>
|
||||||
|
<div>下次执行(预估时间)</div>
|
||||||
|
<div v-for="item in record.nextJobExecuteTimeList" :key="item">{{ item }}</div>
|
||||||
|
</template>
|
||||||
|
{{ record.nextJobExecuteTimeList[0] }}
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'enabledFlag'">
|
||||||
|
<a-switch checked-children="已启用" un-checked-children="已禁用" v-model:checked="record.enabledFlag" disabled :loading="record.enabledLoading" />
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'action'">
|
||||||
|
<div class="smart-table-operate">
|
||||||
|
<a-button v-privilege="'support:job:log:query'" @click="openJobLogModal(record.jobId, record.jobName)" type="link">记录</a-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
|
||||||
|
<div class="smart-query-table-page">
|
||||||
|
<a-pagination
|
||||||
|
showSizeChanger
|
||||||
|
showQuickJumper
|
||||||
|
show-less-items
|
||||||
|
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||||
|
:defaultPageSize="queryForm.pageSize"
|
||||||
|
v-model:current="queryForm.pageNum"
|
||||||
|
v-model:pageSize="queryForm.pageSize"
|
||||||
|
:total="total"
|
||||||
|
@change="queryJobList"
|
||||||
|
@showSizeChange="queryJobList"
|
||||||
|
:show-total="(total) => `共${total}条`"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 记录 -->
|
||||||
|
<JobLogListModal ref="jobLogModal" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
import { jobApi } from '/@/api/support/job-api';
|
||||||
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||||
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
|
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
||||||
|
import JobLogListModal from './job-log-list-modal.vue';
|
||||||
|
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const.js";
|
||||||
|
import TableOperator from "/@/components/support/table-operator/index.vue";
|
||||||
|
|
||||||
|
const columns = ref([
|
||||||
|
{
|
||||||
|
title: 'id',
|
||||||
|
width: 50,
|
||||||
|
dataIndex: 'jobId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '任务名称',
|
||||||
|
dataIndex: 'jobName',
|
||||||
|
minWidth: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '执行类',
|
||||||
|
dataIndex: 'jobClass',
|
||||||
|
minWidth: 180,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '触发类型',
|
||||||
|
dataIndex: 'triggerType',
|
||||||
|
width: 110,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '触发配置',
|
||||||
|
dataIndex: 'triggerValue',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '上次执行',
|
||||||
|
width: 180,
|
||||||
|
dataIndex: 'lastJob',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '下次执行',
|
||||||
|
width: 150,
|
||||||
|
dataIndex: 'nextJob',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '启用状态',
|
||||||
|
dataIndex: 'enabledFlag',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '执行参数',
|
||||||
|
dataIndex: 'param',
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '任务描述',
|
||||||
|
dataIndex: 'remark',
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序',
|
||||||
|
dataIndex: 'sort',
|
||||||
|
width: 65,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新人',
|
||||||
|
dataIndex: 'updateName',
|
||||||
|
width: 90,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
dataIndex: 'updateTime',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
dataIndex: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 70,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ---------------- 查询数据 -----------------------
|
||||||
|
|
||||||
|
const queryFormState = {
|
||||||
|
searchWord: '',
|
||||||
|
enabledFlag: null,
|
||||||
|
triggerType: null,
|
||||||
|
deletedFlag: true,
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
};
|
||||||
|
const queryForm = reactive({ ...queryFormState });
|
||||||
|
|
||||||
|
const tableLoading = ref(false);
|
||||||
|
const tableData = ref([]);
|
||||||
|
const total = ref(0);
|
||||||
|
|
||||||
|
function resetQuery() {
|
||||||
|
Object.assign(queryForm, queryFormState);
|
||||||
|
queryJobList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSearch() {
|
||||||
|
queryForm.pageNum = 1;
|
||||||
|
queryJobList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理执行类展示 默认返回类
|
||||||
|
function handleJobClass(jobClass) {
|
||||||
|
return jobClass.split('.').pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上次处理结果展示
|
||||||
|
function handleExecuteResult(result) {
|
||||||
|
let num = 400;
|
||||||
|
return result ? result.substring(0, num) + (result.length > num ? ' ...' : '') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function queryJobList() {
|
||||||
|
try {
|
||||||
|
tableLoading.value = true;
|
||||||
|
let responseModel = await jobApi.queryJob(queryForm);
|
||||||
|
const list = responseModel.data.list;
|
||||||
|
total.value = responseModel.data.total;
|
||||||
|
tableData.value = list;
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
} finally {
|
||||||
|
tableLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(queryJobList);
|
||||||
|
|
||||||
|
// 查询任务详情
|
||||||
|
async function queryJobInfo(jobId) {
|
||||||
|
try {
|
||||||
|
let res = await jobApi.queryJobInfo(jobId);
|
||||||
|
return res.data;
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------ 执行记录 -------------------------------------
|
||||||
|
const jobLogModal = ref();
|
||||||
|
function openJobLogModal(jobId, name) {
|
||||||
|
jobLogModal.value.show(jobId, name);
|
||||||
|
}
|
||||||
|
</script>
|
@ -6,47 +6,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- 编辑 -->
|
<!-- 编辑 -->
|
||||||
<a-modal :open="updateModalShow" :width="650" title="编辑" ok-text="确认" cancel-text="取消" @cancel="closeUpdateModal" @ok="confirmUpdateJob">
|
<a-modal :open="updateModalShow" :width="650" :title="isAdd ? '添加':'编辑'" ok-text="确认" cancel-text="取消" @cancel="closeUpdateModal" @ok="confirmUpdateJob">
|
||||||
<a-form ref="updateFormRef" :model="updateForm" :rules="updateRules" :label-col="{ span: 4 }">
|
<a-form ref="updateFormRef" :model="updateForm" :rules="updateRules" :label-col="{ span: 4 }">
|
||||||
<a-form-item label="任务名称" name="jobName">
|
<a-form-item label="任务名称" name="jobName">
|
||||||
<a-input placeholder="请输入任务名称" v-model:value="updateForm.jobName" :maxlength="100" :showCount="true" />
|
<a-input placeholder="请输入任务名称" v-model:value="updateForm.jobName" :maxlength="100" :showCount="true" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="任务描述" name="remark">
|
<a-form-item label="任务描述" name="remark">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 2, maxRows: 4 }"
|
:auto-size="{ minRows: 2, maxRows: 4 }"
|
||||||
v-model:value="updateForm.remark"
|
v-model:value="updateForm.remark"
|
||||||
placeholder="(可选)请输入任务备注描述"
|
placeholder="(可选)请输入任务备注描述"
|
||||||
:maxlength="250"
|
:maxlength="250"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="排序" name="sort">
|
<a-form-item label="排序" name="sort">
|
||||||
<a-input-number
|
<a-input-number
|
||||||
v-model:value="updateForm.sort"
|
v-model:value="updateForm.sort"
|
||||||
:min="-99999999"
|
:min="-99999999"
|
||||||
:max="99999999"
|
:max="99999999"
|
||||||
:precision="0"
|
:precision="0"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
placeholder="值越小越靠前"
|
placeholder="值越小越靠前"
|
||||||
>
|
>
|
||||||
</a-input-number>
|
</a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="执行类" name="jobClass">
|
<a-form-item label="执行类" name="jobClass">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 2, maxRows: 4 }"
|
:auto-size="{ minRows: 2, maxRows: 4 }"
|
||||||
v-model:value="updateForm.jobClass"
|
v-model:value="updateForm.jobClass"
|
||||||
placeholder="示例:net.lab1024.sa.base.module.support.job.sample.SmartJobSample1"
|
placeholder="示例:net.lab1024.sa.base.module.support.job.sample.SmartJobSample1"
|
||||||
:maxlength="200"
|
:maxlength="200"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="任务参数" name="param">
|
<a-form-item label="任务参数" name="param">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 3, maxRows: 6 }"
|
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||||||
v-model:value="updateForm.param"
|
v-model:value="updateForm.param"
|
||||||
placeholder="(可选)请输入任务执行参数"
|
placeholder="(可选)请输入任务执行参数"
|
||||||
:maxlength="1000"
|
:maxlength="1000"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="触发类型" name="triggerType">
|
<a-form-item label="触发类型" name="triggerType">
|
||||||
@ -57,19 +57,18 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="触发时间" name="triggerTime">
|
<a-form-item label="触发时间" name="triggerTime">
|
||||||
<a-input
|
<a-input
|
||||||
v-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.CRON.value"
|
v-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.CRON.value"
|
||||||
placeholder="示例:10 15 0/1 * * *"
|
placeholder="示例:10 15 0/1 * * *"
|
||||||
v-model:value="updateForm.cron"
|
v-model:value="updateForm.cron"
|
||||||
:maxlength="100"
|
:maxlength="100"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
<a-input-number
|
<a-input-number
|
||||||
v-else-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value"
|
v-else-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value"
|
||||||
v-model:value="updateForm.fixedDelay"
|
v-model:value="updateForm.fixedDelay"
|
||||||
:min="1"
|
:min="1"
|
||||||
:max="100000000"
|
:max="100000000"
|
||||||
:precision="0"
|
:precision="0"
|
||||||
:defaultValue="100"
|
|
||||||
>
|
>
|
||||||
<template #addonBefore>每隔</template>
|
<template #addonBefore>每隔</template>
|
||||||
<template #addonAfter>秒</template>
|
<template #addonAfter>秒</template>
|
||||||
@ -83,13 +82,13 @@
|
|||||||
|
|
||||||
<!-- 立即执行 -->
|
<!-- 立即执行 -->
|
||||||
<a-modal
|
<a-modal
|
||||||
:open="executeModalShow"
|
:open="executeModalShow"
|
||||||
:width="650"
|
:width="650"
|
||||||
title="执行任务"
|
title="执行任务"
|
||||||
ok-text="执行"
|
ok-text="执行"
|
||||||
cancel-text="取消"
|
cancel-text="取消"
|
||||||
@cancel="closeExecuteModal"
|
@cancel="closeExecuteModal"
|
||||||
@ok="confirmExecuteJob"
|
@ok="confirmExecuteJob"
|
||||||
>
|
>
|
||||||
<br />
|
<br />
|
||||||
<a-alert type="info" show-icon style="margin-left: 25px">
|
<a-alert type="info" show-icon style="margin-left: 25px">
|
||||||
@ -105,11 +104,11 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="任务参数" name="param">
|
<a-form-item label="任务参数" name="param">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
:auto-size="{ minRows: 3, maxRows: 6 }"
|
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||||||
v-model:value="executeForm.param"
|
v-model:value="executeForm.param"
|
||||||
placeholder="(可选)请输入任务执行参数"
|
placeholder="(可选)请输入任务执行参数"
|
||||||
:maxlength="1000"
|
:maxlength="1000"
|
||||||
:showCount="true"
|
:showCount="true"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
@ -117,42 +116,46 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { jobApi } from '/@/api/support/job-api';
|
import { jobApi } from '/@/api/support/job-api';
|
||||||
import { smartSentry } from '/@/lib/smart-sentry';
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
import { SmartLoading } from '/@/components/framework/smart-loading/index.js';
|
import { SmartLoading } from '/@/components/framework/smart-loading/index.js';
|
||||||
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
||||||
|
|
||||||
// emit
|
// emit
|
||||||
const emit = defineEmits(['reloadList']);
|
const emit = defineEmits(['reloadList']);
|
||||||
|
|
||||||
const updateModalShow = ref(false);
|
const isAdd = ref(false);
|
||||||
const updateFormRef = ref();
|
const updateModalShow = ref(false);
|
||||||
|
const updateFormRef = ref();
|
||||||
|
|
||||||
const updateFormDefault = {
|
const updateFormDefault = {
|
||||||
jobId: null,
|
jobId: null,
|
||||||
jobName: '',
|
jobName: '',
|
||||||
jobClass: '',
|
jobClass: '',
|
||||||
triggerType: null,
|
triggerType: TRIGGER_TYPE_ENUM.CRON.value,
|
||||||
triggerValue: null,
|
triggerValue: null,
|
||||||
cron: '',
|
cron: '',
|
||||||
fixedDelay: null,
|
fixedDelay: null,
|
||||||
param: '',
|
param: '',
|
||||||
enabledFlag: false,
|
enabledFlag: false,
|
||||||
remark: '',
|
remark: '',
|
||||||
sort: null,
|
sort: null,
|
||||||
};
|
};
|
||||||
let updateForm = reactive({ ...updateFormDefault });
|
let updateForm = reactive({ ...updateFormDefault });
|
||||||
const updateRules = {
|
const updateRules = {
|
||||||
jobName: [{ required: true, message: '请输入任务名称' }],
|
jobName: [{ required: true, message: '请输入任务名称' }],
|
||||||
jobClass: [{ required: true, message: '请输入执行类' }],
|
jobClass: [{ required: true, message: '请输入执行类' }],
|
||||||
triggerType: [{ required: true, message: '请选择触发类型' }],
|
triggerType: [{ required: true, message: '请选择触发类型' }],
|
||||||
sort: [{ required: true, message: '请输入排序' }],
|
sort: [{ required: true, message: '请输入排序' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开编辑弹框
|
// 打开编辑弹框
|
||||||
function openUpdateModal(record) {
|
function openUpdateModal(record) {
|
||||||
|
isAdd.value = null == record;
|
||||||
|
// 更新
|
||||||
|
if(!isAdd.value){
|
||||||
Object.assign(updateForm, record);
|
Object.assign(updateForm, record);
|
||||||
if (TRIGGER_TYPE_ENUM.CRON.value === record.triggerType) {
|
if (TRIGGER_TYPE_ENUM.CRON.value === record.triggerType) {
|
||||||
updateForm.cron = record.triggerValue;
|
updateForm.cron = record.triggerValue;
|
||||||
@ -160,30 +163,43 @@
|
|||||||
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === record.triggerType) {
|
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === record.triggerType) {
|
||||||
updateForm.fixedDelay = record.triggerValue;
|
updateForm.fixedDelay = record.triggerValue;
|
||||||
}
|
}
|
||||||
updateModalShow.value = true;
|
|
||||||
}
|
}
|
||||||
|
updateModalShow.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 关闭编辑弹框
|
// 关闭编辑弹框
|
||||||
function closeUpdateModal() {
|
function closeUpdateModal() {
|
||||||
Object.assign(updateForm, updateFormDefault);
|
Object.assign(updateForm, updateFormDefault);
|
||||||
updateModalShow.value = false;
|
updateModalShow.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确认更新
|
// 确认更新
|
||||||
async function confirmUpdateJob() {
|
async function confirmUpdateJob() {
|
||||||
updateFormRef.value
|
updateFormRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
SmartLoading.show();
|
|
||||||
if (TRIGGER_TYPE_ENUM.CRON.value === updateForm.triggerType) {
|
if (TRIGGER_TYPE_ENUM.CRON.value === updateForm.triggerType) {
|
||||||
updateForm.triggerValue = updateForm.cron;
|
updateForm.triggerValue = updateForm.cron;
|
||||||
}
|
}
|
||||||
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === updateForm.triggerType) {
|
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === updateForm.triggerType) {
|
||||||
updateForm.triggerValue = updateForm.fixedDelay;
|
updateForm.triggerValue = updateForm.fixedDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!updateForm.triggerValue){
|
||||||
|
message.error('请填写 触发时间');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await jobApi.updateJob(updateForm);
|
SmartLoading.show();
|
||||||
message.success('更新成功');
|
if(isAdd.value){
|
||||||
|
await jobApi.addJob(updateForm)
|
||||||
|
message.success('添加成功');
|
||||||
|
}else {
|
||||||
|
await jobApi.updateJob(updateForm);
|
||||||
|
message.success('更新成功');
|
||||||
|
}
|
||||||
closeUpdateModal();
|
closeUpdateModal();
|
||||||
emit('reloadList');
|
emit('reloadList');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -196,53 +212,53 @@
|
|||||||
console.log('error', error);
|
console.log('error', error);
|
||||||
message.error('参数验证错误,请检查表单数据');
|
message.error('参数验证错误,请检查表单数据');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------ 执行任务 -------------------------------------
|
||||||
|
const executeModalShow = ref(false);
|
||||||
|
const executeFormDefault = {
|
||||||
|
jobId: null,
|
||||||
|
jobName: '',
|
||||||
|
jobClass: '',
|
||||||
|
param: null,
|
||||||
|
};
|
||||||
|
let executeForm = reactive({ ...executeFormDefault });
|
||||||
|
|
||||||
|
// 打开执行弹框
|
||||||
|
function openExecuteModal(record) {
|
||||||
|
Object.assign(executeForm, record);
|
||||||
|
executeModalShow.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭执行弹框
|
||||||
|
function closeExecuteModal() {
|
||||||
|
Object.assign(executeForm, executeFormDefault);
|
||||||
|
executeModalShow.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认执行
|
||||||
|
async function confirmExecuteJob() {
|
||||||
|
try {
|
||||||
|
let executeParam = {
|
||||||
|
jobId: executeForm.jobId,
|
||||||
|
param: executeForm.param,
|
||||||
|
};
|
||||||
|
await jobApi.executeJob(executeParam);
|
||||||
|
// loading 延迟后再提示刷新
|
||||||
|
SmartLoading.show();
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
message.success('执行成功');
|
||||||
|
closeExecuteModal();
|
||||||
|
emit('reloadList');
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------ 执行任务 -------------------------------------
|
defineExpose({
|
||||||
const executeModalShow = ref(false);
|
openUpdateModal,
|
||||||
const executeFormDefault = {
|
openExecuteModal,
|
||||||
jobId: null,
|
});
|
||||||
jobName: '',
|
|
||||||
jobClass: '',
|
|
||||||
param: null,
|
|
||||||
};
|
|
||||||
let executeForm = reactive({ ...executeFormDefault });
|
|
||||||
|
|
||||||
// 打开执行弹框
|
|
||||||
function openExecuteModal(record) {
|
|
||||||
Object.assign(executeForm, record);
|
|
||||||
executeModalShow.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭执行弹框
|
|
||||||
function closeExecuteModal() {
|
|
||||||
Object.assign(executeForm, executeFormDefault);
|
|
||||||
executeModalShow.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 确认执行
|
|
||||||
async function confirmExecuteJob() {
|
|
||||||
try {
|
|
||||||
let executeParam = {
|
|
||||||
jobId: executeForm.jobId,
|
|
||||||
param: executeForm.param,
|
|
||||||
};
|
|
||||||
await jobApi.executeJob(executeParam);
|
|
||||||
// loading 延迟后再提示刷新
|
|
||||||
SmartLoading.show();
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
||||||
message.success('执行成功');
|
|
||||||
closeExecuteModal();
|
|
||||||
emit('reloadList');
|
|
||||||
} catch (e) {
|
|
||||||
smartSentry.captureError(e);
|
|
||||||
} finally {
|
|
||||||
SmartLoading.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
openUpdateModal,
|
|
||||||
openExecuteModal,
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,122 +5,143 @@
|
|||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<a-form class="smart-query-form">
|
|
||||||
<a-row class="smart-query-form-row">
|
|
||||||
<a-form-item label="关键字" class="smart-query-form-item">
|
|
||||||
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="触发类型" class="smart-query-form-item">
|
|
||||||
<a-select style="width: 155px" v-model:value="queryForm.triggerType" placeholder="请选择触发类型" allowClear>
|
|
||||||
<a-select-option v-for="item in $smartEnumPlugin.getValueDescList('TRIGGER_TYPE_ENUM')" :key="item.value" :value="item.value">
|
|
||||||
{{ item.desc }}
|
|
||||||
</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="状态" class="smart-query-form-item">
|
|
||||||
<a-select style="width: 150px" v-model:value="queryForm.enabledFlag" placeholder="请选择状态" allowClear>
|
|
||||||
<a-select-option :key="1"> 开启 </a-select-option>
|
|
||||||
<a-select-option :key="0"> 停止 </a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
|
|
||||||
<a-form-item class="smart-query-form-item smart-margin-left10">
|
|
||||||
<a-button-group>
|
|
||||||
<a-button type="primary" @click="onSearch" v-privilege="'support:job:query'">
|
|
||||||
<template #icon>
|
|
||||||
<ReloadOutlined />
|
|
||||||
</template>
|
|
||||||
查询
|
|
||||||
</a-button>
|
|
||||||
<a-button @click="resetQuery" v-privilege="'support:job:query'">
|
|
||||||
<template #icon>
|
|
||||||
<SearchOutlined />
|
|
||||||
</template>
|
|
||||||
重置
|
|
||||||
</a-button>
|
|
||||||
</a-button-group>
|
|
||||||
</a-form-item>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
|
|
||||||
<a-card size="small" :bordered="false" :hoverable="true">
|
<a-card size="small" :bordered="false" :hoverable="true">
|
||||||
<a-row justify="end">
|
<a-tabs v-model:activeKey="activeKey">
|
||||||
<TableOperator class="smart-margin-bottom5" v-model="columns" :tableId="TABLE_ID_CONST.SUPPORT.JOB" :refresh="queryJobList" />
|
<a-tab-pane key="1" tab="有效任务">
|
||||||
</a-row>
|
<a-form class="smart-query-form">
|
||||||
|
<a-row class="smart-query-form-row">
|
||||||
|
<a-form-item label="关键字" class="smart-query-form-item">
|
||||||
|
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="触发类型" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 155px" v-model:value="queryForm.triggerType" placeholder="请选择触发类型" allowClear>
|
||||||
|
<a-select-option v-for="item in $smartEnumPlugin.getValueDescList('TRIGGER_TYPE_ENUM')" :key="item.value" :value="item.value">
|
||||||
|
{{ item.desc }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="状态" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 150px" v-model:value="queryForm.enabledFlag" placeholder="请选择状态" allowClear>
|
||||||
|
<a-select-option :key="1"> 开启 </a-select-option>
|
||||||
|
<a-select-option :key="0"> 停止 </a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
<a-table
|
<a-form-item class="smart-query-form-item smart-margin-left10">
|
||||||
:scroll="{ x: 1800 }"
|
<a-button-group>
|
||||||
size="small"
|
<a-button type="primary" @click="onSearch" v-privilege="'support:job:query'">
|
||||||
:loading="tableLoading"
|
<template #icon>
|
||||||
bordered
|
<ReloadOutlined />
|
||||||
:dataSource="tableData"
|
</template>
|
||||||
:columns="columns"
|
查询
|
||||||
rowKey="jobId"
|
</a-button>
|
||||||
:pagination="false"
|
<a-button @click="resetQuery" v-privilege="'support:job:query'">
|
||||||
>
|
<template #icon>
|
||||||
<template #bodyCell="{ record, column }">
|
<SearchOutlined />
|
||||||
<template v-if="column.dataIndex === 'jobClass'">
|
</template>
|
||||||
<a-tooltip>
|
重置
|
||||||
<template #title>{{ record.jobClass }}</template>
|
</a-button>
|
||||||
{{ handleJobClass(record.jobClass) }}
|
</a-button-group>
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
<a-button class="smart-margin-left20" type="primary" @click="openUpdateModal()" v-privilege="'support:job:add'">
|
||||||
<template v-if="column.dataIndex === 'triggerType'">
|
<template #icon>
|
||||||
<a-tag v-if="record.triggerType === TRIGGER_TYPE_ENUM.CRON.value" color="success">{{ record.triggerTypeDesc }}</a-tag>
|
<plus-outlined />
|
||||||
<a-tag v-else-if="record.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value" color="processing">{{ record.triggerTypeDesc }}</a-tag>
|
</template>
|
||||||
<a-tag v-else color="pink">{{ record.triggerTypeDesc }}</a-tag>
|
添加任务
|
||||||
</template>
|
</a-button>
|
||||||
<template v-if="column.dataIndex === 'lastJob'">
|
</a-form-item>
|
||||||
<div v-if="record.lastJobLog">
|
</a-row>
|
||||||
<a-tooltip>
|
</a-form>
|
||||||
<template #title>{{ handleExecuteResult(record.lastJobLog.executeResult) }}</template>
|
<a-flex align="end" vertical>
|
||||||
<CheckOutlined v-if="record.lastJobLog.successFlag" style="color: #39c710" />
|
<div class="smart-table-setting-block smart-margin-bottom10">
|
||||||
<WarningOutlined v-else style="color: #f50" />
|
<TableOperator
|
||||||
{{ record.lastJobLog.executeStartTime }}
|
class="smart-margin-bottom5 pull-right"
|
||||||
</a-tooltip>
|
v-model="columns"
|
||||||
|
:tableId="TABLE_ID_CONST.SUPPORT.JOB"
|
||||||
|
:refresh="queryJobList"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</a-flex>
|
||||||
<template v-if="column.dataIndex === 'nextJob'">
|
|
||||||
<a-tooltip v-if="record.enabledFlag && record.nextJobExecuteTimeList">
|
<a-table
|
||||||
<template #title>
|
:scroll="{ x: 1800 }"
|
||||||
<div>下次执行(预估时间)</div>
|
size="small"
|
||||||
<div v-for="item in record.nextJobExecuteTimeList" :key="item">{{ item }}</div>
|
:loading="tableLoading"
|
||||||
|
bordered
|
||||||
|
:dataSource="tableData"
|
||||||
|
:columns="columns"
|
||||||
|
rowKey="jobId"
|
||||||
|
:pagination="false"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ record, column }">
|
||||||
|
<template v-if="column.dataIndex === 'jobClass'">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>{{ record.jobClass }}</template>
|
||||||
|
{{ handleJobClass(record.jobClass) }}
|
||||||
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
{{ record.nextJobExecuteTimeList[0] }}
|
<template v-if="column.dataIndex === 'triggerType'">
|
||||||
</a-tooltip>
|
<a-tag v-if="record.triggerType === TRIGGER_TYPE_ENUM.CRON.value" color="success">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
</template>
|
<a-tag v-else-if="record.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value" color="processing">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
<template v-if="column.dataIndex === 'enabledFlag'">
|
<a-tag v-else color="pink">{{ record.triggerTypeDesc }}</a-tag>
|
||||||
<a-switch
|
</template>
|
||||||
v-model:checked="record.enabledFlag"
|
<template v-if="column.dataIndex === 'lastJob'">
|
||||||
@change="(checked) => handleEnabledUpdate(checked, record)"
|
<div v-if="record.lastJobLog">
|
||||||
:loading="record.enabledLoading"
|
<a-tooltip>
|
||||||
|
<template #title>{{ handleExecuteResult(record.lastJobLog.executeResult) }}</template>
|
||||||
|
<CheckOutlined v-if="record.lastJobLog.successFlag" style="color: #39c710" />
|
||||||
|
<WarningOutlined v-else style="color: #f50" />
|
||||||
|
{{ record.lastJobLog.executeStartTime }}
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'nextJob'">
|
||||||
|
<a-tooltip v-if="record.enabledFlag && record.nextJobExecuteTimeList">
|
||||||
|
<template #title>
|
||||||
|
<div>下次执行(预估时间)</div>
|
||||||
|
<div v-for="item in record.nextJobExecuteTimeList" :key="item">{{ item }}</div>
|
||||||
|
</template>
|
||||||
|
{{ record.nextJobExecuteTimeList[0] }}
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'enabledFlag'">
|
||||||
|
<a-switch
|
||||||
|
v-model:checked="record.enabledFlag"
|
||||||
|
checked-children="已启用" un-checked-children="已禁用"
|
||||||
|
@change="(checked) => handleEnabledUpdate(checked, record)"
|
||||||
|
:loading="record.enabledLoading"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'action'">
|
||||||
|
<div class="smart-table-operate">
|
||||||
|
<a-button v-privilege="'support:job:update'" @click="openUpdateModal(record)" type="link">编辑</a-button>
|
||||||
|
<a-button v-privilege="'support:job:execute'" type="link" @click="openExecuteModal(record)">执行</a-button>
|
||||||
|
<a-button v-privilege="'support:job:log:query'" @click="openJobLogModal(record.jobId, record.jobName)" type="link">记录</a-button>
|
||||||
|
<a-button danger v-privilege="'support:job:log:delete'" @click="confirmDelete(record.jobId, record.jobName)" type="link">删除</a-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
<div class="smart-query-table-page">
|
||||||
|
<a-pagination
|
||||||
|
showSizeChanger
|
||||||
|
showQuickJumper
|
||||||
|
show-less-items
|
||||||
|
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||||
|
:defaultPageSize="queryForm.pageSize"
|
||||||
|
v-model:current="queryForm.pageNum"
|
||||||
|
v-model:pageSize="queryForm.pageSize"
|
||||||
|
:total="total"
|
||||||
|
@change="queryJobList"
|
||||||
|
@showSizeChange="queryJobList"
|
||||||
|
:show-total="(total) => `共${total}条`"
|
||||||
/>
|
/>
|
||||||
</template>
|
</div>
|
||||||
<template v-if="column.dataIndex === 'action'">
|
</a-tab-pane>
|
||||||
<div class="smart-table-operate">
|
<a-tab-pane key="2" tab="已删除任务"><DeletedJobList /></a-tab-pane>
|
||||||
<a-button v-privilege="'support:job:update'" @click="openUpdateModal(record)" type="link">编辑</a-button>
|
</a-tabs>
|
||||||
<a-button v-privilege="'support:job:execute'" type="link" @click="openExecuteModal(record)">执行</a-button>
|
|
||||||
<a-button v-privilege="'support:job:log:query'" @click="openJobLogModal(record.jobId, record.jobName)" type="link">记录</a-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</a-table>
|
|
||||||
|
|
||||||
<div class="smart-query-table-page">
|
|
||||||
<a-pagination
|
|
||||||
showSizeChanger
|
|
||||||
showQuickJumper
|
|
||||||
show-less-items
|
|
||||||
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
|
||||||
:defaultPageSize="queryForm.pageSize"
|
|
||||||
v-model:current="queryForm.pageNum"
|
|
||||||
v-model:pageSize="queryForm.pageSize"
|
|
||||||
:total="total"
|
|
||||||
@change="queryJobList"
|
|
||||||
@showSizeChange="queryJobList"
|
|
||||||
:show-total="(total) => `共${total}条`"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</a-card>
|
</a-card>
|
||||||
|
|
||||||
<!-- 表单操作 -->
|
<!-- 表单操作 -->
|
||||||
@ -131,17 +152,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { message } from 'ant-design-vue';
|
import {message, Modal} from 'ant-design-vue';
|
||||||
import { onMounted, reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import { jobApi } from '/@/api/support/job-api';
|
import { jobApi } from '/@/api/support/job-api';
|
||||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||||
import { smartSentry } from '/@/lib/smart-sentry';
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
import TableOperator from '/@/components/support/table-operator/index.vue';
|
||||||
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
|
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
|
||||||
import { useRouter } from 'vue-router';
|
import DeletedJobList from './components/deleted-job-list.vue';
|
||||||
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
|
||||||
import JobFormModal from './components/job-form-modal.vue';
|
import JobFormModal from './components/job-form-modal.vue';
|
||||||
import JobLogListModal from './components/job-log-list-modal.vue';
|
import JobLogListModal from './components/job-log-list-modal.vue';
|
||||||
|
import {SmartLoading} from "/@/components/framework/smart-loading/index.js";
|
||||||
|
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{
|
{
|
||||||
@ -182,9 +204,9 @@
|
|||||||
dataIndex: 'nextJob',
|
dataIndex: 'nextJob',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '启用状态',
|
||||||
dataIndex: 'enabledFlag',
|
dataIndex: 'enabledFlag',
|
||||||
width: 80,
|
width: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '执行参数',
|
title: '执行参数',
|
||||||
@ -215,7 +237,7 @@
|
|||||||
title: '操作',
|
title: '操作',
|
||||||
dataIndex: 'action',
|
dataIndex: 'action',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 130,
|
width: 170,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -225,6 +247,7 @@
|
|||||||
searchWord: '',
|
searchWord: '',
|
||||||
enabledFlag: null,
|
enabledFlag: null,
|
||||||
triggerType: null,
|
triggerType: null,
|
||||||
|
deletedFlag: false,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
};
|
};
|
||||||
@ -249,7 +272,7 @@
|
|||||||
return jobClass.split('.').pop();
|
return jobClass.split('.').pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上次处理结果展示 最多展示300
|
// 上次处理结果展示
|
||||||
function handleExecuteResult(result) {
|
function handleExecuteResult(result) {
|
||||||
let num = 400;
|
let num = 400;
|
||||||
return result ? result.substring(0, num) + (result.length > num ? ' ...' : '') : '';
|
return result ? result.substring(0, num) + (result.length > num ? ' ...' : '') : '';
|
||||||
@ -308,6 +331,35 @@
|
|||||||
jobLogModal.value.show(jobId, name);
|
jobLogModal.value.show(jobId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------ 删除操作 -------------------------------------
|
||||||
|
|
||||||
|
function confirmDelete(jobId, jobName){
|
||||||
|
Modal.confirm({
|
||||||
|
title: '警告',
|
||||||
|
content: `确定要删除【${jobName}】任务吗?`,
|
||||||
|
okText: '删除',
|
||||||
|
okType: 'danger',
|
||||||
|
onOk() {
|
||||||
|
deleteJob(jobId);
|
||||||
|
},
|
||||||
|
cancelText: '取消',
|
||||||
|
onCancel() {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteJob(jobId){
|
||||||
|
try{
|
||||||
|
SmartLoading.show();
|
||||||
|
await jobApi.deleteJob(jobId);
|
||||||
|
message.success('删除成功!');
|
||||||
|
queryJobList();
|
||||||
|
}catch (e){
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
}finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------ 表单操作 -------------------------------------
|
// ------------------------------------ 表单操作 -------------------------------------
|
||||||
const jobFormModal = ref();
|
const jobFormModal = ref();
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@
|
|||||||
<a-form-item v-if="form.menuType === MENU_TYPE_ENUM.MENU.value" label="是否外链" name="frameFlag">
|
<a-form-item v-if="form.menuType === MENU_TYPE_ENUM.MENU.value" label="是否外链" name="frameFlag">
|
||||||
<a-switch v-model:checked="form.frameFlag" checked-children="是外链" un-checked-children="不是外链" />
|
<a-switch v-model:checked="form.frameFlag" checked-children="是外链" un-checked-children="不是外链" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="显示状态" name="frameFlag">
|
<a-form-item label="显示状态" name="visibleFlag">
|
||||||
<a-switch v-model:checked="form.visibleFlag" checked-children="显示" un-checked-children="不显示" />
|
<a-switch v-model:checked="form.visibleFlag" checked-children="显示" un-checked-children="不显示" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="禁用状态" name="frameFlag">
|
<a-form-item label="禁用状态" name="disabledFlag">
|
||||||
<a-switch v-model:checked="form.disabledFlag" :checkedValue="false" :unCheckedValue="true" checked-children="启用" un-checked-children="禁用" />
|
<a-switch v-model:checked="form.disabledFlag" :checkedValue="false" :unCheckedValue="true" checked-children="启用" un-checked-children="禁用" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</template>
|
</template>
|
||||||
@ -73,7 +73,7 @@
|
|||||||
<a-form-item label="功能点关联菜单">
|
<a-form-item label="功能点关联菜单">
|
||||||
<MenuTreeSelect ref="contextMenuTreeSelect" v-model:value="form.contextMenuId" />
|
<MenuTreeSelect ref="contextMenuTreeSelect" v-model:value="form.contextMenuId" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="功能点状态" name="frameFlag">
|
<a-form-item label="功能点状态" name="funcDisabledFlag">
|
||||||
<a-switch v-model:checked="form.disabledFlag" :checkedValue="false" :unCheckedValue="true" checked-children="启用" un-checked-children="禁用" />
|
<a-switch v-model:checked="form.disabledFlag" :checkedValue="false" :unCheckedValue="true" checked-children="启用" un-checked-children="禁用" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="权限类型" name="permsType">
|
<a-form-item label="权限类型" name="permsType">
|
||||||
|
@ -1209,12 +1209,13 @@ CREATE TABLE `t_serial_number_record` (
|
|||||||
INDEX `uk_generator`(`serial_number_id`, `record_date`) USING BTREE
|
INDEX `uk_generator`(`serial_number_id`, `record_date`) USING BTREE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'serial_number记录表' ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'serial_number记录表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for t_smart_job
|
-- Table structure for t_smart_job
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `t_smart_job`;
|
DROP TABLE IF EXISTS `t_smart_job`;
|
||||||
CREATE TABLE `t_smart_job` (
|
CREATE TABLE `t_smart_job` (
|
||||||
`job_id` int(0) NOT NULL COMMENT '任务id',
|
`job_id` int(0) NOT NULL AUTO_INCREMENT COMMENT '任务id',
|
||||||
`job_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务名称',
|
`job_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务名称',
|
||||||
`job_class` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务执行类',
|
`job_class` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务执行类',
|
||||||
`trigger_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发类型',
|
`trigger_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发类型',
|
||||||
@ -1224,19 +1225,20 @@ CREATE TABLE `t_smart_job` (
|
|||||||
`last_execute_time` datetime(0) NULL DEFAULT NULL COMMENT '最后一次执行时间',
|
`last_execute_time` datetime(0) NULL DEFAULT NULL COMMENT '最后一次执行时间',
|
||||||
`last_execute_log_id` int(0) NULL DEFAULT NULL COMMENT '最后一次执行记录id',
|
`last_execute_log_id` int(0) NULL DEFAULT NULL COMMENT '最后一次执行记录id',
|
||||||
`sort` int(0) NOT NULL DEFAULT 0 COMMENT '排序',
|
`sort` int(0) NOT NULL DEFAULT 0 COMMENT '排序',
|
||||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
|
||||||
|
`deleted_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除状态',
|
||||||
`update_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人',
|
`update_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人',
|
||||||
`update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0),
|
|
||||||
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (`job_id`) USING BTREE,
|
`update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0),
|
||||||
UNIQUE INDEX `uk_job_class`(`job_class`) USING BTREE
|
PRIMARY KEY (`job_id`) USING BTREE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '定时任务配置 @listen' ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '定时任务配置 @listen' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of t_smart_job
|
-- Records of t_smart_job
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `t_smart_job` VALUES (1, '示例任务1', 'net.lab1024.sa.base.module.support.job.sample.SmartJobSample1', 'cron', '10 15 0/1 * * *', 1, '1', '2024-09-03 21:15:10', 7928, 1, '测试测试', '管理员', '2024-09-03 21:15:12', '2024-06-17 20:00:46');
|
INSERT INTO `t_smart_job` VALUES (1, '示例任务1', 'net.lab1024.sa.base.module.support.job.sample.SmartJobSample1', 'cron', '10 15 0/1 * * *', 1, '1', '2025-01-05 19:15:10', 7988, 1, '测试测试', 0, '管理员', '2024-06-17 20:00:46', '2025-01-08 20:07:51');
|
||||||
INSERT INTO `t_smart_job` VALUES (2, '示例任务2', 'net.lab1024.sa.base.module.support.job.sample.SmartJobSample2', 'fixed_delay', '120', 1, '一路春光啊一路荆棘呀惊鸿一般短暂如夏花一样绚烂这是一个不能停留太久的世界,一路春光啊一路荆棘呀惊鸿一般短暂如夏花一样绚烂这是一个不能停留太久的世界啊', '2024-09-03 21:51:24', 7944, 2, '一个不能停留太久的世界啊', '胡克', '2024-09-03 21:51:26', '2024-06-18 20:45:35');
|
INSERT INTO `t_smart_job` VALUES (2, '示例任务2', 'net.lab1024.sa.base.module.support.job.sample.SmartJobSample2', 'fixed_delay', '120', 1, '一路春光啊一路荆棘呀惊鸿一般短暂如夏花一样绚烂这是一个不能停留太久的世界,一路春光啊一路荆棘呀惊鸿一般短暂如夏花一样绚烂这是一个不能停留太久的世界啊', '2025-01-08 19:56:59', 8144, 2, '一个不能停留太久的世界啊', 0, '管理员', '2024-06-18 20:45:35', '2025-01-08 19:57:00');
|
||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for t_smart_job_log
|
-- Table structure for t_smart_job_log
|
||||||
|
Loading…
Reference in New Issue
Block a user