2
0

feat: job module support i18n message

This commit is contained in:
zhangsz
2025-01-22 09:52:06 +08:00
parent eb2c409100
commit 96bd946635
10 changed files with 166 additions and 14 deletions

View File

@@ -18,6 +18,6 @@ public class WfcJobApplication
public static void main(String[] args)
{
SpringApplication.run(WfcJobApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n");
System.out.println("(♥◠‿◠)ノ゙ The scheduled task module started successfully ლ(´ڡ`ლ)゙ \n");
}
}

View File

@@ -9,10 +9,12 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import org.wfc.common.core.annotation.Excel;
import org.wfc.common.core.annotation.Excel.ColumnType;
import org.wfc.common.core.constant.ScheduleConstants;
import org.wfc.common.core.utils.MessageUtils;
import org.wfc.common.core.utils.StringUtils;
import org.wfc.common.core.web.domain.BaseEntity;
import org.wfc.job.util.CronUtils;
/**
* 定时任务调度表 sys_job
*
@@ -64,8 +66,8 @@ public class SysJob extends BaseEntity
this.jobId = jobId;
}
@NotBlank(message = "任务名称不能为空")
@Size(min = 0, max = 64, message = "任务名称不能超过64个字符")
@NotBlank(message = "{job.name.not.blank}")
@Size(min = 0, max = 64, message = "{job.name.length.valid}")
public String getJobName()
{
return jobName;
@@ -86,8 +88,8 @@ public class SysJob extends BaseEntity
this.jobGroup = jobGroup;
}
@NotBlank(message = "调用目标字符串不能为空")
@Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符")
@NotBlank(message = "{job.target.not.blank}")
@Size(min = 0, max = 500, message = "{job.target.length.valid}")
public String getInvokeTarget()
{
return invokeTarget;
@@ -98,8 +100,8 @@ public class SysJob extends BaseEntity
this.invokeTarget = invokeTarget;
}
@NotBlank(message = "Cron执行表达式不能为空")
@Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符")
@NotBlank(message = "{job.cron.not.blank}")
@Size(min = 0, max = 255, message = "{job.cron.length.valid}")
public String getCronExpression()
{
return cronExpression;

View File

@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.utils.MessageUtils;
import org.wfc.system.api.RemoteUserService;
import org.wfc.user.api.RemoteUUserService;
@@ -27,7 +28,7 @@ public class OmadaTask {
remoteUserService.deviceJob();
remoteUUserService.addCdrInfoByOmadaApi();
long endTime = System.currentTimeMillis();
log.info("wifi定时任务执行成功, 耗时:{} 毫秒", endTime - startTime);
log.info(MessageUtils.message("job.execute.success", endTime - startTime));
}
public R<String> testOmadaApi() {

View File

@@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wfc.common.core.constant.ScheduleConstants;
import org.wfc.common.core.utils.ExceptionUtil;
import org.wfc.common.core.utils.MessageUtils;
import org.wfc.common.core.utils.SpringUtils;
import org.wfc.common.core.utils.StringUtils;
import org.wfc.common.core.utils.bean.BeanUtils;
@@ -79,7 +80,7 @@ public abstract class AbstractQuartzJob implements Job
sysJobLog.setStartTime(startTime);
sysJobLog.setStopTime(new Date());
long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
sysJobLog.setJobMessage(sysJobLog.getJobName() + " " + MessageUtils.message("job.execute.spend.time", runMs));
if (e != null)
{
sysJobLog.setStatus("1");