Commit 8e6c42f7 authored by fangxinjiang's avatar fangxinjiang

新增社保、医保截止日配置及假期配置表

parent c7945b25
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
/**
* @author fxj
* @date 2024-05-08 11:52:08
*/
@Data
@TableName("t_holiday_info")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "节假日信息表")
public class THolidayInfo extends BaseEntity {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("id")
@Schema(description = "id")
private String id;
/**
* date
*/
@ExcelAttribute(name = "date", isDate = true)
@ExcelProperty("date")
@Schema(description = "date")
private Date date;
/**
* year
*/
@ExcelAttribute(name = "year", maxLength = 6)
@Length(max = 6, message = "year不能超过6个字符")
@ExcelProperty("year")
@Schema(description = "year")
private String year;
/**
* month
*/
@ExcelAttribute(name = "month", maxLength = 6)
@Length(max = 6, message = "month不能超过6个字符")
@ExcelProperty("month")
@Schema(description = "month")
private String month;
/**
* day
*/
@ExcelAttribute(name = "day", maxLength = 2)
@Length(max = 2, message = "day不能超过2个字符")
@ExcelProperty("day")
@Schema(description = "day")
private String day;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
* 社保医疗截止日配置
*
* @author fxj
* @date 2024-05-08 11:52:09
*/
@Data
@TableName("t_social_deadline_info")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "社保医疗截止日配置")
public class TSocialDeadlineInfo extends BaseEntity {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("id")
@Schema(description = "id")
private String id;
/**
* 月份
*/
@ExcelAttribute(name = "月份", isNotEmpty = true, errorInfo = "月份不能为空", maxLength = 6)
@NotBlank(message = "月份不能为空")
@Length(max = 6, message = "月份不能超过6个字符")
@ExcelProperty("月份")
@Schema(description = "月份")
private String month;
/**
* 省
*/
@ExcelAttribute(name = "省", isNotEmpty = true, errorInfo = "省不能为空", maxLength = 10)
@NotBlank(message = "省不能为空")
@Length(max = 10, message = "省不能超过10个字符")
@ExcelProperty("省")
@Schema(description = "省")
private String province;
/**
* 市
*/
@ExcelAttribute(name = "市", maxLength = 10)
@Length(max = 10, message = "市不能超过10个字符")
@ExcelProperty("市")
@Schema(description = "市")
private String city;
/**
* 县
*/
@ExcelAttribute(name = "县", maxLength = 10)
@Length(max = 10, message = "县不能超过10个字符")
@ExcelProperty("县")
@Schema(description = "县")
private String town;
/**
* 社保截止日
*/
@ExcelAttribute(name = "社保截止日", isNotEmpty = true, errorInfo = "社保截止日不能为空", isDate = true)
@NotBlank(message = "社保截止日不能为空")
@ExcelProperty("社保截止日")
@Schema(description = "社保截止日")
private Date socialEndDate;
/**
* 医疗截止日
*/
@ExcelAttribute(name = "医疗截止日", isNotEmpty = true, errorInfo = "医疗截止日不能为空", isDate = true)
@NotBlank(message = "医疗截止日不能为空")
@ExcelProperty("医疗截止日")
@Schema(description = "医疗截止日")
private Date medicalEndDate;
/**
* 更新人
*/
@ExcelAttribute(name = "更新人", maxLength = 32)
@Length(max = 32, message = "更新人不能超过32个字符")
@ExcelProperty("更新人")
@Schema(description = "更新人")
private String updateName;
/**
* 启用禁用:0启用 1 禁用
*/
@ExcelAttribute(name = "启用禁用:0启用 1 禁用", maxLength = 1)
@Length(max = 1, message = "启用禁用:0启用 1 禁用不能超过1个字符")
@ExcelProperty("启用禁用:0启用 1 禁用")
@Schema(description = "启用禁用:0启用 1 禁用")
private String status;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.vo;
import com.yifu.cloud.plus.v1.yifu.social.entity.THolidayInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author fxj
* @date 2024-05-08 11:52:08
*/
@Data
public class THolidayInfoSearchVo extends THolidayInfo {
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID,多个逗号分割")
private String ids;
/**
* 创建时间区间 [开始时间,结束时间]
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
/**
* @Author fxj
* 查询数据起
**/
@Schema(description = "查询limit 开始")
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
@Schema(description = "查询limit 数据条数")
private int limitEnd;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* @author fxj
* @date 2024-05-08 11:52:08
*/
@Data
public class THolidayInfoVo extends RowIndex implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@NotBlank(message = "id 不能为空")
@Length(max = 32, message = "id 不能超过32 个字符")
@ExcelAttribute(name = "id", isNotEmpty = true, errorInfo = "id 不能为空", maxLength = 32)
@Schema(description = "id")
@ExcelProperty("id")
private String id;
/**
* date
*/
@ExcelAttribute(name = "date", isDate = true)
@Schema(description = "date")
@ExcelProperty("date")
private Date date;
/**
* year
*/
@Length(max = 6, message = "year 不能超过6 个字符")
@ExcelAttribute(name = "year", maxLength = 6)
@Schema(description = "year")
@ExcelProperty("year")
private String year;
/**
* month
*/
@Length(max = 6, message = "month 不能超过6 个字符")
@ExcelAttribute(name = "month", maxLength = 6)
@Schema(description = "month")
@ExcelProperty("month")
private String month;
/**
* day
*/
@Length(max = 2, message = "day 不能超过2 个字符")
@ExcelAttribute(name = "day", maxLength = 2)
@Schema(description = "day")
@ExcelProperty("day")
private String day;
/**
* 创建人id
*/
@Length(max = 32, message = "创建人id 不能超过32 个字符")
@ExcelAttribute(name = "创建人id", maxLength = 32)
@Schema(description = "创建人id")
@ExcelProperty("创建人id")
private String createBy;
/**
* 创建人姓名
*/
@Length(max = 32, message = "创建人姓名 不能超过32 个字符")
@ExcelAttribute(name = "创建人姓名", maxLength = 32)
@Schema(description = "创建人姓名")
@ExcelProperty("创建人姓名")
private String createName;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间", isDate = true)
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private Date createTime;
/**
* 更新人id
*/
@Length(max = 32, message = "更新人id 不能超过32 个字符")
@ExcelAttribute(name = "更新人id", maxLength = 32)
@Schema(description = "更新人id")
@ExcelProperty("更新人id")
private String updateBy;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间", isDate = true)
@Schema(description = "更新时间")
@ExcelProperty("更新时间")
private Date updateTime;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.vo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 社保医疗截止日配置
*
* @author fxj
* @date 2024-05-08 11:52:09
*/
@Data
public class TSocialDeadlineInfoSearchVo extends TSocialDeadlineInfo {
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID,多个逗号分割")
private String ids;
/**
* 创建时间区间 [开始时间,结束时间]
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
/**
* @Author fxj
* 查询数据起
**/
@Schema(description = "查询limit 开始")
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
@Schema(description = "查询limit 数据条数")
private int limitEnd;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* 社保医疗截止日配置
*
* @author fxj
* @date 2024-05-08 11:52:09
*/
@Data
public class TSocialDeadlineInfoVo extends RowIndex implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@NotBlank(message = "id 不能为空")
@Length(max = 32, message = "id 不能超过32 个字符")
@ExcelAttribute(name = "id", isNotEmpty = true, errorInfo = "id 不能为空", maxLength = 32)
@Schema(description = "id")
@ExcelProperty("id")
private String id;
/**
* 月份
*/
@NotBlank(message = "月份 不能为空")
@Length(max = 6, message = "月份 不能超过6 个字符")
@ExcelAttribute(name = "月份", isNotEmpty = true, errorInfo = "月份 不能为空", maxLength = 6)
@Schema(description = "月份")
@ExcelProperty("月份")
private String month;
/**
* 省
*/
@NotBlank(message = "省 不能为空")
@Length(max = 10, message = "省 不能超过10 个字符")
@ExcelAttribute(name = "省", isNotEmpty = true, errorInfo = "省 不能为空", maxLength = 10)
@Schema(description = "省")
@ExcelProperty("省")
private String province;
/**
* 市
*/
@Length(max = 10, message = "市 不能超过10 个字符")
@ExcelAttribute(name = "市", maxLength = 10)
@Schema(description = "市")
@ExcelProperty("市")
private String city;
/**
* 县
*/
@Length(max = 10, message = "县 不能超过10 个字符")
@ExcelAttribute(name = "县", maxLength = 10)
@Schema(description = "县")
@ExcelProperty("县")
private String town;
/**
* 社保截止日
*/
@NotBlank(message = "社保截止日 不能为空")
@ExcelAttribute(name = "社保截止日", isNotEmpty = true, errorInfo = "社保截止日 不能为空", isDate = true)
@Schema(description = "社保截止日")
@ExcelProperty("社保截止日")
private Date socialEndDate;
/**
* 医疗截止日
*/
@NotBlank(message = "医疗截止日 不能为空")
@ExcelAttribute(name = "医疗截止日", isNotEmpty = true, errorInfo = "医疗截止日 不能为空", isDate = true)
@Schema(description = "医疗截止日")
@ExcelProperty("医疗截止日")
private Date medicalEndDate;
/**
* 创建人id
*/
@Length(max = 32, message = "创建人id 不能超过32 个字符")
@ExcelAttribute(name = "创建人id", maxLength = 32)
@Schema(description = "创建人id")
@ExcelProperty("创建人id")
private String createBy;
/**
* 创建人姓名
*/
@Length(max = 32, message = "创建人姓名 不能超过32 个字符")
@ExcelAttribute(name = "创建人姓名", maxLength = 32)
@Schema(description = "创建人姓名")
@ExcelProperty("创建人姓名")
private String createName;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间", isDate = true)
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private Date createTime;
/**
* 更新人id
*/
@Length(max = 32, message = "更新人id 不能超过32 个字符")
@ExcelAttribute(name = "更新人id", maxLength = 32)
@Schema(description = "更新人id")
@ExcelProperty("更新人id")
private String updateBy;
/**
* 更新人
*/
@Length(max = 32, message = "更新人 不能超过32 个字符")
@ExcelAttribute(name = "更新人", maxLength = 32)
@Schema(description = "更新人")
@ExcelProperty("更新人")
private String updateName;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间", isDate = true)
@Schema(description = "更新时间")
@ExcelProperty("更新时间")
private Date updateTime;
/**
* 启用禁用:0启用 1 禁用
*/
@Length(max = 1, message = "启用禁用:0启用 1 禁用 不能超过1 个字符")
@ExcelAttribute(name = "启用禁用:0启用 1 禁用", maxLength = 1)
@Schema(description = "启用禁用:0启用 1 禁用")
@ExcelProperty("启用禁用:0启用 1 禁用")
private String status;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.social.entity.THolidayInfo;
import com.yifu.cloud.plus.v1.yifu.social.service.THolidayInfoService;
import com.yifu.cloud.plus.v1.yifu.social.vo.THolidayInfoSearchVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author fxj
* @date 2024-05-08 11:52:08
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tholidayinfo")
@Tag(name = "节假日管理")
public class THolidayInfoController {
private final THolidayInfoService tHolidayInfoService;
/**
* 简单分页查询
*
* @param page 分页对象
* @param tHolidayInfo
* @return
*/
@Operation(description = "简单分页查询")
@GetMapping("/page")
public R<IPage<THolidayInfo>> getTHolidayInfoPage(Page<THolidayInfo> page, THolidayInfoSearchVo tHolidayInfo) {
return new R<>(tHolidayInfoService.getTHolidayInfoPage(page, tHolidayInfo));
}
/**
* 不分页查询
*
* @param tHolidayInfo
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage")
//@PreAuthorize("@pms.hasPermission('demo_tholidayinfo_get')" )
public R<List<THolidayInfo>> getTHolidayInfoNoPage(@RequestBody THolidayInfoSearchVo tHolidayInfo) {
return R.ok(tHolidayInfoService.noPageDiy(tHolidayInfo));
}
/**
* 通过id查询
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('demo_tholidayinfo_get')")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('demo_tholidayinfo_get')")
public R<THolidayInfo> getById(@PathVariable("id") String id) {
return R.ok(tHolidayInfoService.getById(id));
}
/**
* 新增
*
* @param tHolidayInfo
* @return R
*/
@Operation(summary = "新增", description = "新增:hasPermission('demo_tholidayinfo_add')")
@SysLog("新增")
@PostMapping
@PreAuthorize("@pms.hasPermission('demo_tholidayinfo_add')")
public R<Boolean> save(@RequestBody THolidayInfo tHolidayInfo) {
return R.ok(tHolidayInfoService.save(tHolidayInfo));
}
/**
* 修改
*
* @param tHolidayInfo
* @return R
*/
@Operation(summary = "修改", description = "修改:hasPermission('demo_tholidayinfo_edit')")
@SysLog("修改")
@PutMapping
@PreAuthorize("@pms.hasPermission('demo_tholidayinfo_edit')")
public R<Boolean> updateById(@RequestBody THolidayInfo tHolidayInfo) {
return R.ok(tHolidayInfoService.updateById(tHolidayInfo));
}
/**
* 通过id删除
*
* @param id id
* @return R
*/
@Operation(summary = "通过id删除", description = "通过id删除:hasPermission('demo_tholidayinfo_del')")
@SysLog("通过id删除")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('demo_tholidayinfo_del')")
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tHolidayInfoService.removeById(id));
}
/**
* 批量导入
*
* @author fxj
* @date 2024-05-08 11:52:08
**/
@SneakyThrows
@Operation(description = "批量新增 hasPermission('demo_tholidayinfo-batch-import')")
@SysLog("批量新增")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('demo_tholidayinfo-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tHolidayInfoService.importDiy(file.getInputStream());
}
/**
* 批量导出
*
* @author fxj
* @date 2024-05-08 11:52:08
**/
@Operation(description = "导出 hasPermission('demo_tholidayinfo-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('demo_tholidayinfo-export')")
public void export(HttpServletResponse response, @RequestBody THolidayInfoSearchVo searchVo) {
tHolidayInfoService.listExport(response, searchVo);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.controller;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
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.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.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceTypeRate;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialDeadlineInfoService;
import com.yifu.cloud.plus.v1.yifu.social.vo.TSocialDeadlineInfoSearchVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
* 社保医疗截止日配置
*
* @author fxj
* @date 2024-05-08 11:52:09
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tsocialdeadlineinfo")
@Tag(name = "社保医疗截止日配置管理")
public class TSocialDeadlineInfoController {
private final TSocialDeadlineInfoService tSocialDeadlineInfoService;
/**
* 简单分页查询
*
* @param page 分页对象
* @param tSocialDeadlineInfo 社保医疗截止日配置
* @return
*/
@Operation(description = "简单分页查询")
@GetMapping("/page")
public R<IPage<TSocialDeadlineInfo>> getTSocialDeadlineInfoPage(Page<TSocialDeadlineInfo> page, TSocialDeadlineInfoSearchVo tSocialDeadlineInfo) {
return new R<>(tSocialDeadlineInfoService.getTSocialDeadlineInfoPage(page, tSocialDeadlineInfo));
}
/**
* 不分页查询
*
* @param tSocialDeadlineInfo 社保医疗截止日配置
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage")
public R<List<TSocialDeadlineInfo>> getTSocialDeadlineInfoNoPage(@RequestBody TSocialDeadlineInfoSearchVo tSocialDeadlineInfo) {
return R.ok(tSocialDeadlineInfoService.noPageDiy(tSocialDeadlineInfo));
}
/**
* 通过id查询社保医疗截止日配置
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('demo_tsocialdeadlineinfo_get')")
@GetMapping("/{id}")
public R<TSocialDeadlineInfo> getById(@PathVariable("id") String id) {
return R.ok(tSocialDeadlineInfoService.getById(id));
}
/**
* 新增社保医疗截止日配置
*
* @param tSocialDeadlineInfo 社保医疗截止日配置
* @return R
*/
@Operation(summary = "新增社保医疗截止日配置", description = "新增社保医疗截止日配置:hasPermission('demo_tsocialdeadlineinfo_add')")
@SysLog("新增社保医疗截止日配置")
@PostMapping
public R<Boolean> save(@RequestBody TSocialDeadlineInfo tSocialDeadlineInfo) {
LambdaQueryWrapper<TSocialDeadlineInfo> queryWrapper = new LambdaQueryWrapper<>();
initCheckSql(tSocialDeadlineInfo, queryWrapper);
TSocialDeadlineInfo exit = tSocialDeadlineInfoService.getOne(queryWrapper.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exit)){
return R.failed("已存在对应月份与缴纳地的配置,请确认后操作!");
}
return R.ok(tSocialDeadlineInfoService.save(tSocialDeadlineInfo));
}
private void initCheckSql(TSocialDeadlineInfo tSocialDeadlineInfo, LambdaQueryWrapper<TSocialDeadlineInfo> queryWrapper) {
queryWrapper.eq(TSocialDeadlineInfo::getMonth, tSocialDeadlineInfo.getMonth());
queryWrapper.eq(TSocialDeadlineInfo::getProvince, tSocialDeadlineInfo.getProvince());
if (Common.isNotNull(tSocialDeadlineInfo.getCity())){
queryWrapper.eq(TSocialDeadlineInfo::getCity, tSocialDeadlineInfo.getCity());
if (Common.isNotNull(tSocialDeadlineInfo.getTown())){
queryWrapper.eq(TSocialDeadlineInfo::getTown, tSocialDeadlineInfo.getTown());
}else {
queryWrapper.isNull(TSocialDeadlineInfo::getTown);
}
}else {
queryWrapper.isNull(TSocialDeadlineInfo::getCity);
}
}
/**
* 修改社保医疗截止日配置
*
* @param tSocialDeadlineInfo 社保医疗截止日配置
* @return R
*/
@Operation(summary = "修改社保医疗截止日配置", description = "修改社保医疗截止日配置:hasPermission('demo_tsocialdeadlineinfo_edit')")
@SysLog("修改社保医疗截止日配置")
@PutMapping
public R<Boolean> updateById(@RequestBody TSocialDeadlineInfo tSocialDeadlineInfo) {
LambdaQueryWrapper<TSocialDeadlineInfo> queryWrapper = new LambdaQueryWrapper<>();
initCheckSql(tSocialDeadlineInfo, queryWrapper);
queryWrapper.ne(TSocialDeadlineInfo::getId,tSocialDeadlineInfo.getId());
TSocialDeadlineInfo exit = tSocialDeadlineInfoService.getOne(queryWrapper.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exit)){
return R.failed("已存在对应月份与缴纳地的配置,请确认后操作!");
}
return R.ok(tSocialDeadlineInfoService.updateById(tSocialDeadlineInfo));
}
/**
* 通过id删除社保医疗截止日配置
*
* @param id id
* @return R
*/
@Operation(summary = "通过id删除社保医疗截止日配置", description = "通过id删除社保医疗截止日配置:hasPermission('demo_tsocialdeadlineinfo_del')")
@SysLog("通过id删除社保医疗截止日配置")
@DeleteMapping("/{id}")
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tSocialDeadlineInfoService.removeById(id));
}
/**
* 通过id启用/禁用社保医疗截止日配置
*
* @param id id
* @return R
*/
@Operation(summary = "通过id启用0/禁用1社保医疗截止日配置", description = "通过id启用0/禁用1社保医疗截止日配置")
@SysLog("通过id启用/禁用社保医疗截止日配置")
@PutMapping("/{id}")
public R<Boolean> updateStatusById(@PathVariable String id,@RequestParam String status) {
YifuUser user = SecurityUtils.getUser();
if (!Common.isNotNull(user)){
return R.failed(CommonConstants.USER_FAIL);
}
if (!CommonConstants.ZERO_STRING.equals(status) && !CommonConstants.ONE_STRING.equals(status)){
return R.failed(CommonConstants.PARAM_INFO_ERROR);
}
LambdaUpdateWrapper<TSocialDeadlineInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(TSocialDeadlineInfo::getId,id)
.set(TSocialDeadlineInfo::getStatus, status)
.set(BaseEntity::getUpdateTime, DateUtil.getCurrentDateTime())
.set(TSocialDeadlineInfo::getUpdateName, user.getNickname())
.set(BaseEntity::getUpdateBy,user.getId());
return R.ok(tSocialDeadlineInfoService.update(updateWrapper));
}
/**
* 社保医疗截止日配置 批量导入
*
* @author fxj
* @date 2024-05-08 11:52:09
**/
@SneakyThrows
@Operation(description = "批量新增社保医疗截止日配置 hasPermission('demo_tsocialdeadlineinfo-batch-import')")
@SysLog("批量新增社保医疗截止日配置")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('demo_tsocialdeadlineinfo-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tSocialDeadlineInfoService.importDiy(file.getInputStream());
}
/**
* 社保医疗截止日配置 批量导出
*
* @author fxj
* @date 2024-05-08 11:52:09
**/
@Operation(description = "导出社保医疗截止日配置 hasPermission('demo_tsocialdeadlineinfo-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('demo_tsocialdeadlineinfo-export')")
public void export(HttpServletResponse response, @RequestBody TSocialDeadlineInfoSearchVo searchVo) {
tSocialDeadlineInfoService.listExport(response, searchVo);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.social.entity.THolidayInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @author fxj
* @date 2024-05-08 11:52:08
*/
@Mapper
public interface THolidayInfoMapper extends BaseMapper<THolidayInfo> {
/**
* 简单分页查询
*
* @param tHolidayInfo
* @return
*/
IPage<THolidayInfo> getTHolidayInfoPage(Page<THolidayInfo> page, @Param("tHolidayInfo") THolidayInfo tHolidayInfo);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 社保医疗截止日配置
*
* @author fxj
* @date 2024-05-08 11:52:09
*/
@Mapper
public interface TSocialDeadlineInfoMapper extends BaseMapper<TSocialDeadlineInfo> {
/**
* 社保医疗截止日配置简单分页查询
*
* @param tSocialDeadlineInfo 社保医疗截止日配置
* @return
*/
IPage<TSocialDeadlineInfo> getTSocialDeadlineInfoPage(Page<TSocialDeadlineInfo> page, @Param("tSocialDeadlineInfo") TSocialDeadlineInfo tSocialDeadlineInfo);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
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.social.entity.THolidayInfo;
import com.yifu.cloud.plus.v1.yifu.social.vo.THolidayInfoSearchVo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
* @author fxj
* @date 2024-05-08 11:52:08
*/
public interface THolidayInfoService extends IService<THolidayInfo> {
/**
* 简单分页查询
*
* @param tHolidayInfo
* @return
*/
IPage<THolidayInfo> getTHolidayInfoPage(Page<THolidayInfo> page, THolidayInfoSearchVo tHolidayInfo);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, THolidayInfoSearchVo searchVo);
List<THolidayInfo> noPageDiy(THolidayInfoSearchVo searchVo);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
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.social.entity.TSocialDeadlineInfo;
import com.yifu.cloud.plus.v1.yifu.social.vo.TSocialDeadlineInfoSearchVo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
* 社保医疗截止日配置
*
* @author fxj
* @date 2024-05-08 11:52:09
*/
public interface TSocialDeadlineInfoService extends IService<TSocialDeadlineInfo> {
/**
* 社保医疗截止日配置简单分页查询
*
* @param tSocialDeadlineInfo 社保医疗截止日配置
* @return
*/
IPage<TSocialDeadlineInfo> getTSocialDeadlineInfoPage(Page<TSocialDeadlineInfo> page, TSocialDeadlineInfoSearchVo tSocialDeadlineInfo);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TSocialDeadlineInfoSearchVo searchVo);
List<TSocialDeadlineInfo> noPageDiy(TSocialDeadlineInfoSearchVo searchVo);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.mybatis.base.BaseEntity;
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;
import com.yifu.cloud.plus.v1.yifu.social.vo.THolidayInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.THolidayInfoVo;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
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;
/**
* @author fxj
* @date 2024-05-08 11:52:08
*/
@Log4j2
@Service
public class THolidayInfoServiceImpl extends ServiceImpl<THolidayInfoMapper, THolidayInfo> implements THolidayInfoService {
/**
* 简单分页查询
*
* @param tHolidayInfo
* @return
*/
@Override
public IPage<THolidayInfo> getTHolidayInfoPage(Page<THolidayInfo> page, THolidayInfoSearchVo tHolidayInfo) {
return baseMapper.getTHolidayInfoPage(page, tHolidayInfo);
}
/**
* 批量导出
*
* @param searchVo
* @return
*/
@Override
public void listExport(HttpServletResponse response, THolidayInfoSearchVo searchVo) {
String fileName = "批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<THolidayInfo> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, THolidayInfo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)) {
ExcelUtil<THolidayInfo> util = new ExcelUtil<>(THolidayInfo.class);
for (THolidayInfo vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("" + index).build();
excelWriter.write(list, writeSheet);
index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) {
list.clear();
}
}
} else {
WriteSheet writeSheet = EasyExcel.writerSheet("" + index).build();
excelWriter.write(list, writeSheet);
}
if (Common.isNotNull(list)) {
list.clear();
}
out.flush();
excelWriter.finish();
} catch (Exception e) {
log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
}
@Override
public List<THolidayInfo> noPageDiy(THolidayInfoSearchVo searchVo) {
LambdaQueryWrapper<THolidayInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(THolidayInfo::getId, idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0) {
wrapper.last(" limit " + searchVo.getLimitStart() + "," + searchVo.getLimitEnd());
}
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectList(wrapper);
}
private Long noPageCountDiy(THolidayInfoSearchVo searchVo) {
LambdaQueryWrapper<THolidayInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(THolidayInfo::getId, idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(THolidayInfoSearchVo entity) {
LambdaQueryWrapper<THolidayInfo> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(THolidayInfo::getCreateTime, entity.getCreateTimes()[0])
.le(THolidayInfo::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())) {
wrapper.eq(THolidayInfo::getCreateName, entity.getCreateName());
}
return wrapper;
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<THolidayInfoVo> util1 = new ExcelUtil<>(THolidayInfoVo.class);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, THolidayInfoVo.class, new ReadListener<THolidayInfoVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<THolidayInfoVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(THolidayInfoVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTHolidayInfo(cachedDataList, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private void importTHolidayInfo(List<THolidayInfoVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
THolidayInfoVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(THolidayInfoVo excel) {
THolidayInfo insert = new THolidayInfo();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo;
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.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
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;
/**
* 社保医疗截止日配置
*
* @author fxj
* @date 2024-05-08 11:52:09
*/
@Log4j2
@Service
public class TSocialDeadlineInfoServiceImpl extends ServiceImpl<TSocialDeadlineInfoMapper, TSocialDeadlineInfo> implements TSocialDeadlineInfoService {
/**
* 社保医疗截止日配置简单分页查询
*
* @param tSocialDeadlineInfo 社保医疗截止日配置
* @return
*/
@Override
public IPage<TSocialDeadlineInfo> getTSocialDeadlineInfoPage(Page<TSocialDeadlineInfo> page, TSocialDeadlineInfoSearchVo tSocialDeadlineInfo) {
return baseMapper.getTSocialDeadlineInfoPage(page, tSocialDeadlineInfo);
}
/**
* 社保医疗截止日配置批量导出
*
* @param searchVo 社保医疗截止日配置
* @return
*/
@Override
public void listExport(HttpServletResponse response, TSocialDeadlineInfoSearchVo searchVo) {
String fileName = "社保医疗截止日配置批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TSocialDeadlineInfo> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, TSocialDeadlineInfo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)) {
ExcelUtil<TSocialDeadlineInfo> util = new ExcelUtil<>(TSocialDeadlineInfo.class);
for (TSocialDeadlineInfo vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("社保医疗截止日配置" + index).build();
excelWriter.write(list, writeSheet);
index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) {
list.clear();
}
}
} else {
WriteSheet writeSheet = EasyExcel.writerSheet("社保医疗截止日配置" + index).build();
excelWriter.write(list, writeSheet);
}
if (Common.isNotNull(list)) {
list.clear();
}
out.flush();
excelWriter.finish();
} catch (Exception e) {
log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
}
@Override
public List<TSocialDeadlineInfo> noPageDiy(TSocialDeadlineInfoSearchVo searchVo) {
LambdaQueryWrapper<TSocialDeadlineInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TSocialDeadlineInfo::getId, idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0) {
wrapper.last(" limit " + searchVo.getLimitStart() + "," + searchVo.getLimitEnd());
}
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectList(wrapper);
}
private Long noPageCountDiy(TSocialDeadlineInfoSearchVo searchVo) {
LambdaQueryWrapper<TSocialDeadlineInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TSocialDeadlineInfo::getId, idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TSocialDeadlineInfoSearchVo entity) {
LambdaQueryWrapper<TSocialDeadlineInfo> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(TSocialDeadlineInfo::getCreateTime, entity.getCreateTimes()[0])
.le(TSocialDeadlineInfo::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())) {
wrapper.eq(TSocialDeadlineInfo::getCreateName, entity.getCreateName());
}
return wrapper;
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TSocialDeadlineInfoVo> util1 = new ExcelUtil<>(TSocialDeadlineInfoVo.class);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TSocialDeadlineInfoVo.class, new ReadListener<TSocialDeadlineInfoVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TSocialDeadlineInfoVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TSocialDeadlineInfoVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTSocialDeadlineInfo(cachedDataList, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private void importTSocialDeadlineInfo(List<TSocialDeadlineInfoVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TSocialDeadlineInfoVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TSocialDeadlineInfoVo excel) {
TSocialDeadlineInfo insert = new TSocialDeadlineInfo();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.social.mapper.THolidayInfoMapper">
<resultMap id="tHolidayInfoMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.THolidayInfo">
<id property="id" column="ID"/>
<result property="date" column="DATE"/>
<result property="year" column="YEAR"/>
<result property="month" column="MONTH"/>
<result property="day" column="DAY"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.DATE,
a.YEAR,
a.MONTH,
a.DAY,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME
</sql>
<sql id="tHolidayInfo_where">
<if test="tHolidayInfo != null">
<if test="tHolidayInfo.id != null and tHolidayInfo.id.trim() != ''">
AND a.ID = #{tHolidayInfo.id}
</if>
<if test="tHolidayInfo.date != null">
AND a.DATE = #{tHolidayInfo.date}
</if>
<if test="tHolidayInfo.year != null and tHolidayInfo.year.trim() != ''">
AND a.YEAR = #{tHolidayInfo.year}
</if>
<if test="tHolidayInfo.month != null and tHolidayInfo.month.trim() != ''">
AND a.MONTH = #{tHolidayInfo.month}
</if>
<if test="tHolidayInfo.day != null and tHolidayInfo.day.trim() != ''">
AND a.DAY = #{tHolidayInfo.day}
</if>
<if test="tHolidayInfo.createBy != null and tHolidayInfo.createBy.trim() != ''">
AND a.CREATE_BY = #{tHolidayInfo.createBy}
</if>
<if test="tHolidayInfo.createName != null and tHolidayInfo.createName.trim() != ''">
AND a.CREATE_NAME = #{tHolidayInfo.createName}
</if>
<if test="tHolidayInfo.createTime != null">
AND a.CREATE_TIME = #{tHolidayInfo.createTime}
</if>
<if test="tHolidayInfo.updateBy != null and tHolidayInfo.updateBy.trim() != ''">
AND a.UPDATE_BY = #{tHolidayInfo.updateBy}
</if>
<if test="tHolidayInfo.updateTime != null">
AND a.UPDATE_TIME = #{tHolidayInfo.updateTime}
</if>
</if>
</sql>
<!--tHolidayInfo简单分页查询-->
<select id="getTHolidayInfoPage" resultMap="tHolidayInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_holiday_info a
<where>
1=1
<include refid="tHolidayInfo_where"/>
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialDeadlineInfoMapper">
<resultMap id="tSocialDeadlineInfoMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo">
<id property="id" column="ID"/>
<result property="month" column="MONTH"/>
<result property="province" column="PROVINCE"/>
<result property="city" column="CITY"/>
<result property="town" column="TOWN"/>
<result property="socialEndDate" column="SOCIAL_END_DATE"/>
<result property="medicalEndDate" column="MEDICAL_END_DATE"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="updateName" column="UPDATE_NAME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="status" column="STATUS"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.MONTH,
a.PROVINCE,
a.CITY,
a.TOWN,
a.SOCIAL_END_DATE,
a.MEDICAL_END_DATE,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_NAME,
a.UPDATE_TIME,
a.STATUS
</sql>
<sql id="tSocialDeadlineInfo_where">
<if test="tSocialDeadlineInfo != null">
<if test="tSocialDeadlineInfo.id != null and tSocialDeadlineInfo.id.trim() != ''">
AND a.ID = #{tSocialDeadlineInfo.id}
</if>
<if test="tSocialDeadlineInfo.month != null and tSocialDeadlineInfo.month.trim() != ''">
AND a.MONTH = #{tSocialDeadlineInfo.month}
</if>
<if test="tSocialDeadlineInfo.province != null and tSocialDeadlineInfo.province.trim() != ''">
AND a.PROVINCE = #{tSocialDeadlineInfo.province}
</if>
<if test="tSocialDeadlineInfo.city != null and tSocialDeadlineInfo.city.trim() != ''">
AND a.CITY = #{tSocialDeadlineInfo.city}
</if>
<if test="tSocialDeadlineInfo.town != null and tSocialDeadlineInfo.town.trim() != ''">
AND a.TOWN = #{tSocialDeadlineInfo.town}
</if>
<if test="tSocialDeadlineInfo.socialEndDate != null">
AND a.SOCIAL_END_DATE = #{tSocialDeadlineInfo.socialEndDate}
</if>
<if test="tSocialDeadlineInfo.medicalEndDate != null">
AND a.MEDICAL_END_DATE = #{tSocialDeadlineInfo.medicalEndDate}
</if>
<if test="tSocialDeadlineInfo.createBy != null and tSocialDeadlineInfo.createBy.trim() != ''">
AND a.CREATE_BY = #{tSocialDeadlineInfo.createBy}
</if>
<if test="tSocialDeadlineInfo.createName != null and tSocialDeadlineInfo.createName.trim() != ''">
AND a.CREATE_NAME = #{tSocialDeadlineInfo.createName}
</if>
<if test="tSocialDeadlineInfo.createTime != null">
AND a.CREATE_TIME = #{tSocialDeadlineInfo.createTime}
</if>
<if test="tSocialDeadlineInfo.updateBy != null and tSocialDeadlineInfo.updateBy.trim() != ''">
AND a.UPDATE_BY = #{tSocialDeadlineInfo.updateBy}
</if>
<if test="tSocialDeadlineInfo.updateName != null and tSocialDeadlineInfo.updateName.trim() != ''">
AND a.UPDATE_NAME = #{tSocialDeadlineInfo.updateName}
</if>
<if test="tSocialDeadlineInfo.updateTime != null">
AND a.UPDATE_TIME = #{tSocialDeadlineInfo.updateTime}
</if>
<if test="tSocialDeadlineInfo.status != null and tSocialDeadlineInfo.status.trim() != ''">
AND a.STATUS = #{tSocialDeadlineInfo.status}
</if>
</if>
</sql>
<!--tSocialDeadlineInfo简单分页查询-->
<select id="getTSocialDeadlineInfoPage" resultMap="tSocialDeadlineInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_social_deadline_info a
<where>
1=1
<include refid="tSocialDeadlineInfo_where"/>
</where>
</select>
</mapper>
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