From 7e22711dcd684350c7006efbbc4ecbfa545ab9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 28 Dec 2023 15:47:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/TaxDeclarationAnnualListDTO.java | 11 +++++ .../dto/TaxDeclarationLaborListDTO.java | 40 +++++++++++++------ .../dto/TaxDeclarationWageListDTO.java | 26 ++++++++++++ .../impl/TaxDeclarationExcelServiceImpl.java | 28 ++----------- .../engine/salary/util/excel/ExcelUtil.java | 22 ++++++++++ 5 files changed, 89 insertions(+), 38 deletions(-) diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java index 75b1b3191..696a3f9f7 100644 --- a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java @@ -2,6 +2,7 @@ package com.engine.salary.entity.taxdeclaration.dto; import com.engine.salary.annotation.SalaryTableColumn; import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelHead; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; @@ -31,59 +32,69 @@ public class TaxDeclarationAnnualListDTO { text = "工号", width = "10%", column = "jobNum" ) @TableTitle(title ="工号",dataIndex = "jobNum",key = "jobNum") + @ExcelHead(title ="工号",dataIndex = "jobNum") private String jobNum; @SalaryTableColumn( text = "姓名", width = "10%", column = "username" ) @TableTitle(title ="姓名",dataIndex = "username",key = "username") + @ExcelHead(title ="姓名",dataIndex = "username") private String username; @SalaryTableColumn( text = "证件类型", width = "10%", column = "cardType" ) @TableTitle(title ="证件类型",dataIndex = "cardType",key = "cardType") + @ExcelHead(title ="证件类型",dataIndex = "cardType") private String cardType; @SalaryTableColumn( text = "证件号码", width = "10%", column = "cardNum" ) @TableTitle(title ="证件号码",dataIndex = "cardNum",key = "cardNum") + @ExcelHead(title ="证件号码",dataIndex = "cardNum") private String cardNum; @SalaryTableColumn( text = "全年一次性奖金额", width = "10%", column = "annualIncome" ) @TableTitle(title ="全年一次性奖金额",dataIndex = "annualIncome",key = "annualIncome") + @ExcelHead(title ="全年一次性奖金额",dataIndex = "annualIncome") private String annualIncome; @SalaryTableColumn( text = "免税收入", width = "10%", column = "annualTaxFreeIncome" ) @TableTitle(title ="免税收入",dataIndex = "annualTaxFreeIncome",key = "annualTaxFreeIncome") + @ExcelHead(title ="免税收入",dataIndex = "annualTaxFreeIncome") private String annualTaxFreeIncome; @SalaryTableColumn( text = "其他", width = "10%", column = "annualOther" ) @TableTitle(title ="其他",dataIndex = "annualOther",key = "annualOther") + @ExcelHead(title ="其他",dataIndex = "annualOther") private String annualOther; @SalaryTableColumn( text = "准予扣除的捐赠额", width = "10%", column = "annualDonateTax" ) @TableTitle(title ="准予扣除的捐赠额",dataIndex = "annualDonateTax",key = "annualDonateTax") + @ExcelHead(title ="准予扣除的捐赠额",dataIndex = "annualDonateTax") private String annualDonateTax; @SalaryTableColumn( text = "减免税额", width = "10%", column = "annualTaxSavings" ) @TableTitle(title ="减免税额",dataIndex = "annualTaxSavings",key = "annualTaxSavings") + @ExcelHead(title ="减免税额",dataIndex = "annualTaxSavings") private String annualTaxSavings; @SalaryTableColumn( text = "备注", width = "10%", column = "annualRemark" ) @TableTitle(title ="备注",dataIndex = "annualRemark",key = "annualRemark") + @ExcelHead(title ="备注",dataIndex = "annualRemark") private String annualRemark; } diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java index 73872aa0a..ce03fd52c 100644 --- a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java @@ -2,6 +2,7 @@ package com.engine.salary.entity.taxdeclaration.dto; import com.engine.salary.annotation.SalaryTableColumn; import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelHead; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; @@ -30,78 +31,91 @@ public class TaxDeclarationLaborListDTO { @SalaryTableColumn( text = "工号", width = "10%", column = "jobNum" ) - @TableTitle(title ="工号",dataIndex = "jobNum",key = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelHead(title = "工号", dataIndex = "jobNum") private String jobNum; @SalaryTableColumn( text = "姓名", width = "10%", column = "username" ) - @TableTitle(title ="姓名",dataIndex = "username",key = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelHead(title = "姓名", dataIndex = "username") private String username; @SalaryTableColumn( text = "证件类型", width = "10%", column = "cardType" ) - @TableTitle(title ="证件类型",dataIndex = "cardType",key = "cardType") + @TableTitle(title = "证件类型", dataIndex = "cardType", key = "cardType") + @ExcelHead(title = "证件类型", dataIndex = "cardType") private String cardType; @SalaryTableColumn( text = "证件号码", width = "10%", column = "cardNum" ) - @TableTitle(title ="证件号码",dataIndex = "cardNum",key = "cardNum") + @TableTitle(title = "证件号码", dataIndex = "cardNum", key = "cardNum") + @ExcelHead(title = "证件号码", dataIndex = "cardNum") private String cardNum; @SalaryTableColumn( text = "所得项目", width = "10%", column = "incomeItems" ) - @TableTitle(title ="所得项目",dataIndex = "incomeItems",key = "incomeItems") + @TableTitle(title = "所得项目", dataIndex = "incomeItems", key = "incomeItems") + @ExcelHead(title = "所得项目", dataIndex = "incomeItems") private String incomeItems; @SalaryTableColumn( text = "劳务收入", width = "10%", column = "laborIncome" ) - @TableTitle(title ="劳务收入",dataIndex = "laborIncome",key = "laborIncome") + @TableTitle(title = "劳务收入", dataIndex = "laborIncome", key = "laborIncome") + @ExcelHead(title = "劳务收入", dataIndex = "laborIncome") private String laborIncome; @SalaryTableColumn( text = "劳务免税收入", width = "10%", column = "laborTaxFreeIncome" ) - @TableTitle(title ="劳务免税收入",dataIndex = "laborTaxFreeIncome",key = "laborTaxFreeIncome") + @TableTitle(title = "劳务免税收入", dataIndex = "laborTaxFreeIncome", key = "laborTaxFreeIncome") + @ExcelHead(title = "劳务免税收入", dataIndex = "laborTaxFreeIncome") private String laborTaxFreeIncome; @SalaryTableColumn( text = "商业健康保险", width = "10%", column = "commercialHealthInsurance" ) - @TableTitle(title ="商业健康保险",dataIndex = "commercialHealthInsurance",key = "commercialHealthInsurance") + @TableTitle(title = "商业健康保险", dataIndex = "commercialHealthInsurance", key = "commercialHealthInsurance") + @ExcelHead(title = "商业健康保险", dataIndex = "commercialHealthInsurance") private String commercialHealthInsurance; @SalaryTableColumn( text = "税延养老保险", width = "10%", column = "taxDeferredEndowmentInsurance" ) - @TableTitle(title ="税延养老保险",dataIndex = "taxDeferredEndowmentInsurance",key = "taxDeferredEndowmentInsurance") + @TableTitle(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance", key = "taxDeferredEndowmentInsurance") + @ExcelHead(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance") private String taxDeferredEndowmentInsurance; @SalaryTableColumn( text = "其他", width = "10%", column = "other" ) - @TableTitle(title ="其他",dataIndex = "other",key = "other") + @TableTitle(title = "其他", dataIndex = "other", key = "other") + @ExcelHead(title = "其他", dataIndex = "other") private String other; @SalaryTableColumn( text = "准予扣除的捐赠额", width = "10%", column = "allowedDonation" ) - @TableTitle(title ="准予扣除的捐赠额",dataIndex = "allowedDonation",key = "allowedDonation") + @TableTitle(title = "准予扣除的捐赠额", dataIndex = "allowedDonation", key = "allowedDonation") + @ExcelHead(title = "准予扣除的捐赠额", dataIndex = "allowedDonation") private String allowedDonation; @SalaryTableColumn( text = "减免税额", width = "10%", column = "taxDeduction" ) - @TableTitle(title ="减免税额",dataIndex = "taxDeduction",key = "taxDeduction") + @TableTitle(title = "减免税额", dataIndex = "taxDeduction", key = "taxDeduction") + @ExcelHead(title = "减免税额", dataIndex = "taxDeduction") private String taxDeduction; @SalaryTableColumn( text = "备注", width = "10%", column = "description" ) - @TableTitle(title ="备注",dataIndex = "description",key = "description") + @TableTitle(title = "备注", dataIndex = "description", key = "description") + @ExcelHead(title = "备注", dataIndex = "description") private String description; } diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java index 3725aaf27..419f8f1e0 100644 --- a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java @@ -4,6 +4,7 @@ import com.cloudstore.eccom.pc.table.WeaTableType; import com.engine.salary.annotation.SalaryTable; import com.engine.salary.annotation.SalaryTableColumn; import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelHead; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -35,101 +36,126 @@ public class TaxDeclarationWageListDTO { @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelHead(title = "工号", dataIndex = "jobNum") private String jobNum; @SalaryTableColumn(text = "姓名", width = "10%", column = "username") @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelHead(title = "姓名", dataIndex = "username") private String username; @SalaryTableColumn(text = "证件类型", width = "10%", column = "cardType") @TableTitle(title = "证件类型", dataIndex = "cardType", key = "cardType") + @ExcelHead(title = "证件类型", dataIndex = "cardType") private String cardType; @SalaryTableColumn(text = "证件号码", width = "10%", column = "cardNum") @TableTitle(title = "证件号码", dataIndex = "cardNum", key = "cardNum") + @ExcelHead(title = "证件号码", dataIndex = "cardNum") private String cardNum; @SalaryTableColumn(text = "本期收入", width = "10%", column = "income") @TableTitle(title = "本期收入", dataIndex = "income", key = "income") + @ExcelHead(title = "本期收入", dataIndex = "income") private String income; @SalaryTableColumn(text = "本期免税收入", width = "10%", column = "taxFreeIncome") @TableTitle(title = "本期免税收入", dataIndex = "taxFreeIncome", key = "taxFreeIncome") + @ExcelHead(title = "本期免税收入", dataIndex = "taxFreeIncome") private String taxFreeIncome; @SalaryTableColumn(text = "基本养老保险费", width = "10%", column = "endowmentInsurance") @TableTitle(title = "基本养老保险费", dataIndex = "endowmentInsurance", key = "endowmentInsurance") + @ExcelHead(title = "基本养老保险费", dataIndex = "endowmentInsurance") private String endowmentInsurance; @SalaryTableColumn(text = "基本医疗保险费", width = "10%", column = "medicalInsurance") @TableTitle(title = "基本医疗保险费", dataIndex = "medicalInsurance", key = "medicalInsurance") + @ExcelHead(title = "基本医疗保险费", dataIndex = "medicalInsurance") private String medicalInsurance; @SalaryTableColumn(text = "失业保险费", width = "10%", column = "unemploymentInsurance") @TableTitle(title = "失业保险费", dataIndex = "unemploymentInsurance", key = "unemploymentInsurance") + @ExcelHead(title = "失业保险费", dataIndex = "unemploymentInsurance") private String unemploymentInsurance; @SalaryTableColumn(text = "住房公积金", width = "10%", column = "housingProvidentFund") @TableTitle(title = "住房公积金", dataIndex = "housingProvidentFund", key = "housingProvidentFund") + @ExcelHead(title = "住房公积金", dataIndex = "housingProvidentFund") private String housingProvidentFund; @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") @TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation") + @ExcelHead(title = "累计子女教育", dataIndex = "addUpChildEducation") private String addUpChildEducation; @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") @TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest") + @ExcelHead(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest") private String addUpHousingLoanInterest; @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") @TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent") + @ExcelHead(title = "累计住房租金", dataIndex = "addUpHousingRent") private String addUpHousingRent; @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") @TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation") + @ExcelHead(title = "累计继续教育", dataIndex = "addUpContinuingEducation") private String addUpContinuingEducation; @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") @TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly") + @ExcelHead(title = "累计赡养老人", dataIndex = "addUpSupportElderly") private String addUpSupportElderly; @SalaryTableColumn(text = "累计大病医疗", width = "10%", column = "addUpIllnessMedical") @TableTitle(title = "累计大病医疗", dataIndex = "addUpIllnessMedical", key = "addUpIllnessMedical") + @ExcelHead(title = "累计大病医疗", dataIndex = "addUpIllnessMedical") private String addUpIllnessMedical; @SalaryTableColumn(text = "累计3岁以下婴幼儿照护", width = "10%", column = "addUpInfantCare") @TableTitle(title = "累计3岁以下婴幼儿照护", dataIndex = "addUpInfantCare", key = "addUpInfantCare") + @ExcelHead(title = "累计3岁以下婴幼儿照护", dataIndex = "addUpInfantCare") private String addUpInfantCare; @SalaryTableColumn(text = "累计个人养老金", width = "10%", column = "addUpPrivatePension") @TableTitle(title = "累计个人养老金", dataIndex = "addUpPrivatePension", key = "addUpPrivatePension") + @ExcelHead(title = "累计个人养老金", dataIndex = "addUpPrivatePension") private String addUpPrivatePension; @SalaryTableColumn(text = "企业(职业)年金", width = "10%", column = "annuity") @TableTitle(title = "企业(职业)年金", dataIndex = "annuity", key = "annuity") + @ExcelHead(title = "企业(职业)年金", dataIndex = "annuity") private String annuity; @SalaryTableColumn(text = "商业健康保险", width = "10%", column = "commercialHealthInsurance") @TableTitle(title = "商业健康保险", dataIndex = "commercialHealthInsurance", key = "commercialHealthInsurance") + @ExcelHead(title = "商业健康保险", dataIndex = "commercialHealthInsurance") private String commercialHealthInsurance; @SalaryTableColumn(text = "税延养老保险", width = "10%", column = "taxDeferredEndowmentInsurance") @TableTitle(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance", key = "taxDeferredEndowmentInsurance") + @ExcelHead(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance") private String taxDeferredEndowmentInsurance; @SalaryTableColumn(text = "其他", width = "10%", column = "other") @TableTitle(title = "其他", dataIndex = "other", key = "other") + @ExcelHead(title = "其他", dataIndex = "other") private String other; @SalaryTableColumn(text = "准予扣除的捐赠额", width = "10%", column = "allowedDonation") @TableTitle(title = "准予扣除的捐赠额", dataIndex = "allowedDonation", key = "allowedDonation") + @ExcelHead(title = "准予扣除的捐赠额", dataIndex = "allowedDonation") private String allowedDonation; @SalaryTableColumn(text = "减免税额", width = "10%", column = "taxDeduction") @TableTitle(title = "减免税额", dataIndex = "taxDeduction", key = "taxDeduction") + @ExcelHead(title = "减免税额", dataIndex = "taxDeduction") private String taxDeduction; @SalaryTableColumn(text = "备注", width = "10%", column = "description") @TableTitle(title = "备注", dataIndex = "description", key = "description") + @ExcelHead(title = "备注", dataIndex = "description") private String description; } diff --git a/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java index 957957790..c9eb8796a 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java @@ -2,7 +2,6 @@ package com.engine.salary.service.impl; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.annotation.SalaryTableColumn; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationAnnualListDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; @@ -23,7 +22,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.User; -import java.lang.reflect.Field; import java.util.List; import java.util.Map; import java.util.Objects; @@ -68,7 +66,7 @@ public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclar List dataIndexList = Lists.newArrayList(); if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { // 解析表头 - parseHeader(TaxDeclarationWageListDTO.class, headerList, dataIndexList); + ExcelUtil.parseHeader(TaxDeclarationWageListDTO.class, headerList, dataIndexList); rows.add(headerList); for (int i = 0; i < totalPages; i++) { TaxDeclarationDetailListQueryParam queryParam = new TaxDeclarationDetailListQueryParam(); @@ -89,7 +87,7 @@ public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclar } if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { // 解析表头 - parseHeader(TaxDeclarationLaborListDTO.class, headerList, dataIndexList); + ExcelUtil.parseHeader(TaxDeclarationLaborListDTO.class, headerList, dataIndexList); rows.add(headerList); for (int i = 0; i < totalPages; i++) { TaxDeclarationDetailListQueryParam queryParam = new TaxDeclarationDetailListQueryParam(); @@ -111,7 +109,7 @@ public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclar if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.ONETIME_ANNUAL_BONUS.getValue())) { // 解析表头 - parseHeader(TaxDeclarationAnnualListDTO.class, headerList, dataIndexList); + ExcelUtil.parseHeader(TaxDeclarationAnnualListDTO.class, headerList, dataIndexList); rows.add(headerList); for (int i = 0; i < totalPages; i++) { TaxDeclarationDetailListQueryParam queryParam = new TaxDeclarationDetailListQueryParam(); @@ -133,24 +131,4 @@ public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclar return ExcelUtil.genWorkbookV2(rows, sheetName); } - - /** - * 解析表头 - * - * @param clazz - * @param headerList - * @param dataIndexList - * @param - */ - private void parseHeader(Class clazz, List headerList, List dataIndexList) { - Field[] declaredFields = clazz.getDeclaredFields(); - for (Field declaredField : declaredFields) { - if (!declaredField.isAnnotationPresent(SalaryTableColumn.class)) { - continue; - } - SalaryTableColumn annotation = declaredField.getAnnotation(SalaryTableColumn.class); - headerList.add(SalaryI18nUtil.getI18nLabel( annotation.labelId(), annotation.text())); - dataIndexList.add(declaredField.getName()); - } - } } diff --git a/src/com/engine/salary/util/excel/ExcelUtil.java b/src/com/engine/salary/util/excel/ExcelUtil.java index c50c11d2b..877714295 100644 --- a/src/com/engine/salary/util/excel/ExcelUtil.java +++ b/src/com/engine/salary/util/excel/ExcelUtil.java @@ -1,6 +1,7 @@ package com.engine.salary.util.excel; import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.FillPatternType; @@ -9,6 +10,7 @@ import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.xssf.usermodel.*; import java.awt.*; +import java.lang.reflect.Field; import java.util.Date; import java.util.List; @@ -267,4 +269,24 @@ public class ExcelUtil { } return workbook; } + + /** + * 解析表头 + * + * @param clazz + * @param headerList + * @param dataIndexList + * @param + */ + public static void parseHeader(Class clazz, List headerList, List dataIndexList) { + Field[] declaredFields = clazz.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (!declaredField.isAnnotationPresent(ExcelHead.class)) { + continue; + } + ExcelHead annotation = declaredField.getAnnotation(ExcelHead.class); + headerList.add(SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.title())); + dataIndexList.add(declaredField.getName()); + } + } }