diff --git a/src/com/engine/salary/biz/SalarySendRangeObjBiz.java b/src/com/engine/salary/biz/SalarySendRangeObjBiz.java index 05ccaaadb..53633dce6 100644 --- a/src/com/engine/salary/biz/SalarySendRangeObjBiz.java +++ b/src/com/engine/salary/biz/SalarySendRangeObjBiz.java @@ -7,6 +7,8 @@ import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeTaxAgentDTO; import com.engine.salary.mapper.salarybill.SalarySendRangeObjMapper; import com.engine.salary.service.TaxAgentService; import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; @@ -23,6 +25,10 @@ public class SalarySendRangeObjBiz { return ServiceUtil.getService(TaxAgentServiceImpl.class); } + private SalarySendRangeObjMapper getSalarySendRangeObjMapper() { + return MapperProxyFactory.getProxy(SalarySendRangeObjMapper.class); + } + public R applyMapper(Function mapper) { try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { final SalarySendRangeObjMapper salarySendRangeObjMapper = sqlSession.getMapper(SalarySendRangeObjMapper.class); @@ -41,7 +47,13 @@ public class SalarySendRangeObjBiz { } public List getSalarySendUserInfoDTOs(List employees) { - List userDTOs = applyMapper(mapper -> mapper.getUserInfoByEmployeeIds(employees)); + List userDTOs = new ArrayList<>(); + List> partition = Lists.partition(employees, 500); + partition.forEach(l->{ + List userInfos = getSalarySendRangeObjMapper().getUserInfoByEmployeeIds(l); + userDTOs.addAll(userInfos); + }); + Map userMap = userDTOs.stream() .collect(Collectors.toMap(SalarySendUserInfoDTO::getResourceId, Function.identity())); diff --git a/src/com/engine/salary/entity/employeedeclare/bo/EmployeeDeclareRequest.java b/src/com/engine/salary/entity/employeedeclare/bo/EmployeeDeclareRequest.java index 5527df49e..d45c35b79 100644 --- a/src/com/engine/salary/entity/employeedeclare/bo/EmployeeDeclareRequest.java +++ b/src/com/engine/salary/entity/employeedeclare/bo/EmployeeDeclareRequest.java @@ -62,6 +62,11 @@ public class EmployeeDeclareRequest { // *任职受雇类型 EmploymentTypeEnum employmentTypeEnum = SalaryEnumUtil.enumMatchByValue(employeeDeclare.getEmploymentType(), EmploymentTypeEnum.class); employeeInfoMap.put("sfgy", employmentTypeEnum == null ? "" : employmentTypeEnum.getDefaultLabel()); + //其他情况说明“qtqksm”,有3个选择的值,可选择"扣缴申报利息股息红利所得”、“扣缴申报偶然所得”、”申报其他所得” + //一般劳务所得处理,可以统一用”申报其他所得”作为默认就好 + if (employmentTypeEnum == EmploymentTypeEnum.OTHER) { + employeeInfoMap.put("qtqksm", "申报其他所得"); + } // 入职年度就业情形 employeeInfoMap.put("rzndjyqk", employeeDeclare.getEmploymentFirstYear()); // *手机号码 diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java index 2ccd45402..5bf8a8277 100644 --- a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java +++ b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java @@ -267,7 +267,7 @@ public class SalaryBillBO { } Util_Message.store(messageBean); } catch (IOException e) { - log.error("消息发送失败",e); + log.error("消息发送失败", e); } } @@ -649,7 +649,8 @@ public class SalaryBillBO { } else { for (Object keyName : e.keySet()) { if ((salaryItem.getId() + SalaryArchiveConstant.DYNAMIC_SUFFIX).equals(keyName.toString())) { - boolean isHide = (isHideNull && StringUtils.isEmpty(e.getOrDefault(keyName.toString(), StringUtils.EMPTY).toString())) + String itemValue = Util.null2String(e.get(keyName.toString())); + boolean isHide = (isHideNull && StringUtils.isEmpty(itemValue)) || (isHideZero && NumberUtils.isCreatable(e.getOrDefault(keyName.toString(), "0").toString()) && BigDecimal.ZERO.compareTo(new BigDecimal(e.getOrDefault(keyName.toString(), "0").toString())) == 0); @@ -660,7 +661,7 @@ public class SalaryBillBO { emailContent.append(""); emailContent.append(""); - emailContent.append(e.get(keyName.toString())); + emailContent.append(itemValue.replaceAll("null", "")); emailContent.append(""); } break; @@ -729,7 +730,8 @@ public class SalaryBillBO { SalaryTemplateSalaryItemListDTO salaryItem = itemPartition.get(i); for (Object keyName : e.keySet()) { if ((salaryItem.getId() + SalaryArchiveConstant.DYNAMIC_SUFFIX).equals(keyName.toString())) { - boolean isHide = (isHideNull && StringUtils.isEmpty(e.getOrDefault(keyName.toString(), StringUtils.EMPTY).toString())) + String itemValue = Util.null2String(e.get(keyName.toString())); + boolean isHide = (isHideNull && StringUtils.isEmpty(itemValue)) || (isHideZero && NumberUtils.isCreatable(e.getOrDefault(keyName.toString(), "0").toString()) && BigDecimal.ZERO.compareTo(new BigDecimal(e.getOrDefault(keyName.toString(), "0").toString())) == 0); @@ -740,7 +742,7 @@ public class SalaryBillBO { emailContent.append(""); emailContent.append(""); - emailContent.append(e.get(keyName.toString())); + emailContent.append(itemValue.replaceAll("null", "")); emailContent.append(""); } break; diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java index d5155f0ae..d5399daab 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.salaryacct.bo; +import cn.hutool.core.util.StrUtil; import com.engine.salary.constant.TaxDeclarationDataIndexConstant; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; @@ -73,6 +74,9 @@ public class SalaryAcctConsolidatedTaxBO { .filter(e -> Objects.equals(e.getSalaryItemId(), optional.get())) .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) .reduce(BigDecimal.ZERO, BigDecimal::add); + if (StrUtil.isBlank(resultValue)) { + resultValue = "0.00"; + } return new BigDecimal(resultValue).add(income).toPlainString(); } // 个税调差为0 @@ -98,6 +102,9 @@ public class SalaryAcctConsolidatedTaxBO { .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) .reduce(BigDecimal.ZERO, BigDecimal::add); } + if (StrUtil.isBlank(resultValue)) { + resultValue = "0.00"; + } return new BigDecimal(resultValue).add(refundedOrSupplementedTax).subtract(taxAdjustment).toPlainString(); } return resultValue; diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java index 52c3b7f13..d07b79a6b 100644 --- a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java @@ -20,7 +20,7 @@ import java.util.Collection; @Builder @NoArgsConstructor @AllArgsConstructor -public class SalaryAcctCalculateParam { +public class SalaryAcctCalculateParam { //核算人员的id,不是employeeId而是salaryAcctEmpId private Collection ids; diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java index b737f857e..8424aa765 100644 --- a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.time.YearMonth; +import java.util.List; /** * 薪资核算列表查询参数 @@ -31,6 +32,11 @@ public class SalaryAcctRecordQueryParam extends BaseQueryParam { //账套名称") private String name; + /** + * 扣缴义务人id集合 + */ + private List taxAgentIds; + private String startMonthStr; private String endMonthStr; } diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java index 8432faa61..495e4635b 100644 --- a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java @@ -75,6 +75,7 @@ public class TaxDeclarationRequest { } else if (incomeCategoryEnum == IncomeCategoryEnum.COMPENSATION_FOR_DISMISS) { // 解除劳动合同一次性补偿金 List> employeeRequestParams = listRequestParam.computeIfAbsent("jcldhtycxbcjlb", k -> Lists.newArrayList()); + employeeRequestParam.put("sfzdscmsfb","是"); employeeRequestParams.add(employeeRequestParam); } else if (incomeCategoryEnum == IncomeCategoryEnum.INCOME_FOR_INDIVIDUAL_EQUITY_INCENTIVE) { // 个人股权激励收入 @@ -125,6 +126,7 @@ public class TaxDeclarationRequest { } else if (incomeCategoryEnum == IncomeCategoryEnum.REMUNERATION_FOR_AUTHOR) { // 稿酬所得 List> employeeRequestParams = listRequestParam.computeIfAbsent("gcsdlb", k -> Lists.newArrayList()); + employeeRequestParam.put("sfzdscmsfb","是"); employeeRequestParams.add(employeeRequestParam); } else if (incomeCategoryEnum == IncomeCategoryEnum.ROYALTIES) { // 特许权使用费所得 @@ -167,9 +169,6 @@ public class TaxDeclarationRequest { } } - String string = employeeRequestParam.getOrDefault("syjkbx", "0").toString(); - System.out.println(); - if (new BigDecimal(employeeRequestParam.getOrDefault("syjkbx", "0").toString()).compareTo(new BigDecimal("0")) > 0) { Map healthInsuranceMap = taxFreeMap.get(TaxFreeTypeEnum.HEALTH_INSURANCE); List pos = (List) healthInsuranceMap.get(employeeDeclare.getTaxAgentId() + "-" + employeeDeclare.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(employeeDeclare.getTaxCycle())); diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java index f52ce6a86..420daca25 100644 --- a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java @@ -37,6 +37,10 @@ public class TaxDeclarationListDTO { @TableTitle(title = "薪资类型", dataIndex = "incomeCategory", key = "incomeCategory") private String incomeCategory; + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") + private Date taxCycle; + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") @TableTitle(title = "薪资所属月", dataIndex = "salaryMonth", key = "salaryMonth") private Date salaryMonth; @@ -47,10 +51,6 @@ public class TaxDeclarationListDTO { @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") private String taxAgentName; - @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") - @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") - private Date taxCycle; - //@TableTitle(title = "操作人id", dataIndex = "operateEmployeeId", key = "operateEmployeeId") private Long operateEmployeeId; diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java index 83f65672c..a7de714a9 100644 --- a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java @@ -7,6 +7,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; + import java.util.Date; /** diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java index 101b6dd52..6d696e243 100644 --- a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java @@ -100,6 +100,13 @@ public class TaxDeclarationPO { LocalDateRange salaryMonths; + //"开始日期 + private Date taxCycleFromDate; + + //结束日期 + private Date taxCycleEndDate; + + /** * 税款所属期 */ diff --git a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java index 83892cf9a..504e7d3d7 100644 --- a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java +++ b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java @@ -711,7 +711,7 @@ public enum IncomeCategoryEnum implements BaseEnum { } List rysbsblb = feedbackResponse.getBody().getRysbsblb(); if (CollectionUtil.isNotEmpty(rysbsblb)) { - String err = rysbsblb.stream().map(GetASynIndividualIncomeTaxFeedbackResponse.Body.rysbsb::getSbyy).collect(Collectors.joining(";")); + String err = rysbsblb.stream().map(sb -> Util.null2String(sb.getXm()) + Util.null2String(sb.getSbyy())).collect(Collectors.joining(";")); throw new OnlineCalculateTaxException(err); } } diff --git a/src/com/engine/salary/formlua/func/date/DateTimeServiceImpl.java b/src/com/engine/salary/formlua/func/date/DateTimeServiceImpl.java index 5f2ffedd0..d081615e5 100644 --- a/src/com/engine/salary/formlua/func/date/DateTimeServiceImpl.java +++ b/src/com/engine/salary/formlua/func/date/DateTimeServiceImpl.java @@ -571,7 +571,6 @@ public class DateTimeServiceImpl implements DateTimeService { cale.set(cale.get(Calendar.YEAR), month, 1); String lastday = formatTemp.format(cale.getTime()); - System.out.println(lastday); return new DataType(DataType.STRING, lastday); } diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml index 3b84589f3..3b12becbf 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml @@ -69,6 +69,12 @@ AND tax_cycle #{taxMonths.endDate} + + AND tax_cycle = ]]> #{taxCycleFromDate} + + + AND tax_cycle #{taxCycleEndDate} + AND tax_agent_id IN diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java index d0afd0c00..0d8303b72 100644 --- a/src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java @@ -45,6 +45,9 @@ public class SalaryStatisticsDataPerspectiveQueryParam extends BaseQueryParam { //个税扣缴义务人配置 private List taxAgent; + @JsonIgnore + private List salarySob; + @JsonIgnore //收入所得项目配置 private List incomeCategory; diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index 2b62276cd..dbf64ecb8 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -469,12 +469,21 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary if (reportPO.getTaxAgentSetting() != null) { param.setTaxAgent(((List) JSON.parseArray(reportPO.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); } + if (reportPO.getSalarySobSetting() != null) { + param.setSalarySob(((List) JSON.parseArray(reportPO.getSalarySobSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } if (reportPO.getSubCompanySetting() != null) { param.setSubCompany(((List) JSON.parseArray(reportPO.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); } if (reportPO.getDepartSetting() != null) { param.setDepart(((List) JSON.parseArray(reportPO.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); } + if (reportPO.getPositionSetting() != null) { + param.setPosition(((List) JSON.parseArray(reportPO.getPositionSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (reportPO.getStatusSetting() != null) { + param.setStatus(((List) JSON.parseArray(reportPO.getStatusSetting(), Map.class)).stream().map(m -> m.get(key).toString()).collect(Collectors.toList())); + } if (reportPO.getEmployeeSetting() != null) { param.setEmployee(((List) JSON.parseArray(reportPO.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); } diff --git a/src/com/engine/salary/service/impl/EmployeeDeclareExcelServiceImpl.java b/src/com/engine/salary/service/impl/EmployeeDeclareExcelServiceImpl.java index 8385d54c4..81f4bf29b 100644 --- a/src/com/engine/salary/service/impl/EmployeeDeclareExcelServiceImpl.java +++ b/src/com/engine/salary/service/impl/EmployeeDeclareExcelServiceImpl.java @@ -642,10 +642,14 @@ public class EmployeeDeclareExcelServiceImpl extends Service implements Employee Set emptyNames = new HashSet<>(); for (PropertyDescriptor pd : pds) { - Object srcValue = src.getPropertyValue(pd.getName()); + String name = pd.getName(); + if("dismissDate".equals(name)){ + continue; + } + Object srcValue = src.getPropertyValue(name); // 此处判断可根据需求修改 if (srcValue == null) { - emptyNames.add(pd.getName()); + emptyNames.add(name); } } String[] result = new String[emptyNames.size()]; diff --git a/src/com/engine/salary/service/impl/EmployeeDeclareServiceImpl.java b/src/com/engine/salary/service/impl/EmployeeDeclareServiceImpl.java index 956094d91..57a987063 100644 --- a/src/com/engine/salary/service/impl/EmployeeDeclareServiceImpl.java +++ b/src/com/engine/salary/service/impl/EmployeeDeclareServiceImpl.java @@ -703,6 +703,7 @@ public class EmployeeDeclareServiceImpl extends Service implements EmployeeDecla ImmutableMap requestParam = ImmutableMap.of("requestId", employeeDeclareRecord.getRequestId()); Map header = SingnatureData.initHeader(Collections.emptyMap(), apiConfig.getAppKey(), apiConfig.getAppSecret()); String res = HttpUtil.getRequest(url, header, requestParam); + log.info("人员报送反馈:{}", res); DeclareEmployeeFeedbackResponse declareEmployeeFeedbackResponse = JsonUtil.parseObject(res, DeclareEmployeeFeedbackResponse.class); if (Objects.isNull(declareEmployeeFeedbackResponse) || Objects.isNull(declareEmployeeFeedbackResponse.getHead())) { log.error("服务异常:" + res); diff --git a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java index 79f3ee877..39d4116b7 100644 --- a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java @@ -172,7 +172,8 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); List canAccountIds = baseInfoPOList.stream() .filter(f->f.getPaymentOrganization().toString().equals(queryParam.getPaymentOrganization()) - && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) + && !f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue()) + ) .map(InsuranceArchivesBaseInfoPO::getEmployeeId) .collect(Collectors.toList()); accountExportPOS = accountExportPOS.stream().filter(v -> canAccountIds.contains(v.getEmployeeId())).collect(Collectors.toList()); diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 8ca265c6b..da7684470 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.salary.service.impl; +import cn.hutool.core.collection.CollUtil; import com.api.formmode.mybatis.util.SqlProxyHandle; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; @@ -198,6 +199,21 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); po.setSalarySobIds(salarySobIds); } + if (CollUtil.isNotEmpty(queryParam.getTaxAgentIds())) { + List salarySobPOS = getSalarySobService(user).listByTaxAgentIds(queryParam.getTaxAgentIds()); + if (CollectionUtils.isEmpty(salarySobPOS)) { + return page; + } + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + + Collection existIds = po.getSalarySobIds(); + if (CollectionUtils.isNotEmpty(existIds)) { + existIds = SalaryEntityUtil.intersectionForList(existIds, salarySobIds); + po.setSalarySobIds(existIds); + } else { + po.setSalarySobIds(salarySobIds); + } + } LocalDateRange localDateRange = new LocalDateRange(); if (Objects.nonNull(queryParam.getStartMonth())) { localDateRange.setFromDate(SalaryDateUtil.localDateToDate(queryParam.getStartMonth().atDay(1))); @@ -520,6 +536,12 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe */ @Override public void checkBeforeSave(SalaryAcctRecordPO salaryAcctRecord, List salaryAcctTaxAgents) { + // 如果个税申报功能是关闭的,则不需要检查 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + if (taxDeclarationFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) { + return; + } + // 查询薪资账套 SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecord.getSalarySobId()); IncomeCategoryEnum incomeCategoryEnums = IncomeCategoryEnum.parseByValue(salarySobPO.getIncomeCategory()); @@ -1014,6 +1036,6 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe @Override public void updateDate(Long id, Date updateTime) { - getSalaryAcctRecordMapper().updateDate(id,updateTime); + getSalaryAcctRecordMapper().updateDate(id, updateTime); } } diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java index a308120e2..ac1fe75d9 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -1576,7 +1576,12 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe if (CollectionUtils.isEmpty(employeeIds)) { return Collections.emptyList(); } - return getSalaryArchiveMapper().listPayEndDateIsNull(employeeIds); + List> partition = Lists.partition(employeeIds, 500); + List resultList = new ArrayList<>(); + partition.forEach(part -> { + resultList.addAll(getSalaryArchiveMapper().listPayEndDateIsNull(part)); + }); + return resultList; } @Override public Map getAzRyflInfo(List employeeIds) { diff --git a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java index 4df8aa8f2..8928680cb 100644 --- a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java @@ -169,16 +169,6 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService && Optional.ofNullable(salaryBillProgress.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(136104, "有其他人员正在发送中,请等待其他人员发送结束后再操作")); } - // 初始化进度 - ProgressDTO initProgress = ProgressDTO.builder() - .title(SalaryI18nUtil.getI18nLabel(136097, "发送中")) - .totalQuantity(NumberUtils.INTEGER_ZERO) - .calculatedQuantity(NumberUtils.INTEGER_ZERO) - .progress(BigDecimal.ZERO) - .status(true) - .message("") - .build(); - getProgressService(user).initProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), initProgress); List ids = param.getIds(); @@ -190,6 +180,17 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService throw new SalaryRunTimeException("工资发放范围内没有匹配员工"); } } + // 初始化进度 + ProgressDTO initProgress = ProgressDTO.builder() + .title(SalaryI18nUtil.getI18nLabel(136097, "发送中")) + .totalQuantity(NumberUtils.INTEGER_ZERO) + .calculatedQuantity(NumberUtils.INTEGER_ZERO) + .progress(BigDecimal.ZERO) + .status(true) + .message("") + .build(); + getProgressService(user).initProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), initProgress); + // 异步执行 List finalIds = ids; LocalRunnable localRunnable = new LocalRunnable() { diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 30662220c..af9f51f1e 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -485,6 +485,11 @@ public class SalarySendServiceImpl extends Service implements SalarySendService if (salarySendInfo == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在")); } + + if (!Objects.equals(salarySendInfo.getSendStatus(), 1)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在")); + } + Long employeeId = salarySendInfo.getEmployeeId(); if (currentEmployeeId.compareTo(employeeId) != 0) { @@ -1343,7 +1348,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService } - @Override public Map withdraw(SalarySendWithdrawParam param) { if (param.getSalarySendId() == null) { diff --git a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java index 781c99af5..3e4d548b5 100644 --- a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java @@ -9,20 +9,29 @@ import com.engine.salary.biz.SalarySobItemGroupBiz; import com.engine.salary.biz.SalarySobItemHideBiz; import com.engine.salary.config.SalaryElogConfig; import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.salaryacct.bo.CalculateFormulaVarBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; -import com.engine.salary.entity.salaryarchive.config.ArchiveFieldConfig; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; import com.engine.salary.entity.salaryformula.ExpressFormula; -import com.engine.salary.entity.salaryformula.po.FormulaVar; import com.engine.salary.entity.salaryformula.config.FormluaConfig; import com.engine.salary.entity.salaryformula.po.FormulaPO; import com.engine.salary.entity.salaryformula.po.FormulaVar; -import com.engine.salary.entity.salaryitem.config.SalaryItemAllConfig; -import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; import com.engine.salary.entity.salarysob.dto.SalaryItemTopologyDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemFormDTO; import com.engine.salary.entity.salarysob.param.SalaryItemTopologyQueryParam; @@ -46,11 +55,13 @@ import com.engine.salary.util.valid.ValidUtil; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import weaver.general.BaseBean; import weaver.hrm.User; +import java.time.Month; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -121,6 +132,59 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe } // private LoggerTemplate salarySobLoggerTemplate; + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private AttendQuoteFieldService getAttendQuoteFieldService(User user) { + return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + + private VariableItemService getVariableItemService(User user) { + return ServiceUtil.getService(VariableItemServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private AddUpSituationService getAddUpSituationService(User user) { + return ServiceUtil.getService(AddUpSituationServiceImpl.class, user); + } + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private OtherDeductionService getOtherDeductionService(User user) { + return ServiceUtil.getService(OtherDeductionServiceImpl.class, user); + } + + private AttendQuoteDataService getAttendQuoteDataService(User user) { + return ServiceUtil.getService(AttendQuoteDataServiceImpl.class, user); + } + + private VariableArchiveService getVariableArchiveService(User user) { + return ServiceUtil.getService(VariableArchiveServiceImpl.class, user); + } + + @Override public List list() { return salarySobItemMapper.listAll(); @@ -629,7 +693,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe } salarySobItemPO.setFormula(formulaPO); } - if(SalaryEntityUtil.isNotNullOrEmpty(salarySobItemPO.getSalaryItemId())){ + if (SalaryEntityUtil.isNotNullOrEmpty(salarySobItemPO.getSalaryItemId())) { SalaryItemPO salaryItemPO = itemIdMap.get(salarySobItemPO.getSalaryItemId()); salarySobItemPO.setSalaryItem(salaryItemPO); } @@ -677,7 +741,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe salarySobItemFormDTO .setId(salarySobItemPO.getId()) .setName(salaryItemPO.getName()) - .setItemHide(salarySobItemPO.getItemHide()==null?0:Integer.parseInt(salarySobItemPO.getItemHide().toString())) + .setItemHide(salarySobItemPO.getItemHide() == null ? 0 : Integer.parseInt(salarySobItemPO.getItemHide().toString())) .setDataType(salaryItemPO.getDataType()) .setRoundingMode(salarySobItemPO.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : salarySobItemPO.getRoundingMode()) .setPattern(salarySobItemPO.getPattern() == null ? salaryItemPO.getPattern() : salarySobItemPO.getPattern()) @@ -726,7 +790,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe salaryItemTopologyDTO.setSalaryItemId(salaryItemPO.getId()); salaryItemTopologyDTO.setSalaryItemName(salaryItemPO.getName()); salaryItemTopologyDTO.setFormula(expressFormula); - salaryItemTopologyDTO.setResult(topologyData.getResultItemMap().getOrDefault(salaryItemPO.getId(), "")); + salaryItemTopologyDTO.setResult(topologyData.getResultItemMap().getOrDefault(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() + "_" + salaryItemPO.getCode(), "")); topology(salaryItemTopologyDTO, topologyData); @@ -767,7 +831,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe for (int i = 0; i < parameters.size(); i++) { FormulaVar formulaVar = parameters.get(i); String source = formulaVar.getSource(); - String fieldId = formulaVar.getFieldId().replace(source + "_", ""); + String fieldId = formulaVar.getFieldId(); + String code = fieldId.replace(source + "_", ""); String name = formulaVar.getName(); String fieldName = formulaVar.getFieldName(); //是否是薪资项目 @@ -785,26 +850,26 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe } ExpressFormula expressFormula; - if (salarySobItemCodeMap.containsKey(fieldId)) { + if (salarySobItemCodeMap.containsKey(code)) { // 如果薪资账套下重新定义了薪资项目的公式,则使用薪资账套下的公式,否则使用薪资项目本身的公式 - expressFormula = expressFormulaIdMap.get(salarySobItemCodeMap.get(fieldId).getFormulaId()); - } else if (salaryItemCodeMap.containsKey(fieldId)) { - expressFormula = expressFormulaIdMap.get(salaryItemCodeMap.get(fieldId).getFormulaId()); + expressFormula = expressFormulaIdMap.get(salarySobItemCodeMap.get(code).getFormulaId()); + } else if (salaryItemCodeMap.containsKey(code)) { + expressFormula = expressFormulaIdMap.get(salaryItemCodeMap.get(code).getFormulaId()); } else { expressFormula = null; } - SalaryItemPO salaryItemChild = isSalaryItemVar ? salaryItemCodeMap.get(fieldId) : new SalaryItemPO(); + SalaryItemPO salaryItemChild = isSalaryItemVar ? salaryItemCodeMap.get(code) : new SalaryItemPO(); SalaryItemTopologyDTO salaryItemTopologyChild = new SalaryItemTopologyDTO(); salaryItemTopologyChild.setSalaryItemId(isSalaryItemVar ? salaryItemChild.getId() : null); salaryItemTopologyChild.setSalaryItemName(isSalaryItemVar ? salaryItemChild.getName() : fieldName); salaryItemTopologyChild.setFormula(expressFormula); - salaryItemTopologyChild.setResult(isSalaryItemVar ? topologyData.getResultItemMap().getOrDefault(salaryItemChild.getId(), "") : ""); + salaryItemTopologyChild.setResult(topologyData.getResultItemMap().getOrDefault(fieldId, "")); salaryItemTopologyDTOChildren.add(salaryItemTopologyChild); if (isSalaryItemVar) { - SalaryItemPO salaryItemChildChild = salaryItemCodeMap.get(fieldId); + SalaryItemPO salaryItemChildChild = salaryItemCodeMap.get(code); SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(salaryItemChildChild.getValueType()); if (salaryValueTypeEnum != SalaryValueTypeEnum.INPUT) { topologyData.setSalaryItemId(salaryItemChildChild.getId()); @@ -849,9 +914,119 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe //薪资结果 Long acctEmpId = param.getAcctEmpId(); if (acctEmpId != null) { - List results = getSalaryAcctResultService(user).listBySalaryAcctEmployeeId(acctEmpId); - Map resultItemMap = SalaryEntityUtil.convert2Map(results, SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); - topologyData.setResultItemMap(resultItemMap); + SalaryAcctEmployeePO acctEmployeePO = getSalaryAcctEmployeeService(user).getById(acctEmpId); + List acctEmployeePOS = new ArrayList<>(); + acctEmployeePOS.add(acctEmployeePO); + + Long salaryAcctRecordId = acctEmployeePO.getSalaryAcctRecordId(); + + // 1、查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + //查询对应账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资账套不存在或已被删除")); + } + + // 不是查询薪资账套下实时的薪资项目,而是查询发起薪资核算时存储的薪资项目快照 + SalaryAcctConfig salaryAcctSobConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordId); + + // 2、查询薪资核算记录的薪资周期、考勤周期等 + SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordId); + // 3、查询薪资核算记录所用薪资账套的薪资项目副本 + List salarySobItemPOS = salaryAcctSobConfig.getSalarySobItems(); + // 回算薪资项目 + List salarySobBackItems = Collections.emptyList(); + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) { + salarySobBackItems = salaryAcctSobConfig.getSalarySobBackItems(); + } + // 4、查询当前租户的所有薪资项目 + List salaryItemPOS = getSalaryItemService(user).listAll(); + // 6、查询社保福利的所有字段 + Map welfareColumns = getSIAccountService(user).welfareColumns(); + // 7、查询考勤引用的所有字段 + List attendQuoteFieldListDTOS = getAttendQuoteFieldService(user).listAll(); + List variableItemPOS = getVariableItemService(user).listAll(); + + // 8、查询公式详情 + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId)); + formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); + List formulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 本次运算的回算薪资项目所涉及的变量 +// Set issuedFieldIds = getIssuedFieldIds(salarySobBackItems); + + // 10、根据id查询其他合并计税的薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAcctRecordPO.getId()); + + // 12.3、生成本次运算的key + String calculateKey = UUID.randomUUID().toString(); + // 12.5、多线程运算,运算结果存放在临时表中 + SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO() + .setSalaryAcctRecordPO(salaryAcctRecordPO) + .setSalarySobPO(salarySobPO) + .setSalarySobCycleDTO(salarySobCycleDTO) + .setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS) + .setSalarySobItemPOS(salarySobItemPOS) + .setSalaryItemIdWithPriorityList(new ArrayList<>()) + .setExpressFormulas(formulas) + .setSalaryItemPOS(salaryItemPOS) + .setSalarySobAdjustRulePOS(new ArrayList<>()) + .setWelfareColumns(MapUtils.emptyIfNull(welfareColumns)) + .setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS) + .setSalaryAcctEmployeePOS(acctEmployeePOS) + .setIssuedFieldIds(new HashSet<>()) + .setResults(null) + .setCalculateKey(calculateKey) + .setVariableItems(variableItemPOS) + .setTaxDeclarationFunction(null) + .setTaxIds(null); + + + List employeeIds = Collections.singletonList(acctEmployeePO.getEmployeeId()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + Long taxAgentId = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentId(); + List salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId); + List addUpSituationPOS; + if (salarySobCycleDTO.getTaxCycle().getMonth() == Month.JANUARY) { + // 3.1、如果当前税款所属期是本年度第一个税款所属期,就不需要查询往期累计情况 + addUpSituationPOS = Collections.emptyList(); + } else { + addUpSituationPOS = getAddUpSituationService(user).getAddUpSituationList(salarySobCycleDTO.getTaxCycle().plusMonths(-1), employeeIds); + } + List addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId); + List otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId); + List> welfareData = new ArrayList<>(); + welfareData.addAll(getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentId)); + List attendQuoteDataDTOS = getAttendQuoteDataService(user).getAttendQuoteData(salarySobCycleDTO.getSalaryMonth(), salarySobCycleDTO.getSalarySobId(), employeeIds); + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + Map empItemValueMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOS, p -> p.getSalaryAcctEmpId() + "_" + p.getSalaryItemId(), SalaryAcctResultPO::getResultValue); + List> variableArchiveList = getVariableArchiveService(user).listBySalaryMonthAndEmployeeIds(salarySobCycleDTO.getSalaryMonth(), employeeIds, taxAgentId); + Map> collect = salaryAcctResultPOS.stream().collect(Collectors.groupingBy(k -> k.getEmployeeId() + "-" + k.getTaxAgentId() + "-" + k.getSalaryItemId())); + Map salaryAcctResultPOMap = new HashMap<>(); + for (Map.Entry> et : collect.entrySet()) { + salaryAcctResultPOMap.put(et.getKey(), et.getValue().get(0).getOriginResultValue()); + } + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getOtherSalaryAcctRecordPOS(), SalaryAcctRecordPO::getId); + List otherSalaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds); + Map> otherSalaryAcctResultPOMap = SalaryEntityUtil.group2Map(otherSalaryAcctResultPOS, e -> e.getEmployeeId() + "_" + e.getTaxAgentId()); + List otherSalaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds); + Map> otherSalaryAcctEmployeePOMap = SalaryEntityUtil.group2Map(otherSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId()); +// List lastMonthResultPOS = getSalaryAcctResultService(user).listBySobSalaryMonth(SalaryDateUtil.toDate(salarySobCycleDTO.getSalaryMonth().minusMonths(1), 1), salaryAcctCalculateBO.getSalarySobPO().getId(), employeeIds); + CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList); + Map> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO); + + Map resultMap = new HashMap<>(); + formulaVarMap.entrySet().forEach(e -> { + e.getValue().forEach(f -> { + resultMap.put(f.getFieldId(), f.getFieldValue()); + }); + }); + topologyData.setResultItemMap(resultMap); } else { topologyData.setResultItemMap(new HashMap<>()); } @@ -885,7 +1060,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe /** * 核算结果 */ - Map resultItemMap; + Map resultItemMap; } diff --git a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java index 7ed85fdd9..22525a009 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.salary.service.impl; +import cn.hutool.core.util.StrUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.hrmelog.entity.dto.LoggerContext; @@ -11,6 +12,7 @@ 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.taxagent.param.TaxAgentQueryParam; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationAddParam; @@ -152,15 +154,12 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration // 分页参数 TaxDeclarationPO po = TaxDeclarationPO.builder().build(); - LocalDateRange localDateRange = new LocalDateRange(); if (Objects.nonNull(queryParam.getFromSalaryMonth())) { - localDateRange.setFromDate(queryParam.getFromSalaryMonth()); + po.setTaxCycleFromDate(queryParam.getFromSalaryMonth()); } if (Objects.nonNull(queryParam.getEndSalaryMonth())) { - localDateRange.setEndDate(SalaryDateUtil.localDateToDate(SalaryDateUtil.localDate2YearMonth(queryParam.getEndSalaryMonth()).atEndOfMonth())); + po.setTaxCycleEndDate(queryParam.getEndSalaryMonth()); } - po.setSalaryMonths(localDateRange); - // 分权 Boolean openDevolution = getTaxAgentService(user).isNeedAuth(currentEmployeeId); @@ -176,6 +175,15 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration // 查询个税申报表 List taxDeclarationPOS = getTaxDeclarationMapper().listSome(po); + + + if (StrUtil.isNotBlank(queryParam.getTaxAgentName())) { + List taxAgentPOs = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(queryParam.getTaxAgentName()).build()); + Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOs, TaxAgentPO::getId); + taxDeclarationPOS = taxDeclarationPOS.stream().filter(tax -> taxAgentIds.contains(tax.getTaxAgentId())).collect(Collectors.toList()); + } + + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), taxDeclarationPOS, TaxDeclarationPO.class); diff --git a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java index 8e88e73da..e97449a22 100644 --- a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java @@ -1,5 +1,7 @@ package com.engine.salary.service.impl; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.hrmelog.entity.dto.LoggerContext; @@ -23,6 +25,7 @@ import com.engine.salary.entity.salarysob.po.SalarySobAddUpRulePO; import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.entity.salarysob.po.SalarySobTaxReportRulePO; import com.engine.salary.entity.taxagent.bo.TaxAgentTaxReturnBO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO; import com.engine.salary.entity.taxapiflow.bo.TaxApiFlowBO; @@ -258,6 +261,13 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe } List taxDeclareRecordPOS = getTaxDeclareRecordMapper().listSome(build); + + if (StrUtil.isNotBlank(queryParam.getTaxAgentName())) { + List taxAgentPOs = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(queryParam.getTaxAgentName()).build()); + Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOs, TaxAgentPO::getId); + taxDeclareRecordPOS = taxDeclareRecordPOS.stream().filter(tax -> taxAgentIds.contains(tax.getTaxAgentId())).collect(Collectors.toList()); + } + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), taxDeclareRecordPOS, TaxDeclareRecordPO.class); } @@ -916,7 +926,8 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe declareStatus.setTaxDeclareStatus(taxDeclareStatusEnum.getValue()); // 申报类型 declareStatus.setTaxPayAmount(Util.null2String(declareTaxFeedbackResponse.getBody().get("ykjse"))); - declareStatus.setPersonNum(Integer.parseInt(Optional.ofNullable(declareTaxFeedbackResponse.getBody().get("nsrc")).orElse("0").toString())); + String nsrc = Util.null2String(declareTaxFeedbackResponse.getBody().get("nsrc")); + declareStatus.setPersonNum(Integer.parseInt(NumberUtil.isNumber(nsrc) ? nsrc : "0")); declareStatus.setDeclareRequestId(declareStatus.getRequestId()); declareStatus.setRequestId(""); //实缴(不含滞纳金) diff --git a/src/com/engine/salary/util/excel/ExcelUtil.java b/src/com/engine/salary/util/excel/ExcelUtil.java index 55f5dc54e..093ee3ed3 100644 --- a/src/com/engine/salary/util/excel/ExcelUtil.java +++ b/src/com/engine/salary/util/excel/ExcelUtil.java @@ -1,5 +1,6 @@ package com.engine.salary.util.excel; +import cn.hutool.core.util.StrUtil; import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; import com.engine.salary.util.JsonUtil; import com.engine.salary.util.SalaryDateUtil; @@ -139,8 +140,10 @@ public class ExcelUtil { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { cell.setCellType(CellType.NUMERIC); cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); @@ -235,8 +238,10 @@ public class ExcelUtil { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { cell.setCellType(CellType.NUMERIC); cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); @@ -311,8 +316,10 @@ public class ExcelUtil { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { cell.setCellType(CellType.NUMERIC); cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); @@ -377,8 +384,10 @@ public class ExcelUtil { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof Boolean) { cell.setCellType(CellType.BOOLEAN); cell.setCellValue(String.valueOf(o)); @@ -458,8 +467,10 @@ public class ExcelUtil { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof Boolean) { cell.setCellType(CellType.BOOLEAN); cell.setCellValue(String.valueOf(o)); diff --git a/src/com/engine/salary/util/excel/ExcelUtilPlus.java b/src/com/engine/salary/util/excel/ExcelUtilPlus.java index f10834532..a9c2a1107 100644 --- a/src/com/engine/salary/util/excel/ExcelUtilPlus.java +++ b/src/com/engine/salary/util/excel/ExcelUtilPlus.java @@ -1,6 +1,7 @@ package com.engine.salary.util.excel; import com.cloudstore.eccom.pc.table.WeaTableColumn; +import cn.hutool.core.util.StrUtil; import com.engine.salary.component.WeaTableColumnGroup; import com.engine.salary.entity.taxdeclaration.dto.ContrastListDTO; import com.engine.salary.util.SalaryDateUtil; @@ -9,6 +10,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.*; +import weaver.wechat.util.Utils; import java.awt.Color; import java.math.BigDecimal; @@ -132,10 +134,10 @@ public class ExcelUtilPlus { for (int i = 0; i < header.size(); i++) { WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i); XSSFCell rowZeroCell = row0.createCell(i, CellType.STRING); - rowZeroCell.setCellValue(columnGroupItem.getText().toString()); + rowZeroCell.setCellValue(columnGroupItem.getText()); rowZeroCell.setCellStyle(titleCellStyle); //设置列宽 - sheet.setColumnWidth(i, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256); + sheet.setColumnWidth(i, Math.min(255, Math.max(12, Utils.null2String(columnGroupItem.getText()).length() * 4)) * 256); patternList.add(columnGroupItem.getPattern()); } @@ -191,8 +193,10 @@ public class ExcelUtilPlus { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { if (lastRowRed && rowIndex == rowList.size() - 1) { cell.setCellStyle(numberRedCellStyleMap.get(patternList.get(cellIndex))); @@ -200,7 +204,7 @@ public class ExcelUtilPlus { cell.setCellStyle(numberCellStyleMap.get(patternList.get(cellIndex))); } cell.setCellType(CellType.NUMERIC); - cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + cell.setCellValue(((BigDecimal) o).doubleValue()); } else if (o instanceof Boolean) { cell.setCellType(CellType.BOOLEAN); cell.setCellValue(String.valueOf(o)); @@ -220,6 +224,7 @@ public class ExcelUtilPlus { } return workbook; } + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName) { XSSFWorkbook workbook = new XSSFWorkbook(); @@ -280,11 +285,13 @@ public class ExcelUtilPlus { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { cell.setCellType(CellType.NUMERIC); - cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + cell.setCellValue(((BigDecimal) o).doubleValue()); } else if (o instanceof Boolean) { cell.setCellType(CellType.BOOLEAN); cell.setCellValue(String.valueOf(o)); @@ -457,8 +464,10 @@ public class ExcelUtilPlus { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof Boolean) { cell.setCellType(CellType.BOOLEAN); cell.setCellValue(String.valueOf(o)); @@ -566,11 +575,13 @@ public class ExcelUtilPlus { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { cell.setCellType(CellType.NUMERIC); - cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + cell.setCellValue(((BigDecimal) o).doubleValue()); } else if (o instanceof Boolean) { cell.setCellType(CellType.BOOLEAN); cell.setCellValue(String.valueOf(o)); @@ -764,8 +775,10 @@ public class ExcelUtilPlus { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { if (lastRowRed && rowIndex == rowList.size() - 1) { cell.setCellStyle(numberRedCellStyleMap.get(patternList.get(cellIndex))); @@ -929,8 +942,10 @@ public class ExcelUtilPlus { } Object o = infoList.get(cellIndex); if (o instanceof String) { - cell.setCellType(CellType.STRING); - cell.setCellValue(String.valueOf(o)); + if (StrUtil.isNotBlank(String.valueOf(o))) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } } else if (o instanceof BigDecimal) { cell.setCellType(CellType.NUMERIC); cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); diff --git a/src/com/engine/salary/util/valid/ValidUtil.java b/src/com/engine/salary/util/valid/ValidUtil.java index 906718077..bcdec10d6 100644 --- a/src/com/engine/salary/util/valid/ValidUtil.java +++ b/src/com/engine/salary/util/valid/ValidUtil.java @@ -250,7 +250,9 @@ public class ValidUtil { .replace("between", "between") .replace("BETWEEN", "BETWEEN") .replace("union", "union") - .replace("UNION", "UNION"); + .replace("UNION", "UNION") + .replace("substr", "substr") + .replace("SUBSTR", "SUBSTR"); } setValue(t, field.getName(), result); } else if (valueTypeEnum == ValueTypeEnum.OBJECT) { diff --git a/src/com/engine/salary/web/TaxDeclarationController.java b/src/com/engine/salary/web/TaxDeclarationController.java index eba43a597..8f54f2d10 100644 --- a/src/com/engine/salary/web/TaxDeclarationController.java +++ b/src/com/engine/salary/web/TaxDeclarationController.java @@ -72,7 +72,7 @@ public class TaxDeclarationController { @POST @Path("/list") @Produces(MediaType.APPLICATION_JSON) - public String listTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam) { + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam) { User user = HrmUserVarify.getUser(request, response); return new ResponseResult>(user).run(getTaxDeclareRecordWrapper(user)::listPage, queryParam); } diff --git a/src/com/engine/salary/wrapper/SalarySobRangeWrapper.java b/src/com/engine/salary/wrapper/SalarySobRangeWrapper.java index 1ae272efc..b308f7b82 100644 --- a/src/com/engine/salary/wrapper/SalarySobRangeWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySobRangeWrapper.java @@ -97,7 +97,10 @@ public class SalarySobRangeWrapper extends Service { .replace("between", "between") .replace("BETWEEN", "BETWEEN") .replace("union", "union") - .replace("UNION", "UNION")); + .replace("UNION", "UNION") + .replace("substr", "substr") + .replace("SUBSTR", "SUBSTR") + ); } }); @@ -127,7 +130,10 @@ public class SalarySobRangeWrapper extends Service { .replace("between", "between") .replace("BETWEEN", "BETWEEN") .replace("union", "union") - .replace("UNION", "UNION")); + .replace("UNION", "UNION") + .replace("substr", "substr") + .replace("SUBSTR", "SUBSTR") + ); } }); diff --git a/src/com/engine/salary/wrapper/TaxAgentWrapper.java b/src/com/engine/salary/wrapper/TaxAgentWrapper.java index 9c094747d..aedb89a02 100644 --- a/src/com/engine/salary/wrapper/TaxAgentWrapper.java +++ b/src/com/engine/salary/wrapper/TaxAgentWrapper.java @@ -411,7 +411,10 @@ public class TaxAgentWrapper extends Service { .replace("between", "between") .replace("BETWEEN", "BETWEEN") .replace("union", "union") - .replace("UNION", "UNION")); + .replace("UNION", "UNION") + .replace("substr", "substr") + .replace("SUBSTR", "SUBSTR") + ); } }); @@ -445,7 +448,10 @@ public class TaxAgentWrapper extends Service { .replace("between", "between") .replace("BETWEEN", "BETWEEN") .replace("union", "union") - .replace("UNION", "UNION")); + .replace("UNION", "UNION") + .replace("substr", "substr") + .replace("SUBSTR", "SUBSTR") + ); } });