|
|
@@ -1,7 +1,16 @@
|
|
|
package com.ruoyi.job.task;
|
|
|
|
|
|
+
|
|
|
+import com.ruoyi.logistics.domain.RptFinancialMonthSummary;
|
|
|
+import com.ruoyi.logistics.service.IRptFinancialMonthSummaryService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+
|
|
|
/**
|
|
|
* 月度汇总定时任务
|
|
|
*
|
|
|
@@ -10,10 +19,33 @@ import org.springframework.stereotype.Component;
|
|
|
@Component("financialMonthSummaryTask")
|
|
|
public class FinancialMonthSummaryTask {
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(FinancialMonthSummaryTask.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IRptFinancialMonthSummaryService iRptFinancialMonthSummaryService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每个月月初 执行生成上个月的月度账单
|
|
|
+ * @author zxf
|
|
|
+ */
|
|
|
public void doTask() {
|
|
|
- System.out.println("月度汇总定时任务");
|
|
|
+ logger.info("月度汇总上单定时任务开始");
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDate lastMonth = today.minusMonths(1);
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM");
|
|
|
+ // 格式化上个月日期为字符串
|
|
|
+ String formattedDate = lastMonth.format(formatter);
|
|
|
+ RptFinancialMonthSummary rptFinancialMonthSummary= new RptFinancialMonthSummary();
|
|
|
+ rptFinancialMonthSummary.setSummaryMonth(formattedDate);
|
|
|
+ iRptFinancialMonthSummaryService.insertRptFinancialMonthSummary(rptFinancialMonthSummary);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每次调账时 都会重新生成该供应商的月度账单
|
|
|
+ * 这里的定时任务 作为方便测试
|
|
|
+ * @author zxf
|
|
|
+ */
|
|
|
public void doTask(Integer deptName, String month) {
|
|
|
System.out.println("月度汇总定时任务,部门ID:" + deptName + ", 月份:" + month);
|
|
|
}
|