diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml index a07542ab2..6bc7983a8 100644 --- a/ruoyi-quartz/pom.xml +++ b/ruoyi-quartz/pom.xml @@ -35,6 +35,14 @@ ruoyi-common + + + com.ruoyi + xkt + ${ruoyi.version} + + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/DailySaleController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/DailySaleController.java new file mode 100644 index 000000000..92b7ae07f --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/DailySaleController.java @@ -0,0 +1,42 @@ +package com.ruoyi.quartz.controller; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.task.XktTask; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 调度任务信息操作处理 + * + * @author ruoyi + */ +@RequiredArgsConstructor +@RestController +@RequestMapping("/rest/v1/daily-sale") +public class DailySaleController extends BaseController { + + final XktTask task; + + @PostMapping("") + public R dailySale(SysJob sysJob) { + task.dailySale(); + return R.ok(); + } + + @PostMapping("/prod") + public R dailySaleProd(SysJob sysJob) { + task.dailySaleProduct(); + return R.ok(); + } + + @PostMapping("/cus") + public R dailySaleCus(SysJob sysJob) { + task.dailySaleCustomer(); + return R.ok(); + } + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java index f8189babe..69c1b96cb 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -1,18 +1,5 @@ package com.ruoyi.quartz.controller; -import java.util.List; -import javax.servlet.http.HttpServletResponse; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.controller.BaseController; @@ -26,16 +13,22 @@ import com.ruoyi.quartz.domain.SysJob; import com.ruoyi.quartz.service.ISysJobService; import com.ruoyi.quartz.util.CronUtils; import com.ruoyi.quartz.util.ScheduleUtils; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 调度任务信息操作处理 - * + * * @author ruoyi */ @RestController @RequestMapping("/monitor/job") -public class SysJobController extends BaseController -{ +public class SysJobController extends BaseController { @Autowired private ISysJobService jobService; @@ -44,8 +37,7 @@ public class SysJobController extends BaseController */ @PreAuthorize("@ss.hasPermi('monitor:job:list')") @GetMapping("/list") - public TableDataInfo list(SysJob sysJob) - { + public TableDataInfo list(SysJob sysJob) { startPage(); List list = jobService.selectJobList(sysJob); return getDataTable(list); @@ -57,8 +49,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:export')") @Log(title = "定时任务", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, SysJob sysJob) - { + public void export(HttpServletResponse response, SysJob sysJob) { List list = jobService.selectJobList(sysJob); ExcelUtil util = new ExcelUtil(SysJob.class); util.exportExcel(response, list, "定时任务"); @@ -69,8 +60,7 @@ public class SysJobController extends BaseController */ @PreAuthorize("@ss.hasPermi('monitor:job:query')") @GetMapping(value = "/{jobId}") - public AjaxResult getInfo(@PathVariable("jobId") Long jobId) - { + public AjaxResult getInfo(@PathVariable("jobId") Long jobId) { return success(jobService.selectJobById(jobId)); } @@ -80,30 +70,18 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:add')") @Log(title = "定时任务", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(job.getCronExpression())) - { + public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException { + if (!CronUtils.isValid(job.getCronExpression())) { return error("新增任务'" + job.getJobName() + "'失败,Cron表达式不正确"); - } - else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) - { + } else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) { return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi'调用"); - } - else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS })) - { + } else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[]{Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS})) { return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap(s)'调用"); - } - else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) - { + } else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[]{Constants.HTTP, Constants.HTTPS})) { return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用"); - } - else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) - { + } else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) { return error("新增任务'" + job.getJobName() + "'失败,目标字符串存在违规"); - } - else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) - { + } else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) { return error("新增任务'" + job.getJobName() + "'失败,目标字符串不在白名单内"); } job.setCreateBy(getUsername()); @@ -116,30 +94,18 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:edit')") @Log(title = "定时任务", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(job.getCronExpression())) - { + public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException { + if (!CronUtils.isValid(job.getCronExpression())) { return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确"); - } - else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) - { + } else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) { return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi'调用"); - } - else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS })) - { + } else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[]{Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS})) { return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap(s)'调用"); - } - else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) - { + } else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[]{Constants.HTTP, Constants.HTTPS})) { return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用"); - } - else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) - { + } else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) { return error("修改任务'" + job.getJobName() + "'失败,目标字符串存在违规"); - } - else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) - { + } else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) { return error("修改任务'" + job.getJobName() + "'失败,目标字符串不在白名单内"); } job.setUpdateBy(getUsername()); @@ -152,8 +118,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") @Log(title = "定时任务", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException - { + public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException { SysJob newJob = jobService.selectJobById(job.getJobId()); newJob.setStatus(job.getStatus()); return toAjax(jobService.changeStatus(newJob)); @@ -165,8 +130,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") @Log(title = "定时任务", businessType = BusinessType.UPDATE) @PutMapping("/run") - public AjaxResult run(@RequestBody SysJob job) throws SchedulerException - { + public AjaxResult run(@RequestBody SysJob job) throws SchedulerException { boolean result = jobService.run(job); return result ? success() : error("任务不存在或已过期!"); } @@ -177,8 +141,7 @@ public class SysJobController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:remove')") @Log(title = "定时任务", businessType = BusinessType.DELETE) @DeleteMapping("/{jobIds}") - public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException - { + public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException { jobService.deleteJobByIds(jobIds); return success(); } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java index 67f44abf9..b9d86e4ac 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java @@ -1,15 +1,5 @@ package com.ruoyi.quartz.controller; -import java.util.List; -import javax.servlet.http.HttpServletResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -18,16 +8,21 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.service.ISysJobLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 调度日志操作处理 - * + * * @author ruoyi */ @RestController @RequestMapping("/monitor/jobLog") -public class SysJobLogController extends BaseController -{ +public class SysJobLogController extends BaseController { @Autowired private ISysJobLogService jobLogService; @@ -36,8 +31,7 @@ public class SysJobLogController extends BaseController */ @PreAuthorize("@ss.hasPermi('monitor:job:list')") @GetMapping("/list") - public TableDataInfo list(SysJobLog sysJobLog) - { + public TableDataInfo list(SysJobLog sysJobLog) { startPage(); List list = jobLogService.selectJobLogList(sysJobLog); return getDataTable(list); @@ -49,20 +43,18 @@ public class SysJobLogController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:export')") @Log(title = "任务调度日志", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, SysJobLog sysJobLog) - { + public void export(HttpServletResponse response, SysJobLog sysJobLog) { List list = jobLogService.selectJobLogList(sysJobLog); ExcelUtil util = new ExcelUtil(SysJobLog.class); util.exportExcel(response, list, "调度日志"); } - + /** * 根据调度编号获取详细信息 */ @PreAuthorize("@ss.hasPermi('monitor:job:query')") @GetMapping(value = "/{jobLogId}") - public AjaxResult getInfo(@PathVariable Long jobLogId) - { + public AjaxResult getInfo(@PathVariable Long jobLogId) { return success(jobLogService.selectJobLogById(jobLogId)); } @@ -73,8 +65,7 @@ public class SysJobLogController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:remove')") @Log(title = "定时任务调度日志", businessType = BusinessType.DELETE) @DeleteMapping("/{jobLogIds}") - public AjaxResult remove(@PathVariable Long[] jobLogIds) - { + public AjaxResult remove(@PathVariable Long[] jobLogIds) { return toAjax(jobLogService.deleteJobLogByIds(jobLogIds)); } @@ -84,8 +75,7 @@ public class SysJobLogController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:job:remove')") @Log(title = "调度日志", businessType = BusinessType.CLEAN) @DeleteMapping("/clean") - public AjaxResult clean() - { + public AjaxResult clean() { jobLogService.cleanJobLog(); return success(); } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySale.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySale.java new file mode 100644 index 000000000..1fb48dd7b --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySale.java @@ -0,0 +1,67 @@ +package com.ruoyi.quartz.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.XktBaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 档口每天销售数据统计 daily_sale + * + * @author ruoyi + * @date 2025-03-26 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +public class DailySale extends XktBaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 每日销售统计ID + */ + @TableId + private Long id; + /** + * 档口ID + */ + private Long storeId; + + /** + * 销售金额 + */ + private BigDecimal saleAmount; + /** + * 退货金额 + */ + private BigDecimal returnAmount; + /** + * 销售数量 + */ + private Integer saleNum; + /** + * 退货数量 + */ + private Integer returnNum; + /** + * 拿货客户数量(人次) + */ + private Integer customerNum; + /** + * 入库数量 + */ + private Integer storageNum; + /** + * 统计时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date voucherDate; + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySaleCustomer.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySaleCustomer.java new file mode 100644 index 000000000..276a60c5e --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySaleCustomer.java @@ -0,0 +1,61 @@ +package com.ruoyi.quartz.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.domain.XktBaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 档口客户每天销售数据统计 daily_sale_customer + * + * @author ruoyi + * @date 2025-03-26 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +public class DailySaleCustomer extends XktBaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 每日销售统计ID + */ + @TableId + private Long id; + /** + * 档口ID + */ + private Long storeId; + /** + * 档口客户ID + */ + private Long storeCusId; + /** + * 销售金额 + */ + private BigDecimal saleAmount; + /** + * 退货金额 + */ + private BigDecimal returnAmount; + /** + * 销售数量 + */ + private Integer saleNum; + /** + * 退货数量 + */ + private Integer returnNum; + /** + * 统计时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date voucherDate; + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySaleProduct.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySaleProduct.java new file mode 100644 index 000000000..f8aa3adc5 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/DailySaleProduct.java @@ -0,0 +1,66 @@ +package com.ruoyi.quartz.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.XktBaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 档口客户每天销售数据统计 daily_sale_customer + * + * @author ruoyi + * @date 2025-03-26 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +public class DailySaleProduct extends XktBaseEntity { + + private static final long serialVersionUID = 1L; + /** + * 档口销售出库ID + */ + @TableId + private Long id; + /** + * 档口ID + */ + @Excel(name = "档口ID") + private Long storeId; + /** + * 档口商品ID + */ + private Long storeProdId; + /** + * 档口商品货号 + */ + private String prodArtNum; + /** + * 销售金额 + */ + private BigDecimal saleAmount; + /** + * 退货金额 + */ + private BigDecimal returnAmount; + /** + * 销售数量 + */ + private Integer saleNum; + /** + * 退货数量 + */ + private Integer returnNum; + /** + * 统计时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date voucherDate; + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java index 4776e5fe9..b63a2572c 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java @@ -1,10 +1,5 @@ package com.ruoyi.quartz.domain; -import java.util.Date; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel.ColumnType; @@ -12,160 +7,163 @@ import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.quartz.util.CronUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Date; /** * 定时任务调度表 sys_job - * + * * @author ruoyi */ -public class SysJob extends BaseEntity -{ +public class SysJob extends BaseEntity { private static final long serialVersionUID = 1L; - /** 任务ID */ + /** + * 任务ID + */ @Excel(name = "任务序号", cellType = ColumnType.NUMERIC) private Long jobId; - /** 任务名称 */ + /** + * 任务名称 + */ @Excel(name = "任务名称") private String jobName; - /** 任务组名 */ + /** + * 任务组名 + */ @Excel(name = "任务组名") private String jobGroup; - /** 调用目标字符串 */ + /** + * 调用目标字符串 + */ @Excel(name = "调用目标字符串") private String invokeTarget; - /** cron执行表达式 */ + /** + * cron执行表达式 + */ @Excel(name = "执行表达式 ") private String cronExpression; - /** cron计划策略 */ + /** + * cron计划策略 + */ @Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行") private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; - /** 是否并发执行(0允许 1禁止) */ + /** + * 是否并发执行(0允许 1禁止) + */ @Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止") private String concurrent; - /** 任务状态(0正常 1暂停) */ + /** + * 任务状态(0正常 1暂停) + */ @Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停") private String status; - public Long getJobId() - { + public Long getJobId() { return jobId; } - public void setJobId(Long jobId) - { + public void setJobId(Long jobId) { this.jobId = jobId; } @NotBlank(message = "任务名称不能为空") @Size(min = 0, max = 64, message = "任务名称不能超过64个字符") - public String getJobName() - { + public String getJobName() { return jobName; } - public void setJobName(String jobName) - { + public void setJobName(String jobName) { this.jobName = jobName; } - public String getJobGroup() - { + public String getJobGroup() { return jobGroup; } - public void setJobGroup(String jobGroup) - { + public void setJobGroup(String jobGroup) { this.jobGroup = jobGroup; } @NotBlank(message = "调用目标字符串不能为空") @Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符") - public String getInvokeTarget() - { + public String getInvokeTarget() { return invokeTarget; } - public void setInvokeTarget(String invokeTarget) - { + public void setInvokeTarget(String invokeTarget) { this.invokeTarget = invokeTarget; } @NotBlank(message = "Cron执行表达式不能为空") @Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符") - public String getCronExpression() - { + public String getCronExpression() { return cronExpression; } - public void setCronExpression(String cronExpression) - { + public void setCronExpression(String cronExpression) { this.cronExpression = cronExpression; } @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - public Date getNextValidTime() - { - if (StringUtils.isNotEmpty(cronExpression)) - { + public Date getNextValidTime() { + if (StringUtils.isNotEmpty(cronExpression)) { return CronUtils.getNextExecution(cronExpression); } return null; } - public String getMisfirePolicy() - { + public String getMisfirePolicy() { return misfirePolicy; } - public void setMisfirePolicy(String misfirePolicy) - { + public void setMisfirePolicy(String misfirePolicy) { this.misfirePolicy = misfirePolicy; } - public String getConcurrent() - { + public String getConcurrent() { return concurrent; } - public void setConcurrent(String concurrent) - { + public void setConcurrent(String concurrent) { this.concurrent = concurrent; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobId", getJobId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("cronExpression", getCronExpression()) - .append("nextValidTime", getNextValidTime()) - .append("misfirePolicy", getMisfirePolicy()) - .append("concurrent", getConcurrent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("jobId", getJobId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("cronExpression", getCronExpression()) + .append("nextValidTime", getNextValidTime()) + .append("misfirePolicy", getMisfirePolicy()) + .append("concurrent", getConcurrent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java index 63c4cd69d..81759b85a 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java @@ -1,155 +1,155 @@ package com.ruoyi.quartz.domain; -import java.util.Date; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; /** * 定时任务调度日志表 sys_job_log - * + * * @author ruoyi */ -public class SysJobLog extends BaseEntity -{ +public class SysJobLog extends BaseEntity { private static final long serialVersionUID = 1L; - /** ID */ + /** + * ID + */ @Excel(name = "日志序号") private Long jobLogId; - /** 任务名称 */ + /** + * 任务名称 + */ @Excel(name = "任务名称") private String jobName; - /** 任务组名 */ + /** + * 任务组名 + */ @Excel(name = "任务组名") private String jobGroup; - /** 调用目标字符串 */ + /** + * 调用目标字符串 + */ @Excel(name = "调用目标字符串") private String invokeTarget; - /** 日志信息 */ + /** + * 日志信息 + */ @Excel(name = "日志信息") private String jobMessage; - /** 执行状态(0正常 1失败) */ + /** + * 执行状态(0正常 1失败) + */ @Excel(name = "执行状态", readConverterExp = "0=正常,1=失败") private String status; - /** 异常信息 */ + /** + * 异常信息 + */ @Excel(name = "异常信息") private String exceptionInfo; - /** 开始时间 */ + /** + * 开始时间 + */ private Date startTime; - /** 停止时间 */ + /** + * 停止时间 + */ private Date stopTime; - public Long getJobLogId() - { + public Long getJobLogId() { return jobLogId; } - public void setJobLogId(Long jobLogId) - { + public void setJobLogId(Long jobLogId) { this.jobLogId = jobLogId; } - public String getJobName() - { + public String getJobName() { return jobName; } - public void setJobName(String jobName) - { + public void setJobName(String jobName) { this.jobName = jobName; } - public String getJobGroup() - { + public String getJobGroup() { return jobGroup; } - public void setJobGroup(String jobGroup) - { + public void setJobGroup(String jobGroup) { this.jobGroup = jobGroup; } - public String getInvokeTarget() - { + public String getInvokeTarget() { return invokeTarget; } - public void setInvokeTarget(String invokeTarget) - { + public void setInvokeTarget(String invokeTarget) { this.invokeTarget = invokeTarget; } - public String getJobMessage() - { + public String getJobMessage() { return jobMessage; } - public void setJobMessage(String jobMessage) - { + public void setJobMessage(String jobMessage) { this.jobMessage = jobMessage; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getExceptionInfo() - { + public String getExceptionInfo() { return exceptionInfo; } - public void setExceptionInfo(String exceptionInfo) - { + public void setExceptionInfo(String exceptionInfo) { this.exceptionInfo = exceptionInfo; } - public Date getStartTime() - { + public Date getStartTime() { return startTime; } - public void setStartTime(Date startTime) - { + public void setStartTime(Date startTime) { this.startTime = startTime; } - - public Date getStopTime() - { + + public Date getStopTime() { return stopTime; } - public void setStopTime(Date stopTime) - { + public void setStopTime(Date stopTime) { this.stopTime = stopTime; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobLogId", getJobLogId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("jobMessage", getJobMessage()) - .append("status", getStatus()) - .append("exceptionInfo", getExceptionInfo()) - .append("startTime", getStartTime()) - .append("stopTime", getStopTime()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("jobLogId", getJobLogId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("jobMessage", getJobMessage()) + .append("status", getStatus()) + .append("exceptionInfo", getExceptionInfo()) + .append("startTime", getStartTime()) + .append("stopTime", getStopTime()) + .toString(); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleCusDTO.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleCusDTO.java new file mode 100644 index 000000000..6e14116d6 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleCusDTO.java @@ -0,0 +1,40 @@ +package com.ruoyi.quartz.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author liujiang + * @version v1.0 + * @date 2025/4/16 23:06 + */ +@Data +public class DailySaleCusDTO { + + /** + * 档口ID + */ + private Long storeId; + /** + * 档口客户ID + */ + private Long storeCusId; + /** + * 销售金额 + */ + private BigDecimal saleAmount; + /** + * 退货金额 + */ + private BigDecimal returnAmount; + /** + * 销售数量 + */ + private Integer saleNum; + /** + * 退货数量 + */ + private Integer returnNum; + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleDTO.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleDTO.java new file mode 100644 index 000000000..5d433a92f --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleDTO.java @@ -0,0 +1,45 @@ +package com.ruoyi.quartz.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author liujiang + * @version v1.0 + * @date 2025/4/16 23:06 + */ +@Data +public class DailySaleDTO { + + /** + * 档口ID + */ + private Long storeId; + + /** + * 销售金额 + */ + private BigDecimal saleAmount; + /** + * 退货金额 + */ + private BigDecimal returnAmount; + /** + * 销售数量 + */ + private Integer saleNum; + /** + * 退货数量 + */ + private Integer returnNum; + /** + * 拿货客户数量(人次) + */ + private Integer customerNum; + /** + * 入库数量 + */ + private Integer storageNum; + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleProdDTO.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleProdDTO.java new file mode 100644 index 000000000..9d544cecd --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/dto/DailySaleProdDTO.java @@ -0,0 +1,45 @@ +package com.ruoyi.quartz.dto; + +import com.ruoyi.common.annotation.Excel; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author liujiang + * @version v1.0 + * @date 2025/4/16 23:06 + */ +@Data +public class DailySaleProdDTO { + + /** + * 档口ID + */ + private Long storeId; + /** + * 档口商品ID + */ + private Long storeProdId; + /** + * 档口商品货号 + */ + private String prodArtNum; + /** + * 销售金额 + */ + private BigDecimal saleAmount; + /** + * 退货金额 + */ + private BigDecimal returnAmount; + /** + * 销售数量 + */ + private Integer saleNum; + /** + * 退货数量 + */ + private Integer returnNum; + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleCustomerMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleCustomerMapper.java new file mode 100644 index 000000000..e802fa9e2 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleCustomerMapper.java @@ -0,0 +1,19 @@ +package com.ruoyi.quartz.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.quartz.domain.DailySaleCustomer; +import com.ruoyi.quartz.dto.DailySaleCusDTO; + +import java.util.Date; +import java.util.List; + +/** + * 调度任务信息 数据层 + * + * @author ruoyi + */ +public interface DailySaleCustomerMapper extends BaseMapper { + + List selectDailySale(Date voucherDate); + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleMapper.java new file mode 100644 index 000000000..fcb50a740 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleMapper.java @@ -0,0 +1,19 @@ +package com.ruoyi.quartz.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.quartz.domain.DailySale; +import com.ruoyi.quartz.dto.DailySaleDTO; + +import java.util.Date; +import java.util.List; + +/** + * 调度任务信息 数据层 + * + * @author ruoyi + */ +public interface DailySaleMapper extends BaseMapper { + + List selectDailySale(Date voucherDate); + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleProductMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleProductMapper.java new file mode 100644 index 000000000..482775538 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/DailySaleProductMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.quartz.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.quartz.domain.DailySaleCustomer; +import com.ruoyi.quartz.domain.DailySaleProduct; +import com.ruoyi.quartz.dto.DailySaleDTO; +import com.ruoyi.quartz.dto.DailySaleProdDTO; + +import java.util.Date; +import java.util.List; + +/** + * 调度任务信息 数据层 + * + * @author ruoyi + */ +public interface DailySaleProductMapper extends BaseMapper { + + List selectDailySale(Date voucherDate); + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java index ed01ef72e..4982d8c20 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java @@ -1,18 +1,18 @@ package com.ruoyi.quartz.mapper; -import java.util.List; import com.ruoyi.quartz.domain.SysJobLog; +import java.util.List; + /** * 调度任务日志信息 数据层 - * + * * @author ruoyi */ -public interface SysJobLogMapper -{ +public interface SysJobLogMapper { /** * 获取quartz调度器日志的计划任务 - * + * * @param jobLog 调度日志信息 * @return 调度任务日志集合 */ @@ -27,7 +27,7 @@ public interface SysJobLogMapper /** * 通过调度任务日志ID查询调度信息 - * + * * @param jobLogId 调度任务日志ID * @return 调度任务日志对象信息 */ @@ -35,7 +35,7 @@ public interface SysJobLogMapper /** * 新增任务日志 - * + * * @param jobLog 调度日志信息 * @return 结果 */ @@ -43,7 +43,7 @@ public interface SysJobLogMapper /** * 批量删除调度日志信息 - * + * * @param logIds 需要删除的数据ID * @return 结果 */ @@ -51,7 +51,7 @@ public interface SysJobLogMapper /** * 删除任务日志 - * + * * @param jobId 调度日志ID * @return 结果 */ diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java index f481ea12e..6c8a53059 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java @@ -1,18 +1,18 @@ package com.ruoyi.quartz.mapper; -import java.util.List; import com.ruoyi.quartz.domain.SysJob; +import java.util.List; + /** * 调度任务信息 数据层 - * + * * @author ruoyi */ -public interface SysJobMapper -{ +public interface SysJobMapper { /** * 查询调度任务日志集合 - * + * * @param job 调度信息 * @return 操作日志集合 */ @@ -20,14 +20,14 @@ public interface SysJobMapper /** * 查询所有调度任务 - * + * * @return 调度任务列表 */ public List selectJobAll(); /** * 通过调度ID查询调度任务信息 - * + * * @param jobId 调度ID * @return 角色对象信息 */ @@ -35,7 +35,7 @@ public interface SysJobMapper /** * 通过调度ID删除调度任务信息 - * + * * @param jobId 调度ID * @return 结果 */ @@ -43,7 +43,7 @@ public interface SysJobMapper /** * 批量删除调度任务信息 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @@ -51,7 +51,7 @@ public interface SysJobMapper /** * 修改调度任务信息 - * + * * @param job 调度任务信息 * @return 结果 */ @@ -59,7 +59,7 @@ public interface SysJobMapper /** * 新增调度任务信息 - * + * * @param job 调度任务信息 * @return 结果 */ diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java index 5291a63ac..52fc3fa35 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java @@ -1,18 +1,18 @@ package com.ruoyi.quartz.service; -import java.util.List; import com.ruoyi.quartz.domain.SysJobLog; +import java.util.List; + /** * 定时任务调度日志信息信息 服务层 - * + * * @author ruoyi */ -public interface ISysJobLogService -{ +public interface ISysJobLogService { /** * 获取quartz调度器日志的计划任务 - * + * * @param jobLog 调度日志信息 * @return 调度任务日志集合 */ @@ -20,7 +20,7 @@ public interface ISysJobLogService /** * 通过调度任务日志ID查询调度信息 - * + * * @param jobLogId 调度任务日志ID * @return 调度任务日志对象信息 */ @@ -28,14 +28,14 @@ public interface ISysJobLogService /** * 新增任务日志 - * + * * @param jobLog 调度日志信息 */ public void addJobLog(SysJobLog jobLog); /** * 批量删除调度日志信息 - * + * * @param logIds 需要删除的日志ID * @return 结果 */ @@ -43,7 +43,7 @@ public interface ISysJobLogService /** * 删除任务日志 - * + * * @param jobId 调度日志ID * @return 结果 */ diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java index afdb707b1..ee93cd73d 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java @@ -1,20 +1,20 @@ package com.ruoyi.quartz.service; -import java.util.List; -import org.quartz.SchedulerException; import com.ruoyi.common.exception.job.TaskException; import com.ruoyi.quartz.domain.SysJob; +import org.quartz.SchedulerException; + +import java.util.List; /** * 定时任务调度信息信息 服务层 - * + * * @author ruoyi */ -public interface ISysJobService -{ +public interface ISysJobService { /** * 获取quartz调度器的计划任务 - * + * * @param job 调度信息 * @return 调度任务集合 */ @@ -22,7 +22,7 @@ public interface ISysJobService /** * 通过调度任务ID查询调度信息 - * + * * @param jobId 调度任务ID * @return 调度任务对象信息 */ @@ -30,7 +30,7 @@ public interface ISysJobService /** * 暂停任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -38,7 +38,7 @@ public interface ISysJobService /** * 恢复任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -46,7 +46,7 @@ public interface ISysJobService /** * 删除任务后,所对应的trigger也将被删除 - * + * * @param job 调度信息 * @return 结果 */ @@ -54,7 +54,7 @@ public interface ISysJobService /** * 批量删除调度信息 - * + * * @param jobIds 需要删除的任务ID * @return 结果 */ @@ -62,7 +62,7 @@ public interface ISysJobService /** * 任务调度状态修改 - * + * * @param job 调度信息 * @return 结果 */ @@ -70,7 +70,7 @@ public interface ISysJobService /** * 立即运行任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -78,7 +78,7 @@ public interface ISysJobService /** * 新增任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -86,7 +86,7 @@ public interface ISysJobService /** * 更新任务 - * + * * @param job 调度信息 * @return 结果 */ @@ -94,7 +94,7 @@ public interface ISysJobService /** * 校验cron表达式是否有效 - * + * * @param cronExpression 表达式 * @return 结果 */ diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java index f68a5482b..d0f6543df 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java @@ -1,78 +1,73 @@ package com.ruoyi.quartz.service.impl; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.mapper.SysJobLogMapper; import com.ruoyi.quartz.service.ISysJobLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; /** * 定时任务调度日志信息 服务层 - * + * * @author ruoyi */ @Service -public class SysJobLogServiceImpl implements ISysJobLogService -{ +public class SysJobLogServiceImpl implements ISysJobLogService { @Autowired private SysJobLogMapper jobLogMapper; /** * 获取quartz调度器日志的计划任务 - * + * * @param jobLog 调度日志信息 * @return 调度任务日志集合 */ @Override - public List selectJobLogList(SysJobLog jobLog) - { + public List selectJobLogList(SysJobLog jobLog) { return jobLogMapper.selectJobLogList(jobLog); } /** * 通过调度任务日志ID查询调度信息 - * + * * @param jobLogId 调度任务日志ID * @return 调度任务日志对象信息 */ @Override - public SysJobLog selectJobLogById(Long jobLogId) - { + public SysJobLog selectJobLogById(Long jobLogId) { return jobLogMapper.selectJobLogById(jobLogId); } /** * 新增任务日志 - * + * * @param jobLog 调度日志信息 */ @Override - public void addJobLog(SysJobLog jobLog) - { + public void addJobLog(SysJobLog jobLog) { jobLogMapper.insertJobLog(jobLog); } /** * 批量删除调度日志信息 - * + * * @param logIds 需要删除的数据ID * @return 结果 */ @Override - public int deleteJobLogByIds(Long[] logIds) - { + public int deleteJobLogByIds(Long[] logIds) { return jobLogMapper.deleteJobLogByIds(logIds); } /** * 删除任务日志 - * + * * @param jobId 调度日志ID */ @Override - public int deleteJobLogById(Long jobId) - { + public int deleteJobLogById(Long jobId) { return jobLogMapper.deleteJobLogById(jobId); } @@ -80,8 +75,7 @@ public class SysJobLogServiceImpl implements ISysJobLogService * 清空任务日志 */ @Override - public void cleanJobLog() - { + public void cleanJobLog() { jobLogMapper.cleanJobLog(); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java index 71540b365..c18e989b2 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java @@ -1,14 +1,5 @@ package com.ruoyi.quartz.service.impl; -import java.util.List; -import javax.annotation.PostConstruct; -import org.quartz.JobDataMap; -import org.quartz.JobKey; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.exception.job.TaskException; import com.ruoyi.quartz.domain.SysJob; @@ -16,15 +7,24 @@ import com.ruoyi.quartz.mapper.SysJobMapper; import com.ruoyi.quartz.service.ISysJobService; import com.ruoyi.quartz.util.CronUtils; import com.ruoyi.quartz.util.ScheduleUtils; +import org.quartz.JobDataMap; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.PostConstruct; +import java.util.List; /** * 定时任务调度信息 服务层 - * + * * @author ruoyi */ @Service -public class SysJobServiceImpl implements ISysJobService -{ +public class SysJobServiceImpl implements ISysJobService { @Autowired private Scheduler scheduler; @@ -35,55 +35,49 @@ public class SysJobServiceImpl implements ISysJobService * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) */ @PostConstruct - public void init() throws SchedulerException, TaskException - { + public void init() throws SchedulerException, TaskException { scheduler.clear(); List jobList = jobMapper.selectJobAll(); - for (SysJob job : jobList) - { + for (SysJob job : jobList) { ScheduleUtils.createScheduleJob(scheduler, job); } } /** * 获取quartz调度器的计划任务列表 - * + * * @param job 调度信息 * @return */ @Override - public List selectJobList(SysJob job) - { + public List selectJobList(SysJob job) { return jobMapper.selectJobList(job); } /** * 通过调度任务ID查询调度信息 - * + * * @param jobId 调度任务ID * @return 调度任务对象信息 */ @Override - public SysJob selectJobById(Long jobId) - { + public SysJob selectJobById(Long jobId) { return jobMapper.selectJobById(jobId); } /** * 暂停任务 - * + * * @param job 调度信息 */ @Override @Transactional(rollbackFor = Exception.class) - public int pauseJob(SysJob job) throws SchedulerException - { + public int pauseJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); int rows = jobMapper.updateJob(job); - if (rows > 0) - { + if (rows > 0) { scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -91,19 +85,17 @@ public class SysJobServiceImpl implements ISysJobService /** * 恢复任务 - * + * * @param job 调度信息 */ @Override @Transactional(rollbackFor = Exception.class) - public int resumeJob(SysJob job) throws SchedulerException - { + public int resumeJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); int rows = jobMapper.updateJob(job); - if (rows > 0) - { + if (rows > 0) { scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -111,18 +103,16 @@ public class SysJobServiceImpl implements ISysJobService /** * 删除任务后,所对应的trigger也将被删除 - * + * * @param job 调度信息 */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteJob(SysJob job) throws SchedulerException - { + public int deleteJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); int rows = jobMapper.deleteJobById(jobId); - if (rows > 0) - { + if (rows > 0) { scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -130,16 +120,14 @@ public class SysJobServiceImpl implements ISysJobService /** * 批量删除调度信息 - * + * * @param jobIds 需要删除的任务ID * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public void deleteJobByIds(Long[] jobIds) throws SchedulerException - { - for (Long jobId : jobIds) - { + public void deleteJobByIds(Long[] jobIds) throws SchedulerException { + for (Long jobId : jobIds) { SysJob job = jobMapper.selectJobById(jobId); deleteJob(job); } @@ -147,21 +135,17 @@ public class SysJobServiceImpl implements ISysJobService /** * 任务调度状态修改 - * + * * @param job 调度信息 */ @Override @Transactional(rollbackFor = Exception.class) - public int changeStatus(SysJob job) throws SchedulerException - { + public int changeStatus(SysJob job) throws SchedulerException { int rows = 0; String status = job.getStatus(); - if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) - { + if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) { rows = resumeJob(job); - } - else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) - { + } else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) { rows = pauseJob(job); } return rows; @@ -169,13 +153,12 @@ public class SysJobServiceImpl implements ISysJobService /** * 立即运行任务 - * + * * @param job 调度信息 */ @Override @Transactional(rollbackFor = Exception.class) - public boolean run(SysJob job) throws SchedulerException - { + public boolean run(SysJob job) throws SchedulerException { boolean result = false; Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); @@ -184,8 +167,7 @@ public class SysJobServiceImpl implements ISysJobService JobDataMap dataMap = new JobDataMap(); dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties); JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); - if (scheduler.checkExists(jobKey)) - { + if (scheduler.checkExists(jobKey)) { result = true; scheduler.triggerJob(jobKey, dataMap); } @@ -194,17 +176,15 @@ public class SysJobServiceImpl implements ISysJobService /** * 新增任务 - * + * * @param job 调度信息 调度信息 */ @Override @Transactional(rollbackFor = Exception.class) - public int insertJob(SysJob job) throws SchedulerException, TaskException - { + public int insertJob(SysJob job) throws SchedulerException, TaskException { job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); int rows = jobMapper.insertJob(job); - if (rows > 0) - { + if (rows > 0) { ScheduleUtils.createScheduleJob(scheduler, job); } return rows; @@ -212,17 +192,15 @@ public class SysJobServiceImpl implements ISysJobService /** * 更新任务的时间表达式 - * + * * @param job 调度信息 */ @Override @Transactional(rollbackFor = Exception.class) - public int updateJob(SysJob job) throws SchedulerException, TaskException - { + public int updateJob(SysJob job) throws SchedulerException, TaskException { SysJob properties = selectJobById(job.getJobId()); int rows = jobMapper.updateJob(job); - if (rows > 0) - { + if (rows > 0) { updateSchedulerJob(job, properties.getJobGroup()); } return rows; @@ -230,17 +208,15 @@ public class SysJobServiceImpl implements ISysJobService /** * 更新任务 - * - * @param job 任务对象 + * + * @param job 任务对象 * @param jobGroup 任务组名 */ - public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException - { + public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException { Long jobId = job.getJobId(); // 判断是否存在 JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); - if (scheduler.checkExists(jobKey)) - { + if (scheduler.checkExists(jobKey)) { // 防止创建时存在数据问题 先移除,然后在执行创建操作 scheduler.deleteJob(jobKey); } @@ -249,13 +225,12 @@ public class SysJobServiceImpl implements ISysJobService /** * 校验cron表达式是否有效 - * + * * @param cronExpression 表达式 * @return 结果 */ @Override - public boolean checkCronExpressionIsValid(String cronExpression) - { + public boolean checkCronExpressionIsValid(String cronExpression) { return CronUtils.isValid(cronExpression); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java index 25d1ddd02..24427675c 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -1,28 +1,24 @@ package com.ruoyi.quartz.task; -import org.springframework.stereotype.Component; import com.ruoyi.common.utils.StringUtils; +import org.springframework.stereotype.Component; /** * 定时任务调度测试 - * + * * @author ruoyi */ @Component("ryTask") -public class RyTask -{ - public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) - { +public class RyTask { + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); } - public void ryParams(String params) - { + public void ryParams(String params) { System.out.println("执行有参方法:" + params); } - public void ryNoParams() - { + public void ryNoParams() { System.out.println("执行无参方法"); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java new file mode 100644 index 000000000..b667cf892 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java @@ -0,0 +1,112 @@ +package com.ruoyi.quartz.task; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.quartz.domain.DailySale; +import com.ruoyi.quartz.domain.DailySaleCustomer; +import com.ruoyi.quartz.domain.DailySaleProduct; +import com.ruoyi.quartz.dto.DailySaleCusDTO; +import com.ruoyi.quartz.dto.DailySaleDTO; +import com.ruoyi.quartz.dto.DailySaleProdDTO; +import com.ruoyi.quartz.mapper.DailySaleCustomerMapper; +import com.ruoyi.quartz.mapper.DailySaleMapper; +import com.ruoyi.quartz.mapper.DailySaleProductMapper; +import com.ruoyi.xkt.mapper.StoreProductStorageMapper; +import com.ruoyi.xkt.mapper.StoreSaleDetailMapper; +import com.ruoyi.xkt.mapper.StoreSaleMapper; +import lombok.RequiredArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 鞋库通定时任务 + * + * @author ruoyi + */ +@Component("xktTask") +@RequiredArgsConstructor +public class XktTask { + + final DailySaleMapper dailySaleMapper; + final StoreSaleMapper saleMapper; + final StoreSaleDetailMapper saleDetailMapper; + final StoreProductStorageMapper storageMapper; + final DailySaleCustomerMapper dailySaleCusMapper; + final DailySaleProductMapper dailySaleProdMapper; + + /** + * 每晚1点同步档口销售数据 + */ + @Transactional + public void dailySale() { + // 使用LocalDate获取当前日期前一天,并转为 Date 格式 + final Date yesterday = Date.from(LocalDate.now().minusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); + // 先检查是否有该天的销售数据,若有则先删除,保证数据唯一性 + List existList = this.dailySaleMapper.selectList(new LambdaQueryWrapper() + .eq(DailySale::getVoucherDate, yesterday).eq(DailySale::getDelFlag, Constants.UNDELETED)); + if (CollectionUtils.isNotEmpty(existList)) { + this.dailySaleMapper.deleteByIds(existList.stream().map(DailySale::getId).collect(Collectors.toList())); + } + // 查询当前的销售数据 + List saleList = this.dailySaleMapper.selectDailySale(yesterday); + if (CollectionUtils.isEmpty(saleList)) { + return; + } + this.dailySaleMapper.insert(saleList.stream().map(x -> BeanUtil.toBean(x, DailySale.class) + .setVoucherDate(yesterday)).collect(Collectors.toList())); + } + + /** + * 每晚1点30分同步档口客户销售数据 + */ + @Transactional + public void dailySaleCustomer() { + // 使用LocalDate获取当前日期前一天,并转为 Date 格式 + final Date yesterday = Date.from(LocalDate.now().minusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); + // 先检查是否有该天的销售数据,若有则先删除,保证数据唯一性 + List existList = this.dailySaleCusMapper.selectList(new LambdaQueryWrapper() + .eq(DailySaleCustomer::getVoucherDate, yesterday).eq(DailySaleCustomer::getDelFlag, Constants.UNDELETED)); + if (CollectionUtils.isNotEmpty(existList)) { + this.dailySaleCusMapper.deleteByIds(existList.stream().map(DailySaleCustomer::getId).collect(Collectors.toList())); + } + // 查询当前的客户销售数据 + List cusSaleList = this.dailySaleCusMapper.selectDailySale(yesterday); + if (CollectionUtils.isEmpty(cusSaleList)) { + return; + } + this.dailySaleCusMapper.insert(cusSaleList.stream().map(x -> BeanUtil.toBean(x, DailySaleCustomer.class) + .setVoucherDate(yesterday)).collect(Collectors.toList())); + } + + /** + * 每晚2点同步档口商品销售数据 + */ + @Transactional + public void dailySaleProduct() { + // 使用LocalDate获取当前日期前一天,并转为 Date 格式 + final Date yesterday = Date.from(LocalDate.now().minusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); + // 先检查是否有该天的销售数据,若有则先删除,保证数据唯一性 + List existList = this.dailySaleProdMapper.selectList(new LambdaQueryWrapper() + .eq(DailySaleProduct::getVoucherDate, yesterday).eq(DailySaleProduct::getDelFlag, Constants.UNDELETED)); + if (CollectionUtils.isNotEmpty(existList)) { + this.dailySaleProdMapper.deleteByIds(existList.stream().map(DailySaleProduct::getId).collect(Collectors.toList())); + } + // 查询档口商品的销售数据 + List saleList = this.dailySaleProdMapper.selectDailySale(yesterday); + if (CollectionUtils.isEmpty(saleList)) { + return; + } + this.dailySaleProdMapper.insert(saleList.stream().map(x -> BeanUtil.toBean(x, DailySaleProduct.class) + .setVoucherDate(yesterday)).collect(Collectors.toList())); + + } + +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java index fd652d677..809be0ec3 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java @@ -1,11 +1,5 @@ package com.ruoyi.quartz.util; -import java.util.Date; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.utils.ExceptionUtil; @@ -15,14 +9,20 @@ import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.quartz.domain.SysJob; import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.service.ISysJobLogService; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; /** * 抽象quartz调用 * * @author ruoyi */ -public abstract class AbstractQuartzJob implements Job -{ +public abstract class AbstractQuartzJob implements Job { private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); /** @@ -31,21 +31,16 @@ public abstract class AbstractQuartzJob implements Job private static ThreadLocal threadLocal = new ThreadLocal<>(); @Override - public void execute(JobExecutionContext context) throws JobExecutionException - { + public void execute(JobExecutionContext context) throws JobExecutionException { SysJob sysJob = new SysJob(); BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); - try - { + try { before(context, sysJob); - if (sysJob != null) - { + if (sysJob != null) { doExecute(context, sysJob); } after(context, sysJob, null); - } - catch (Exception e) - { + } catch (Exception e) { log.error("任务执行异常 - :", e); after(context, sysJob, e); } @@ -55,10 +50,9 @@ public abstract class AbstractQuartzJob implements Job * 执行前 * * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 + * @param sysJob 系统计划任务 */ - protected void before(JobExecutionContext context, SysJob sysJob) - { + protected void before(JobExecutionContext context, SysJob sysJob) { threadLocal.set(new Date()); } @@ -66,10 +60,9 @@ public abstract class AbstractQuartzJob implements Job * 执行后 * * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 + * @param sysJob 系统计划任务 */ - protected void after(JobExecutionContext context, SysJob sysJob, Exception e) - { + protected void after(JobExecutionContext context, SysJob sysJob, Exception e) { Date startTime = threadLocal.get(); threadLocal.remove(); @@ -81,14 +74,11 @@ public abstract class AbstractQuartzJob implements Job sysJobLog.setStopTime(new Date()); long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒"); - if (e != null) - { + if (e != null) { sysJobLog.setStatus(Constants.FAIL); String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); sysJobLog.setExceptionInfo(errorMsg); - } - else - { + } else { sysJobLog.setStatus(Constants.SUCCESS); } @@ -100,7 +90,7 @@ public abstract class AbstractQuartzJob implements Job * 执行方法,由子类重载 * * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 + * @param sysJob 系统计划任务 * @throws Exception 执行过程中的异常 */ protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java index 6826787a6..ed34c147f 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java @@ -1,25 +1,23 @@ package com.ruoyi.quartz.util; +import org.quartz.CronExpression; + import java.text.ParseException; import java.util.Date; -import org.quartz.CronExpression; /** * cron表达式工具类 - * - * @author ruoyi * + * @author ruoyi */ -public class CronUtils -{ +public class CronUtils { /** * 返回一个布尔值代表一个给定的Cron表达式的有效性 * * @param cronExpression Cron表达式 * @return boolean 表达式是否有效 */ - public static boolean isValid(String cronExpression) - { + public static boolean isValid(String cronExpression) { return CronExpression.isValidExpression(cronExpression); } @@ -29,15 +27,11 @@ public class CronUtils * @param cronExpression Cron表达式 * @return String 无效时返回表达式错误描述,如果有效返回null */ - public static String getInvalidMessage(String cronExpression) - { - try - { + public static String getInvalidMessage(String cronExpression) { + try { new CronExpression(cronExpression); return null; - } - catch (ParseException pe) - { + } catch (ParseException pe) { return pe.getMessage(); } } @@ -48,15 +42,11 @@ public class CronUtils * @param cronExpression Cron表达式 * @return Date 下次Cron表达式执行时间 */ - public static Date getNextExecution(String cronExpression) - { - try - { + public static Date getNextExecution(String cronExpression) { + try { CronExpression cron = new CronExpression(cronExpression); return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); - } - catch (ParseException e) - { + } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java index 86fdb927f..dc608a490 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java @@ -1,39 +1,35 @@ package com.ruoyi.quartz.util; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.quartz.domain.SysJob; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.quartz.domain.SysJob; /** * 任务执行工具 * * @author ruoyi */ -public class JobInvokeUtil -{ +public class JobInvokeUtil { /** * 执行方法 * * @param sysJob 系统任务 */ - public static void invokeMethod(SysJob sysJob) throws Exception - { + public static void invokeMethod(SysJob sysJob) throws Exception { String invokeTarget = sysJob.getInvokeTarget(); String beanName = getBeanName(invokeTarget); String methodName = getMethodName(invokeTarget); List methodParams = getMethodParams(invokeTarget); - if (!isValidClassName(beanName)) - { + if (!isValidClassName(beanName)) { Object bean = SpringUtils.getBean(beanName); invokeMethod(bean, methodName, methodParams); - } - else - { + } else { Object bean = Class.forName(beanName).getDeclaredConstructor().newInstance(); invokeMethod(bean, methodName, methodParams); } @@ -42,21 +38,17 @@ public class JobInvokeUtil /** * 调用任务方法 * - * @param bean 目标对象 - * @param methodName 方法名称 + * @param bean 目标对象 + * @param methodName 方法名称 * @param methodParams 方法参数 */ private static void invokeMethod(Object bean, String methodName, List methodParams) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, - InvocationTargetException - { - if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) - { + InvocationTargetException { + if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) { Method method = bean.getClass().getMethod(methodName, getMethodParamsType(methodParams)); method.invoke(bean, getMethodParamsValue(methodParams)); - } - else - { + } else { Method method = bean.getClass().getMethod(methodName); method.invoke(bean); } @@ -64,81 +56,70 @@ public class JobInvokeUtil /** * 校验是否为为class包名 - * + * * @param invokeTarget 名称 * @return true是 false否 */ - public static boolean isValidClassName(String invokeTarget) - { + public static boolean isValidClassName(String invokeTarget) { return StringUtils.countMatches(invokeTarget, ".") > 1; } /** * 获取bean名称 - * + * * @param invokeTarget 目标字符串 * @return bean名称 */ - public static String getBeanName(String invokeTarget) - { + public static String getBeanName(String invokeTarget) { String beanName = StringUtils.substringBefore(invokeTarget, "("); return StringUtils.substringBeforeLast(beanName, "."); } /** * 获取bean方法 - * + * * @param invokeTarget 目标字符串 * @return method方法 */ - public static String getMethodName(String invokeTarget) - { + public static String getMethodName(String invokeTarget) { String methodName = StringUtils.substringBefore(invokeTarget, "("); return StringUtils.substringAfterLast(methodName, "."); } /** * 获取method方法参数相关列表 - * + * * @param invokeTarget 目标字符串 * @return method方法相关参数列表 */ - public static List getMethodParams(String invokeTarget) - { + public static List getMethodParams(String invokeTarget) { String methodStr = StringUtils.substringBetweenLast(invokeTarget, "(", ")"); - if (StringUtils.isEmpty(methodStr)) - { + if (StringUtils.isEmpty(methodStr)) { return null; } String[] methodParams = methodStr.split(",(?=([^\"']*[\"'][^\"']*[\"'])*[^\"']*$)"); List classs = new LinkedList<>(); - for (int i = 0; i < methodParams.length; i++) - { + for (int i = 0; i < methodParams.length; i++) { String str = StringUtils.trimToEmpty(methodParams[i]); // String字符串类型,以'或"开头 - if (StringUtils.startsWithAny(str, "'", "\"")) - { - classs.add(new Object[] { StringUtils.substring(str, 1, str.length() - 1), String.class }); + if (StringUtils.startsWithAny(str, "'", "\"")) { + classs.add(new Object[]{StringUtils.substring(str, 1, str.length() - 1), String.class}); } // boolean布尔类型,等于true或者false - else if ("true".equalsIgnoreCase(str) || "false".equalsIgnoreCase(str)) - { - classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); + else if ("true".equalsIgnoreCase(str) || "false".equalsIgnoreCase(str)) { + classs.add(new Object[]{Boolean.valueOf(str), Boolean.class}); } // long长整形,以L结尾 - else if (StringUtils.endsWith(str, "L")) - { - classs.add(new Object[] { Long.valueOf(StringUtils.substring(str, 0, str.length() - 1)), Long.class }); + else if (StringUtils.endsWith(str, "L")) { + classs.add(new Object[]{Long.valueOf(StringUtils.substring(str, 0, str.length() - 1)), Long.class}); } // double浮点类型,以D结尾 - else if (StringUtils.endsWith(str, "D")) - { - classs.add(new Object[] { Double.valueOf(StringUtils.substring(str, 0, str.length() - 1)), Double.class }); + else if (StringUtils.endsWith(str, "D")) { + classs.add(new Object[]{Double.valueOf(StringUtils.substring(str, 0, str.length() - 1)), Double.class}); } // 其他类型归类为整形 - else - { - classs.add(new Object[] { Integer.valueOf(str), Integer.class }); + else { + classs.add(new Object[]{Integer.valueOf(str), Integer.class}); } } return classs; @@ -146,16 +127,14 @@ public class JobInvokeUtil /** * 获取参数类型 - * + * * @param methodParams 参数相关列表 * @return 参数类型列表 */ - public static Class[] getMethodParamsType(List methodParams) - { + public static Class[] getMethodParamsType(List methodParams) { Class[] classs = new Class[methodParams.size()]; int index = 0; - for (Object[] os : methodParams) - { + for (Object[] os : methodParams) { classs[index] = (Class) os[1]; index++; } @@ -164,16 +143,14 @@ public class JobInvokeUtil /** * 获取参数值 - * + * * @param methodParams 参数相关列表 * @return 参数值列表 */ - public static Object[] getMethodParamsValue(List methodParams) - { + public static Object[] getMethodParamsValue(List methodParams) { Object[] classs = new Object[methodParams.size()]; int index = 0; - for (Object[] os : methodParams) - { + for (Object[] os : methodParams) { classs[index] = (Object) os[0]; index++; } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java index 96a6dcf8e..c9b109949 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java @@ -1,21 +1,18 @@ package com.ruoyi.quartz.util; +import com.ruoyi.quartz.domain.SysJob; import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; -import com.ruoyi.quartz.domain.SysJob; /** * 定时任务处理(禁止并发执行) - * - * @author ruoyi * + * @author ruoyi */ @DisallowConcurrentExecution -public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob -{ +public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob { @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception { JobInvokeUtil.invokeMethod(sysJob); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java index 87a06bc13..42eded290 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java @@ -1,19 +1,16 @@ package com.ruoyi.quartz.util; -import org.quartz.JobExecutionContext; import com.ruoyi.quartz.domain.SysJob; +import org.quartz.JobExecutionContext; /** * 定时任务处理(允许并发执行) - * - * @author ruoyi * + * @author ruoyi */ -public class QuartzJobExecution extends AbstractQuartzJob -{ +public class QuartzJobExecution extends AbstractQuartzJob { @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception { JobInvokeUtil.invokeMethod(sysJob); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java index ab829e690..759be3225 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java @@ -1,15 +1,5 @@ package com.ruoyi.quartz.util; -import org.quartz.CronScheduleBuilder; -import org.quartz.CronTrigger; -import org.quartz.Job; -import org.quartz.JobBuilder; -import org.quartz.JobDetail; -import org.quartz.JobKey; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.TriggerBuilder; -import org.quartz.TriggerKey; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.exception.job.TaskException; @@ -17,23 +7,21 @@ import com.ruoyi.common.exception.job.TaskException.Code; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.quartz.domain.SysJob; +import org.quartz.*; /** * 定时任务工具类 - * - * @author ruoyi * + * @author ruoyi */ -public class ScheduleUtils -{ +public class ScheduleUtils { /** * 得到quartz任务类 * * @param sysJob 执行计划 * @return 具体执行任务类 */ - private static Class getQuartzJobClass(SysJob sysJob) - { + private static Class getQuartzJobClass(SysJob sysJob) { boolean isConcurrent = "0".equals(sysJob.getConcurrent()); return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; } @@ -41,24 +29,21 @@ public class ScheduleUtils /** * 构建任务触发对象 */ - public static TriggerKey getTriggerKey(Long jobId, String jobGroup) - { + public static TriggerKey getTriggerKey(Long jobId, String jobGroup) { return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); } /** * 构建任务键对象 */ - public static JobKey getJobKey(Long jobId, String jobGroup) - { + public static JobKey getJobKey(Long jobId, String jobGroup) { return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); } /** * 创建定时任务 */ - public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException - { + public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException { Class jobClass = getQuartzJobClass(job); // 构建job信息 Long jobId = job.getJobId(); @@ -77,22 +62,19 @@ public class ScheduleUtils jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); // 判断是否存在 - if (scheduler.checkExists(getJobKey(jobId, jobGroup))) - { + if (scheduler.checkExists(getJobKey(jobId, jobGroup))) { // 防止创建时存在数据问题 先移除,然后在执行创建操作 scheduler.deleteJob(getJobKey(jobId, jobGroup)); } // 判断任务是否过期 - if (StringUtils.isNotNull(CronUtils.getNextExecution(job.getCronExpression()))) - { + if (StringUtils.isNotNull(CronUtils.getNextExecution(job.getCronExpression()))) { // 执行调度任务 scheduler.scheduleJob(jobDetail, trigger); } // 暂停任务 - if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) - { + if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) { scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } } @@ -101,10 +83,8 @@ public class ScheduleUtils * 设置定时任务策略 */ public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) - throws TaskException - { - switch (job.getMisfirePolicy()) - { + throws TaskException { + switch (job.getMisfirePolicy()) { case ScheduleConstants.MISFIRE_DEFAULT: return cb; case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: @@ -121,16 +101,14 @@ public class ScheduleUtils /** * 检查包名是否为白名单配置 - * + * * @param invokeTarget 目标字符串 * @return 结果 */ - public static boolean whiteList(String invokeTarget) - { + public static boolean whiteList(String invokeTarget) { String packageName = StringUtils.substringBefore(invokeTarget, "("); int count = StringUtils.countMatches(packageName, "."); - if (count > 1) - { + if (count > 1) { return StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR); } Object obj = SpringUtils.getBean(StringUtils.split(invokeTarget, ".")[0]); diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleCustomerMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleCustomerMapper.xml new file mode 100644 index 000000000..1b68e43cd --- /dev/null +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleCustomerMapper.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleMapper.xml new file mode 100644 index 000000000..d3f96596d --- /dev/null +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleMapper.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleProductMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleProductMapper.xml new file mode 100644 index 000000000..8242e52fd --- /dev/null +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/DailySaleProductMapper.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml index 5ed72647b..4e3d6bd00 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml @@ -1,94 +1,103 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time - from sys_job_log + + + + + + + + + + + + + select job_log_id, + job_name, + job_group, + invoke_target, + job_message, + status, + exception_info, + create_time + from sys_job_log - - - - - - - - - delete from sys_job_log where job_log_id = #{jobLogId} - - - - delete from sys_job_log where job_log_id in - - #{jobLogId} - - - - + + + + + + + + + delete + from sys_job_log + where job_log_id = #{jobLogId} + + + + delete from sys_job_log where job_log_id in + + #{jobLogId} + + + + truncate table sys_job_log - - - insert into sys_job_log( - job_log_id, - job_name, - job_group, - invoke_target, - job_message, - status, - exception_info, - create_time - )values( - #{jobLogId}, - #{jobName}, - #{jobGroup}, - #{invokeTarget}, - #{jobMessage}, - #{status}, - #{exceptionInfo}, - sysdate() - ) - + + + insert into sys_job_log( + job_log_id, + job_name, + job_group, + invoke_target, + job_message, + status, + exception_info, + create_time + )values( + #{jobLogId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{jobMessage}, + #{status}, + #{exceptionInfo}, + sysdate() + ) + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml index 69233bdf7..352e00cde 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml @@ -1,111 +1,123 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark - from sys_job + + + + + + + + + + + + + + + + + + select job_id, + job_name, + job_group, + invoke_target, + cron_expression, + misfire_policy, + concurrent, + status, + create_by, + create_time, + remark + from sys_job - - - - - - - - - delete from sys_job where job_id = #{jobId} - - - - delete from sys_job where job_id in - - #{jobId} - - - - - update sys_job - - job_name = #{jobName}, - job_group = #{jobGroup}, - invoke_target = #{invokeTarget}, - cron_expression = #{cronExpression}, - misfire_policy = #{misfirePolicy}, - concurrent = #{concurrent}, - status = #{status}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where job_id = #{jobId} - - - - insert into sys_job( - job_id, - job_name, - job_group, - invoke_target, - cron_expression, - misfire_policy, - concurrent, - status, - remark, - create_by, - create_time - )values( - #{jobId}, - #{jobName}, - #{jobGroup}, - #{invokeTarget}, - #{cronExpression}, - #{misfirePolicy}, - #{concurrent}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - + + + + + + + + + delete + from sys_job + where job_id = #{jobId} + + + + delete from sys_job where job_id in + + #{jobId} + + + + + update sys_job + + job_name = #{jobName}, + job_group = #{jobGroup}, + invoke_target = #{invokeTarget}, + cron_expression = #{cronExpression}, + misfire_policy = #{misfirePolicy}, + concurrent = #{concurrent}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where job_id = #{jobId} + + + + insert into sys_job( + job_id, + job_name, + job_group, + invoke_target, + cron_expression, + misfire_policy, + concurrent, + status, + remark, + create_by, + create_time + )values( + #{jobId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{cronExpression}, + #{misfirePolicy}, + #{concurrent}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + \ No newline at end of file diff --git a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreProductStorage.java b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreProductStorage.java index 900681671..e661d7d4c 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreProductStorage.java +++ b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreProductStorage.java @@ -1,6 +1,7 @@ package com.ruoyi.xkt.domain; import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.XktBaseEntity; import lombok.Data; @@ -10,6 +11,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import java.math.BigDecimal; +import java.util.Date; /** * 档口商品入库对象 store_product_storage @@ -61,6 +63,12 @@ public class StoreProductStorage extends XktBaseEntity { * 操作人名称 */ private String operatorName; + /** + * 单据日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "单据日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date voucherDate; @Override public String toString() { diff --git a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleDetail.java b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleDetail.java index f25cf801c..3ac1b2b35 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleDetail.java +++ b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleDetail.java @@ -1,6 +1,7 @@ package com.ruoyi.xkt.domain; import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.XktBaseEntity; import lombok.Data; @@ -10,6 +11,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import java.math.BigDecimal; +import java.util.Date; /** * 档口销售明细对象 store_sale_detail @@ -91,6 +93,11 @@ public class StoreSaleDetail extends XktBaseEntity { */ @Excel(name = "条码") private String sns; + /** + * 单据日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date voucherDate; @Override public String toString() { diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageServiceImpl.java index 4b0fa8dda..a57cb55ab 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductStorageServiceImpl.java @@ -89,7 +89,8 @@ public class StoreProductStorageServiceImpl implements IStoreProductStorageServi LoginUser loginUser = SecurityUtils.getLoginUser(); // 新增档口商品入库 StoreProductStorage storeProdStorage = BeanUtil.toBean(storeProdStorageDTO, StoreProductStorage.class) - .setCode(code).setQuantity(totalNum).setProduceAmount(produceAmount).setOperatorId(loginUser.getUserId()).setOperatorName(loginUser.getUsername()); + .setCode(code).setQuantity(totalNum).setProduceAmount(produceAmount).setOperatorId(loginUser.getUserId()) + .setOperatorName(loginUser.getUsername()).setVoucherDate(DateUtils.getNowDate()); int count = this.storageMapper.insert(storeProdStorage); // 新增档口商品入库明细 List detailList = storeProdStorageDTO.getDetailList().stream().map(x -> BeanUtil.toBean(x, StoreProductStorageDetail.class)