From f2fdbca8f7b696399f3616db4e0e75abaf4b09f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 7 Nov 2022 11:31:21 +0800 Subject: [PATCH 01/33] =?UTF-8?q?=E8=84=B1=E6=95=8F=E8=A1=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryAcctReportServiceImpl.java | 19 ++++++++++++++++++- .../sys/constant/SalarySysConstant.java | 5 +++++ .../sys/entity/param/AppSettingSaveParam.java | 9 +++++++++ .../salary/sys/entity/vo/AppSettingVO.java | 7 +++++++ .../sys/service/SalarySysConfService.java | 5 +++++ .../impl/SalarySysConfServiceImpl.java | 13 ++++++++++++- 6 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java index 334221f35..e02c2aeac 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java @@ -1,19 +1,27 @@ package com.engine.salary.service.impl; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.encrypt.AESEncryptUtil; import com.engine.salary.encrypt.report.SalaryAcctResultReportPOEncrypt; import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; import com.engine.salary.mapper.report.SalaryAcctResultReportMapper; import com.engine.salary.service.SalaryAcctReportService; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.db.MapperProxyFactory; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; +import static com.engine.salary.sys.constant.SalarySysConstant.DISPLAY_EMP_INFO_REPORT; + /** * 薪资报表 *

Copyright: Copyright (c) 2022

@@ -28,6 +36,11 @@ public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctRe return MapperProxyFactory.getProxy(SalaryAcctResultReportMapper.class); } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + /** * 薪酬解密方法 * @@ -61,7 +74,11 @@ public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctRe @Override public void batchSave(Collection pos) { if (CollectionUtils.isNotEmpty(pos)) { - SalaryAcctResultReportPOEncrypt.encryptList(pos); + SalarySysConfPO disPlay = getSalarySysConfService(user).getOneByCode(DISPLAY_EMP_INFO_REPORT); + //默认不显示,关闭状态 + if (disPlay == null || OpenEnum.OFF.getValue().equals(disPlay.getConfValue())) { + SalaryAcctResultReportPOEncrypt.encryptList(pos); + } // List> partition = Lists.partition((List) pos, 100); // partition.forEach(getSalaryAcctResultReportMapper()::batchInsert); diff --git a/src/com/engine/salary/sys/constant/SalarySysConstant.java b/src/com/engine/salary/sys/constant/SalarySysConstant.java index 4800e1e61..30f352cbf 100644 --- a/src/com/engine/salary/sys/constant/SalarySysConstant.java +++ b/src/com/engine/salary/sys/constant/SalarySysConstant.java @@ -32,6 +32,11 @@ public class SalarySysConstant { */ public static final String OPEN_ACCT_RESULT_SUM = "OPEN_ACCT_RESULT_SUM"; + /** + * 是否显示脱敏表人员信息 + */ + public static final String DISPLAY_EMP_INFO_REPORT = "DISPLAY_EMP_INFO_REPORT"; + /** * 应用设置是否开启加密 */ diff --git a/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java index e235ad139..12c36115b 100644 --- a/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java +++ b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java @@ -1,6 +1,7 @@ package com.engine.salary.sys.entity.param; import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -32,6 +33,7 @@ public class AppSettingSaveParam { * * @see OpenEnum */ + @DataCheck(require = true,message = "是否开启核算结果合计列?") private String openAcctResultSum; /** @@ -39,4 +41,11 @@ public class AppSettingSaveParam { */ private String isOpenEncrypt; + /** + * 是否显示脱敏表人员信息 + * @see OpenEnum + */ + @DataCheck(require = true,message = "是否显示脱敏表人员信息?") + private String displayEmpInfoReport; + } diff --git a/src/com/engine/salary/sys/entity/vo/AppSettingVO.java b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java index cfa2dbc77..d95b33af4 100644 --- a/src/com/engine/salary/sys/entity/vo/AppSettingVO.java +++ b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java @@ -40,4 +40,11 @@ public class AppSettingVO { private String isOpenEncrypt; + + /** + * 是否显示脱敏表人员信息 + * @see OpenEnum + */ + private String displayEmpInfoReport; + } diff --git a/src/com/engine/salary/sys/service/SalarySysConfService.java b/src/com/engine/salary/sys/service/SalarySysConfService.java index de1fd16ae..30e97581d 100644 --- a/src/com/engine/salary/sys/service/SalarySysConfService.java +++ b/src/com/engine/salary/sys/service/SalarySysConfService.java @@ -67,5 +67,10 @@ public interface SalarySysConfService { */ Map saveEncryptSetting(AppSettingSaveParam appSettingSaveParam); + /** + * 加密进度 + * @param progressId + * @return + */ Map getEncryptProgress(String progressId); } diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index efd8e42c0..14b971945 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -298,6 +298,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe public void saveAppSetting(AppSettingSaveParam param) { String openAcctResultSum = param.getOpenAcctResultSum(); saveSettingByType(openAcctResultSum, OPEN_ACCT_RESULT_SUM, "开启核算结果合并", "app"); + saveSettingByType(param.getDisplayEmpInfoReport(), DISPLAY_EMP_INFO_REPORT, "是否显示脱敏表人员信息", "app"); } @Override @@ -410,6 +411,9 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe case OPEN_APPLICATION_ENCRYPT: appSettingVO.setIsOpenEncrypt(salarySysConfPO.getConfValue()); break; + case DISPLAY_EMP_INFO_REPORT: + appSettingVO.setDisplayEmpInfoReport(salarySysConfPO.getConfValue()); + break; default: break; } @@ -417,7 +421,14 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe } //默认加密开启 if (StringUtils.isEmpty(appSettingVO.getIsOpenEncrypt())) { - appSettingVO.setIsOpenEncrypt("1"); + appSettingVO.setIsOpenEncrypt(OpenEnum.OPEN.getValue()); + } + + /** + * 默认不显示 + */ + if (StringUtils.isEmpty(appSettingVO.getDisplayEmpInfoReport())) { + appSettingVO.setDisplayEmpInfoReport(OpenEnum.OFF.getValue()); } return appSettingVO; } From 2da0455c46da79847d9f8c0c9aeb953ca218e57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 7 Nov 2022 15:11:24 +0800 Subject: [PATCH 02/33] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=96=AA=E8=B5=84?= =?UTF-8?q?=E6=A1=A3=E6=A1=88=E4=B8=AA=E7=A8=8E=E6=89=A3=E7=BC=B4=E4=B9=89?= =?UTF-8?q?=E5=8A=A1=E4=BA=BA=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20=E5=A4=84=E7=90=86=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=B9=E4=B8=BA=E5=BC=82=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryArchiveServiceImpl.java | 60 ++++++++++--------- .../salary/wrapper/SalaryArchiveWrapper.java | 49 +-------------- 2 files changed, 36 insertions(+), 73 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java index 30d2d2d85..a0e5dc2fe 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -1,6 +1,6 @@ package com.engine.salary.service.impl; -import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.util.Util_DataCache; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.*; @@ -26,9 +26,9 @@ import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; import com.engine.salary.mapper.archive.SalaryArchiveMapper; -import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.service.*; import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.OpenEnum; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.SalaryDateUtil; @@ -118,11 +118,6 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); } - - private SalarySysConfMapper getSalarySysConfMapper() { - return SqlProxyHandle.getProxy(SalarySysConfMapper.class); - } - @Override public SalaryArchivePO getById(Long salaryArchiveId) { return salaryArchiveMapper.getById(salaryArchiveId); @@ -131,10 +126,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe @Override public List listSome(SalaryArchivePO po) { Collection ids = po.getIds(); - if(CollectionUtils.isNotEmpty(ids)){ + if (CollectionUtils.isNotEmpty(ids)) { List list = new ArrayList<>(); List> partition = Lists.partition((List) ids, 1000); - partition.forEach(idss->{ + partition.forEach(idss -> { po.setIds(idss); list.addAll(getSalaryArchiveMapper().listSome(po)); }); @@ -142,10 +137,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } Collection employeeIds = po.getEmployeeIds(); - if(CollectionUtils.isNotEmpty(employeeIds)){ + if (CollectionUtils.isNotEmpty(employeeIds)) { List list = new ArrayList<>(); List> partition = Lists.partition((List) employeeIds, 1000); - partition.forEach(emps->{ + partition.forEach(emps -> { po.setEmployeeIds(emps); list.addAll(getSalaryArchiveMapper().listSome(po)); }); @@ -160,13 +155,24 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe public PageInfo listPage(SalaryArchiveQueryParam queryParam) { long currentEmployeeId = user.getUID(); - - // 1.历史数据处理 - handleHistory(currentEmployeeId); - // 2.待停薪自动处理 - handleSuspendData(currentEmployeeId); - // 3.增量数据处理 - handleChangeData(currentEmployeeId); + /** + * 异步处理档案数据 + */ + String handleable = Util.null2String(Util_DataCache.getObjVal("salaryArchiveHandleable")); + if (StringUtils.isBlank(handleable) || OpenEnum.OPEN.getValue().equals(handleable)) { + new Thread() { + public void run() { + Util_DataCache.setObjVal("salaryArchiveHandleable", "0"); + // 1.历史数据处理 + handleHistory(currentEmployeeId); + // 2.待停薪自动处理 + handleSuspendData(currentEmployeeId); + // 3.增量数据处理 + handleChangeData(currentEmployeeId); + Util_DataCache.setObjVal("salaryArchiveHandleable", "1"); + } + }.start(); + } Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId); @@ -1107,9 +1113,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } List oldList = listSome(SalaryArchivePO.builder() - .ids(ids) - .runStatus(SalaryArchiveStatusEnum.PENDING.getValue()) - .build()); + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.PENDING.getValue()) + .build()); if (CollectionUtils.isEmpty(oldList)) { @@ -1192,9 +1198,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); } List oldList = listSome(SalaryArchivePO.builder() - .ids(ids) - .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) - .build()); + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) + .build()); if (CollectionUtils.isEmpty(oldList)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "档案不存在!")); @@ -1241,9 +1247,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } List oldList = listSome(SalaryArchivePO.builder() - .ids(ids) - .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) - .build()); + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) + .build()); List unableList = oldList.stream().filter(f -> Objects.nonNull(f.getPayEndDate()) && !f.getPayEndDate().after(new Date())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(unableList)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115789, "最后发薪日必须晚于今天")); diff --git a/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java index 596808e3a..d50b8de03 100644 --- a/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java @@ -15,7 +15,6 @@ import com.engine.salary.entity.salaryarchive.param.*; import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO; import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; -import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; @@ -323,16 +322,8 @@ public class SalaryArchiveWrapper extends Service { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100465, "薪资档案员工信息不存在")); } - // 获取当前已生效个税扣缴义务人 - List taxAgentList = getSalaryArchiveService(user).getCurrentEffectiveTaxAgentList(Collections.singletonList(salaryArchiveId)); - // 获取所有个税扣缴义务人 - Collection taxAgentLists = getTaxAgentService(user).findAll(); - String taxAgent = ""; - if (CollectionUtils.isNotEmpty(taxAgentList)) { - SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = taxAgentList.get(0); - Optional taxAgentOptional = taxAgentLists.stream().filter(f -> f.getId().equals(salaryArchiveTaxAgent.getTaxAgentId())).findFirst(); - taxAgent = taxAgentOptional.isPresent() ? taxAgentOptional.get().getName() : taxAgent; - } + Long taxAgentId = po.getTaxAgentId(); + TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId); // 1.基本信息表单 Map baseInfo = new HashMap<>(); @@ -343,7 +334,7 @@ public class SalaryArchiveWrapper extends Service { .position(employee.getJobtitleName() == null ? "" : employee.getJobtitleName()) .hiredate(employee.getCompanystartdate()) .mobile(employee.getMobile()) - .taxAgent(taxAgent) + .taxAgent(taxAgent.getName()) .build(); baseInfo.put("employee", build); @@ -422,31 +413,6 @@ public class SalaryArchiveWrapper extends Service { return importTypes; } -// /** -// * 导出薪资档案 -// * -// * @param queryParam -// * @param employeeId -// * @param tenantKey -// * @return -// */ -// public Map exportList(SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) { -// // 构建异步导出参数 -// Map map = salaryBatchService.buildeExportParam("exportSalaryArchive"); -// String username = UserContext.getCurrentUser().getUsername(); -// String eteamsId = TenantRpcContext.getEteamsId(); -// taskExecutor.execute(() -> { -// try { -// DSTenantKeyThreadVar.tenantKey.set(tenantKey); -// getSalaryArchiveService(user).exportList(map, username, eteamsId, queryParam, employeeId, tenantKey); -// } finally { -// DSTenantKeyThreadVar.tenantKey.remove(); -// } -// }); -// -// return map; -// } -// /** * 下载导入模板 @@ -561,15 +527,6 @@ public class SalaryArchiveWrapper extends Service { return getSalaryArchiveExcelService(user).processInit(importData); } - -// public Map importSalaryArchiveSalaryItemAdjust(SalaryArchiveImportActionParam importData) { -// importData.setListType("FIXED"); -// importData.setImportType("salaryItemAdjust"); -// importData.setAddData(true); -// return getSalaryArchiveExcelService(user).processInit(importData); -// } - - /** * 停薪 * From 457fe51239d3318810862e1ad850091e5849a985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 7 Nov 2022 17:05:50 +0800 Subject: [PATCH 03/33] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=96=AA=E8=B5=84?= =?UTF-8?q?=E6=A1=A3=E6=A1=88=E9=87=8D=E5=A4=8D=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/SalaryArchiveService.java | 4 ++++ .../impl/SalaryArchiveServiceImpl.java | 24 +++++++++++++++++++ .../salary/web/SalaryArchiveController.java | 11 +++++++++ .../salary/wrapper/SalaryArchiveWrapper.java | 3 +++ 4 files changed, 42 insertions(+) diff --git a/src/com/engine/salary/service/SalaryArchiveService.java b/src/com/engine/salary/service/SalaryArchiveService.java index c2ee80e3b..296a31fb7 100644 --- a/src/com/engine/salary/service/SalaryArchiveService.java +++ b/src/com/engine/salary/service/SalaryArchiveService.java @@ -215,4 +215,8 @@ public interface SalaryArchiveService { String cancelStop(Collection ids); + /** + * 处理异常数据 + */ + Map handleRepeatData(); } diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java index a0e5dc2fe..9eccd455f 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -62,6 +62,7 @@ import weaver.hrm.User; import java.io.InputStream; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -1292,4 +1293,27 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe return StringUtils.EMPTY; } + @Override + public Map handleRepeatData() { + Map result = new HashMap<>(); + + //获取所有薪资档案 + List list = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatus(SalaryArchiveStatusEnum.PENDING.getValue()).build()); + AtomicInteger num = new AtomicInteger(); + if (CollectionUtils.isNotEmpty(list)) { + Map> maps = SalaryEntityUtil.group2Map(list, k -> k.getTaxAgentId() + "-" + k.getEmployeeId()); + maps.forEach((key, pos) -> { + if (pos.size() > 1) { + for (int i = 1; i < pos.size(); i++) { + SalaryArchivePO salaryArchivePO = pos.get(i); + getSalaryArchiveMapper().delete(salaryArchivePO); + num.getAndIncrement(); + } + } + }); + } + result.put("共处理", num.get()); + return result; + } + } diff --git a/src/com/engine/salary/web/SalaryArchiveController.java b/src/com/engine/salary/web/SalaryArchiveController.java index a7724f325..f5fbfcaae 100644 --- a/src/com/engine/salary/web/SalaryArchiveController.java +++ b/src/com/engine/salary/web/SalaryArchiveController.java @@ -896,4 +896,15 @@ public class SalaryArchiveController { /******** 个税扣缴义务人调整记录 end ***********************************************************************************************/ + + + + @GET + @Path("/handleRepeatData") + @Produces(MediaType.APPLICATION_JSON) + public String SingleTaxAgentAdjustRecordList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::handleRepeatData); + } + } diff --git a/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java index d50b8de03..bd230481c 100644 --- a/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java @@ -538,4 +538,7 @@ public class SalaryArchiveWrapper extends Service { } + public Map handleRepeatData() { + return getSalaryArchiveService(user).handleRepeatData(); + } } From defa7dacc3ad54b8852aead2176890863fd1b2fc Mon Sep 17 00:00:00 2001 From: sy Date: Mon, 7 Nov 2022 17:15:42 +0800 Subject: [PATCH 04/33] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=E5=85=A8=E9=87=8F=E5=A2=9E?= =?UTF-8?q?=E5=91=98=E3=80=81=E5=85=A8=E9=87=8F=E5=87=8F=E5=91=98=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B8=AA=E7=A8=8E=E6=89=A3=E7=BC=B4=E4=B9=89=E5=8A=A1?= =?UTF-8?q?=E4=BA=BA=E7=AD=9B=E9=80=89=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SIArchivesServiceImpl.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 8bc1b33e7..a94740c06 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -186,8 +186,14 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService private void handleHistoryData(long currentEmployeeId) { //如果触发历史数据处理,则进行一次全量增员 if (siArchivesBiz.createOldInsuranceBaseInfo(currentEmployeeId)) { - //全量增员 - allStayAddToPay(); + + //批量增员 + List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); + Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) + .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + if (stayAddIds.size() > 0) { + stayAddToPay(stayAddIds); + } } } @@ -742,9 +748,14 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ @Override public Map allStayDelToStop() { + long currentEmployeeId = user.getUID(); List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); if (allBaseInfoList.size() > 0) { - Collection stayDelIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) + //筛选当前人员可管辖(个税扣缴义务人)范围 + Collection taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); + List paymentOrganizationList = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + + Collection stayDelIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) && paymentOrganizationList.contains(f.getPaymentOrganization())) .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); if (stayDelIds.size() > 0) { return stayDelToStop(stayDelIds); @@ -914,9 +925,14 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ @Override public Map allStayAddToPay() { + long currentEmployeeId = user.getUID(); List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); if (allBaseInfoList.size() > 0) { - Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) + //筛选当前人员可管辖(个税扣缴义务人)范围 + Collection taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); + List paymentOrganizationList = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + + Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue()) && paymentOrganizationList.contains(f.getPaymentOrganization())) .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); if (stayAddIds.size() > 0) { return stayAddToPay(stayAddIds); From 21ccf6cbcb3f2b9b21d636c49b0a2486a3e99522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 8 Nov 2022 11:10:56 +0800 Subject: [PATCH 05/33] =?UTF-8?q?sql=E8=A7=A3=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FormulaRunServiceImpl.java | 19 ++++++++++++++++--- .../impl/SalaryAcctCalculateServiceImpl.java | 14 +++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java index 3f7e13f67..79190007f 100644 --- a/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java +++ b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java @@ -1,12 +1,14 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; +import com.engine.salary.encrypt.AESEncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryformula.ExpressFormula; import com.engine.salary.entity.salaryformula.po.FormulaVar; import com.engine.salary.enums.salaryformula.ReferenceTypeEnum; import com.engine.salary.formlua.entity.parameter.DataType; import com.engine.salary.service.FormulaRunService; +import com.engine.salary.sys.enums.OpenEnum; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -56,6 +58,8 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService String extendParam = expressFormula.getExtendParam(); String sqlReturnKey = ""; String datasourceId = ""; + String openDecrypt = ""; + String result = ""; try { JsonNode jsonNode = objectMapper.readTree(extendParam); //返回值配置 @@ -71,6 +75,11 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService datasourceId = datasourceIdNode.asText(); } } + //是否需要解密 + JsonNode decrypt = jsonNode.get("openDecrypt"); + if (decrypt != null) { + openDecrypt = decrypt.asText().trim(); + } } catch (JsonProcessingException e) { log.error("express execute fail, sql extendParam parse fail", e); } @@ -89,18 +98,22 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService RecordSetDataSource rs = new RecordSetDataSource(datasourceId); if (rs.executeSql(sql)) { if (rs.next()) { - return rs.getString(sqlReturnKey); + result = rs.getString(sqlReturnKey); } } } else { RecordSet rs = new RecordSet(); if (rs.execute(sql)) { if (rs.next()) { - return rs.getString(sqlReturnKey); + result = rs.getString(sqlReturnKey); } } } - return StringUtils.EMPTY; + + if (OpenEnum.OPEN.getValue().equals(openDecrypt)) { + result = AESEncryptUtil.decrypt(openDecrypt); + } + return result; } private Object runFormula(ExpressFormula expressFormula, List formulaVars) throws Exception { diff --git a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java index c272b65f9..c793713d9 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java @@ -198,7 +198,19 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc if (salaryItemIdKeySalarySobItemPOMap.containsKey(salaryItemId)) { // 转换成薪资核算结果po SalaryAcctResultTempPO salaryAcctResultTempPO = new SalaryAcctResultTempPO() - .setSalaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()).setSalaryAcctEmpId(salaryAcctEmployeePO.getId()).setEmployeeId(salaryAcctEmployeePO.getEmployeeId()).setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()).setSalarySobId(salaryAcctEmployeePO.getSalarySobId()).setSalaryItemId(salaryItemPO.getId()).setResultValue(resultValue).setCalculateKey(salaryAcctCalculateBO.getCalculateKey()).setCreator((long) user.getUID()).setCreateTime(now).setUpdateTime(now).setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).setDeleteType(0); + .setSalaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()) + .setSalaryAcctEmpId(salaryAcctEmployeePO.getId()) + .setEmployeeId(salaryAcctEmployeePO.getEmployeeId()) + .setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()) + .setSalarySobId(salaryAcctEmployeePO.getSalarySobId()) + .setSalaryItemId(salaryItemPO.getId()) + .setResultValue(resultValue) + .setCalculateKey(salaryAcctCalculateBO.getCalculateKey()) + .setCreator((long) user.getUID()) + .setCreateTime(now) + .setUpdateTime(now) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .setDeleteType(0); salaryAcctResultTempPOS.add(salaryAcctResultTempPO); } } From 1fb96be58b6dfb993c4b12eb68f12c921aad9abd Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 8 Nov 2022 11:22:56 +0800 Subject: [PATCH 06/33] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/sql/Oracle常见问题.txt | 2 + .../impl/SalaryAcctRecordServiceImpl.java | 66 ++++++++++++------- .../sys/constant/SalarySysConstant.java | 5 ++ .../sys/entity/param/AppSettingSaveParam.java | 5 ++ .../sys/enums/TaxDeclarationFunctionEnum.java | 4 +- .../sys/service/SalarySysConfService.java | 6 ++ .../impl/SalarySysConfServiceImpl.java | 20 +++++- .../web/SalarySystemConfigController.java | 6 +- 8 files changed, 83 insertions(+), 31 deletions(-) diff --git a/resource/sql/Oracle常见问题.txt b/resource/sql/Oracle常见问题.txt index 8725b72ea..e7550cf71 100644 --- a/resource/sql/Oracle常见问题.txt +++ b/resource/sql/Oracle常见问题.txt @@ -9,9 +9,11 @@ Oracle数据库中常见报错问题 -- 删除原表HRSA_SALARY_TEMPLATE数据 delete from HRSA_SALARY_TEMPLATE; + alter TABLE HRSA_SALARY_TEMPLATE MODIFY SALARY_ITEM_SETTING NULL; alter table HRSA_SALARY_TEMPLATE modify salary_item_setting long; alter table HRSA_SALARY_TEMPLATE modify salary_item_setting CLOB; insert into HRSA_SALARY_TEMPLATE select * from HRSA_SALARY_TEMPLAT_TEMPT ; + alter TABLE HRSA_SALARY_TEMPLATE MODIFY SALARY_ITEM_SETTING NOT NULL; drop table HRSA_SALARY_TEMPLAT_TEMPT; diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index da52c4415..0bc998079 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -16,6 +16,8 @@ import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.service.*; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; @@ -65,6 +67,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalarySendServiceImpl.class, user); } + private SalarySysConfService getSalarySysConfService(User user){ + return ServiceUtil.getService(SalarySysConfServiceImpl.class,user); + } + // private SalaryCheckResultService salaryCheckResultService; // // private SalaryCheckResultDetailService salaryCheckResultDetailService; @@ -85,6 +91,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); } + @Override public SalaryAcctRecordPO getById(Long id) { return getSalaryAcctRecordMapper().getById(id); @@ -296,17 +303,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe //获取账套下的所有核算结果 List salaryAcctRecords = listByTaxCycle(taxCycleYearRange,salarySobIds); - // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 - SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) - && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } + // 是否关闭个税申报功能 + Boolean haveClosedTaxDeclaration = getSalarySysConfService(user).haveClosedTaxDeclaration(); // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) @@ -318,17 +316,33 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); } - // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 - SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) - && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) - .findAny() - .orElse(null); - if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + + if(!haveClosedTaxDeclaration){ + // 开启了个税申报功能 + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } } + } @@ -454,7 +468,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月为空")); } // 查询税款所在年的该个税扣缴义务人所有薪资核算记录 - //获取账套所属个税扣缴义务人的核算记录 + // 获取账套所属个税扣缴义务人的核算记录 SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); Long taxAgentId = salarySobPO.getTaxAgentId(); //查询扣缴义务人下的所有账套 @@ -474,8 +488,12 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } //撤回工资单 getSalarySendService(user).revokeSalaryBill(salaryAcctRecordId); - //删除个税申报表(个税申报表、个税申报表详情、往期累计情况) - getTaxDeclarationService(user).delete(salaryAcctRecordPO); + Boolean haveClosedTaxDeclaration = getSalarySysConfService(user).haveClosedTaxDeclaration(); + if(!haveClosedTaxDeclaration){ + // 开启了个税申报功能 + // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) + getTaxDeclarationService(user).delete(salaryAcctRecordPO); + } // 更新薪资核算记录的状态 salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()); salaryAcctRecordPO.setUpdateTime(new Date()); diff --git a/src/com/engine/salary/sys/constant/SalarySysConstant.java b/src/com/engine/salary/sys/constant/SalarySysConstant.java index 4800e1e61..82c432564 100644 --- a/src/com/engine/salary/sys/constant/SalarySysConstant.java +++ b/src/com/engine/salary/sys/constant/SalarySysConstant.java @@ -45,4 +45,9 @@ public class SalarySysConstant { */ public static final String AES_ENCRYPT_IN_PROGRESS = "AES_ENCRYPT_IN_PROGRESS"; public static final String ENCRYPT_IN_PROGRESS = "ENCRYPT_PROGRESS_"; + + /** + * 需要申报功能 + */ + public static final String TAX_DECLARATION_FUNCTION = "taxDeclarationFunction"; } diff --git a/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java index e235ad139..a5edb437f 100644 --- a/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java +++ b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java @@ -39,4 +39,9 @@ public class AppSettingSaveParam { */ private String isOpenEncrypt; + /** + * 是否关闭个税申报 + */ + private String operateTaxDeclaration; + } diff --git a/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java index c76be7f95..6852e0c3b 100644 --- a/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java +++ b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java @@ -12,8 +12,8 @@ import org.apache.commons.lang3.StringUtils; * @version 1.0 **/ public enum TaxDeclarationFunctionEnum implements BaseEnum { - OPEN("OPEN", "开启", 1), - CLOSURE("CLOSURE", "关闭", 1), + OPEN("OPEN", "开启申报功能", 1), + CLOSURE("CLOSURE", "关闭申报功能", 1), REBOOT("REBOOT", "重启", 1); private String value; diff --git a/src/com/engine/salary/sys/service/SalarySysConfService.java b/src/com/engine/salary/sys/service/SalarySysConfService.java index de1fd16ae..31d497b70 100644 --- a/src/com/engine/salary/sys/service/SalarySysConfService.java +++ b/src/com/engine/salary/sys/service/SalarySysConfService.java @@ -29,6 +29,12 @@ public interface SalarySysConfService { */ boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag); + /** + * 是否关闭了个税申报功能 + * @return BOOLEAN + */ + public Boolean haveClosedTaxDeclaration(); + SalarySysConfPO getOneByCode(String code); List listSome(SalarySysConfPO build); diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index efd8e42c0..b9824b03c 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -138,9 +138,9 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe @Override public boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag) { Date date = new Date(); - SalarySysConfPO taxDeclarationFunction = getSalarySysConfMapper().getOneByCode("taxDeclarationFunction"); + SalarySysConfPO taxDeclarationFunction = getSalarySysConfMapper().getOneByCode(TAX_DECLARATION_FUNCTION); if (taxDeclarationFunction == null) { - taxDeclarationFunction = SalarySysConfPO.builder().id(IdGenerator.generate()).confKey("taxDeclarationFunction").confValue(flag.getValue()).title(flag.getDefaultLabel()).module("taxDeclaration").orderWeight(0).createTime(date).updateTime(date).deleteType(0).build(); + taxDeclarationFunction = SalarySysConfPO.builder().id(IdGenerator.generate()).confKey(TAX_DECLARATION_FUNCTION).confValue(flag.getValue()).title(flag.getDefaultLabel()).module("taxDeclaration").orderWeight(0).createTime(date).updateTime(date).deleteType(0).build(); getSalarySysConfMapper().insertIgnoreNull(taxDeclarationFunction); } else { TaxDeclarationFunctionEnum oldFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue()); @@ -165,6 +165,22 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return true; } + /** + * @description 是否关闭需要申报功能 + * @return Boolean + * @author Harryxzy + * @date 2022/11/7 17:05 + */ + public Boolean haveClosedTaxDeclaration(){ + SalarySysConfPO taxDeclarationFunction = salarySysConfService.getOneByCode(TAX_DECLARATION_FUNCTION); + if(taxDeclarationFunction != null && taxDeclarationFunction.getConfValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){ + // 关闭 + return true; + } + return false; + } + + @Override public SalarySysConfPO getOneByCode(String code) { return getSalarySysConfMapper().getOneByCode(code); diff --git a/src/com/engine/salary/web/SalarySystemConfigController.java b/src/com/engine/salary/web/SalarySystemConfigController.java index 2b20dc209..5c03047de 100644 --- a/src/com/engine/salary/web/SalarySystemConfigController.java +++ b/src/com/engine/salary/web/SalarySystemConfigController.java @@ -51,16 +51,16 @@ public class SalarySystemConfigController { * * @param request * @param response - * @param flag + * @param param * @return */ @POST @Path("/operateTaxDeclarationFunction") @Produces(MediaType.APPLICATION_JSON) - public String operateTaxDeclarationFunction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String flag) { + public String operateTaxDeclarationFunction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AppSettingSaveParam param) { User user = HrmUserVarify.getUser(request, response); - return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::operateTaxDeclarationFunction, TaxDeclarationFunctionEnum.parseByValue(flag)); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::operateTaxDeclarationFunction, TaxDeclarationFunctionEnum.parseByValue(param.getOperateTaxDeclaration())); } /** From 0630fb7b7d9252f45edd028a5df4cf79066eb32c Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 8 Nov 2022 13:58:21 +0800 Subject: [PATCH 07/33] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E5=BC=80=E5=85=B3-=E6=9F=A5=E8=AF=A2=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/sys/entity/vo/AppSettingVO.java | 5 +++++ .../salary/sys/service/impl/SalarySysConfServiceImpl.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/com/engine/salary/sys/entity/vo/AppSettingVO.java b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java index cfa2dbc77..d690bc178 100644 --- a/src/com/engine/salary/sys/entity/vo/AppSettingVO.java +++ b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java @@ -39,5 +39,10 @@ public class AppSettingVO { */ private String isOpenEncrypt; + /** + * 是否开启个税申报功能 + */ + private String isOpenTaxDeclaration; + } diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index b9824b03c..a4d1c84e3 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -426,6 +426,9 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe case OPEN_APPLICATION_ENCRYPT: appSettingVO.setIsOpenEncrypt(salarySysConfPO.getConfValue()); break; + case TAX_DECLARATION_FUNCTION: + appSettingVO.setIsOpenTaxDeclaration(salarySysConfPO.getConfValue()); + break; default: break; } From 8a704a9f5b7bda6a776a079c23c33c56332910b3 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 8 Nov 2022 16:27:29 +0800 Subject: [PATCH 08/33] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E5=BC=80=E5=85=B3-=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryAcctRecordServiceImpl.java | 48 ++++++++++++++----- .../sys/enums/TaxDeclarationFunctionEnum.java | 6 +-- .../impl/SalarySysConfServiceImpl.java | 4 ++ 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 0bc998079..a11055e28 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -305,20 +305,44 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe // 是否关闭个税申报功能 Boolean haveClosedTaxDeclaration = getSalarySysConfService(user).haveClosedTaxDeclaration(); - // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 - SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) - && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } + if(haveClosedTaxDeclaration){ + // 关闭了个税申报功能 + // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) + && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}",salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果有某个月(薪资所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO havaSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if(Objects.nonNull(havaSalaryAcctRecordPO)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98755, "薪资所属期{0}的薪资核算结果已经归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}",SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString()) + .replace("{1}",salarySobCycleDTO.getSalaryMonth().toString())); + } - if(!haveClosedTaxDeclaration){ + }else { // 开启了个税申报功能 + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) diff --git a/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java index 6852e0c3b..325c5463e 100644 --- a/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java +++ b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java @@ -12,9 +12,9 @@ import org.apache.commons.lang3.StringUtils; * @version 1.0 **/ public enum TaxDeclarationFunctionEnum implements BaseEnum { - OPEN("OPEN", "开启申报功能", 1), - CLOSURE("CLOSURE", "关闭申报功能", 1), - REBOOT("REBOOT", "重启", 1); + OPEN("1", "开启申报功能", 1), + CLOSURE("0", "关闭申报功能", 1), + REBOOT("2", "重启", 1); private String value; diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index a4d1c84e3..05ff72671 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -438,6 +438,10 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe if (StringUtils.isEmpty(appSettingVO.getIsOpenEncrypt())) { appSettingVO.setIsOpenEncrypt("1"); } + // 默认开启报税功能 + if(StringUtils.isEmpty(appSettingVO.getIsOpenTaxDeclaration())){ + appSettingVO.setIsOpenTaxDeclaration("1"); + } return appSettingVO; } From b66fe2b593c90937bb1f9aaecea3e5019361e995 Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 9 Nov 2022 09:53:13 +0800 Subject: [PATCH 09/33] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=E5=AF=BC=E5=85=A5=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E7=A4=BE=E4=BF=9D=E3=80=81=E5=85=AC?= =?UTF-8?q?=E7=A7=AF=E9=87=91=E3=80=81=E5=85=B6=E4=BB=96=E7=A6=8F=E5=88=A9?= =?UTF-8?q?=E6=96=B9=E6=A1=88=E8=AE=BE=E7=BD=AE=E6=98=AF=E5=90=A6=E4=B8=BA?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E7=A6=8F=E5=88=A9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SISchemeServiceImpl.java | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java index 3875365e0..1a1ab9cdc 100644 --- a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -899,6 +899,15 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案不存在")); excelComments.add(errorMessageMap); isError = true; + } else if (StringUtils.isNotBlank((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) + && schemeNameIdMap.get((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称")))).getWelfareType().equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案不属于社保福利类型")); + excelComments.add(errorMessageMap); + isError = true; + } else { insuranceArchivesSocialSchemePO = buildSocialPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); } @@ -907,15 +916,32 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100323, "公积金方案不存在")); excelComments.add(errorMessageMap); isError = true; - } else { + } else if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) + && schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称")))).getWelfareType().equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "公积金方案不属于公积金福利类型")); + excelComments.add(errorMessageMap); + isError = true; + + }else { insuranceArchivesFundSchemePO = buildFundPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); } - if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) == null) { + if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) == null) { Map errorMessageMap = Maps.newHashMap(); errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100324, "其他福利方案不存在")); excelComments.add(errorMessageMap); isError = true; - } else { + } else if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) + && schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称")))).getWelfareType().equals(WelfareTypeEnum.OTHER.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "其他福利方案不属于其他福利类型")); + excelComments.add(errorMessageMap); + isError = true; + }else { insuranceArchivesOtherSchemePO = buildOtherPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); } /**************校验申报基数**************/ From 775580f994a045bbb3621362a773bc2715a22c66 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Wed, 9 Nov 2022 10:20:46 +0800 Subject: [PATCH 10/33] --- --- .../salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java index 4e8062365..41bba094d 100644 --- a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java @@ -123,6 +123,7 @@ public class SalaryArchiveExcelBO extends Service { salaryArchiveErr = SalaryI18nUtil.getI18nLabel(101723, "该员工的薪资档案记录有误,请检查"); numberErr = SalaryI18nUtil.getI18nLabel(100581, "请输入数字"); + } /** From 5e69d07b7c902d067d65a7d5582e570898752984 Mon Sep 17 00:00:00 2001 From: fcli Date: Mon, 31 Oct 2022 16:19:42 +0800 Subject: [PATCH 11/33] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E6=89=A3=E9=99=A4=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/biz/SpecialAddDeductionBiz.java | 208 ++++++++++++++++++ .../SpecialAddDeductionEncrypt.java | 66 ++++++ .../po/SpecialAddDeductionPO.java | 93 ++++++++ .../SpecialAddDeductionMapper.java | 16 ++ .../SpecialAddDeductionMapper.xml | 197 +++++++++++++++++ 5 files changed, 580 insertions(+) create mode 100644 src/com/engine/salary/biz/SpecialAddDeductionBiz.java create mode 100644 src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java create mode 100644 src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java create mode 100644 src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java new file mode 100644 index 000000000..b9b8cc9d0 --- /dev/null +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -0,0 +1,208 @@ +package com.engine.salary.biz; + +import com.engine.salary.encrypt.datacollection.OtherDeductionPOEncrypt; +import com.engine.salary.encrypt.datacollection.OtherDeductionRecordDTOEncrypt; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.mapper.datacollection.OtherDeductionMapper; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.*; +import java.util.stream.Collectors; + +public class SpecialAddDeductionBiz extends BaseBean { + + + + /** + * 条件查询 + * + * @param param + * @return + */ + public List listSome(SpecialAddDeductionPO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List list = mapper.insertSelective(param); + return OtherDeductionPOEncrypt.decryptOtherDeductionPOList(otherDeductionPOS); + } finally { + sqlSession.close(); + } + } + + + /** + * 根据id获取 + * + * @param id + * @return + */ + public OtherDeductionPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + OtherDeductionPO byId = mapper.getById(id); + return OtherDeductionPOEncrypt.decryptOtherDeductionPO(byId); + } finally { + sqlSession.close(); + } + } + + /** + * 详情列表 + * + * @param param + * @return + */ + public List recordList(OtherDeductionQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + List otherDeductionRecordDTOS = mapper.recordList(param); + return OtherDeductionRecordDTOEncrypt.decryptOtherDeductionRecordDTOList(otherDeductionRecordDTOS); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchSave(List param) { + if(CollectionUtils.isEmpty(param)){ + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + OtherDeductionPOEncrypt.encryptOtherDeductionPOList(param); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::insertData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchUpdate(List param) { + if(CollectionUtils.isEmpty(param)){ + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + OtherDeductionPOEncrypt.encryptOtherDeductionPOList(param); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::updateData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + + + + + /** + * 处理导入数据 + * + * @param pos + */ + public void handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + OtherDeductionPO po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + // 查询已有数据 + List list = listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).build()); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream().map(m -> { + Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (optional.isPresent()) { + temp = optional.get(); + // 换成本地库的id + temp.setId(m.getId()); + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream().map(m -> { + Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (!optional.isPresent()) { + temp = m; + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + batchSave(saveList); + } + // 记录操作日志 +// saveList.addAll(updateList); +// +// if (CollectionUtils.isNotEmpty(saveList)) { +// LoggerContext loggerContext = new LoggerContext(); +// loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); +// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); +// loggerContext.setNewValueList(saveList); +// loggerContext.setTenant_key(message.getTenantKey()); +// loggerContext.setOperator(message.getUserId().toString()); +// loggerContext.setOperatorName(message.getOpreator()); +// loggerContext.setClientIp(message.getClientIp()); +// addUpDeductionLoggerTemplate.write(loggerContext); +// } + } + + + /** + * @description 批量删除 + * @return void + * @author Harryxzy + * @date 2022/10/27 16:07 + */ + public void batchDeleteByIDS(List deleteIds) { + if (CollectionUtils.isEmpty(deleteIds)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + List> partition = Lists.partition(deleteIds, 100); + partition.forEach(mapper::deleteData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java new file mode 100644 index 000000000..a9935875f --- /dev/null +++ b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java @@ -0,0 +1,66 @@ +package com.engine.salary.encrypt.datacollection; + +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * hrsa_special_add_deduction: 加解密 + * 字段: + * children_education + * continuing_education + * housing_loan_interest + * housing_rent + * supporting_elder + * serious_illness_treatment + * infant_care + */ +public class SpecialAddDeductionEncrypt { + public static SpecialAddDeductionPO encryptSpecialAddDeduction(SpecialAddDeductionPO po) { + if (po == null) { + return po; + } + po.setChildrenEducation(AESEncryptUtil.encrypt(po.getChildrenEducation())); + po.setContinuingEducation(AESEncryptUtil.encrypt(po.getContinuingEducation())); + po.setHousingLoanInterest(AESEncryptUtil.encrypt(po.getHousingLoanInterest())); + po.setHousingRent(AESEncryptUtil.encrypt(po.getHousingRent())); + po.setSupportingElder(AESEncryptUtil.encrypt(po.getSupportingElder())); + po.setSeriousIllnessTreatment(AESEncryptUtil.encrypt(po.getSeriousIllnessTreatment())); + po.setInfantCare(AESEncryptUtil.encrypt(po.getInfantCare())); + return po; + } + + public static SpecialAddDeductionPO decryptSpecialAddDeduction(SpecialAddDeductionPO po) { + if (po == null) { + return po; + } + po.setChildrenEducation(AESEncryptUtil.decrypt(po.getChildrenEducation())); + po.setContinuingEducation(AESEncryptUtil.decrypt(po.getContinuingEducation())); + po.setHousingLoanInterest(AESEncryptUtil.decrypt(po.getHousingLoanInterest())); + po.setHousingRent(AESEncryptUtil.decrypt(po.getHousingRent())); + po.setSupportingElder(AESEncryptUtil.decrypt(po.getSupportingElder())); + po.setSeriousIllnessTreatment(AESEncryptUtil.decrypt(po.getSeriousIllnessTreatment())); + po.setInfantCare(AESEncryptUtil.decrypt(po.getInfantCare())); + return po; + } + + public static List encryptSpecialAddDeductionPOList(List list) { + if (null == list || list.isEmpty()) { + return list; + } + return list.stream() + .map(SpecialAddDeductionEncrypt::encryptSpecialAddDeduction) + .collect(Collectors.toList()); + } + + public static List decryptSpecialAddDeductionPOList(List list) { + if (null == list || list.isEmpty()) { + return list; + } + return list.stream() + .map(SpecialAddDeductionEncrypt::decryptSpecialAddDeduction) + .collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java new file mode 100644 index 000000000..e169f7342 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java @@ -0,0 +1,93 @@ +package com.engine.salary.entity.datacollection.po; + +import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-专项附加扣除表 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SpecialAddDeductionPO { + private Long id; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 申报年月 + */ + private Date declareMonth; + + /** + * 子女教育 + */ + private String childrenEducation; + + /** + * 继续教育 + */ + private String continuingEducation; + + /** + * 住房贷款利息 + */ + private String housingLoanInterest; + + /** + * 住房租金 + */ + private String housingRent; + + /** + * 赡养老人 + */ + private String supportingElder; + + /** + * 大病医疗 + */ + private String seriousIllnessTreatment; + + /** + * 婴幼儿照护 + */ + private String infantCare; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java new file mode 100644 index 000000000..8d1bf1143 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java @@ -0,0 +1,16 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; + +import java.util.List; + +public interface SpecialAddDeductionMapper { + int insertSelective(SpecialAddDeductionPO record); + + SpecialAddDeductionPO getById(Long id); + + int updateByPrimaryKeySelective(SpecialAddDeductionPO record); + + List selectAllByPO(SpecialAddDeductionPO param); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml new file mode 100644 index 000000000..44916d521 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + id, employee_id, tax_agent_id, declare_month, children_education, continuing_education, + housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, + infant_care, create_time, update_time, creator, delete_type, tenant_key + + + + + insert into hrsa_special_add_deduction + + + employee_id, + + + tax_agent_id, + + + declare_month, + + + children_education, + + + continuing_education, + + + housing_loan_interest, + + + housing_rent, + + + supporting_elder, + + + serious_illness_treatment, + + + infant_care, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{employeeId,jdbcType=BIGINT}, + + + #{taxAgentId,jdbcType=BIGINT}, + + + #{declareMonth,jdbcType=TIMESTAMP}, + + + #{childrenEducation,jdbcType=VARCHAR}, + + + #{continuingEducation,jdbcType=VARCHAR}, + + + #{housingLoanInterest,jdbcType=VARCHAR}, + + + #{housingRent,jdbcType=VARCHAR}, + + + #{supportingElder,jdbcType=VARCHAR}, + + + #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + #{infantCare,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=BIGINT}, + + + #{deleteType,jdbcType=INTEGER}, + + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + update hrsa_special_add_deduction + + + employee_id = #{employeeId,jdbcType=BIGINT}, + + + tax_agent_id = #{taxAgentId,jdbcType=BIGINT}, + + + declare_month = #{declareMonth,jdbcType=TIMESTAMP}, + + + children_education = #{childrenEducation,jdbcType=VARCHAR}, + + + continuing_education = #{continuingEducation,jdbcType=VARCHAR}, + + + housing_loan_interest = #{housingLoanInterest,jdbcType=VARCHAR}, + + + housing_rent = #{housingRent,jdbcType=VARCHAR}, + + + supporting_elder = #{supportingElder,jdbcType=VARCHAR}, + + + serious_illness_treatment = #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + infant_care = #{infantCare,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + creator = #{creator,jdbcType=BIGINT}, + + + delete_type = #{deleteType,jdbcType=INTEGER}, + + + tenant_key = #{tenantKey,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + + \ No newline at end of file From 171f726bd372f65bc5a58e5d841f6f9952e936b6 Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 2 Nov 2022 17:27:07 +0800 Subject: [PATCH 12/33] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E6=89=A3=E9=99=A4=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/biz/SpecialAddDeductionBiz.java | 190 ++-- .../SpecialAddDeductionMapper.xml | 792 ++++++++++++----- .../impl/SpecialAddDeductionServiceImpl.java | 810 ++++++++++++++++++ 3 files changed, 1477 insertions(+), 315 deletions(-) create mode 100644 src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java index b9b8cc9d0..c505a964e 100644 --- a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -1,12 +1,9 @@ package com.engine.salary.biz; -import com.engine.salary.encrypt.datacollection.OtherDeductionPOEncrypt; -import com.engine.salary.encrypt.datacollection.OtherDeductionRecordDTOEncrypt; -import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; -import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; -import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; -import com.engine.salary.mapper.datacollection.OtherDeductionMapper; import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; @@ -18,58 +15,53 @@ import java.util.*; import java.util.stream.Collectors; public class SpecialAddDeductionBiz extends BaseBean { - - - - /** - * 条件查询 - * - * @param param - * @return - */ - public List listSome(SpecialAddDeductionPO param) { - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); - List list = mapper.insertSelective(param); - return OtherDeductionPOEncrypt.decryptOtherDeductionPOList(otherDeductionPOS); - } finally { - sqlSession.close(); - } - } - - /** * 根据id获取 * * @param id * @return */ - public OtherDeductionPO getById(Long id) { - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); - OtherDeductionPO byId = mapper.getById(id); - return OtherDeductionPOEncrypt.decryptOtherDeductionPO(byId); - } finally { - sqlSession.close(); + public SpecialAddDeductionPO getById(Long id) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + SpecialAddDeductionPO byId = mapper.getById(id); + return SpecialAddDeductionEncrypt.decrypt(byId); } } + public List listDTOByParam(SpecialAddDeductionQueryParam param) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List specialAddDeductionRecordDTOS = mapper.listDtoByParam(param); + return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionRecordDTOS); + } + } + + public List listByDeclareMonthAndTaxAgentIds(Date declareMonth, List taxAgentIds) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List pos = mapper.listByDeclareMonthAndTaxAgentIds(declareMonth, taxAgentIds); + return SpecialAddDeductionEncrypt.decrypt(pos); + } + } + + /** - * 详情列表 + * 批量插入 * * @param param * @return */ - public List recordList(OtherDeductionQueryParam param) { - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); - List otherDeductionRecordDTOS = mapper.recordList(param); - return OtherDeductionRecordDTOEncrypt.decryptOtherDeductionRecordDTOList(otherDeductionRecordDTOS); - } finally { - sqlSession.close(); + public void batchSave(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + SpecialAddDeductionEncrypt.encrypt(param); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); } } @@ -79,84 +71,55 @@ public class SpecialAddDeductionBiz extends BaseBean { * @param param * @return */ - public void batchSave(List param) { - if(CollectionUtils.isEmpty(param)){ + public void batchUpdate(List param) { + if (CollectionUtils.isEmpty(param)) { return; } SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { - OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); - OtherDeductionPOEncrypt.encryptOtherDeductionPOList(param); - List> partition = Lists.partition(param, 100); - partition.forEach(mapper::insertData); + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + SpecialAddDeductionEncrypt.encrypt(param); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::updateBatchSelective); sqlSession.commit(); } finally { sqlSession.close(); } } - /** - * 批量插入 - * - * @param param - * @return - */ - public void batchUpdate(List param) { - if(CollectionUtils.isEmpty(param)){ - return; - } - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); - OtherDeductionPOEncrypt.encryptOtherDeductionPOList(param); - List> partition = Lists.partition(param, 100); - partition.forEach(mapper::updateData); - sqlSession.commit(); - } finally { - sqlSession.close(); - } - } - - - - - /** * 处理导入数据 * * @param pos */ - public void handleImportData(List pos) { + public void handleImportData(List pos) { if (CollectionUtils.isEmpty(pos)) { return; } - OtherDeductionPO po = pos.get(0); + SpecialAddDeductionPO po = pos.get(0); // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) - List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + List finalPos = pos.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> + new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), + ArrayList::new) + ); // 查询已有数据 - List list = listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).build()); + List list = listByDeclareMonthAndTaxAgentIds(po.getDeclareMonth(), null); // 待修改的 本地已存在则更新【交集】 - List updateList = list.stream().map(m -> { - Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); - OtherDeductionPO temp = null; - if (optional.isPresent()) { - temp = optional.get(); - // 换成本地库的id - temp.setId(m.getId()); - } - return temp; - }).filter(Objects::nonNull).collect(Collectors.toList()); + List updateList = list.stream() + .map(m -> finalPos.stream() + .filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())) + .findFirst() + .map(t -> t.setId(m.getId())) + .orElse(null) + ).filter(Objects::nonNull).collect(Collectors.toList()); // 待新增的 导入比本地多,则新增【差集(导入 - local)】 - List saveList = finalPos.stream().map(m -> { - Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); - OtherDeductionPO temp = null; - if (!optional.isPresent()) { - temp = m; - } - return temp; - }).filter(Objects::nonNull).collect(Collectors.toList()); + List saveList = finalPos.stream() + .filter(m -> list.stream().noneMatch(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())) + ).filter(Objects::nonNull).collect(Collectors.toList()); // 修改 if (CollectionUtils.isNotEmpty(updateList)) { @@ -166,43 +129,22 @@ public class SpecialAddDeductionBiz extends BaseBean { if (CollectionUtils.isNotEmpty(saveList)) { batchSave(saveList); } - // 记录操作日志 -// saveList.addAll(updateList); -// -// if (CollectionUtils.isNotEmpty(saveList)) { -// LoggerContext loggerContext = new LoggerContext(); -// loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); -// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); -// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); -// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); -// loggerContext.setNewValueList(saveList); -// loggerContext.setTenant_key(message.getTenantKey()); -// loggerContext.setOperator(message.getUserId().toString()); -// loggerContext.setOperatorName(message.getOpreator()); -// loggerContext.setClientIp(message.getClientIp()); -// addUpDeductionLoggerTemplate.write(loggerContext); -// } } /** - * @description 批量删除 * @return void - * @author Harryxzy - * @date 2022/10/27 16:07 + * @description 批量删除 */ - public void batchDeleteByIDS(List deleteIds) { + public void batchDeleteByIds(List deleteIds) { if (CollectionUtils.isEmpty(deleteIds)) { return; } - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); List> partition = Lists.partition(deleteIds, 100); - partition.forEach(mapper::deleteData); + partition.forEach(mapper::deleteByIds); sqlSession.commit(); - } finally { - sqlSession.close(); } } } diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml index 44916d521..01cdbc987 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -1,197 +1,607 @@ - - - - - - - - - - - - - - - - - - - - - - - id, employee_id, tax_agent_id, declare_month, children_education, continuing_education, - housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, - infant_care, create_time, update_time, creator, delete_type, tenant_key - - - - - insert into hrsa_special_add_deduction - - - employee_id, - - - tax_agent_id, - - - declare_month, - - - children_education, - - - continuing_education, - - - housing_loan_interest, - - - housing_rent, - - - supporting_elder, - - - serious_illness_treatment, - - - infant_care, - - - create_time, - - - update_time, - - - creator, - - - delete_type, - - - tenant_key, - - - - - #{employeeId,jdbcType=BIGINT}, - - - #{taxAgentId,jdbcType=BIGINT}, - - - #{declareMonth,jdbcType=TIMESTAMP}, - - - #{childrenEducation,jdbcType=VARCHAR}, - - - #{continuingEducation,jdbcType=VARCHAR}, - - - #{housingLoanInterest,jdbcType=VARCHAR}, - - - #{housingRent,jdbcType=VARCHAR}, - - - #{supportingElder,jdbcType=VARCHAR}, - - - #{seriousIllnessTreatment,jdbcType=VARCHAR}, - - - #{infantCare,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{updateTime,jdbcType=TIMESTAMP}, - - - #{creator,jdbcType=BIGINT}, - - - #{deleteType,jdbcType=INTEGER}, - - - #{tenantKey,jdbcType=VARCHAR}, - - - - - - update hrsa_special_add_deduction - - - employee_id = #{employeeId,jdbcType=BIGINT}, - - - tax_agent_id = #{taxAgentId,jdbcType=BIGINT}, - - - declare_month = #{declareMonth,jdbcType=TIMESTAMP}, - - - children_education = #{childrenEducation,jdbcType=VARCHAR}, - - - continuing_education = #{continuingEducation,jdbcType=VARCHAR}, - - - housing_loan_interest = #{housingLoanInterest,jdbcType=VARCHAR}, - - - housing_rent = #{housingRent,jdbcType=VARCHAR}, - - - supporting_elder = #{supportingElder,jdbcType=VARCHAR}, - - - serious_illness_treatment = #{seriousIllnessTreatment,jdbcType=VARCHAR}, - - - infant_care = #{infantCare,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - - - creator = #{creator,jdbcType=BIGINT}, - - - delete_type = #{deleteType,jdbcType=INTEGER}, - - - tenant_key = #{tenantKey,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=BIGINT} - + + + + + + + + + + + + + + + + + + + + - + + t1.id, + t1.declare_month, + t1.employee_id, + t2.id AS tax_agent_id, + t2.name AS tax_agent_name, + e.lastname as username, + e.certificatenum as idNo, + d.departmentname AS departmentName, + e.mobile, + e.workcode as job_num, + e.companystartdate as hiredate, + t1.children_education, + t1.continuing_education, + t1.housing_loan_interest, + t1.housing_rent, + t1.serious_illness_treatment, + t1.supporting_elder, + t1.infant_care + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like CONCAT('%',#{param.mobile},'%') + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'||#{param.mobile}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'+#{param.mobile}+'%' + + + + + + + + + + + insert into hrsa_special_add_deduction + + + employee_id, + + + tax_agent_id, + + + declare_month, + + + children_education, + + + continuing_education, + + + housing_loan_interest, + + + housing_rent, + + + supporting_elder, + + + serious_illness_treatment, + + + infant_care, + + + create_time, + + + update_time, + + + creator, + + delete_type, + + tenant_key, + + + + + #{employeeId,jdbcType=BIGINT}, + + + #{taxAgentId,jdbcType=BIGINT}, + + + #{declareMonth,jdbcType=TIMESTAMP}, + + + #{childrenEducation,jdbcType=VARCHAR}, + + + #{continuingEducation,jdbcType=VARCHAR}, + + + #{housingLoanInterest,jdbcType=VARCHAR}, + + + #{housingRent,jdbcType=VARCHAR}, + + + #{supportingElder,jdbcType=VARCHAR}, + + + #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + #{infantCare,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=BIGINT}, + + 0, + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + update hrsa_special_add_deduction + + + employee_id = #{employeeId,jdbcType=BIGINT}, + + + tax_agent_id = #{taxAgentId,jdbcType=BIGINT}, + + + declare_month = #{declareMonth,jdbcType=TIMESTAMP}, + + + children_education = #{childrenEducation,jdbcType=VARCHAR}, + + + continuing_education = #{continuingEducation,jdbcType=VARCHAR}, + + + housing_loan_interest = #{housingLoanInterest,jdbcType=VARCHAR}, + + + housing_rent = #{housingRent,jdbcType=VARCHAR}, + + + supporting_elder = #{supportingElder,jdbcType=VARCHAR}, + + + serious_illness_treatment = #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + infant_care = #{infantCare,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + creator = #{creator,jdbcType=BIGINT}, + + + delete_type = #{deleteType,jdbcType=INTEGER}, + + + tenant_key = #{tenantKey,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + + + update hrsa_special_add_deduction + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.employeeId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.taxAgentId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.declareMonth,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.childrenEducation,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.continuingEducation,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.housingLoanInterest,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.housingRent,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.supportingElder,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.seriousIllnessTreatment,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.infantCare,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.updateTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.creator,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.deleteType,jdbcType=INTEGER} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.tenantKey,jdbcType=VARCHAR} + + + + + where id in + + #{item.id,jdbcType=BIGINT} + + + + + + insert into hrsa_special_add_deduction + (employee_id, tax_agent_id, declare_month, children_education, continuing_education, + housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, + infant_care, create_time, update_time, creator, delete_type, tenant_key) + values + + (#{item.employeeId,jdbcType=BIGINT}, #{item.taxAgentId,jdbcType=BIGINT}, + #{item.declareMonth,jdbcType=TIMESTAMP}, + #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, + #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, + #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, + #{item.infantCare,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, + #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.creator,jdbcType=BIGINT}, 0, #{item.tenantKey,jdbcType=VARCHAR}) + + + + + + + + + + + update hrsa_special_add_deduction + set delete_type = 1 + where id in ( + + #{id} + + ) and delete_type = 0 + \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java new file mode 100644 index 000000000..f658c66cb --- /dev/null +++ b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java @@ -0,0 +1,810 @@ +package com.engine.salary.service.impl; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.EmployBiz; +import com.engine.salary.biz.SpecialAddDeductionBiz; +import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SpecialAddDeductionService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +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.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.time.YearMonth; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +public class SpecialAddDeductionServiceImpl extends Service implements SpecialAddDeductionService { + + private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + @Override + public SpecialAddDeductionPO getById(Long id) { + return getSpecialAddDeductionMapper().getById(id); + } + + + @Override + public PageInfo listPage(SpecialAddDeductionQueryParam queryParam) { + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + long employeeId = user.getUID(); + + Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); + if (needAuth) { + List taxAgentIdsAsAdmin = getTaxAgentService(user) + .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { + return new PageInfo<>(SpecialAddDeductionListDTO.class); + } + queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + } + SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List list = getSpecialAddDeductionMapper().listByParam(queryParam); + SpecialAddDeductionEncrypt.decrypt(list); + return new PageInfo<>(list, SpecialAddDeductionListDTO.class); + } + + @Override + public PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam) { + long employeeId = user.getUID(); + + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); + if (needAuth) { + List taxAgentIdsAsAdmin = getTaxAgentService(user) + .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { + return new PageInfo<>(SpecialAddDeductionRecordDTO.class); + } + queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + } + SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List list = getSpecialAddDeductionMapper().listDtoByParam(queryParam); + SpecialAddDeductionEncrypt.decrypt(list); + return new PageInfo<>(list, SpecialAddDeductionRecordDTO.class); + } + + + @Override + public Map preview(SpecialAddDeductionImportParam importParam) { + Map apidatas = new HashMap(); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List SpecialAddDeductions = + ExcelParseHelper.parse2Map(fileInputStream, SpecialAddDeductionListDTO.class, 0, 1, 11, + "SpecialAddDeductionTemplate.xlsx"); + apidatas.put("preview", SpecialAddDeductions); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + + public Map importData(SpecialAddDeductionImportParam importParam) { + + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + + long currentEmployeeId = user.getUID(); + Map apidatas = new HashMap(); + EmployBiz employBiz = new EmployBiz(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //检验参数 + checkImportParam(importParam); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List SpecialAddDeductions = ExcelParseHelper.parse2Map(fileInputStream, SpecialAddDeductionListDTO.class, 0, 1, 14, "SpecialAddDeductionTemplate.xlsx"); + + int total = SpecialAddDeductions.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + //人员信息 + List employees = employBiz.listEmployee(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + //税款所属期 + Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user) + .getAccountedEmployeeData(declareMonthStr); + // 查询已有数据 + List list = getSpecialAddDeductionMapper() + .listByDeclareMonthAndTaxAgentIds(declareMonth, null); + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + + for (int i = 0; i < SpecialAddDeductions.size(); i++) { + SpecialAddDeductionListDTO dto = SpecialAddDeductions.get(i); + + Date now = new Date(); + //待插入数据库对象 + SpecialAddDeductionPO po = SpecialAddDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .declareMonth(declareMonth).build(); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + List employeeSameIds = new ArrayList<>(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List emps = getSalaryEmployeeService(user) + .matchImportEmployee(employees, userName, deparmentName, mobile, workcode, null); + //含在职和离职,选在职数据 + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream() + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setEmployeeId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + String taxAgentName = dto.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getTaxAgentId().equals(Long.valueOf(taxAgentId))) { + //个税扣缴义务人与导入时选择的不一致 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + po.setTaxAgentId(optionalTemp.get().getTaxAgentId()); + } + } else { + //个税扣缴义务人不存在 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + // 核心字段 + po.setInfantCare(dto.getInfantCare()) + .setSeriousIllnessTreatment(dto.getSeriousIllnessTreatment()) + .setSupportingElder(dto.getSupportingElder()) + .setHousingRent(dto.getHousingRent()) + .setHousingLoanInterest(dto.getHousingLoanInterest()) + .setContinuingEducation(dto.getContinuingEducation()) + .setChildrenEducation(dto.getChildrenEducation()); + + + //fixme 分权判断 +// + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + SpecialAddDeductionPO finalPo = po; + Optional optionalAcctEmp = + salaryAcctEmployees.stream() + .filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())) + .findFirst(); + boolean isExist = list.stream() + .anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + Map errorMessageMap = new HashMap(); + errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + //入库 + SpecialAddDeductionBiz.handleImportData(eligibleData); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + private void checkImportParam(SpecialAddDeductionImportParam importParam) { + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + if (StringUtils.isBlank(declareMonthStr)) { + throw new SalaryRunTimeException("税款所属期为空"); + } + } + + + /** + * 导出 + * + * @param param + * @return + */ + public XSSFWorkbook export(SpecialAddDeductionQueryParam param) { + + //获取操作按钮资源 + List> rowList = getExcelRowList(param); + + //获取excel + return ExcelUtil.genWorkbook(rowList, "其他免税扣除"); + } + + + /** + * 获取excel数据行 + * + * @return 导出数据行集合 + */ + private List> getExcelRowList(SpecialAddDeductionQueryParam param) { + long employeeId = user.getUID(); + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + + //申报月份 + List declareMonth = param.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + List list = getSpecialAddDeductionMapper().listByParam(param); + SpecialAddDeductionEncrypt.decrypt(list); + // 开启分权并且不是薪酬模块总管理员 + if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) { + List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + list = list.stream().filter(f -> + // 作为管理员 + taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) + ).collect(Collectors.toList()); + } + + + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getIdNo())); + cellList.add(Util.null2String(dto.getHiredate())); + cellList.add(Util.null2String(dto.getChildrenEducation())); + cellList.add(Util.null2String(dto.getContinuingEducation())); + cellList.add(Util.null2String(dto.getHousingLoanInterest())); + cellList.add(Util.null2String(dto.getHousingRent())); + cellList.add(Util.null2String(dto.getSupportingElder())); + cellList.add(Util.null2String(dto.getSeriousIllnessTreatment())); + cellList.add(Util.null2String(dto.getInfantCare())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + /** + * 导出详情列表 + * + * @param param + * @return + */ + public XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam param) { + + SpecialAddDeductionBiz biz = new SpecialAddDeductionBiz(); + EmployBiz employBiz = new EmployBiz(); + + Long id = param.getSpecialAddDeductionId(); + if (id == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + SpecialAddDeductionPO po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("专项附加扣除不存在" + "[id:%s]", id)); + } + + List employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException("员工信息不存在"); + } + + //构建参数 + param.setEmployeeId(po.getEmployeeId()); + //申报月份 + List declareMonth = param.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + + //获取操作按钮资源 + List> rowList = getExcelRowDetailList(param); + + //获取excel + return ExcelUtil.genWorkbook(rowList, "其他免税扣除明细"); + } + + + /** + * 导出详情 + * + * @param param + * @return + */ + private List> getExcelRowDetailList(SpecialAddDeductionQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "手机号", "工号", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); + //查询详细信息 + List list = getSpecialAddDeductionMapper().listDtoByParam(param); + SpecialAddDeductionEncrypt.decrypt(list); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth()))); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getChildrenEducation())); + cellList.add(Util.null2String(dto.getContinuingEducation())); + cellList.add(Util.null2String(dto.getHousingLoanInterest())); + cellList.add(Util.null2String(dto.getHousingRent())); + cellList.add(Util.null2String(dto.getSupportingElder())); + cellList.add(Util.null2String(dto.getSeriousIllnessTreatment())); + cellList.add(Util.null2String(dto.getInfantCare())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + @Override + public List getSpecialAddDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId) { + if (declareMonth == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传")); + } + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + return SpecialAddDeductionBiz.listByDeclareMonthAndTaxAgentIds(SalaryDateUtil.toDateStartOfMonth(declareMonth), null); + } + + @Override + public void editData(SpecialAddDeductionParam specialAddDeductionParam) { + String declareMonthStr = specialAddDeductionParam.getDeclareMonth(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + + Long currentEmployeeId = (long) user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + SpecialAddDeductionPO byId = SpecialAddDeductionBiz.getById(specialAddDeductionParam.getId()); + if (byId == null) { + throw new SalaryRunTimeException("该数据不存在!"); + } + Long taxAgentId = byId.getTaxAgentId(); + boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); + if (!canEdit) { + //没有编辑权限 + throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); + } + // 获取已经核算的数据 + List salaryAcctEmployees = + getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = + salaryAcctEmployees.stream() + .filter(f -> f.getEmployeeId().equals(specialAddDeductionParam.getEmployeeId()) && f.getTaxAgentId().equals(specialAddDeductionParam.getTaxAgentId())) + .findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!"); + } + } + ArrayList updateList = new ArrayList<>(); + SpecialAddDeductionPO build = SpecialAddDeductionPO.builder() + .id(specialAddDeductionParam.getId()) + .childrenEducation(specialAddDeductionParam.getChildrenEducation()) + .continuingEducation(specialAddDeductionParam.getContinuingEducation()) + .housingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) + .housingRent(specialAddDeductionParam.getHousingRent()) + .build(); + updateList.add(build); + SpecialAddDeductionBiz.batchUpdate(updateList); + } + + @Override + public void createData(SpecialAddDeductionParam specialAddDeductionParam) { + long currentEmployeeId = user.getUID(); + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + EmployBiz employBiz = new EmployBiz(); + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //税款所属期 + String declareMonthStr = Util.null2String(specialAddDeductionParam.getDeclareMonth()); + //人员信息 + List employees = employBiz.listEmployee(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + //税款所属期 + Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); + // 查询已有数据 + List list = getSpecialAddDeductionMapper().listByDeclareMonthAndTaxAgentIds(declareMonth, null); + //合规数据 + List insertData = new ArrayList<>(); + Date now = new Date(); + //待插入数据库对象 + SpecialAddDeductionPO po = SpecialAddDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .declareMonth(declareMonth).build(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + boolean employeeSameId = employees.stream() + .anyMatch(e -> Objects.equals(e.getEmployeeId(), specialAddDeductionParam.getEmployeeId())); + if (!employeeSameId) { + throw new SalaryRunTimeException("员工信息不存在"); + } + po.setEmployeeId(specialAddDeductionParam.getEmployeeId()); + String taxAgentName = specialAddDeductionParam.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + throw new SalaryRunTimeException("个税扣缴义务人不能为空"); + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + po.setTaxAgentId(optionalTemp.get().getTaxAgentId()); + } else { + //个税扣缴义务人不存在或不在权限范围内 + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + } + + //商业健康保险 + po.setContinuingEducation(specialAddDeductionParam.getContinuingEducation()) + .setChildrenEducation(specialAddDeductionParam.getChildrenEducation()) + .setHousingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) + .setHousingRent(specialAddDeductionParam.getHousingRent()) + .setSupportingElder(specialAddDeductionParam.getSupportingElder()) + .setSeriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment()) + .setInfantCare(specialAddDeductionParam.getInfantCare()); + //fixme 分权判断 + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + SpecialAddDeductionPO finalPo = po; + Optional optionalAcctEmp = + salaryAcctEmployees.stream() + .filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())) + .findFirst(); + boolean isExist = list.stream() + .anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入"); + } + } + insertData.add(po); + //入库 + SpecialAddDeductionBiz.handleImportData(insertData); + } + + @Override + public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) { + long currentEmployeeId = user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + String declareMonthStr = deleteParam.getDeclareMonth(); + List deleteIds = deleteParam.getIds(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = + getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); + // 判断是否有核算过 + List deleteList = new ArrayList<>(); + for (Long id : deleteIds) { + SpecialAddDeductionPO byId = SpecialAddDeductionBiz.getById(id); + if (byId == null) { + throw new SalaryRunTimeException("数据不存在或已被删除!"); + } + // 判断是否在个税扣缴义务人范围内 + boolean isNotInRegion = + taxAgentList.stream() + .noneMatch(m -> Objects.equals(m.getTaxAgentId(), byId.getTaxAgentId())); + if (isNotInRegion) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + // 判断用户是否存在 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = + salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!"); + } + } + deleteList.add(byId.getId()); + } + SpecialAddDeductionBiz.batchDeleteByIds(deleteList); + } + + @Override + public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) { + String declareMonthStr = deleteParam.getDeclareMonth(); + long currentEmployeeId = user.getUID(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + List taxAgentIds = taxAgentList.stream() + .map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId) + .collect(Collectors.toList()); + SpecialAddDeductionBiz specialAddDeductionBiz = new SpecialAddDeductionBiz(); + Date declareMonthDate = null; + try { + declareMonthDate = sdf.parse(declareMonthStr + "-01"); + } catch (Exception e) { + throw new SalaryRunTimeException("日期异常"); + } + + if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) { + // 设置了个税扣缴义务人 + Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId)); + if (!canDelete) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); + } + ArrayList tai = new ArrayList<>(); + tai.add(taxAgentId); + taxAgentIds = tai; + } + // 获取所有想要删除的数据 + List list = specialAddDeductionBiz.listByDeclareMonthAndTaxAgentIds(declareMonthDate, taxAgentIds); + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user) + .getAccountedEmployeeData(declareMonthStr); + for (SpecialAddDeductionPO item : list) { + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("有员工在该年月中已经完成核算并归档,不能进行一键清空!"); + } + } + } + List deleteIds = list.stream().map(SpecialAddDeductionPO::getId).collect(Collectors.toList()); + specialAddDeductionBiz.batchDeleteByIds(deleteIds); + } + + @Override + public XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam param) { + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(101604, "其他免税扣除导入模板"); + String[] header = { + SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), + SalaryI18nUtil.getI18nLabel(86185, "部门"), + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86317, "工号"), + SalaryI18nUtil.getI18nLabel(86318, "证件号码"), + SalaryI18nUtil.getI18nLabel(86319, "入职日期"), + SalaryI18nUtil.getI18nLabel(91238, "商业健康保险"), + SalaryI18nUtil.getI18nLabel(91239, "税延养老保险"), + SalaryI18nUtil.getI18nLabel(84500, "其他"), + SalaryI18nUtil.getI18nLabel(91240, "准予扣除的捐赠额") + }; + // 2.表头 + List> rows = new ArrayList<>(); + List headerList = Arrays.asList(header); + rows.add(headerList); + + // 4.注释 + List excelComments = Lists.newArrayList(); + excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(9, 0, 12, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(10, 0, 13, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + + XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName, excelComments); + return book; + } + +} From dffee9206f8a1114bd0d3310ef83ee2f105d6fe5 Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 2 Nov 2022 17:27:49 +0800 Subject: [PATCH 13/33] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E6=89=A3=E9=99=A4=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/SpecialAddDeductionController.java | 332 ++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 src/com/engine/salary/web/SpecialAddDeductionController.java diff --git a/src/com/engine/salary/web/SpecialAddDeductionController.java b/src/com/engine/salary/web/SpecialAddDeductionController.java new file mode 100644 index 000000000..3fb80b286 --- /dev/null +++ b/src/com/engine/salary/web/SpecialAddDeductionController.java @@ -0,0 +1,332 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SpecialAddDeductionWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +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; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 数据采集-专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + **/ +@Slf4j +public class SpecialAddDeductionController { + + private SpecialAddDeductionWrapper getSpecialAddDeductionWrapper(User user) { + return ServiceUtil.getService(SpecialAddDeductionWrapper.class, user); + } + + /** + * 数据采集-专项附加扣除列表的高级搜索 + * + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSpecialAddDeductionWrapper(user)::getSearchCondition); + } + + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::list, queryParam); + } + + + @POST + @Path("/getDetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::getDetailList, queryParam); + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).downloadTemplate(param); + String fileName = "专项附加扣除导入模板" + LocalDate.now(); + 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(); + + } catch (Exception e) { + log.error("专项附加扣除导入模板异常", e); + throw e; + } + } + + + /** + * 导出 + * + * @param + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).export(param); + + String fileName = null; + try { + fileName = URLEncoder.encode("专项附加扣除" + LocalDate.now() + ".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(); + } catch (Exception e) { + log.error("专项附加扣除导出异常", e); + throw e; + } + } + + + @GET + @Path("/exportDetail") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).exportDetail(param); + + String fileName = "专项附加扣除明细" + LocalDate.now(); + 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(); + } catch (Exception e) { + log.error("专项附加扣除明细导出异常", e); + throw e; + } + + } + + @Nullable + private SpecialAddDeductionQueryParam buildParam(HttpServletRequest request) { + SpecialAddDeductionQueryParam param = new SpecialAddDeductionQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + param.setId(Long.valueOf(id)); + } + String declareMonth = request.getParameter("declareMonth"); + if (StringUtils.isNotBlank(declareMonth)) { + param.setDeclareMonth(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + param.setDeclareMonthDate(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if (StringUtils.isNotBlank(employeeId)) { + param.setEmployeeId(Long.valueOf(employeeId)); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setJobNum(jobNum); + } + String idNo = request.getParameter("idNo"); + if (StringUtils.isNotBlank(idNo)) { + param.setIdNo(idNo); + } + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + List dates = Arrays.stream(hiredate.split(",")).map(d -> { + try { + return format.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + }).collect(Collectors.toList()); + param.setHiredate(dates); + } + String mobile = request.getParameter("mobile"); + if (StringUtils.isNotBlank(mobile)) { + param.setMobile(mobile); + } + String otherTaxExemptDeductionId = request.getParameter("otherTaxExemptDeductionId"); + if (StringUtils.isNotBlank(otherTaxExemptDeductionId)) { + param.setSpecialAddDeductionId(Long.valueOf(otherTaxExemptDeductionId)); + } + return param; + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::preview, importParam); + } + + @POST + @Path("/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::importData, importParam); + } + + /** + * @return String + * @description 编辑专项附加扣除 + * @author Harryxzy + * @date 2022/10/26 9:41 + */ + @POST + @Path("/editData") + @Produces(MediaType.APPLICATION_JSON) + public String editOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionParam otherDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::editData, otherDeductionParam); + } + + /** + * @return String + * @description 新建专项附加扣除 + * @author Harryxzy + * @date 2022/10/27 14:41 + */ + @POST + @Path("/createData") + @Produces(MediaType.APPLICATION_JSON) + public String createSpecialAddDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionParam specialAddDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::createData, specialAddDeductionParam); + } + + /** + * @return String + * @description 删除所选专项附加扣除 + * @author Harryxzy + * @date 2022/10/27 14:41 + */ + @POST + @Path("/deleteSelectData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSelectOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam otherDeductionDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteSelectData, otherDeductionDeleteParam); + } + + /** + * @return null + * @description 一键清空专项附加扣除 + * @author Harryxzy + * @date 2022/10/27 15:15 + */ + @POST + @Path("/deleteAllData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteAllOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam otherDeductionDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteAllData, otherDeductionDeleteParam); + } + + +} From fafc157e630f4415e825244bb149e7a7b027a659 Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 2 Nov 2022 17:29:44 +0800 Subject: [PATCH 14/33] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E6=89=A3=E9=99=A4=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/web/AddUpDeductionController.java | 10 + .../web/SpecialAddDeductionController.java | 8 + .../SpecialAddDeductionEncrypt.java | 99 ++++++--- .../dto/SpecialAddDeductionListDTO.java | 131 ++++++++++++ .../dto/SpecialAddDeductionRecordDTO.java | 106 +++++++++ .../param/SpecialAddDeductionImportParam.java | 31 +++ .../param/SpecialAddDeductionParam.java | 83 +++++++ .../param/SpecialAddDeductionQueryParam.java | 61 ++++++ .../po/SpecialAddDeductionPO.java | 2 + .../SpecialAddDeductionMapper.java | 25 ++- .../service/SpecialAddDeductionService.java | 111 ++++++++++ .../wrapper/SpecialAddDeductionWrapper.java | 202 ++++++++++++++++++ 12 files changed, 831 insertions(+), 38 deletions(-) create mode 100644 src/com/api/salary/web/SpecialAddDeductionController.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java create mode 100644 src/com/engine/salary/service/SpecialAddDeductionService.java create mode 100644 src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java diff --git a/src/com/api/salary/web/AddUpDeductionController.java b/src/com/api/salary/web/AddUpDeductionController.java index 37b454324..0355200b5 100644 --- a/src/com/api/salary/web/AddUpDeductionController.java +++ b/src/com/api/salary/web/AddUpDeductionController.java @@ -1,8 +1,18 @@ package com.api.salary.web; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.huawei.shade.com.alibaba.fastjson.JSON; +import com.huawei.shade.com.alibaba.fastjson.serializer.SerializerFeature; + import javax.ws.rs.Path; @Path("/bs/hrmsalary/addUpDeduction") public class AddUpDeductionController extends com.engine.salary.web.AddUpDeductionController{ + + public static void main(String[] args) { + SpecialAddDeductionParam specialAddDeductionParam = new SpecialAddDeductionParam(); + String s = JSON.toJSONString(specialAddDeductionParam, SerializerFeature.WriteNullStringAsEmpty); + System.out.println(s); + } } diff --git a/src/com/api/salary/web/SpecialAddDeductionController.java b/src/com/api/salary/web/SpecialAddDeductionController.java new file mode 100644 index 000000000..61afb7017 --- /dev/null +++ b/src/com/api/salary/web/SpecialAddDeductionController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/specialAddDeduction") +public class SpecialAddDeductionController extends com.engine.salary.web.SpecialAddDeductionController { + +} diff --git a/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java index a9935875f..d21e97b87 100644 --- a/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java +++ b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java @@ -1,8 +1,13 @@ -package com.engine.salary.encrypt.datacollection; +package com.engine.salary.encrypt.datacollection; import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -18,49 +23,75 @@ import java.util.stream.Collectors; * infant_care */ public class SpecialAddDeductionEncrypt { - public static SpecialAddDeductionPO encryptSpecialAddDeduction(SpecialAddDeductionPO po) { - if (po == null) { - return po; + private static final List FIELDS = Arrays.asList( + "childrenEducation", "continuingEducation", "supportElder", "housingLoanInterest", + "housingRent", "seriousIllnessTreatment", "infantCare"); + + public static T encrypt(T obj) { + if (obj == null) { + return obj; } - po.setChildrenEducation(AESEncryptUtil.encrypt(po.getChildrenEducation())); - po.setContinuingEducation(AESEncryptUtil.encrypt(po.getContinuingEducation())); - po.setHousingLoanInterest(AESEncryptUtil.encrypt(po.getHousingLoanInterest())); - po.setHousingRent(AESEncryptUtil.encrypt(po.getHousingRent())); - po.setSupportingElder(AESEncryptUtil.encrypt(po.getSupportingElder())); - po.setSeriousIllnessTreatment(AESEncryptUtil.encrypt(po.getSeriousIllnessTreatment())); - po.setInfantCare(AESEncryptUtil.encrypt(po.getInfantCare())); - return po; + if(obj instanceof List) { + return encrypt(obj); + } + Class clazz = obj.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + if (FIELDS.contains(field.getName())) { + try { + Object o = field.get(obj); + if (o instanceof String) { + Object value = AESEncryptUtil.encrypt((String)o); + field.set(obj, value); + } + } catch (IllegalAccessException e) { + //ignore + } + } + } + return obj; } - public static SpecialAddDeductionPO decryptSpecialAddDeduction(SpecialAddDeductionPO po) { - if (po == null) { - return po; - } - po.setChildrenEducation(AESEncryptUtil.decrypt(po.getChildrenEducation())); - po.setContinuingEducation(AESEncryptUtil.decrypt(po.getContinuingEducation())); - po.setHousingLoanInterest(AESEncryptUtil.decrypt(po.getHousingLoanInterest())); - po.setHousingRent(AESEncryptUtil.decrypt(po.getHousingRent())); - po.setSupportingElder(AESEncryptUtil.decrypt(po.getSupportingElder())); - po.setSeriousIllnessTreatment(AESEncryptUtil.decrypt(po.getSeriousIllnessTreatment())); - po.setInfantCare(AESEncryptUtil.decrypt(po.getInfantCare())); - return po; - } - - public static List encryptSpecialAddDeductionPOList(List list) { - if (null == list || list.isEmpty()) { + public static List encrypt(List list) { + if (list == null || list.isEmpty()) { return list; } - return list.stream() - .map(SpecialAddDeductionEncrypt::encryptSpecialAddDeduction) + return list.stream().map(SpecialAddDeductionEncrypt::encrypt) .collect(Collectors.toList()); } - public static List decryptSpecialAddDeductionPOList(List list) { - if (null == list || list.isEmpty()) { + public static T decrypt(T obj) { + if (obj == null) { + return obj; + } + if(obj instanceof List) { + return encrypt(obj); + } + Class clazz = obj.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + if (FIELDS.contains(field.getName())) { + try { + Object o = field.get(obj); + if (o instanceof String) { + Object value = AESEncryptUtil.decrypt((String)o); + field.set(obj, value); + } + } catch (IllegalAccessException e) { + //ignore + } + } + } + return obj; + } + + public static List decrypt(List list) { + if (list == null || list.isEmpty()) { return list; } - return list.stream() - .map(SpecialAddDeductionEncrypt::decryptSpecialAddDeduction) + return list.stream().map(SpecialAddDeductionEncrypt::decrypt) .collect(Collectors.toList()); } } diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java new file mode 100644 index 000000000..5785d22a5 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java @@ -0,0 +1,131 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-专项附加扣除列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +public class SpecialAddDeductionListDTO { + + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + //姓名 + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelProperty(index = 0) + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @ExcelProperty(index = 1) + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 2) + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 3) + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 4) + private String jobNum; + + //证件号码 + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + @ExcelProperty(index = 5) + private String idNo; + + //入职日期 + @ExcelProperty(index = 6) + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate") + @TableTitle(title = "入职日期", dataIndex = "hiredate", key = "hiredate") + private String hiredate; + + //子女教育 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation") + @TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation") + private String childrenEducation; + + //继续教育 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation") + @TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation") + private String continuingEducation; + + //住房贷款利息 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest") + @TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest") + private String housingLoanInterest; + + //住房租金 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "住房租金", width = "10%", column = "housingRent") + @TableTitle(title = "住房租金", dataIndex = "housingRent", key = "housingRent") + private String housingRent; + + //赡养老人 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder") + @TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder") + private String supportingElder; + + //大病医疗 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment") + @TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment") + private String seriousIllnessTreatment; + + //婴幼儿照护 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare") + @TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare") + private String infantCare; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + private String operate; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java new file mode 100644 index 000000000..d35dc4574 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java @@ -0,0 +1,106 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 其他免税扣除记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d98e54y6rj8", tableType = WeaTableType.CHECKBOX) +public class SpecialAddDeductionRecordDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //申报月份 + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @SalaryTableColumn(text = "申报月份", width = "10%", column = "declareMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + @TableTitle(title = "申报月份", dataIndex = "declareMonth", key = "declareMonth") + private Date declareMonth; + + //员工id + private Long employeeId; + + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + private String idNo; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + //子女教育 + @SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation") + @TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation") + private String childrenEducation; + + //继续教育 + @SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation") + @TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation") + private String continuingEducation; + + //住房贷款利息 + @SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest") + @TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest") + private String housingLoanInterest; + + //住房租金 + @SalaryTableColumn(text = "住房租金", width = "10%", column = "housingRent") + @TableTitle(title = "住房租金", dataIndex = "housingRent", key = "housingRent") + private String housingRent; + + //赡养老人 + @SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder") + @TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder") + private String supportingElder; + + //大病医疗 + @SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment") + @TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment") + private String seriousIllnessTreatment; + + //大病医疗 + @SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare") + @TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare") + private String infantCare; +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java new file mode 100644 index 000000000..231c49af7 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionImportParam { + + //上传文件id + String imageId; + + //税款所属期 + String declareMonth; + + //个税扣缴义务人 + String taxAgentId; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java new file mode 100644 index 000000000..8ef0b4816 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java @@ -0,0 +1,83 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/10/26 9:50 + * @description 数据采集-其他免税扣除 编辑参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionParam { + + // 主键id + private Long id; + + // 申报月份 + private String declareMonth; + + // 员工id + private Long employeeId; + + private String username; + + // 个税扣缴义务人 + private String taxAgentName; + + // 个税扣缴义务人id + private Long taxAgentId; + + // 部门 + private String departmentName; + + // 手机号 + private String mobile; + + private String idNo; + + // 工号 + private String jobNum; + + /** + * 子女教育 + */ + private String childrenEducation; + + /** + * 继续教育 + */ + private String continuingEducation; + + /** + * 住房贷款利息 + */ + private String housingLoanInterest; + + /** + * 住房租金 + */ + private String housingRent; + + /** + * 赡养老人 + */ + private String supportingElder; + + /** + * 大病医疗 + */ + private String seriousIllnessTreatment; + + /** + * 婴幼儿照护 + */ + private String infantCare; + + +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java new file mode 100644 index 000000000..6ab00f45f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-其他免税扣除查询参数 +public class SpecialAddDeductionQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //关键字(姓名、部门、工号) + private String keyword; + + //主键id + private Long id; + + //申报年月 + private List declareMonth; + private List declareMonthDate; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //个税扣缴义务人的主键id + private Long taxAgentId; + private Collection taxAgentIds; + + //部门id + private List departmentIds; + + //工号 + private String jobNum; + + //证件号 + private String idNo; + + //入职日期 + private List hiredate; + + //手机号 + private String mobile; + + //其他免税扣除id(获取明细) + private Long specialAddDeductionId; +} diff --git a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java index e169f7342..8c1570af7 100644 --- a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java +++ b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java @@ -5,6 +5,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; /** * 数据采集-专项附加扣除表 @@ -13,6 +14,7 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor +@Accessors(chain = true) public class SpecialAddDeductionPO { private Long id; diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java index 8d1bf1143..501189979 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java @@ -1,16 +1,33 @@ package com.engine.salary.mapper.datacollection; +import java.util.Date; -import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import org.apache.ibatis.annotations.Param; import java.util.List; public interface SpecialAddDeductionMapper { int insertSelective(SpecialAddDeductionPO record); - SpecialAddDeductionPO getById(Long id); - int updateByPrimaryKeySelective(SpecialAddDeductionPO record); - List selectAllByPO(SpecialAddDeductionPO param); + SpecialAddDeductionPO getById(Long id); + + int updateBatchSelective(@Param("list") List list); + + int batchInsert(@Param("list") List list); + + List listDtoByParam(@Param("param") SpecialAddDeductionQueryParam param); + + List listByDeclareMonthAndTaxAgentIds(@Param("declareMonth") Date declareMonth, + @Param("taxAgentIds") List taxAgentIds); + + List listByParam(@Param("param") SpecialAddDeductionQueryParam param); + + int deleteByIds(@Param("ids")List id); + + } \ No newline at end of file diff --git a/src/com/engine/salary/service/SpecialAddDeductionService.java b/src/com/engine/salary/service/SpecialAddDeductionService.java new file mode 100644 index 000000000..18025b7bb --- /dev/null +++ b/src/com/engine/salary/service/SpecialAddDeductionService.java @@ -0,0 +1,111 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-其他免税扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +public interface SpecialAddDeductionService { + + /** + * 通过id获取单条专项扣除记录 + * + * @param id + * @return + */ + SpecialAddDeductionPO getById(Long id); + + /** + * 数据采集-其他免税扣除列表 + * + * @param queryParam + * @return + */ + PageInfo listPage(SpecialAddDeductionQueryParam queryParam); + + /** + * 获取数据采集-其他免税扣除详情 + * + * @param queryParam + * @return + */ + PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam); + + /** + * 导出 + * + */ + XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam); + + /** + * 导出详情 + * + */ + XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam queryParam); + + /** + * 下载导入模板 + * + * @param param + * @return + */ + XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam param); + + /** + * 预览 + */ + Map preview(SpecialAddDeductionImportParam importParam); + + /** + * 导入数据 + */ + Map importData(SpecialAddDeductionImportParam importParam); + + + + /** + * 获取其他免税扣除数据 + * + * @param declareMonth + * @param employeeIds + * @return + */ + List getSpecialAddDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId); + + /** + * 编辑数据 + */ + void editData(SpecialAddDeductionParam SpecialAddDeductionParam); + + /** + * 新增数据 + */ + void createData(SpecialAddDeductionParam SpecialAddDeductionParam); + + /** + * 删除所选数据 + */ + void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam); + + /** + * 一键清空数据 + */ + void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam); +} diff --git a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java new file mode 100644 index 000000000..feb244d3f --- /dev/null +++ b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java @@ -0,0 +1,202 @@ +package com.engine.salary.wrapper; + +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SpecialAddDeductionService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.SpecialAddDeductionServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 专项附加扣除 + */ +public class SpecialAddDeductionWrapper extends Service { + private SpecialAddDeductionService getSpecialAddDeductionService(User user) { + return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user); + } + private TaxAgentService getTaxAgentV2Service(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + /** + * 数据采集-专项附加扣除列表的高级搜索 + * + * @return + */ + public Map getSearchCondition() { + Map apidatas = new HashMap<>(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentName", "4"); + departmentName.setInputType("browser"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + conditionItems.add(departmentName); + + + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2); + jobNum.setFieldcol(16); + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); + jobNum.setLabel("工号"); + conditionItems.add(jobNum); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + /** + * 数据采集-专项附加扣除列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo list(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).listPage(queryParam); + + } + + /** + * 数据采集-专项附加扣除详情列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo getDetailList(SpecialAddDeductionQueryParam queryParam) { + Long id = queryParam.getSpecialAddDeductionId(); + + SpecialAddDeductionPO po = getSpecialAddDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "专项附加扣除不存在") + "[id:%s]", id)); + } + queryParam.setEmployeeId(po.getEmployeeId()); + + return getSpecialAddDeductionService(user).recordListPage(queryParam); + } + + /** + * 导出-专项附加扣除列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).export(queryParam); + } + + /** + * 导出-专项附加扣除详情列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam queryParam) { + Long id = queryParam.getSpecialAddDeductionId(); + SpecialAddDeductionPO po = getSpecialAddDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel( 100415, "专项附加扣除不存在") + "[id:%s]", id)); + } + return getSpecialAddDeductionService(user).exportDetail(queryParam); + } + + /** + * 下载导入模板 + * + * @param queryParam + * @return + */ + public XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).export(queryParam); + } + + /** + * 预览 + */ + public Map preview(SpecialAddDeductionImportParam importParam){ + return getSpecialAddDeductionService(user).preview(importParam); + } + + /** + * 导入数据 + */ + public Map importData(SpecialAddDeductionImportParam importParam){ + return getSpecialAddDeductionService(user).importData(importParam); + } + + /** + * 编辑数据 + */ + public void editData(SpecialAddDeductionParam specialAddDeductionParam) { + getSpecialAddDeductionService(user).editData(specialAddDeductionParam); + } + + + /** + * 新增数据 + */ + public void createData(SpecialAddDeductionParam specialAddDeductionParam) { + getSpecialAddDeductionService(user).createData(specialAddDeductionParam); + } + + /** + * 删除所选数据 + */ + public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) { + getSpecialAddDeductionService(user).deleteSelectData(deleteParam); + } + + /** + * 一键清空所有数据 + */ + public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) { + getSpecialAddDeductionService(user).deleteAllData(deleteParam); + } +} From 92a6512dc854583a286ef6f1b80e6acefeb6114d Mon Sep 17 00:00:00 2001 From: fcli Date: Fri, 4 Nov 2022 09:41:32 +0800 Subject: [PATCH 15/33] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E6=89=A3=E9=99=A4=E6=A8=A1=E5=9D=97,=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E6=9C=88=E4=BB=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E6=9C=AC=E4=BA=BA=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/biz/SpecialAddDeductionBiz.java | 15 +- .../dto/SpecialAddDeductionRecordDTO.java | 6 - .../param/SpecialAddDeductionImportParam.java | 3 - .../param/SpecialAddDeductionParam.java | 3 - .../param/SpecialAddDeductionQueryParam.java | 4 - .../po/SpecialAddDeductionPO.java | 5 - .../SpecialAddDeductionMapper.java | 4 +- .../SpecialAddDeductionMapper.xml | 54 +----- .../impl/SpecialAddDeductionServiceImpl.java | 165 ++++-------------- .../web/SpecialAddDeductionController.java | 5 - .../wrapper/SpecialAddDeductionWrapper.java | 4 +- 11 files changed, 55 insertions(+), 213 deletions(-) diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java index c505a964e..ab63a4540 100644 --- a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -1,6 +1,7 @@ package com.engine.salary.biz; import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; @@ -37,10 +38,18 @@ public class SpecialAddDeductionBiz extends BaseBean { } } - public List listByDeclareMonthAndTaxAgentIds(Date declareMonth, List taxAgentIds) { + public List listByParam(SpecialAddDeductionQueryParam param) { try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); - List pos = mapper.listByDeclareMonthAndTaxAgentIds(declareMonth, taxAgentIds); + List specialAddDeductionListDTOS = mapper.listByParam(param); + return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionListDTOS); + } + } + + public List listByTaxAgentIds(List taxAgentIds) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List pos = mapper.listByTaxAgentIds(taxAgentIds); return SpecialAddDeductionEncrypt.decrypt(pos); } } @@ -107,7 +116,7 @@ public class SpecialAddDeductionBiz extends BaseBean { ArrayList::new) ); // 查询已有数据 - List list = listByDeclareMonthAndTaxAgentIds(po.getDeclareMonth(), null); + List list = listByTaxAgentIds(null); // 待修改的 本地已存在则更新【交集】 List updateList = list.stream() .map(m -> finalPos.stream() diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java index d35dc4574..a7cb63bac 100644 --- a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java @@ -31,12 +31,6 @@ public class SpecialAddDeductionRecordDTO { @SalaryTableColumn(column = "id", display = false) private Long id; - //申报月份 - @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") - @SalaryTableColumn(text = "申报月份", width = "10%", column = "declareMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") - @TableTitle(title = "申报月份", dataIndex = "declareMonth", key = "declareMonth") - private Date declareMonth; - //员工id private Long employeeId; diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java index 231c49af7..d221c7a69 100644 --- a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java @@ -22,9 +22,6 @@ public class SpecialAddDeductionImportParam { //上传文件id String imageId; - //税款所属期 - String declareMonth; - //个税扣缴义务人 String taxAgentId; diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java index 8ef0b4816..76408c9d4 100644 --- a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java @@ -19,9 +19,6 @@ public class SpecialAddDeductionParam { // 主键id private Long id; - // 申报月份 - private String declareMonth; - // 员工id private Long employeeId; diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java index 6ab00f45f..a9e887bb7 100644 --- a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java @@ -27,10 +27,6 @@ public class SpecialAddDeductionQueryParam extends BaseQueryParam { //主键id private Long id; - //申报年月 - private List declareMonth; - private List declareMonthDate; - //姓名 private String username; diff --git a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java index 8c1570af7..32cfe786b 100644 --- a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java +++ b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java @@ -28,11 +28,6 @@ public class SpecialAddDeductionPO { */ private Long taxAgentId; - /** - * 申报年月 - */ - private Date declareMonth; - /** * 子女教育 */ diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java index 501189979..8d097b221 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java @@ -1,5 +1,4 @@ package com.engine.salary.mapper.datacollection; -import java.util.Date; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; @@ -22,8 +21,7 @@ public interface SpecialAddDeductionMapper { List listDtoByParam(@Param("param") SpecialAddDeductionQueryParam param); - List listByDeclareMonthAndTaxAgentIds(@Param("declareMonth") Date declareMonth, - @Param("taxAgentIds") List taxAgentIds); + List listByTaxAgentIds(@Param("taxAgentIds") List taxAgentIds); List listByParam(@Param("param") SpecialAddDeductionQueryParam param); diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml index 01cdbc987..657985390 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -7,7 +7,6 @@ - @@ -26,7 +25,6 @@ t1.id, t1.employee_id, t1.tax_agent_id, - t1.declare_month, t1.children_education, t1.continuing_education, t1.housing_loan_interest, @@ -43,7 +41,6 @@ t1.id, - t1.declare_month, t1.employee_id, t2.id AS tax_agent_id, t2.name AS tax_agent_name, @@ -81,15 +78,6 @@ OR e.workcode like CONCAT('%',#{param.keyword},'%') ) - - - - AND t1.declare_month = #{param.declareMonthDate[0]} - - - AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) - - AND e.lastname like CONCAT('%',#{param.username},'%') @@ -144,15 +132,6 @@ ) - - - AND t1.declare_month = #{param.declareMonthDate[0]} - - - AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) - - - AND e.lastname like '%'||#{param.username}||'%' @@ -205,15 +184,6 @@ ) - - - AND t1.declare_month = #{param.declareMonthDate[0]} - - - AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) - - - AND e.lastname like '%'+#{param.username}+'%' @@ -268,9 +238,6 @@ tax_agent_id, - - declare_month, - children_education, @@ -313,9 +280,6 @@ #{taxAgentId,jdbcType=BIGINT}, - - #{declareMonth,jdbcType=TIMESTAMP}, - #{childrenEducation,jdbcType=VARCHAR}, @@ -363,9 +327,6 @@ tax_agent_id = #{taxAgentId,jdbcType=BIGINT}, - - declare_month = #{declareMonth,jdbcType=TIMESTAMP}, - children_education = #{childrenEducation,jdbcType=VARCHAR}, @@ -424,13 +385,6 @@ - - - - when id = #{item.id,jdbcType=BIGINT} then #{item.declareMonth,jdbcType=TIMESTAMP} - - - @@ -525,13 +479,12 @@ insert into hrsa_special_add_deduction - (employee_id, tax_agent_id, declare_month, children_education, continuing_education, + (employee_id, tax_agent_id, children_education, continuing_education, housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, infant_care, create_time, update_time, creator, delete_type, tenant_key) values (#{item.employeeId,jdbcType=BIGINT}, #{item.taxAgentId,jdbcType=BIGINT}, - #{item.declareMonth,jdbcType=TIMESTAMP}, #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, @@ -560,7 +513,7 @@ - select from hrsa_special_add_deduction t1 @@ -570,7 +523,6 @@ t1.delete_type = 0 AND t2.delete_type = 0 AND e.status not in (7) and (e.accounttype is null or e.accounttype = 0) - and declare_month=#{declareMonth,jdbcType=TIMESTAMP} AND t1.tax_agent_id IN @@ -592,7 +544,7 @@ AND e.status not in (7) and (e.accounttype is null or e.accounttype = 0) - order by t1.declare_month desc + order by t1.create_time desc diff --git a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java index f658c66cb..ae3214328 100644 --- a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java @@ -15,11 +15,11 @@ import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeTaxAgentDTO; import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.exception.SalaryRunTimeException; -import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.service.AddUpDeductionService; import com.engine.salary.service.SalaryEmployeeService; @@ -29,10 +29,8 @@ import com.engine.salary.sys.entity.po.SalarySysConfPO; import com.engine.salary.sys.entity.vo.OrderRuleVO; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; -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.excel.ExcelComment; import com.engine.salary.util.excel.ExcelParseHelper; import com.engine.salary.util.excel.ExcelUtil; @@ -59,8 +57,8 @@ import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TEN public class SpecialAddDeductionServiceImpl extends Service implements SpecialAddDeductionService { - private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { - return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + private SpecialAddDeductionBiz getSpecialAddDeductionMapper() { + return new SpecialAddDeductionBiz(); } private TaxAgentService getTaxAgentService(User user) { @@ -91,13 +89,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd @Override public PageInfo listPage(SpecialAddDeductionQueryParam queryParam) { - //申报月份 - List declareMonth = queryParam.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } - //排序配置 OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); queryParam.setOrderRule(orderRule); @@ -106,16 +97,10 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); if (needAuth) { - List taxAgentIdsAsAdmin = getTaxAgentService(user) - .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { - return new PageInfo<>(SpecialAddDeductionListDTO.class); - } - queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + putQueryRange(queryParam, employeeId); } SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getSpecialAddDeductionMapper().listByParam(queryParam); - SpecialAddDeductionEncrypt.decrypt(list); return new PageInfo<>(list, SpecialAddDeductionListDTO.class); } @@ -123,29 +108,35 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd public PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam) { long employeeId = user.getUID(); - //申报月份 - List declareMonth = queryParam.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } - Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); if (needAuth) { - List taxAgentIdsAsAdmin = getTaxAgentService(user) - .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId) - .collect(Collectors.toList()); - if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { - return new PageInfo<>(SpecialAddDeductionRecordDTO.class); - } - queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + putQueryRange(queryParam, employeeId); } SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); - List list = getSpecialAddDeductionMapper().listDtoByParam(queryParam); - SpecialAddDeductionEncrypt.decrypt(list); + List list = getSpecialAddDeductionMapper().listDTOByParam(queryParam); return new PageInfo<>(list, SpecialAddDeductionRecordDTO.class); } + private void putQueryRange(SpecialAddDeductionQueryParam queryParam, long employeeId) { + List taxAgentIdsAsAdmin = getTaxAgentService(user) + .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { + // 不是个税扣缴义务人管理员,限定搜索范围为当前登录人 + List taxAgentIdsAsEmployee = getTaxAgentService(user) + .listAllTaxAgentsAsRange(Collections.singletonList(employeeId)) + .stream().filter(t -> t.getEmployeeId().equals(employeeId)) + .map(TaxAgentEmployeeTaxAgentDTO::getTaxAgentIds) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + queryParam.setTaxAgentIds(taxAgentIdsAsEmployee); + queryParam.setEmployeeId(employeeId); + } else { + //管理员设置相应的个税扣缴义务人来筛选 + queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + } + } + @Override public Map preview(SpecialAddDeductionImportParam importParam) { @@ -188,8 +179,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd //excel文件id String imageId = Util.null2String(importParam.getImageId()); Validate.notBlank(imageId, "imageId为空"); - //税款所属期 - String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); //个税扣缴义务人 String taxAgentId = Util.null2String(importParam.getTaxAgentId()); @@ -207,14 +196,9 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd List employees = employBiz.listEmployee(); // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); - //税款所属期 - Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); - // 获取已经核算的数据 - List salaryAcctEmployees = getAddUpDeductionService(user) - .getAccountedEmployeeData(declareMonthStr); // 查询已有数据 List list = getSpecialAddDeductionMapper() - .listByDeclareMonthAndTaxAgentIds(declareMonth, null); + .listByTaxAgentIds(null); // 错误excel内容 List errorData = new ArrayList<>(); @@ -231,7 +215,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd .createTime(now) .updateTime(now) .creator((long) user.getUID()) - .declareMonth(declareMonth).build(); + .build(); //异常点数量 int errorSum = 0; @@ -328,25 +312,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd //fixme 分权判断 -// - // 判断是否有核算过 - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - SpecialAddDeductionPO finalPo = po; - Optional optionalAcctEmp = - salaryAcctEmployees.stream() - .filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())) - .findFirst(); - boolean isExist = list.stream() - .anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); - if (optionalAcctEmp.isPresent() && isExist) { - Map errorMessageMap = new HashMap(); - errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入"); - errorData.add(errorMessageMap); - errorSum += 1; - } - } - - if (errorSum == 0) { successCount += 1; // 合格数据 @@ -373,20 +338,14 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd private void checkImportParam(SpecialAddDeductionImportParam importParam) { //excel文件id String imageId = Util.null2String(importParam.getImageId()); - //税款所属期 - String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); //个税扣缴义务人 String taxAgentId = Util.null2String(importParam.getTaxAgentId()); if (StringUtils.isBlank(imageId)) { throw new SalaryRunTimeException("文件不存在"); } - if (StringUtils.isBlank(declareMonthStr)) { - throw new SalaryRunTimeException("税款所属期为空"); - } } - /** * 导出 * @@ -416,15 +375,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); param.setOrderRule(orderRule); - //申报月份 - List declareMonth = param.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } - List list = getSpecialAddDeductionMapper().listByParam(param); - SpecialAddDeductionEncrypt.decrypt(list); // 开启分权并且不是薪酬模块总管理员 if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) { List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); @@ -492,19 +443,13 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd //构建参数 param.setEmployeeId(po.getEmployeeId()); - //申报月份 - List declareMonth = param.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } //获取操作按钮资源 List> rowList = getExcelRowDetailList(param); //获取excel - return ExcelUtil.genWorkbook(rowList, "其他免税扣除明细"); + return ExcelUtil.genWorkbook(rowList, "专项附加扣除明细"); } @@ -516,18 +461,17 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd */ private List> getExcelRowDetailList(SpecialAddDeductionQueryParam param) { //excel标题 - List title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "手机号", "工号", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); //查询详细信息 - List list = getSpecialAddDeductionMapper().listDtoByParam(param); + List list = getSpecialAddDeductionMapper().listDTOByParam(param); SpecialAddDeductionEncrypt.decrypt(list); final List> dataRowList = Optional.ofNullable(list) .map(List::stream) .map(operatorStream -> operatorStream.map(dto -> { List cellList = new ArrayList<>(); cellList.add(Util.null2String(dto.getUsername())); - cellList.add(Util.null2String(dto.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth()))); cellList.add(Util.null2String(dto.getTaxAgentName())); cellList.add(Util.null2String(dto.getDepartmentName())); cellList.add(Util.null2String(dto.getMobile())); @@ -556,12 +500,11 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传")); } SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); - return SpecialAddDeductionBiz.listByDeclareMonthAndTaxAgentIds(SalaryDateUtil.toDateStartOfMonth(declareMonth), null); + return SpecialAddDeductionBiz.listByTaxAgentIds(null); } @Override public void editData(SpecialAddDeductionParam specialAddDeductionParam) { - String declareMonthStr = specialAddDeductionParam.getDeclareMonth(); SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); Long currentEmployeeId = (long) user.getUID(); @@ -573,24 +516,11 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd throw new SalaryRunTimeException("该数据不存在!"); } Long taxAgentId = byId.getTaxAgentId(); - boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId(), taxAgentId)); if (!canEdit) { //没有编辑权限 throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); } - // 获取已经核算的数据 - List salaryAcctEmployees = - getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); - // 判断是否有核算过 - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - Optional optionalAcctEmp = - salaryAcctEmployees.stream() - .filter(f -> f.getEmployeeId().equals(specialAddDeductionParam.getEmployeeId()) && f.getTaxAgentId().equals(specialAddDeductionParam.getTaxAgentId())) - .findFirst(); - if (optionalAcctEmp.isPresent()) { - throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!"); - } - } ArrayList updateList = new ArrayList<>(); SpecialAddDeductionPO build = SpecialAddDeductionPO.builder() .id(specialAddDeductionParam.getId()) @@ -613,18 +543,12 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; - //税款所属期 - String declareMonthStr = Util.null2String(specialAddDeductionParam.getDeclareMonth()); //人员信息 List employees = employBiz.listEmployee(); // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); - //税款所属期 - Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); - // 获取已经核算的数据 - List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); // 查询已有数据 - List list = getSpecialAddDeductionMapper().listByDeclareMonthAndTaxAgentIds(declareMonth, null); + List list = getSpecialAddDeductionMapper().listByTaxAgentIds(null); //合规数据 List insertData = new ArrayList<>(); Date now = new Date(); @@ -634,7 +558,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd .createTime(now) .updateTime(now) .creator((long) user.getUID()) - .declareMonth(declareMonth).build(); + .build(); //筛选导入人员信息可以在人力资源池中匹配到的人员信息 boolean employeeSameId = employees.stream() @@ -656,8 +580,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } } - - //商业健康保险 + //数据填充 po.setContinuingEducation(specialAddDeductionParam.getContinuingEducation()) .setChildrenEducation(specialAddDeductionParam.getChildrenEducation()) .setHousingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) @@ -666,20 +589,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd .setSeriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment()) .setInfantCare(specialAddDeductionParam.getInfantCare()); //fixme 分权判断 - - // 判断是否有核算过 - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - SpecialAddDeductionPO finalPo = po; - Optional optionalAcctEmp = - salaryAcctEmployees.stream() - .filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())) - .findFirst(); - boolean isExist = list.stream() - .anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); - if (optionalAcctEmp.isPresent() && isExist) { - throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入"); - } - } insertData.add(po); //入库 SpecialAddDeductionBiz.handleImportData(insertData); @@ -756,7 +665,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd taxAgentIds = tai; } // 获取所有想要删除的数据 - List list = specialAddDeductionBiz.listByDeclareMonthAndTaxAgentIds(declareMonthDate, taxAgentIds); + List list = specialAddDeductionBiz.listByTaxAgentIds(taxAgentIds); // 获取已经核算的数据 List salaryAcctEmployees = getAddUpDeductionService(user) .getAccountedEmployeeData(declareMonthStr); diff --git a/src/com/engine/salary/web/SpecialAddDeductionController.java b/src/com/engine/salary/web/SpecialAddDeductionController.java index 3fb80b286..49416aa62 100644 --- a/src/com/engine/salary/web/SpecialAddDeductionController.java +++ b/src/com/engine/salary/web/SpecialAddDeductionController.java @@ -202,11 +202,6 @@ public class SpecialAddDeductionController { if (StringUtils.isNotBlank(id)) { param.setId(Long.valueOf(id)); } - String declareMonth = request.getParameter("declareMonth"); - if (StringUtils.isNotBlank(declareMonth)) { - param.setDeclareMonth(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - param.setDeclareMonthDate(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } String username = request.getParameter("username"); if (StringUtils.isNotBlank(username)) { diff --git a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java index feb244d3f..270022b3f 100644 --- a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java @@ -53,9 +53,9 @@ public class SpecialAddDeductionWrapper extends Service { ConditionFactory conditionFactory = new ConditionFactory(user); //条件组 - List addGroups = new ArrayList(); + List addGroups = new ArrayList<>(); - List conditionItems = new ArrayList(); + List conditionItems = new ArrayList<>(); //文本输入框 SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); From 9b77bf7139bd129785fdb5b0fbf1767cbe8b21b1 Mon Sep 17 00:00:00 2001 From: fcli Date: Fri, 4 Nov 2022 15:16:27 +0800 Subject: [PATCH 16/33] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E6=89=A3=E9=99=A4=E6=A8=A1=E5=9D=97,=20=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E6=B8=85=E7=A9=BA=E3=80=81=E5=88=86=E9=A1=B5bug?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/web/AddUpDeductionController.java | 6 -- .../salary/biz/SpecialAddDeductionBiz.java | 38 ++++++--- .../SpecialAddDeductionRecordDeleteParam.java | 25 ++++++ .../SpecialAddDeductionMapper.java | 2 + .../SpecialAddDeductionMapper.xml | 37 ++++++--- .../salary/service/AddUpDeductionService.java | 7 ++ .../service/SpecialAddDeductionService.java | 13 +-- .../impl/AddUpDeductionServiceImpl.java | 29 +++++++ .../impl/SpecialAddDeductionServiceImpl.java | 81 ++++++++----------- .../salary/web/AddUpDeductionController.java | 11 +++ .../web/SpecialAddDeductionController.java | 31 +++---- .../salary/wrapper/AddUpDeductionWrapper.java | 7 ++ .../wrapper/SpecialAddDeductionWrapper.java | 19 +++-- 13 files changed, 199 insertions(+), 107 deletions(-) create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java diff --git a/src/com/api/salary/web/AddUpDeductionController.java b/src/com/api/salary/web/AddUpDeductionController.java index 0355200b5..6e89b73c7 100644 --- a/src/com/api/salary/web/AddUpDeductionController.java +++ b/src/com/api/salary/web/AddUpDeductionController.java @@ -9,10 +9,4 @@ import javax.ws.rs.Path; @Path("/bs/hrmsalary/addUpDeduction") public class AddUpDeductionController extends com.engine.salary.web.AddUpDeductionController{ - - public static void main(String[] args) { - SpecialAddDeductionParam specialAddDeductionParam = new SpecialAddDeductionParam(); - String s = JSON.toJSONString(specialAddDeductionParam, SerializerFeature.WriteNullStringAsEmpty); - System.out.println(s); - } } diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java index ab63a4540..b841a12d0 100644 --- a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -6,6 +6,8 @@ import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.SalaryPageUtil; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import org.apache.ibatis.session.SqlSession; @@ -16,6 +18,10 @@ import java.util.*; import java.util.stream.Collectors; public class SpecialAddDeductionBiz extends BaseBean { + private SpecialAddDeductionMapper mapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + /** * 根据id获取 * @@ -31,19 +37,14 @@ public class SpecialAddDeductionBiz extends BaseBean { } public List listDTOByParam(SpecialAddDeductionQueryParam param) { - try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { - SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); - List specialAddDeductionRecordDTOS = mapper.listDtoByParam(param); - return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionRecordDTOS); - } + List specialAddDeductionRecordDTOS = mapper().listDtoByParam(param); + return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionRecordDTOS); } + public List listByParam(SpecialAddDeductionQueryParam param) { - try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { - SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); - List specialAddDeductionListDTOS = mapper.listByParam(param); - return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionListDTOS); - } + List specialAddDeductionListDTOS = mapper().listByParam(param); + return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionListDTOS); } public List listByTaxAgentIds(List taxAgentIds) { @@ -111,9 +112,9 @@ public class SpecialAddDeductionBiz extends BaseBean { // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) List finalPos = pos.stream() .collect(Collectors.collectingAndThen( - Collectors.toCollection(() -> - new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), - ArrayList::new) + Collectors.toCollection(() -> + new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), + ArrayList::new) ); // 查询已有数据 List list = listByTaxAgentIds(null); @@ -156,4 +157,15 @@ public class SpecialAddDeductionBiz extends BaseBean { sqlSession.commit(); } } + + public List getByEmployeeId(List employeeIds, Long taxAgentId) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return mapper().getByEmployeeIds(employeeIds, taxAgentId) + .stream() + .filter(Objects::nonNull) + .filter(s -> s.getEmployeeId() != null) + .collect(Collectors.toList()); + } } diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java new file mode 100644 index 000000000..58332b91a --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author lfc + * @description 专项附加扣-除删除参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionRecordDeleteParam { + + // 删除id + private List ids; + + // 个税扣缴义务人 + private String taxAgentId; +} diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java index 8d097b221..0915acf16 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java @@ -28,4 +28,6 @@ public interface SpecialAddDeductionMapper { int deleteByIds(@Param("ids")List id); + List getByEmployeeIds(@Param("employeeIds") List employeeIds, + @Param("taxAgentId") Long taxAgentId); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml index 657985390..e3472dfc5 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -66,6 +66,9 @@ #{id} + + AND t1.id = #{param.specialAddDeductionId} + AND t1.employee_id = #{param.employeeId} @@ -119,6 +122,9 @@ #{id} + + AND t1.id = #{param.specialAddDeductionId} + AND t1.employee_id = #{param.employeeId} @@ -171,6 +177,9 @@ #{id} + + AND t1.id = #{param.specialAddDeductionId} + AND t1.employee_id = #{param.employeeId} @@ -217,10 +226,6 @@ - - - - @@ -556,4 +560,19 @@ ) and delete_type = 0 + + \ No newline at end of file diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java index 1b4a7aba7..6596ad887 100644 --- a/src/com/engine/salary/service/AddUpDeductionService.java +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -147,4 +147,11 @@ public interface AddUpDeductionService { * @date 2022/10/31 11:33 */ AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam id); + + /** + * 自动累计专项附加扣除 + * @return void + * @author lfc + */ + void autoAddAll(); } diff --git a/src/com/engine/salary/service/SpecialAddDeductionService.java b/src/com/engine/salary/service/SpecialAddDeductionService.java index 18025b7bb..543679d55 100644 --- a/src/com/engine/salary/service/SpecialAddDeductionService.java +++ b/src/com/engine/salary/service/SpecialAddDeductionService.java @@ -2,10 +2,7 @@ package com.engine.salary.service; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -102,10 +99,14 @@ public interface SpecialAddDeductionService { /** * 删除所选数据 */ - void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam); + void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam); /** * 一键清空数据 */ - void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam); + void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam); + + List getSpecialAddDeductionPOByEmployee(List employeeId, Long taxAgentId); + + SpecialAddDeductionRecordDTO getRecordById(Long id); } diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index e7086f94c..207654f8f 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -20,6 +20,7 @@ import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam; import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.taxagent.bo.TaxAgentBO; @@ -59,6 +60,7 @@ import weaver.hrm.User; import java.io.InputStream; import java.text.SimpleDateFormat; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.YearMonth; import java.util.*; import java.util.stream.Collectors; @@ -102,6 +104,10 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); } + private SpecialAddDeductionService getSpecialAddDeductionService(User user) { + return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user); + } + @Override public Map getSearchCondition(Map params) { Map apidatas = new HashMap(); @@ -629,6 +635,29 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction return addUpDeductionRecordDTOS.get(0); } + @Override + public void autoAddAll() { + int uid = user.getUID(); + Collection taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) uid); + for (TaxAgentPO taxAgent : taxAgents) { + Collection employeeIds = getTaxAgentService(user) + .listEmployeeIdsInTaxAgent(taxAgent.getId()); + List employeePOs = getSpecialAddDeductionService(user) + .getSpecialAddDeductionPOByEmployee(new ArrayList<>(employeeIds), taxAgent.getId()); + Map> lastEmpInfo = getLastEmpInfo(taxAgent, employeePOs); + + } + } + + private Map> getLastEmpInfo(TaxAgentPO taxAgent, List employeePOs) { + LocalDateTime lastMonthDateTime = LocalDateTime.now().minusMonths(1); + YearMonth lastMonth = YearMonth.of(lastMonthDateTime.getYear(), lastMonthDateTime.getMonth()); + List addUpDeductionList = getAddUpDeductionList(lastMonth, + employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()), + taxAgent.getId()); + return addUpDeductionList.stream().collect(Collectors.groupingBy(AddUpDeduction::getEmployeeId)); + } + private void checkImportParam(AddUpDeductionImportParam importParam) { diff --git a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java index ae3214328..dbc68250e 100644 --- a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java @@ -9,17 +9,14 @@ import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; -import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeTaxAgentDTO; import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.service.AddUpDeductionService; import com.engine.salary.service.SalaryEmployeeService; @@ -31,6 +28,7 @@ import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelComment; import com.engine.salary.util.excel.ExcelParseHelper; import com.engine.salary.util.excel.ExcelUtil; @@ -57,10 +55,14 @@ import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TEN public class SpecialAddDeductionServiceImpl extends Service implements SpecialAddDeductionService { - private SpecialAddDeductionBiz getSpecialAddDeductionMapper() { + private SpecialAddDeductionBiz getSpecialAddDeductionBiz() { return new SpecialAddDeductionBiz(); } + private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + private TaxAgentService getTaxAgentService(User user) { return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } @@ -83,7 +85,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd @Override public SpecialAddDeductionPO getById(Long id) { - return getSpecialAddDeductionMapper().getById(id); + return getSpecialAddDeductionBiz().getById(id); } @@ -101,6 +103,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd } SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getSpecialAddDeductionMapper().listByParam(queryParam); + SpecialAddDeductionEncrypt.decrypt(list); return new PageInfo<>(list, SpecialAddDeductionListDTO.class); } @@ -113,7 +116,9 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd putQueryRange(queryParam, employeeId); } SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); - List list = getSpecialAddDeductionMapper().listDTOByParam(queryParam); + List list = getSpecialAddDeductionMapper().listDtoByParam(queryParam); + SpecialAddDeductionEncrypt.decrypt(list); + return new PageInfo<>(list, SpecialAddDeductionRecordDTO.class); } @@ -197,7 +202,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); // 查询已有数据 - List list = getSpecialAddDeductionMapper() + List list = getSpecialAddDeductionBiz() .listByTaxAgentIds(null); // 错误excel内容 @@ -375,7 +380,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); param.setOrderRule(orderRule); - List list = getSpecialAddDeductionMapper().listByParam(param); + List list = getSpecialAddDeductionBiz().listByParam(param); // 开启分权并且不是薪酬模块总管理员 if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) { List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); @@ -465,7 +470,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); //查询详细信息 - List list = getSpecialAddDeductionMapper().listDTOByParam(param); + List list = getSpecialAddDeductionBiz().listDTOByParam(param); SpecialAddDeductionEncrypt.decrypt(list); final List> dataRowList = Optional.ofNullable(list) .map(List::stream) @@ -548,7 +553,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); // 查询已有数据 - List list = getSpecialAddDeductionMapper().listByTaxAgentIds(null); + List list = getSpecialAddDeductionBiz().listByTaxAgentIds(null); //合规数据 List insertData = new ArrayList<>(); Date now = new Date(); @@ -595,19 +600,13 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd } @Override - public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) { + public void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam) { long currentEmployeeId = user.getUID(); // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); - String declareMonthStr = deleteParam.getDeclareMonth(); List deleteIds = deleteParam.getIds(); - // 已经核算过的不可操作 - // 获取已经核算的数据 - List salaryAcctEmployees = - getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); - // 判断是否有核算过 List deleteList = new ArrayList<>(); for (Long id : deleteIds) { SpecialAddDeductionPO byId = SpecialAddDeductionBiz.getById(id); @@ -621,37 +620,20 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd if (isNotInRegion) { throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } - // 判断用户是否存在 - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - Optional optionalAcctEmp = - salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst(); - if (optionalAcctEmp.isPresent()) { - throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!"); - } - } deleteList.add(byId.getId()); } SpecialAddDeductionBiz.batchDeleteByIds(deleteList); } @Override - public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) { - String declareMonthStr = deleteParam.getDeclareMonth(); - long currentEmployeeId = user.getUID(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + public void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam) { // 获取所有个税扣缴义务人 Collection taxAgentList = - getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + getTaxAgentService(user).listTaxAgentAndEmployeeTree((long) user.getUID()); List taxAgentIds = taxAgentList.stream() .map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId) .collect(Collectors.toList()); SpecialAddDeductionBiz specialAddDeductionBiz = new SpecialAddDeductionBiz(); - Date declareMonthDate = null; - try { - declareMonthDate = sdf.parse(declareMonthStr + "-01"); - } catch (Exception e) { - throw new SalaryRunTimeException("日期异常"); - } if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) { // 设置了个税扣缴义务人 @@ -666,21 +648,22 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd } // 获取所有想要删除的数据 List list = specialAddDeductionBiz.listByTaxAgentIds(taxAgentIds); - // 获取已经核算的数据 - List salaryAcctEmployees = getAddUpDeductionService(user) - .getAccountedEmployeeData(declareMonthStr); - for (SpecialAddDeductionPO item : list) { - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); - if (optionalAcctEmp.isPresent()) { - throw new SalaryRunTimeException("有员工在该年月中已经完成核算并归档,不能进行一键清空!"); - } - } - } List deleteIds = list.stream().map(SpecialAddDeductionPO::getId).collect(Collectors.toList()); specialAddDeductionBiz.batchDeleteByIds(deleteIds); } + @Override + public List getSpecialAddDeductionPOByEmployee(List employeeId, Long taxAgentId) { + return getSpecialAddDeductionBiz().getByEmployeeId(employeeId, taxAgentId); + } + + @Override + public SpecialAddDeductionRecordDTO getRecordById(Long id) { + return getSpecialAddDeductionBiz() + .listDTOByParam(SpecialAddDeductionQueryParam.builder().specialAddDeductionId(id).build()) + .stream().findFirst().orElse(null); + } + @Override public XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam param) { // 1.工作簿名称 diff --git a/src/com/engine/salary/web/AddUpDeductionController.java b/src/com/engine/salary/web/AddUpDeductionController.java index 894fbc81d..d97aaaed3 100644 --- a/src/com/engine/salary/web/AddUpDeductionController.java +++ b/src/com/engine/salary/web/AddUpDeductionController.java @@ -340,4 +340,15 @@ public class AddUpDeductionController { } + /** + * 一键自动累计 + * @return + */ + @POST + @Path("/autoAddAll") + @Produces(MediaType.APPLICATION_JSON) + public String autoAddAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, user); + } } diff --git a/src/com/engine/salary/web/SpecialAddDeductionController.java b/src/com/engine/salary/web/SpecialAddDeductionController.java index 49416aa62..940ab5ede 100644 --- a/src/com/engine/salary/web/SpecialAddDeductionController.java +++ b/src/com/engine/salary/web/SpecialAddDeductionController.java @@ -5,7 +5,6 @@ import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.util.ResponseResult; -import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.wrapper.SpecialAddDeductionWrapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -74,10 +73,19 @@ public class SpecialAddDeductionController { } + @POST + @Path("/getSpecialAddDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + Long id = param.getId(); + return new ResponseResult(user).run(getSpecialAddDeductionWrapper(user)::getRecordById, id); + } + @POST @Path("/getDetailList") @Produces(MediaType.APPLICATION_JSON) - public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { + public String getSpecialAddDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { User user = HrmUserVarify.getUser(request, response); return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::getDetailList, queryParam); } @@ -284,8 +292,7 @@ public class SpecialAddDeductionController { /** * @return String * @description 新建专项附加扣除 - * @author Harryxzy - * @date 2022/10/27 14:41 + * @author lfc */ @POST @Path("/createData") @@ -298,30 +305,26 @@ public class SpecialAddDeductionController { /** * @return String * @description 删除所选专项附加扣除 - * @author Harryxzy - * @date 2022/10/27 14:41 + * @author lfc */ @POST @Path("/deleteSelectData") @Produces(MediaType.APPLICATION_JSON) - public String deleteSelectOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam otherDeductionDeleteParam) { + public String deleteSelectOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionRecordDeleteParam deleteParam) { User user = HrmUserVarify.getUser(request, response); - return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteSelectData, otherDeductionDeleteParam); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteSelectData, deleteParam); } /** * @return null * @description 一键清空专项附加扣除 - * @author Harryxzy - * @date 2022/10/27 15:15 + * @author lfc */ @POST @Path("/deleteAllData") @Produces(MediaType.APPLICATION_JSON) - public String deleteAllOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam otherDeductionDeleteParam) { + public String deleteAllOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionRecordDeleteParam deductionRecordDeleteParam) { User user = HrmUserVarify.getUser(request, response); - return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteAllData, otherDeductionDeleteParam); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteAllData, deductionRecordDeleteParam); } - - } diff --git a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java index bf50b1960..e91305bf6 100644 --- a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java @@ -19,6 +19,7 @@ import com.engine.salary.service.impl.TaxAgentServiceImpl; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.User; @@ -35,6 +36,7 @@ import java.util.stream.Collectors; * @author qiantao * @version 1.0 **/ +@Slf4j public class AddUpDeductionWrapper extends Service { private AddUpDeductionService getAddUpDeductionService(User user) { @@ -162,4 +164,9 @@ public class AddUpDeductionWrapper extends Service { public AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam param) { return getAddUpDeductionService(user).getAddUpDeduction(param); } + + public void autoAddAll(User opt) { + log.info("一键累计, 操作人 「{}」", opt.getUsername()); + getAddUpDeductionService(user).autoAddAll(); + } } diff --git a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java index 270022b3f..817fe6058 100644 --- a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java @@ -8,10 +8,7 @@ import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; -import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.service.SalaryEmployeeService; @@ -22,13 +19,11 @@ import com.engine.salary.service.impl.SpecialAddDeductionServiceImpl; import com.engine.salary.service.impl.TaxAgentServiceImpl; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; +import org.apache.commons.collections4.CollectionUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.User; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 专项附加扣除 @@ -189,14 +184,18 @@ public class SpecialAddDeductionWrapper extends Service { /** * 删除所选数据 */ - public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) { + public void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam) { getSpecialAddDeductionService(user).deleteSelectData(deleteParam); } /** * 一键清空所有数据 */ - public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) { + public void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam) { getSpecialAddDeductionService(user).deleteAllData(deleteParam); } + + public SpecialAddDeductionRecordDTO getRecordById(Long id) { + return getSpecialAddDeductionService(user).getRecordById(id); + } } From 07a07d2be805e60fe060bbd3a348be47307ec85c Mon Sep 17 00:00:00 2001 From: fcli Date: Mon, 7 Nov 2022 16:20:21 +0800 Subject: [PATCH 17/33] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E6=89=A3=E9=99=A4=E6=A8=A1=E5=9D=97,=20=E6=9D=83?= =?UTF-8?q?=E9=99=90=E9=99=90=E5=88=B6=EF=BC=8C=E5=AF=BC=E5=85=A5=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=BC=98=E5=8C=96=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E7=B4=AF=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/biz/SpecialAddDeductionBiz.java | 1 + .../dto/SpecialAddDeductionListDTO.java | 12 +- .../SpecialAddDeductionMapper.xml | 2 +- .../salary/service/AddUpDeductionService.java | 3 +- .../service/SpecialAddDeductionService.java | 10 +- .../impl/AddUpDeductionServiceImpl.java | 149 ++++++++++++++---- .../impl/SpecialAddDeductionServiceImpl.java | 144 +++++++---------- .../web/SpecialAddDeductionController.java | 2 + .../salary/wrapper/AddUpDeductionWrapper.java | 14 +- .../wrapper/SpecialAddDeductionWrapper.java | 8 +- 10 files changed, 207 insertions(+), 138 deletions(-) diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java index b841a12d0..e7b05813e 100644 --- a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -166,6 +166,7 @@ public class SpecialAddDeductionBiz extends BaseBean { .stream() .filter(Objects::nonNull) .filter(s -> s.getEmployeeId() != null) + .map(SpecialAddDeductionEncrypt::decrypt) .collect(Collectors.toList()); } } diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java index 5785d22a5..8b86b6281 100644 --- a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java @@ -84,19 +84,19 @@ public class SpecialAddDeductionListDTO { private String hiredate; //子女教育 - @ExcelProperty(index = 10) + @ExcelProperty(index = 7) @SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation") @TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation") private String childrenEducation; //继续教育 - @ExcelProperty(index = 10) + @ExcelProperty(index = 8) @SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation") @TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation") private String continuingEducation; //住房贷款利息 - @ExcelProperty(index = 10) + @ExcelProperty(index = 9) @SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest") @TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest") private String housingLoanInterest; @@ -108,19 +108,19 @@ public class SpecialAddDeductionListDTO { private String housingRent; //赡养老人 - @ExcelProperty(index = 10) + @ExcelProperty(index = 11) @SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder") @TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder") private String supportingElder; //大病医疗 - @ExcelProperty(index = 10) + @ExcelProperty(index = 12) @SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment") @TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment") private String seriousIllnessTreatment; //婴幼儿照护 - @ExcelProperty(index = 10) + @ExcelProperty(index = 13) @SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare") @TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare") private String infantCare; diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml index e3472dfc5..37c5a765a 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -564,7 +564,7 @@ \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index b3c97fa62..b29cf4b8e 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -656,7 +656,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction Collection employeeIds = getTaxAgentService(user) .listEmployeeIdsInTaxAgent(taxAgent.getId()); List employeePOs = getSpecialAddDeductionService(user) - .getSpecialAddDeductionPOByEmployee(new ArrayList<>(employeeIds), taxAgent.getId()); + .getSpecialAddDeductionPOByEmployee(null, taxAgent.getId()); //获取上月员工数据,用于累加 LocalDateTime lastMonthDateTime = LocalDateTime.now().minusMonths(1); From e3b7f7c7327b433fc1156815027b35c387b934af Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 9 Nov 2022 10:10:10 +0800 Subject: [PATCH 20/33] =?UTF-8?q?fix:=20sql=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpecialAddDeductionMapper.xml | 111 +++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml index f343b7371..2b5338b63 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -321,6 +321,97 @@ + + + select hrsa_special_a_d_id.currval from dual + + insert into hrsa_special_add_deduction + + + employee_id, + + + tax_agent_id, + + + children_education, + + + continuing_education, + + + housing_loan_interest, + + + housing_rent, + + + supporting_elder, + + + serious_illness_treatment, + + + infant_care, + + + create_time, + + + update_time, + + + creator, + + delete_type, + + tenant_key, + + + + + #{employeeId,jdbcType=BIGINT}, + + + #{taxAgentId,jdbcType=BIGINT}, + + + #{childrenEducation,jdbcType=VARCHAR}, + + + #{continuingEducation,jdbcType=VARCHAR}, + + + #{housingLoanInterest,jdbcType=VARCHAR}, + + + #{housingRent,jdbcType=VARCHAR}, + + + #{supportingElder,jdbcType=VARCHAR}, + + + #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + #{infantCare,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=BIGINT}, + + 0, + + #{tenantKey,jdbcType=VARCHAR}, + + + @@ -481,7 +572,7 @@ - + insert into hrsa_special_add_deduction (employee_id, tax_agent_id, children_education, continuing_education, @@ -499,6 +590,24 @@ + + insert into hrsa_special_add_deduction + (employee_id, tax_agent_id, children_education, continuing_education, + housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, + infant_care, create_time, update_time, creator, delete_type, tenant_key) + + select + #{item.employeeId,jdbcType=BIGINT}, #{item.taxAgentId,jdbcType=BIGINT}, + #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, + #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, + #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, + #{item.infantCare,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, + #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.creator,jdbcType=BIGINT}, 0, #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index efd8e42c0..321d4e828 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -4,9 +4,11 @@ import com.api.formmode.mybatis.util.SqlProxyHandle; import com.cloudstore.dev.api.util.Util_DataCache; import com.engine.core.impl.Service; import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.AddUpSituation; import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; @@ -22,6 +24,7 @@ import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; import com.engine.salary.mapper.datacollection.AddUpSituationMapper; import com.engine.salary.mapper.datacollection.OtherDeductionMapper; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; import com.engine.salary.mapper.salaryacct.ExcelAcctResultMapper; import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; @@ -127,6 +130,10 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return MapperProxyFactory.getProxy(AddUpSituationMapper.class); } + private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + static SalarySysConfServiceImpl salarySysConfService = new SalarySysConfServiceImpl(); /** @@ -865,14 +872,41 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe } return 1; }); - int flag = submit.get() + submit1.get() + submit2.get() + submit3.get() + submit4.get() + submit5.get() + submit6.get() + submit7.get() + submit8.get() + submit9.get() + submit10.get() + submit11.get() + submit12.get(); - if (flag == 13) { + Future submit13 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List addUpSituations = getSpecialAddDeductionMapper().listAll(); + if (CollectionUtils.isNotEmpty(addUpSituations)) { + addUpSituations.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + SpecialAddDeductionEncrypt.decrypt(po); + } else { + SpecialAddDeductionEncrypt.encrypt(po); + } + }); + List> partition = Lists.partition(addUpSituations, 50); + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + partition.forEach(mapper::updateBatchSelective); + sqlSession.commit(); + baseBean.writeLog("hrsa_special_add_deduction"); + } + } catch (Exception e) { + sqlSession.rollback(); + baseBean.writeLog("hrsa_special_add_deduction:", e.getMessage()); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + int flag = submit.get() + submit1.get() + submit2.get() + submit3.get() + submit4.get() + submit5.get() + submit6.get() + submit7.get() + submit8.get() + submit9.get() + submit10.get() + submit11.get() + submit12.get() + submit13.get(); + if (flag == 14) { Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "success", 30); } else { Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30); } Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); - return flag == 13; + return flag == 14; } catch (Exception e) { Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30); Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); From 07f9976d63e392d367f121321f055bf285105666 Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 9 Nov 2022 14:27:58 +0800 Subject: [PATCH 23/33] =?UTF-8?q?fix:=20=E5=8A=A0=E8=A7=A3=E5=AF=86?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../encrypt/datacollection/SpecialAddDeductionEncrypt.java | 2 +- .../salary/mapper/datacollection/SpecialAddDeductionMapper.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java index d21e97b87..c6169219c 100644 --- a/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java +++ b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java @@ -24,7 +24,7 @@ import java.util.stream.Collectors; */ public class SpecialAddDeductionEncrypt { private static final List FIELDS = Arrays.asList( - "childrenEducation", "continuingEducation", "supportElder", "housingLoanInterest", + "childrenEducation", "continuingEducation", "supportingElder", "housingLoanInterest", "housingRent", "seriousIllnessTreatment", "infantCare"); public static T encrypt(T obj) { diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml index dd77bfb01..1464a979e 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -688,6 +688,6 @@ \ No newline at end of file From e2e383bd79b083439615017848cb76161239681e Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Wed, 9 Nov 2022 15:36:07 +0800 Subject: [PATCH 24/33] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=87=87=E9=9B=86-Fix?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=87=87=E9=9B=86Long=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/impl/AddUpDeductionServiceImpl.java | 10 +++++----- .../salary/service/impl/AddUpSituationServiceImpl.java | 8 ++++---- .../salary/service/impl/OtherDeductionServiceImpl.java | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index e7086f94c..ab72dcc47 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -405,7 +405,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction throw new SalaryRunTimeException("该数据不存在!"); } Long taxAgentId = byId.getTaxAgentId(); - boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId)); if(!canEdit){ //没有编辑权限 throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); @@ -436,7 +436,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction //税款所属期 String declareMonthStr = addUpDeductionRecordParam.getDeclareMonth(); - if(declareMonthStr == ""){ + if(declareMonthStr .equals("")){ throw new SalaryRunTimeException("税款所属期不能为空!"); } // 获取所有个税扣缴义务人 @@ -464,7 +464,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction .updateTime(now) .creator((long) user.getUID()) .declareMonth(declareMonth).build(); - boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == addUpDeductionRecordParam.getEmployeeId()); + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , addUpDeductionRecordParam.getEmployeeId())); if (!employeeSameId) { throw new SalaryRunTimeException("员工信息不存在"); } @@ -548,7 +548,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction throw new SalaryRunTimeException("数据不存在或已被删除!"); } // 判断是否在个税扣缴义务人范围内 - Optional first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst(); if(!first.isPresent()){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } @@ -583,7 +583,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){ // 设置了个税扣缴义务人 Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); - boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId)); if(!canDelete){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); } diff --git a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java index 94d770e82..ee52107f4 100644 --- a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java @@ -846,7 +846,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation throw new SalaryRunTimeException("该数据不存在!"); } Long taxAgentId = byId.getTaxAgentId(); - boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId)); if(!canEdit){ //没有编辑权限 throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); @@ -922,7 +922,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation //筛选导入人员信息可以在人力资源池中匹配到的人员信息 - boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == addUpSituationParam.getEmployeeId()); + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , addUpSituationParam.getEmployeeId())); if(!employeeSameId){ throw new SalaryRunTimeException("员工信息不存在"); } @@ -1033,7 +1033,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation throw new SalaryRunTimeException("数据不存在或已被删除!"); } // 判断是否在个税扣缴义务人范围内 - Optional first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst(); if(!first.isPresent()){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } @@ -1069,7 +1069,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){ // 设置了个税扣缴义务人 Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); - boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId)); if(!canDelete){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); } diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java index 6edd8bddf..1529e9966 100644 --- a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -567,7 +567,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction throw new SalaryRunTimeException("该数据不存在!"); } Long taxAgentId = byId.getTaxAgentId(); - boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId)); if(!canEdit){ //没有编辑权限 throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); @@ -622,7 +622,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction .declareMonth(declareMonth).build(); //筛选导入人员信息可以在人力资源池中匹配到的人员信息 - boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == otherDeductionParam.getEmployeeId()); + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , otherDeductionParam.getEmployeeId())); if(!employeeSameId){ throw new SalaryRunTimeException("员工信息不存在"); } @@ -701,7 +701,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction throw new SalaryRunTimeException("数据不存在或已被删除!"); } // 判断是否在个税扣缴义务人范围内 - Optional first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst(); if(!first.isPresent()){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } @@ -737,7 +737,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){ // 设置了个税扣缴义务人 Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); - boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId)); if(!canDelete){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); } From bf75c3831f3bd247ef2de7628aa3f93174e14c58 Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 9 Nov 2022 15:39:00 +0800 Subject: [PATCH 25/33] =?UTF-8?q?fix:=20=E4=B8=80=E9=94=AE=E7=B4=AF?= =?UTF-8?q?=E8=AE=A1=E6=B7=BB=E5=8A=A0=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/AddDeductionAutoAddParam.java | 17 ++++++++++++++ .../salary/service/AddUpDeductionService.java | 2 +- .../impl/AddUpDeductionServiceImpl.java | 10 ++++---- .../salary/web/AddUpDeductionController.java | 23 ++++++++++++++----- .../salary/wrapper/AddUpDeductionWrapper.java | 10 ++++---- 5 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java diff --git a/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java b/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java new file mode 100644 index 000000000..ba14a6f02 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java @@ -0,0 +1,17 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description 数据采集-专项附加扣除一键累计参数 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddDeductionAutoAddParam { + String yearMonth = ""; +} diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java index 523495ba5..4876bf723 100644 --- a/src/com/engine/salary/service/AddUpDeductionService.java +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -154,5 +154,5 @@ public interface AddUpDeductionService { * @return void * @author lfc */ - void autoAddAll(Date operateTime); + void autoAddAll(Date yearMonth); } diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index b29cf4b8e..51f7398ce 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -641,7 +641,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } @Override - public void autoAddAll(Date operateTime) { + public void autoAddAll(Date yearMonth) { int uid = user.getUID(); Boolean isChief = getTaxAgentService(user).isChief((long) uid); Collection taxAgents; @@ -677,7 +677,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction addUpDeduction.setEmployeeId(employeeId); addUpDeduction.setTaxAgentId(taxAgent.getId()); - addUpDeduction.setDeclareMonth(DateUtil.beginOfMonth(operateTime)); + addUpDeduction.setDeclareMonth(DateUtil.beginOfMonth(yearMonth)); addUpDeduction.setCreator((long) user.getUID()); addUpDeduction.setTenantKey(DEFAULT_TENANT_KEY); @@ -686,13 +686,13 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction .flatMap(c -> c.stream().findFirst()) .orElse(null); if (oldInfo == null) { - addUpDeduction.setCreateTime(operateTime); - addUpDeduction.setUpdateTime(operateTime); + addUpDeduction.setCreateTime(yearMonth); + addUpDeduction.setUpdateTime(yearMonth); insertList.add(AddUpDeductionEncrypt.encryptAddUpDeduction(addUpDeduction)); } else { addUpDeduction.setId(oldInfo.getId()); addUpDeduction.setCreateTime(oldInfo.getCreateTime()); - addUpDeduction.setUpdateTime(operateTime); + addUpDeduction.setUpdateTime(yearMonth); updateList.add(AddUpDeductionEncrypt.encryptAddUpDeduction(addUpDeduction)); } }); diff --git a/src/com/engine/salary/web/AddUpDeductionController.java b/src/com/engine/salary/web/AddUpDeductionController.java index d97aaaed3..6cda46630 100644 --- a/src/com/engine/salary/web/AddUpDeductionController.java +++ b/src/com/engine/salary/web/AddUpDeductionController.java @@ -1,13 +1,13 @@ package com.engine.salary.web; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; -import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam; +import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.util.ResponseResult; import com.engine.salary.util.page.PageInfo; import com.engine.salary.wrapper.AddUpDeductionWrapper; @@ -347,8 +347,19 @@ public class AddUpDeductionController { @POST @Path("/autoAddAll") @Produces(MediaType.APPLICATION_JSON) - public String autoAddAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + public String autoAddAll(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody AddDeductionAutoAddParam param) { + DateTime date = null; + if (StrUtil.isNotEmpty(param.getYearMonth())) { + try { + date = DateUtil.parse(param.getYearMonth(), "yyyy-MM"); + } catch (Exception e) { + //ignore 放在service中处理,这里处理了页面上收不到 + } + } else { + date = DateUtil.beginOfMonth(new Date()); + } User user = HrmUserVarify.getUser(request, response); - return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, user); + return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, date); } } diff --git a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java index b0f57c860..162291cb1 100644 --- a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java @@ -25,7 +25,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.general.BaseBean; import weaver.hrm.User; -import java.time.LocalDateTime; import java.util.Date; import java.util.List; import java.util.Map; @@ -171,10 +170,13 @@ public class AddUpDeductionWrapper extends Service { return getAddUpDeductionService(user).getAddUpDeduction(param); } - public void autoAddAll(User opt) { + public void autoAddAll(Date yearMonth) { if (isLog) { - log.info("一键累计, 操作人 「{}」", opt.getUsername()); + log.info("一键累计, 操作人 「{}」", user.getUsername()); } - getAddUpDeductionService(user).autoAddAll(new Date()); + if (yearMonth == null) { + throw new SalaryRunTimeException("一键累计传入日期格式错误"); + } + getAddUpDeductionService(user).autoAddAll(yearMonth); } } From e63c72f51e0e7da5be9d3671eac1b7dd1e9426d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Wed, 9 Nov 2022 15:47:09 +0800 Subject: [PATCH 26/33] =?UTF-8?q?=E9=80=86=E5=90=91=E8=A7=A3=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java b/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java index b3a6fbc61..0dd40eee4 100644 --- a/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java @@ -17,7 +17,6 @@ import com.engine.salary.util.page.SalaryPageUtil; import com.engine.salary.util.valid.RuntimeTypeEnum; import com.engine.salary.util.valid.ValidUtil; import org.apache.commons.lang3.StringUtils; -import tebie.applib.api.O; import weaver.general.BaseBean; import weaver.hrm.User; @@ -134,7 +133,6 @@ public class SalarySystemConfigWrapper extends Service { } public Map saveEncryptSetting(AppSettingSaveParam param) { - ValidUtil.doValidator(param); return getSalarySysConfService(user).saveEncryptSetting(param); } From 815e37e50ba8cfe2497a3a49ed579458919f6b51 Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 9 Nov 2022 16:55:00 +0800 Subject: [PATCH 27/33] =?UTF-8?q?fix:=20=E4=B8=80=E9=94=AE=E7=B4=AF?= =?UTF-8?q?=E8=AE=A1=E6=B7=BB=E5=8A=A0=E6=97=A5=E6=9C=9F=E4=B8=8E=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datacollection/AddUpDeductionMapper.java | 7 ++ .../datacollection/AddUpDeductionMapper.xml | 105 +++++++++++++++++- .../service/SpecialAddDeductionService.java | 1 + .../impl/AddUpDeductionServiceImpl.java | 26 +++-- 4 files changed, 131 insertions(+), 8 deletions(-) diff --git a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java index 15c1953af..6aedf838c 100644 --- a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java +++ b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java @@ -1,4 +1,5 @@ package com.engine.salary.mapper.datacollection; +import java.util.Date; import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.DataCollectionEmployee; @@ -61,6 +62,8 @@ public interface AddUpDeductionMapper { */ void updateData(@Param("collection") List updateList); + void updateDataAndDeclareMonth(@Param("collection") List updateList); + List recordList(@Param("param") AddUpDeductionQueryParam param); @@ -71,4 +74,8 @@ public interface AddUpDeductionMapper { * @date 2022/10/27 9:54 */ void deleteData(@Param("collection")List longs); + + int countByDeclareAfter(@Param("minDeclareMonth") Date minDeclareMonth, + @Param("maxDeclareMonth") Date maxDeclareMonth, + @Param("taxAgentIds") List taxAgentIds); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml index e90fdc37a..ebd2b723f 100644 --- a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml @@ -1,6 +1,24 @@ + + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + create_time, + creator, + declare_month, + delete_type, + employee_id, + id, + tax_agent_id, + tenant_key, + update_time, + add_up_illness_medical, + add_up_infant_care + @@ -553,6 +571,73 @@ + + update hrsa_add_up_deduction + + + + + when id=#{item.id} then #{item.addUpChildEducation} + + + + + + + when id=#{item.id} then #{item.addUpContinuingEducation} + + + + + + + when id=#{item.id} then #{item.addUpHousingLoanInterest} + + + + + + + when id=#{item.id} then #{item.addUpHousingRent} + + + + + + + when id=#{item.id} then #{item.addUpSupportElderly} + + + + + + + when id=#{item.id} then #{item.addUpIllnessMedical} + + + + + + + when id=#{item.id} then #{item.addUpInfantCare} + + + + + + + when id=#{item.id} then #{item.declareMonth} + + + + + where + id in + + #{item.id} + + + - + \ No newline at end of file diff --git a/src/com/engine/salary/service/SpecialAddDeductionService.java b/src/com/engine/salary/service/SpecialAddDeductionService.java index 89ea40b4a..d2f893323 100644 --- a/src/com/engine/salary/service/SpecialAddDeductionService.java +++ b/src/com/engine/salary/service/SpecialAddDeductionService.java @@ -8,6 +8,7 @@ import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.time.YearMonth; +import java.util.Date; import java.util.List; import java.util.Map; diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index 51f7398ce..6f419efbe 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -63,9 +63,7 @@ import weaver.hrm.User; import java.io.InputStream; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.YearMonth; +import java.time.*; import java.util.*; import java.util.stream.Collectors; @@ -650,22 +648,36 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } else { taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) uid); } + LocalDateTime yearMonthTime = DateUtil.toLocalDateTime(yearMonth); + //设置时间到下一年1月1号 + Instant instant = yearMonthTime.plusYears(1L) + .withMonth(1).withDayOfMonth(1) + .atZone(ZoneOffset.systemDefault()).toInstant(); + Date nextYearStart = Date.from(instant); + int countByDeclareAfter = getAddUpDeductionMapper() + .countByDeclareAfter(yearMonth, nextYearStart, + taxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList()) + ); + if (countByDeclareAfter > 0) { + throw new SalaryRunTimeException("无法累计,请检查当前累计年度内该月后是否有累计专项附加扣除记录!"); + } List updateList = new ArrayList<>(); List insertList = new ArrayList<>(); + List errorMessages = new ArrayList<>(); for (TaxAgentPO taxAgent : taxAgents) { Collection employeeIds = getTaxAgentService(user) .listEmployeeIdsInTaxAgent(taxAgent.getId()); List employeePOs = getSpecialAddDeductionService(user) .getSpecialAddDeductionPOByEmployee(null, taxAgent.getId()); + //获取上月员工数据,用于累加 - LocalDateTime lastMonthDateTime = LocalDateTime.now().minusMonths(1); + LocalDateTime lastMonthDateTime = yearMonthTime.minusMonths(1); YearMonth lastMonth = YearMonth.of(lastMonthDateTime.getYear(), lastMonthDateTime.getMonth()); Map> lastEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, lastMonth); //获取当月员工数据,用于更新 - LocalDateTime currentMonthDateTime = LocalDateTime.now(); - YearMonth currentMonth = YearMonth.of(currentMonthDateTime.getYear(), currentMonthDateTime.getMonth()); + YearMonth currentMonth = YearMonth.of(yearMonthTime.getYear(), yearMonthTime.getMonth()); Map> currentEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, currentMonth); employeePOs.forEach(employeePO -> { @@ -700,7 +712,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction Lists.partition(insertList, 100) .forEach(l -> getAddUpDeductionMapper().insertData((List) l)); Lists.partition(updateList, 100) - .forEach(l -> getAddUpDeductionMapper().updateData((List) l)); + .forEach(l -> getAddUpDeductionMapper().updateDataAndDeclareMonth((List) l)); } /** From b55c339bb0bd8b458074a652cac15d2619b56175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Wed, 9 Nov 2022 17:26:51 +0800 Subject: [PATCH 28/33] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8A=E6=9C=88?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/service/impl/FormulaRunServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java index 79190007f..6beac534d 100644 --- a/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java +++ b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java @@ -111,7 +111,7 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService } if (OpenEnum.OPEN.getValue().equals(openDecrypt)) { - result = AESEncryptUtil.decrypt(openDecrypt); + result = AESEncryptUtil.decrypt(result); } return result; } From 63ee9c9b8e02d72794d79f726aeb3f55fee5a59a Mon Sep 17 00:00:00 2001 From: fcli Date: Wed, 9 Nov 2022 18:57:28 +0800 Subject: [PATCH 29/33] =?UTF-8?q?fix:=20=E4=B8=80=E9=94=AE=E7=B4=AF?= =?UTF-8?q?=E8=AE=A1=E6=B7=BB=E5=8A=A0=E6=97=A5=E6=9C=9F=E4=B8=8E=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/AddUpDeductionService.java | 2 +- .../impl/AddUpDeductionServiceImpl.java | 24 +++++++++++++++++-- .../salary/web/AddUpDeductionController.java | 5 ++-- .../salary/wrapper/AddUpDeductionWrapper.java | 4 ++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java index 4876bf723..d65082de7 100644 --- a/src/com/engine/salary/service/AddUpDeductionService.java +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -154,5 +154,5 @@ public interface AddUpDeductionService { * @return void * @author lfc */ - void autoAddAll(Date yearMonth); + String autoAddAll(Date yearMonth); } diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index 6f419efbe..5311cd699 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -639,7 +639,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } @Override - public void autoAddAll(Date yearMonth) { + public String autoAddAll(Date yearMonth) { int uid = user.getUID(); Boolean isChief = getTaxAgentService(user).isChief((long) uid); Collection taxAgents; @@ -663,7 +663,9 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } List updateList = new ArrayList<>(); List insertList = new ArrayList<>(); - List errorMessages = new ArrayList<>(); + List errorMessages = new ArrayList<>(); + List accountedEmployeeData = + getAccountedEmployeeData(DateUtil.format(yearMonth, "yyyy-MM")); for (TaxAgentPO taxAgent : taxAgents) { Collection employeeIds = getTaxAgentService(user) .listEmployeeIdsInTaxAgent(taxAgent.getId()); @@ -682,6 +684,15 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction employeePOs.forEach(employeePO -> { Long employeeId = employeePO.getEmployeeId(); + // 如果该员工当前月份已经核算,不做累计 + SalaryAcctEmployeePO anyAccountedEmployee = accountedEmployeeData.stream() + .filter(e -> e.getEmployeeId().equals(employeeId)) + .filter(e -> e.getTaxAgentId().equals(taxAgent.getId())) + .findAny().orElse(null); + if (anyAccountedEmployee != null) { + errorMessages.add(employeeId); + return; + } AddUpDeduction addUpDeduction = Optional.ofNullable(lastEmpInfo.get(employeeId)) .flatMap(list -> list.stream().findFirst()) .orElseGet(AddUpDeduction::new); @@ -713,6 +724,15 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction .forEach(l -> getAddUpDeductionMapper().insertData((List) l)); Lists.partition(updateList, 100) .forEach(l -> getAddUpDeductionMapper().updateDataAndDeclareMonth((List) l)); + if (!errorMessages.isEmpty()) { + String userNames = getSalaryEmployeeService(user) + .listByIds(errorMessages) + .stream() + .map(DataCollectionEmployee::getUsername) + .collect(Collectors.joining(",")); + return "一键累计完成!员工" + userNames + "在该年月已核算归档,跳过本次累计"; + } + return "一键累计完成!"; } /** diff --git a/src/com/engine/salary/web/AddUpDeductionController.java b/src/com/engine/salary/web/AddUpDeductionController.java index 6cda46630..5d421153e 100644 --- a/src/com/engine/salary/web/AddUpDeductionController.java +++ b/src/com/engine/salary/web/AddUpDeductionController.java @@ -354,12 +354,13 @@ public class AddUpDeductionController { try { date = DateUtil.parse(param.getYearMonth(), "yyyy-MM"); } catch (Exception e) { - //ignore 放在service中处理,这里处理了页面上收不到 + //ignore + // 放在service中处理,这里处理了页面上收不到 } } else { date = DateUtil.beginOfMonth(new Date()); } User user = HrmUserVarify.getUser(request, response); - return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, date); + return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, date); } } diff --git a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java index 162291cb1..84c45384e 100644 --- a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java @@ -170,13 +170,13 @@ public class AddUpDeductionWrapper extends Service { return getAddUpDeductionService(user).getAddUpDeduction(param); } - public void autoAddAll(Date yearMonth) { + public String autoAddAll(Date yearMonth) { if (isLog) { log.info("一键累计, 操作人 「{}」", user.getUsername()); } if (yearMonth == null) { throw new SalaryRunTimeException("一键累计传入日期格式错误"); } - getAddUpDeductionService(user).autoAddAll(yearMonth); + return getAddUpDeductionService(user).autoAddAll(yearMonth); } } From 3d4be3265ec4b68640c343035def85b6a5c07fcf Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Thu, 10 Nov 2022 09:46:30 +0800 Subject: [PATCH 30/33] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD-=E9=87=8D=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/sys/SalarySysConfMapper.java | 9 ++ .../salary/mapper/sys/SalarySysConfMapper.xml | 3 + .../impl/SalaryAcctRecordServiceImpl.java | 86 +++++++++++++++++-- .../sys/service/SalarySysConfService.java | 11 ++- .../impl/SalarySysConfServiceImpl.java | 42 +++++---- .../engine/salary/util/SalaryDateUtil.java | 24 ++++++ 6 files changed, 151 insertions(+), 24 deletions(-) diff --git a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java index 2b3596f74..36e3a4d37 100644 --- a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java +++ b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java @@ -2,6 +2,7 @@ package com.engine.salary.mapper.sys; import com.engine.salary.sys.entity.po.SalarySysConfPO; +import java.util.Date; import java.util.List; public interface SalarySysConfMapper { @@ -64,4 +65,12 @@ public interface SalarySysConfMapper { SalarySysConfPO getOneByCode(String confKey); int countByCode(String confKey); + + /** + * @description 获取个税申报功能重启时间 + * @return Date + * @author Harryxzy + * @date 2022/11/9 21:09 + */ + Date getTaxDeclarationRebootDate(); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml index 221900da7..3d0c299c4 100644 --- a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml +++ b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml @@ -233,5 +233,8 @@ WHERE delete_type = 0 AND conf_key = #{confKey} + \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index a11055e28..f326c51c7 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -16,6 +16,7 @@ import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.service.*; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.SalaryDateUtil; @@ -303,9 +304,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe //获取账套下的所有核算结果 List salaryAcctRecords = listByTaxCycle(taxCycleYearRange,salarySobIds); - // 是否关闭个税申报功能 - Boolean haveClosedTaxDeclaration = getSalarySysConfService(user).haveClosedTaxDeclaration(); - if(haveClosedTaxDeclaration){ + // 获取个税申报功能状态 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + + if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){ // 关闭了个税申报功能 // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() @@ -330,7 +332,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe .replace("{1}",salarySobCycleDTO.getSalaryMonth().toString())); } - }else { + } + if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){ // 开启了个税申报功能 // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() @@ -366,6 +369,67 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); } } + if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){ + // 重启了个税申报功能(不去校验重启之前是否申报数据) + // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) + && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}",salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + //获取账套下从重启月至所在年的最后一天的所有核算结果 + Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate(); + if(taxDeclarationRebootDate == null){ + throw new SalaryRunTimeException("个税申报功能异常"); + } + + + LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder() + .fromDate(SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDate)) + .endDate(SalaryDateUtil.getLastDayOfYearWithMinutesAndSeconds(taxDeclarationRebootDate)) + .build(); + List salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds); + SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream() + .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + + } } @@ -512,11 +576,21 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } //撤回工资单 getSalarySendService(user).revokeSalaryBill(salaryAcctRecordId); - Boolean haveClosedTaxDeclaration = getSalarySysConfService(user).haveClosedTaxDeclaration(); - if(!haveClosedTaxDeclaration){ + + TaxDeclarationFunctionEnum taxDeclaration = getSalarySysConfService(user).getTaxDeclaration(); + + if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){ // 开启了个税申报功能 // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) getTaxDeclarationService(user).delete(salaryAcctRecordPO); + }else if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){ + // 重启个税申报功能 + Date taxDeclarationRebootDateTemp = getSalarySysConfService(user).getTaxDeclarationRebootDate(); + Date taxDeclarationRebootDate = SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDateTemp); + if(!taxDeclarationRebootDate.after(salaryAcctRecordPO.getTaxCycle())){ + // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) + getTaxDeclarationService(user).delete(salaryAcctRecordPO); + } } // 更新薪资核算记录的状态 salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()); diff --git a/src/com/engine/salary/sys/service/SalarySysConfService.java b/src/com/engine/salary/sys/service/SalarySysConfService.java index 31d497b70..5b97d6c99 100644 --- a/src/com/engine/salary/sys/service/SalarySysConfService.java +++ b/src/com/engine/salary/sys/service/SalarySysConfService.java @@ -7,6 +7,7 @@ import com.engine.salary.sys.entity.vo.AppSettingVO; import com.engine.salary.sys.entity.vo.OrderRuleVO; import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import java.util.Date; import java.util.List; import java.util.Map; @@ -33,7 +34,7 @@ public interface SalarySysConfService { * 是否关闭了个税申报功能 * @return BOOLEAN */ - public Boolean haveClosedTaxDeclaration(); + TaxDeclarationFunctionEnum getTaxDeclaration(); SalarySysConfPO getOneByCode(String code); @@ -74,4 +75,12 @@ public interface SalarySysConfService { Map saveEncryptSetting(AppSettingSaveParam appSettingSaveParam); Map getEncryptProgress(String progressId); + + /** + * @description 获取个税申报功能重启日期 + * @return Date + * @author Harryxzy + * @date 2022/11/9 21:07 + */ + Date getTaxDeclarationRebootDate(); } diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index 05ff72671..5636dc88c 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -149,15 +149,15 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return true; } //关闭 - if (flag == TaxDeclarationFunctionEnum.CLOSURE) { + if (flag == TaxDeclarationFunctionEnum.CLOSURE || flag == TaxDeclarationFunctionEnum.OPEN) { taxDeclarationFunction.setConfValue(flag.getValue()); taxDeclarationFunction.setTitle(flag.getDefaultLabel()); taxDeclarationFunction.setUpdateTime(new Date()); } - //重启 + //重启 (从关闭到开启) if (flag == TaxDeclarationFunctionEnum.OPEN && oldFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) { - taxDeclarationFunction.setConfValue(flag.getValue()); - taxDeclarationFunction.setTitle(flag.getDefaultLabel()); + taxDeclarationFunction.setConfValue(TaxDeclarationFunctionEnum.REBOOT.getValue()); + taxDeclarationFunction.setTitle(TaxDeclarationFunctionEnum.REBOOT.getDefaultLabel()); taxDeclarationFunction.setUpdateTime(new Date()); } getSalarySysConfMapper().updateIgnoreNull(taxDeclarationFunction); @@ -166,18 +166,19 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe } /** - * @description 是否关闭需要申报功能 + * @description 获取申报功能状态 * @return Boolean * @author Harryxzy * @date 2022/11/7 17:05 */ - public Boolean haveClosedTaxDeclaration(){ + public TaxDeclarationFunctionEnum getTaxDeclaration(){ SalarySysConfPO taxDeclarationFunction = salarySysConfService.getOneByCode(TAX_DECLARATION_FUNCTION); - if(taxDeclarationFunction != null && taxDeclarationFunction.getConfValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){ - // 关闭 - return true; + if(taxDeclarationFunction == null){ + // 默认开启 + return TaxDeclarationFunctionEnum.OPEN; } - return false; + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue()); + return taxDeclarationFunctionEnum; } @@ -380,6 +381,12 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return resultMap; } + @Override + public Date getTaxDeclarationRebootDate() { + Date date = getSalarySysConfMapper().getTaxDeclarationRebootDate(); + return date; + } + /** * 保存或者修改应用设置 * @@ -426,22 +433,23 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe case OPEN_APPLICATION_ENCRYPT: appSettingVO.setIsOpenEncrypt(salarySysConfPO.getConfValue()); break; - case TAX_DECLARATION_FUNCTION: - appSettingVO.setIsOpenTaxDeclaration(salarySysConfPO.getConfValue()); - break; default: break; } }); } + + List taxDeclarationFunction = getSalarySysConfMapper().listSome(SalarySysConfPO.builder().deleteType(0).confKey(TAX_DECLARATION_FUNCTION).build()); + if(taxDeclarationFunction == null || taxDeclarationFunction.size() == 0){ + // 默认开启报税功能 + appSettingVO.setIsOpenTaxDeclaration("1"); + }else{ + appSettingVO.setIsOpenTaxDeclaration(taxDeclarationFunction.get(0).getConfValue()); + } //默认加密开启 if (StringUtils.isEmpty(appSettingVO.getIsOpenEncrypt())) { appSettingVO.setIsOpenEncrypt("1"); } - // 默认开启报税功能 - if(StringUtils.isEmpty(appSettingVO.getIsOpenTaxDeclaration())){ - appSettingVO.setIsOpenTaxDeclaration("1"); - } return appSettingVO; } diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 90d3504bb..5b146358f 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -240,6 +240,17 @@ public class SalaryDateUtil { cal.set(Calendar.DAY_OF_MONTH, last); return cal.getTime(); } + public static Date getFirstDayDateOfMonthWithMinutesAndSeconds(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH); + cal.set(Calendar.DAY_OF_MONTH, last); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } public static Date getLastDayOfMonth(final Date date) { final Calendar cal = Calendar.getInstance(); @@ -265,6 +276,19 @@ public class SalaryDateUtil { return cal.getTime(); } + public static Date getLastDayOfYearWithMinutesAndSeconds(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMaximum(Calendar.DAY_OF_YEAR); + cal.set(Calendar.DAY_OF_YEAR, last); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } + + public static String getMonthBegin(String specifiedDay) { int year; int month; From 1abd3d47f2208413bb16d2290d64da70bb433e12 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Thu, 10 Nov 2022 10:14:29 +0800 Subject: [PATCH 31/33] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD-=E9=87=8D=E5=90=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=B1=95=E7=A4=BA=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/sys/service/impl/SalarySysConfServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index 5636dc88c..a2aecb35a 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -440,10 +440,10 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe } List taxDeclarationFunction = getSalarySysConfMapper().listSome(SalarySysConfPO.builder().deleteType(0).confKey(TAX_DECLARATION_FUNCTION).build()); - if(taxDeclarationFunction == null || taxDeclarationFunction.size() == 0){ - // 默认开启报税功能 + if(taxDeclarationFunction == null || taxDeclarationFunction.size() == 0 || (taxDeclarationFunction.get(0).getConfValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue()))){ + // 默认开启报税功能 或者重启状态时前端展示开启 appSettingVO.setIsOpenTaxDeclaration("1"); - }else{ + }else { appSettingVO.setIsOpenTaxDeclaration(taxDeclarationFunction.get(0).getConfValue()); } //默认加密开启 From 9dab99d3c54006c0e3f0cf58879a5d361c6561ee Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Thu, 10 Nov 2022 10:28:03 +0800 Subject: [PATCH 32/33] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD-fix=E9=87=8D=E5=90=AF=E5=90=8E=E5=9B=9E?= =?UTF-8?q?=E5=88=B0=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/sys/service/impl/SalarySysConfServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index a2aecb35a..e80dce191 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -149,7 +149,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return true; } //关闭 - if (flag == TaxDeclarationFunctionEnum.CLOSURE || flag == TaxDeclarationFunctionEnum.OPEN) { + if (flag == TaxDeclarationFunctionEnum.CLOSURE) { taxDeclarationFunction.setConfValue(flag.getValue()); taxDeclarationFunction.setTitle(flag.getDefaultLabel()); taxDeclarationFunction.setUpdateTime(new Date()); From c786dc2d14cb95dd7d2668775e846fdeecb38971 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Thu, 10 Nov 2022 11:11:41 +0800 Subject: [PATCH 33/33] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD-=E9=87=8D=E5=90=AF=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=92=8C=E8=96=AA=E8=B5=84=E6=A0=B8=E7=AE=97=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=AF=94=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salaryacct/SalaryAcctRecordMapper.java | 3 ++ .../salaryacct/SalaryAcctRecordMapper.xml | 19 +++++++++++ .../impl/SalaryAcctRecordServiceImpl.java | 32 +++++++++++-------- .../engine/salary/util/SalaryDateUtil.java | 12 +------ 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java index 4d53cff06..eda9abadb 100644 --- a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java @@ -1,10 +1,12 @@ package com.engine.salary.mapper.salaryacct; +import com.engine.salary.common.LocalDateRange; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.List; +import java.util.Set; public interface SalaryAcctRecordMapper { @@ -71,4 +73,5 @@ public interface SalaryAcctRecordMapper { */ void deleteByIds(@Param("ids") Collection ids); + List listByCreateDate(@Param(value = "createRange") LocalDateRange createRange, @Param(value = "salarySobIds") Set salarySobIds); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml index 5e1e0b404..123da569a 100644 --- a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml @@ -117,6 +117,25 @@ ORDER BY id DESC + diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index f326c51c7..5f9ff6c7d 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -400,12 +400,12 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe throw new SalaryRunTimeException("个税申报功能异常"); } - LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder() - .fromDate(SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDate)) - .endDate(SalaryDateUtil.getLastDayOfYearWithMinutesAndSeconds(taxDeclarationRebootDate)) + .fromDate(taxDeclarationRebootDate) + .endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate)) .build(); - List salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds); +// List salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds); + List salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange,salarySobIds); SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream() .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) @@ -433,6 +433,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } + private List listByCreateDate(LocalDateRange taxCycleRebootYearRange, Set salarySobIds) { + return getSalaryAcctRecordMapper().listByCreateDate(taxCycleRebootYearRange,salarySobIds); + } + @Override public void updateStatusByIds(Collection ids, SalaryAcctRecordStatusEnum status) { @@ -579,19 +583,19 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe TaxDeclarationFunctionEnum taxDeclaration = getSalarySysConfService(user).getTaxDeclaration(); - if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){ +// if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){ // 开启了个税申报功能 // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) getTaxDeclarationService(user).delete(salaryAcctRecordPO); - }else if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){ - // 重启个税申报功能 - Date taxDeclarationRebootDateTemp = getSalarySysConfService(user).getTaxDeclarationRebootDate(); - Date taxDeclarationRebootDate = SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDateTemp); - if(!taxDeclarationRebootDate.after(salaryAcctRecordPO.getTaxCycle())){ - // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) - getTaxDeclarationService(user).delete(salaryAcctRecordPO); - } - } +// }else if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){ +// // 重启个税申报功能 +// Date taxDeclarationRebootDateTemp = getSalarySysConfService(user).getTaxDeclarationRebootDate(); +// Date taxDeclarationRebootDate = SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDateTemp); +// if(!taxDeclarationRebootDate.after(salaryAcctRecordPO.getTaxCycle())){ +// // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) +// getTaxDeclarationService(user).delete(salaryAcctRecordPO); +// } +// } // 更新薪资核算记录的状态 salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()); salaryAcctRecordPO.setUpdateTime(new Date()); diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 5b146358f..c34b18dbc 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -276,17 +276,7 @@ public class SalaryDateUtil { return cal.getTime(); } - public static Date getLastDayOfYearWithMinutesAndSeconds(final Date date) { - final Calendar cal = Calendar.getInstance(); - cal.setTime(date); - final int last = cal.getActualMaximum(Calendar.DAY_OF_YEAR); - cal.set(Calendar.DAY_OF_YEAR, last); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - return cal.getTime(); - } + public static String getMonthBegin(String specifiedDay) {