From bf31d993a70c3b53898d919359a6ade1a4e03b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 11 Jul 2022 17:31:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E9=85=AC=E6=8A=A5=E8=A1=A8-=E8=96=AA?= =?UTF-8?q?=E9=85=AC=E6=A0=B8=E7=AE=97=E5=AE=8C=E6=88=90=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=98=E5=82=A8=E5=88=B0=E9=9D=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=E8=A1=A8=EF=BC=8C=E5=88=A0=E9=99=A4=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E8=A1=A5=E5=85=85=EF=BC=9A=E5=88=86?= =?UTF-8?q?=E9=83=A8=E3=80=81=E9=83=A8=E9=97=A8=E3=80=81=E5=B2=97=E4=BD=8D?= =?UTF-8?q?=E7=AD=89=E5=85=B6=E4=BB=96=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BE=9B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=AD=E5=BF=83=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cmd/siarchives/SIArchivesTipsCmd.java | 2 +- .../SalaryAcctResultReportPOEncrypt.java | 34 ++ .../DataCollectionEmployee.java | 7 + .../report/bo/SalaryAcctResultReportBO.java | 100 ++++++ .../report/po/SalaryAcctResultReportPO.java | 91 ++++++ .../salaryacct/bo/SalaryAcctResultBO.java | 4 + .../param/SalaryAcctCalculateParam.java | 7 + .../siarchives/bo/InsuranceArchivesBO.java | 2 +- .../mapper/datacollection/EmployMapper.java | 7 +- .../mapper/datacollection/EmployMapper.xml | 49 ++- .../report/SalaryAcctResultReportMapper.java | 47 +++ .../report/SalaryAcctResultReportMapper.xml | 301 ++++++++++++++++++ .../service/SalaryAcctReportService.java | 27 ++ .../salary/service/SalaryEmployeeService.java | 6 + .../impl/SalaryAcctEmployeeServiceImpl.java | 47 +-- .../impl/SalaryAcctExcelServiceImpl.java | 45 ++- .../impl/SalaryAcctRecordServiceImpl.java | 6 + .../impl/SalaryAcctReportServiceImpl.java | 52 +++ .../impl/SalaryAcctResultServiceImpl.java | 106 +++--- .../impl/SalaryEmployeeServiceImpl.java | 5 + .../wrapper/SalaryAcctEmployeeWrapper.java | 4 +- .../wrapper/SalaryAcctResultWrapper.java | 22 +- 22 files changed, 852 insertions(+), 119 deletions(-) create mode 100644 src/com/engine/salary/encrypt/report/SalaryAcctResultReportPOEncrypt.java create mode 100644 src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java create mode 100644 src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java create mode 100644 src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.java create mode 100644 src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.xml diff --git a/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java b/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java index a7421ccf0..561a395a4 100644 --- a/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java +++ b/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java @@ -10,7 +10,7 @@ import java.util.Map; /** * @Author weaver_cl - * @Description: TODO + * @Description: * @Date 2022/3/12 * @Version V1.0 **/ diff --git a/src/com/engine/salary/encrypt/report/SalaryAcctResultReportPOEncrypt.java b/src/com/engine/salary/encrypt/report/SalaryAcctResultReportPOEncrypt.java new file mode 100644 index 000000000..37232d0e2 --- /dev/null +++ b/src/com/engine/salary/encrypt/report/SalaryAcctResultReportPOEncrypt.java @@ -0,0 +1,34 @@ +package com.engine.salary.encrypt.report; + +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; + +import java.util.Collection; + +/** + * 薪资核算报表 + */ +public class SalaryAcctResultReportPOEncrypt { + + public static Collection encryptList(Collection list) { + if (list == null || list.size() == 0) { + return list; + } + list.forEach(item -> { + item.setEmployeeId(AESEncryptUtil.encrypt(item.getEmployeeId())); + item.setSalaryAcctEmpId(AESEncryptUtil.encrypt(item.getSalaryAcctEmpId())); + }); + return list; + } + + public static Collection decryptList(Collection list) { + if (list == null || list.size() == 0) { + return list; + } + list.forEach(item -> { + item.setEmployeeId(AESEncryptUtil.decrypt(item.getEmployeeId())); + item.setSalaryAcctEmpId(AESEncryptUtil.decrypt(item.getSalaryAcctEmpId())); + }); + return list; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java index 6f85d1e4f..0b32fc302 100644 --- a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java +++ b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java @@ -39,9 +39,16 @@ public class DataCollectionEmployee { @SalaryFormulaVar(defaultLabel = "部门ID", labelId = 86185, dataType = "string") private Long departmentId; + //分部 private String subcompanyName; private Long subcompanyid; + //所属成本中心 + private Long costcenterId; + + //工作地点 + private Long locationId; + //岗位 @SalaryFormulaVar(defaultLabel = "岗位", labelId = 90633, dataType = "string") private String jobtitleName; diff --git a/src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java b/src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java new file mode 100644 index 000000000..b7534567d --- /dev/null +++ b/src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java @@ -0,0 +1,100 @@ +package com.engine.salary.entity.report.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO; +import dm.jdbc.util.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +public class SalaryAcctResultReportBO { + + + /** + * 薪资核算结果保存参数转换成薪资核算结果po + * + * @param saveParam 前端保存参数 + * @param salaryAcctEmployee 薪资核算人员po + * @param employeeId 当前登陆人员id + * @return + */ + public static List convert2PO(SalaryAcctResultSaveParam saveParam, + SalaryAcctEmployeePO salaryAcctEmployee, + Long employeeId, Map emps) { + if (CollectionUtils.isEmpty(saveParam.getItems())) { + return Collections.emptyList(); + } + Date now = new Date(); + return saveParam.getItems().stream() + .map(e -> { + SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder() + .id(IdGenerator.generate()) + .salarySobId(salaryAcctEmployee.getSalarySobId()) + .salaryItemId(e.getSalaryItemId()) + .salaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId()) + .salaryAcctEmpId(salaryAcctEmployee.getId().toString()) + .employeeId(salaryAcctEmployee.getEmployeeId().toString()) + .taxAgentId(salaryAcctEmployee.getTaxAgentId()) + .resultValue(e.getResultValue()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + DataCollectionEmployee dataCollectionEmployee = emps.get(salaryAcctEmployee.getEmployeeId()); + if (dataCollectionEmployee != null) { + po.setDepartmentId(dataCollectionEmployee.getDepartmentId()); + po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid()); + po.setCostcenterId(dataCollectionEmployee.getCostcenterId()); + po.setJobtitleId(dataCollectionEmployee.getJobtitleId()); + po.setLocationId(dataCollectionEmployee.getLocationId()); + } + return po; + }) + .collect(Collectors.toList()); + } + + + public static List convert2ReportPO(Collection temps, Map emps) { +// Map longDataCollectionEmployeeMap = SalaryEntityUtil.convert2Map(emps, DataCollectionEmployee::getEmployeeId); + if (CollectionUtils.isEmpty(temps)) { + return Collections.emptyList(); + } + return temps.stream().map(e -> { + SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder() + .id(IdGenerator.generate()) + .salarySobId(e.getSalarySobId()) + .salaryAcctEmpId(e.getSalaryAcctEmpId().toString()) + .salaryAcctRecordId(e.getSalaryAcctRecordId()) + .employeeId(e.getEmployeeId().toString()) + .taxAgentId(e.getTaxAgentId()) + .salaryItemId(e.getSalaryItemId()) + .resultValue(e.getResultValue()) + .creator(e.getCreator()) + .createTime(e.getCreateTime()) + .updateTime(e.getUpdateTime()) + .deleteType(e.getDeleteType()) + .tenantKey(e.getTenantKey()) + .build(); + + Long employeeId = e.getEmployeeId(); + DataCollectionEmployee dataCollectionEmployee = emps.get(employeeId); + if (dataCollectionEmployee != null) { + po.setDepartmentId(dataCollectionEmployee.getDepartmentId()); + po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid()); + po.setCostcenterId(dataCollectionEmployee.getCostcenterId()); + po.setJobtitleId(dataCollectionEmployee.getJobtitleId()); + po.setLocationId(dataCollectionEmployee.getLocationId()); + } + return po; + }).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java b/src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java new file mode 100644 index 000000000..400a8ab2d --- /dev/null +++ b/src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java @@ -0,0 +1,91 @@ +package com.engine.salary.entity.report.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资核算结果表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctResultReportPO { + private Long id; + /** + * 薪资帐套id + */ + private Long salarySobId; + /** + * 薪资核算人员id + */ + private String salaryAcctEmpId; + /** + * 薪资核算的id + */ + private Long salaryAcctRecordId; + /** + * 人员id + */ + private String employeeId; + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + /** + * 薪资项目的id + */ + private Long salaryItemId; + /** + * 计算后的值 + */ + private String resultValue; + /** + * 创建人 + */ + private Long creator; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 租户ID + */ + private String tenantKey; + /** + * 所属部门 + */ + private Long departmentId; + /** + * 所属分部 + */ + private Long subcompanyId; + /** + * 所属成本中心 + */ + private Long costcenterId; + /** + * 岗位 + */ + private Long jobtitleId; + /** + * 工作地点 + */ + private Long locationId; + + //主键id集合 + private Collection ids; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java index 4aed4b74b..9204ac5bf 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java @@ -153,6 +153,7 @@ public class SalaryAcctResultBO { /** * 构建核算结果表头-供报表使用 + * * @param salarySobItemAggregateDTO * @return */ @@ -567,4 +568,7 @@ public class SalaryAcctResultBO { return salaryAcctResult; }).collect(Collectors.toList()); } + + + } diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java index 52c3b7f13..b09c535ce 100644 --- a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.salaryacct.param; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,6 +8,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.util.Collection; +import java.util.Map; /** * 薪资核算的参数 @@ -27,4 +29,9 @@ public class SalaryAcctCalculateParam { @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") private Long salaryAcctRecordId; + + /** + * 人员信息,报表使用 + */ + private Map emps; } diff --git a/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java index 97d34d429..ce88f5e9b 100644 --- a/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java +++ b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java @@ -13,7 +13,7 @@ import java.util.Objects; /** * @Author weaver_cl - * @Description: TODO + * @Description: * @Date 2022/3/15 * @Version V1.0 **/ diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.java b/src/com/engine/salary/mapper/datacollection/EmployMapper.java index 551740b04..9202a26af 100644 --- a/src/com/engine/salary/mapper/datacollection/EmployMapper.java +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.java @@ -5,7 +5,6 @@ import com.engine.salary.entity.hrm.DeptInfo; import com.engine.salary.entity.hrm.PositionInfo; import com.engine.salary.entity.hrm.SubCompanyInfo; import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; -import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.Collection; @@ -40,6 +39,12 @@ public interface EmployMapper { List listAllFields(); + /** + * 报表专用 + * @return + */ + List listAllForReport(); + List listPositionInfo(@Param("collection") List ids); List getDeptInfoList(@Param("departmentIds") List departmentIds); diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml index b3d45863f..82659d6e3 100644 --- a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml @@ -7,10 +7,11 @@ e.LASTNAME as username, d.DEPARTMENTNAME as departmentName, e.status, - e.mobile + e.mobile from hrmresource e left join hrmdepartment d on e.departmentid = d.id - where e.status not in (7) and (e.accounttype is null or e.accounttype = 0) + where e.status not in (7) + and (e.accounttype is null or e.accounttype = 0) @@ -214,10 +216,10 @@ e.lastname as username, e.status as status, e.workcode as workcode, - e.certificatenum as idNo, + e.certificatenum as idNo, e.companystartdate as companystartdate, e.mobile as mobile, - e.subcompanyid1 as subcompanyid, + e.subcompanyid1 as subcompanyid, d.departmentname as departmentName, d.id as departmentId, c.jobtitlename as jobtitleName, @@ -230,6 +232,25 @@ + + + + SELECT + + FROM hrsa_salary_acct_result_report t + WHERE delete_type = 0 + + AND salary_sob_id = #{salarySobId} + + + AND salary_acct_emp_id = #{salaryAcctEmpId} + + + AND salary_acct_record_id = #{salaryAcctRecordId} + + + AND employee_id = #{employeeId} + + + AND tax_agent_id = #{taxAgentId} + + + AND salary_item_id = #{salaryItemId} + + + AND result_value = #{resultValue} + + + AND creator = #{creator} + + + AND create_time = #{createTime} + + + AND update_time = #{updateTime} + + + AND delete_type = #{deleteType} + + + AND tenant_key = #{tenantKey} + + + AND department_id = #{departmentId} + + + AND subcompany_id = #{subcompanyId} + + + AND costcenter_id = #{costcenterId} + + + AND jobtitle_id = #{jobtitleId} + + + AND location_id = #{locationId} + + + AND id IN + + #{id} + + + ORDER BY id DESC + + + + + + UPDATE hrsa_salary_acct_result_report + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + INSERT INTO hrsa_salary_acct_result_report( + id + , salary_sob_id + , salary_acct_emp_id + , salary_acct_record_id + , employee_id + , tax_agent_id + , salary_item_id + , result_value + , creator + , create_time + , update_time + , delete_type + , tenant_key + , department_id + , subcompany_id + , costcenter_id + , jobtitle_id + , location_id) + VALUES + + ( + #{item.id} + , #{item.salarySobId} + , #{item.salaryAcctEmpId} + , #{item.salaryAcctRecordId} + , #{item.employeeId} + , #{item.taxAgentId} + , #{item.salaryItemId} + , #{item.resultValue} + , #{item.creator} + , #{item.createTime} + , #{item.updateTime} + , #{item.deleteType} + , #{item.tenantKey} + , #{item.departmentId} + , #{item.subcompanyId} + , #{item.costcenterId} + , #{item.jobtitleId} + , #{item.locationId} + ) + + + + + INSERT INTO hrsa_salary_acct_result_report( + id + , salary_sob_id + , salary_acct_emp_id + , salary_acct_record_id + , employee_id + , tax_agent_id + , salary_item_id + , result_value + , creator + , create_time + , update_time + , delete_type + , tenant_key + , department_id + , subcompany_id + , costcenter_id + , jobtitle_id + , location_id) + + select + #{item.id} + , #{item.salarySobId} + , #{item.salaryAcctEmpId} + , #{item.salaryAcctRecordId} + , #{item.employeeId} + , #{item.taxAgentId} + , #{item.salaryItemId} + , #{item.resultValue} + , #{item.creator} + , #{item.createTime} + , #{item.updateTime} + , #{item.deleteType} + , #{item.tenantKey} + , #{item.departmentId} + , #{item.subcompanyId} + , #{item.costcenterId} + , #{item.jobtitleId} + , #{item.locationId} + from dual + + + + + + INSERT INTO hrsa_salary_acct_result_report + ( + id + , salary_sob_id + , salary_acct_emp_id + , salary_acct_record_id + , employee_id + , tax_agent_id + , salary_item_id + , result_value + , creator + , create_time + , update_time + , delete_type + , tenant_key + , department_id + , subcompany_id + , costcenter_id + , jobtitle_id + , location_id) + VALUES + ( + #{item.id} + , #{item.salarySobId} + , #{item.salaryAcctEmpId} + , #{item.salaryAcctRecordId} + , #{item.employeeId} + , #{item.taxAgentId} + , #{item.salaryItemId} + , #{item.resultValue} + , #{item.creator} + , #{item.createTime} + , #{item.updateTime} + , #{item.deleteType} + , #{item.tenantKey} + , #{item.departmentId} + , #{item.subcompanyId} + , #{item.costcenterId} + , #{item.jobtitleId} + , #{item.locationId} + ) + + + + + + DELETE FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + DELETE + FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_record_id = #{salaryAcctRecordId} + + + + DELETE FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_emp_id IN + + #{salaryAcctEmpId} + + + + + + DELETE FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_emp_id IN + + #{salaryAcctEmpId} + + AND salary_item_id IN + + #{salaryItemId} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SalaryAcctReportService.java b/src/com/engine/salary/service/SalaryAcctReportService.java index 5dcc23958..4d3f8206e 100644 --- a/src/com/engine/salary/service/SalaryAcctReportService.java +++ b/src/com/engine/salary/service/SalaryAcctReportService.java @@ -1,5 +1,8 @@ package com.engine.salary.service; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; + +import java.util.Collection; import java.util.List; /** @@ -29,4 +32,28 @@ public interface SalaryAcctReportService { */ String decrypt(String s); + /** + * 保存核算记录报表数据 + * @param pos + */ + void batchSave(Collection pos); + + /** + * 根据核算记录删除 + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + + void deleteBySalaryAcctRecordId(Long salaryAcctRecordId); + + void deleteBySalaryAcctEmpIds(Collection salaryAcctEmpIds); + + /** + * 根据薪资核算人员id、薪资项目id删除薪资核算结果 + * + * @param salaryAcctEmployeeIds 薪资核算人员id + * @param salaryItemIds 薪资项目id + */ + void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection salaryAcctEmployeeIds, Collection salaryItemIds); + } diff --git a/src/com/engine/salary/service/SalaryEmployeeService.java b/src/com/engine/salary/service/SalaryEmployeeService.java index 445ccb0b9..d5bf2f191 100644 --- a/src/com/engine/salary/service/SalaryEmployeeService.java +++ b/src/com/engine/salary/service/SalaryEmployeeService.java @@ -21,6 +21,12 @@ public interface SalaryEmployeeService { */ List listAll(); + /** + * 获取报表人员字段 + * @return + */ + List listAllForReport(); + /** * 根据薪资账套id查询人员 * diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java index 32d253f1f..29d713a90 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -57,9 +57,9 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); } -// private SalaryAcctResultService getSalaryAcctResultService(User user) { -// return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); -// } + private SalaryAcctReportServiceImpl getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } // private SalaryCheckResultDetailService salaryCheckResultDetailService; @@ -74,7 +74,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } private SalaryArchiveService getSalaryArchiveService(User user) { - return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); } private TaxAgentService getTaxAgentService(User user) { @@ -131,20 +131,9 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } // 添加薪资核算人员 Date now = new Date(); - List newSalaryAcctEmployeePOS = salaryAcctEmployeePOS.stream() - .map(salaryAcctEmployeePO -> new SalaryAcctEmployeePO() + List newSalaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().map(salaryAcctEmployeePO -> new SalaryAcctEmployeePO() // .setId(IdGenerator.generate()) - .setSalaryAcctRecordId(salaryAcctRecordPO.getId()) - .setSalarySobId(salaryAcctRecordPO.getSalarySobId()) - .setSalaryMonth(salaryAcctRecordPO.getSalaryMonth()) - .setEmployeeId(salaryAcctEmployeePO.getEmployeeId()) - .setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()) - .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .setCreateTime(now) - .setUpdateTime(now) - .setCreator((long) user.getUID()) - .setDeleteType(0)) - .collect(Collectors.toList()); + .setSalaryAcctRecordId(salaryAcctRecordPO.getId()).setSalarySobId(salaryAcctRecordPO.getSalarySobId()).setSalaryMonth(salaryAcctRecordPO.getSalaryMonth()).setEmployeeId(salaryAcctEmployeePO.getEmployeeId()).setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()).setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).setCreateTime(now).setUpdateTime(now).setCreator((long) user.getUID()).setDeleteType(0)).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) { batchSave(newSalaryAcctEmployeePOS); } @@ -340,6 +329,9 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct getSalaryAcctEmployeeMapper().deleteByIds(ids); // 删除薪资核算人员对应的薪资核算结果 getSalaryAcctResultService(user).deleteBySalaryAcctEmployeeIds(ids); + // 删除报表 + getSalaryAcctReportService(user).deleteBySalaryAcctEmpIds(ids); + // 删除薪资核算人员对应的校验异常明细 // salaryCheckResultDetailService.deleteBySalaryAcctEmployeeIds(ids); // 删除薪资核算人员对应的线下对比结果 @@ -401,17 +393,11 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct List finalSalaryEmployees = new ArrayList<>(); // 根据薪资账套的"核算人员范围"过滤入职日期大于薪资周期止的人员 - salaryEmployees = salaryEmployees.stream() - .filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getCompanystartdate()) - || (SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()) != null && SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) <= 0)) - .collect(Collectors.toList()); + salaryEmployees = salaryEmployees.stream().filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getCompanystartdate()) || (SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()) != null && SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) <= 0)).collect(Collectors.toList()); // 根据薪资账套的"核算人员范围"过滤离职日期小于薪资周期起的人员 - salaryEmployees = salaryEmployees.stream() - .filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getDismissdate()) - || (SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()) != null && SalaryDateUtil.stringToDate(salaryEmployee.getDismissdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) > 0)) - .collect(Collectors.toList()); + salaryEmployees = salaryEmployees.stream().filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getDismissdate()) || (SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()) != null && SalaryDateUtil.stringToDate(salaryEmployee.getDismissdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) > 0)).collect(Collectors.toList()); //查询账套对应的扣缴义务人 @@ -419,9 +405,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct Long taxAgentId = salarySobPO.getTaxAgentId(); //过滤扣税扣缴义务人不包含的人员 Collection employeeIdsInTaxAgent = getTaxAgentService(user).listEmployeeIdsInTaxAgent(taxAgentId); - salaryEmployees = salaryEmployees.stream() - .filter(salaryEmployee -> employeeIdsInTaxAgent.contains(salaryEmployee.getEmployeeId())) - .collect(Collectors.toList()); + salaryEmployees = salaryEmployees.stream().filter(salaryEmployee -> employeeIdsInTaxAgent.contains(salaryEmployee.getEmployeeId())).collect(Collectors.toList()); // 查询薪资档案,获取人员的个税扣缴义务人 Set employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId); @@ -430,7 +414,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(employeeIds, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); //过滤掉不属于当前账套扣缴义务人的人员 - salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(po->Objects.equals(taxAgentId,po.getTaxAgentId())).collect(Collectors.toList()); + salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList()); // 保存薪资核算人员 if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) { @@ -452,8 +436,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); } // 查询薪资核算记录所用的帐套的薪资周期 - SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), - SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); // 查询薪资档案,获取人员的个税扣缴义务人 List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds); // 转换成薪资核算人员po @@ -462,7 +445,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); //过滤掉不属于当前账套扣缴义务人的人员 Long taxAgentId = salarySobPO.getTaxAgentId(); - newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po->Objects.equals(taxAgentId,po.getTaxAgentId())).collect(Collectors.toList()); + newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList()); // 删除以前的薪资核算人员 getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); // 插入新的薪资核算人员 diff --git a/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java index 1b76c9328..e800229a9 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java @@ -6,6 +6,7 @@ import com.engine.core.impl.Service; import com.engine.salary.component.WeaTableColumnGroup; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO; import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO; @@ -36,6 +37,7 @@ import com.engine.salary.util.valid.ValidUtil; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import dm.jdbc.util.IdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -110,6 +112,9 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc private SalarySobCheckRuleService salarySobCheckRuleService; + private SalaryAcctReportService getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } @Override public XSSFWorkbook exportSalaryAcctEmployee(SalaryAcctEmployeeQueryParam queryParam) { @@ -502,8 +507,9 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId); Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, e -> e.getEmployeeId() + "-" + e.getTaxAgentId()); // 租户下所有的人员 - List salaryEmployees = getSalaryEmployeeService(user).listAll(); + List salaryEmployees = getSalaryEmployeeService(user).listAllForReport(); Map salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getUsername, DataCollectionEmployee::getEmployeeId); + Map emps = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getEmployeeId); // 租户下所有的个税扣缴义务人 List taxAgents = getTaxAgentService(user).listAll(); Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId); @@ -527,6 +533,7 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc // excel导入了哪些薪资项目 Set excelSalaryItemIds = Sets.newHashSet(); List salaryAcctResults = Lists.newArrayList(); + List salaryAcctReports = Lists.newArrayList(); List newSalaryAcctEmployees = Lists.newArrayList(); List excelAcctResults = Lists.newArrayList(); @@ -562,6 +569,7 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc Long employeeId = 0L; Long taxAgentId = 0L; List salaryAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1); + List salaryAcctResultReportOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1); List excelAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1); for (int j = 0; j < headers.size(); j++) { String header = headers.get(j); @@ -644,6 +652,21 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .build(); salaryAcctResultsOfOneEmp.add(salaryAcctResult); + + + SalaryAcctResultReportPO reportPO = SalaryAcctResultReportPO.builder() + .id(IdGenerator.generate()) + .salaryAcctRecordId(salaryAcctRecordPO.getId()) + .salarySobId(salaryAcctRecordPO.getSalarySobId()) + .salaryItemId(salaryItemId) + .resultValue(dataValue) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + salaryAcctResultReportOfOneEmp.add(reportPO); } } } @@ -703,8 +726,24 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc salaryAcctResultPO.setTaxAgentId(taxAgentId); salaryAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId); } + + for (SalaryAcctResultReportPO po : salaryAcctResultReportOfOneEmp) { + po.setEmployeeId(employeeId.toString()); + po.setTaxAgentId(taxAgentId); + po.setSalaryAcctEmpId(salaryAcctEmpId.toString()); + + + DataCollectionEmployee emp = emps.get(employeeId); + po.setSubcompanyId(emp.getSubcompanyid()); + po.setDepartmentId(emp.getDepartmentId()); + po.setCostcenterId(emp.getCostcenterId()); + po.setJobtitleId(emp.getJobtitleId()); + po.setLocationId(emp.getLocationId()); + + } salaryAcctEmpIds.add(salaryAcctEmpId); salaryAcctResults.addAll(salaryAcctResultsOfOneEmp); + salaryAcctReports.addAll(salaryAcctResultReportOfOneEmp); } successCount++; } @@ -721,9 +760,13 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc if (StringUtils.equals("importSalaryAcctResult", importType)) { if (CollectionUtils.isNotEmpty(salaryAcctEmpIds)) { getSalaryAcctResultService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, excelSalaryItemIds); + //删除报表 + getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, excelSalaryItemIds); } if (CollectionUtils.isNotEmpty(salaryAcctResults)) { getSalaryAcctResultService(user).batchSave(salaryAcctResults); + //报表 + getSalaryAcctReportService(user).batchSave(salaryAcctReports); } if (CollectionUtils.isNotEmpty(newSalaryAcctEmployees)) { getSalaryAcctEmployeeService(user).batchSave(newSalaryAcctEmployees); diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 5a4fe3845..3ee8b0ada 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -85,6 +85,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } + private SalaryAcctReportService getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } + @Override public SalaryAcctRecordPO getById(Long id) { return getSalaryAcctRecordMapper().getById(id); @@ -369,6 +373,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe getSalaryAcctEmployeeService(user).deleteBySalaryAcctRecordIds(ids); // 删除薪资核算结果 getSalaryAcctResultService(user).deleteBySalaryAcctRecordIds(ids); + //报表 + getSalaryAcctReportService(user).deleteBySalaryAcctRecordIds(ids); // 删除校验异常 // salaryCheckResultService.deleteBySalaryAcctRecordIds(ids); // 删除校验异常明细 diff --git a/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java index 213fbc91e..f0983c3e6 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java @@ -2,9 +2,15 @@ package com.engine.salary.service.impl; 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.util.db.MapperProxyFactory; import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -18,6 +24,10 @@ import java.util.stream.Collectors; **/ public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctReportService { + private SalaryAcctResultReportMapper getSalaryAcctResultReportMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultReportMapper.class); + } + /** * 薪酬解密方法 * @@ -43,4 +53,46 @@ public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctRe return AESEncryptUtil.decrypt(s); } + /** + * 保存核算报表数据 + * + * @param pos + */ + @Override + public void batchSave(Collection pos) { + if (CollectionUtils.isNotEmpty(pos)) { + SalaryAcctResultReportPOEncrypt.encryptList(pos); + List> partition = Lists.partition((List) pos, 100); + partition.forEach(getSalaryAcctResultReportMapper()::batchInsert); + } + } + + @Override + public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + if (CollectionUtils.isNotEmpty(salaryAcctRecordIds)) { + List> partition = Lists.partition((List) salaryAcctRecordIds, 100); + partition.forEach(getSalaryAcctResultReportMapper()::deleteBySalaryAcctRecordIds); + } + } + + @Override + public void deleteBySalaryAcctRecordId(Long salaryAcctRecordId) { + getSalaryAcctResultReportMapper().deleteBySalaryAcctRecordId(salaryAcctRecordId); + } + + @Override + public void deleteBySalaryAcctEmpIds(Collection salaryAcctEmpIds) { + if (CollectionUtils.isNotEmpty(salaryAcctEmpIds)) { + List collect = salaryAcctEmpIds.stream().map(e -> AESEncryptUtil.encrypt(e.toString())).collect(Collectors.toList()); + getSalaryAcctResultReportMapper().deleteBySalaryAcctEmpIds(collect); + } + } + + @Override + public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection salaryAcctEmployeeIds, Collection salaryItemIds) { + if (CollectionUtils.isNotEmpty(salaryAcctEmployeeIds) && CollectionUtils.isNotEmpty(salaryItemIds)) { + List salaryAcctEmployeeIdsStr = salaryAcctEmployeeIds.stream().map(e -> AESEncryptUtil.encrypt(e.toString())).collect(Collectors.toList()); + getSalaryAcctResultReportMapper().deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIdsStr, salaryItemIds); + } + } } diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java index ca8073e6c..5556535e1 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -7,6 +7,8 @@ import com.engine.salary.common.LocalDateRange; import com.engine.salary.encrypt.salaryacct.SalaryAcctResultPOEncrypt; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.report.bo.SalaryAcctResultReportBO; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO; @@ -73,27 +75,27 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe } private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { - return (SalaryAcctEmployeeService) ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); } private SalarySobItemService getSalarySobItemService(User user) { - return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); } private SalaryItemService getSalaryItemService(User user) { - return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); } private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { - return (SalarySobEmpFieldService) ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); } private SalarySobService getSalarySobService(User user) { - return (SalarySobService) ServiceUtil.getService(SalarySobServiceImpl.class, user); + return ServiceUtil.getService(SalarySobServiceImpl.class, user); } private SalaryAcctRecordService getSalaryAcctRecordService(User user) { - return (SalaryAcctRecordService) ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); } private TaxAgentService getTaxAgentService(User user) { @@ -101,38 +103,42 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe } private SalaryEmployeeService getSalaryEmployeeService(User user) { - return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); } private SalaryFormulaService getSalaryFormulaService(User user) { - return (SalaryFormulaService) ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); } private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) { - return (SalarySobAdjustRuleService) ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); + return ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); } private SalaryAcctCalculateService getSalaryAcctCalculateService(User user) { - return (SalaryAcctCalculateService) ServiceUtil.getService(SalaryAcctCalculateServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctCalculateServiceImpl.class, user); } private SalaryAcctProgressService getSalaryAcctProgressService(User user) { - return (SalaryAcctProgressService) ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user); } private DataSourceTransactionManager dataSourceTransactionManager; private SalaryAcctResultTempService getSalaryAcctResultTempService(User user) { - return (SalaryAcctResultTempService) ServiceUtil.getService(SalaryAcctResultTempServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctResultTempServiceImpl.class, user); } // private LoggerTemplate salaryAcctRecordLoggerTemplate; private SIAccountService getSIAccountService(User user) { - return (SIAccountService) ServiceUtil.getService(SIAccountServiceImpl.class, user); + return ServiceUtil.getService(SIAccountServiceImpl.class, user); } private AttendQuoteFieldService getAttendQuoteFieldService(User user) { - return (AttendQuoteFieldService) ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + + private SalaryAcctReportService getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); } private SalaryCheckResultService salaryCheckResultService; @@ -142,8 +148,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { return Collections.emptyList(); } - List salaryAcctResultPOS = - getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build()); + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build()); SalaryAcctResultPOEncrypt.decryptList(salaryAcctResultPOS); return salaryAcctResultPOS; } @@ -231,8 +236,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe * @param queryParam 列表查询条件 * @return */ - private List> listBySalaryAcctEmployees(List salaryAcctEmployeePOS, - SalaryAcctResultQueryParam queryParam) { + private List> listBySalaryAcctEmployees(List salaryAcctEmployeePOS, SalaryAcctResultQueryParam queryParam) { if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { return Collections.emptyList(); } @@ -263,10 +267,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); } else { // 如果查询条件中没有包含"合并计税",那么就需要查询出存在合并计税的人,标记给前端 - SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder() - .salaryAcctRecordId(queryParam.getSalaryAcctRecordId()) - .ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId)) - .build(); + SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryAcctRecordId(queryParam.getSalaryAcctRecordId()).ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId)).build(); List salaryAcctEmployeePOS4ConsolidatedTax = getSalaryAcctEmployeeService(user).listByParam4ConsolidatedTax(accEmployeeQueryParam); salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId); } @@ -281,8 +282,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe return expressFormulaMap.getOrDefault(salarySobItemPO.getFormulaId(), StringUtils.EMPTY); }); // 转换成薪资核算结果列表 - return SalaryAcctResultBO - .buildTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS, salaryAcctEmployeeIds4ConsolidatedTax, customParameters); + return SalaryAcctResultBO.buildTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS, salaryAcctEmployeeIds4ConsolidatedTax, customParameters); } @@ -317,8 +317,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIdsAndSalaryMonth(salarySobIds, taxCycleDateRange); // 查询当前薪资核算人员所涉及的合并计税的所有薪资核算人员 Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); - salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds, - salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId()); + salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds, salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId()); } // 查询薪资核算人员的薪资核算结果 Set salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); @@ -332,12 +331,15 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); // 转换成合并计税详情dto - return SalaryAcctResultBO.convert2ConsolidatedTaxDetailDTO(simpleEmployee, taxAgentPO, salarySobEmpFieldPOS, salaryItemPOS, - salaryAcctEmployeePOS, salarySobPOS, salaryAcctRecordPOS, salaryAcctResultPOS); + return SalaryAcctResultBO.convert2ConsolidatedTaxDetailDTO(simpleEmployee, taxAgentPO, salarySobEmpFieldPOS, salaryItemPOS, salaryAcctEmployeePOS, salarySobPOS, salaryAcctRecordPOS, salaryAcctResultPOS); } @Override public void save(SalaryAcctResultSaveParam saveParam) { + + List dataCollectionEmployees = getSalaryEmployeeService(user).listAllForReport(); + Map emps = SalaryEntityUtil.convert2Map(dataCollectionEmployees, DataCollectionEmployee::getEmployeeId); + // 查询薪资核算人员 SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(saveParam.getSalaryAcctEmpId()); if (Objects.isNull(salaryAcctEmployeePO)) { @@ -353,10 +355,14 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe SalaryAcctResultPOEncrypt.encryptList(salaryAcctResultPOS); List> partition = Lists.partition(salaryAcctResultPOS, 100); partition.forEach(getSalaryAcctResultMapper()::batchInsert); - - //todo 报表 } + //报表 + getSalaryAcctReportService(user).deleteBySalaryAcctEmpIds(Collections.singleton(saveParam.getSalaryAcctEmpId())); + List salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2PO(saveParam, salaryAcctEmployeePO, (long) user.getUID(), emps); + if (CollectionUtils.isNotEmpty(salaryAcctResultReportPOS)) { + getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS); + } // 查询操作日志的targetName // String targetName = getSalaryAcctRecordService(user).getLogTargetNameById(salaryAcctEmployeePO.getSalaryAcctRecordId()); @@ -379,16 +385,15 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe @Override public void batchSave(Collection salaryAcctResultPOS) { if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) { - List list = (List)salaryAcctResultPOS; + List list = (List) salaryAcctResultPOS; // 数据加密 SalaryAcctResultPOEncrypt.encryptList(list); List> partition = Lists.partition(list, 100); partition.forEach(getSalaryAcctResultMapper()::batchInsert); - - //todo 报表 } } + @Override public void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds) { getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds); @@ -456,14 +461,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空")); } // 11.1、初始化进度 - SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO() - .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")) - .setTitleLabelId(97515L) - .setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1) - .setCalculatedQuantity(0) - .setProgress(BigDecimal.ZERO) - .setStatus(true) - .setMessage(StringUtils.EMPTY); + SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY); getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), initProgress); // 12、对薪资核算人员进行拆分 List> partition = Lists.partition(salaryAcctEmployeePOS, 500); @@ -475,22 +473,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe String calculateKey = UUID.randomUUID().toString(); // 12.4、多线程运算,运算结果存放在临时表中 for (List acctEmployeePOS : partition) { - SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO() - .setSalaryAcctRecordPO(salaryAcctRecordPO) - .setSalarySobPO(salarySobPO) - .setSalarySobCycleDTO(salarySobCycleDTO) - .setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS) - .setSalarySobItemPOS(salarySobItemPOS) - .setSalaryItemIdWithPriorityList(salarySobItemsWithPriority) - .setExpressFormulas(expressFormulas) - .setSalaryItemPOS(salaryItemPOS) - .setSalarySobAdjustRulePOS(salarySobAdjustRulePOS) - .setWelfareColumns(MapUtils.emptyIfNull(welfareColumns)) - .setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS) - .setSalaryAcctEmployeePOS(acctEmployeePOS) - .setChildMonitor(childMonitor) - .setResults(calculateResults) - .setCalculateKey(calculateKey); + SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO().setSalaryAcctRecordPO(salaryAcctRecordPO).setSalarySobPO(salarySobPO).setSalarySobCycleDTO(salarySobCycleDTO).setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS).setSalarySobItemPOS(salarySobItemPOS).setSalaryItemIdWithPriorityList(salarySobItemsWithPriority).setExpressFormulas(expressFormulas).setSalaryItemPOS(salaryItemPOS).setSalarySobAdjustRulePOS(salarySobAdjustRulePOS).setWelfareColumns(MapUtils.emptyIfNull(welfareColumns)).setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS).setSalaryAcctEmployeePOS(acctEmployeePOS).setChildMonitor(childMonitor).setResults(calculateResults).setCalculateKey(calculateKey); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { @@ -505,10 +488,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe boolean allSuccess = calculateResults.stream().allMatch(SalaryAcctCalculateBO.Result::isStatus); if (!allSuccess) { // 薪资核算实现的线程的错误信息 - String errorMsg = calculateResults.stream() - .filter(result -> !result.isStatus()) - .map(SalaryAcctCalculateBO.Result::getErrMsg) - .collect(Collectors.joining("|")); + String errorMsg = calculateResults.stream().filter(result -> !result.isStatus()).map(SalaryAcctCalculateBO.Result::getErrMsg).collect(Collectors.joining("|")); getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), errorMsg); // 删除薪资核算临时存储表中的数据 getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey); @@ -558,10 +538,14 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(calculateParam.getIds()); } else { getSalaryAcctResultMapper().deleteBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId())); + getSalaryAcctReportService(user).deleteBySalaryAcctRecordId(calculateParam.getSalaryAcctRecordId()); } // 保存薪资的薪资核算结果 List salaryAcctResultPOS = SalaryAcctResultBO.convert2ResultPO(salaryAcctResultTempPOS); batchSave(salaryAcctResultPOS); + //保存核算报表数据 + List salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2ReportPO(salaryAcctResultTempPOS, calculateParam.getEmps()); + getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS); // 删除薪资核算临时存储表中的数据 getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey); // // 提交事务 diff --git a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java index de5530a4f..987bfbabd 100644 --- a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java @@ -47,6 +47,11 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee return employBiz.listEmployee(); } + @Override + public List listAllForReport() { + return getEmployMapper().listAllForReport(); + } + @Override public List listBySalarySobId(Long salarySobId) { // 查询薪资账套的人员范围 diff --git a/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java index 0d1a10e9f..2bf4b4ca3 100644 --- a/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java @@ -38,10 +38,10 @@ import java.util.stream.Collectors; public class SalaryAcctEmployeeWrapper extends Service { private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { - return (SalaryAcctEmployeeService) ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); } private SalaryEmployeeService getSalaryEmployeeService(User user) { - return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); } diff --git a/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java index eb394d092..00df29901 100644 --- a/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java @@ -15,6 +15,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.service.*; import com.engine.salary.service.impl.*; +import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.valid.ValidUtil; @@ -38,30 +39,34 @@ import java.util.*; public class SalaryAcctResultWrapper extends Service { private SalaryAcctResultService getSalaryAcctResultService(User user) { - return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); } private SalaryAcctRecordService getSalaryAcctRecordService(User user) { - return (SalaryAcctRecordService) ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); } private SalarySobItemService getSalarySobItemService(User user) { - return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); } private SalaryAcctEmployeeWrapper getSalaryAcctEmployeeWrapper(User user) { - return (SalaryAcctEmployeeWrapper) ServiceUtil.getService(SalaryAcctEmployeeWrapper.class, user); + return ServiceUtil.getService(SalaryAcctEmployeeWrapper.class, user); } private SalaryAcctProgressService getSalaryAcctProgressService(User user) { - return (SalaryAcctProgressService) ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user); } // private SalaryCheckResultService salaryCheckResultService; private SalaryAcctExcelService getSalaryAcctExcelService(User user) { - return (SalaryAcctExcelService) ServiceUtil.getService(SalaryAcctExcelServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctExcelServiceImpl.class, user); } /** @@ -183,6 +188,11 @@ public class SalaryAcctResultWrapper extends Service { */ public void calculate(SalaryAcctCalculateParam calculateParam) { log.info("开始核算V1{}", calculateParam); + + //报表参数 + List emps = getSalaryEmployeeService(user).listAllForReport(); + calculateParam.setEmps(SalaryEntityUtil.convert2Map(emps,DataCollectionEmployee::getEmployeeId)); + //当前登陆人员 DataCollectionEmployee simpleEmployee = new DataCollectionEmployee(); simpleEmployee.setEmployeeId((long) user.getUID());