|
@@ -17,8 +17,13 @@
|
|
|
|
|
|
package com.qunzhixinxi.hnqz.daemon.quartz.task;
|
|
package com.qunzhixinxi.hnqz.daemon.quartz.task;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.constants.HnqzQuartzEnum;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.constants.HnqzQuartzEnum;
|
|
|
|
+import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleMemberSettleSameAmountInSeveralMonths;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.WmTaskType;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.WmTaskType;
|
|
|
|
+import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleMemberSettleSameAmountInSeveralMonthsMapper;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.service.*;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.service.*;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.zhuqu.ZhuaquTest;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.zhuqu.ZhuaquTest;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
@@ -27,7 +32,13 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.LocalTime;
|
|
|
|
+import java.time.temporal.TemporalAdjuster;
|
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author 郑健楠
|
|
* @author 郑健楠
|
|
@@ -37,12 +48,14 @@ import java.time.LocalDateTime;
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class SpringBeanTaskDemo {
|
|
public class SpringBeanTaskDemo {
|
|
private final WmScorePackageStatusService wmScorePackageStatusService;
|
|
private final WmScorePackageStatusService wmScorePackageStatusService;
|
|
|
|
+ private final WmScorePackageSettleNoteService scorePackageSettleNoteService;
|
|
private final WmScorePackageService wmScorePackageService;
|
|
private final WmScorePackageService wmScorePackageService;
|
|
private final ZhuaquTest zhuaquTest;
|
|
private final ZhuaquTest zhuaquTest;
|
|
private final WmTaskTypeService wmTaskTypeService;
|
|
private final WmTaskTypeService wmTaskTypeService;
|
|
private final WmTaskService wmTaskService;
|
|
private final WmTaskService wmTaskService;
|
|
private final WmWkArticleService wmWkArticleService;
|
|
private final WmWkArticleService wmWkArticleService;
|
|
private final WmStatisticsService wmStatisticsService;
|
|
private final WmStatisticsService wmStatisticsService;
|
|
|
|
+ private final SingleMemberSettleSameAmountInSeveralMonthsMapper singleMemberSettleSameAmountInSeveralMonthsMapper;
|
|
|
|
|
|
// /**
|
|
// /**
|
|
// * 测试Spring Bean的演示方法
|
|
// * 测试Spring Bean的演示方法
|
|
@@ -85,6 +98,7 @@ public class SpringBeanTaskDemo {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 每日GMVs统计
|
|
* 每日GMVs统计
|
|
|
|
+ *
|
|
* @param para
|
|
* @param para
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -102,7 +116,56 @@ public class SpringBeanTaskDemo {
|
|
return HnqzQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
|
|
return HnqzQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 同一用户,连续多月结算金额相同
|
|
|
|
+ *
|
|
|
|
+ * @param para 参数(月数)
|
|
|
|
+ * @return 运行结果
|
|
|
|
+ */
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ public String singleMemberSettleSameAmountInSeveralMonths(String para) {
|
|
|
|
+ // 校验参数
|
|
|
|
+ if (StrUtil.isBlank(para)) {
|
|
|
|
+ log.error("参数缺失");
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int period = Integer.parseInt(para.trim());
|
|
|
|
+
|
|
|
|
+ if (period < 2) {
|
|
|
|
+ log.error("参数错误");
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 计算查询时间
|
|
|
|
+ LocalDate now = LocalDateTime.now().toLocalDate().with(TemporalAdjusters.firstDayOfNextMonth());
|
|
|
|
+ LocalDateTime startTime = LocalDateTime.of(now.minusMonths(period), LocalTime.MIN);
|
|
|
|
+ LocalDateTime endTime = LocalDateTime.of(now, LocalTime.MIN).minusSeconds(1);
|
|
|
|
+
|
|
|
|
+ System.out.println(startTime);
|
|
|
|
+ System.out.println(endTime);
|
|
|
|
+
|
|
|
|
+ log.info("singleMemberSettleSameAmountInSeveralMonths开始于:{},输入参数{}", LocalDateTime.now(), para);
|
|
|
|
+
|
|
|
|
+ List<SingleMemberSettleSameAmountInSeveralMonths> result = scorePackageSettleNoteService.singleMemberSettleSameAmountInSeveralMonths(startTime, endTime);
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(result)) {
|
|
|
|
+ List<SingleMemberSettleSameAmountInSeveralMonths> history = singleMemberSettleSameAmountInSeveralMonthsMapper.selectList(Wrappers.<SingleMemberSettleSameAmountInSeveralMonths>lambdaQuery().between(SingleMemberSettleSameAmountInSeveralMonths::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN), LocalDateTime.of(LocalDate.now(), LocalTime.MAX)));
|
|
|
|
+ // 删除历史记录
|
|
|
|
+ log.warn("删除当期的历史记录:{}", history);
|
|
|
|
+ if (CollUtil.isNotEmpty(history)) {
|
|
|
|
+ List<Integer> ids = history.stream().mapToInt(SingleMemberSettleSameAmountInSeveralMonths::getRecordId).boxed().collect(Collectors.toList());
|
|
|
|
+ singleMemberSettleSameAmountInSeveralMonthsMapper.deleteBatchIds(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result.forEach(e -> {
|
|
|
|
+ e.setPeriod(period);
|
|
|
|
+ singleMemberSettleSameAmountInSeveralMonthsMapper.insert(e);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|