Commit 8563859f authored by fangxinjiang's avatar fangxinjiang

节假日配置表及社保医疗截止配置表

parent 8e6c42f7
......@@ -1644,4 +1644,23 @@ public class DateUtil {
}
return false;
}
/**
* @Author fxj
* @Description 判断是否为 周六 周日
* @Date 18:04 2024/5/8
* @Param
* @return
**/
public static boolean isHoliday(Date date){
// 创建一个Calendar对象,并设置日期为解析得到的Date对象
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 获取对应的星期几
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
// 输出星期几
if (dayOfWeek==Calendar.SUNDAY || dayOfWeek==Calendar.SATURDAY){
return true;
}
return false;
}
}
package com.yifu.cloud.plus.v1.yifu.common.core.util;
import org.springframework.web.client.RestTemplate;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Author fxj
* @Date 2024/5/8
* @Description 年度法定节假日、公休日查询接口地址
* @Version 1.0
*/
public class HolidayCrawler {
/**
* 年度法定节假日、公休日查询接口地址
*/
private static final String YEAR_HOLIDAY_URL = "https://api.apihubs.cn/holiday/get?field=date,weekend&year="+DateUtil.getYear(new Date())+"&workday=2&order_by=1&cn=1&page=1&size=500";
/**
* http请求工具类
*/
private static final RestTemplate REST_TEMPLATE = new RestTemplate();
public static List<Map<String,Object>> initHolidays(){
long ts = System.currentTimeMillis();
Map<String,Object> result = REST_TEMPLATE.getForObject(String.format(YEAR_HOLIDAY_URL, ts, ts), Map.class);
if(null!=result){
String code=String.valueOf(result.get("code"));
String msg=String.valueOf(result.get("msg"));
if(code.equals("0") && msg.equals("ok")){
Map data= (Map) result.get("data");
if(null!=data){
List<Map<String,Object>> list= (List<Map<String, Object>>) data.get("list");
return list;
/*int i=0;
for(Map<String,Object> d:list){
System.out.println("i="+(++i)+" 日期="+d.get("date")+" 类型="+d.get("weekend")+" weekend_cn="+d.get("weekend_cn"));
}*/
}
}
}
return null;
}
}
......@@ -145,4 +145,28 @@ public class SocialTask {
HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tpaymentinfo/inner/signPaymentNoIncomeFlag","", Object.class, SecurityConstants.FROM_IN);
log.info("------------定时任务标识根据项目不需要生成收入的数据-定时任务结束------------");
}
/**
* @Description: 定时任务生成月度截止日配置信息
* @Author: fxj
* @Date: 2022/8/30
* @return: void
**/
public void createDeadLineSetInfo() {
log.info("------------定时任务生成月度截止日配置信息定时任务开始------------");
HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tsocialdeadlineinfo/inner/createDeadLineSetInfo","", Object.class, SecurityConstants.FROM_IN);
log.info("------------定时任务生成月度截止日配置信息-定时任务结束------------");
}
/**
* @Description: 定时任务1月1号生成年度假期表
* @Author: fxj
* @Date: 2022/8/30
* @return: void
**/
public void createHolidayInfo() {
log.info("------------定时任务1月1号生成年度假期表-定时任务开始------------");
HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tholidayinfo/inner/createHolidayInfo","", Object.class, SecurityConstants.FROM_IN);
log.info("------------定时任务1月1号生成年度假期表-定时任务结束------------");
}
}
......@@ -48,14 +48,14 @@ public class THolidayInfo extends BaseEntity {
@Schema(description = "id")
private String id;
/**
* date
* date 例:2024-05-08
*/
@ExcelAttribute(name = "date", isDate = true)
@ExcelProperty("date")
@Schema(description = "date")
private Date date;
/**
* year
* year 例:2024
*/
@ExcelAttribute(name = "year", maxLength = 6)
@Length(max = 6, message = "year不能超过6个字符")
......@@ -63,7 +63,7 @@ public class THolidayInfo extends BaseEntity {
@Schema(description = "year")
private String year;
/**
* month
* month 例:05
*/
@ExcelAttribute(name = "month", maxLength = 6)
@Length(max = 6, message = "month不能超过6个字符")
......@@ -71,7 +71,7 @@ public class THolidayInfo extends BaseEntity {
@Schema(description = "month")
private String month;
/**
* day
* day 例:08
*/
@ExcelAttribute(name = "day", maxLength = 2)
@Length(max = 2, message = "day不能超过2个字符")
......
......@@ -117,4 +117,12 @@ public class TSocialDeadlineInfo extends BaseEntity {
@Schema(description = "启用禁用:0启用 1 禁用")
private String status;
/**
* 配置类型:0 非基础配置 1基础配置(后面配置都是按他生成的)
*/
@Length(max = 1, message = "配置类型:0 非基础配置 1基础配置(后面配置都是按他生成的) 禁用不能超过1个字符")
@Schema(description = "配置类型:0 非基础配置 1基础配置(后面配置都是按他生成的)")
private String type;
}
......@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.social.entity.THolidayInfo;
import com.yifu.cloud.plus.v1.yifu.social.service.THolidayInfoService;
import com.yifu.cloud.plus.v1.yifu.social.vo.THolidayInfoSearchVo;
......@@ -158,4 +159,17 @@ public class THolidayInfoController {
public void export(HttpServletResponse response, @RequestBody THolidayInfoSearchVo searchVo) {
tHolidayInfoService.listExport(response, searchVo);
}
/**
* @Description: 定时任务1月1号生成年度假期表
* @Author: fxj
* @Date: 2024/5/8
**/
@Operation(summary = "定时任务1月1号生成年度假期表", description = "定时任务1月1号生成年度假期表")
@SysLog("定时任务1月1号生成年度假期表")
@Inner
@PostMapping("/inner/createHolidayInfo")
public void createHolidayInfo() {
tHolidayInfoService.createHolidayInfo();
}
}
......@@ -32,6 +32,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceTypeRate;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo;
......@@ -223,4 +224,17 @@ public class TSocialDeadlineInfoController {
public void export(HttpServletResponse response, @RequestBody TSocialDeadlineInfoSearchVo searchVo) {
tSocialDeadlineInfoService.listExport(response, searchVo);
}
/**
* @Description: 定时任务生成月度截止日配置信息
* @Author: fxj
* @Date: 2024/5/8
**/
@Operation(summary = "定时任务生成月度截止日配置信息", description = "定时任务生成月度截止日配置信息")
@SysLog("定时任务生成月度截止日配置信息")
@Inner
@PostMapping("/inner/createDeadLineSetInfo")
public void createDeadLineSetInfo() {
tSocialDeadlineInfoService.createDeadLineSetInfo();
}
}
......@@ -47,4 +47,6 @@ public interface THolidayInfoService extends IService<THolidayInfo> {
void listExport(HttpServletResponse response, THolidayInfoSearchVo searchVo);
List<THolidayInfo> noPageDiy(THolidayInfoSearchVo searchVo);
void createHolidayInfo();
}
......@@ -49,4 +49,7 @@ public interface TSocialDeadlineInfoService extends IService<TSocialDeadlineInfo
void listExport(HttpServletResponse response, TSocialDeadlineInfoSearchVo searchVo);
List<TSocialDeadlineInfo> noPageDiy(TSocialDeadlineInfoSearchVo searchVo);
void createDeadLineSetInfo();
}
......@@ -17,6 +17,7 @@
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
......@@ -32,7 +33,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.social.entity.THolidayInfo;
import com.yifu.cloud.plus.v1.yifu.social.mapper.THolidayInfoMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.THolidayInfoService;
......@@ -46,8 +49,11 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author fxj
......@@ -249,4 +255,33 @@ public class THolidayInfoServiceImpl extends ServiceImpl<THolidayInfoMapper, THo
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
@Override
public void createHolidayInfo() {
baseMapper.delete(Wrappers.<THolidayInfo>query().lambda());
List<Map<String,Object>> json = HolidayCrawler.initHolidays();
List<THolidayInfo> saveList = new ArrayList<>();
THolidayInfo save;
for(Map<String,Object> d:json){
save = new THolidayInfo();
try {
save.setDate(DateUtil.stringToDate((String) d.get("date").toString(),DateUtil.ISO_DATE_FORMAT));
}catch (Exception e){
log.error("假期表初始化异常:"+d.get("date"),e);
continue;
}
save.setDay(DateUtil.getDay(save.getDate()));
save.setMonth(DateUtil.getMonth(save.getDate()));
save.setYear(DateUtil.getYear(save.getDate()));
save.setCreateBy("1");
save.setCreateName("admin");
save.setCreateTime(LocalDateTime.now());
save.setUpdateBy("1");
saveList.add(save);
}
if (Common.isNotNull(saveList)){
this.saveBatch(saveList);
}
log.info(DateUtil.getYear(new Date())+"年假期表初始化完成:");
}
}
......@@ -33,11 +33,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.social.entity.THolidayInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo;
import com.yifu.cloud.plus.v1.yifu.social.mapper.THolidayInfoMapper;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialDeadlineInfoMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialDeadlineInfoService;
import com.yifu.cloud.plus.v1.yifu.social.vo.TSocialDeadlineInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.TSocialDeadlineInfoVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
......@@ -46,8 +50,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
/**
* 社保医疗截止日配置
......@@ -56,8 +59,11 @@ import java.util.List;
* @date 2024-05-08 11:52:09
*/
@Log4j2
@AllArgsConstructor
@Service
public class TSocialDeadlineInfoServiceImpl extends ServiceImpl<TSocialDeadlineInfoMapper, TSocialDeadlineInfo> implements TSocialDeadlineInfoService {
private final THolidayInfoMapper holidayInfoMapper;
/**
* 社保医疗截止日配置简单分页查询
*
......@@ -251,4 +257,63 @@ public class TSocialDeadlineInfoServiceImpl extends ServiceImpl<TSocialDeadlineI
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
/**
* @Description: 定时任务生成月度截止日配置信息 没有一号生成当月派遣截止日配置
* @Author: fxj
* @Date: 2024/5/8
**/
@Override
public void createDeadLineSetInfo() {
//获取基础配置信息
List<TSocialDeadlineInfo> baseLists = baseMapper.selectList(Wrappers.<TSocialDeadlineInfo>query().lambda()
.eq(TSocialDeadlineInfo::getType,CommonConstants.ONE_STRING));
if (Common.isNotNull(baseLists)){
List<TSocialDeadlineInfo> saveList = new ArrayList<>();;
//获取当前月份所有假期配置表
Date date = new Date();
List<THolidayInfo> holidayInfos = holidayInfoMapper.selectList(Wrappers.<THolidayInfo>query().lambda()
.eq(THolidayInfo::getYear,DateUtil.getYear(date))
.eq(THolidayInfo::getMonth,DateUtil.getMonth(date)));
Map<String,String> holidayMap = new HashMap<>();
if (Common.isNotNull(holidayInfos)){
for (THolidayInfo h:holidayInfos){
holidayMap.put(h.getDay(),h.getDay());
}
}
TSocialDeadlineInfo save;
for (TSocialDeadlineInfo sd:baseLists){
save = new TSocialDeadlineInfo();
BeanUtil.copyProperties(sd,save);
initSocialEndDate(holidayMap, save);
initMedicalEndDate(holidayMap, save);
}
if (Common.isNotNull(saveList)){
this.saveBatch(saveList);
}
}
}
private void initMedicalEndDate(Map<String, String> holidayMap, TSocialDeadlineInfo save) {
// type 0 休假 1 补班
String type;
type = holidayMap.get(DateUtil.getDay(save.getMedicalEndDate()));
if (Common.isNotNull(type) && CommonConstants.ZERO_STRING.equals(type)){
save.setMedicalEndDate(DateUtil.addDayByDate(save.getMedicalEndDate(),CommonConstants.ONE_INT_NEGATE));
}else {
return;
}
initMedicalEndDate(holidayMap,save);
}
private void initSocialEndDate(Map<String, String> holidayMap, TSocialDeadlineInfo save) {
// type 0 休假 1 补班
String type;
type = holidayMap.get(DateUtil.getDay(save.getSocialEndDate()));
if (Common.isNotNull(type)&& CommonConstants.ZERO_STRING.equals(type)){
save.setSocialEndDate(DateUtil.addDayByDate(save.getSocialEndDate(),CommonConstants.ONE_INT_NEGATE));
}else {
return;
}
initSocialEndDate(holidayMap,save);
}
}
......@@ -38,6 +38,7 @@
<result property="updateName" column="UPDATE_NAME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="status" column="STATUS"/>
<result property="type" column="TYPE"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
......@@ -53,7 +54,7 @@
a.UPDATE_BY,
a.UPDATE_NAME,
a.UPDATE_TIME,
a.STATUS
a.STATUS,a.TYPE
</sql>
<sql id="tSocialDeadlineInfo_where">
<if test="tSocialDeadlineInfo != null">
......@@ -99,6 +100,9 @@
<if test="tSocialDeadlineInfo.status != null and tSocialDeadlineInfo.status.trim() != ''">
AND a.STATUS = #{tSocialDeadlineInfo.status}
</if>
<if test="tSocialDeadlineInfo.type != null and tSocialDeadlineInfo.type.trim() != ''">
AND a.TYPE = #{tSocialDeadlineInfo.type}
</if>
</if>
</sql>
<!--tSocialDeadlineInfo简单分页查询-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment