|
@@ -18,6 +18,7 @@
|
|
package com.qunzhixinxi.hnqz.daemon.quartz.task;
|
|
package com.qunzhixinxi.hnqz.daemon.quartz.task;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.bean.copier.CopyOptions;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -25,10 +26,12 @@ import com.qunzhixinxi.hnqz.daemon.quartz.constants.HnqzQuartzEnum;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonth;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonth;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleMemberSettleAmountOverrunInSeveralMonths;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleMemberSettleAmountOverrunInSeveralMonths;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleMemberSettleSameAmountInSeveralMonths;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleMemberSettleSameAmountInSeveralMonths;
|
|
|
|
+import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleMemberWithoutSuchTaskTypesInSeveralMonths;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.WmTaskType;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.WmTaskType;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonthMapper;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonthMapper;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleMemberSettleAmountOverrunInSeveralMonthsMapper;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleMemberSettleAmountOverrunInSeveralMonthsMapper;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleMemberSettleSameAmountInSeveralMonthsMapper;
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleMemberSettleSameAmountInSeveralMonthsMapper;
|
|
|
|
+import com.qunzhixinxi.hnqz.daemon.quartz.mapper.SingleMemberWithoutSuchTaskTypesInSeveralMonthsMapper;
|
|
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;
|
|
@@ -44,6 +47,8 @@ import java.time.LocalTime;
|
|
import java.time.temporal.TemporalAdjuster;
|
|
import java.time.temporal.TemporalAdjuster;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.StringJoiner;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -64,6 +69,7 @@ public class SpringBeanTaskDemo {
|
|
private final SingleMemberSettleSameAmountInSeveralMonthsMapper singleMemberSettleSameAmountInSeveralMonthsMapper;
|
|
private final SingleMemberSettleSameAmountInSeveralMonthsMapper singleMemberSettleSameAmountInSeveralMonthsMapper;
|
|
private final SingleMemberSettleAmountOverrunInSeveralMonthsMapper singleMemberSettleAmountOverrunInSeveralMonthsMapper;
|
|
private final SingleMemberSettleAmountOverrunInSeveralMonthsMapper singleMemberSettleAmountOverrunInSeveralMonthsMapper;
|
|
private final SingleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonthMapper singleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonthMapper;
|
|
private final SingleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonthMapper singleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonthMapper;
|
|
|
|
+ private final SingleMemberWithoutSuchTaskTypesInSeveralMonthsMapper singleMemberWithoutSuchTaskTypesInSeveralMonthsMapper;
|
|
|
|
|
|
// /**
|
|
// /**
|
|
// * 测试Spring Bean的演示方法
|
|
// * 测试Spring Bean的演示方法
|
|
@@ -294,4 +300,75 @@ public class SpringBeanTaskDemo {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 同一用户,连续多月没有指定任务类型
|
|
|
|
+ *
|
|
|
|
+ * @param para 参数(周期和任务类型)
|
|
|
|
+ * @return 运行结果
|
|
|
|
+ */
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ public String singleMemberWithoutSuchTaskTypesInSeveralMonths(String para) {
|
|
|
|
+
|
|
|
|
+ // 校验参数
|
|
|
|
+ if (StrUtil.isBlank(para)) {
|
|
|
|
+ log.error("参数缺失");
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!para.contains(StrUtil.COMMA)) {
|
|
|
|
+ log.error("参数错误");
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> params = StrUtil.split(para, StrUtil.COMMA);
|
|
|
|
+
|
|
|
|
+ if (params.size() < 2) {
|
|
|
|
+ log.error("参数错误");
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int period = Integer.parseInt(params.get(0));
|
|
|
|
+ if (period < 2) {
|
|
|
|
+ log.error("参数错误");
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> typeList = params.subList(1, params.size());
|
|
|
|
+
|
|
|
|
+ // 计算查询时间
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ log.info("singleMemberWithoutSuchTaskTypesInSeveralMonths开始于:{},输入参数{}", LocalDateTime.now(), para);
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> result = wmTaskService.singleMemberWithoutSuchTaskTypesInSeveralMonths(startTime, endTime, typeList);
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(result)) {
|
|
|
|
+ List<SingleMemberWithoutSuchTaskTypesInSeveralMonths> history = singleMemberWithoutSuchTaskTypesInSeveralMonthsMapper.selectList(Wrappers.<SingleMemberWithoutSuchTaskTypesInSeveralMonths>lambdaQuery().between(SingleMemberWithoutSuchTaskTypesInSeveralMonths::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(SingleMemberWithoutSuchTaskTypesInSeveralMonths::getRecordId).boxed().collect(Collectors.toList());
|
|
|
|
+ singleMemberWithoutSuchTaskTypesInSeveralMonthsMapper.deleteBatchIds(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String types = String.join(StrUtil.COMMA, typeList.toArray(new String[0]));
|
|
|
|
+
|
|
|
|
+ result.forEach(e -> {
|
|
|
|
+ SingleMemberWithoutSuchTaskTypesInSeveralMonths singleMemberWithoutSuchTaskTypesInSeveralMonths
|
|
|
|
+ = BeanUtil.mapToBean(e, SingleMemberWithoutSuchTaskTypesInSeveralMonths.class,true, new CopyOptions());
|
|
|
|
+ singleMemberWithoutSuchTaskTypesInSeveralMonths.setPeriod(period);
|
|
|
|
+ singleMemberWithoutSuchTaskTypesInSeveralMonths.setTypeList(types);
|
|
|
|
+ singleMemberWithoutSuchTaskTypesInSeveralMonths.setCreateTime(LocalDateTime.now());
|
|
|
|
+ singleMemberWithoutSuchTaskTypesInSeveralMonthsMapper.insert(singleMemberWithoutSuchTaskTypesInSeveralMonths);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return HnqzQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|