Commit 7e1ed015 authored by fangxinjiang's avatar fangxinjiang

员工报账查询-审核导出优化-fxj

parent 2b58de6f
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
/**
* @Author fxj
* @Date 2024/10/31
* @Description 员工报账查询审核导出明细项2
* @Version 1.0
*/
@Schema(description = " 员工报账查询审核导出明细项2")
@Data
public class TAuditExportItemVo {
private String salaryAccountId;
@ExcelProperty("通讯补贴(不计税)")
private BigDecimal phoneSubsidy;
@ExcelProperty("年终奖")
private BigDecimal annualBonus;
@ExcelProperty("免个税个人代扣")
private BigDecimal exemptionPersionTax;
@ExcelProperty("企业(职业)年金")
private BigDecimal enterpriseAnnuity;
}
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Author fxj
* @Date 2024/10/31
* @Description 员工报账查询审核导出明细项1
* @Version 1.0
*/
@Schema(description = " 员工报账查询审核导出明细项1")
@Data
@HeadFontStyle(fontHeightInPoints = 11)
public class TAuditExportStandardVo {
//关键关联字段
private String salaryFormId;
@ExcelProperty("薪酬状态")
private String status;
private String businessPrimaryTyp;
private String businessSecondType;
private String businessThirdType;
}
......@@ -35,6 +35,8 @@ import java.math.BigDecimal;
@HeadFontStyle(fontHeightInPoints = 11)
public class TSalaryAccountExportVo {
private String id;
private String salaryFormId;
// 是否劳务费 手机号 计税月份 发放时间 结算月份 工资月份 出账单位 结算单位 结算单位编码
// 结算部门 部门编码 人员类型 在职状态 员工姓名 身份证号 工资应发 实发工资合计
// 年终奖 薪资个税 年终奖扣税 代扣个人社保 代扣个人公积金 个人社保 个人公积金
......
......@@ -120,6 +120,17 @@ public interface TSalaryAccountMapper extends BaseMapper<TSalaryAccount> {
List<TSalaryAccountItemExportVo> auditExportSelectItems(@Param("idList") List<String> idList);
List<TAuditExportStandardVo> auditExportStandard(@Param("idList") List<String> idList);
List<TAuditExportItemVo> auditExportAnnualBonus(@Param("idList") List<String> idList);
List<TAuditExportItemVo> auditExportExemptionPersionTax(@Param("idList") List<String> idList);
List<TAuditExportItemVo> auditExportEnterpriseAnnuity(@Param("idList") List<String> idList);
List<TAuditExportItemVo> auditExportPhoneSubsidy(@Param("idList") List<String> idList);
List<TSalaryAccount> getAccountListBySalaryId(@Param("searchVo") TSalaryAccountSearchVo searchVo);
// 导出报账专用hgw
......
......@@ -39,6 +39,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryAccountService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -207,23 +208,65 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper,
if (count > CommonConstants.ZERO_INT) {
Map<String,TSalaryAccountItemExportVo> itemExportVoMap = new HashMap<>();
List<String> idList = null;
List<String> idStandardList = null;
List<TAuditExportStandardVo> standardItems = null;
Map<String,TAuditExportStandardVo> itemStandardMap = new HashMap<>();
Map<String,TAuditExportItemVo> itemAnnualBonusMap = new HashMap<>();
Map<String,TAuditExportItemVo> itemPersionTaxMap = new HashMap<>();
Map<String,TAuditExportItemVo> itemAnnuityMap = new HashMap<>();
Map<String,TAuditExportItemVo> itemSubsidyMap = new HashMap<>();
List<TSalaryAccountItemExportVo> items = null;
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT_2) {
List<TAuditExportItemVo> annualBonusItems;
List<TAuditExportItemVo> exemptionPersionTaxItems;
List<TAuditExportItemVo> enterpriseAnnuityItems;
List<TAuditExportItemVo> phoneSubsidyItems;
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT_1) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT_2);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT_1);
list = baseMapper.auditExportDiy(searchVo, searchVo.getIdList());
if (Common.isNotNull(list)) {
//先把数据封装完成
idList = list.stream().map(TSalaryAccountExportVo::getId).collect(Collectors.toList());
idStandardList = list.stream().map(TSalaryAccountExportVo::getSalaryFormId).collect(Collectors.toList());
//初始化明细数据MAP
if (Common.isNotNull(idList)){
items = baseMapper.auditExportSelectItems(idList);
if (Common.isNotNull(items)){
itemExportVoMap = items.stream().collect(Collectors.toMap(TSalaryAccountItemExportVo::getSalaryAccountId,vo -> vo,(k1,k2) -> k1));
}
items.clear();
annualBonusItems = baseMapper.auditExportAnnualBonus(idList);
if (Common.isNotNull(annualBonusItems)){
itemAnnualBonusMap = annualBonusItems.stream().collect(Collectors.toMap(TAuditExportItemVo::getSalaryAccountId,vo -> vo,(k1,k2) -> k1));
}
annualBonusItems.clear();
exemptionPersionTaxItems = baseMapper.auditExportExemptionPersionTax(idList);
if (Common.isNotNull(exemptionPersionTaxItems)){
itemPersionTaxMap = exemptionPersionTaxItems.stream().collect(Collectors.toMap(TAuditExportItemVo::getSalaryAccountId,vo -> vo,(k1,k2) -> k1));
}
exemptionPersionTaxItems.clear();
enterpriseAnnuityItems = baseMapper.auditExportEnterpriseAnnuity(idList);
if (Common.isNotNull(enterpriseAnnuityItems)){
itemAnnuityMap = enterpriseAnnuityItems.stream().collect(Collectors.toMap(TAuditExportItemVo::getSalaryAccountId,vo -> vo,(k1,k2) -> k1));
}
enterpriseAnnuityItems.clear();
phoneSubsidyItems = baseMapper.auditExportPhoneSubsidy(idList);
if (Common.isNotNull(phoneSubsidyItems)){
itemSubsidyMap = phoneSubsidyItems.stream().collect(Collectors.toMap(TAuditExportItemVo::getSalaryAccountId,vo -> vo,(k1,k2) -> k1));
}
phoneSubsidyItems.clear();
}
if (Common.isNotNull(items)){
itemExportVoMap = items.stream().collect(Collectors.toMap(TSalaryAccountItemExportVo::getSalaryAccountId,vo -> vo,(k1,k2) -> k1));
if (Common.isNotNull(idStandardList)){
standardItems = baseMapper.auditExportStandard(idStandardList);
if (Common.isNotNull(standardItems)){
itemStandardMap = standardItems.stream().collect(Collectors.toMap(TAuditExportStandardVo::getSalaryFormId,vo -> vo,(k1,k2) -> k1));
standardItems.clear();
}
}
//封装信息
initResult(list, itemExportVoMap);
initResult(list, itemExportVoMap,itemStandardMap,itemAnnualBonusMap,itemPersionTaxMap,itemAnnuityMap,itemSubsidyMap);
if (i%CommonConstants.EXCEL_EXPORT_LIMIT==0){
writeSheet = EasyExcelFactory.writerSheet("工资报账" + index).build();
index++;
......@@ -231,12 +274,7 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper,
excelWriter.write(list, writeSheet);
list.clear();
}
if (Common.isNotNull(idList)){
idList.clear();
}
if (Common.isNotNull(itemExportVoMap)){
itemExportVoMap.clear();
}
clearMap(itemExportVoMap, idList, idStandardList, itemStandardMap, itemAnnualBonusMap, itemPersionTaxMap, itemAnnuityMap, itemSubsidyMap);
}
} else {
writeSheet = EasyExcelFactory.writerSheet("工资报账" + index).build();
......@@ -261,14 +299,72 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper,
}
}
private void initResult(List<TSalaryAccountExportVo> list, Map<String, TSalaryAccountItemExportVo> itemExportVoMap) {
private void clearMap(Map<String, TSalaryAccountItemExportVo> itemExportVoMap, List<String> idList, List<String> idStandardList, Map<String, TAuditExportStandardVo> itemStandardMap, Map<String, TAuditExportItemVo> itemAnnualBonusMap, Map<String, TAuditExportItemVo> itemPersionTaxMap, Map<String, TAuditExportItemVo> itemAnnuityMap, Map<String, TAuditExportItemVo> itemSubsidyMap) {
if (Common.isNotNull(idList)){
idList.clear();
}
if (Common.isNotNull(idStandardList)){
idStandardList.clear();
}
if (Common.isNotNull(itemExportVoMap)){
itemExportVoMap.clear();
}
if (Common.isNotNull(itemStandardMap)){
itemStandardMap.clear();
}
if (Common.isNotNull(itemAnnualBonusMap)){
itemAnnualBonusMap.clear();
}
if (Common.isNotNull(itemPersionTaxMap)){
itemPersionTaxMap.clear();
}
if (Common.isNotNull(itemAnnuityMap)){
itemAnnuityMap.clear();
}
if (Common.isNotNull(itemSubsidyMap)){
itemSubsidyMap.clear();
}
}
private void initResult(List<TSalaryAccountExportVo> list,
Map<String, TSalaryAccountItemExportVo> itemExportVoMap,
Map<String,TAuditExportStandardVo> itemStandardMap,
Map<String,TAuditExportItemVo> itemAnnualBonusMap,
Map<String,TAuditExportItemVo> itemPersionTaxMap,
Map<String,TAuditExportItemVo> itemAnnuityMap,
Map<String,TAuditExportItemVo> itemSubsidyMap) {
TSalaryAccountItemExportVo voTemp;
TAuditExportStandardVo standardVo;
TAuditExportItemVo itemVo;
for (TSalaryAccountExportVo vo: list){
voTemp = itemExportVoMap.get(vo.getId());
if (Common.isNotNull(voTemp)){
vo.setPdeductionMoney(voTemp.getPdeductionMoney());
vo.setPdeductionDetail(voTemp.getPdeductionDetail());
}
standardVo = itemStandardMap.get(vo.getSalaryFormId());
if (Common.isNotNull(standardVo)){
vo.setStatus(standardVo.getStatus());
vo.setBusinessPrimaryType(standardVo.getBusinessPrimaryTyp());
vo.setBusinessSecondType(standardVo.getBusinessSecondType());
vo.setBusinessThirdType(standardVo.getBusinessThirdType());
}
itemVo = itemAnnualBonusMap.get(vo.getId());
if (Common.isNotNull(itemVo)){
vo.setAnnualBonus(itemVo.getAnnualBonus());
}
itemVo = itemPersionTaxMap.get(vo.getId());
if (Common.isNotNull(itemVo)){
vo.setExemptionPersionTax(itemVo.getExemptionPersionTax());
}
itemVo = itemAnnuityMap.get(vo.getId());
if (Common.isNotNull(itemVo)){
vo.setEnterpriseAnnuity(itemVo.getEnterpriseAnnuity());
}
itemVo = itemSubsidyMap.get(vo.getId());
if (Common.isNotNull(itemVo)){
vo.setPhoneSubsidy(itemVo.getPhoneSubsidy());
}
}
}
......
......@@ -1583,6 +1583,7 @@
<select id="auditExportDiy" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryAccountExportVo"
parameterType="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryAccount">
select
a.SALARY_FORM_ID as salaryFormId,
a.id,
case a.FORM_TYPE when '0' then '薪资' when '1' then '绩效' when '3' then '劳务费' when '4' then '稿酬' else '其他' end as formType,
a.EMP_PHONE as empPhone,
......@@ -1598,13 +1599,10 @@
a.EMP_IDCARD as empIdcard,
if(a.RELAY_SALARY_UNIT is not null and a.RELAY_SALARY_UNIT != 0, a.RELAY_SALARY_UNIT, ifnull(a.RELAY_SALARY,0)) as relaySalary,
a.ACTUAL_SALARY as actualSalary,
annualBonus.SALARY_MONEY as annualBonus,
ifnull(a.SALARY_TAX,0) + ifnull(a.SALARY_TAX_UNIT,0) as salaryTax,
a.ANNUAL_BONUS_TAX as annualBonusTax,
a.PERSON_SOCIAL as personSocial,
a.PERSON_FUND as personFund,
exemptionPersionTax.SALARY_MONEY as exemptionPersionTax,
enterpriseAnnuity.SALARY_MONEY as enterpriseAnnuity,
a.UNIT_SOCIAL as unitSocial,
a.UNIT_FUND as unitFund,
a.SUM_BABY_MONEY as sumBabyMoney,
......@@ -1616,22 +1614,21 @@
a.SUM_SUPPORT_ELDERLY_MONEY as sumSupportElderlyMoney,
a.COST_REDUCTION as costReduction,
a.CREATE_NAME as createName,
/*GROUP_CONCAT(pdeduction.CN_NAME,':',pdeduction.SALARY_MONEY SEPARATOR ';') pdeductionDetail,
sum(ifnull(pdeduction.SALARY_MONEY,0)) pdeductionMoney,*/
if(a.PAY_SETTLE_FLAG = '0','已结算',if(a.PAY_SETTLE_FLAG = '1','结算中',if(a.PAY_SETTLE_FLAG = '2','未结算','-'))) paySettleFlag,
case s.STATUS when 0 then '待提交' when 1 then '待审核' when 2 then '待推送明细' when 3 then '已推送待发放' when 4 then '已发放' when 5 then '审核不通过' when 6 then '确认不通过' when 7 then '财务退回' when 10 then '推送失败' when 11 then '已审核生成收入中' when 12 then '已审核生成收入失败' else '-' end as status
if(a.PAY_SETTLE_FLAG = '0','已结算',if(a.PAY_SETTLE_FLAG = '1','结算中',if(a.PAY_SETTLE_FLAG = '2','未结算','-'))) paySettleFlag
/*
,phoneSubsidy.SALARY_MONEY as phoneSubsidy
,s.BUSINESS_PRIMARY_TYPE as businessPrimaryType
,s.BUSINESS_SECOND_TYPE as businessSecondType
,s.BUSINESS_THIRD_TYPE as businessThirdType
annualBonus.SALARY_MONEY as annualBonus,
exemptionPersionTax.SALARY_MONEY as exemptionPersionTax,
enterpriseAnnuity.SALARY_MONEY as enterpriseAnnuity,
*/
from
t_salary_account a
left join t_salary_standard s on a.SALARY_FORM_ID = s.id
/*left join t_salary_standard s on a.SALARY_FORM_ID = s.id
left join t_salary_account_item annualBonus on annualBonus.SALARY_ACCOUNT_ID = a.id and annualBonus.JAVA_FIED_NAME = 'annualBonus'
left join t_salary_account_item exemptionPersionTax on exemptionPersionTax.SALARY_ACCOUNT_ID = a.id and exemptionPersionTax.JAVA_FIED_NAME='exemptionPersionTax'
left join t_salary_account_item enterpriseAnnuity on enterpriseAnnuity.SALARY_ACCOUNT_ID = a.id and enterpriseAnnuity.JAVA_FIED_NAME='enterpriseAnnuity'
/*left join t_salary_account_item pdeduction on pdeduction.SALARY_ACCOUNT_ID = a.id and pdeduction.JAVA_FIED_NAME='pdeduction'*/
left join t_salary_account_item phoneSubsidy on phoneSubsidy.SALARY_ACCOUNT_ID = a.id and phoneSubsidy.JAVA_FIED_NAME='phoneSubsidy'
left join t_salary_account_item pdeduction on pdeduction.SALARY_ACCOUNT_ID = a.id and pdeduction.JAVA_FIED_NAME='pdeduction'
left join t_salary_account_item phoneSubsidy on phoneSubsidy.SALARY_ACCOUNT_ID = a.id and phoneSubsidy.JAVA_FIED_NAME='phoneSubsidy'*/
<where>
a.DELETE_FLAG = 0
<include refid="where_export"/>
......@@ -1645,7 +1642,84 @@
</where>
</select>
<select id="auditExportPhoneSubsidy" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.TAuditExportItemVo">
select
phoneSubsidy.SALARY_ACCOUNT_ID as salaryAccountId,
phoneSubsidy.SALARY_MONEY as phoneSubsidy
FROM
t_salary_account_item phoneSubsidy
where
phoneSubsidy.JAVA_FIED_NAME='phoneSubsidy'
<if test="idList != null and idList.size>0">
AND phoneSubsidy.SALARY_ACCOUNT_ID in
<foreach item="idStr" index="index" collection="idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
</select>
<select id="auditExportEnterpriseAnnuity" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.TAuditExportItemVo">
select
enterpriseAnnuity.SALARY_ACCOUNT_ID as salaryAccountId,
enterpriseAnnuity.SALARY_MONEY as enterpriseAnnuity
FROM
t_salary_account_item enterpriseAnnuity
where
enterpriseAnnuity.JAVA_FIED_NAME='enterpriseAnnuity'
<if test="idList != null and idList.size>0">
AND enterpriseAnnuity.SALARY_ACCOUNT_ID in
<foreach item="idStr" index="index" collection="idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
</select>
<select id="auditExportExemptionPersionTax" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.TAuditExportItemVo">
select
exemptionPersionTax.SALARY_ACCOUNT_ID as salaryAccountId,
exemptionPersionTax.SALARY_MONEY as exemptionPersionTax
FROM
t_salary_account_item exemptionPersionTax
where
exemptionPersionTax.JAVA_FIED_NAME='exemptionPersionTax'
<if test="idList != null and idList.size>0">
AND exemptionPersionTax.SALARY_ACCOUNT_ID in
<foreach item="idStr" index="index" collection="idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
</select>
<select id="auditExportAnnualBonus" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.TAuditExportItemVo">
select
annualBonus.SALARY_ACCOUNT_ID as salaryAccountId,
annualBonus.SALARY_MONEY as annualBonus
FROM
t_salary_account_item annualBonus
where
annualBonus.JAVA_FIED_NAME = 'annualBonus'
<if test="idList != null and idList.size>0">
AND annualBonus.SALARY_ACCOUNT_ID in
<foreach item="idStr" index="index" collection="idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
</select>
<select id="auditExportStandard" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.TAuditExportStandardVo">
select
s.id as salaryFormId
,case s.STATUS when 0 then '待提交' when 1 then '待审核' when 2 then '待推送明细' when 3 then '已推送待发放' when 4 then '已发放' when 5 then '审核不通过' when 6 then '确认不通过' when 7 then '财务退回' when 10 then '推送失败' when 11 then '已审核生成收入中' when 12 then '已审核生成收入失败' else '-' end as status
,s.BUSINESS_PRIMARY_TYPE as businessPrimaryType
,s.BUSINESS_SECOND_TYPE as businessSecondType
,s.BUSINESS_THIRD_TYPE as businessThirdType
FROM
t_salary_standard s
where
<if test="idList != null and idList.size>0">
s.id in
<foreach item="idStr" index="index" collection="idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
</select>
<select id="auditExportSelectItems" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryAccountItemExportVo">
select
GROUP_CONCAT(pdeduction.CN_NAME,':',pdeduction.SALARY_MONEY SEPARATOR ';') pdeductionDetail,
......
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