From 3e64b1cfdea92676d2ad70032d7a7d5b290a06fc Mon Sep 17 00:00:00 2001 From: "18895359881@163.com" <521027xyz> Date: Sat, 16 Apr 2022 15:33:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=96=AA=E9=85=AC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 15 - .../TaxDeclarationGetFormCmd.java | 33 ++ ...axDeclarationGetTaxDeclarationInfoCmd.java | 33 ++ .../taxDeclaration/TaxDeclarationListCmd.java | 118 +++--- .../entity/taxdeclaration/TaxDeclaration.java | 5 + .../taxdeclaration/bo/TaxDeclarationBO.java | 372 ++++++++++++++++++ .../dto/TaxDeclarationDetailListDTO.java | 235 +++++++++++ .../dto/TaxDeclarationFormDTO.java | 33 ++ .../dto/TaxDeclarationInfoDTO.java | 31 ++ .../dto/TaxDeclarationLaborListDTO.java | 61 +++ .../dto/TaxDeclarationListDTO.java | 52 +++ .../dto/TaxDeclarationWageListDTO.java | 91 +++++ .../TaxDeclarationDetailListQueryParam.java | 26 ++ .../param/TaxDeclarationListQueryParam.java | 33 ++ .../param/TaxDeclarationSaveParam.java | 31 ++ .../po/TaxDeclarationDetailPO.java | 78 ++++ .../taxdeclaration/po/TaxDeclarationPO.java | 76 ++++ .../taxrate/vo/TaxDeclarationListVO.java | 78 ++++ .../enums/salarysob/IncomeCategoryEnum.java | 2 + .../TaxDeclarationDetailMapper.java | 11 +- .../TaxDeclarationDetailMapper.xml | 20 + .../taxdeclaration/TaxDeclarationMapper.java | 17 + .../taxdeclaration/TaxDeclarationMapper.xml | 39 +- .../service/TaxDeclarationDetailService.java | 73 ++++ .../salary/service/TaxDeclarationService.java | 22 +- .../impl/TaxDeclarationDetailServiceImpl.java | 81 ++++ .../impl/TaxDeclarationServiceImpl.java | 88 ++++- .../engine/salary/util/SalaryDateUtil.java | 6 + .../salary/web/TaxDeclarationController.java | 123 ++++-- .../wrapper/TaxDeclarationDetailWrapper.java | 66 ++++ .../salary/wrapper/TaxDeclarationWrapper.java | 286 ++++++++++++++ 31 files changed, 2119 insertions(+), 116 deletions(-) delete mode 100644 .gitignore create mode 100644 src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetFormCmd.java create mode 100644 src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetTaxDeclarationInfoCmd.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java create mode 100644 src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java create mode 100644 src/com/engine/salary/service/TaxDeclarationDetailService.java create mode 100644 src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java create mode 100644 src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java create mode 100644 src/com/engine/salary/wrapper/TaxDeclarationWrapper.java diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ddbcd048a..000000000 --- a/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/weaver-hrm-salary.iml -/out/ -/.idea/ - -HELP.md -target/ - -### IntelliJ IDEA ### -.idea - -/src/test -/src/META-INF - -/log - diff --git a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetFormCmd.java b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetFormCmd.java new file mode 100644 index 000000000..25d3a329e --- /dev/null +++ b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetFormCmd.java @@ -0,0 +1,33 @@ +package com.engine.salary.cmd.taxDeclaration; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +public class TaxDeclarationGetFormCmd extends AbstractCommonCommand> { + + public TaxDeclarationGetFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + TaxRateBiz taxRateBiz = new TaxRateBiz(); + TaxRateSaveParam taxRateSaveParam = (TaxRateSaveParam) params.get("taxRateSaveParam"); + taxRateBiz.save(taxRateSaveParam, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetTaxDeclarationInfoCmd.java b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetTaxDeclarationInfoCmd.java new file mode 100644 index 000000000..4d0f2bfdd --- /dev/null +++ b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetTaxDeclarationInfoCmd.java @@ -0,0 +1,33 @@ +package com.engine.salary.cmd.taxDeclaration; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +public class TaxDeclarationGetTaxDeclarationInfoCmd extends AbstractCommonCommand> { + + public TaxDeclarationGetTaxDeclarationInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + TaxRateBiz taxRateBiz = new TaxRateBiz(); + TaxRateSaveParam taxRateSaveParam = (TaxRateSaveParam) params.get("taxRateSaveParam"); + taxRateBiz.save(taxRateSaveParam, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java index 42032ff57..52433685c 100644 --- a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java +++ b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java @@ -1,19 +1,22 @@ package com.engine.salary.cmd.taxDeclaration; -import com.cloudstore.eccom.constant.WeaBoolAttr; -import com.cloudstore.eccom.pc.table.WeaTable; -import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.salaryarchive.po.TaxAgentPO; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxrate.vo.TaxAgentTableVO; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.DBType; +import com.fapiao.neon.model.in.Page; import org.apache.commons.lang3.StringUtils; -import weaver.general.PageIdConst; -import weaver.general.Util; +import weaver.conn.RecordSet; import weaver.hrm.User; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; public class TaxDeclarationListCmd extends AbstractCommonCommand> { @@ -31,51 +34,68 @@ public class TaxDeclarationListCmd extends AbstractCommonCommand execute(CommandContext commandContext) { Map apidatas = new HashMap(16); + //查询个税申报表 + SalaryWeaTable table = new SalaryWeaTable(user, TaxDeclaration.class); + //sql条件 + String sqlWhere = makeSqlWhere(params,user); + table.setSqlwhere(sqlWhere); WeaResultMsg result = new WeaResultMsg(false); - String pageID = "a4f85287-e3f9-4275-9527-7d06e54y6rj8"; - String pageUid = pageID + "_" + user.getUID(); - String pageSize = PageIdConst.getPageSize(pageID, user.getUID()); - - - String fileds = " create_time,creator,delete_type, description, id, name, system_type, tenant_key, update_time"; - String sql = " from hrsa_sys_tax_rate_base s " + - " where s.delete_type = 0"; - //模糊查询 - String name = Util.null2String(params.get("name")); - if (StringUtils.isNotBlank(name)) { - sql += " and s.name like '%" + name + "%' "; - } - sql += " union all " + - " select create_time,creator,delete_type, description, id, name, system_type, tenant_key, update_time " + - " from hrsa_tax_rate_base b " + - " where b.delete_type = 0 "; - //模糊查询 - if (StringUtils.isNotBlank(name)) { - sql += " and b.name like '%" + name + "%' "; - } - - WeaTable table = new WeaTable(); - table.setPageUID(pageUid); - table.setPageID(pageID); - table.setPagesize(pageSize); - table.setBackfields(fileds); - table.setSqlform(sql); -// table.setSqlwhere(); - table.setSqlorderby("id desc"); - table.setSqlprimarykey("id"); - table.setSqlisdistinct("false"); - - table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE)); - table.getColumns().add(new WeaTableColumn("20%", "名称", "name", "")); - table.getColumns().add(new WeaTableColumn("20%", "名称", "systemType", "")); - table.getColumns().add(new WeaTableColumn("20%", "名称", "createTime", "")); - table.getColumns().add(new WeaTableColumn("20%", "名称", "description", "")); - - result.putAll(table.makeDataResult()); + result.success(); - apidatas = result.getResultMap(); - return apidatas; + //人员list + List list = table.makeDataResult().values().stream().collect(Collectors.toList()); + //SalaryWeaTable simpleEmployees = new SalaryWeaTable(user, SimpleEmployee.class); + //查询个税扣缴义务人 + + SalaryWeaTable taxAgentPOS = new SalaryWeaTable(user, TaxAgentTableVO.class); + List employeeIds = new ArrayList(); + + if(!table.makeDataResult().isEmpty()){ + //查询人员 + + //查询个税扣缴义务人 + + } + return result.getResultMap(); + + } + + /** + * sql条件 + * + * @param params + * @return + */ + private String makeSqlWhere(Map params,User user) { + DBType dbType = DBType.get(new RecordSet().getDBType()); + //租户key + String userId = user.getLoginid(); + String sqlWhere = "where delete_Type = 0 and tenantKey = userId"; + //区间查询 + String FromSalaryMonth = (String) params.get("FromSalaryMonth"); + String EndSalaryMonth = (String) params.get("EndSalaryMonth"); + if (SalaryEntityUtil.isNotNullOrEmpty(FromSalaryMonth)&&SalaryEntityUtil.isNotNullOrEmpty(EndSalaryMonth)) { + sqlWhere += "AND salary_month between to_date(FromSalaryMonth,'yyyy-mm') and to_date(EndSalaryMonth,'yyyy-mm')"; + } + return sqlWhere; + } + + /** + * sql条件 + * + * @param params + * @return + */ + private String makeSqlWhereAgent(Map params) { + DBType dbType = DBType.get(new RecordSet().getDBType()); + String sqlWhere = "where delete_Type = 0"; + //模糊查询 + String name = (String) params.get("name"); + if (StringUtils.isNotBlank(name)) { + sqlWhere += " AND name " + dbType.like(name); + } + return sqlWhere; } } diff --git a/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java b/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java index 086f0e45b..e39ebff74 100644 --- a/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java +++ b/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java @@ -56,4 +56,9 @@ public class TaxDeclaration { */ private Date updateTime; + /** + * 应税项目。1:正常工资薪金所得 + */ + private Integer incomeCategory; + } \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java new file mode 100644 index 000000000..d4328bc2c --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java @@ -0,0 +1,372 @@ +package com.engine.salary.entity.taxdeclaration.bo; + +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import dm.jdbc.util.IdGenerator; +import lombok.Data; +import org.apache.commons.collections4.CollectionUtils; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @description: 个税申报表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 10:01 AM + * @version:v1.0 + */ +public class TaxDeclarationBO { + + public static List convert2ListDTO(List taxDeclarations, + List simpleEmployees, + List taxAgents) { + if (CollectionUtils.isEmpty(simpleEmployees)) { + return Collections.emptyList(); + } + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getId, TaxAgent::getName); + Map employeeNameMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + return taxDeclarations.stream().map(e -> TaxDeclarationListDTO.builder() + .id(e.getId()) + .salaryMonth(e.getSalaryMonth().toString()) + .taxAgentId(e.getTaxAgentId()) + .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), "")) + .taxCycle(e.getTaxCycle().toString()) + .operateEmployeeId(e.getCreator()) + .operateEmployeeName(employeeNameMap.getOrDefault(e.getCreator(), "")) + .operateTime(SalaryDateUtil.getFormatLocalDateTime(e.getCreateTime())) + .description(e.getDescription()) + .build()).collect(Collectors.toList()); + } + + /*public static void buildDetailListDTO(Long taxDeclarationId, + Page page, + List taxDeclarationDetails, + List simpleEmployees) { + if (CollectionUtils.isEmpty(taxDeclarationDetails)) { + return; + } + int index = (int) ((page.getCurrent() - 1) * page.getSize()); + List dtos = Lists.newArrayListWithExpectedSize(simpleEmployees.size()); + Map> taxDeclarationDetailMap = SalaryEntityUtil.group2Map(taxDeclarationDetails, TaxDeclarationDetailPO::getEmployeeId); + for (SimpleEmployee simpleEmployee : simpleEmployees) { + Map valueMap = SalaryEntityUtil.convert2Map(taxDeclarationDetailMap.get(simpleEmployee.getEmployeeId()), TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue); + TaxDeclarationDetailListDTO dto = new TaxDeclarationDetailListDTO(); + dto.setId(simpleEmployee.getEmployeeId()); + dto.setTaxDeclarationId(taxDeclarationId); + dto.setSeq(++index); + dto.setEmployeeId(simpleEmployee.getEmployeeId()); + dto.setEmployeeName(simpleEmployee.getUsername()); + dto.setIdCardType(SalaryI18nUtil.getI18nLabel(101696,"身份证")); + dto.setIdCardNo(""); + dto.setTaxpayerIdNo(""); + dto.setResidentType(SalaryI18nUtil.getI18nLabel(101697,"居民")); + dto.setIncomeType(SalaryI18nUtil.getI18nLabel(101698,"工资、薪金")); + dto.setIncome(valueMap.getOrDefault("income","")); + dto.setFee(valueMap.getOrDefault("fee", "")); + dto.setTaxFreeIncome(valueMap.getOrDefault("taxFreeIncome", "")); + dto.setSubtraction(valueMap.getOrDefault("subtraction", "")); + dto.setEndowmentInsurance(valueMap.getOrDefault("endowmentInsurance", "")); + dto.setMedicalInsurance(valueMap.getOrDefault("medicalInsurance","")); + dto.setUnemploymentInsurance(valueMap.getOrDefault("unemploymentInsurance","")); + dto.setHousingProvidentFund(valueMap.getOrDefault("housingProvidentFund","")); + dto.setAnnuity(valueMap.getOrDefault("annuity","")); + dto.setCommercialHealthInsurance(valueMap.getOrDefault("commercialHealthInsurance","")); + dto.setTaxDeferredEndowmentInsurance(valueMap.getOrDefault("taxDeferredEndowmentInsurance","")); + dto.setOriginalValueOfProperty(valueMap.getOrDefault("originalValueOfProperty","")); + dto.setDeductedTax(valueMap.getOrDefault("deductedTax","")); + dto.setOther(valueMap.getOrDefault("other","")); + dto.setAddUpIncome(valueMap.getOrDefault("addUpIncome","")); + dto.setAddUpSubtraction(valueMap.getOrDefault("addUpSubtraction","")); + dto.setAddUpSpecialDeduction(valueMap.getOrDefault("addUpSpecialDeduction","")); + dto.setAddUpChildEducation(valueMap.getOrDefault("addUpChildEducation","")); + dto.setAddUpContinuingEducation(valueMap.getOrDefault("addUpContinuingEducation","")); + dto.setAddUpHousingLoanInterest(valueMap.getOrDefault("addUpHousingLoanInterest","")); + dto.setAddUpHousingRent(valueMap.getOrDefault("addUpHousingRent","")); + dto.setAddUpSupportElderly(valueMap.getOrDefault("addUpSupportElderly","")); + dto.setAddUpOther(valueMap.getOrDefault("addUpOtherDeduction","")); + dto.setLessTaxProportion(valueMap.getOrDefault("lessTaxProportion","")); + dto.setAllowedDonation(valueMap.getOrDefault("addUpAllowedDonation","")); + dto.setTaxableIncome(valueMap.getOrDefault("addUpTaxableIncome","")); + dto.setTaxRate(valueMap.getOrDefault("taxRate","")); + dto.setQuickDeductionFactor(valueMap.getOrDefault("quickDeductionFactor","")); + dto.setTaxPayable(valueMap.getOrDefault("addUpTaxPayable","")); + dto.setTaxSavings(valueMap.getOrDefault("addUpTaxDeduction","")); + dto.setTaxWithheld(valueMap.getOrDefault("taxWithheld","")); + dto.setRefundedOrSupplementedTax(valueMap.getOrDefault("refundedOrSupplementedTax","")); + dtos.add(dto); + } + page.setRecords(dtos); + }*/ + + public static Result handle(TaxDeclarationSaveParam saveParam, + Date taxCycle, + List salaryItems, + List salarySobs, + List salaryAcctResults + ) { + Result result = new Result(); + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return result; + } + // 薪资项目聚合成map(为了根据code获取id) + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getCode, SalaryItemPO::getId); + // 薪资账套聚合成map(为了根据id获取incomeCategory) + Map salarySobPOMap = SalaryEntityUtil.convert2Map(salarySobs, SalarySobPO::getId); + // 薪资核算结果按照个税扣缴义务人id、所用薪资账套的incomeCategory聚合成map + /* Map>> taxAgentIdKeyAcctResultMap = salaryAcctResults.stream() + .collect(Collectors.groupingBy(SalaryAcctResultPO::getTaxAgentId, + Collectors.groupingBy(salaryAcctResultPO -> salarySobPOMap.get(salaryAcctResultPO.getSalarySobId()).getIncomeCategory()))); + */// 一个个税扣缴义务人,一种薪资类型生成一张个税申报表 + Map> taxAgentIdKeyAcctResultMap = SalaryEntityUtil.group2Map(salaryAcctResults, SalaryAcctResultPO::getTaxAgentId); + taxAgentIdKeyAcctResultMap.forEach((k, v) -> { + // 新增的个税申报表 + TaxDeclarationPO taxDeclaration = convert2PO(saveParam, taxCycle, k); + result.getNeedInsertTaxDeclarations().add(taxDeclaration); + // 处理个税申报明细以及累计情况 + handleTaxDeclarationDetail(result, taxDeclaration, v, salaryItemMap); + }); + /*taxAgentIdKeyAcctResultMap.forEach((taxAgentId, incomeCategoryKeyAcctResultPOMap) -> { + incomeCategoryKeyAcctResultPOMap.forEach((incomeCategory, salaryAcctResultPOS) -> { + // 新增的个税申报表 + TaxDeclarationPO taxDeclaration = convert2PO(saveParam, taxCycle, taxAgentId, incomeCategory, employeeId); + result.getNeedInsertTaxDeclarations().add(taxDeclaration); + if (Objects.equals(incomeCategory, IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + // 生成个税申报表 + handleTaxDeclaration4Wage(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + // 生成往期累计情况 + handleAddUpSituation(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + } + if (Objects.equals(incomeCategory, IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { + // 生成个税申报表 + handleTaxDeclaration4Labor(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + } + }); + });*/ + return result; + } + + private static void handleTaxDeclarationDetail(Result result, + TaxDeclarationPO taxDeclaration, + List salaryAcctResults, + Map salaryItemMap) { + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return; + } + // 核算结果按照人员id分类 + Map> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResults, SalaryAcctResultPO::getEmployeeId); + acctResultMap.forEach((k, v) -> { + Map valueMap = Maps.newHashMapWithExpectedSize(32); + Map> resultMap = SalaryEntityUtil.group2Map(v, SalaryAcctResultPO::getSalaryItemId); + // 收入 + BigDecimal income = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault("income", 0L)), e -> SalaryEntityUtil.empty2Zero(e.getResultValue())); + valueMap.put("income", income); + // 费用 + BigDecimal fee = BigDecimal.ZERO; + valueMap.put("fee", fee); + // 免税收入 + BigDecimal taxFreeIncome = BigDecimal.ZERO; + valueMap.put("taxFreeIncome", taxFreeIncome); + // 减除费用 + BigDecimal subtraction = findValue("subtraction", resultMap, salaryItemMap); + valueMap.put("subtraction", subtraction); + // 基本养老保险 + BigDecimal endowmentInsurance = findValue("endowmentInsurance", resultMap, salaryItemMap); + valueMap.put("endowmentInsurance", endowmentInsurance); + // 基本医疗保险 + BigDecimal medicalInsurance = findValue("medicalInsurance", resultMap, salaryItemMap); + valueMap.put("medicalInsurance", medicalInsurance); + // 失业保险 + BigDecimal unemploymentInsurance = findValue("unemploymentInsurance", resultMap, salaryItemMap); + valueMap.put("unemploymentInsurance", unemploymentInsurance); + // 住房公积金 + BigDecimal housingProvidentFund = findValue("housingProvidentFund", resultMap, salaryItemMap); + valueMap.put("housingProvidentFund", housingProvidentFund); + // 年金 + BigDecimal annuity = findValue("annuity", resultMap, salaryItemMap); + valueMap.put("annuity", annuity); + // 商业健康保险 + BigDecimal commercialHealthInsurance = findValue("commercialHealthInsurance", resultMap, salaryItemMap); + valueMap.put("commercialHealthInsurance", commercialHealthInsurance); + // 税延养老保险 + BigDecimal taxDeferredEndowmentInsurance = findValue("taxDeferredEndowmentInsurance", resultMap, salaryItemMap); + valueMap.put("taxDeferredEndowmentInsurance", taxDeferredEndowmentInsurance); + // 财产原值 + BigDecimal originalValueOfProperty = findValue("originalValueOfProperty", resultMap, salaryItemMap); + valueMap.put("originalValueOfProperty", originalValueOfProperty); + // 允许扣除的税费 + BigDecimal deductedTax = findValue("deductedTax", resultMap, salaryItemMap); + valueMap.put("deductedTax", deductedTax); + // 其他 + BigDecimal other = findValue("other", resultMap, salaryItemMap); + valueMap.put("other", other); + // 累计收入 + BigDecimal addUpIncome = findAddUpValue("addUpIncome", resultMap, salaryItemMap); + valueMap.put("addUpIncome", addUpIncome); + // 累计减除费用 + BigDecimal addUpSubtraction = findAddUpValue("addUpSubtraction", resultMap, salaryItemMap); + valueMap.put("addUpSubtraction", addUpSubtraction); + // 累计专项扣除 + BigDecimal addUpSpecialDeduction = findAddUpValue("addUpSpecialDeduction", resultMap, salaryItemMap); + valueMap.put("addUpSpecialDeduction", addUpSpecialDeduction); + // 累计子女教育 + BigDecimal addUpChildEducation = findAddUpValue("addUpChildEducation", resultMap, salaryItemMap); + valueMap.put("addUpChildEducation", addUpChildEducation); + // 累计继续教育 + BigDecimal addUpContinuingEducation = findAddUpValue("addUpContinuingEducation", resultMap, salaryItemMap); + valueMap.put("addUpContinuingEducation", addUpContinuingEducation); + // 累计住房贷款利息 + BigDecimal addUpHousingLoanInterest = findAddUpValue("addUpHousingLoanInterest", resultMap, salaryItemMap); + valueMap.put("addUpHousingLoanInterest", addUpHousingLoanInterest); + // 累计住房租金 + BigDecimal addUpHousingRent = findAddUpValue("addUpHousingRent", resultMap, salaryItemMap); + valueMap.put("addUpHousingRent", addUpHousingRent); + // 累计赡养老人 + BigDecimal addUpSupportElderly = findAddUpValue("addUpSupportElderly", resultMap, salaryItemMap); + valueMap.put("addUpSupportElderly", addUpSupportElderly); + // 累计其他扣除 + BigDecimal addUpOtherDeduction = findAddUpValue("addUpOtherDeduction", resultMap, salaryItemMap); + valueMap.put("addUpOtherDeduction", addUpOtherDeduction); + // 减按计税比例 + BigDecimal lessTaxProportion = BigDecimal.ONE; + valueMap.put("lessTaxProportion", lessTaxProportion); + // 准允扣除的捐赠额 + BigDecimal addUpAllowedDonation = findAddUpValue("addUpAllowedDonation", resultMap, salaryItemMap); + valueMap.put("addUpAllowedDonation", addUpAllowedDonation); + // 应纳税所得额 + BigDecimal addUpTaxableIncome = findAddUpValue("addUpTaxableIncome", resultMap, salaryItemMap); + valueMap.put("addUpTaxableIncome", addUpTaxableIncome); + // 税率 + BigDecimal taxRate = findAddUpValue("taxRate", resultMap, salaryItemMap); + valueMap.put("taxRate", taxRate); + // 速算扣除数 + BigDecimal quickDeductionFactor = findAddUpValue("quickDeductionFactor", resultMap, salaryItemMap); + valueMap.put("quickDeductionFactor", quickDeductionFactor); + // 应纳税额 + BigDecimal addUpTaxPayable = findAddUpValue("addUpTaxPayable", resultMap, salaryItemMap); + valueMap.put("addUpTaxPayable", addUpTaxPayable); + // 减免税额 + BigDecimal addUpTaxDeduction = BigDecimal.ZERO; + valueMap.put("addUpTaxDeduction", addUpTaxDeduction); + // 应补缴税额 + BigDecimal refundedOrSupplementedTax = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault("refundedOrSupplementedTax", 0L)), + e -> SalaryEntityUtil.empty2Zero(e.getResultValue())); + valueMap.put("refundedOrSupplementedTax", refundedOrSupplementedTax); + // 已扣缴税额 + BigDecimal taxWithheld = addUpTaxPayable.subtract(refundedOrSupplementedTax); + valueMap.put("taxWithheld", taxWithheld); + + valueMap.forEach((key, value) -> { + TaxDeclarationDetailPO detailPO = TaxDeclarationDetailPO.builder() + .id(IdGenerator.generate()) + .taxDeclarationId(taxDeclaration.getId()) + .employeeId(k) + .fieldCode(key) + .fieldValue(value.toPlainString()) + .creator(taxDeclaration.getCreator()) + .createTime(SalaryDateUtil.dateToLocalDateTime(taxDeclaration.getCreateTime())) + .updateTime(SalaryDateUtil.dateToLocalDateTime(taxDeclaration.getUpdateTime())) + .deleteType(0) + .tenantKey(taxDeclaration.getTenantKey()) + .build(); + result.getNeedInsertTaxDeclarationDetails().add(detailPO); + }); + // 累计社保个人合计 + BigDecimal addUpSocialSecurityTotal = findAddUpValue("addUpSocialSecurityTotal", resultMap, salaryItemMap); + // 累计公积金个人合计 + BigDecimal addUpAccumulationFundTotal = findAddUpValue("addUpAccumulationFundTotal", resultMap, salaryItemMap); + // 累计年金及其他福利合计 + BigDecimal addUpEnterpriseAndOther = findAddUpValue("addUpEnterpriseAndOther", resultMap, salaryItemMap); + // 更新累计情况 + AddUpSituation accumulatedSituation = AddUpSituation.builder() + .id(IdGenerator.generate()) + .employeeId(k) + .taxAgentId(taxDeclaration.getTaxAgentId()) + .taxYearMonth((taxDeclaration.getSalaryMonth())) + .year(taxDeclaration.getSalaryMonth().getYear()) + .addUpIncome(addUpIncome.toPlainString()) + .addUpSocialSecurityTotal(addUpSocialSecurityTotal.toPlainString()) + .addUpAccumulationFundTotal(addUpAccumulationFundTotal.toPlainString()) + .addUpEnterpriseAndOther(addUpEnterpriseAndOther.toPlainString()) + .addUpSubtraction(addUpSubtraction.toPlainString()) + .addUpChildEducation(addUpChildEducation.toPlainString()) + .addUpContinuingEducation(addUpContinuingEducation.toPlainString()) + .addUpHousingLoanInterest(addUpHousingLoanInterest.toPlainString()) + .addUpHousingRent(addUpHousingRent.toPlainString()) + .addUpSupportElderly(addUpSupportElderly.toPlainString()) + .addUpOtherDeduction(addUpOtherDeduction.toPlainString()) + .addUpTaxExemptIncome("0") + .addUpAllowedDonation(addUpAllowedDonation.toPlainString()) + .addUpAdvanceTax(addUpTaxPayable.toPlainString()) + .creator(taxDeclaration.getCreator()) + .createTime(taxDeclaration.getCreateTime()) + .updateTime(taxDeclaration.getUpdateTime()) + .tenantKey(taxDeclaration.getTenantKey()) + .deleteType(0) + .build(); + result.getNeedInsertAccumulatedSituations().add(accumulatedSituation); + }); + } + + private static TaxDeclarationPO convert2PO(TaxDeclarationSaveParam saveParam, Date taxCycle, Long taxAgentId) { + LocalDateTime now = LocalDateTime.now(); + return TaxDeclarationPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(taxAgentId) + .salaryMonth(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))) + .taxCycle(taxCycle) + .description(saveParam.getDescription()) + // .creator(employeeId) + .createTime(SalaryDateUtil.localDateTimeToDate(now)) + .updateTime(SalaryDateUtil.localDateTimeToDate(now)) + .deleteType(0) + //.tenantKey(tenantKey) + .build(); + } + + private static BigDecimal findValue(String fieldCode, Map> resultMap, Map salaryItemMap) { + return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream() + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .filter(e -> e.compareTo(BigDecimal.ZERO) > 0) + .findAny() + .orElse(BigDecimal.ZERO); + } + + private static BigDecimal findAddUpValue(String fieldCode, Map> resultMap, Map salaryItemMap) { + return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream() + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .max(Comparator.comparingDouble(BigDecimal::doubleValue)) + .orElse(BigDecimal.ZERO); + } + + @Data + public static class Result { + + private Collection needInsertTaxDeclarations; + + private Collection needInsertTaxDeclarationDetails; + + private Collection needInsertAccumulatedSituations; + + public Result() { + this.needInsertTaxDeclarations = Lists.newArrayList(); + this.needInsertTaxDeclarationDetails = Lists.newArrayList(); + this.needInsertAccumulatedSituations = Lists.newArrayList(); + } + } +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java new file mode 100644 index 000000000..89c66086b --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java @@ -0,0 +1,235 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报表详情列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 10:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailListDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税申报记录id + */ + private Long taxDeclarationId; + + /** + * 序号 + */ + private Integer seq; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 姓名 + */ + private String employeeName; + + /** + * 身份证件类型 + */ + private String idCardType; + + /** + * 身份证件号码 + */ + private String idCardNo; + + /** + * 纳税人识别号 + */ + private String taxpayerIdNo; + + /** + * 是居民还是非居民 + */ + private String residentType; + + /** + * 所得项目 + */ + private String incomeType; + + /** + * 收入 + */ + private String income; + + /** + * 费用 + */ + private String fee; + + /** + * 免税收入 + */ + private String taxFreeIncome; + + /** + * 减除费用 + */ + private String subtraction; + + /** + * 养老保险 + */ + private String endowmentInsurance; + + /** + * 医疗保险 + */ + private String medicalInsurance; + + /** + * 失业保险 + */ + private String unemploymentInsurance; + + /** + * 住房公积金 + */ + private String housingProvidentFund; + + /** + * 年金 + */ + private String annuity; + + /** + * 商业健康保险 + */ + private String commercialHealthInsurance; + + /** + * 税延养老保险 + */ + private String taxDeferredEndowmentInsurance; + + /** + * 财产原值 + */ + private String originalValueOfProperty; + + /** + * 允许扣除的税费 + */ + private String deductedTax; + + /** + * 其他 + */ + private String other; + + /** + * 累计收入额 + */ + private String addUpIncome; + + /** + * 累计减除费用 + */ + private String addUpSubtraction; + + /** + * 累计专项扣除 + */ + private String addUpSpecialDeduction; + + /** + * 累计子女教育 + */ + private String addUpChildEducation; + + /** + * 累计继续教育 + */ + private String addUpContinuingEducation; + + /** + * 累计住房贷款利息 + */ + private String addUpHousingLoanInterest; + + /** + * 累计住房租金 + */ + private String addUpHousingRent; + + /** + * 累计赡养老人 + */ + private String addUpSupportElderly; + + /** + * 累计其他扣除 + */ + private String addUpOther; + + /** + * 减按计税比例 + */ + private String lessTaxProportion; + + /** + * 准允扣除的捐赠额 + */ + private String allowedDonation; + + /** + * 应纳税所得额 + */ + private String taxableIncome; + + /** + * 税率 + */ + private String taxRate; + + /** + * 速算扣除数 + */ + private String quickDeductionFactor; + + /** + * 应纳税款 + */ + private String taxPayable; + + /** + * 减免税额 + */ + private String taxSavings; + + /** + * 已扣缴税额 + */ + private String taxWithheld; + + /** + * 应补(退)税额 + */ + private String refundedOrSupplementedTax; + + /** + * 备注 + */ + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java new file mode 100644 index 000000000..b8b120063 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxdeclaration.dto; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报记录表单 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:40 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationFormDTO { + + //薪资所属月") + private YearMonth salaryMonth; + + //个税扣缴义务人id") + private Long taxAgentId; + + //个税扣缴义务人名称") + private String taxAgentName; + + //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java new file mode 100644 index 000000000..7fdadf741 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报表信息 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/16/21 3:22 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationInfoDTO { + + //薪资所属月") + private YearMonth salaryMonth; + + //个税扣缴义务人id") + private Long taxAgentId; + + //个税扣缴义务人名称") + private String taxAgentName; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java new file mode 100644 index 000000000..6ef172e76 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @description: 个税申报表详情列表(劳务报酬所得) + * @author: xiajun + * @modified By: xiajun + * @date: 2022/3/11 10:05 + * @version:v1.0 + */ +@Data +@Accessors(chain = true) +public class TaxDeclarationLaborListDTO { + + //主键id") + private Long id; + + //人员id") + private Long employeeId; + + //工号") + private String jobNum; + + //姓名") + private String username; + + //证件类型") + private String cardType; + + //证件号码") + private String cardNum; + + //"所得项目") + private String incomeItems; + + //"劳务收入") + private String laborIncome; + + //"劳务免税收入") + private String laborTaxFreeIncome; + + //"商业健康保险") + private String commercialHealthInsurance; + + //"税延养老保险") + private String taxDeferredEndowmentInsurance; + + //"其他") + private String other; + + //"准允扣除的捐赠额") + private String allowedDonation; + + //"减免税额") + private String taxDeduction; + + //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java new file mode 100644 index 000000000..13db69425 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报记录列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @TableTitle(title = "薪资所属月份", dataIndex = "salaryMonth", key = "salaryMonth") + private String salaryMonth; + + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentId", key = "taxAgentId") + private Long taxAgentId; + + @TableTitle(title = "个税扣缴义务人名称", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + + @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") + private String taxCycle; + + @TableTitle(title = "操作人id", dataIndex = "operateEmployeeId", key = "operateEmployeeId") + private Long operateEmployeeId; + + @TableTitle(title = "操作人名称", dataIndex = "operateEmployeeName", key = "operateEmployeeName") + private String operateEmployeeName; + + @JsonFormat(pattern = "yyyy-MM-dd") + @TableTitle(title = "操作时间", dataIndex = "operateTime", key = "operateTime") + private String operateTime; + + @TableTitle(title = "备注", dataIndex = "description", key = "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 new file mode 100644 index 000000000..a5d1f3630 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java @@ -0,0 +1,91 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @description: 个税申报表详情列表(正常工资薪金所得) + * @author: xiajun + * @modified By: xiajun + * @date: 2022/3/11 9:35 + * @version:v1.0 + */ +@Data +@Accessors(chain = true) +public class TaxDeclarationWageListDTO { + + //主键id") + private Long id; + + //人员id") + private Long employeeId; + + //"工号") + private String jobNum; + + //"姓名") + private String username; + + //证件类型") + private String cardType; + + //证件号码") + private String cardNum; + + //本期收入") + private String income; + + //本期免税收入") + private String taxFreeIncome; + + //"基本养老保险费") + private String endowmentInsurance; + + //"基本医疗保险费") + private String medicalInsurance; + + //失业保险费") + private String unemploymentInsurance; + + //住房公积金") + private String housingProvidentFund; + + //"累计子女教育") + private String addUpChildEducation; + + //累计住房贷款利息") + private String addUpHousingLoanInterest; + + //"累计住房租金") + private String addUpHousingRent; + + //累计继续教育") + private String addUpContinuingEducation; + + //"累计赡养老人") + private String addUpSupportElderly; + + //"累计大病医疗") + private String addUpIllnessMedical; + + //"企业(职业)年金") + private String annuity; + + //商业健康保险") + private String commercialHealthInsurance; + + //"税延养老保险") + private String taxDeferredEndowmentInsurance; + + //"其他") + private String other; + + //"准允扣除的捐赠额") + private String allowedDonation; + + //"减免税额") + private String taxDeduction; + + //"备注") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java new file mode 100644 index 000000000..ee7c58e2a --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * @description: 个税申报记录详情列表查询参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 3:21 PM + * @version:v1.0 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailListQueryParam extends BaseQueryParam { + + //"个税申报记录id") + private Long taxDeclarationId; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java new file mode 100644 index 000000000..9bf32829c --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报记录查询条件 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:30 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationListQueryParam extends BaseQueryParam { + + //薪资所属月范围起点 + private YearMonth fromSalaryMonth; + + //薪资所属月范围终点 + private YearMonth endSalaryMonth; + + private String fromSalaryMonthStr; + + private String endSalaryMonthStr; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java new file mode 100644 index 000000000..8e4c734ed --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 生成个税申报表参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:44 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationSaveParam { + + //薪资所属月") + private YearMonth salaryMonth; + + //备注") + private String description; + + private String salaryMonthStr; + +} diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java new file mode 100644 index 000000000..2f6952696 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.taxdeclaration.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @description: 个税申报表详情 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/14/21 7:01 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailPO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税申报记录id + */ + private Long taxDeclarationId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 申报表字段code + */ + private String fieldCode; + + /** + * 申报表字段的值 + */ + private String fieldValue; + + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; + + /** + * 应税项目。1:正常工资薪金所得 + */ + private Integer incomeCategory; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java new file mode 100644 index 000000000..7836bff64 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java @@ -0,0 +1,76 @@ +package com.engine.salary.entity.taxdeclaration.po; + +import com.engine.salary.common.LocalDateRange; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @description: 个税申报记录 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/14/21 6:57 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资所属月 + */ + private Date salaryMonth; + + /** + * 税款所属期 + */ + private Date taxCycle; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 备注 + */ + private String description; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + //税款所属期 + LocalDateRange salaryMonths; +} diff --git a/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java b/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java new file mode 100644 index 000000000..6da2aab85 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.taxrate.vo; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报记录列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4275-9527-7d06e54y6rj8", + fields = "id, salary_month, tax_cycle, tax_agent_id, description,creator, create_time, update_time, delete_type, tenant_key", + fromSql = "from hrsa_tax_declaration", + orderby = "id desc", + primarykey = "id", + operates = {@SalaryTableOperate(text = "查看")} +) +public class TaxDeclarationListVO { + + private Long id; + + @SalaryTableColumn( + text = "薪资所属月", + column = "salaryMonth", + width = "10%" + ) + private String salaryMonth; + + private Long taxAgentId; + + /* @SalaryTableColumn( + text = "个税扣缴义务人", + column = "taxAgentName", + width = "20%" + ) + private String taxAgentName;*/ + + @SalaryTableColumn( + text = "税款所属期", + column = "taxCycle", + width = "10%" + ) + private String taxCycle; + + private Long operateEmployeeId; + + /* @SalaryTableColumn( + text = "操作人", + column = "operateEmployeeName", + width = "10%" + ) + private String operateEmployeeName; +*/ + /* @SalaryTableColumn( + text = "操作时间", + column = "operateTime", + width = "20%" + ) + private String operateTime;*/ + + @SalaryTableColumn( + text = "备注", + column = "description", + width = "30%" + ) + private String description; +} diff --git a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java index 5de3d0b81..5b60f0b0a 100644 --- a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java +++ b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java @@ -15,6 +15,8 @@ public enum IncomeCategoryEnum implements BaseEnum { WAGES_AND_SALARIES(1, "正常工资薪金所得", 98656), + REMUNERATION_FOR_LABOR(4, "劳务报酬所得", 105218), + // 暂时注释掉,后续会开放 // ONETIME_ANNUAL_BONUS(2,"全年一次性奖金收入", 0), // diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java index 39242506c..e3f852d35 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java @@ -1,8 +1,11 @@ package com.engine.salary.mapper.taxdeclaration; import com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; @Mapper @@ -63,5 +66,11 @@ public interface TaxDeclarationDetailMapper { * @return 返回影响行数 */ int delete(TaxDeclarationDetail taxDeclarationDetail); - + + /** + * 批量插入 + * + * @param taxDeclarationDetails + */ + void batchInsert(@Param("collection") Collection taxDeclarationDetails); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml index e777cf3d9..3394ebbfa 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml @@ -148,6 +148,26 @@ + + INSERT INTO hrsa_tax_declaration_detail + (id, tax_declaration_id, employee_id, field_code, field_value, creator, + create_time, update_time, delete_type, tenant_key) + VALUES + + ( + #{item.id}, + #{item.taxDeclarationId}, + #{item.employeeId}, + #{item.fieldCode}, + #{item.fieldValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java index ba3011bcc..f436d1d08 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java @@ -1,8 +1,11 @@ package com.engine.salary.mapper.taxdeclaration; import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; @Mapper @@ -63,5 +66,19 @@ public interface TaxDeclarationMapper { * @return 返回影响行数 */ int delete(TaxDeclaration taxDeclaration); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + + List listSome(TaxDeclarationPO taxDeclarationPO); + /** + * 批量插入 + * + * @param taxDeclarationDetails + */ + void batchInsert(@Param("collection") Collection taxDeclarationDetails); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml index 03080c4cf..67a478c41 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml @@ -16,9 +16,7 @@ - t - . - create_time + t.create_time , t.creator , t.delete_type , t.description @@ -45,6 +43,41 @@ FROM hrsa_tax_declaration t WHERE id = #{id} AND delete_type = 0 + + + + + INSERT INTO hrsa_tax_declaration + (create_time, creator, delete_type, description, id, salary_month, + tax_agent_id, tax_cycle, tenant_key, update_time) + VALUES + + ( + #{item.create_time}, + #{item.creator}, + #{item.delete_type}, + #{item.description}, + #{item.id}, + #{item.salary_month}, + #{item.tax_agent_id}, + #{item.tax_cycle}, + #{item.tenant_key}, + #{item.update_time} + ) + + listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds, String tenantKey); + + /** + * 根据列表查询条件查询个税申报列表明细中的人员 + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + //Page listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey); + + /** + * 根据列表查询条件查询个税申报列表明细 + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + // Page listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey); + + /** + * 根据列表查询条件查询个税申报列表明细(劳务报酬所得) + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + PageInfo listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 根据列表查询条件查询个税申报列表明细(正常工资薪金所得) + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + PageInfo listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 批量保存 + * + * @param taxDeclarationDetailPOS 个税申报表明细po + */ + void batchSave(Collection taxDeclarationDetailPOS); +} diff --git a/src/com/engine/salary/service/TaxDeclarationService.java b/src/com/engine/salary/service/TaxDeclarationService.java index 32dbe8831..07ea4d1e5 100644 --- a/src/com/engine/salary/service/TaxDeclarationService.java +++ b/src/com/engine/salary/service/TaxDeclarationService.java @@ -1,5 +1,14 @@ package com.engine.salary.service; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; import java.util.Map; public interface TaxDeclarationService { @@ -9,7 +18,18 @@ public interface TaxDeclarationService { */ Map listPage(Map params); - Map save(Map params); + PageInfo listPageByParam(TaxDeclarationListQueryParam queryParam); + + List countByTaxDeclarationId(Collection taxAgentIds); + + //表单 + TaxDeclaration getById(Long id); + + Map getForm(Map params); + + Map getTaxDeclarationInfo(Map params); + + void save(TaxDeclarationSaveParam saveParam); Map update(Map params); diff --git a/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java new file mode 100644 index 000000000..40336a291 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java @@ -0,0 +1,81 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.util.page.PageInfo; + +import javax.annotation.Resource; +import java.util.Collection; + +/** + * @description: 个税申报表明细 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/23/22 4:29 PM + * @version:v1.0 + */ +public class TaxDeclarationDetailServiceImpl extends Service implements TaxDeclarationDetailService { + + @Resource + private TaxDeclarationDetailMapper taxDeclarationDetailMapper; + //@Resource + //private HrmCommonEmployeeService hrmCommonEmployeeService; + + /*@Override + public List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds, String tenantKey) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return new LambdaQueryChainWrapper<>(taxDeclarationDetailMapper) + .eq(TaxDeclarationDetailPO::getTenantKey, tenantKey) + .eq(TaxDeclarationDetailPO::getDeleteType, 0) + .eq(TaxDeclarationDetailPO::getTaxDeclarationId, taxDeclarationId) + .in(TaxDeclarationDetailPO::getEmployeeId, employeeIds) + .list(); + } + + @Override + public Page listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey) { + // 分页参数 + Page page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + // 查询个税申报表明细中的人员(分页) + return taxDeclarationDetailMapper.listEmployeeId(page, queryParam.getTaxDeclarationId(), tenantKey); + } + + @Override + public Page listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey) { + // 查询个税申报表明细的人员 + Page employeeIdPage = listPage4EmployeeIdByParam(queryParam, tenantKey); + Page dtoPage = new Page<>(employeeIdPage.getCurrent(), employeeIdPage.getSize(), employeeIdPage.getTotal(), employeeIdPage.isSearchCount()); + if (CollectionUtils.isNotEmpty(employeeIdPage.getRecords())) { + // 查询个税申报表明细 + List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(queryParam.getTaxDeclarationId(), + employeeIdPage.getRecords(), tenantKey); + // 查询人员信息 + List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIdPage.getRecords(), tenantKey); + // 转换成列表dto + TaxDeclarationBO.buildDetailListDTO(queryParam.getTaxDeclarationId(), dtoPage, taxDeclarationDetailPOS, simpleEmployees); + } + return dtoPage; + }*/ + + @Override + public PageInfo listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam) { + return null; + } + + @Override + public PageInfo listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam) { + return null; + } + + @Override + public void batchSave(Collection taxDeclarationDetailPOS) { + taxDeclarationDetailMapper.batchInsert(taxDeclarationDetailPOS); + } +} diff --git a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java index ce30a20e1..44290e421 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java @@ -1,24 +1,98 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationDeleteCmd; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationListCmd; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationSaveCmd; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationUpdateCmd; +import com.engine.salary.cmd.taxDeclaration.*; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.entity.taxrate.param.TaxAgentQueryParam; +import com.engine.salary.mapper.TaxAgentMapper; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.PageUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; -import java.util.Map; +import java.util.*; public class TaxDeclarationServiceImpl extends Service implements TaxDeclarationService { + private TaxDeclarationMapper getTaxDeclarationMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationMapper.class); + } + @Override public Map listPage(Map params) { return commandExecutor.execute(new TaxDeclarationListCmd(params, user)); } @Override - public Map save(Map params) { - return commandExecutor.execute(new TaxDeclarationSaveCmd(params, user)); + public PageInfo listPageByParam(TaxDeclarationListQueryParam queryParam) { + // 分页参数 + TaxDeclarationPO po = TaxDeclarationPO.builder().build(); + PageInfo page = new PageInfo<>(); + LocalDateRange localDateRange = new LocalDateRange(); + if (Objects.nonNull(queryParam.getFromSalaryMonth())) { + localDateRange.setFromDate(SalaryDateUtil.localDateToDate(queryParam.getFromSalaryMonth().atDay(1))); + } + if (Objects.nonNull(queryParam.getEndSalaryMonth())) { + localDateRange.setEndDate(SalaryDateUtil.localDateToDate(queryParam.getEndSalaryMonth().atEndOfMonth())); + } + po.setSalaryMonths(localDateRange); + //Page page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); +// if (SalaryEntityUtil.isNotNullOrEmpty(queryParam.getFromSalaryMonth())&&SalaryEntityUtil.isNotNullOrEmpty(queryParam.getEndSalaryMonth()) ) { +// // taxDeclarationMapper.selectPage(page, queryWrapper) +// } + // 查询个税申报表 + PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List taxDeclarationPOS = getTaxDeclarationMapper().listSome(po); + page.setList(taxDeclarationPOS); + + return page; + } + //根据id查询taxAgents + @Override + public List countByTaxDeclarationId(Collection taxAgentIds) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return Collections.emptyList(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class); + return taxAgentMapper.listBySome(TaxAgentQueryParam.builder().ids(taxAgentIds).build()); + } finally { + sqlSession.close(); + } + } + //根据id获取TaxDeclaration + @Override + public TaxDeclaration getById(Long id) { + return getTaxDeclarationMapper().getById(id); + } + + @Override + public Map getForm(Map params) { + return commandExecutor.execute(new TaxDeclarationGetFormCmd(params, user)); + } + + @Override + public Map getTaxDeclarationInfo(Map params) { + return commandExecutor.execute(new TaxDeclarationGetTaxDeclarationInfoCmd(params, user)); + } + + @Override + public void save(TaxDeclarationSaveParam saveParam) { + //return commandExecutor.execute(new TaxDeclarationSaveCmd(saveParam)); + return; } @Override diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 8a4853cd8..566dc95a5 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -165,6 +165,12 @@ public class SalaryDateUtil { ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault()); return Date.from(zonedDateTime.toInstant()); } + public static Date localDateTimeToDate(LocalDateTime localDateTime) { + if (null == localDateTime) { + return null; + } + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } public static String getFormatLocalDate(Date date) { if (date == null) { diff --git a/src/com/engine/salary/web/TaxDeclarationController.java b/src/com/engine/salary/web/TaxDeclarationController.java index 48268a4b8..c4bc63540 100644 --- a/src/com/engine/salary/web/TaxDeclarationController.java +++ b/src/com/engine/salary/web/TaxDeclarationController.java @@ -1,47 +1,90 @@ package com.engine.salary.web; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.TaxDeclarationWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + + public class TaxDeclarationController { - // @PostMapping("/list") - // @ApiOperation("个税申报表列表") - // @WeaPermission - // public WeaResult> listTaxDeclaration(@RequestBody TaxDeclarationListQueryParam queryParam) { - // WeaTable weaTable = taxDeclarationWrapper.listPage(queryParam, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(weaTable); - // } - // - // @GetMapping("/getForm") - // @ApiOperation("个税申报表表单") - // @WeaPermission - // public WeaResult getForm(@RequestParam(value = "id", required = false) Long id) { - // WeaForm weaForm = taxDeclarationWrapper.getForm(id, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(weaForm); - // } - // - // @GetMapping("/getTaxDeclarationInfo") - // @ApiOperation("个税申报表相关信息") - // @WeaPermission - // public WeaResult getTaxDeclarationInfo(@RequestParam(value = "taxDeclarationId") Long taxDeclarationId) { - // TaxDeclarationInfoDTO taxDeclarationInfo = taxDeclarationWrapper.getTaxDeclarationInfoById(taxDeclarationId, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(taxDeclarationInfo); - // } - // - // @PostMapping("/save") - // @ApiOperation("个税申报表生成") - // @WeaPermission - // public WeaResult saveTaxDeclaration(@RequestBody TaxDeclarationSaveParam saveParam) { - // taxDeclarationWrapper.save(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); - // return WeaResult.success(null); - // } - // - // @PostMapping("/detail/list") - // @ApiOperation("个税申报表详情列表") - // @WeaPermission - // public WeaResult> listTaxDeclarationDetail(@RequestBody TaxDeclarationDetailListQueryParam queryParam) { - // WeaTable weaTable = taxDeclarationDetailWrapper.listPage(queryParam, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(weaTable); - // } - // + // private BaseBean logger = new BaseBean(); + + private TaxDeclarationService getService(User user) { + return (TaxDeclarationService) ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxDeclarationWrapper getTaxDeclarationWrapper(User user) { + return ServiceUtil.getService(TaxDeclarationWrapper.class, user); + } + /* private TaxDeclarationDetailWrapper getTaxDeclarationDetailWrapper(User user) { + return ServiceUtil.getService(TaxDeclarationDetailWrapper.class, user); + }*/ + + + //个税申报表列表 + @POST + @Path("/listPage") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationListQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + queryParam.setFromSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getFromSalaryMonthStr())); + queryParam.setEndSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndSalaryMonthStr())); + return new ResponseResult>().run(getTaxDeclarationWrapper(user)::listPage, queryParam); + } + + //个税申报表表单 + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult().run(getTaxDeclarationWrapper(user)::getForm, id); + } + //个税申报表相关信息 + @GET + @Path("/getTaxDeclarationInfo") + @Produces(MediaType.APPLICATION_JSON) + public String getTaxDeclarationInfo(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "taxDeclarationId") Long taxDeclarationId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult().run(getTaxDeclarationWrapper(user)::getTaxDeclarationInfoById, taxDeclarationId); + } + //个税申报表生成 + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + param.setSalaryMonth(SalaryDateUtil.String2YearMonth(param.getSalaryMonthStr())); + return new ResponseResult().run(getTaxDeclarationWrapper(user)::save, param); + } + //个税申报表详情列表 + /* @GET + @Path("/detail/list") + @Produces(MediaType.APPLICATION_JSON) + public String listTaxDeclarationDetail(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationDetailListQueryParam param) { + User user = HrmUserVerify.getUser(request, response); + return new ResponseResult().run(getTaxDeclarationDetailWrapper(user)::listPage, param); + }*/ + // @PostMapping("/export") // @ApiOperation("个税申报表相关信息") // @WeaPermission diff --git a/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java new file mode 100644 index 000000000..0717444c8 --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java @@ -0,0 +1,66 @@ +/* +package com.engine.salary.wrapper; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Objects; + +*/ +/** + * @description: 个税申报表明细 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/23/22 6:07 PM + * @version:v1.0 + *//* + +@Slf4j +@Component +public class TaxDeclarationDetailWrapper extends Service { + + @Resource + private TaxDeclarationService taxDeclarationService; + @Resource + private TaxDeclarationDetailService taxDeclarationDetailService; + + */ +/** + * 个税申报表明细列表 + * + * @param queryParam 列表查询条件 + * @return + *//* + + public PageInfo listPage(TaxDeclarationDetailListQueryParam queryParam) { + TaxDeclaration taxDeclaration = taxDeclarationService.getById(queryParam.getTaxDeclarationId()); + PageInfo dtoPage = new PageInfo(TaxDeclarationDetailListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + // 正常工资薪金所得 + if (Objects.equals(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + PageInfo taxDeclarationWageListDTOPageInfo = taxDeclarationDetailService.listDtoPageByParam4Wage(queryParam); + dtoPage.setList(taxDeclarationWageListDTOPageInfo.getList()); + //weaTable = SalaryFormatUtil.getInstance().buildTable(TaxDeclarationWageListDTO.class, dtoPage); + } + // 劳务报酬所得 + if (Objects.equals(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { + PageInfo taxDeclarationLaborListDTOPageInfo = taxDeclarationDetailService.listDtoPageByParam4Labor(queryParam); + dtoPage.setList(taxDeclarationLaborListDTOPageInfo.getList()); + //weaTable = SalaryFormatUtil.getInstance().buildTable(TaxDeclarationLaborListDTO.class, dtoPage); + } + return dtoPage; + } +} +*/ diff --git a/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java new file mode 100644 index 000000000..0fea8f8dd --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java @@ -0,0 +1,286 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.EmployBiz; +import com.engine.salary.biz.SalaryItemBiz; +import com.engine.salary.biz.TaxAgentBiz; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AddUpSituationMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import weaver.hrm.User; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @description: 个税申报表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/23/22 5:50 PM + * @version:v1.0 + */ +@Component +public class TaxDeclarationWrapper extends Service { + + private TaxDeclarationService getTaxDeclarationService(User user) { + return (TaxDeclarationService) ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + private TaxDeclarationMapper getTaxDeclarationMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationMapper.class); + } + + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); + } + + @Resource + private TaxAgentBiz taxAgentBiz; + @Resource + private SalaryItemBiz salaryItemBiz; + @Resource + private TaxDeclarationDetailService taxDeclarationDetailService; + @Resource + private SalaryAcctResultService salaryAcctResultService; + @Resource + private SalaryAcctRecordService salaryAcctRecordService; + @Resource + private AddUpSituationMapper addUpSituationMapper; + @Resource + private TaxDeclarationMapper taxDeclarationMapper; + @Resource + private SalarySobService salarySobService; + + /** + * 个税申报表列表 + * + * @param queryParam 列表查询条件 + * @param + * @return + */ + public PageInfo listPage(TaxDeclarationListQueryParam queryParam) { + EmployBiz employBiz = new EmployBiz(); + // 询个税申报表(分页) + PageInfo page = getTaxDeclarationService(user).listPageByParam(queryParam); + PageInfo dtoPage = new PageInfo(TaxDeclarationListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + List list = page.getList(); + if (CollectionUtils.isNotEmpty(list)) { + // 查询人员 + List employeeIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getCreator, Collectors.toList()); + List employeeComInfos = employBiz.getEmployeeByIdsAll(employeeIds); + // 查询个税扣缴义务人 + Set taxAgentIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getTaxAgentId); + List taxAgentPOS = taxAgentBiz.listByIds(taxAgentIds); + //List taxAgentPOS = getTaxDeclarationService(user).countByTaxDeclarationId(taxAgentIds); + // 转换成列表dto + List taxDeclarationListDTOS = TaxDeclarationBO.convert2ListDTO(list, employeeComInfos, taxAgentPOS); + dtoPage.setList(taxDeclarationListDTOS); + } + return dtoPage; + } + + + public TaxDeclarationFormDTO getForm(Long id) { + TaxDeclarationFormDTO formDTO = new TaxDeclarationFormDTO(); + if (Objects.nonNull(id)) { + // 查询个税申报表 + TaxDeclaration taxDeclaration = getTaxDeclarationService(user).getById(id); + if (Objects.isNull(taxDeclaration)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); + } + // 查询个税扣缴义务人 + TaxAgent taxAgent = taxAgentBiz.getById(id); + // 转换成个税申报表详情dto + formDTO = TaxDeclarationFormDTO.builder() + .salaryMonth(SalaryDateUtil.localDate2YearMonth(taxDeclaration.getSalaryMonth())) + .taxAgentId(taxDeclaration.getTaxAgentId()) + .taxAgentName(Optional.ofNullable(taxAgent).map(TaxAgent::getName).orElse("")) + .description(taxDeclaration.getDescription()) + .build(); + } + // 转换成前端所需的数据格式 + // WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(TaxDeclarationFormDTO.class, formDTO); + + // 查询租户所有的个税扣缴义务人 + Collection taxAgentListDTOS = taxAgentBiz.listAll(); + // 表单中个税扣缴义务人的可选项 + List weaFormOptions = Lists.newArrayListWithExpectedSize(taxAgentListDTOS.size()); + for (TaxAgent taxAgent : taxAgentListDTOS) { + weaFormOptions.add(new WeaFormOption("" + taxAgent.getId(), taxAgent.getName())); + } +// weaForm.getItems().forEach((k, v) -> { +// if (StringUtils.equals("taxAgentId", k)) { +// v.setOptions(weaFormOptions); +// } +// if (StringUtils.equals("salaryMonth", k)) { +// Map otherParams = new HashMap<>(); +// otherParams.put("type", "month"); +// v.setOtherParams(otherParams); +// } +// }); + return formDTO; + } + /* + *//** + * 查询个税申报表的基本信息 + * + * @param id 个税申报表id + * @return + */ + public TaxDeclarationInfoDTO getTaxDeclarationInfoById(Long id) { + // 查询个税申报表 + //TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(id); + TaxDeclaration taxDeclaration = getTaxDeclarationService(user).getById(id); + if (Objects.isNull(taxDeclaration)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); + } + // 查询个税扣缴义务人 + TaxAgent taxAgentPO = taxAgentBiz.getById(taxDeclaration.getTaxAgentId()); + return TaxDeclarationInfoDTO.builder() + .salaryMonth(SalaryDateUtil.localDate2YearMonth(taxDeclaration.getSalaryMonth())) + .taxAgentId(taxDeclaration.getTaxAgentId()) + .taxAgentName(Optional.ofNullable(taxAgentPO).map(TaxAgent::getName).orElse("")) + .build(); + } + /* + *//** + * 保存 + * + * @param saveParam 保存参数 + */ + @Transactional(rollbackFor = Exception.class) + public void save(TaxDeclarationSaveParam saveParam) { + //getTaxDeclarationService(user).save(saveParam); + EmployBiz employBiz = new EmployBiz(); + // 薪资所属月的日期范围 + LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2YearRange(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))); + if (Objects.isNull(salaryMonthDateRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + // 查询薪资所属月已经生成过的个税申报表 + List taxDeclarationPOS = listBySalaryMonthTax(salaryMonthDateRange); + // 已经生成过个税申报表,不允许再次生成个税申报表 + if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98873, "{0}已经生成过个税申报表,不允许再次生成") + .replace("{0}", saveParam.getSalaryMonth().toString())); + } + // 查询薪资所属月的薪资核算记录 + List salaryAcctRecordPOS = listBySalaryMonth(salaryMonthDateRange); + // 无薪资核算记录,不允许生成个税申报表 + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据") + .replace("{0}", saveParam.getSalaryMonth().toString())); + } + // 如果存在未归档的,也不允许生成个税申报表 + boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())); + if (notArchived) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报") + .replace("{0}", saveParam.getSalaryMonth().toString())); + } + // 如果当前薪资所属月下存在不同的税款所属期,属于异常业务场景,不允许生成个税申报表 + Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle(); + boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0); + if (differentTaxCycle) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表") + .replace("{0}", saveParam.getSalaryMonth().toString())); + } + // 查询薪资核算结果 + Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + List salaryAcctResultPOS = salaryAcctResultService.listBySalaryAcctRecordIds(salaryAcctRecordIds); + // 无薪资核算结果,不允许生成个税申报表 + if (CollectionUtils.isEmpty(salaryAcctResultPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据") + .replace("{0}", saveParam.getSalaryMonth().toString())); + } + // 查询薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); + List salarySobPOS = salarySobService.listByIds(salarySobIds); + + //查询DataCollectionEmployee + //DataCollectionEmployee employeeId = + + // 查询所有薪资项目 + List salaryItemPOS = salaryItemBiz.listAll(); + // 处理要保存的数据 + TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, salaryItemPOS, salarySobPOS,salaryAcctResultPOS); + // 保存个税申报表 + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) { + + taxDeclarationMapper.batchInsert(result.getNeedInsertTaxDeclarations()); + } + // 保存个税申报表明细 + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) { + + taxDeclarationDetailService.batchSave(result.getNeedInsertTaxDeclarationDetails()); + } + // 保存累计情况 + if (CollectionUtils.isNotEmpty(result.getNeedInsertAccumulatedSituations())) { + // TODO: 1/23/22 待修改(不能直接调用mapper) + // addUpSituationMapper.insertData(Lists.newArrayList(result.getNeedInsertAccumulatedSituations())); + } + // 更新薪资核算记录的状态 + salaryAcctRecordService.updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED); + // 查询个税扣缴义务人 + Set taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId); + List taxAgentPOS = taxAgentBiz.listByIds(taxAgentIds); + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgent::getId, TaxAgent::getName); + // 记录日志 + /*for (TaxDeclarationPO taxDeclarationPO : result.getNeedInsertTaxDeclarations()) { + String targetName = SalaryDateUtil.toYearMonth(taxDeclarationPO.getSalaryMonth()) + + "(" + taxAgentNameMap.getOrDefault(taxDeclarationPO.getTaxAgentId(), StringUtils.EMPTY) + ")"; + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(String.valueOf(taxDeclarationPO.getId())); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(99815, "生成个税申报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(99815, "生成个税申报表")); + taxDeclarationLoggerTemplate.write(loggerContext); + }*/ + } + + public List listBySalaryMonthTax(LocalDateRange salaryMonthDateRange) { + return getTaxDeclarationMapper().listSome(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).build()); + } + + public List listBySalaryMonth(LocalDateRange salaryMonthDateRange) { + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build()); + } + +} From 6fce8cdf4cbed36cdbdb9f3147fa070dd60535dc Mon Sep 17 00:00:00 2001 From: "18895359881@163.com" <521027xyz> Date: Mon, 18 Apr 2022 18:56:17 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=96=AA=E9=85=AC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taxdeclaration/bo/TaxDeclarationBO.java | 17 +- .../bo/TaxDeclarationDetailListColumn.java | 870 ++++++++++++++++++ .../param/TaxDeclarationListQueryParam.java | 5 +- .../TaxDeclarationDetailMapper.java | 29 + .../TaxDeclarationDetailMapper.xml | 16 + .../taxdeclaration/TaxDeclarationMapper.xml | 8 +- .../service/TaxDeclarationDetailService.java | 3 +- .../service/TaxDeclarationExcelService.java | 23 + .../impl/TaxDeclarationDetailServiceImpl.java | 66 +- .../impl/TaxDeclarationExcelServiceImpl.java | 78 ++ .../impl/TaxDeclarationServiceImpl.java | 2 - .../engine/salary/util/SalaryDateUtil.java | 13 + .../salary/web/TaxDeclarationController.java | 46 +- .../salary/wrapper/TaxDeclarationWrapper.java | 38 +- 14 files changed, 1153 insertions(+), 61 deletions(-) create mode 100644 src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java create mode 100644 src/com/engine/salary/service/TaxDeclarationExcelService.java create mode 100644 src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java index d4328bc2c..d7775ea78 100644 --- a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java @@ -5,6 +5,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; @@ -13,6 +14,8 @@ import com.engine.salary.entity.taxrate.TaxAgent; import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import dm.jdbc.util.IdGenerator; @@ -54,17 +57,17 @@ public class TaxDeclarationBO { .build()).collect(Collectors.toList()); } - /*public static void buildDetailListDTO(Long taxDeclarationId, - Page page, + public static void buildDetailListDTO(Long taxDeclarationId, + PageInfo page, List taxDeclarationDetails, - List simpleEmployees) { + List simpleEmployees) { if (CollectionUtils.isEmpty(taxDeclarationDetails)) { return; } - int index = (int) ((page.getCurrent() - 1) * page.getSize()); + int index = (page.getNextPage() - 1) * page.getSize(); List dtos = Lists.newArrayListWithExpectedSize(simpleEmployees.size()); Map> taxDeclarationDetailMap = SalaryEntityUtil.group2Map(taxDeclarationDetails, TaxDeclarationDetailPO::getEmployeeId); - for (SimpleEmployee simpleEmployee : simpleEmployees) { + for (DataCollectionEmployee simpleEmployee : simpleEmployees) { Map valueMap = SalaryEntityUtil.convert2Map(taxDeclarationDetailMap.get(simpleEmployee.getEmployeeId()), TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue); TaxDeclarationDetailListDTO dto = new TaxDeclarationDetailListDTO(); dto.setId(simpleEmployee.getEmployeeId()); @@ -111,8 +114,8 @@ public class TaxDeclarationBO { dto.setRefundedOrSupplementedTax(valueMap.getOrDefault("refundedOrSupplementedTax","")); dtos.add(dto); } - page.setRecords(dtos); - }*/ + page.setList(dtos); + } public static Result handle(TaxDeclarationSaveParam saveParam, Date taxCycle, diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java new file mode 100644 index 000000000..0664942dc --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java @@ -0,0 +1,870 @@ +package com.engine.salary.entity.taxdeclaration.bo; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import java.util.List; + +/** + * @description: 个税申报表明细的表头 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 11:31 AM + * @version:v1.0 + */ +public class TaxDeclarationDetailListColumn { + + private static final String COLUMN = " [\n" + + " {\n" + + " title: '序号',\n" + + " titleLabelId: 84162,\n" + + " dataIndex: 'seq_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '1',\n" + + " dataIndex: 'seq',\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '姓名',\n" + + " titleLabelId: 85429,\n" + + " dataIndex: 'employeeName_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '2',\n" + + " dataIndex: 'employeeName'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '身份证件类型',\n" + + " titleLabelId: 102781,\n" + + " dataIndex: 'idCardType_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '3',\n" + + " dataIndex: 'idCardType'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '身份证件号码',\n" + + " titleLabelId: 102782,\n" + + " dataIndex: 'idCardNo_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '4',\n" + + " dataIndex: 'idCardNo'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '纳税人识别号',\n" + + " titleLabelId: 102783,\n" + + " dataIndex: 'taxpayerIdNo_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '5',\n" + + " dataIndex: 'taxpayerIdNo'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '是否为非居民个人',\n" + + " titleLabelId: 102785,\n" + + " dataIndex: 'isPersonal_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '6',\n" + + " dataIndex: 'isPersonal'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '所得项目',\n" + + " titleLabelId: 102786,\n" + + " dataIndex: 'incomeType_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '7',\n" + + " dataIndex: 'incomeType'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '本月(次)情况',\n" + + " titleLabelId: 102787,\n" + + " dataIndex: 'condition_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " children : [\n" + + " {\n" + + " title: '收入额计算',\n" + + " titleLabelId: 102788,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'income_calc_p',\n" + + " children : [\n" + + " {\n" + + " title: '收入',\n" + + " titleLabelId: 96689,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'income_p',\n" + + " children : [\n" + + " {\n" + + " title: '8',\n" + + " dataIndex: 'income'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '费用',\n" + + " titleLabelId: 102789,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'fee_p',\n" + + " children : [\n" + + " {\n" + + " title: '9',\n" + + " dataIndex: 'fee'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '免税收入',\n" + + " titleLabelId: 102790,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxFreeIncome_p',\n" + + " children : [\n" + + " {\n" + + " title: '10',\n" + + " dataIndex: 'taxFreeIncome'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '减除费用',\n" + + " titleLabelId: 102791,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'subtraction_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '11',\n" + + " dataIndex: 'subtraction'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '专项扣除',\n" + + " titleLabelId: 85829,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'special_deduction_p',\n" + + " children : [\n" + + " {\n" + + " title: '基本养老保险费',\n" + + " titleLabelId: 102792,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'endowment_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '12',\n" + + " dataIndex: 'endowmentInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '基本医疗保险费',\n" + + " titleLabelId: 102793,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'medical_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '13',\n" + + " dataIndex: 'medicalInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '失业保险费',\n" + + " titleLabelId: 102794,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'unemployment_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '14',\n" + + " dataIndex: 'unemploymentInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '住房公积金',\n" + + " titleLabelId: 102795,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'housing_fund_p',\n" + + " children : [\n" + + " {\n" + + " title: '15',\n" + + " dataIndex: 'housingProvidentFund'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '其他扣除',\n" + + " titleLabelId: 85831,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'other_deduction_p',\n" + + " children : [\n" + + " {\n" + + " title: '年金',\n" + + " titleLabelId: 102796,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'annuity_p',\n" + + " children : [\n" + + " {\n" + + " title: '16',\n" + + " dataIndex: 'annuity'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '商业健康保险',\n" + + " titleLabelId: 91238,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'commercial_health_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '17',\n" + + " dataIndex: 'commercialHealthInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '税延养老保险',\n" + + " titleLabelId: 91239,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'tax_deferred_endowment_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '18',\n" + + " dataIndex: 'taxDeferredEndowmentInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '财产原值',\n" + + " titleLabelId: 102797,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'originalValueOfProperty_p',\n" + + " children : [\n" + + " {\n" + + " title: '19',\n" + + " dataIndex: 'originalValueOfProperty'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '允许扣除的税费',\n" + + " titleLabelId: 102798,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'deductedTax_p',\n" + + " children : [\n" + + " {\n" + + " title: '20',\n" + + " dataIndex: 'deductedTax'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '其他',\n" + + " titleLabelId: 102799,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'other_p',\n" + + " children : [\n" + + " {\n" + + " title: '21',\n" + + " dataIndex: 'other'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '累计情况(工资、薪金)',\n" + + " titleLabelId: 87521,\n" + + " dataIndex: 'cumsituation_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " children : [\n" + + " {\n" + + " title: '累计收入额',\n" + + " titleLabelId: 86712,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpIncome_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '22',\n" + + " dataIndex: 'addUpIncome'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '累计减除费用',\n" + + " titleLabelId: 86711,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpSubtraction_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '23',\n" + + " dataIndex: 'addUpSubtraction'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '累计专项扣除',\n" + + " titleLabelId: 102800,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpSpecialDeduction_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '24',\n" + + " dataIndex: 'addUpSpecialDeduction'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + "\n" + + " {\n" + + " title: '累计专项附加扣除',\n" + + " titleLabelId: 85380,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'income_calc_p',\n" + + " children : [\n" + + " {\n" + + " title: '子女教育',\n" + + " titleLabelId: 102801,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpChildEducation_p',\n" + + " children : [\n" + + " {\n" + + " title: '25',\n" + + " dataIndex: 'addUpChildEducation'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '赡养老人',\n" + + " titleLabelId: 102802,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpSupportElderly_p',\n" + + " children : [\n" + + " {\n" + + " title: '26',\n" + + " dataIndex: 'addUpSupportElderly'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '住房贷款利息',\n" + + " titleLabelId: 102803,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpHousingLoanInterest_p',\n" + + " children : [\n" + + " {\n" + + " title: '27',\n" + + " dataIndex: 'addUpHousingLoanInterest'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '住房租金',\n" + + " titleLabelId: 102804,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpHousingRent_p',\n" + + " children : [\n" + + " {\n" + + " title: '28',\n" + + " dataIndex: 'addUpHousingRent'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '继续教育',\n" + + " titleLabelId: 102805,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpContinuingEducation_p',\n" + + " children : [\n" + + " {\n" + + " title: '29',\n" + + " dataIndex: 'addUpContinuingEducation'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '累计其他扣除',\n" + + " titleLabelId: 90569,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpOther_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '30',\n" + + " dataIndex: 'addUpOther'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '减按计税比例',\n" + + " titleLabelId: 102806,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'lessTaxProportion_p',\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '31',\n" + + " dataIndex: 'lessTaxProportion'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '准予扣除的捐赠额',\n" + + " titleLabelId: 91240,\n" + + " dataIndex: 'allowedDonation_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '32',\n" + + " dataIndex: 'allowedDonation'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '税款计算',\n" + + " titleLabelId: 102807,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'cumsituation_p',\n" + + " children : [\n" + + " {\n" + + " title: '应纳税所得额',\n" + + " titleLabelId: 96693,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxableIncome_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '33',\n" + + " dataIndex: 'taxableIncome'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '税率/预扣率',\n" + + " titleLabelId: 102808,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxRate_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '34',\n" + + " dataIndex: 'taxRate'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '速算扣除数',\n" + + " titleLabelId: 84228,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'quickDeductionFactor_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '35',\n" + + " dataIndex: 'quickDeductionFactor'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '应纳税额',\n" + + " titleLabelId: 102809,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxPayable_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '36',\n" + + " dataIndex: 'taxPayable'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '减免税额',\n" + + " titleLabelId: 102810,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxSavings_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '37',\n" + + " dataIndex: 'taxSavings'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '已扣缴税额',\n" + + " titleLabelId: 102811,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxWithheld_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '38',\n" + + " dataIndex: 'taxWithheld'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '应补(退)税额',\n" + + " titleLabelId: 102812,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'refundedOrSupplementedTax_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '39',\n" + + " dataIndex: 'refundedOrSupplementedTax'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + "\n" + + " {\n" + + " title: '备注',\n" + + " titleLabelId: 84961,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'description_p',\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '40',\n" + + " dataIndex: 'description'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]"; + + /** + * 个税申报表导出的表头 + * + * @return + */ + public static String[] listHeader() { + return new String[]{ + SalaryI18nUtil.getI18nLabel(84162, "序号"), + SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(102781, "身份证件类型"), + SalaryI18nUtil.getI18nLabel(102782, "身份证件号码"), + SalaryI18nUtil.getI18nLabel(102783, "纳税人识别号"), + SalaryI18nUtil.getI18nLabel(102785, "是否为非居民个人"), + SalaryI18nUtil.getI18nLabel(102786, "所得项目"), + SalaryI18nUtil.getI18nLabel(96689, "收入"), + SalaryI18nUtil.getI18nLabel(102789, "费用"), + SalaryI18nUtil.getI18nLabel(102790, "免税收入"), + SalaryI18nUtil.getI18nLabel(102791, "减除费用"), + SalaryI18nUtil.getI18nLabel(102792, "基本养老保险费"), + SalaryI18nUtil.getI18nLabel(102793, "基本医疗保险费"), + SalaryI18nUtil.getI18nLabel(102794, "失业保险费"), + SalaryI18nUtil.getI18nLabel(102795, "住房公积金"), + SalaryI18nUtil.getI18nLabel(102796, "年金"), + SalaryI18nUtil.getI18nLabel(91238, "商业健康保险"), + SalaryI18nUtil.getI18nLabel(91239, "税延养老保险"), + SalaryI18nUtil.getI18nLabel(102797, "财产原值"), + SalaryI18nUtil.getI18nLabel(102798, "允许扣除的税费"), + SalaryI18nUtil.getI18nLabel(102799, "其他"), + SalaryI18nUtil.getI18nLabel(86712, "累计收入额"), + SalaryI18nUtil.getI18nLabel(86711, "累计减除费用"), + SalaryI18nUtil.getI18nLabel(102800, "累计专项扣除"), + SalaryI18nUtil.getI18nLabel(102801, "子女教育"), + SalaryI18nUtil.getI18nLabel(102802, "赡养老人"), + SalaryI18nUtil.getI18nLabel(102803, "住房贷款利息"), + SalaryI18nUtil.getI18nLabel(102804, "住房租金"), + SalaryI18nUtil.getI18nLabel(102805, "继续教育"), + SalaryI18nUtil.getI18nLabel(90569, "累计其他扣除"), + SalaryI18nUtil.getI18nLabel(102806, "减按计税比例"), + SalaryI18nUtil.getI18nLabel(91240, "准予扣除的捐赠额"), + SalaryI18nUtil.getI18nLabel(96693, "应纳税所得额"), + SalaryI18nUtil.getI18nLabel(102808, "税率/预扣率"), + SalaryI18nUtil.getI18nLabel(84228, "速算扣除数"), + SalaryI18nUtil.getI18nLabel(102809, "应纳税额"), + SalaryI18nUtil.getI18nLabel(102810, "减免税额"), + SalaryI18nUtil.getI18nLabel(102811, "已扣缴税额"), + SalaryI18nUtil.getI18nLabel(102812, "应补(退)税额"), + SalaryI18nUtil.getI18nLabel(84961, "备注")}; + } + + /** + * 解析个税申报表的标头 + * + * @return + */ + public static List listTableColumn() { + List weaTableColumns = Lists.newArrayList(JsonUtil.parseList(TaxDeclarationDetailListColumn.COLUMN, WeaTableColumn.class)); +// for (WeaTableColumn weaTableColumn : weaTableColumns) { +// buildTitle(weaTableColumn); +// } + return weaTableColumns; + } + + /** + * 个税申报表表头多语言 + * + * @param weaTableColumn + */ +// private static void buildTitle(WeaTableColumn weaTableColumn) { +// weaTableColumn.setTitle(SalaryI18nUtil.getI18nLabel(weaTableColumn.getTitleLabelId(), weaTableColumn.getTitle())); +// if (CollectionUtils.isNotEmpty(weaTableColumn.getChildren())) { +// for (WeaTableColumnWapper weaTableColumnWapper : weaTableColumn.getChildren()) { +// buildTitle(weaTableColumnWapper); +// } +// } +// } +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java index 9bf32829c..9e424075e 100644 --- a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java @@ -1,10 +1,7 @@ package com.engine.salary.entity.taxdeclaration.param; import com.engine.salary.common.BaseQueryParam; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import java.time.YearMonth; diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java index e3f852d35..1292826b5 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java @@ -2,6 +2,8 @@ package com.engine.salary.mapper.taxdeclaration; import com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail; import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.util.page.PageInfo; +import com.fapiao.neon.model.in.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -73,4 +75,31 @@ public interface TaxDeclarationDetailMapper { * @param taxDeclarationDetails */ void batchInsert(@Param("collection") Collection taxDeclarationDetails); + + /** + * 统计一共多少人员 + * + * @param taxDeclarationId + * @param tenantKey + * @return + */ + int countEmployeeId(@Param("taxDeclarationId") Long taxDeclarationId); + /** + * 分页查询人员id + * + * @param page + * @param taxDeclarationId + * @param tenantKey + * @return + */ + PageInfo listEmployeeId(@Param("taxDeclarationId") Long taxDeclarationId); + /** + * 查询个税申报表明细 + * + * @param page + * @param taxDeclarationId + * @param employeeIds + * @return + */ + List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml index 3394ebbfa..352256066 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml @@ -45,6 +45,22 @@ FROM hrsa_tax_declaration_detail t WHERE id = #{id} AND delete_type = 0 + + + FROM hrsa_tax_declaration t WHERE delete_type = 0 - - AND salary_month = ]]> #{salaryMonths.fromSalaryMonth} + + AND salary_month = ]]> #{salaryMonths.fromDate} - - AND salary_month #{salaryMonths.endSalaryMonth} + + AND salary_month #{salaryMonths.endDate} ORDER BY id DESC diff --git a/src/com/engine/salary/service/TaxDeclarationDetailService.java b/src/com/engine/salary/service/TaxDeclarationDetailService.java index 5b3e2f972..fa17e6178 100644 --- a/src/com/engine/salary/service/TaxDeclarationDetailService.java +++ b/src/com/engine/salary/service/TaxDeclarationDetailService.java @@ -1,5 +1,6 @@ package com.engine.salary.service; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; @@ -44,7 +45,7 @@ public interface TaxDeclarationDetailService { * @param tenantKey 租户key * @return */ - // Page listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey); + PageInfo listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam); /** * 根据列表查询条件查询个税申报列表明细(劳务报酬所得) diff --git a/src/com/engine/salary/service/TaxDeclarationExcelService.java b/src/com/engine/salary/service/TaxDeclarationExcelService.java new file mode 100644 index 000000000..54f8644a1 --- /dev/null +++ b/src/com/engine/salary/service/TaxDeclarationExcelService.java @@ -0,0 +1,23 @@ +package com.engine.salary.service; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Map; + +/** + * @description: 个税申报表导出 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/4/22 4:09 PM + * @version:v1.0 + */ +public interface TaxDeclarationExcelService { + + /** + * 导出个税申报表 + * + * @param taxDeclarationId + * @param tenantKey + */ + XSSFWorkbook exportTaxDeclaration(Long taxDeclarationId); +} diff --git a/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java index 40336a291..003dd3744 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java @@ -1,16 +1,34 @@ package com.engine.salary.service.impl; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.salary.biz.EmployBiz; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; +import com.fapiao.neon.model.in.Page; +import com.mzlion.core.lang.CollectionUtils; +import weaver.hrm.User; import javax.annotation.Resource; import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import static com.engine.salary.entity.siaccount.param.DSTenantKeyThreadVar.tenantKey; /** * @description: 个税申报表明细 @@ -21,10 +39,12 @@ import java.util.Collection; */ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDeclarationDetailService { - @Resource - private TaxDeclarationDetailMapper taxDeclarationDetailMapper; - //@Resource - //private HrmCommonEmployeeService hrmCommonEmployeeService; + private TaxDeclarationDetailMapper getTaxDeclarationDetailMapper(User user) { + return MapperProxyFactory.getProxy(TaxDeclarationDetailMapper.class); + } + private SalaryEmployeeService getSalaryEmployeeService() { + return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } /*@Override public List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds, String tenantKey) { @@ -46,23 +66,26 @@ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDecla // 查询个税申报表明细中的人员(分页) return taxDeclarationDetailMapper.listEmployeeId(page, queryParam.getTaxDeclarationId(), tenantKey); } - +*/ @Override - public Page listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey) { + public PageInfo listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam) { // 查询个税申报表明细的人员 - Page employeeIdPage = listPage4EmployeeIdByParam(queryParam, tenantKey); - Page dtoPage = new Page<>(employeeIdPage.getCurrent(), employeeIdPage.getSize(), employeeIdPage.getTotal(), employeeIdPage.isSearchCount()); - if (CollectionUtils.isNotEmpty(employeeIdPage.getRecords())) { + PageInfo employeeIdPage = getTaxDeclarationDetailMapper(user).listEmployeeId(queryParam.getTaxDeclarationId()); + PageInfo dtoPage = new PageInfo(TaxDeclarationDetailListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + List list = employeeIdPage.getList(); + if (CollectionUtils.isNotEmpty(list)) { // 查询个税申报表明细 - List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(queryParam.getTaxDeclarationId(), - employeeIdPage.getRecords(), tenantKey); - // 查询人员信息 - List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIdPage.getRecords(), tenantKey); + List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(queryParam.getTaxDeclarationId(), employeeIdPage.getList()); + // 查询人员 + List simpleEmployees = getSalaryEmployeeService().listByIds(employeeIdPage.getList()); + // List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIdPage.getRecords(), tenantKey); // 转换成列表dto TaxDeclarationBO.buildDetailListDTO(queryParam.getTaxDeclarationId(), dtoPage, taxDeclarationDetailPOS, simpleEmployees); } return dtoPage; - }*/ + } @Override public PageInfo listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam) { @@ -76,6 +99,19 @@ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDecla @Override public void batchSave(Collection taxDeclarationDetailPOS) { - taxDeclarationDetailMapper.batchInsert(taxDeclarationDetailPOS); + getTaxDeclarationDetailMapper(user).batchInsert(taxDeclarationDetailPOS); + } + public List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + +// return new LambdaQueryChainWrapper<>(taxDeclarationDetailMapper) +// .eq(TaxDeclarationDetailPO::getTenantKey, tenantKey) +// .eq(TaxDeclarationDetailPO::getDeleteType, 0) +// .eq(TaxDeclarationDetailPO::getTaxDeclarationId, taxDeclarationId) +// .in(TaxDeclarationDetailPO::getEmployeeId, employeeIds) +// .list(); + return getTaxDeclarationDetailMapper(user).listByTaxDeclarationIdAndEmployeeIds(taxDeclarationId,employeeIds); } } diff --git a/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java new file mode 100644 index 000000000..9b48c48fd --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java @@ -0,0 +1,78 @@ +package com.engine.salary.service.impl; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationDetailListColumn; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.service.TaxDeclarationExcelService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.fapiao.neon.model.in.Page; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.time.LocalDateTime; +import java.util.*; + +/** + * @description: 个税申报表导出 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/4/22 4:17 PM + * @version:v1.0 + */ +@Slf4j +public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclarationExcelService { + + private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) { + return (TaxDeclarationDetailService) ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user); + } + private TaxDeclarationDetailMapper getTaxDeclarationDetailMapper(User user) { + return MapperProxyFactory.getProxy(TaxDeclarationDetailMapper.class); + } + + @Override + public XSSFWorkbook exportTaxDeclaration(Long taxDeclarationId) { + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "个税申报表"); + //表头字段 + String[] headers = TaxDeclarationDetailListColumn.listHeader(); + // 解析表头 + List weaTableColumns = TaxDeclarationDetailListColumn.listTableColumn(); + List headerList = new ArrayList<>(Arrays.asList(headers)); + // 查询当前个税申报表一共有多少人员 + int count = getTaxDeclarationDetailMapper(user).countEmployeeId(taxDeclarationId); + // 以1000个人员一页,一共有多少页 + int totalPages = (count % 1000 == 0) ? (count / 1000) : (count / 1000 + 1); //总页数 + // excel导出的数据 + List> rows = Lists.newArrayListWithExpectedSize(count); + rows.add(headerList); + for (int i = 0; i < totalPages; i++) { + TaxDeclarationDetailListQueryParam queryParam = new TaxDeclarationDetailListQueryParam().setTaxDeclarationId(taxDeclarationId); + queryParam.setCurrent(i); + queryParam.setPageSize(1000); + PageInfo dtoPage = getTaxDeclarationDetailService(user).listDtoPageByParam(queryParam); + for (Object taxDeclarationDetailListDTO : dtoPage.getList()) { + List row = Lists.newArrayListWithExpectedSize(headerList.size()); + Map map = JsonUtil.parseMap(taxDeclarationDetailListDTO, Object.class); + for (Object weaTableColumn : headerList) { + row.add(map.get(weaTableColumn)); + } + rows.add(row); + } + } + return ExcelUtil.genWorkbookV2(rows, sheetName); + } +} diff --git a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java index 44290e421..ac97f8aac 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java @@ -13,12 +13,10 @@ import com.engine.salary.mapper.TaxAgentMapper; import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; import com.engine.salary.service.TaxDeclarationService; import com.engine.salary.util.SalaryDateUtil; -import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.PageUtil; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 566dc95a5..cf9562811 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -401,5 +401,18 @@ public class SalaryDateUtil { return yearMonth.atEndOfMonth(); } + /** + * String转Date + * @param date + * @return + */ + public static Date stringToDate(String date) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = null; + if (date != null) { + parse = sdf.parse(date); + } + return parse; + } } diff --git a/src/com/engine/salary/web/TaxDeclarationController.java b/src/com/engine/salary/web/TaxDeclarationController.java index c4bc63540..8da68ee7a 100644 --- a/src/com/engine/salary/web/TaxDeclarationController.java +++ b/src/com/engine/salary/web/TaxDeclarationController.java @@ -6,14 +6,16 @@ import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.service.TaxDeclarationExcelService; import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.service.impl.TaxDeclarationExcelServiceImpl; import com.engine.salary.service.impl.TaxDeclarationServiceImpl; import com.engine.salary.util.ResponseResult; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.wrapper.TaxDeclarationWrapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; -import weaver.general.BaseBean; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -22,6 +24,11 @@ import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; public class TaxDeclarationController { @@ -35,6 +42,9 @@ public class TaxDeclarationController { private TaxDeclarationWrapper getTaxDeclarationWrapper(User user) { return ServiceUtil.getService(TaxDeclarationWrapper.class, user); } + private TaxDeclarationExcelService getTaxDeclarationExcelService(User user) { + return (TaxDeclarationExcelService)ServiceUtil.getService(TaxDeclarationExcelServiceImpl.class, user); + } /* private TaxDeclarationDetailWrapper getTaxDeclarationDetailWrapper(User user) { return ServiceUtil.getService(TaxDeclarationDetailWrapper.class, user); }*/ @@ -44,10 +54,10 @@ public class TaxDeclarationController { @POST @Path("/listPage") @Produces(MediaType.APPLICATION_JSON) - public String list(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationListQueryParam queryParam) { + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationListQueryParam queryParam) throws ParseException { User user = HrmUserVarify.getUser(request, response); - queryParam.setFromSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getFromSalaryMonthStr())); - queryParam.setEndSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndSalaryMonthStr())); + queryParam.setFromSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getFromSalaryMonthStr()==null?"":queryParam.getFromSalaryMonthStr())); + queryParam.setEndSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndSalaryMonthStr()==null?"":queryParam.getEndSalaryMonthStr())); return new ResponseResult>().run(getTaxDeclarationWrapper(user)::listPage, queryParam); } @@ -85,13 +95,27 @@ public class TaxDeclarationController { return new ResponseResult().run(getTaxDeclarationDetailWrapper(user)::listPage, param); }*/ - // @PostMapping("/export") - // @ApiOperation("个税申报表相关信息") - // @WeaPermission - // public WeaResult> exportTaxDeclaration(@RequestParam(value = "taxDeclarationId") Long taxDeclarationId) { - // Map map = taxDeclarationExcelService.exportTaxDeclaration(taxDeclarationId, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(map); - // } + //个税申报表相关信息 + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "taxDeclarationId") Long taxDeclarationId) { + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getTaxDeclarationExcelService(user).exportTaxDeclaration(taxDeclarationId); + String fileName = "个税申报表"; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } } diff --git a/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java index 0fea8f8dd..08692a492 100644 --- a/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java +++ b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java @@ -27,14 +27,15 @@ import com.engine.salary.mapper.datacollection.AddUpSituationMapper; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; import com.engine.salary.service.*; -import com.engine.salary.service.impl.TaxAgentServiceImpl; -import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.service.impl.*; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.google.common.collect.Lists; +import com.google.j2objc.annotations.AutoreleasePool; +import com.weaverboot.frame.ioc.anno.fieldAnno.WeaAutowired; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -54,6 +55,9 @@ import java.util.stream.Collectors; @Component public class TaxDeclarationWrapper extends Service { + public TaxDeclarationWrapper() { + } + private TaxDeclarationService getTaxDeclarationService(User user) { return (TaxDeclarationService) ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); } @@ -69,11 +73,11 @@ public class TaxDeclarationWrapper extends Service { return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); } - @Resource - private TaxAgentBiz taxAgentBiz; +// @Resource + private TaxAgentBiz taxAgentBiz = new TaxAgentBiz(); @Resource private SalaryItemBiz salaryItemBiz; - @Resource + @WeaAutowired private TaxDeclarationDetailService taxDeclarationDetailService; @Resource private SalaryAcctResultService salaryAcctResultService; @@ -107,8 +111,8 @@ public class TaxDeclarationWrapper extends Service { List employeeComInfos = employBiz.getEmployeeByIdsAll(employeeIds); // 查询个税扣缴义务人 Set taxAgentIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getTaxAgentId); - List taxAgentPOS = taxAgentBiz.listByIds(taxAgentIds); - //List taxAgentPOS = getTaxDeclarationService(user).countByTaxDeclarationId(taxAgentIds); + //List taxAgentPOS = new TaxAgentBiz().listByIds(taxAgentIds); + List taxAgentPOS = getTaxDeclarationService(user).countByTaxDeclarationId(taxAgentIds); // 转换成列表dto List taxDeclarationListDTOS = TaxDeclarationBO.convert2ListDTO(list, employeeComInfos, taxAgentPOS); dtoPage.setList(taxDeclarationListDTOS); @@ -126,7 +130,7 @@ public class TaxDeclarationWrapper extends Service { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); } // 查询个税扣缴义务人 - TaxAgent taxAgent = taxAgentBiz.getById(id); + TaxAgent taxAgent = new TaxAgentBiz().getById(id); // 转换成个税申报表详情dto formDTO = TaxDeclarationFormDTO.builder() .salaryMonth(SalaryDateUtil.localDate2YearMonth(taxDeclaration.getSalaryMonth())) @@ -139,7 +143,7 @@ public class TaxDeclarationWrapper extends Service { // WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(TaxDeclarationFormDTO.class, formDTO); // 查询租户所有的个税扣缴义务人 - Collection taxAgentListDTOS = taxAgentBiz.listAll(); + Collection taxAgentListDTOS = new TaxAgentBiz().listAll(); // 表单中个税扣缴义务人的可选项 List weaFormOptions = Lists.newArrayListWithExpectedSize(taxAgentListDTOS.size()); for (TaxAgent taxAgent : taxAgentListDTOS) { @@ -172,7 +176,7 @@ public class TaxDeclarationWrapper extends Service { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); } // 查询个税扣缴义务人 - TaxAgent taxAgentPO = taxAgentBiz.getById(taxDeclaration.getTaxAgentId()); + TaxAgent taxAgentPO = new TaxAgentBiz().getById(taxDeclaration.getTaxAgentId()); return TaxDeclarationInfoDTO.builder() .salaryMonth(SalaryDateUtil.localDate2YearMonth(taxDeclaration.getSalaryMonth())) .taxAgentId(taxDeclaration.getTaxAgentId()) @@ -223,7 +227,7 @@ public class TaxDeclarationWrapper extends Service { } // 查询薪资核算结果 Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); - List salaryAcctResultPOS = salaryAcctResultService.listBySalaryAcctRecordIds(salaryAcctRecordIds); + List salaryAcctResultPOS = new SalaryAcctResultServiceImpl().listBySalaryAcctRecordIds(salaryAcctRecordIds); // 无薪资核算结果,不允许生成个税申报表 if (CollectionUtils.isEmpty(salaryAcctResultPOS)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据") @@ -231,24 +235,24 @@ public class TaxDeclarationWrapper extends Service { } // 查询薪资账套 Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); - List salarySobPOS = salarySobService.listByIds(salarySobIds); + List salarySobPOS = new SalarySobServiceImpl().listByIds(salarySobIds); //查询DataCollectionEmployee //DataCollectionEmployee employeeId = // 查询所有薪资项目 - List salaryItemPOS = salaryItemBiz.listAll(); + List salaryItemPOS = new SalaryItemBiz().listAll(); // 处理要保存的数据 TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, salaryItemPOS, salarySobPOS,salaryAcctResultPOS); // 保存个税申报表 if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) { - taxDeclarationMapper.batchInsert(result.getNeedInsertTaxDeclarations()); + getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations()); } // 保存个税申报表明细 if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) { - taxDeclarationDetailService.batchSave(result.getNeedInsertTaxDeclarationDetails()); + new TaxDeclarationDetailServiceImpl().batchSave(result.getNeedInsertTaxDeclarationDetails()); } // 保存累计情况 if (CollectionUtils.isNotEmpty(result.getNeedInsertAccumulatedSituations())) { @@ -256,10 +260,10 @@ public class TaxDeclarationWrapper extends Service { // addUpSituationMapper.insertData(Lists.newArrayList(result.getNeedInsertAccumulatedSituations())); } // 更新薪资核算记录的状态 - salaryAcctRecordService.updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED); + new SalaryAcctRecordServiceImpl().updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED); // 查询个税扣缴义务人 Set taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId); - List taxAgentPOS = taxAgentBiz.listByIds(taxAgentIds); + List taxAgentPOS = new TaxAgentBiz().listByIds(taxAgentIds); Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgent::getId, TaxAgent::getName); // 记录日志 /*for (TaxDeclarationPO taxDeclarationPO : result.getNeedInsertTaxDeclarations()) { From 545e8f5b7a9ba8951cca6c933bfcedf6339bf063 Mon Sep 17 00:00:00 2001 From: "18895359881@163.com" <521027xyz> Date: Mon, 18 Apr 2022 19:50:28 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AFSQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taxdeclaration/TaxDeclarationDetailMapper.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml index 352256066..a7546ebbb 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml @@ -59,7 +59,17 @@ From 651df1842e74e2aa4553533d67f8b1a3e0c58c14 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 18 Apr 2022 20:24:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/biz/SIAccountBiz.java | 167 ++++++ .../dto/InsuranceAccountViewListDTO.java | 24 +- .../siexport/param/InsuranceExportParam.java | 25 + .../entity/siexport/po/AccountExportPO.java | 53 ++ .../salary/mapper/InsuranceExportMapper.java | 18 + .../salary/mapper/InsuranceExportMapper.xml | 34 ++ .../InsuranceAccountDetailMapper.xml | 3 +- .../salary/service/SIAccountService.java | 30 ++ .../salary/service/SIExportService.java | 28 ++ .../salary/service/SISchemeService.java | 6 + .../service/impl/SIAccountServiceImpl.java | 91 +++- .../service/impl/SIExportServiceImpl.java | 474 ++++++++++++++++++ .../service/impl/SISchemeServiceImpl.java | 16 + .../salary/util/SalaryFormItemUtil.java | 24 + .../salary/web/SIAccountController.java | 51 +- .../engine/salary/web/SIExportController.java | 112 +++++ .../salary/wrapper/SIAccountWrapper.java | 31 ++ 17 files changed, 1157 insertions(+), 30 deletions(-) create mode 100644 src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java create mode 100644 src/com/engine/salary/entity/siexport/po/AccountExportPO.java create mode 100644 src/com/engine/salary/mapper/InsuranceExportMapper.java create mode 100644 src/com/engine/salary/mapper/InsuranceExportMapper.xml create mode 100644 src/com/engine/salary/service/SIExportService.java create mode 100644 src/com/engine/salary/service/impl/SIExportServiceImpl.java create mode 100644 src/com/engine/salary/web/SIExportController.java create mode 100644 src/com/engine/salary/wrapper/SIAccountWrapper.java diff --git a/src/com/engine/salary/biz/SIAccountBiz.java b/src/com/engine/salary/biz/SIAccountBiz.java index 3fe2a0ef3..d9520b0bd 100644 --- a/src/com/engine/salary/biz/SIAccountBiz.java +++ b/src/com/engine/salary/biz/SIAccountBiz.java @@ -6,6 +6,8 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO; +import com.engine.salary.entity.salaryarchive.po.TaxAgentPO; +import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.param.*; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; @@ -14,9 +16,11 @@ import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; import com.engine.salary.entity.siarchives.po.*; import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.taxrate.TaxAgent; import com.engine.salary.enums.siaccount.*; import com.engine.salary.enums.sicategory.*; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.TaxAgentMapper; import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; @@ -1303,7 +1307,170 @@ public class SIAccountBiz { } + public PageInfo overView(InsuranceAccountDetailParam queryParam) { + PageUtil.start(queryParam.getCurrent(),queryParam.getPageSize()); + List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(queryParam.getBillMonth()); + + //获取扣缴义务人信息 + List paymentList = MapperProxyFactory.getProxy(TaxAgentMapper.class).listAll(); + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel( 100341, "该租户无扣缴义务人")); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgent::getId, Function.identity())); + List insuranceAccountViewListDTOS = buildRecords(insuranceAccountDetailPOS, paymentMap); + +// List iCategoryPOS = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll(); +// Page page = FormatManager.getTablePage(); +// Page insuranceAccountViewListDTOPage = new Page<>(page.getCurrent(), insuranceAccountViewListDTOS.size(), insuranceAccountViewListDTOS.size(), +// page.isSearchCount()); + + PageInfo insuranceAccountViewListDTOPage = new PageInfo<>(insuranceAccountViewListDTOS,InsuranceAccountViewListDTO.class); + insuranceAccountViewListDTOPage.setTotal(insuranceAccountViewListDTOS.size()); + return insuranceAccountViewListDTOPage; + } + + public List buildRecords(List list, Map paymentMap) { + Map result = new HashMap<>(); + //根据组织分组,对社保进行统计 + Map> socialCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + socialCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountSocialView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对公积金进行统计 + Map> fundCollect = list.stream().filter(item -> item.getFundPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getFundPayOrg)); + fundCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountFundView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对其他福利进行统计 + Map> otherCollect = list.stream().filter(item -> item.getOtherPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getOtherPayOrg)); + otherCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountOtherView(insuranceAccountViewListDTO, v); + }); + //对各组织进行金额合计 + List viewDTOS = new ArrayList<>(); + result.forEach((k, v) -> { + BigDecimal socialPaySum = StringUtils.isBlank(v.getSocialPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getSocialPaySum()); + BigDecimal fundPaySum = StringUtils.isBlank(v.getFundPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getFundPaySum()); + BigDecimal otherPaySum = StringUtils.isBlank(v.getOtherPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getOtherPaySum()); + v.setIndex(k); + BigDecimal sum = socialPaySum.add(fundPaySum).add(otherPaySum); + v.setSum(sum.toPlainString()); + viewDTOS.add(v); + }); + //合计 + InsuranceAccountViewListDTO insuranceAccountViewListDTO = new InsuranceAccountViewListDTO(); + int socialNum = 0; + int fundNum = 0; + int otherNum = 0; + BigDecimal socialSum = new BigDecimal("0"); + BigDecimal fundSum = new BigDecimal("0"); + BigDecimal otherSum = new BigDecimal("0"); + BigDecimal sum = new BigDecimal("0"); + for (InsuranceAccountViewListDTO item : viewDTOS) { + if (item.getSocialNum() != null) { + socialNum += item.getSocialNum(); + } + if (item.getFundNum() != null) { + fundNum += item.getFundNum(); + } + if (item.getOtherNum() != null) { + otherNum += item.getOtherNum(); + } + if (StringUtils.isNotBlank(item.getSocialPaySum())) { + socialSum = socialSum.add(new BigDecimal(item.getSocialPaySum())); + } + if (StringUtils.isNotBlank(item.getFundPaySum())) { + fundSum = fundSum.add(new BigDecimal(item.getFundPaySum())); + } + if (StringUtils.isNotBlank(item.getOtherPaySum())) { + otherSum = otherSum.add(new BigDecimal(item.getOtherPaySum())); + } + if (StringUtils.isNotBlank(item.getSum())) { + sum = sum.add(new BigDecimal(item.getSum())); + } + } + insuranceAccountViewListDTO.setSum(sum.toPlainString()); + insuranceAccountViewListDTO.setSocialPaySum(socialSum.toPlainString()); + insuranceAccountViewListDTO.setPayOrg(SalaryI18nUtil.getI18nLabel(93278, "合计")); + insuranceAccountViewListDTO.setFundPaySum(fundSum.toPlainString()); + insuranceAccountViewListDTO.setOtherPaySum(otherSum.toPlainString()); + insuranceAccountViewListDTO.setSocialNum(socialNum); + insuranceAccountViewListDTO.setFundNum(fundNum); + insuranceAccountViewListDTO.setOtherNum(otherNum); + viewDTOS.add(insuranceAccountViewListDTO); + viewDTOS.forEach(e -> { + e.setSocialPaySum(StringUtils.isBlank(e.getSocialPaySum()) ? "0" : e.getSocialPaySum()); + e.setSocialNum(e.getSocialNum() == null ? 0 : e.getSocialNum()); + e.setFundNum(e.getFundNum() == null ? 0 : e.getFundNum()); + e.setFundPaySum(StringUtils.isBlank(e.getFundPaySum()) ? "0" : e.getFundPaySum()); + e.setOtherPaySum(StringUtils.isBlank(e.getOtherPaySum()) ? "0" : e.getOtherPaySum()); + e.setOtherNum(e.getOtherNum() == null ? 0 : e.getOtherNum()); + e.setSum(SalaryEntityUtil.thousandthConvert(e.getSum())); + e.setSocialPaySum(SalaryEntityUtil.thousandthConvert(e.getSocialPaySum())); + e.setOtherPaySum(SalaryEntityUtil.thousandthConvert(e.getOtherPaySum())); + e.setFundPaySum(SalaryEntityUtil.thousandthConvert(e.getFundPaySum())); + }); + return viewDTOS; + } + + public void accountOtherView(InsuranceAccountViewListDTO dto, List pos) { + int otherNum = 0; + BigDecimal otherPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getOtherSum())) { + otherNum += 1; + otherPaySum = otherPaySum.add(new BigDecimal(item.getOtherSum())); + } + } + dto.setOtherNum(otherNum); + dto.setOtherPaySum(otherPaySum.toPlainString()); + } + + public void accountFundView(InsuranceAccountViewListDTO dto, List pos) { + int fundNum = 0; + BigDecimal fundPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getFundSum())) { + fundNum += 1; + fundPaySum = fundPaySum.add(new BigDecimal(item.getFundSum())); + } + } + dto.setFundNum(fundNum); + dto.setFundPaySum(fundPaySum.toPlainString()); + } + + public void accountSocialView(InsuranceAccountViewListDTO dto, List pos) { + int socialNum = 0; + BigDecimal socialPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getSocialSum())) { + socialNum += 1; + socialPaySum = socialPaySum.add(new BigDecimal(item.getSocialSum())); + } + } + dto.setSocialNum(socialNum); + dto.setSocialPaySum(socialPaySum.toPlainString()); + } } diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java index 069e739c8..95cdf9fd3 100644 --- a/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java @@ -1,6 +1,10 @@ package com.engine.salary.entity.siaccount.dto; +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -16,32 +20,34 @@ import lombok.NoArgsConstructor; @Builder @NoArgsConstructor @AllArgsConstructor +@SalaryTable(pageId = "b3afad76-a971-4fe3-8064-0cabdcb10b18", tableType = WeaTableType.NONE,operates = { +}) public class InsuranceAccountViewListDTO { - //"序号") + @TableTitle(title = "序号", dataIndex = "index", key = "index") private Long index; - //缴纳组织") + @TableTitle(title = "缴纳组织", dataIndex = "payOrg", key = "payOrg") private String payOrg; - //社保人数") + @TableTitle(title = "社保人数", dataIndex = "socialNum", key = "socialNum") private Integer socialNum; - //公积金人数") + @TableTitle(title = "公积金人数", dataIndex = "fundNum", key = "fundNum") private Integer fundNum; - //其他福利人数") + @TableTitle(title = "其他福利人数", dataIndex = "otherNum", key = "otherNum") private Integer otherNum; - //社保缴费合计") + @TableTitle(title = "社保缴费合计", dataIndex = "socialPaySum", key = "socialPaySum") private String socialPaySum; - //公积金缴费合计") + @TableTitle(title = "公积金缴费合计", dataIndex = "fundPaySum", key = "fundPaySum") private String fundPaySum; - //其他福利缴费合计") + @TableTitle(title = "其他福利缴费合计", dataIndex = "otherPaySum", key = "otherPaySum") private String otherPaySum; - //合计") + @TableTitle(title = "合计", dataIndex = "sum", key = "sum") private String sum; } diff --git a/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java b/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java new file mode 100644 index 000000000..0e199aaae --- /dev/null +++ b/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.siexport.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * @Author weaver_cl + * @Description: TODO 导出 + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceExportParam { + + //@NotBlank + @DataCheck(require = true,message = "账单月份不可为空") + private String billMonth; +} diff --git a/src/com/engine/salary/entity/siexport/po/AccountExportPO.java b/src/com/engine/salary/entity/siexport/po/AccountExportPO.java new file mode 100644 index 000000000..815f85e69 --- /dev/null +++ b/src/com/engine/salary/entity/siexport/po/AccountExportPO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.siexport.po; + +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.enums.UserStatusEnum; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/7 + * @Version V1.0 + **/ +public class AccountExportPO extends InsuranceAccountDetailPO { + + private String userName; + + private String telephone; + + private String departmentName; + + private UserStatusEnum userStatus; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getDepartmentName() { + return departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public UserStatusEnum getUserStatus() { + return userStatus; + } + + public void setUserStatus(UserStatusEnum userStatus) { + this.userStatus = userStatus; + } +} diff --git a/src/com/engine/salary/mapper/InsuranceExportMapper.java b/src/com/engine/salary/mapper/InsuranceExportMapper.java new file mode 100644 index 000000000..97caecf4f --- /dev/null +++ b/src/com/engine/salary/mapper/InsuranceExportMapper.java @@ -0,0 +1,18 @@ +package com.engine.salary.mapper; + +import com.engine.salary.entity.siexport.po.AccountExportPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/18 + * @Version V1.0 + **/ +public interface InsuranceExportMapper { + + List exportAccount(@Param("paymentStatus") Integer paymentStatus, @Param("billMonth") String billMonth); + +} diff --git a/src/com/engine/salary/mapper/InsuranceExportMapper.xml b/src/com/engine/salary/mapper/InsuranceExportMapper.xml new file mode 100644 index 000000000..868c05d33 --- /dev/null +++ b/src/com/engine/salary/mapper/InsuranceExportMapper.xml @@ -0,0 +1,34 @@ + + + + + + + diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml index 132b4035a..c58e7521b 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml @@ -124,7 +124,8 @@