薪酬系统-福利台账,线下对比excel数据导入功能

This commit is contained in:
sy 2022-09-27 17:36:06 +08:00
parent bd3e44442d
commit 78ce712116
7 changed files with 1025 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<ExcelInsuranceDetailPO> 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<Long> ids);
/**
* 批量保存
*/
void batchSave(@Param("accounts") Collection<ExcelInsuranceDetailPO> accounts);
}

View File

@ -0,0 +1,341 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.siaccount.ExcelInsuranceDetailMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="bill_month" property="billMonth"/>
<result column="bill_status" property="billStatus"/>
<result column="payment_status" property="paymentStatus"/>
<result column="supplementary_month" property="supplementaryMonth"/>
<result column="supplementary_projects" property="supplementaryProjects"/>
<result column="resource_from" property="resourceFrom"/>
<result column="social_pay_org" property="socialPayOrg"/>
<result column="social_account" property="socialAccount"/>
<result column="fund_pay_org" property="fundPayOrg"/>
<result column="fund_account" property="fundAccount"/>
<result column="supplement_fund_account" property="supplementFundAccount"/>
<result column="other_pay_org" property="otherPayOrg"/>
<result column="social_scheme_id" property="socialSchemeId"/>
<result column="social_payment_base_string" property="socialPaymentBaseString"/>
<result column="fund_scheme_id" property="fundSchemeId"/>
<result column="fund_payment_base_string" property="fundPaymentBaseString"/>
<result column="other_scheme_id" property="otherSchemeId"/>
<result column="other_payment_base_string" property="otherPaymentBaseString"/>
<result column="social_per_json" property="socialPerJson"/>
<result column="social_per_sum" property="socialPerSum"/>
<result column="fund_per_json" property="fundPerJson"/>
<result column="fund_per_sum" property="fundPerSum"/>
<result column="other_per_json" property="otherPerJson"/>
<result column="other_per_sum" property="otherPerSum"/>
<result column="per_sum" property="perSum"/>
<result column="social_com_json" property="socialComJson"/>
<result column="social_com_sum" property="socialComSum"/>
<result column="fund_com_json" property="fundComJson"/>
<result column="fund_com_sum" property="fundComSum"/>
<result column="other_com_json" property="otherComJson"/>
<result column="other_com_sum" property="otherComSum"/>
<result column="com_sum" property="comSum"/>
<result column="social_sum" property="socialSum"/>
<result column="fund_sum" property="fundSum"/>
<result column="other_sum" property="otherSum"/>
<result column="total" property="total"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="tenant_key" property="tenantKey"/>
<result column="payment_organization" property="paymentOrganization"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
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
</sql>
<sql id="paramSqlCommon">
<if test="param.billMonth != null and param.billMonth != ''">
AND
t.bill_month = #{param.billMonth}
</if>
<if test="param.paymentStatus != null">
AND
t.payment_status = #{param.paymentStatus}
</if>
<if test="param.paymentOrganization != null and param.paymentOrganization != ''">
AND
t.payment_organization = #{param.paymentOrganization}
</if>
</sql>
<select id="queryCompareList" resultMap="BaseResultMap">
SELECT
t.id,t.employee_id,t.social_per_json,t.social_com_json,
t.fund_per_json,t.fund_com_json,t.other_per_json,
t.other_com_json,t.social_per_sum,t.social_com_sum,
t.fund_per_sum,t.fund_com_sum,t.other_per_sum,
t.other_com_sum,t.per_sum,t.com_sum
FROM
hrsa_excel_bill_detail t
WHERE t.delete_type = 0
AND t.payment_status = 0
AND t.bill_month = #{billMonth}
AND t.payment_organization = #{paymentOrganization}
AND employee_id = #{employeeId}
</select>
<!-- 根据主键删除记录 -->
<delete id="deleteById" parameterType="com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO">
UPDATE hrsa_excel_bill_detail
SET delete_type = 1
WHERE id = #{id}
AND delete_type = 0
</delete>
<!-- 根据id批量删除 -->
<delete id="batchDelByIds">
UPDATE hrsa_excel_bill_detail
SET delete_type = 1
WHERE delete_type = 0
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</delete>
<insert id="batchSave">
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
<foreach collection="accounts" item="item" separator=",">
(
#{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}
)
</foreach>
</insert>
<insert id="batchSave" databaseId="oracle">
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)
<foreach collection="accounts" item="item" separator="union all">
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
</foreach>
</insert>
<insert id="batchSave" databaseId="sqlserver">
<foreach collection="accounts" item="item" separator=";">
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}
)
</foreach>
</insert>
<sql id="likeCondition" databaseId="mysql">
<if test="userName != null and userName != ''">
AND e.lastname like CONCAT('%',#{userName},'%')
</if>
</sql>
<sql id="likeCondition" databaseId="oracle">
<if test="userName != null and userName != ''">
AND e.lastname like '%'||#{userName}||'%'
</if>
</sql>
<sql id="likeCondition" databaseId="sqlserver">
<if test="userName != null and userName != ''">
AND e.lastname like '%'+#{userName}+'%'
</if>
</sql>
</mapper>

View File

@ -232,5 +232,11 @@ public interface SIAccountService {
* 导出福利核算-线下对比导入模板
*/
XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAcctDetailImportTemplateParam param);
/**
* 将通过福利核算-线下对比导入模板导入的数据更新到hrsa_excel_bill_detail表中
*/
Map<String, Object> importExcelInsuranceDetail(ExcelInsuranceImportParam excelInsuranceImportParam);
}

