111
This commit is contained in:
parent
fba02533a0
commit
4dbc145cd5
@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.base.service.IBaseCalendarEventService;
|
||||
import com.ruoyi.base.vo.BaseCalendarVO;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -39,6 +40,8 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
public class BaseCalendarController extends BaseController {
|
||||
@Autowired
|
||||
private IBaseCalendarService baseCalendarService;
|
||||
@Autowired
|
||||
private IBaseCalendarEventService eventService;
|
||||
|
||||
/**
|
||||
* 分页查询日历列表
|
||||
@ -62,31 +65,42 @@ public class BaseCalendarController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 通过当前日期生成近5年的日历
|
||||
* 生成日历以及中国的节假日
|
||||
*
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
* @author PQZ
|
||||
* @date 10:46 2025/11/3
|
||||
**/
|
||||
@GetMapping("/generateCalendar")
|
||||
public AjaxResult generateCalendar() {
|
||||
baseCalendarService.generateCalendar();
|
||||
public AjaxResult generateCalendar(BaseCalendarVO calendarVO) {
|
||||
if (calendarVO.getSyncType() == 1) {
|
||||
//生成日历
|
||||
baseCalendarService.generateCalendar(calendarVO.getYear());
|
||||
//生成中国节日
|
||||
eventService.syncEvent(calendarVO.getYear());
|
||||
} else if (calendarVO.getSyncType() == 2) {
|
||||
//生成中国节日
|
||||
eventService.syncEvent(calendarVO.getYear());
|
||||
} else if (calendarVO.getSyncType() == 3) {
|
||||
//生成日历
|
||||
baseCalendarService.generateCalendar(calendarVO.getYear());
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出日历列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('base:calendar:export')")
|
||||
@Log(title = "日历", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BaseCalendar baseCalendar) {
|
||||
List<BaseCalendar> list = baseCalendarService.list();
|
||||
ExcelUtil<BaseCalendar> util = new ExcelUtil<BaseCalendar>(BaseCalendar.class);
|
||||
util.exportExcel(response, list, "日历数据");
|
||||
* 获取已生成日历和中国节假日的年份
|
||||
*
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
* @author PQZ
|
||||
* @date 15:49 2025/11/12
|
||||
**/
|
||||
@GetMapping("/getGeneraYear")
|
||||
public AjaxResult getGeneraYear() {
|
||||
return success(baseCalendarService.getGeneraYear());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取日历详细信息
|
||||
*/
|
||||
@ -96,34 +110,5 @@ public class BaseCalendarController extends BaseController {
|
||||
return success(baseCalendarService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增日历
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('base:calendar:add')")
|
||||
@Log(title = "日历", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BaseCalendar baseCalendar) {
|
||||
return toAjax(baseCalendarService.save(baseCalendar));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改日历
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('base:calendar:edit')")
|
||||
@Log(title = "日历", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BaseCalendar baseCalendar) {
|
||||
return toAjax(baseCalendarService.updateById(baseCalendar));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除日历
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('base:calendar:remove')")
|
||||
@Log(title = "日历", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids) {
|
||||
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||
return toAjax(baseCalendarService.removeByIds(list));
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,17 +53,6 @@ public class BaseCalendarEventController extends BaseController
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步中国节假日
|
||||
* @author PQZ
|
||||
* @date 17:18 2025/11/3
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
@GetMapping("/syncEvent")
|
||||
public AjaxResult syncEvent() {
|
||||
baseCalendarEventService.syncEvent();
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出节日列表
|
||||
|
||||
@ -29,15 +29,15 @@ public class BaseCalendar
|
||||
|
||||
/** 公历年份(如2025) */
|
||||
@Excel(name = "公历年份(如2025)")
|
||||
private Long year;
|
||||
private Integer year;
|
||||
|
||||
/** 公历月份(1-12) */
|
||||
@Excel(name = "公历月份(1-12)")
|
||||
private Long month;
|
||||
private Integer month;
|
||||
|
||||
/** 公历日期(1-31) */
|
||||
@Excel(name = "公历日期(1-31)")
|
||||
private Long day;
|
||||
private Integer day;
|
||||
|
||||
/** 农历日期(“初八”“十二”“九月”) */
|
||||
@Excel(name = "农历日期", readConverterExp = "“=初八”“十二”“九月”")
|
||||
@ -45,11 +45,11 @@ public class BaseCalendar
|
||||
|
||||
/** 星期(1 = 周一,2 = 周二,...,7 = 周日) */
|
||||
@Excel(name = "星期", readConverterExp = "1=,==,周=一,2,==,周=二,...,7,==,周=日")
|
||||
private Long weekday;
|
||||
private Integer weekday;
|
||||
|
||||
/** 第几周(全年) */
|
||||
@Excel(name = "第几周", readConverterExp = "全=年")
|
||||
private Long week;
|
||||
private Integer week;
|
||||
|
||||
/** 法定作息状态(休-休息、班-加班、空-正常) */
|
||||
@Excel(name = "法定作息状态", readConverterExp = "休=-休息、班-加班、空-正常")
|
||||
|
||||
@ -39,4 +39,20 @@ public class BaseCalendarEvent
|
||||
@Excel(name = "节日名称")
|
||||
private String eventName;
|
||||
|
||||
/** 公历年份(如2025) */
|
||||
@Excel(name = "公历年份(如2025)")
|
||||
private Integer year;
|
||||
|
||||
/** 公历月份(1-12) */
|
||||
@Excel(name = "公历月份(1-12)")
|
||||
private Integer month;
|
||||
|
||||
/** 公历日期(1-31) */
|
||||
@Excel(name = "公历日期(1-31)")
|
||||
private Integer day;
|
||||
|
||||
/** 是否是中国 */
|
||||
@Excel(name = "是否是中国")
|
||||
private String isChina;
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.base.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.base.domain.BaseCalendarEvent;
|
||||
@ -10,12 +11,19 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 节日Mapper接口
|
||||
*
|
||||
*
|
||||
* @author pqz
|
||||
* @date 2025-10-31
|
||||
*/
|
||||
@Mapper
|
||||
public interface BaseCalendarEventMapper extends BaseMapper<BaseCalendarEvent>
|
||||
{
|
||||
public interface BaseCalendarEventMapper extends BaseMapper<BaseCalendarEvent> {
|
||||
IPage<BaseCalendarEvent> queryListPage(@Param("entity") BaseCalendarEvent entity, Page<BaseCalendarEvent> page);
|
||||
|
||||
/**
|
||||
* 获取节假日年份
|
||||
* @author PQZ
|
||||
* @date 15:34 2025/11/12
|
||||
* @return java.util.List<java.lang.Long>
|
||||
**/
|
||||
List<Long> getEventYear();
|
||||
}
|
||||
|
||||
@ -29,4 +29,12 @@ public interface BaseCalendarMapper extends BaseMapper<BaseCalendar> {
|
||||
* @date 18:19 2025/11/11
|
||||
**/
|
||||
IPage<BaseCalendarVO> queryListPage(@Param("entity") BaseCalendar entity, Page<BaseCalendar> page);
|
||||
|
||||
/**
|
||||
* 获取已经生成日历的年份
|
||||
* @author PQZ
|
||||
* @date 15:27 2025/11/12
|
||||
* @return java.util.List<java.lang.Long>
|
||||
**/
|
||||
List<Long> getCalendarYear();
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.base.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@ -8,18 +9,27 @@ import com.ruoyi.base.domain.BaseCalendarEvent;
|
||||
|
||||
/**
|
||||
* 节日Service接口
|
||||
*
|
||||
*
|
||||
* @author pqz
|
||||
* @date 2025-10-31
|
||||
*/
|
||||
public interface IBaseCalendarEventService extends IService<BaseCalendarEvent>
|
||||
{
|
||||
public interface IBaseCalendarEventService extends IService<BaseCalendarEvent> {
|
||||
IPage<BaseCalendarEvent> queryListPage(BaseCalendarEvent pageReqVO, Page<BaseCalendarEvent> page);
|
||||
|
||||
/**
|
||||
* 同步国内节假日
|
||||
*
|
||||
* @author PQZ
|
||||
* @date 17:55 2025/11/11
|
||||
**/
|
||||
void syncEvent();
|
||||
**/
|
||||
void syncEvent(Integer year);
|
||||
|
||||
/**
|
||||
* 获取中国节假日的年份
|
||||
*
|
||||
* @return java.util.List<java.lang.Long>
|
||||
* @author PQZ
|
||||
* @date 15:33 2025/11/12
|
||||
**/
|
||||
List<Long> getEventYear();
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public interface IBaseCalendarService extends IService<BaseCalendar> {
|
||||
* @author PQZ
|
||||
* @date 10:47 2025/11/3
|
||||
**/
|
||||
void generateCalendar();
|
||||
void generateCalendar(Integer year);
|
||||
|
||||
/**
|
||||
* 根据集合修改法定作息状态
|
||||
@ -45,4 +45,12 @@ public interface IBaseCalendarService extends IService<BaseCalendar> {
|
||||
* @date 17:52 2025/11/11
|
||||
**/
|
||||
void updateWorkStatus(List<Map<String, Object>> dateList, String workStatus);
|
||||
|
||||
/**
|
||||
* 获取已经生成日历的年份以及生成中国节假日的年份
|
||||
* @author PQZ
|
||||
* @date 15:26 2025/11/12
|
||||
* @return java.util.Map<java.lang.String,java.util.List<java.lang.String>>
|
||||
**/
|
||||
Map<String,List<Long>> getGeneraYear();
|
||||
}
|
||||
|
||||
@ -15,8 +15,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.base.domain.BaseCalendar;
|
||||
import com.ruoyi.base.mapper.BaseCalendarMapper;
|
||||
import com.ruoyi.base.service.IBaseCalendarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -39,9 +41,11 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IBaseCalendarService baseCalendarService;
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<BaseCalendarEvent> queryListPage(BaseCalendarEvent pageReqVO, Page<BaseCalendarEvent> page) {
|
||||
return baseCalendarEventMapper.queryListPage(pageReqVO, page);
|
||||
@ -49,15 +53,16 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
||||
|
||||
/**
|
||||
* 同步国内节假日
|
||||
* @author PQZ
|
||||
* @date 17:55 2025/11/11
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
* @author PQZ
|
||||
* @date 17:55 2025/11/11
|
||||
**/
|
||||
@Override
|
||||
public void syncEvent() {
|
||||
public void syncEvent(Integer year) {
|
||||
String apiKey = "55bc9d05a05e5e1c0183f7ab380707d8";
|
||||
String baseUrl = "https://apis.tianapi.com/jiejiari/index";
|
||||
String date = "2025";
|
||||
String date = String.valueOf(year);
|
||||
String type = "1";
|
||||
|
||||
try {
|
||||
@ -98,7 +103,7 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
||||
int day = Integer.parseInt(parts[1]);
|
||||
|
||||
Map<String, Object> holiday = new HashMap<>();
|
||||
holiday.put("year", 2025);
|
||||
holiday.put("year", year);
|
||||
holiday.put("month", month);
|
||||
holiday.put("day", day);
|
||||
holiday.put("name", name);
|
||||
@ -132,24 +137,37 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
||||
}
|
||||
}
|
||||
|
||||
// baseCalendarService.updateWorkStatus(vacationList, "休");
|
||||
baseCalendarService.updateWorkStatus(vacationList, "休");
|
||||
baseCalendarService.updateWorkStatus(remarkList, "班");
|
||||
// saveCalendarEvent(holidayList);
|
||||
saveCalendarEvent(holidayList);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取中国节假日的年份
|
||||
*
|
||||
* @return java.util.List<java.lang.Long>
|
||||
* @author PQZ
|
||||
* @date 15:33 2025/11/12
|
||||
**/
|
||||
@Override
|
||||
public List<Long> getEventYear() {
|
||||
return baseCalendarEventMapper.getEventYear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存节假日数据
|
||||
* @author PQZ
|
||||
* @date 18:09 2025/11/11
|
||||
*
|
||||
* @param holidayList List<Map<String, Object>>
|
||||
* @return void
|
||||
**/
|
||||
void saveCalendarEvent(List<Map<String, Object>> holidayList){
|
||||
* @author PQZ
|
||||
* @date 18:09 2025/11/11
|
||||
**/
|
||||
void saveCalendarEvent(List<Map<String, Object>> holidayList) {
|
||||
if (holidayList == null || holidayList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -176,6 +194,10 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
||||
event.setDateId(calendar.getId());
|
||||
event.setCountry("中国");
|
||||
event.setEventName(name);
|
||||
event.setYear(year);
|
||||
event.setMonth(month);
|
||||
event.setDay(day);
|
||||
event.setIsChina("1");
|
||||
eventList.add(event);
|
||||
}
|
||||
}
|
||||
@ -184,7 +206,7 @@ public class BaseCalendarEventServiceImpl extends ServiceImpl<BaseCalendarEventM
|
||||
if (!eventList.isEmpty()) {
|
||||
this.saveBatch(eventList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -16,8 +16,10 @@ 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.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.base.service.IBaseCalendarEventService;
|
||||
import com.ruoyi.base.vo.BaseCalendarVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.base.mapper.BaseCalendarMapper;
|
||||
@ -35,6 +37,11 @@ public class BaseCalendarServiceImpl extends ServiceImpl<BaseCalendarMapper, Bas
|
||||
@Autowired
|
||||
private BaseCalendarMapper baseCalendarMapper;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IBaseCalendarEventService eventService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询日历列表
|
||||
*
|
||||
@ -57,24 +64,20 @@ public class BaseCalendarServiceImpl extends ServiceImpl<BaseCalendarMapper, Bas
|
||||
* @date 10:47 2025/11/3
|
||||
**/
|
||||
@Override
|
||||
public void generateCalendar() {
|
||||
// 获取当前年份
|
||||
int currentYear = LocalDate.now().getYear();
|
||||
public void generateCalendar(Integer year) {
|
||||
// 从当前年份的1月1日开始计算
|
||||
LocalDate startDate = LocalDate.of(currentYear, 1, 1);
|
||||
LocalDate startDate = LocalDate.of(year, 1, 1);
|
||||
// 结束日期为当前年的12月31日
|
||||
LocalDate endDate = LocalDate.of(currentYear, 12, 31);
|
||||
|
||||
LocalDate endDate = LocalDate.of(year, 12, 31);
|
||||
List<BaseCalendar> calendarList = new ArrayList<>();
|
||||
|
||||
// 遍历从开始日期到结束日期的每一天
|
||||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||||
BaseCalendar calendar = new BaseCalendar();
|
||||
calendar.setYear((long) date.getYear());
|
||||
calendar.setMonth((long) date.getMonthValue());
|
||||
calendar.setDay((long) date.getDayOfMonth());
|
||||
calendar.setWeek((long) date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
|
||||
calendar.setWeekday((long) date.getDayOfWeek().getValue());
|
||||
calendar.setYear( date.getYear());
|
||||
calendar.setMonth(date.getMonthValue());
|
||||
calendar.setDay( date.getDayOfMonth());
|
||||
calendar.setWeek(date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
|
||||
calendar.setWeekday(date.getDayOfWeek().getValue());
|
||||
// 使用Hutool计算农历日期
|
||||
calendar.setLunarDate(calculateLunarDate(date));
|
||||
// 设置工作状态:周六(6)和周日(7)设置为"休"
|
||||
@ -112,9 +115,9 @@ public class BaseCalendarServiceImpl extends ServiceImpl<BaseCalendarMapper, Bas
|
||||
|
||||
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())
|
||||
updateWrapper.eq("year", year)
|
||||
.eq("month", month)
|
||||
.eq("day", day)
|
||||
.set("work_status", workStatus);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
@ -122,6 +125,23 @@ public class BaseCalendarServiceImpl extends ServiceImpl<BaseCalendarMapper, Bas
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已经生成日历的年份以及生成中国节假日的年份
|
||||
*
|
||||
* @return java.util.Map<java.lang.String, java.util.List < java.lang.String>>
|
||||
* @author PQZ
|
||||
* @date 15:26 2025/11/12
|
||||
**/
|
||||
@Override
|
||||
public Map<String, List<Long>> getGeneraYear() {
|
||||
List<Long> calendarYear = baseCalendarMapper.getCalendarYear();
|
||||
List<Long> eventYear = eventService.getEventYear();
|
||||
Map<String, List<Long>> result = new java.util.HashMap<>();
|
||||
result.put("calendarYear", calendarYear);
|
||||
result.put("eventYear", eventYear);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用Hutool计算农历日期
|
||||
*
|
||||
|
||||
@ -13,4 +13,6 @@ import lombok.Data;
|
||||
public class BaseCalendarVO extends BaseCalendar {
|
||||
/**节日*/
|
||||
String eventName;
|
||||
/**同步类型*/
|
||||
Integer syncType;
|
||||
}
|
||||
|
||||
@ -23,4 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="entity.eventName != null and entity.eventName != ''"> and event_name like concat('%', #{entity.eventName}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getEventYear" resultType="java.lang.Long">
|
||||
select year from base_calendar_event group by year
|
||||
</select>
|
||||
</mapper>
|
||||
@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="queryListPage" resultType="com.ruoyi.base.vo.BaseCalendarVO">
|
||||
select main.*, event.event_name as eventName
|
||||
from base_calendar main
|
||||
left join base_calendar_event event on main.id = event.date_id
|
||||
left join base_calendar_event event on main.id = event.date_id and is_china = '1'
|
||||
<where>
|
||||
<if test="entity.year != null "> and main.year = #{entity.year}</if>
|
||||
<if test="entity.month != null "> and main.month = #{entity.month}</if>
|
||||
@ -33,4 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="entity.workStatus != null and entity.workStatus != ''"> and main.work_status = #{entity.workStatus}</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getCalendarYear" resultType="java.lang.Long">
|
||||
select year from base_calendar group by year
|
||||
</select>
|
||||
</mapper>
|
||||
@ -10,10 +10,19 @@ export function listCalendar(query) {
|
||||
}
|
||||
|
||||
// 生成日历
|
||||
export function generateCalendar() {
|
||||
export function generateCalendar(query) {
|
||||
return request({
|
||||
url: '/base/calendar/generateCalendar',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 获取已生成日历和中国节假日的年份
|
||||
export function getGeneraYear() {
|
||||
return request({
|
||||
url: '/base/calendar/getGeneraYear',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -24,29 +33,3 @@ export function getCalendar(id) {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增日历
|
||||
export function addCalendar(data) {
|
||||
return request({
|
||||
url: '/base/calendar',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改日历
|
||||
export function updateCalendar(data) {
|
||||
return request({
|
||||
url: '/base/calendar',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除日历
|
||||
export function delCalendar(id) {
|
||||
return request({
|
||||
url: '/base/calendar/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
@ -7,9 +7,10 @@
|
||||
type="primary"
|
||||
plain
|
||||
size="mini"
|
||||
@click="generate"
|
||||
@click="getYear"
|
||||
v-hasPermi="['base:calendar:add']"
|
||||
>日历同步</el-button>
|
||||
>日历同步
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-calendar v-model="currentDate" ref="calendar">
|
||||
@ -26,18 +27,66 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-calendar>
|
||||
|
||||
<!-- 提示同步日历和同步节日的框 -->
|
||||
<el-dialog title="日历同步" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="130px">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="日历已生成年份">
|
||||
<el-tag v-for="item in generateYear.calendarYear" class="tag-item">{{ item }}</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="节假日已生成年份">
|
||||
<el-tag v-for="item in generateYear.eventYear" class="tag-item">
|
||||
{{ item }}
|
||||
</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="年份" prop="year">
|
||||
<el-input v-model="form.year" placeholder="请输入年份"/>
|
||||
<span style="color: red">*已生成年份请勿重复生成</span>
|
||||
|
||||
</el-form-item>
|
||||
<el-form-item label="同步内容" >
|
||||
<el-radio-group v-model="form.syncType">
|
||||
<el-radio :label="1">全部同步</el-radio>
|
||||
<el-radio :label="2">国内节假日</el-radio>
|
||||
<el-radio :label="3">日历</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">同 步</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listCalendar,generateCalendar } from '@/api/base/calendar'
|
||||
import { listCalendar, generateCalendar, getGeneraYear } from '@/api/base/calendar'
|
||||
|
||||
export default {
|
||||
name: 'CalendarView',
|
||||
data() {
|
||||
return {
|
||||
currentDate: new Date(),
|
||||
calendarData: []
|
||||
calendarData: [],
|
||||
//已生成年份的日历
|
||||
generateYear: {},
|
||||
open: false,
|
||||
form: {
|
||||
year: null,
|
||||
syncType: 1
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
year: [
|
||||
{ required: true, trigger: 'blur', message: '请输入年份' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -52,7 +101,9 @@ export default {
|
||||
mounted() {
|
||||
const year = this.currentDate.getFullYear()
|
||||
const month = this.currentDate.getMonth() + 1
|
||||
//查询日历
|
||||
this.fetchCalendarData(year, month)
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
@ -67,9 +118,39 @@ export default {
|
||||
this.calendarData = response.data.records
|
||||
})
|
||||
},
|
||||
generate(){
|
||||
|
||||
cancel() {
|
||||
this.open = false
|
||||
},
|
||||
|
||||
submitForm() {
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
this.open = false
|
||||
this.$message.success('请求成功,正在同步,时间较长请耐心等待');
|
||||
generateCalendar(this.form).then(res =>{
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生成日历及中国的节假日
|
||||
*/
|
||||
generate() {
|
||||
generateCalendar().then(res => {
|
||||
this.$message.success("同步成功")
|
||||
this.$message.success('同步成功')
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取已生成日历和中国节假日的年份
|
||||
*/
|
||||
getYear() {
|
||||
getGeneraYear().then(res => {
|
||||
this.generateYear = res.data
|
||||
this.open = true
|
||||
})
|
||||
},
|
||||
|
||||
@ -96,7 +177,6 @@ export default {
|
||||
) || null
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 获取农历日期
|
||||
* @param {string} dateStr - 日期字符串
|
||||
@ -104,7 +184,7 @@ export default {
|
||||
*/
|
||||
getLunarDate(dateStr) {
|
||||
const record = this.getCalendarRecord(dateStr)
|
||||
if(record!=null && record.eventName != null){
|
||||
if (record != null && record.eventName != null) {
|
||||
return record.eventName
|
||||
}
|
||||
return record ? record.lunarDate : null
|
||||
|
||||
Loading…
Reference in New Issue
Block a user