From 78ce7121161d253e0bb7b4b9bdceb8c26862ddcc Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 27 Sep 2022 17:36:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E5=8F=B0=E8=B4=A6=EF=BC=8C=E7=BA=BF=E4=B8=8B=E5=AF=B9?= =?UTF-8?q?=E6=AF=94excel=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/ExcelInsuranceImportParam.java | 29 ++ .../siaccount/po/ExcelInsuranceDetailPO.java | 241 ++++++++++++ .../siaccount/ExcelInsuranceDetailMapper.java | 39 ++ .../siaccount/ExcelInsuranceDetailMapper.xml | 341 +++++++++++++++++ .../salary/service/SIAccountService.java | 6 + .../service/impl/SIAccountServiceImpl.java | 359 ++++++++++++++++++ .../salary/web/SIAccountController.java | 10 + 7 files changed, 1025 insertions(+) create mode 100644 src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java create mode 100644 src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java create mode 100644 src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml diff --git a/src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java b/src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java new file mode 100644 index 000000000..17b926b08 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: sy + * @Description: 福利核算-线下对比导入参数 + * @Date: 2022/9/27 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExcelInsuranceImportParam { + /** + * 上传文件id + */ + @DataCheck(require = true,message = "imageId为空") + String imageId; + + /** + * 账单月份 + */ + private String billMonth; +} diff --git a/src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java b/src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java new file mode 100644 index 000000000..7f7544456 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java @@ -0,0 +1,241 @@ +package com.engine.salary.entity.siaccount.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author: sy + * @Description: 线下Excel福利明细表 + * @Date: 2022/9/27 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_excel_bill_detail +public class ExcelInsuranceDetailPO { + + /** + * 主键id + */ + private Long id; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 账单月份,该处的账单月份即导入的数据需要对比的账单月份 + */ + private String billMonth; + + /** + * 账单状态 0-未归档 1-已归档 + */ + private Integer billStatus; + + /** + * 缴纳状态 + */ + private Integer paymentStatus; + + /** + * 补缴月份 + */ + private String supplementaryMonth; + + /** + * 补缴项目 + */ + private String supplementaryProjects; + + /** + * 数据来源 0-系统核算 1-临时数据 + */ + private Integer resourceFrom; + + /** + * 社保缴纳组织 + */ + private Long socialPayOrg; + + /** + * 社保账号 + */ + private String socialAccount; + + /** + * 公积金缴纳组织 + */ + private Long fundPayOrg; + + /** + * 公积金账号 + */ + private String fundAccount; + + /** + * 补充公积金账号 + */ + private String supplementFundAccount; + + /** + * 其他福利缴纳组织 + */ + private Long otherPayOrg; + + /** + * 社保方案ID + */ + private Long socialSchemeId; + + /** + * 社保缴纳基数 + */ + private String socialPaymentBaseString; + + /** + * 公积金方案ID + */ + private Long fundSchemeId; + + /** + * 公积金缴纳基数 + */ + private String fundPaymentBaseString; + + /** + * 其他福利方案id + */ + private Long otherSchemeId; + + /** + * 其他福利缴纳基数 + */ + private String otherPaymentBaseString; + + /** + * 社保个人缴费明细 + */ + private String socialPerJson; + + /** + * 社保个人合计 + */ + private String socialPerSum; + + /** + * 公积金个人缴费明细 + */ + private String fundPerJson; + + /** + * 公积金个人合计 + */ + private String fundPerSum; + + /** + * 其他福利个人缴费明细 + */ + private String otherPerJson; + + /** + * 其他福利个人合计 + */ + private String otherPerSum; + + /** + * 个人合计 + */ + private String perSum; + + /** + * 社保单位缴费明细 + */ + private String socialComJson; + + /** + * 社保单位合计 + */ + private String socialComSum; + + /** + * 公积金单位缴费明细 + */ + private String fundComJson; + + /** + * 公积金单位合计 + */ + private String fundComSum; + + /** + * 其他福利单位缴费明细 + */ + private String otherComJson; + + /** + * 其他福利单位合计 + */ + private String otherComSum; + + /** + * 单位合计 + */ + private String comSum; + + /** + * 社保合计 + */ + private String socialSum; + + /** + * 公积金合计 + */ + private String fundSum; + + /** + * 其他福利合计 + */ + private String otherSum; + + /** + * 合计 + */ + private String total; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 个税扣缴义务人 + */ + private Long paymentOrganization; +} diff --git a/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java new file mode 100644 index 000000000..105c0f636 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java @@ -0,0 +1,39 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @author songyang + */ +public interface ExcelInsuranceDetailMapper { + + /** + * 查询对比数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人 + * @param employeeId 人员id + * @return + */ + List queryCompareList(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("employeeId") Long employeeId); + + /** + * 根据id删除 + * + * @param id + */ + void deleteById(@Param("id") Long id); + + /** + * 根据id批量删除 + */ + void batchDelByIds(@Param("ids") Collection ids); + + /** + * 批量保存 + */ + void batchSave(@Param("accounts") Collection accounts); +} diff --git a/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml new file mode 100644 index 000000000..eda1a1ebb --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml @@ -0,0 +1,341 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , e.status as employee_status + , t.bill_month + , t.bill_status + , t.payment_status + , t.supplementary_month + , t.supplementary_projects + , t.resource_from + , t.social_pay_org + , t.social_account + , t.fund_pay_org + , t.fund_account + , t.supplement_fund_account + , t.other_pay_org + , t.social_scheme_id + , t.social_payment_base_string + , t.fund_scheme_id + , t.fund_payment_base_string + , t.other_scheme_id + , t.other_payment_base_string + , t.social_per_json + , t.social_per_sum + , t.fund_per_json + , t.fund_per_sum + , t.other_per_json + , t.other_per_sum + , t.per_sum + , t.social_com_json + , t.social_com_sum + , t.fund_com_json + , t.fund_com_sum + , t.other_com_json + , t.other_com_sum + , t.com_sum + , t.social_sum + , t.fund_sum + , t.other_sum + , t.total + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + , t.payment_organization + + + + + AND + t.bill_month = #{param.billMonth} + + + AND + t.payment_status = #{param.paymentStatus} + + + AND + t.payment_organization = #{param.paymentOrganization} + + + + + + + + UPDATE hrsa_excel_bill_detail + SET delete_type = 1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_excel_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + INSERT INTO hrsa_excel_bill_detail + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization} + ) + + + + INSERT INTO hrsa_excel_bill_detail + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization) + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.billMonth,jdbcType=VARCHAR}, + #{item.billStatus,jdbcType=INTEGER}, + #{item.paymentStatus,jdbcType=INTEGER}, + #{item.supplementaryMonth,jdbcType=VARCHAR}, + #{item.supplementaryProjects,jdbcType=VARCHAR}, + #{item.resourceFrom,jdbcType=INTEGER}, + #{item.socialPayOrg,jdbcType=DOUBLE}, + #{item.socialAccount,jdbcType=VARCHAR}, + #{item.socialSchemeId,jdbcType=DOUBLE}, + #{item.socialPaymentBaseString,jdbcType=VARCHAR}, + #{item.fundPayOrg,jdbcType=DOUBLE}, + #{item.fundAccount,jdbcType=VARCHAR}, + #{item.supplementFundAccount,jdbcType=VARCHAR}, + #{item.fundSchemeId,jdbcType=DOUBLE}, + #{item.fundPaymentBaseString,jdbcType=VARCHAR}, + #{item.otherPayOrg,jdbcType=DOUBLE}, + #{item.otherSchemeId,jdbcType=DOUBLE}, + #{item.otherPaymentBaseString,jdbcType=VARCHAR}, + #{item.socialPerJson,jdbcType=VARCHAR}, + #{item.socialPerSum,jdbcType=VARCHAR}, + #{item.fundPerJson,jdbcType=VARCHAR}, + #{item.fundPerSum,jdbcType=VARCHAR}, + #{item.otherPerJson,jdbcType=VARCHAR}, + #{item.otherPerSum,jdbcType=VARCHAR}, + #{item.perSum,jdbcType=VARCHAR}, + #{item.socialComJson,jdbcType=VARCHAR}, + #{item.socialComSum,jdbcType=VARCHAR}, + #{item.fundComJson,jdbcType=VARCHAR}, + #{item.fundComSum,jdbcType=VARCHAR}, + #{item.otherComJson,jdbcType=VARCHAR}, + #{item.otherComSum,jdbcType=VARCHAR}, + #{item.comSum,jdbcType=VARCHAR}, + #{item.socialSum,jdbcType=VARCHAR}, + #{item.fundSum,jdbcType=VARCHAR}, + #{item.otherSum,jdbcType=VARCHAR}, + #{item.total,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.paymentOrganization,jdbcType=DOUBLE} + from dual + + + + + INSERT INTO hrsa_excel_bill_detail + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization) + VALUES + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization} + ) + + + + + + + AND e.lastname like CONCAT('%',#{userName},'%') + + + + + + AND e.lastname like '%'||#{userName}||'%' + + + + + + AND e.lastname like '%'+#{userName}+'%' + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index 5e1e3afae..e7e61f8e6 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -232,5 +232,11 @@ public interface SIAccountService { * 导出“福利核算-线下对比导入模板” */ XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAcctDetailImportTemplateParam param); + + /** + * 将通过“福利核算-线下对比导入”模板导入的数据更新到hrsa_excel_bill_detail表中 + */ + Map importExcelInsuranceDetail(ExcelInsuranceImportParam excelInsuranceImportParam); + } diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index eb1dcdee4..3146f3aa2 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -20,11 +20,13 @@ import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.param.*; +import com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.enums.siaccount.BillStatusEnum; @@ -33,10 +35,12 @@ import com.engine.salary.enums.siaccount.PaymentStatusEnum; import com.engine.salary.enums.siaccount.ProjectTypeEnum; import com.engine.salary.enums.sicategory.WelfareTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.siaccount.ExcelInsuranceDetailMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper; import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; import com.engine.salary.service.*; @@ -113,6 +117,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class); } + private ExcelInsuranceDetailMapper getExcelInsuranceDetailMapper() { + return MapperProxyFactory.getProxy(ExcelInsuranceDetailMapper.class); + } + private SalaryItemService getSalaryItemService(User user) { return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); } @@ -131,6 +139,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); } + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + private EmployBiz employeeBiz = new EmployBiz(); private TaxAgentBiz taxAgentBiz = new TaxAgentBiz(); @@ -1641,5 +1653,352 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return ExcelUtil.genWorkbookV2(rows, sheetName); } + /** + * 将通过“福利核算-线下对比导入”模板导入的数据更新到hrsa_excel_bill_detail表中 + */ + @Override + public Map importExcelInsuranceDetail(ExcelInsuranceImportParam importParam) { + + Map apidatas = new HashMap(); + EmployBiz employBiz = new EmployBiz(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + //检验参数 + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + + // 获取租户下所有的人员 + List salaryEmployees = employBiz.listEmployee(); + + // 失败的数量 + int failCount = 0; + // 成功的数量 + int successCount = 0; + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(importParam.getImageId())); + + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + + // 错误提示信息 + List excelComments = Lists.newArrayList(); + // 存在错误的那行数据 + List> errorDatas = Lists.newArrayList(); + // 表头 + List headers = ExcelSupport.getSheetHeader(sheet, 0); + // 处理数值 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + if (CollectionUtils.isEmpty(headers)) { + throw new RuntimeException("表头为空"); + } + if (CollectionUtils.isEmpty(data)) { + throw new RuntimeException("无数据"); + } + + String billMonth = importParam.getBillMonth(); + //存储待更新的InsuranceAccountDetailPO数据 + List addCompareList = new ArrayList<>(); + //记录待删除hrsa_excel_bill_detail.id + List idList = new ArrayList<>(); + //遍历excel表具体数据 + for (int i = 0; i < data.size(); i++) { + + String row = "第" + (i + 2) + "行"; + + boolean isError = false; + Map map = data.get(i); + Long employeeId = 0L; + + List list = new ArrayList<>(); + + String taxAgentName = (String) map.getOrDefault("个税扣缴义务人", ""); + Long paymentOrganization = 0L; + List taxAgentPoList = getTaxAgentMapper().listByName(taxAgentName); + + if (taxAgentPoList.size() == 1) { + paymentOrganization = taxAgentPoList.get(0).getId(); + } else { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"))); + excelComments.add(errorMessageMap); + } + + //遍历表头 + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + String dataKey = header; + if (dataKey == null) { + continue; + } + String dataValue = (String) map.getOrDefault(dataKey.toString(), ""); + String deparmentName = (String) map.getOrDefault("部门", ""); + String mobile = (String) map.getOrDefault("手机号", ""); + String workcode = (String) map.getOrDefault("工号", ""); + + + if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) { + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isEmpty(dataValue) && "0".equals(confValue)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空")); + excelComments.add(errorMessageMap); + + } else { + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(salaryEmployees, dataValue, deparmentName, mobile, workcode, null); + + if (CollectionUtils.isEmpty(employeeSameIds)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名")); + excelComments.add(errorMessageMap); + + } else if (employeeSameIds.size() > 1) { + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (employeeSameIds.size() != 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + "员工信息不存在或者存在多个员工"); + excelComments.add(errorMessageMap); + } else { + employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + } + } else { + employeeId = employeeSameIds.get(0).getEmployeeId(); + } + } + } + + + } + + if (!isError){ + List employeeIds = new ArrayList<>(); + employeeIds.add(employeeId); + //根据员工id、个税扣缴义务人id、账单月份查询,如果当前对比表中存在数据,则记录为待删除数据 + list = getExcelInsuranceDetailMapper().queryCompareList(billMonth, paymentOrganization, employeeIds.get(0)); + + if (!list.isEmpty()) { + List ids = list.stream().map(ExcelInsuranceDetailPO::getId) + .collect(Collectors.toList()); + + idList.addAll(ids); + } + //拼装待更新数据 + addCompareList.add(handleExcelInsuranceDetail(billMonth, employeeId, paymentOrganization, map)); + + } + + if (isError) { + failCount++; + errorDatas.add(map); + } else { + successCount++; + } + + } + //将待更新列表加密 +// InsuranceAccountDetailPOEncrypt.encryptInsuranceAccountDetailPOList(addCompareList); + //删除 + if (idList.size() > 0) { + getExcelInsuranceDetailMapper().batchDelByIds(idList); + } + //新增 + getExcelInsuranceDetailMapper().batchSave(addCompareList); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", failCount); + apidatas.put("errorData", excelComments); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + /** + * 将excel导入的数据行组装成ExcelInsuranceDetailPO对象 + * @param billMonth 对比的账单月份 + * @param baseMap excel导入的对比数据 + */ + private ExcelInsuranceDetailPO handleExcelInsuranceDetail(String billMonth, Long employeeId, Long paymentOrganization, Map baseMap) { + + ExcelInsuranceDetailPO excelInsuranceDetailPO = new ExcelInsuranceDetailPO(); + //组装json数据,格式Map + Map socialPerMap = new HashMap<>(); + Map fundPerMap = new HashMap<>(); + Map otherPerMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + //组装福利基数P + Map socialPaymentBaseMap = new HashMap<>(); + Map fundPaymentBaseMap = new HashMap<>(); + Map otherPaymentBaseMap = new HashMap<>(); + + //筛选出福利核算项 + Map toDealMap = + baseMap.entrySet().stream() + .filter(map -> !"姓名".equals(map.getKey()) + && !"部门".equals(map.getKey()) + && !"手机号".equals(map.getKey()) + && !"个税扣缴义务人".equals(map.getKey()) + && !"员工状态".equals(map.getKey()) + && !"数据来源".equals(map.getKey()) + && !"工号".equals(map.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + for(Map.Entry entry : toDealMap.entrySet()) { + //判断元素是否属于福利类 + String keyName = entry.getKey(); + //获取元素名后缀,方便之后判断“个人”或“单位”或者“基数” + String payScope = keyName.substring(keyName.length() - 2); + //获取福利类型 + Integer welfareType; + //根据元素名后缀,区分截取内容 + String targetWelfareName; + if ("基数".equals(payScope)) { + targetWelfareName = entry.getKey().substring(0, keyName.length() - 4); + } else { + targetWelfareName = entry.getKey().substring(0, keyName.length() - 2); + } + List categoryPOList = siCategoryBiz.listByName(targetWelfareName); + if (categoryPOList.size() == 1) { + ICategoryPO iCategoryPO = categoryPOList.get(0); + welfareType = iCategoryPO.getWelfareType(); + + switch (payScope) { + case "个人": + switch (welfareType) { + case 1: + socialPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 2: + fundPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 3: + otherPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + break; + case "单位": + switch (welfareType) { + case 1: + socialComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 2: + fundComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 3: + otherComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + break; + case "基数": + switch (welfareType) { + case 1: + socialPaymentBaseMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 2: + fundPaymentBaseMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 3: + otherPaymentBaseMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + break; + } + } + + } + + //设置社保个人和公司缴纳明细 + excelInsuranceDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap)); + excelInsuranceDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + //设置公积金个人和公司缴纳明细 + excelInsuranceDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap)); + excelInsuranceDetailPO.setFundComJson(JSON.toJSONString(fundComMap)); + //设置其他福利个人和公司缴纳明细 + excelInsuranceDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap)); + excelInsuranceDetailPO.setOtherComJson(JSON.toJSONString(otherComMap)); + //设置社保、公积金、其他福利缴纳基数 + excelInsuranceDetailPO.setSocialPaymentBaseString(JSON.toJSONString(socialPaymentBaseMap)); + excelInsuranceDetailPO.setFundPaymentBaseString(JSON.toJSONString(fundPaymentBaseMap)); + excelInsuranceDetailPO.setOtherPaymentBaseString(JSON.toJSONString(otherPaymentBaseMap)); + + //组装新的insuranceAccountDetailPO对象数据 + excelInsuranceDetailPO.setEmployeeId(employeeId); + excelInsuranceDetailPO.setBillMonth(billMonth); + excelInsuranceDetailPO.setBillStatus(1); + excelInsuranceDetailPO.setPaymentStatus(0); + excelInsuranceDetailPO.setResourceFrom(1); + excelInsuranceDetailPO.setSocialAccount(baseMap.getOrDefault("社保账号", "").toString()); + if (baseMap.getOrDefault("社保方案名称", "") != null) { + List socialSchemeList = getInsuranceSchemeMapper().listByName(baseMap.get("社保方案名称").toString()); + if (socialSchemeList.size() == 1) { + //设置社保方案id + excelInsuranceDetailPO.setSocialSchemeId(socialSchemeList.get(0).getId()); + } + } + excelInsuranceDetailPO.setFundAccount(baseMap.getOrDefault("公积金账号", "").toString()); + excelInsuranceDetailPO.setSupplementFundAccount(baseMap.getOrDefault("补充公积金账号", "").toString()); + if (baseMap.getOrDefault("公积金方案名称", "") != null) { + List fundSchemeList = getInsuranceSchemeMapper().listByName(baseMap.get("公积金方案名称").toString()); + if (fundSchemeList.size() == 1) { + //设置公积金方案id + excelInsuranceDetailPO.setFundSchemeId(fundSchemeList.get(0).getId()); + } + } + if (baseMap.getOrDefault("其他福利方案名称", "") != null) { + List otherSchemeList = getInsuranceSchemeMapper().listByName(baseMap.get("其他福利方案名称").toString()); + if (otherSchemeList.size() == 1) { + //其他福利方案id + excelInsuranceDetailPO.setOtherSchemeId(otherSchemeList.get(0).getId()); + } + } + + excelInsuranceDetailPO.setSocialPerSum(baseMap.getOrDefault("社保个人合计", "").toString()); + excelInsuranceDetailPO.setFundPerSum(baseMap.getOrDefault("公积金个人合计", "").toString()); + excelInsuranceDetailPO.setOtherPerSum(baseMap.getOrDefault("其他福利个人合计", "").toString()); + excelInsuranceDetailPO.setPerSum(baseMap.getOrDefault("个人合计", "").toString()); + + excelInsuranceDetailPO.setSocialComSum(baseMap.getOrDefault("社保单位合计", "").toString()); + excelInsuranceDetailPO.setFundComSum(baseMap.getOrDefault("公积金单位合计", "").toString()); + excelInsuranceDetailPO.setOtherComSum(baseMap.getOrDefault("其他福利单位合计", "").toString()); + excelInsuranceDetailPO.setComSum(baseMap.getOrDefault("单位合计", "").toString()); + + excelInsuranceDetailPO.setSocialSum(baseMap.getOrDefault("社保合计", "").toString()); + excelInsuranceDetailPO.setFundSum(baseMap.getOrDefault("公积金合计", "").toString()); + excelInsuranceDetailPO.setOtherSum(baseMap.getOrDefault("其他福利合计", "").toString()); + excelInsuranceDetailPO.setTotal(baseMap.getOrDefault("合计", "").toString()); + + excelInsuranceDetailPO.setCreator((long) 100); //todo + excelInsuranceDetailPO.setCreateTime(new Date()); + excelInsuranceDetailPO.setUpdateTime(new Date()); + excelInsuranceDetailPO.setDeleteType(0); + excelInsuranceDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + excelInsuranceDetailPO.setPaymentOrganization(paymentOrganization); + + + return excelInsuranceDetailPO; + } + } diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java index 72a2e9192..a24e9bbf0 100644 --- a/src/com/engine/salary/web/SIAccountController.java +++ b/src/com/engine/salary/web/SIAccountController.java @@ -541,6 +541,16 @@ public class SIAccountController { } + /** + * 将通过“福利核算-线下对比导入”模板导入的数据更新到hrsa_excel_bill_detail表中 + */ + @POST + @Path("/comparisonwelfare/importExcelInsuranceDetail") + @Produces(MediaType.APPLICATION_JSON) + public String importExcelInsuranceDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExcelInsuranceImportParam excelInsuranceImportParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::importExcelInsuranceDetail, excelInsuranceImportParam); + } // **********************************线下对比 end*********************************/ }