消息修改

This commit is contained in:
梁琦涛
2021-09-28 10:06:27 +08:00
parent 1f00c179bc
commit eebfef1c99
14 changed files with 360 additions and 34 deletions
@@ -0,0 +1,16 @@
package com.jero.system;
public class SystemRemindersCommon {
/**
* 频率 (1:仅一此,2:每月一次,3:每年一次)
*/
public final static Integer FREQUENCY1 = 1;
/**
* 频率 (1:仅一此,2:每月一次,3:每年一次)
*/
public final static Integer FREQUENCY2 = 2;
/**
* 频率 (1:仅一此,2:每月一次,3:每年一次)
*/
public final static Integer FREQUENCY3 = 4;
}
@@ -0,0 +1,84 @@
package com.jero.system.controller;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.mail.service.IPayMailBillService;
import com.jero.modules.quartz.entity.QuartzJob;
import com.jero.modules.quartz.service.IQuartzJobService;
import com.jero.payment.service.IPayPaymentRecordService;
import com.jero.system.SystemRemindersCommon;
import com.jero.system.vo.SystemRemindersVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;
/**
* @Description: 系统催款
* @Author: jeecg-boot
* @Date: 2021-09-24
* @Version: V1.0
*/
@Api(tags="系统催款")
@RestController
@RequestMapping("/reminders")
@Slf4j
public class SystemRemindersController {
@Resource
private IPayPaymentRecordService payPaymentRecordService;
@Resource
private IQuartzJobService quartzJobService;
private static final String id = "1442663790058471425";
/**
* 系统催款
*
* @return
*/
@AutoLog(value = "系统催款-编辑")
@ApiOperation(value="系统催款-编辑", notes="首页-编辑")
@PostMapping(value = "/edit")
public Result<?> edit(@RequestBody SystemRemindersVO systemRemindersVO) {
// 每年
String year = "0 0 0 ${day} ${month} ? *";
// 每月
String month = "0 0 0 ${day} * ?";
// 指定日期执行一次
String day = "0 0 0 ${day} ${month} ? ${year}";
if(Objects.isNull(systemRemindersVO.getFrequency())){
return Result.error("频率不能为空");
}
if(Objects.isNull(systemRemindersVO.getTime())){
return Result.error("催款时间不能为空");
}
String cron = "";
// 频率 (1:仅一此,2:每月一次,3:每年一次)
if(Objects.equals(systemRemindersVO.getFrequency(),SystemRemindersCommon.FREQUENCY1)){
String[] t = systemRemindersVO.getTime().split("-");
Calendar now = Calendar.getInstance();
cron = day.replace("${day}",t[1]).replace("${month}",t[0]).replace("${year}",String.valueOf(now.get(Calendar.YEAR)));
}else if(Objects.equals(systemRemindersVO.getFrequency(),SystemRemindersCommon.FREQUENCY2)){
cron = month.replace("${day}",systemRemindersVO.getTime());
}else if(Objects.equals(systemRemindersVO.getFrequency(),SystemRemindersCommon.FREQUENCY3)){
String[] t = systemRemindersVO.getTime().split("-");
cron = year.replace("${day}",t[1]).replace("${month}",t[0]);
}
LambdaUpdateWrapper<QuartzJob> update = new LambdaUpdateWrapper<>();
update.eq(QuartzJob::getId,id);
update.set(QuartzJob::getCronExpression,cron);
quartzJobService.update(update);
return Result.OK("操作成功");
}
}
@@ -0,0 +1,20 @@
package com.jero.system.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class SystemRemindersVO implements Serializable {
/**
* 频率 (1:仅一此,2:每月一次,3:每年一次)
*/
@ApiModelProperty(value = "频率")
private Integer frequency;
/**
* 催款时间
*/
@ApiModelProperty(value = "催款时间")
private String time;
}