View File

@ -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<String, Object> importExcelInsuranceDetail(ExcelInsuranceImportParam importParam) {
Map<String, Object> apidatas = new HashMap<String, Object>();
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<DataCollectionEmployee> 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<Map> excelComments = Lists.newArrayList();
// 存在错误的那行数据
List<Map<String, Object>> errorDatas = Lists.newArrayList();
// 表头
List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
// 处理数值
List<Map<String, Object>> 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<ExcelInsuranceDetailPO> addCompareList = new ArrayList<>();
//记录待删除hrsa_excel_bill_detail.id
List<Long> idList = new ArrayList<>();
//遍历excel表具体数据
for (int i = 0; i < data.size(); i++) {
String row = "" + (i + 2) + "";
boolean isError = false;
Map<String, Object> map = data.get(i);
Long employeeId = 0L;
List<ExcelInsuranceDetailPO> list = new ArrayList<>();
String taxAgentName = (String) map.getOrDefault("个税扣缴义务人", "");
Long paymentOrganization = 0L;
List<TaxAgentPO> taxAgentPoList = getTaxAgentMapper().listByName(taxAgentName);
if (taxAgentPoList.size() == 1) {
paymentOrganization = taxAgentPoList.get(0).getId();
} else {
isError = true;
Map<String, String> 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<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"));
excelComments.add(errorMessageMap);
} else {
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
List<DataCollectionEmployee> employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(salaryEmployees, dataValue, deparmentName, mobile, workcode, null);
if (CollectionUtils.isEmpty(employeeSameIds)) {
isError = true;
Map<String, String> 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<String, String> 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<Long> employeeIds = new ArrayList<>();
employeeIds.add(employeeId);
//根据员工id个税扣缴义务人id账单月份查询如果当前对比表中存在数据则记录为待删除数据
list = getExcelInsuranceDetailMapper().queryCompareList(billMonth, paymentOrganization, employeeIds.get(0));
if (!list.isEmpty()) {
List<Long> 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<String, Object> baseMap) {
ExcelInsuranceDetailPO excelInsuranceDetailPO = new ExcelInsuranceDetailPO();
//组装json数据,格式Map<String, Object>
Map<String, String> socialPerMap = new HashMap<>();
Map<String, String> fundPerMap = new HashMap<>();
Map<String, String> otherPerMap = new HashMap<>();
Map<String, String> socialComMap = new HashMap<>();
Map<String, String> fundComMap = new HashMap<>();
Map<String, String> otherComMap = new HashMap<>();
//组装福利基数P
Map<String, String> socialPaymentBaseMap = new HashMap<>();
Map<String, String> fundPaymentBaseMap = new HashMap<>();
Map<String, String> otherPaymentBaseMap = new HashMap<>();
//筛选出福利核算项
Map<String, Object> 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<String, Object> 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<ICategoryPO> 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<InsuranceSchemePO> 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<InsuranceSchemePO> fundSchemeList = getInsuranceSchemeMapper().listByName(baseMap.get("公积金方案名称").toString());
if (fundSchemeList.size() == 1) {
//设置公积金方案id
excelInsuranceDetailPO.setFundSchemeId(fundSchemeList.get(0).getId());
}
}
if (baseMap.getOrDefault("其他福利方案名称", "") != null) {
List<InsuranceSchemePO> 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;
}
}

View File

@ -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<ExcelInsuranceImportParam, Map<String, Object>>(user).run(getService(user)::importExcelInsuranceDetail, excelInsuranceImportParam);
}
// **********************************线下对比 end*********************************/
}