更换获取每年节假日路径

This commit is contained in:
aikai 2024-06-14 12:05:44 +08:00
parent 7121d3bee2
commit 6557d6b502
2 changed files with 12 additions and 4 deletions

View File

@ -214,10 +214,17 @@ public class AttendanceServiceImpl implements AttendanceService {
Boolean flag = stringRedisTemplate.hasKey(key);
// 缓存不存在
if (Boolean.FALSE.equals(flag)) {
String url = "https://cdn.jsdelivr.net/gh/NateScarlet/holiday-cn@master/" + year + ".json";
String json = HttpUtil.get(url, 0);
String url = "https://timor.tech/api/holiday/year/" + year;
String json = HttpUtil.get(url, 3000);
Map<String, String> map = new HashMap<>();
JSONObject jsonObject = JSONUtil.parseObj(json);
Map<String, String> map = jsonObject.getBeanList("days", HolidayVO.class).stream().collect(Collectors.toMap(HolidayVO::getDate, HolidayVO::getIsOffDay));
Object o = jsonObject.get("holiday");
//将o转为json对象并且循环获取对象中所有的属性
JSONObject data = JSONUtil.parseObj(o);
data.forEach((k, v) -> {
JSONObject item = JSONUtil.parseObj(v);
map.put(item.get("date").toString(), item.get("isOffDay").toString());
});
stringRedisTemplate.opsForHash().putAll(key, map);
// -- 删除去年的
String lastKey = "holiday_" + (Integer.parseInt(year) - 1);
@ -756,6 +763,7 @@ public class AttendanceServiceImpl implements AttendanceService {
// 导出 Excel
// ExcelUtils.write(response, "考勤组人员.xls", "数据", AttendanceGroupUserRespVO.class,
// BeanUtils.toBean(list, AttendanceGroupUserRespVO.class));
}
/**

View File

@ -63,7 +63,7 @@ public class FactoryInfoSaveReqVO {
private BigDecimal lat;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态不能为空")
// @NotNull(message = "状态不能为空")
private Integer status;
@Schema(description = "负责人编号", example = "126")