Commit 1d7f716d authored by hongguangwu's avatar hongguangwu

MVP1.6.4-薪资原表识别导出

parent 62cf9946
/*
* 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.salary.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
/**
* 薪资原表识别配置导出vo
*
* @author hgw
* @date 2023-01-10 11:34:27
*/
@Data
@Schema(description = "薪资代发户配置导出Vo")
public class TSalaryOriginalExportVo {
@ExcelAttribute(name = "项目编码", maxLength = 32)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("项目编码")
private String deptNo;
@ExcelAttribute(name = "项目名称", maxLength = 50)
@Length(max = 50, message = "项目名称不能超过50个字符")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("项目名称")
private String deptName;
@ExcelAttribute(name = "原表类型", maxLength = 50)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("原表类型")
private String setName;
@ExcelAttribute(name = "申请人", maxLength = 50)
@Schema(description = "申请人")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("申请人")
private String createName;
@ExcelAttribute(name = "申请时间", maxLength = 50)
@Schema(description = "申请时间")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("申请时间")
private String createTime;
}
/*
* 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.salary.vo;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 薪资识别配置导出查询vo
*
* @author hgw
* @date 2024-5-13 17:50:35
*/
@Data
public class TSalaryOriginalSearchVo extends TSalaryStandardOriginal {
/**
* 多选导出或删除等操作
*/
@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;
}
...@@ -31,9 +31,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal; ...@@ -31,9 +31,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalDetailService; import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalDetailService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalService; import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.*;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadOriginalParamVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -42,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -42,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
...@@ -266,4 +265,17 @@ public class TSalaryStandardOriginalController { ...@@ -266,4 +265,17 @@ public class TSalaryStandardOriginalController {
return tSalaryStandardOriginalService.salaryUploadByOriginal(file, vo); return tSalaryStandardOriginalService.salaryUploadByOriginal(file, vo);
} }
/**
* 薪资原表配置导出 批量导出
* @author hgw
* @date 2024-5-13 17:47:07
**/
//@Operation(description = "薪资原表配置导出 hasPermission('tsalaryoriginal-export')")
@Operation(description = "薪资原表配置导出")
@PostMapping("/exportOriginal")
//@PreAuthorize("@pms.hasPermission('tsalaryoriginal-export')")
public void exportOriginal(HttpServletResponse response, @RequestBody TSalaryOriginalSearchVo searchVo) {
tSalaryStandardOriginalService.exportOriginal(response,searchVo);
}
} }
...@@ -20,7 +20,11 @@ package com.yifu.cloud.plus.v1.yifu.salary.mapper; ...@@ -20,7 +20,11 @@ package com.yifu.cloud.plus.v1.yifu.salary.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardIssue;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryOriginalExportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryOriginalSearchVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardIssueExportVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -50,4 +54,7 @@ public interface TSalaryStandardOriginalMapper extends BaseMapper<TSalaryStandar ...@@ -50,4 +54,7 @@ public interface TSalaryStandardOriginalMapper extends BaseMapper<TSalaryStandar
*/ */
List<String> getSpecialIdCardList(); List<String> getSpecialIdCardList();
List<TSalaryOriginalExportVo> getTSalaryOriginalExportVoList(@Param("tSalaryStandardOriginal") TSalaryOriginalSearchVo tSalaryStandardOriginal
, @Param("idsStr") List<String> idsStr);
} }
...@@ -22,11 +22,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -22,11 +22,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.*;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadOriginalParamVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
...@@ -64,4 +63,12 @@ public interface TSalaryStandardOriginalService extends IService<TSalaryStandard ...@@ -64,4 +63,12 @@ public interface TSalaryStandardOriginalService extends IService<TSalaryStandard
**/ **/
R<SalaryUploadParamVo> salaryUploadByOriginal(MultipartFile file, SalaryUploadOriginalParamVo excelVo); R<SalaryUploadParamVo> salaryUploadByOriginal(MultipartFile file, SalaryUploadOriginalParamVo excelVo);
/**
* @Description: 薪资原表配置导出
* @Author: hgw
* @Date: 2024/5/13 17:47
* @return: void
**/
void exportOriginal(HttpServletResponse response, TSalaryOriginalSearchVo searchVo);
} }
...@@ -16,15 +16,23 @@ ...@@ -16,15 +16,23 @@
*/ */
package com.yifu.cloud.plus.v1.yifu.salary.service.impl; package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.monitorjbl.xlsx.StreamingReader; import com.monitorjbl.xlsx.StreamingReader;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard; import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; 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.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardIssue;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardOriginalMapper; import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardOriginalMapper;
...@@ -32,10 +40,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.service.SalaryUploadService; ...@@ -32,10 +40,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.service.SalaryUploadService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalDetailService; import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalDetailService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalService; import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardOriginalService;
import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants; import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelColumnVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.*;
import com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadOriginalParamVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryUploadParamVo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
...@@ -43,9 +48,12 @@ import org.apache.poi.ss.usermodel.*; ...@@ -43,9 +48,12 @@ import org.apache.poi.ss.usermodel.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -80,6 +88,17 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -80,6 +88,17 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
return baseMapper.getTSalaryStandardOriginalPage(page, tSalaryStandardOriginal); return baseMapper.getTSalaryStandardOriginalPage(page, tSalaryStandardOriginal);
} }
/**
* @Description: 导出
* @Author: hgw
* @Date: 2023/1/18 10:31
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardIssueExportVo>
**/
private List<TSalaryOriginalExportVo> exportList(TSalaryOriginalSearchVo searchVo) {
List<String> idList = Common.getList(searchVo.getIds());
return baseMapper.getTSalaryOriginalExportVoList(searchVo, idList);
}
/** /**
* @Description: 分页查询 * @Description: 分页查询
* @Author: hgw * @Author: hgw
...@@ -1013,4 +1032,77 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -1013,4 +1032,77 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
return R.failed("无法识别数据!请联系管理员!"); return R.failed("无法识别数据!请联系管理员!");
} }
/**
* @Description: 薪资原表配置导出
* @Author: hgw
* @Date: 2024/5/13 17:47
* @return: void
**/
@Override
public void exportOriginal(HttpServletResponse response, TSalaryOriginalSearchVo searchVo) {
String fileName = "薪资原表配置导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TSalaryOriginalExportVo> 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,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcelFactory.write(out, TSalaryStandardIssueExportVo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i = i + CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = exportList(searchVo);
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcelFactory.writerSheet("原表配置" + index).build();
excelWriter.write(list, writeSheet);
index++;
list.clear();
}
}
} else {
WriteSheet writeSheet = EasyExcelFactory.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);
}
}
}
private Long noPageCountDiy(TSalaryOriginalSearchVo searchVo) {
LambdaQueryWrapper<TSalaryStandardOriginal> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TSalaryStandardOriginal::getId, idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TSalaryOriginalSearchVo entity) {
LambdaQueryWrapper<TSalaryOriginalSearchVo> wrapper = Wrappers.lambdaQuery(entity);
if (Common.isNotNull(entity.getCreateName())) {
wrapper.like(TSalaryOriginalSearchVo::getCreateName, entity.getCreateName());
}
return wrapper;
}
} }
...@@ -43,6 +43,14 @@ ...@@ -43,6 +43,14 @@
<result property="dateNum" column="DATE_NUM"/> <result property="dateNum" column="DATE_NUM"/>
<result property="deleteFlag" column="DELETE_FLAG"/> <result property="deleteFlag" column="DELETE_FLAG"/>
</resultMap> </resultMap>
<resultMap id="TSalaryOriginalExportMap" type="com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryOriginalExportVo">
<result property="deptNo" column="DEPT_NO"/>
<result property="deptName" column="DEPT_NAME"/>
<result property="setName" column="SET_NAME"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
</resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
a.ID, a.ID,
a.DEPT_ID, a.DEPT_ID,
...@@ -98,6 +106,9 @@ ...@@ -98,6 +106,9 @@
<if test="tSalaryStandardOriginal.attaType != null and tSalaryStandardOriginal.attaType.trim() != ''"> <if test="tSalaryStandardOriginal.attaType != null and tSalaryStandardOriginal.attaType.trim() != ''">
AND ATTA_TYPE = #{tSalaryStandardOriginal.attaType} AND ATTA_TYPE = #{tSalaryStandardOriginal.attaType}
</if> </if>
<if test="tSalaryStandardOriginal.createName != null and tSalaryStandardOriginal.createName.trim() != ''">
and a.CREATE_NAME like concat('%',#{tSalaryStandardOriginal.createName},'%')
</if>
</if> </if>
</sql> </sql>
<!--TSalaryStandardOriginal简单分页查询--> <!--TSalaryStandardOriginal简单分页查询-->
...@@ -111,6 +122,29 @@ ...@@ -111,6 +122,29 @@
</where> </where>
ORDER BY a.CREATE_TIME desc ORDER BY a.CREATE_TIME desc
</select> </select>
<select id="getTSalaryOriginalExportVoList" resultMap="TSalaryOriginalExportMap">
SELECT
a.DEPT_NO,a.DEPT_NAME,a.SET_NAME,a.CREATE_NAME,a.CREATE_TIME
FROM
t_salary_standard_original a
<where> a.DELETE_FLAG = 0
<if test="idsStr != null and idsStr.size > 0">
AND a.ID in
<foreach item="items" index="index" collection="idsStr" open="(" separator="," close=")">
#{items}
</foreach>
</if>
<include refid="TSalaryStandardOriginal_where"/>
</where>
ORDER BY a.CREATE_TIME desc
<if test="tSalaryStandardOriginal != null">
<if test="tSalaryStandardOriginal.limitStart != null">
limit #{tSalaryStandardOriginal.limitStart},#{tSalaryStandardOriginal.limitEnd}
</if>
</if>
</select>
<!--导入工资时的获取识别配置列表--> <!--导入工资时的获取识别配置列表-->
<select id="getTSalaryStandardOriginalList" resultMap="TSalaryStandardOriginalMap"> <select id="getTSalaryStandardOriginalList" resultMap="TSalaryStandardOriginalMap">
SELECT SELECT
......
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