测试基本完成,待编写逻辑
This commit is contained in:
@@ -35,4 +35,12 @@ public class AlarmController {
|
||||
log.info("离开[上传位置信息接口],出参:{}", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动确认工作日
|
||||
*/
|
||||
@GetMapping("/checkWorkDay")
|
||||
public void checkWorkDay() {
|
||||
alarmService.checkWorkDay();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.kkz.kpersonalre.entity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDate;
|
||||
import java.sql.Blob;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.Builder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
/**
|
||||
* <p>
|
||||
* 日期是否节假日表
|
||||
@@ -23,9 +26,10 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Builder
|
||||
@TableName("tb_date_holiday")
|
||||
public class TbDateHolidayEntity extends BaseEntity {
|
||||
@TableName("tb_date_weekday")
|
||||
public class TbDateWeekdayEntity extends BaseEntity implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -37,6 +41,6 @@ public class TbDateHolidayEntity extends BaseEntity {
|
||||
* 是否节假日 0否 1是
|
||||
*/
|
||||
@TableField("holidayFlag")
|
||||
private Blob holidayFlag;
|
||||
private Boolean holidayFlag;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.kkz.kpersonalre.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.kkz.kpersonalre.entity.TbDateHolidayEntity;
|
||||
import com.kkz.kpersonalre.entity.TbDateWeekdayEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@@ -13,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @since 2025-03-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbDateHolidayMapper extends BaseMapper<TbDateHolidayEntity> {
|
||||
public interface TbDateWeekdayMapper extends BaseMapper<TbDateWeekdayEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.kkz.kpersonalre.scheduled;
|
||||
|
||||
import com.kkz.kpersonalre.service.AlarmService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
/**
|
||||
* @program: kpersonalre
|
||||
* @description: 定时任务
|
||||
* @author: 孔成文
|
||||
* @createTime: 2025-03-29 21:23
|
||||
**/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@EnableScheduling
|
||||
public class ScheduledTask {
|
||||
|
||||
private final AlarmService alarmService;
|
||||
|
||||
public ScheduledTask(AlarmService alarmService) {
|
||||
this.alarmService = alarmService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每天0点整运行的定时任务
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void dailyTask() {
|
||||
log.info("定时任务--[查询工作日]--开始");
|
||||
alarmService.checkWorkDay();
|
||||
log.info("定时任务--[查询工作日]--结束");
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,9 @@ public interface AlarmService {
|
||||
* @return
|
||||
*/
|
||||
R<String> uploadLocation(String location);
|
||||
|
||||
/**
|
||||
* 查询工作日
|
||||
*/
|
||||
void checkWorkDay();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.kkz.kpersonalre.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.kkz.kpersonalre.api.R;
|
||||
import com.kkz.kpersonalre.entity.TbDateWeekdayEntity;
|
||||
import com.kkz.kpersonalre.entity.TbLocationConfigEntity;
|
||||
import com.kkz.kpersonalre.entity.TbLocationUploadEntity;
|
||||
import com.kkz.kpersonalre.mapper.TbAlarmClockConfigMapper;
|
||||
import com.kkz.kpersonalre.mapper.TbAlarmPersonConfigMapper;
|
||||
import com.kkz.kpersonalre.mapper.TbDateHolidayMapper;
|
||||
import com.kkz.kpersonalre.mapper.TbDateWeekdayMapper;
|
||||
import com.kkz.kpersonalre.mapper.TbForceWeekdayConfigMapper;
|
||||
import com.kkz.kpersonalre.mapper.TbLocationConfigMapper;
|
||||
import com.kkz.kpersonalre.mapper.TbLocationUploadMapper;
|
||||
@@ -16,6 +22,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @program: KPersonal
|
||||
* @description:
|
||||
@@ -33,7 +42,7 @@ public class AlarmServiceImpl implements AlarmService {
|
||||
private TbAlarmPersonConfigMapper alarmPersonConfigMapper;
|
||||
|
||||
@Autowired
|
||||
private TbDateHolidayMapper dateHolidayMapper;
|
||||
private TbDateWeekdayMapper dateWeekdayMapper;
|
||||
|
||||
@Autowired
|
||||
private TbForceWeekdayConfigMapper forceWeekdayConfigMapper;
|
||||
@@ -66,4 +75,23 @@ public class AlarmServiceImpl implements AlarmService {
|
||||
.setLocationConfigId(locationConfigEntity.getId().intValue()));
|
||||
return R.ok("上传成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询工作日
|
||||
*/
|
||||
@Override
|
||||
public void checkWorkDay() {
|
||||
|
||||
String s = HttpUtil.get("https://api.jiejiariapi.com/v1/workdays/" + DateUtil.year(DateUtil.nextWeek()));
|
||||
Map<String, Object> map = JSONUtil.toBean(s, HashMap.class);
|
||||
for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
|
||||
TbDateWeekdayEntity dateWeekdayEntity = dateWeekdayMapper.selectOne(new LambdaQueryWrapper<TbDateWeekdayEntity>()
|
||||
.eq(TbDateWeekdayEntity::getDate, stringObjectEntry.getKey()));
|
||||
if (BeanUtil.isEmpty(dateWeekdayEntity)) {
|
||||
dateWeekdayMapper.insert(new TbDateWeekdayEntity()
|
||||
.setDate(LocalDateTimeUtil.parseDate(stringObjectEntry.getKey()))
|
||||
.setHolidayFlag(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user