Commit 490e40c5 authored by hongguangwu's avatar hongguangwu

MVP1.4-EXPORT-报账、收入导出

parent 539856ec
...@@ -332,6 +332,8 @@ public interface CommonConstants { ...@@ -332,6 +332,8 @@ public interface CommonConstants {
String ID = "ID"; String ID = "ID";
String PARAM_IS_NOT_ERROR = "传参异常,请检查参数"; String PARAM_IS_NOT_ERROR = "传参异常,请检查参数";
int EXCEL_EXPORT_LIMIT = 60000; int EXCEL_EXPORT_LIMIT = 60000;
// 给量大的表导出使用
int EXCEL_EXPORT_LIMIT_3 = 30000;
String USER = "用户"; String USER = "用户";
......
...@@ -17,16 +17,15 @@ ...@@ -17,16 +17,15 @@
package com.yifu.cloud.plus.v1.yifu.salary.service.impl; package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.BigDecimalUtils;
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.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpSalaryParamVo; import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpSalaryParamVo;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.EkpSocialViewVo; import com.yifu.cloud.plus.v1.yifu.insurances.vo.EkpSocialViewVo;
import com.yifu.cloud.plus.v1.yifu.salary.entity.THaveSalaryNosocial; import com.yifu.cloud.plus.v1.yifu.salary.entity.THaveSalaryNosocial;
...@@ -86,38 +85,24 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper, ...@@ -86,38 +85,24 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper,
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8")); response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, TSalaryAccount.class).includeColumnFiledNames(searchVo.getExportFields()).build(); ExcelWriter excelWriter = EasyExcelFactory.write(out, TSalaryAccount.class).includeColumnFiledNames(searchVo.getExportFields()).build();
int index = 0; int index = 0;
WriteSheet writeSheet;
if (count > CommonConstants.ZERO_INT) { if (count > CommonConstants.ZERO_INT) {
WriteSheet writeSheet; for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT_3) {
ExcelUtil<TSalaryAccount> util;
for (int i = 0; i <= count; ) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT_3);
list = noPageDiy(searchVo); list = noPageDiy(searchVo);
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
util = new ExcelUtil<>(TSalaryAccount.class); writeSheet = EasyExcelFactory.writerSheet("工资报账主表(工资条)" + index).build();
for (TSalaryAccount vo : list) {
if (CommonConstants.THREE_STRING.equals(vo.getFormType())){
vo.setRelaySalary(vo.getRelaySalaryUnit());
vo.setSalaryTax(BigDecimalUtils.safeAdd(vo.getSalaryTax(),vo.getSalaryTaxUnit()));
}
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
writeSheet = EasyExcel.writerSheet("工资报账主表(工资条)" + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
} }
} else { } else {
WriteSheet writeSheet = EasyExcel.writerSheet("工资报账主表(工资条)" + index).build(); writeSheet = EasyExcelFactory.writerSheet("工资报账主表(工资条)" + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
} }
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
......
...@@ -242,6 +242,7 @@ ...@@ -242,6 +242,7 @@
a.SUM_BABY_MONEY, a.SUM_BABY_MONEY,
a.SUM_PRIVATE_PENSION a.SUM_PRIVATE_PENSION
</sql> </sql>
<sql id="tSalaryAccount_where"> <sql id="tSalaryAccount_where">
<if test="tSalaryAccount != null"> <if test="tSalaryAccount != null">
<if test="tSalaryAccount.id != null and tSalaryAccount.id.trim() != ''"> <if test="tSalaryAccount.id != null and tSalaryAccount.id.trim() != ''">
...@@ -626,7 +627,46 @@ ...@@ -626,7 +627,46 @@
<select id="noPageDiy" resultMap="tSalaryAccountMap" parameterType="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryAccount"> <select id="noPageDiy" resultMap="tSalaryAccountMap" parameterType="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryAccount">
SELECT SELECT
<include refid="Base_Column_List"/> a.ID,
a.INVOICE_TITLE,
a.SALARY_MONTH,
a.EMP_NAME,
a.EMP_IDCARD,
a.BANK_NO,
a.BANK_NAME,
a.DEPT_NO,
a.DEPT_NAME,
a.SALARY_GIVE_TIME,
a.DEDU_SOCIAL_MONTH,
a.DEDU_PROVIDENT_MONTH,
a.SETTLEMENT_MONTH,
a.ANNUAL_BONUS_TYPE,
a.TAX_MONTH,
a.IS_DEDUCT_SOCIAL,
a.IS_DEDUCT_FUND,
a.EMP_PHONE,
a.BANK_SUB_NAME,
ap.AREA_NAME BANK_PROVINCE,
ac.AREA_NAME BANK_CITY,
a.IS_PERSON_TAX,
ifnull(a.RELAY_SALARY,0) + ifnull(a.RELAY_SALARY_UNIT,0) RELAY_SALARY,
a.ACTUAL_SALARY,
ifnull(a.SALARY_TAX,0) + ifnull(a.SALARY_TAX_UNIT,0) SALARY_TAX,
a.CREATE_NAME,
a.CREATE_TIME,
a.UNIT_SOCIAL,
a.PERSON_SOCIAL,
a.UNIT_FUND,
a.PERSON_FUND,
a.COST_REDUCTION,
a.ANNUAL_BONUS_TAX,
a.SUM_CHILD_EDU_MONEY,
a.SUM_HOUSING_LOAN_MONEY,
a.SUM_HOUSING_RENT_MONEY,
a.SUM_SUPPORT_ELDERLY_MONEY,
a.SUM_CONTINUING_EDUCATION_MONEY,
a.SUM_BABY_MONEY,
a.SUM_PRIVATE_PENSION
FROM FROM
<if test="searchVo.salaryMonthStart == null or searchVo.salaryMonthStart.trim() >= '202201'"> <if test="searchVo.salaryMonthStart == null or searchVo.salaryMonthStart.trim() >= '202201'">
t_salary_account a t_salary_account a
...@@ -634,6 +674,8 @@ ...@@ -634,6 +674,8 @@
<if test="searchVo.salaryMonthStart != null and searchVo.salaryMonthStart.trim() &lt; '202201' "> <if test="searchVo.salaryMonthStart != null and searchVo.salaryMonthStart.trim() &lt; '202201' ">
t_salary_account_hro_2021 a t_salary_account_hro_2021 a
</if> </if>
left join sys_area ap on ap.id=a.BANK_PROVINCE
left join sys_area ac on ac.id=a.BANK_CITY
<where> <where>
a.DELETE_FLAG = 0 and not EXISTS ( a.DELETE_FLAG = 0 and not EXISTS (
select 1 from t_dept_see d where a.DEPT_NO = d.DEPT_NO and d.CAN_SEE = 1 select 1 from t_dept_see d where a.DEPT_NO = d.DEPT_NO and d.CAN_SEE = 1
......
...@@ -116,23 +116,16 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl ...@@ -116,23 +116,16 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
ExcelWriter excelWriter = EasyExcelFactory.write(out, IncomeExportVo.class).build(); ExcelWriter excelWriter = EasyExcelFactory.write(out, IncomeExportVo.class).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT) { if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) { WriteSheet writeSheet;
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT_3) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT_3);
list = noPageDiy(searchVo, Common.getList(searchVo.getIds())); list = noPageDiy(searchVo, Common.getList(searchVo.getIds()));
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
ExcelUtil<IncomeExportVo> util = new ExcelUtil<>(IncomeExportVo.class); writeSheet = EasyExcelFactory.writerSheet("收入明细表" + index).build();
for (IncomeExportVo vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcelFactory.writerSheet("收入明细表" + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
}
if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
} }
......
...@@ -176,12 +176,30 @@ ...@@ -176,12 +176,30 @@
<!--noPageDiy查询--> <!--noPageDiy查询-->
<select id="noPageDiy" resultMap="incomeExportMap"> <select id="noPageDiy" resultMap="incomeExportMap">
SELECT SELECT
<include refid="Base_Column_List"/> a.ID,
a.EMP_NAME,
a.EMP_IDCARD,
a.UNIT_NAME,
a.UNIT_NO,
a.DEPT_NAME,
a.DEPT_NO,
if(a.FEE_TYPE=1,'管理费','风险金') FEE_TYPE,
if(a.FEE_MODE=1,'按比例',if(a.FEE_MODE=2,'金额-人数','金额-人次')) FEE_MODE,
a.CHARGES,
case a.SOURCE_TYPE when 1 then '社保' when 2 then '公积金' when 3 then '商险' else '薪资' end SOURCE_TYPE,
a.MONEY,
a.CREATE_MONTH,
a.PAY_MONTH,
a.CREATE_TIME,
a.DATA_CREATE_MONTH,
if(a.SEND_STATUS=0,'未推送','已推送') SEND_STATUS,
a.SEND_TIME,
a.SEND_MONTH,
a.APPLY_NO
FROM t_income a FROM t_income a
<where> <where>
1=1 1=1
<include refid="export_sql"/> <include refid="export_sql"/>
group by a.id
order by a.CREATE_TIME DESC order by a.CREATE_TIME DESC
<if test="tIncome != null"> <if test="tIncome != null">
<if test="tIncome.limitStart != null"> <if test="tIncome.limitStart != null">
......
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