1111
This commit is contained in:
parent
4f9b4afcfd
commit
fba02533a0
@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.base.vo.BaseCalendarVO;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -40,15 +41,22 @@ public class BaseCalendarController extends BaseController {
|
|||||||
private IBaseCalendarService baseCalendarService;
|
private IBaseCalendarService baseCalendarService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询日历列表
|
* 分页查询日历列表
|
||||||
*/
|
*
|
||||||
|
* @param baseCalendar {@link BaseCalendar}
|
||||||
|
* @param pageNum 分页参数
|
||||||
|
* @param pageSize 分页参数
|
||||||
|
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||||
|
* @author PQZ
|
||||||
|
* @date 18:18 2025/11/11
|
||||||
|
**/
|
||||||
@PreAuthorize("@ss.hasPermi('base:calendar:list')")
|
@PreAuthorize("@ss.hasPermi('base:calendar:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(BaseCalendar baseCalendar,
|
public AjaxResult list(BaseCalendar baseCalendar,
|
||||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||||
Page<BaseCalendar> page = new Page<>(pageNum, pageSize);
|
Page<BaseCalendar> page = new Page<>(pageNum, pageSize);
|
||||||
IPage<BaseCalendar> list = baseCalendarService.queryListPage(baseCalendar, page);
|
IPage<BaseCalendarVO> list = baseCalendarService.queryListPage(baseCalendar, page);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,12 +15,11 @@ import com.ruoyi.common.core.domain.DlBaseEntity;
|
|||||||
*/
|
*/
|
||||||
@TableName("base_calendar_event")
|
@TableName("base_calendar_event")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BaseCalendarEvent extends DlBaseEntity
|
public class BaseCalendarEvent
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
package com.ruoyi.base.mapper;
|
package com.ruoyi.base.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.base.domain.BaseCalendar;
|
import com.ruoyi.base.domain.BaseCalendar;
|
||||||
|
import com.ruoyi.base.vo.BaseCalendarVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -15,7 +17,16 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
* @date 2025-10-31
|
* @date 2025-10-31
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BaseCalendarMapper extends BaseMapper<BaseCalendar>
|
public interface BaseCalendarMapper extends BaseMapper<BaseCalendar> {
|
||||||
{
|
|
||||||
IPage<BaseCalendar> queryListPage(@Param("entity") BaseCalendar entity, Page<BaseCalendar> page);
|
/**
|
||||||
|
* 分页查询日历列表
|
||||||
|
*
|
||||||
|
* @param entity {@link BaseCalendar}
|
||||||
|
* @param page 分页参数
|
||||||
|
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.base.domain.BaseCalendar>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 18:19 2025/11/11
|
||||||
|
**/
|
||||||
|
IPage<BaseCalendarVO> queryListPage(@Param("entity") BaseCalendar entity, Page<BaseCalendar> page);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,5 +16,10 @@ public interface IBaseCalendarEventService extends IService<BaseCalendarEvent>
|
|||||||
{
|
{
|
||||||
IPage<BaseCalendarEvent> queryListPage(BaseCalendarEvent pageReqVO, Page<BaseCalendarEvent> page);
|
IPage<BaseCalendarEvent> queryListPage(BaseCalendarEvent pageReqVO, Page<BaseCalendarEvent> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步国内节假日
|
||||||
|
* @author PQZ
|
||||||
|
* @date 17:55 2025/11/11
|
||||||
|
**/
|
||||||
void syncEvent();
|
void syncEvent();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
package com.ruoyi.base.service;
|
package com.ruoyi.base.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.base.domain.BaseCalendar;
|
import com.ruoyi.base.domain.BaseCalendar;
|
||||||
|
import com.ruoyi.base.vo.BaseCalendarVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日历Service接口
|
* 日历Service接口
|
||||||
@ -14,14 +16,33 @@ import com.ruoyi.base.domain.BaseCalendar;
|
|||||||
* @date 2025-10-31
|
* @date 2025-10-31
|
||||||
*/
|
*/
|
||||||
public interface IBaseCalendarService extends IService<BaseCalendar> {
|
public interface IBaseCalendarService extends IService<BaseCalendar> {
|
||||||
IPage<BaseCalendar> queryListPage(BaseCalendar pageReqVO, Page<BaseCalendar> page);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过当前时间生成近5年的日历
|
* 分页查询日历列表
|
||||||
|
*
|
||||||
|
* @param pageReqVO {@link BaseCalendar}
|
||||||
|
* @param page 分页参数
|
||||||
|
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.base.domain.BaseCalendar>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 18:19 2025/11/11
|
||||||
|
**/
|
||||||
|
IPage<BaseCalendarVO> queryListPage(BaseCalendar pageReqVO, Page<BaseCalendar> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过当前时间生成指定年份的日历
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
* @author PQZ
|
* @author PQZ
|
||||||
* @date 10:47 2025/11/3
|
* @date 10:47 2025/11/3
|
||||||
**/
|
**/
|
||||||
void generateCalendar();
|
void generateCalendar();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据集合修改法定作息状态
|
||||||
|
*
|
||||||
|
* @param dateList List<Map<String, Object>> list
|
||||||
|
* @param workStatus 法定作息状态
|
||||||
|
* @author PQZ
|
||||||
|
* @date 17:52 2025/11/11
|
||||||
|
**/
|
||||||
|
void updateWorkStatus(List<Map<String, Object>> dateList, String workStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,14 +7,15 @@ import java.net.URL;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Year;
|
import java.time.Year;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.ruoyi.base.domain.BaseCalendar;
|
||||||
|
import com.ruoyi.base.service.IBaseCalendarService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -38,11 +39,20 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
|||||||
private final RestTemplate restTemplate = new RestTemplate();
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBaseCalendarService baseCalendarService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<BaseCalendarEvent> queryListPage(BaseCalendarEvent pageReqVO, Page<BaseCalendarEvent> page) {
|
public IPage<BaseCalendarEvent> queryListPage(BaseCalendarEvent pageReqVO, Page<BaseCalendarEvent> page) {
|
||||||
return baseCalendarEventMapper.queryListPage(pageReqVO, page);
|
return baseCalendarEventMapper.queryListPage(pageReqVO, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步国内节假日
|
||||||
|
* @author PQZ
|
||||||
|
* @date 17:55 2025/11/11
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void syncEvent() {
|
public void syncEvent() {
|
||||||
String apiKey = "55bc9d05a05e5e1c0183f7ab380707d8";
|
String apiKey = "55bc9d05a05e5e1c0183f7ab380707d8";
|
||||||
@ -69,17 +79,62 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
|||||||
if (code != null && code == 200) {
|
if (code != null && code == 200) {
|
||||||
Map<String, Object> newsMap = (Map<String, Object>) resultMap.get("result");
|
Map<String, Object> newsMap = (Map<String, Object>) resultMap.get("result");
|
||||||
List<Map<String, Object>> dataList = (List<Map<String, Object>>) newsMap.get("list");
|
List<Map<String, Object>> dataList = (List<Map<String, Object>>) newsMap.get("list");
|
||||||
|
// 创建三个集合
|
||||||
|
List<Map<String, Object>> holidayList = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> vacationList = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> remarkList = new ArrayList<>();
|
||||||
|
|
||||||
// 输出数据到控制台
|
|
||||||
System.out.println("获取到 " + dataList.size() + " 条节假日数据:");
|
|
||||||
for (Map<String, Object> data : dataList) {
|
for (Map<String, Object> data : dataList) {
|
||||||
System.out.println("日期: " + data.get("date") +
|
String name = (String) data.get("name");
|
||||||
", 名称: " + data.get("name") +
|
String holidayStr = (String) data.get("holiday");
|
||||||
", 类型: " + data.get("type"));
|
String vacationStr = (String) data.get("vacation");
|
||||||
|
String remarkStr = (String) data.get("remark");
|
||||||
|
|
||||||
|
// 处理节假日集合
|
||||||
|
if (holidayStr != null && !holidayStr.isEmpty()) {
|
||||||
|
// 解析 holiday 字段,例如 "1月1号"
|
||||||
|
String[] parts = holidayStr.replace("号", "").split("月");
|
||||||
|
int month = Integer.parseInt(parts[0]);
|
||||||
|
int day = Integer.parseInt(parts[1]);
|
||||||
|
|
||||||
|
Map<String, Object> holiday = new HashMap<>();
|
||||||
|
holiday.put("year", 2025);
|
||||||
|
holiday.put("month", month);
|
||||||
|
holiday.put("day", day);
|
||||||
|
holiday.put("name", name);
|
||||||
|
holidayList.add(holiday);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理休息日集合
|
||||||
|
if (vacationStr != null && !vacationStr.isEmpty()) {
|
||||||
|
String[] dates = vacationStr.split("\\|");
|
||||||
|
for (String vacationDate : dates) {
|
||||||
|
String[] dateParts = vacationDate.split("-");
|
||||||
|
Map<String, Object> vacation = new HashMap<>();
|
||||||
|
vacation.put("year", Integer.parseInt(dateParts[0]));
|
||||||
|
vacation.put("month", Integer.parseInt(dateParts[1]));
|
||||||
|
vacation.put("day", Integer.parseInt(dateParts[2]));
|
||||||
|
vacationList.add(vacation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理调休加班日集合
|
||||||
|
if (remarkStr != null && !remarkStr.isEmpty()) {
|
||||||
|
String[] dates = remarkStr.split("\\|");
|
||||||
|
for (String remarkDate : dates) {
|
||||||
|
String[] dateParts = remarkDate.split("-");
|
||||||
|
Map<String, Object> remark = new HashMap<>();
|
||||||
|
remark.put("year", Integer.parseInt(dateParts[0]));
|
||||||
|
remark.put("month", Integer.parseInt(dateParts[1]));
|
||||||
|
remark.put("day", Integer.parseInt(dateParts[2]));
|
||||||
|
remarkList.add(remark);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
System.err.println("获取节假日数据失败,错误码: " + code +
|
// baseCalendarService.updateWorkStatus(vacationList, "休");
|
||||||
", 错误信息: " + resultMap.get("msg"));
|
baseCalendarService.updateWorkStatus(remarkList, "班");
|
||||||
|
// saveCalendarEvent(holidayList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -87,5 +142,50 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存节假日数据
|
||||||
|
* @author PQZ
|
||||||
|
* @date 18:09 2025/11/11
|
||||||
|
* @param holidayList List<Map<String, Object>>
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
void saveCalendarEvent(List<Map<String, Object>> holidayList){
|
||||||
|
if (holidayList == null || holidayList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<BaseCalendarEvent> eventList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map<String, Object> holiday : holidayList) {
|
||||||
|
Integer year = (Integer) holiday.get("year");
|
||||||
|
Integer month = (Integer) holiday.get("month");
|
||||||
|
Integer day = (Integer) holiday.get("day");
|
||||||
|
String name = (String) holiday.get("name");
|
||||||
|
|
||||||
|
if (year != null && month != null && day != null && name != null) {
|
||||||
|
// 查询baseCalendar表中是否存在该日期记录
|
||||||
|
BaseCalendar calendar = baseCalendarService.getOne(new LambdaQueryWrapper<BaseCalendar>()
|
||||||
|
.eq(BaseCalendar::getYear, year)
|
||||||
|
.eq(BaseCalendar::getMonth, month)
|
||||||
|
.eq(BaseCalendar::getDay, day));
|
||||||
|
|
||||||
|
// 如果存在该日期记录,则创建节日事件
|
||||||
|
if (calendar != null) {
|
||||||
|
BaseCalendarEvent event = new BaseCalendarEvent();
|
||||||
|
// 使用baseCalendar表的ID作为dateId
|
||||||
|
event.setDateId(calendar.getId());
|
||||||
|
event.setCountry("中国");
|
||||||
|
event.setEventName(name);
|
||||||
|
eventList.add(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 批量保存节日事件
|
||||||
|
if (!eventList.isEmpty()) {
|
||||||
|
this.saveBatch(eventList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,14 @@ import java.time.temporal.IsoFields;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.base.vo.BaseCalendarVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@ -30,13 +35,22 @@ public class BaseCalendarServiceImpl extends ServiceImpl<BaseCalendarMapper, Bas
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BaseCalendarMapper baseCalendarMapper;
|
private BaseCalendarMapper baseCalendarMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询日历列表
|
||||||
|
*
|
||||||
|
* @param pageReqVO {@link BaseCalendar}
|
||||||
|
* @param page 分页参数
|
||||||
|
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.base.domain.BaseCalendar>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 18:19 2025/11/11
|
||||||
|
**/
|
||||||
@Override
|
@Override
|
||||||
public IPage<BaseCalendar> queryListPage(BaseCalendar pageReqVO, Page<BaseCalendar> page) {
|
public IPage<BaseCalendarVO> queryListPage(BaseCalendar pageReqVO, Page<BaseCalendar> page) {
|
||||||
return baseCalendarMapper.queryListPage(pageReqVO, page);
|
return baseCalendarMapper.queryListPage(pageReqVO, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过当前时间生成近5年的日历
|
* 通过当前时间生成指定年份的日历
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @author PQZ
|
* @author PQZ
|
||||||
@ -64,6 +78,7 @@ public class BaseCalendarServiceImpl extends ServiceImpl<BaseCalendarMapper, Bas
|
|||||||
// 使用Hutool计算农历日期
|
// 使用Hutool计算农历日期
|
||||||
calendar.setLunarDate(calculateLunarDate(date));
|
calendar.setLunarDate(calculateLunarDate(date));
|
||||||
// 设置工作状态:周六(6)和周日(7)设置为"休"
|
// 设置工作状态:周六(6)和周日(7)设置为"休"
|
||||||
|
|
||||||
if (date.getDayOfWeek().getValue() == 6 || date.getDayOfWeek().getValue() == 7) {
|
if (date.getDayOfWeek().getValue() == 6 || date.getDayOfWeek().getValue() == 7) {
|
||||||
calendar.setWorkStatus("休");
|
calendar.setWorkStatus("休");
|
||||||
} else {
|
} else {
|
||||||
@ -76,6 +91,37 @@ public class BaseCalendarServiceImpl extends ServiceImpl<BaseCalendarMapper, Bas
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据集合修改法定作息状态
|
||||||
|
*
|
||||||
|
* @param dateList List<Map<String, Object>> list
|
||||||
|
* @param workStatus 法定作息状态
|
||||||
|
* @author PQZ
|
||||||
|
* @date 17:52 2025/11/11
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void updateWorkStatus(List<Map<String, Object>> dateList, String workStatus) {
|
||||||
|
if (dateList == null || dateList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 转换为BaseCalendar对象列表
|
||||||
|
for (Map<String, Object> dateMap : dateList) {
|
||||||
|
Integer year = (Integer) dateMap.get("year");
|
||||||
|
Integer month = (Integer) dateMap.get("month");
|
||||||
|
Integer day = (Integer) dateMap.get("day");
|
||||||
|
|
||||||
|
if (year != null && month != null && day != null) {
|
||||||
|
UpdateWrapper<BaseCalendar> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("year", year.longValue())
|
||||||
|
.eq("month", month.longValue())
|
||||||
|
.eq("day", day.longValue())
|
||||||
|
.set("work_status", workStatus);
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用Hutool计算农历日期
|
* 使用Hutool计算农历日期
|
||||||
*
|
*
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.base.vo;
|
||||||
|
|
||||||
|
import com.ruoyi.base.domain.BaseCalendar;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日历对象 base_calendar
|
||||||
|
*
|
||||||
|
* @author pqz
|
||||||
|
* @date 2025-10-31
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BaseCalendarVO extends BaseCalendar {
|
||||||
|
/**节日*/
|
||||||
|
String eventName;
|
||||||
|
}
|
||||||
@ -19,16 +19,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
select id, year, month, day, lunar_date, weekday, week, work_status from base_calendar
|
select id, year, month, day, lunar_date, weekday, week, work_status from base_calendar
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="queryListPage" parameterType="BaseCalendar" resultMap="BaseCalendarResult">
|
<select id="queryListPage" resultType="com.ruoyi.base.vo.BaseCalendarVO">
|
||||||
<include refid="selectBaseCalendarVo"/>
|
select main.*, event.event_name as eventName
|
||||||
|
from base_calendar main
|
||||||
|
left join base_calendar_event event on main.id = event.date_id
|
||||||
<where>
|
<where>
|
||||||
<if test="entity.year != null "> and year = #{entity.year}</if>
|
<if test="entity.year != null "> and main.year = #{entity.year}</if>
|
||||||
<if test="entity.month != null "> and month = #{entity.month}</if>
|
<if test="entity.month != null "> and main.month = #{entity.month}</if>
|
||||||
<if test="entity.day != null "> and day = #{entity.day}</if>
|
<if test="entity.day != null "> and main.day = #{entity.day}</if>
|
||||||
<if test="entity.lunarDate != null and entity.lunarDate != ''"> and lunar_date = #{entity.lunarDate}</if>
|
<if test="entity.lunarDate != null and entity.lunarDate != ''"> and main.lunar_date = #{entity.lunarDate}</if>
|
||||||
<if test="entity.weekday != null "> and weekday = #{entity.weekday}</if>
|
<if test="entity.weekday != null "> and main.weekday = #{entity.weekday}</if>
|
||||||
<if test="entity.week != null "> and week = #{entity.week}</if>
|
<if test="entity.week != null "> and main.week = #{entity.week}</if>
|
||||||
<if test="entity.workStatus != null and entity.workStatus != ''"> and work_status = #{entity.workStatus}</if>
|
<if test="entity.workStatus != null and entity.workStatus != ''"> and main.work_status = #{entity.workStatus}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -113,7 +113,7 @@ service.interceptors.response.use(res => {
|
|||||||
if (message == "Network Error") {
|
if (message == "Network Error") {
|
||||||
message = "后端接口连接异常";
|
message = "后端接口连接异常";
|
||||||
} else if (message.includes("timeout")) {
|
} else if (message.includes("timeout")) {
|
||||||
message = "系统接口请求超时";
|
// message = "系统接口请求超时";
|
||||||
} else if (message.includes("Request failed with status code")) {
|
} else if (message.includes("Request failed with status code")) {
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,12 @@
|
|||||||
<div class="calendar-cell">
|
<div class="calendar-cell">
|
||||||
<div class="calendar-date">{{ data.day.split('-')[2] }}</div>
|
<div class="calendar-date">{{ data.day.split('-')[2] }}</div>
|
||||||
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
|
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
|
||||||
<div v-if="getWorkStatus(data.day)" class="work-status">休</div>
|
<div
|
||||||
|
v-if="getWorkStatus(data.day)"
|
||||||
|
:class="['work-status', getWorkStatus(data.day)]"
|
||||||
|
>
|
||||||
|
{{ getWorkStatus(data.day) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-calendar>
|
</el-calendar>
|
||||||
@ -99,6 +104,9 @@ export default {
|
|||||||
*/
|
*/
|
||||||
getLunarDate(dateStr) {
|
getLunarDate(dateStr) {
|
||||||
const record = this.getCalendarRecord(dateStr)
|
const record = this.getCalendarRecord(dateStr)
|
||||||
|
if(record!=null && record.eventName != null){
|
||||||
|
return record.eventName
|
||||||
|
}
|
||||||
return record ? record.lunarDate : null
|
return record ? record.lunarDate : null
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -136,9 +144,23 @@ export default {
|
|||||||
|
|
||||||
.work-status {
|
.work-status {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #ef9e11;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
|
display: inline-block;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 16px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-status.休 {
|
||||||
|
background-color: #1890ff; /* 蓝色 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-status.班 {
|
||||||
|
background-color: #52c41a; /* 绿色 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-calendar-table .el-calendar-day:hover {
|
.el-calendar-table .el-calendar-day:hover {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user