Commit 135c8c96 by 吕明尚

Merge branch 'dev' into test

parents 32bd89b9 4f516337
...@@ -9,89 +9,89 @@ import share.common.core.domain.AjaxResult; ...@@ -9,89 +9,89 @@ import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType; import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil; import share.common.utils.poi.ExcelUtil;
import share.system.domain.SysJobLog; import share.system.domain.JobErrorLog;
import share.system.service.SysJobLogService; import share.system.service.JobErrorLogService;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
* 定时任务日志Controller * 定时任务异常日志Controller
* *
* @author wuwenlong * @author wuwenlong
* @date 2024-11-15 * @date 2024-11-18
*/ */
@RestController @RestController
@RequestMapping("/system/sysJobLog") @RequestMapping("/system/jobErrorLog")
public class SysJobLogController extends BaseController { public class JobErrorLogController extends BaseController {
@Autowired @Autowired
private SysJobLogService sysJobLogService; private JobErrorLogService jobErrorLogService;
/** /**
* 查询定时任务日志列表 * 查询定时任务异常日志列表
*/ */
@PreAuthorize("@ss.hasPermi('system:sysJobLog:list')") @PreAuthorize("@ss.hasPermi('system:jobErrorLog:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysJobLog sysJobLog) { public TableDataInfo list(JobErrorLog jobErrorLog) {
startPage(); startPage();
List<SysJobLog> list = sysJobLogService.selectSysJobLogList(sysJobLog); List<JobErrorLog> list = jobErrorLogService.selectJobErrorLogList(jobErrorLog);
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 导出定时任务日志列表 * 导出定时任务异常日志列表
*/ */
@PreAuthorize("@ss.hasPermi('system:sysJobLog:export')") @PreAuthorize("@ss.hasPermi('system:jobErrorLog:export')")
@Log(title = "定时任务日志", businessType = BusinessType.EXPORT) @Log(title = "定时任务异常日志", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, SysJobLog sysJobLog) { public void export(HttpServletResponse response, JobErrorLog jobErrorLog) {
List<SysJobLog> list = sysJobLogService.selectSysJobLogList(sysJobLog); List<JobErrorLog> list = jobErrorLogService.selectJobErrorLogList(jobErrorLog);
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class); ExcelUtil<JobErrorLog> util = new ExcelUtil<JobErrorLog>(JobErrorLog.class);
util.exportExcel(response, list, "定时任务日志数据"); util.exportExcel(response, list, "定时任务异常日志数据");
} }
/** /**
* 获取定时任务日志详细信息 * 获取定时任务异常日志详细信息
*/ */
@PreAuthorize("@ss.hasPermi('system:sysJobLog:query')") @PreAuthorize("@ss.hasPermi('system:jobErrorLog:query')")
@GetMapping(value = "/{jobLogId}") @GetMapping(value = "/{jobLogId}")
public AjaxResult getInfo(@PathVariable("jobLogId") Long jobLogId) { public AjaxResult getInfo(@PathVariable("jobLogId") Long jobLogId) {
return success(sysJobLogService.selectSysJobLogByJobLogId(jobLogId)); return success(jobErrorLogService.selectJobErrorLogByJobLogId(jobLogId));
} }
/** /**
* 新增定时任务日志 * 新增定时任务异常日志
*/ */
@PreAuthorize("@ss.hasPermi('system:sysJobLog:add')") @PreAuthorize("@ss.hasPermi('system:jobErrorLog:add')")
@Log(title = "定时任务日志", businessType = BusinessType.INSERT) @Log(title = "定时任务异常日志", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody SysJobLog sysJobLog) { public AjaxResult add(@RequestBody JobErrorLog jobErrorLog) {
return toAjax(sysJobLogService.insertSysJobLog(sysJobLog)); return toAjax(jobErrorLogService.insertJobErrorLog(jobErrorLog));
} }
/** /**
* 修改定时任务日志 * 修改定时任务异常日志
*/ */
@PreAuthorize("@ss.hasPermi('system:sysJobLog:edit')") @PreAuthorize("@ss.hasPermi('system:jobErrorLog:edit')")
@Log(title = "定时任务日志", businessType = BusinessType.UPDATE) @Log(title = "定时任务异常日志", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody SysJobLog sysJobLog) { public AjaxResult edit(@RequestBody JobErrorLog jobErrorLog) {
return toAjax(sysJobLogService.updateSysJobLog(sysJobLog)); return toAjax(jobErrorLogService.updateJobErrorLog(jobErrorLog));
} }
/** /**
* 删除定时任务日志 * 删除定时任务异常日志
*/ */
@PreAuthorize("@ss.hasPermi('system:sysJobLog:remove')") @PreAuthorize("@ss.hasPermi('system:jobErrorLog:remove')")
@Log(title = "定时任务日志", businessType = BusinessType.DELETE) @Log(title = "定时任务异常日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{jobLogIds}") @DeleteMapping("/{jobLogIds}")
public AjaxResult remove(@PathVariable Long[] jobLogIds) { public AjaxResult remove(@PathVariable Long[] jobLogIds) {
return toAjax(sysJobLogService.deleteSysJobLogByJobLogIds(jobLogIds)); return toAjax(jobErrorLogService.deleteJobErrorLogByJobLogIds(jobLogIds));
} }
@DeleteMapping("/clean") @DeleteMapping("/clean")
public AjaxResult clean() { public AjaxResult clean() {
sysJobLogService.cleanJobLog(); jobErrorLogService.cleanJobLog();
return success(); return success();
} }
} }
...@@ -122,7 +122,7 @@ public class RedisTask { ...@@ -122,7 +122,7 @@ public class RedisTask {
private ConsumerSecondaryCardService consumerSecondaryCardService; private ConsumerSecondaryCardService consumerSecondaryCardService;
@Autowired @Autowired
private SysJobLogService sysJobLogService; private JobErrorLogService jobErrorLogService;
//15分钟的常量 //15分钟的常量
...@@ -380,27 +380,20 @@ public class RedisTask { ...@@ -380,27 +380,20 @@ public class RedisTask {
redisUtil.set(ReceiptRdeisEnum.ROOM_EXPIRE_TIME.getValue() + sOrder.getOrderNo(), json.toString()); redisUtil.set(ReceiptRdeisEnum.ROOM_EXPIRE_TIME.getValue() + sOrder.getOrderNo(), json.toString());
logger.debug("订单号为:" + sOrder.getOrderNo() + "的订单已结束,更改订单状态为已使用"); logger.debug("订单号为:" + sOrder.getOrderNo() + "的订单已结束,更改订单状态为已使用");
} }
SysJobLog sysJobLog = new SysJobLog();
sysJobLog.setJobName("AutoAddSCleanRecords:自动添加保洁记录");
sysJobLog.setJobGroup("RedisTask");
sysJobLog.setInvokeTarget("AutoAddSCleanRecords");
sysJobLog.setJobMessage("自动添加保洁记录:" + jsonObject.toString());
sysJobLog.setStatus(YesNoEnum.no.getIndex().toString());
sysJobLogService.save(sysJobLog);
} catch (BaseException e) { } catch (BaseException e) {
String value = redisUtil.get(String.valueOf(o)); String value = redisUtil.get(String.valueOf(o));
JSONObject jsonObject = new JSONObject(value); JSONObject jsonObject = new JSONObject(value);
logger.error("订单号:" + jsonObject.getStr("orderNo") + "异常," logger.error("订单号:" + jsonObject.getStr("orderNo") + "异常,"
+ "异常为:" + e.getMessage() + "异常为:" + e.getMessage()
); );
SysJobLog sysJobLog = new SysJobLog(); JobErrorLog jobErrorLog = new JobErrorLog();
sysJobLog.setJobName("AutoAddSCleanRecords:自动添加保洁记录"); jobErrorLog.setJobName("自动添加保洁记录");
sysJobLog.setJobGroup("RedisTask"); jobErrorLog.setJobGroup("RedisTask");
sysJobLog.setInvokeTarget("AutoAddSCleanRecords"); jobErrorLog.setInvokeTarget("RedisTask.AutoAddSCleanRecords");
sysJobLog.setJobMessage("自动添加保洁记录:" + jsonObject.toString()); jobErrorLog.setJobMessage("自动添加保洁记录:" + jsonObject.toString());
sysJobLog.setStatus(YesNoEnum.yes.getIndex().toString()); jobErrorLog.setStatus(YesNoEnum.yes.getIndex().toString());
sysJobLog.setExceptionInfo(e.getMessage()); jobErrorLog.setExceptionInfo(e.getMessage());
sysJobLogService.save(sysJobLog); jobErrorLogService.save(jobErrorLog);
continue; continue;
} }
} }
...@@ -550,7 +543,8 @@ public class RedisTask { ...@@ -550,7 +543,8 @@ public class RedisTask {
if (keys.size() == 0) { if (keys.size() == 0) {
return; return;
} }
keys.stream().forEach(key -> { for (String key : keys) {
try {
String value = redisUtil.get(String.valueOf(key)); String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value); JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime"); Date expirationTime = jsonObject.getDate("expirationTime");
...@@ -562,9 +556,23 @@ public class RedisTask { ...@@ -562,9 +556,23 @@ public class RedisTask {
SConsumer sConsumer = sConsumerService.getById(consumerId); SConsumer sConsumer = sConsumerService.getById(consumerId);
logger.debug("手机号为:{}的用户年度权益会员将在3天后失效", sConsumer.getPhone()); logger.debug("手机号为:{}的用户年度权益会员将在3天后失效", sConsumer.getPhone());
smsService.sendOneSms(sConsumer.getPhone(), "年度权益会员将在3天后失效,请及时续约保障权益会员的权益"); smsService.sendOneSms(sConsumer.getPhone(), "年度权益会员将在3天后失效,请及时续约保障权益会员的权益");
// redisUtil.delete(key); // redisUtil.delete(key);
} }
}); } catch (Exception e) {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
JobErrorLog jobErrorLog = new JobErrorLog();
jobErrorLog.setJobName("自动发送权益会员过期短信");
jobErrorLog.setJobGroup("RedisTask");
jobErrorLog.setInvokeTarget("RedisTask.AutoEquityMembersSms");
jobErrorLog.setJobMessage("自动发送权益会员过期短信:" + jsonObject.toString());
jobErrorLog.setStatus(YesNoEnum.yes.getIndex().toString());
jobErrorLog.setExceptionInfo(e.getMessage());
jobErrorLogService.save(jobErrorLog);
continue;
}
}
logger.debug("AutoEquityMembersSms:自动发送权益会员过期短信结束"); logger.debug("AutoEquityMembersSms:自动发送权益会员过期短信结束");
} }
...@@ -576,7 +584,8 @@ public class RedisTask { ...@@ -576,7 +584,8 @@ public class RedisTask {
if (keys.size() == 0) { if (keys.size() == 0) {
return; return;
} }
keys.stream().forEach(key -> { for (String key : keys) {
try {
String value = redisUtil.get(String.valueOf(key)); String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value); JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime"); Date expirationTime = jsonObject.getDate("expirationTime");
...@@ -591,7 +600,20 @@ public class RedisTask { ...@@ -591,7 +600,20 @@ public class RedisTask {
} }
redisUtil.delete(key); redisUtil.delete(key);
} }
}); } catch (Exception e) {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
JobErrorLog jobErrorLog = new JobErrorLog();
jobErrorLog.setJobName("权益会员降级");
jobErrorLog.setJobGroup("RedisTask");
jobErrorLog.setInvokeTarget("RedisTask.AutoUpdateEquityMembers");
jobErrorLog.setJobMessage("权益会员降级:" + jsonObject.toString());
jobErrorLog.setStatus(YesNoEnum.yes.getIndex().toString());
jobErrorLog.setExceptionInfo(e.getMessage());
jobErrorLogService.save(jobErrorLog);
continue;
}
}
logger.debug("AutoUpdateEquityMembers:权益会员降级结束"); logger.debug("AutoUpdateEquityMembers:权益会员降级结束");
} }
...@@ -823,7 +845,8 @@ public class RedisTask { ...@@ -823,7 +845,8 @@ public class RedisTask {
logger.debug("AutomaticallyMonthlyCard:自动结束月卡开始"); logger.debug("AutomaticallyMonthlyCard:自动结束月卡开始");
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.MONTHLY_CARD.getValue() + "*"); Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.MONTHLY_CARD.getValue() + "*");
if (keys.size() == 0) return; if (keys.size() == 0) return;
keys.stream().forEach(key -> { for (String key : keys) {
try {
String value = redisUtil.get(String.valueOf(key)); String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value); JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime"); Date expirationTime = jsonObject.getDate("expirationTime");
...@@ -832,7 +855,20 @@ public class RedisTask { ...@@ -832,7 +855,20 @@ public class RedisTask {
consumerMonthlyCardService.removeById(consumerMonthlyCardId); consumerMonthlyCardService.removeById(consumerMonthlyCardId);
redisUtil.delete(key); redisUtil.delete(key);
} }
}); } catch (Exception e) {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
JobErrorLog jobErrorLog = new JobErrorLog();
jobErrorLog.setJobName("自动结束月卡");
jobErrorLog.setJobGroup("RedisTask");
jobErrorLog.setInvokeTarget("RedisTask.AutomaticallyMonthlyCard");
jobErrorLog.setJobMessage("自动结束月卡:" + jsonObject.toString());
jobErrorLog.setStatus(YesNoEnum.yes.getIndex().toString());
jobErrorLog.setExceptionInfo(e.getMessage());
jobErrorLogService.save(jobErrorLog);
continue;
}
}
logger.debug("AutomaticallyMonthlyCard:自动结束月卡结束"); logger.debug("AutomaticallyMonthlyCard:自动结束月卡结束");
} }
...@@ -845,7 +881,8 @@ public class RedisTask { ...@@ -845,7 +881,8 @@ public class RedisTask {
if (keys.size() == 0) return; if (keys.size() == 0) return;
List<ConsumerMonthlyCard> consumerMonthlyCards = new ArrayList<>(); List<ConsumerMonthlyCard> consumerMonthlyCards = new ArrayList<>();
String monthlyCardTime = sysConfigService.selectConfigByKey("monthlyCardTime"); String monthlyCardTime = sysConfigService.selectConfigByKey("monthlyCardTime");
keys.stream().forEach(key -> { for (String key : keys) {
try {
String value = redisUtil.get(String.valueOf(key)); String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value); JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime"); Date expirationTime = jsonObject.getDate("expirationTime");
...@@ -856,7 +893,20 @@ public class RedisTask { ...@@ -856,7 +893,20 @@ public class RedisTask {
consumerMonthlyCard.setId(consumerMonthlyCardId); consumerMonthlyCard.setId(consumerMonthlyCardId);
consumerMonthlyCards.add(consumerMonthlyCard); consumerMonthlyCards.add(consumerMonthlyCard);
} }
}); } catch (Exception e) {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
JobErrorLog jobErrorLog = new JobErrorLog();
jobErrorLog.setJobName("自动增加月卡时长");
jobErrorLog.setJobGroup("RedisTask");
jobErrorLog.setInvokeTarget("RedisTask.AutoMonthlyCardTime");
jobErrorLog.setJobMessage("自动增加月卡时长:" + jsonObject.toString());
jobErrorLog.setStatus(YesNoEnum.yes.getIndex().toString());
jobErrorLog.setExceptionInfo(e.getMessage());
jobErrorLogService.save(jobErrorLog);
continue;
}
}
if (!CollectionUtils.isEmpty(consumerMonthlyCards)) if (!CollectionUtils.isEmpty(consumerMonthlyCards))
consumerMonthlyCardService.updateBatchById(consumerMonthlyCards); consumerMonthlyCardService.updateBatchById(consumerMonthlyCards);
logger.debug("AutoMonthlyCardTime:自动增加月卡时长结束"); logger.debug("AutoMonthlyCardTime:自动增加月卡时长结束");
...@@ -867,7 +917,8 @@ public class RedisTask { ...@@ -867,7 +917,8 @@ public class RedisTask {
logger.debug("AutomaticallySecondaryCard:自动结束次卡开始"); logger.debug("AutomaticallySecondaryCard:自动结束次卡开始");
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.SECONDARY_CARD.getValue() + "*"); Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.SECONDARY_CARD.getValue() + "*");
if (keys.size() == 0) return; if (keys.size() == 0) return;
keys.stream().forEach(key -> { for (String key : keys) {
try {
String value = redisUtil.get(String.valueOf(key)); String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value); JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime"); Date expirationTime = jsonObject.getDate("expirationTime");
...@@ -876,8 +927,20 @@ public class RedisTask { ...@@ -876,8 +927,20 @@ public class RedisTask {
consumerSecondaryCardService.removeById(consumerSecondaryCardId); consumerSecondaryCardService.removeById(consumerSecondaryCardId);
redisUtil.delete(key); redisUtil.delete(key);
} }
}); } catch (Exception e) {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
JobErrorLog jobErrorLog = new JobErrorLog();
jobErrorLog.setJobName("自动结束次卡");
jobErrorLog.setJobGroup("RedisTask");
jobErrorLog.setInvokeTarget("RedisTask.AutomaticallySecondaryCard");
jobErrorLog.setJobMessage("自动结束次卡:" + jsonObject.toString());
jobErrorLog.setStatus(YesNoEnum.yes.getIndex().toString());
jobErrorLog.setExceptionInfo(e.getMessage());
jobErrorLogService.save(jobErrorLog);
continue;
}
}
logger.debug("AutomaticallySecondaryCard:自动结束次卡结束"); logger.debug("AutomaticallySecondaryCard:自动结束次卡结束");
} }
......
...@@ -10,14 +10,14 @@ import share.common.annotation.Excel; ...@@ -10,14 +10,14 @@ import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity; import share.common.core.domain.BaseEntity;
/** /**
* 定时任务日志对象 sys_job_log * 定时任务异常日志对象 s_job_error_log
* *
* @author wuwenlong * @author wuwenlong
* @date 2024-11-15 * @date 2024-11-18
*/ */
@Data @Data
@TableName("sys_job_log") @TableName(value = "s_job_error_log")
public class SysJobLog extends BaseEntity { public class JobErrorLog extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
...@@ -73,7 +73,11 @@ public class SysJobLog extends BaseEntity { ...@@ -73,7 +73,11 @@ public class SysJobLog extends BaseEntity {
.append("jobMessage", getJobMessage()) .append("jobMessage", getJobMessage())
.append("status", getStatus()) .append("status", getStatus())
.append("exceptionInfo", getExceptionInfo()) .append("exceptionInfo", getExceptionInfo())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString(); .toString();
} }
} }
package share.system.mapper; package share.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SysJobLog; import share.system.domain.JobErrorLog;
import java.util.List; import java.util.List;
/** /**
* 定时任务日志Mapper接口 * 定时任务异常日志Mapper接口
* *
* @author wuwenlong * @author wuwenlong
* @date 2024-11-15 * @date 2024-11-18
*/ */
public interface SysJobLogMapper extends BaseMapper<SysJobLog> { public interface JobErrorLogMapper extends BaseMapper<JobErrorLog> {
/** /**
* 查询定时任务日志 * 查询定时任务异常日志
* *
* @param jobLogId 定时任务日志主键 * @param jobLogId 定时任务异常日志主键
* @return 定时任务日志 * @return 定时任务异常日志
*/ */
public SysJobLog selectSysJobLogByJobLogId(Long jobLogId); public JobErrorLog selectJobErrorLogByJobLogId(Long jobLogId);
/** /**
* 查询定时任务日志列表 * 查询定时任务异常日志列表
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 定时任务日志集合 * @return 定时任务异常日志集合
*/ */
public List<SysJobLog> selectSysJobLogList(SysJobLog sysJobLog); public List<JobErrorLog> selectJobErrorLogList(JobErrorLog jobErrorLog);
/** /**
* 新增定时任务日志 * 新增定时任务异常日志
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 结果 * @return 结果
*/ */
public int insertSysJobLog(SysJobLog sysJobLog); public int insertJobErrorLog(JobErrorLog jobErrorLog);
/** /**
* 修改定时任务日志 * 修改定时任务异常日志
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 结果 * @return 结果
*/ */
public int updateSysJobLog(SysJobLog sysJobLog); public int updateJobErrorLog(JobErrorLog jobErrorLog);
/** /**
* 删除定时任务日志 * 删除定时任务异常日志
* *
* @param jobLogId 定时任务日志主键 * @param jobLogId 定时任务异常日志主键
* @return 结果 * @return 结果
*/ */
public int deleteSysJobLogByJobLogId(Long jobLogId); public int deleteJobErrorLogByJobLogId(Long jobLogId);
/** /**
* 批量删除定时任务日志 * 批量删除定时任务异常日志
* *
* @param jobLogIds 需要删除的数据主键集合 * @param jobLogIds 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteSysJobLogByJobLogIds(Long[] jobLogIds); public int deleteJobErrorLogByJobLogIds(Long[] jobLogIds);
void cleanJobLog(); void cleanJobLog();
} }
package share.system.service; package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SysJobLog; import share.system.domain.JobErrorLog;
import java.util.List; import java.util.List;
/** /**
* 定时任务日志Service接口 * 定时任务异常日志Service接口
* *
* @author wuwenlong * @author wuwenlong
* @date 2024-11-15 * @date 2024-11-18
*/ */
public interface SysJobLogService extends IService<SysJobLog> { public interface JobErrorLogService extends IService<JobErrorLog> {
/** /**
* 查询定时任务日志 * 查询定时任务异常日志
* *
* @param jobLogId 定时任务日志主键 * @param jobLogId 定时任务异常日志主键
* @return 定时任务日志 * @return 定时任务异常日志
*/ */
public SysJobLog selectSysJobLogByJobLogId(Long jobLogId); public JobErrorLog selectJobErrorLogByJobLogId(Long jobLogId);
/** /**
* 查询定时任务日志列表 * 查询定时任务异常日志列表
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 定时任务日志集合 * @return 定时任务异常日志集合
*/ */
public List<SysJobLog> selectSysJobLogList(SysJobLog sysJobLog); public List<JobErrorLog> selectJobErrorLogList(JobErrorLog jobErrorLog);
/** /**
* 新增定时任务日志 * 新增定时任务异常日志
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 结果 * @return 结果
*/ */
public int insertSysJobLog(SysJobLog sysJobLog); public int insertJobErrorLog(JobErrorLog jobErrorLog);
/** /**
* 修改定时任务日志 * 修改定时任务异常日志
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 结果 * @return 结果
*/ */
public int updateSysJobLog(SysJobLog sysJobLog); public int updateJobErrorLog(JobErrorLog jobErrorLog);
/** /**
* 批量删除定时任务日志 * 批量删除定时任务异常日志
* *
* @param jobLogIds 需要删除的定时任务日志主键集合 * @param jobLogIds 需要删除的定时任务异常日志主键集合
* @return 结果 * @return 结果
*/ */
public int deleteSysJobLogByJobLogIds(Long[] jobLogIds); public int deleteJobErrorLogByJobLogIds(Long[] jobLogIds);
/** /**
* 删除定时任务日志信息 * 删除定时任务异常日志信息
* *
* @param jobLogId 定时任务日志主键 * @param jobLogId 定时任务异常日志主键
* @return 结果 * @return 结果
*/ */
public int deleteSysJobLogByJobLogId(Long jobLogId); public int deleteJobErrorLogByJobLogId(Long jobLogId);
public void cleanJobLog(); void cleanJobLog();
} }
...@@ -4,92 +4,93 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -4,92 +4,93 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import share.system.domain.SysJobLog; import share.system.domain.JobErrorLog;
import share.system.mapper.SysJobLogMapper; import share.system.mapper.JobErrorLogMapper;
import share.system.service.SysJobLogService; import share.system.service.JobErrorLogService;
import java.util.List; import java.util.List;
/** /**
* 定时任务日志Service业务层处理 * 定时任务异常日志Service业务层处理
* *
* @author wuwenlong * @author wuwenlong
* @date 2024-11-15 * @date 2024-11-18
*/ */
@Service @Service
public class SysJobLogServiceImpl extends ServiceImpl<SysJobLogMapper, SysJobLog> implements SysJobLogService { public class JobErrorLogServiceImpl extends ServiceImpl<JobErrorLogMapper, JobErrorLog> implements JobErrorLogService {
@Autowired @Autowired
private SysJobLogMapper sysJobLogMapper; private JobErrorLogMapper jobErrorLogMapper;
/** /**
* 查询定时任务日志 * 查询定时任务异常日志
* *
* @param jobLogId 定时任务日志主键 * @param jobLogId 定时任务异常日志主键
* @return 定时任务日志 * @return 定时任务异常日志
*/ */
@Override @Override
public SysJobLog selectSysJobLogByJobLogId(Long jobLogId) { public JobErrorLog selectJobErrorLogByJobLogId(Long jobLogId) {
return sysJobLogMapper.selectSysJobLogByJobLogId(jobLogId); return jobErrorLogMapper.selectJobErrorLogByJobLogId(jobLogId);
} }
/** /**
* 查询定时任务日志列表 * 查询定时任务异常日志列表
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 定时任务日志 * @return 定时任务异常日志
*/ */
@Override @Override
public List<SysJobLog> selectSysJobLogList(SysJobLog sysJobLog) { public List<JobErrorLog> selectJobErrorLogList(JobErrorLog jobErrorLog) {
return sysJobLogMapper.selectSysJobLogList(sysJobLog); return jobErrorLogMapper.selectJobErrorLogList(jobErrorLog);
} }
/** /**
* 新增定时任务日志 * 新增定时任务异常日志
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertSysJobLog(SysJobLog sysJobLog) { public int insertJobErrorLog(JobErrorLog jobErrorLog) {
sysJobLog.setCreateTime(DateUtils.getNowDate()); jobErrorLog.setCreateTime(DateUtils.getNowDate());
return sysJobLogMapper.insertSysJobLog(sysJobLog); return jobErrorLogMapper.insertJobErrorLog(jobErrorLog);
} }
/** /**
* 修改定时任务日志 * 修改定时任务异常日志
* *
* @param sysJobLog 定时任务日志 * @param jobErrorLog 定时任务异常日志
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateSysJobLog(SysJobLog sysJobLog) { public int updateJobErrorLog(JobErrorLog jobErrorLog) {
return sysJobLogMapper.updateSysJobLog(sysJobLog); jobErrorLog.setUpdateTime(DateUtils.getNowDate());
return jobErrorLogMapper.updateJobErrorLog(jobErrorLog);
} }
/** /**
* 批量删除定时任务日志 * 批量删除定时任务异常日志
* *
* @param jobLogIds 需要删除的定时任务日志主键 * @param jobLogIds 需要删除的定时任务异常日志主键
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteSysJobLogByJobLogIds(Long[] jobLogIds) { public int deleteJobErrorLogByJobLogIds(Long[] jobLogIds) {
return sysJobLogMapper.deleteSysJobLogByJobLogIds(jobLogIds); return jobErrorLogMapper.deleteJobErrorLogByJobLogIds(jobLogIds);
} }
/** /**
* 删除定时任务日志信息 * 删除定时任务异常日志信息
* *
* @param jobLogId 定时任务日志主键 * @param jobLogId 定时任务异常日志主键
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteSysJobLogByJobLogId(Long jobLogId) { public int deleteJobErrorLogByJobLogId(Long jobLogId) {
return sysJobLogMapper.deleteSysJobLogByJobLogId(jobLogId); return jobErrorLogMapper.deleteJobErrorLogByJobLogId(jobLogId);
} }
@Override @Override
public void cleanJobLog() { public void cleanJobLog() {
sysJobLogMapper.cleanJobLog(); jobErrorLogMapper.cleanJobLog();
} }
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.system.mapper.SysJobLogMapper"> <mapper namespace="share.system.mapper.JobErrorLogMapper">
<resultMap type="SysJobLog" id="SysJobLogResult"> <resultMap type="JobErrorLog" id="JobErrorLogResult">
<result property="jobLogId" column="job_log_id"/> <result property="jobLogId" column="job_log_id"/>
<result property="jobName" column="job_name"/> <result property="jobName" column="job_name"/>
<result property="jobGroup" column="job_group"/> <result property="jobGroup" column="job_group"/>
...@@ -12,10 +12,14 @@ ...@@ -12,10 +12,14 @@
<result property="jobMessage" column="job_message"/> <result property="jobMessage" column="job_message"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="exceptionInfo" column="exception_info"/> <result property="exceptionInfo" column="exception_info"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap> </resultMap>
<sql id="selectSysJobLogVo"> <sql id="selectJobErrorLogVo">
select job_log_id, select job_log_id,
job_name, job_name,
job_group, job_group,
...@@ -23,12 +27,16 @@ ...@@ -23,12 +27,16 @@
job_message, job_message,
status, status,
exception_info, exception_info,
create_time create_by,
from sys_job_log create_time,
update_by,
update_time,
remark
from s_job_error_log
</sql> </sql>
<select id="selectSysJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult"> <select id="selectJobErrorLogList" parameterType="JobErrorLog" resultMap="JobErrorLogResult">
<include refid="selectSysJobLogVo"/> <include refid="selectJobErrorLogVo"/>
<where> <where>
<if test="jobName != null and jobName != ''">and job_name like concat('%', #{jobName}, '%')</if> <if test="jobName != null and jobName != ''">and job_name like concat('%', #{jobName}, '%')</if>
<if test="jobGroup != null and jobGroup != ''">and job_group = #{jobGroup}</if> <if test="jobGroup != null and jobGroup != ''">and job_group = #{jobGroup}</if>
...@@ -39,13 +47,13 @@ ...@@ -39,13 +47,13 @@
</where> </where>
</select> </select>
<select id="selectSysJobLogByJobLogId" parameterType="Long" resultMap="SysJobLogResult"> <select id="selectJobErrorLogByJobLogId" parameterType="Long" resultMap="JobErrorLogResult">
<include refid="selectSysJobLogVo"/> <include refid="selectJobErrorLogVo"/>
where job_log_id = #{jobLogId} where job_log_id = #{jobLogId}
</select> </select>
<insert id="insertSysJobLog" parameterType="SysJobLog" useGeneratedKeys="true" keyProperty="jobLogId"> <insert id="insertJobErrorLog" parameterType="JobErrorLog" useGeneratedKeys="true" keyProperty="jobLogId">
insert into sys_job_log insert into s_job_error_log
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="jobName != null and jobName != ''">job_name,</if> <if test="jobName != null and jobName != ''">job_name,</if>
<if test="jobGroup != null and jobGroup != ''">job_group,</if> <if test="jobGroup != null and jobGroup != ''">job_group,</if>
...@@ -53,7 +61,11 @@ ...@@ -53,7 +61,11 @@
<if test="jobMessage != null">job_message,</if> <if test="jobMessage != null">job_message,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="exceptionInfo != null">exception_info,</if> <if test="exceptionInfo != null">exception_info,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="jobName != null and jobName != ''">#{jobName},</if> <if test="jobName != null and jobName != ''">#{jobName},</if>
...@@ -62,12 +74,16 @@ ...@@ -62,12 +74,16 @@
<if test="jobMessage != null">#{jobMessage},</if> <if test="jobMessage != null">#{jobMessage},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="exceptionInfo != null">#{exceptionInfo},</if> <if test="exceptionInfo != null">#{exceptionInfo},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim> </trim>
</insert> </insert>
<update id="updateSysJobLog" parameterType="SysJobLog"> <update id="updateJobErrorLog" parameterType="JobErrorLog">
update sys_job_log update s_job_error_log
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="jobName != null and jobName != ''">job_name = #{jobName},</if> <if test="jobName != null and jobName != ''">job_name = #{jobName},</if>
<if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if> <if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if>
...@@ -75,25 +91,29 @@ ...@@ -75,25 +91,29 @@
<if test="jobMessage != null">job_message = #{jobMessage},</if> <if test="jobMessage != null">job_message = #{jobMessage},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="exceptionInfo != null">exception_info = #{exceptionInfo},</if> <if test="exceptionInfo != null">exception_info = #{exceptionInfo},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim> </trim>
where job_log_id = #{jobLogId} where job_log_id = #{jobLogId}
</update> </update>
<delete id="deleteSysJobLogByJobLogId" parameterType="Long"> <delete id="deleteJobErrorLogByJobLogId" parameterType="Long">
delete delete
from sys_job_log from s_job_error_log
where job_log_id = #{jobLogId} where job_log_id = #{jobLogId}
</delete> </delete>
<delete id="deleteSysJobLogByJobLogIds" parameterType="String"> <delete id="deleteJobErrorLogByJobLogIds" parameterType="String">
delete from sys_job_log where job_log_id in delete from s_job_error_log where job_log_id in
<foreach item="jobLogId" collection="array" open="(" separator="," close=")"> <foreach item="jobLogId" collection="array" open="(" separator="," close=")">
#{jobLogId} #{jobLogId}
</foreach> </foreach>
</delete> </delete>
<update id="cleanJobLog"> <update id="cleanJobLog">
truncate table sys_job_log truncate table s_job_error_log
</update> </update>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment