福利核算结果干预功能,福利核算项列表接口、福利核算导入模板下载接口、福利核算干预数据导入接口
This commit is contained in:
parent
3445642489
commit
5a6df5a257
|
|
@ -1687,4 +1687,11 @@ public class SIAccountBiz extends Service {
|
|||
getInsuranceAccountBatchMapper().updateById(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新福利台账
|
||||
*/
|
||||
public void batchUpdateByEmployeeIdAndBillMonth(List<InsuranceAccountDetailPO> insuranceAccountDetailPOS) {
|
||||
getInsuranceAccountDetailMapper().batchUpdateByEmployeeIdAndBillMonth(insuranceAccountDetailPOS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.engine.salary.entity.siaccount.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author sy
|
||||
* @Description 福利核算导入时生成导入模板的薪资(福利)项目
|
||||
* @Date 2022/9/2
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InsuranceAcctDetailImportFieldDTO {
|
||||
//字段id
|
||||
// private String fieldId;
|
||||
|
||||
//薪资项目名称
|
||||
private String salaryItemName;
|
||||
}
|
||||
|
|
@ -20,6 +20,6 @@ public class InsuranceAcctDetailImportTemplateParam {
|
|||
/**
|
||||
* 薪资项目id(薪资项目包含了福利项)
|
||||
*/
|
||||
@DataCheck(require = true,message = "薪资项目id不能为空")
|
||||
private Collection<Long> salaryItemIds;
|
||||
@DataCheck(require = true,message = "福利核算项目name不能为空")
|
||||
private Collection<String> welfareNames;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.salary.mapper.siaccount;
|
||||
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO;
|
||||
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
|
||||
import com.engine.salary.entity.siaccount.param.SupplementAccountBaseParam;
|
||||
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
|
||||
|
|
@ -104,4 +105,9 @@ public interface InsuranceAccountDetailMapper {
|
|||
|
||||
List<InsuranceArchivesEmployeePO> changeList(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 根据员工id和账单月份批量更新数据
|
||||
*/
|
||||
void batchUpdateByEmployeeIdAndBillMonth(@Param("pos") Collection<InsuranceAccountDetailPO> pos);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -761,4 +761,31 @@
|
|||
)a
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateByEmployeeIdAndBillMonth">
|
||||
<foreach collection="pos" item="item" index="index" separator=";">
|
||||
UPDATE hrsa_bill_detail
|
||||
<set>
|
||||
|
||||
<if test="null != item.socialPerJson and '' != item.socialPerJson">social_per_json = #{item.socialPerJson},</if>
|
||||
<if test="null != item.socialPerSum and '' != item.socialPerSum">social_per_sum = #{item.socialPerSum},</if>
|
||||
<if test="null != item.fundPerJson and '' != item.fundPerJson">fund_per_json = #{item.fundPerJson},</if>
|
||||
<if test="null != item.fundPerSum and '' != item.fundPerSum">fund_per_sum = #{item.fundPerSum},</if>
|
||||
<if test="null != item.otherPerJson and '' != item.otherPerJson">other_per_json = #{item.otherPerJson},</if>
|
||||
<if test="null != item.otherPerSum and '' != item.otherPerSum">other_per_sum = #{item.otherPerSum},</if>
|
||||
<if test="null != item.perSum and '' != item.perSum">per_sum = #{item.perSum},</if>
|
||||
<if test="null != item.socialComJson and '' != item.socialComJson">social_com_json = #{item.socialComJson},</if>
|
||||
<if test="null != item.socialComSum and '' != item.socialComSum">social_com_sum = #{item.socialComSum},</if>
|
||||
<if test="null != item.fundComJson and '' != item.fundComJson">fund_com_json = #{item.fundComJson},</if>
|
||||
<if test="null != item.fundComSum and '' != item.fundComSum">fund_com_sum = #{item.fundComSum},</if>
|
||||
<if test="null != item.otherComJson and '' != item.otherComJson">other_com_json = #{item.otherComJson},</if>
|
||||
<if test="null != item.otherComSum and '' != item.otherComSum">other_com_sum = #{item.otherComSum},</if>
|
||||
<if test="null != item.updateTime">update_time = #{item.updateTime},</if>
|
||||
|
||||
</set>
|
||||
WHERE employee_id = #{item.employeeId}
|
||||
AND bill_month = #{item.billMonth}
|
||||
AND delete_type = 0
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -208,8 +208,14 @@ public interface SIAccountService {
|
|||
void socialSecurityBenefitsRecalculate(InsuranceAccountBatchPO param);
|
||||
|
||||
|
||||
/**
|
||||
* 导出“福利核算导入模板”
|
||||
*/
|
||||
XSSFWorkbook exportImportTemplate(InsuranceAcctDetailImportTemplateParam param);
|
||||
|
||||
/**
|
||||
* 将福利核算模板导入的数据更新到数据库
|
||||
*/
|
||||
Map<String, Object> importInsuranceAcctDetail(InsuranceAcctImportParam insuranceAcctImportParam);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ 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.taxagent.TaxAgentMapper;
|
||||
import com.engine.salary.service.*;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
|
|
@ -128,6 +129,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private TaxAgentMapper getTaxAgentMapper() {
|
||||
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
|
||||
}
|
||||
|
||||
SICategoryBiz siCategoryBiz = new SICategoryBiz();
|
||||
|
||||
@Override
|
||||
|
|
@ -998,8 +1003,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
ValidUtil.doValidator(param);
|
||||
|
||||
// 必须选择导入模板所需的薪资项目(福利项)
|
||||
if (CollectionUtils.isEmpty(param.getSalaryItemIds())) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的福利项目"));
|
||||
if (CollectionUtils.isEmpty(param.getWelfareNames())) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的福利项目核算项"));
|
||||
}
|
||||
|
||||
// 模板表头(默认必带"个税扣缴义务人"、"姓名")
|
||||
|
|
@ -1008,13 +1013,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
SalaryI18nUtil.getI18nLabel(86186, "手机号"),
|
||||
SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"),
|
||||
"账单月份");
|
||||
List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "taxAgentName", "billMonth");
|
||||
// 查询薪资项目(福利项)
|
||||
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds());
|
||||
for (SalaryItemPO salaryItemPO : salaryItemPOS) {
|
||||
headerList.add(salaryItemPO.getName());
|
||||
dataIndexList.add("" + salaryItemPO.getId());
|
||||
}
|
||||
// List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "taxAgentName", "billMonth");
|
||||
// 查询福利核算项目
|
||||
List<String> welfareNames = (List<String>) param.getWelfareNames();
|
||||
headerList.addAll(welfareNames);
|
||||
|
||||
// excel导出的数据
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
|
|
@ -1024,35 +1026,30 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将福利核算模板导入的数据更新到数据库
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> importInsuranceAcctDetail(InsuranceAcctImportParam importParam) {
|
||||
long currentEmployeeId = user.getUID();
|
||||
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
// long currentEmployeeId = user.getUID();
|
||||
// Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
EmployBiz employBiz = new EmployBiz();
|
||||
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); //todo,改为对应Biz
|
||||
|
||||
//检验参数
|
||||
//excel文件id
|
||||
String imageId = Util.null2String(importParam.getImageId());
|
||||
// Validate.notBlank(imageId, "imageId为空");
|
||||
|
||||
if (StringUtils.isBlank(imageId)) {
|
||||
throw new SalaryRunTimeException("文件不存在");
|
||||
}
|
||||
// 获取所有个税扣缴义务人
|
||||
List<TaxAgentPO> taxAgents = getTaxAgentService(user).listAll();
|
||||
Map<String, Long> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId);
|
||||
// //个税扣缴义务人
|
||||
// String taxAgentId = Util.null2String(importParam.getTaxAgentId());
|
||||
// // 获取所有个税扣缴义务人
|
||||
// List<TaxAgentPO> taxAgents = getTaxAgentService(user).listAll();
|
||||
// Map<String, Long> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId);
|
||||
|
||||
// 获取租户下所有的人员
|
||||
List<DataCollectionEmployee> salaryEmployees = employBiz.listEmployee();
|
||||
// //已经核算过的不可操作
|
||||
// // 获取已经核算的数据
|
||||
// List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
|
||||
// // 查询已有数据
|
||||
// Date declareMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER));
|
||||
// List<AddUpDeduction> list = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(declareMonth).build());
|
||||
|
||||
// 失败的数量
|
||||
int failCount = 0;
|
||||
|
|
@ -1064,14 +1061,12 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
|
||||
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)) {
|
||||
|
|
@ -1080,18 +1075,43 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
if (CollectionUtils.isEmpty(data)) {
|
||||
throw new RuntimeException("无数据");
|
||||
}
|
||||
//存储待更新的InsuranceAccountDetailPO数据
|
||||
List<InsuranceAccountDetailPO> updateInsuranceAccountDetailList = new ArrayList<>();
|
||||
//遍历excel表具体数据
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
|
||||
String row = "第" + (i + 2) + "行";
|
||||
|
||||
int usernameIndex = 0;
|
||||
boolean isError = false;
|
||||
Map<String, Object> map = data.get(i);
|
||||
Long employeeId = 0L;
|
||||
Long taxAgentId = 0L;
|
||||
// Long taxAgentId = 0L;
|
||||
|
||||
List<InsuranceAccountDetailPO> updateInsuranceAccountDetailList = new ArrayList<>();
|
||||
List<InsuranceAccountDetailPO> list = new ArrayList<>();
|
||||
|
||||
String billMonth = (String) map.getOrDefault("账单月份", "");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (!checkBillMonth(billMonth)) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "账单月份输入有误,请参照“2022-09”这种格式进行检查"));
|
||||
excelComments.add(errorMessageMap);
|
||||
}
|
||||
|
||||
//遍历表头
|
||||
for (int j = 0; j < headers.size(); j++) {
|
||||
String header = headers.get(j);
|
||||
String dataKey = header;
|
||||
|
|
@ -1099,25 +1119,17 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
continue;
|
||||
}
|
||||
String dataValue = (String) map.getOrDefault(dataKey.toString(), "");
|
||||
|
||||
String deparmentName = (String) map.getOrDefault("部门", "");
|
||||
|
||||
String mobile = (String) map.getOrDefault("手机号", "");
|
||||
|
||||
String billMonth = (String) map.getOrDefault("账单月份", "");
|
||||
|
||||
Long paymentOrganization = (Long) map.getOrDefault("个税扣缴义务人", "");
|
||||
|
||||
if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) {
|
||||
usernameIndex = j;
|
||||
if (StringUtils.isEmpty(dataValue)) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"));
|
||||
excelComments.add(errorMessageMap);
|
||||
//salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"), i, i, j, j);
|
||||
} else {
|
||||
|
||||
} else {
|
||||
List<DataCollectionEmployee> employeeSameIds = salaryEmployees.stream().filter(e -> (StringUtils.isBlank(dataValue) || Objects.equals(e.getUsername(), dataValue))
|
||||
&& (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName))
|
||||
&& (StringUtils.isBlank(mobile) || Objects.equals(e.getMobile(), mobile)))
|
||||
|
|
@ -1128,7 +1140,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名"));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名"), i, i, j, j);
|
||||
|
||||
} else if (employeeSameIds.size() > 1) {
|
||||
//存在离职和在职状态取在职状态
|
||||
employeeSameIds = employeeSameIds.stream()
|
||||
|
|
@ -1149,70 +1161,46 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
}else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "部门"), dataKey.toString())) {
|
||||
|
||||
} else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), dataKey.toString())) {
|
||||
if (StringUtils.isEmpty(dataValue)) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102839, "个税扣缴义务人不能为空")));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102839, "个税扣缴义务人不能为空"), i, i, j, j);
|
||||
} else {
|
||||
taxAgentId = taxAgentNameMap.getOrDefault(dataValue, 0L);
|
||||
if (taxAgentId == null || taxAgentId <= 0) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人")));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"), i, i, j, j);
|
||||
}
|
||||
}
|
||||
} else if (!checkBillMonth(billMonth)) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "账单月份输入有误,请参照“2022-09”这种格式进行检查"));
|
||||
excelComments.add(errorMessageMap);
|
||||
}
|
||||
|
||||
if (!isError){
|
||||
List<Long> employeeIds = new ArrayList<>();
|
||||
employeeIds.add(employeeId);
|
||||
//如果福利核算信息查询不到唯一匹配数据,不支持导入
|
||||
//根据员工id和账单月份查询
|
||||
List<InsuranceAccountDetailPO> list = queryList(billMonth, paymentOrganization, employeeIds);
|
||||
if (list.isEmpty()) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "本次福利核算不包含该人员"));
|
||||
excelComments.add(errorMessageMap);
|
||||
} else if (list.size() > 1) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "该人员本次核算出现多组数据,请删除数据库中多余核算项"));
|
||||
excelComments.add(errorMessageMap);
|
||||
} else {
|
||||
//拼装待更新数据
|
||||
updateInsuranceAccountDetailList.add(handleInsuranceAccountDetail(list.get(0), map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//将待更新列表加密
|
||||
InsuranceAccountDetailPOEncrypt.encryptInsuranceAccountDetailPOList(updateInsuranceAccountDetailList);
|
||||
//todo,更新数据
|
||||
|
||||
if (!isError){
|
||||
List<Long> employeeIds = new ArrayList<>();
|
||||
employeeIds.add(employeeId);
|
||||
//如果福利核算信息查询不到唯一匹配数据,不支持导入
|
||||
//根据员工id、个税扣缴义务人id、账单月份查询
|
||||
list = queryList(billMonth, paymentOrganization, employeeIds);
|
||||
if (list.isEmpty()) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "本次福利核算不包含该人员"));
|
||||
excelComments.add(errorMessageMap);
|
||||
} else if (list.size() > 1) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "该人员本次核算出现多组数据,请删除数据库中多余核算项"));
|
||||
excelComments.add(errorMessageMap);
|
||||
} else {
|
||||
//拼装待更新数据
|
||||
updateInsuranceAccountDetailList.add(handleInsuranceAccountDetail(list.get(0), map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
failCount++;
|
||||
errorDatas.add(map);
|
||||
continue;
|
||||
} else {
|
||||
|
||||
successCount++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//将待更新列表加密
|
||||
InsuranceAccountDetailPOEncrypt.encryptInsuranceAccountDetailPOList(updateInsuranceAccountDetailList);
|
||||
//更新
|
||||
getSiAccountBiz(user).batchUpdateByEmployeeIdAndBillMonth(updateInsuranceAccountDetailList);
|
||||
apidatas.put("successCount", successCount);
|
||||
apidatas.put("errorCount", failCount);
|
||||
apidatas.put("errorData", excelComments);
|
||||
|
|
@ -1226,18 +1214,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
|
||||
/**
|
||||
* 将更新的数据设置到老的insuranceAccountDetailPO对象中
|
||||
* @param insuranceAccountDetailPO
|
||||
* @param map
|
||||
*/
|
||||
private InsuranceAccountDetailPO handleInsuranceAccountDetail(InsuranceAccountDetailPO insuranceAccountDetailPO, Map<String, Object> map) {
|
||||
private InsuranceAccountDetailPO handleInsuranceAccountDetail(InsuranceAccountDetailPO insuranceAccountDetailPO, Map<String, Object> baseMap) {
|
||||
|
||||
//组装json数据,格式Map<String, Object>
|
||||
// StringBuilder socialPerJson = new StringBuilder();
|
||||
// StringBuilder fundPerJson = new StringBuilder();
|
||||
// StringBuilder otherPerJson = new StringBuilder();
|
||||
// StringBuilder socialComJson = new StringBuilder();
|
||||
// StringBuilder fundComJson = new StringBuilder();
|
||||
// StringBuilder otherComJson = new StringBuilder();
|
||||
Map<String, String> socialPerMap = new HashMap<>();
|
||||
Map<String, String> fundPerMap = new HashMap<>();
|
||||
Map<String, String> otherPerMap = new HashMap<>();
|
||||
|
|
@ -1245,42 +1225,28 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
Map<String, String> fundComMap = new HashMap<>();
|
||||
Map<String, String> otherComMap = new HashMap<>();
|
||||
|
||||
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
//筛选出福利核算项
|
||||
Map<String, Object> toDealMap =
|
||||
baseMap.entrySet().stream()
|
||||
.filter(map -> !"姓名".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() - 1, keyName.length() + 1);
|
||||
String payScope = keyName.substring(keyName.length() - 2);
|
||||
//获取福利类型
|
||||
Integer welfareType;
|
||||
List<ICategoryPO> categoryPOList = siCategoryBiz.listByName(entry.getKey().substring(0, keyName.length() - 1));
|
||||
List<ICategoryPO> categoryPOList = siCategoryBiz.listByName(entry.getKey().substring(0, keyName.length() - 2));
|
||||
if (categoryPOList.size() == 1) {
|
||||
ICategoryPO iCategoryPO = categoryPOList.get(0);
|
||||
welfareType = iCategoryPO.getWelfareType();
|
||||
// if ("个人".equals(payScope)) {
|
||||
// switch (welfareType) {
|
||||
// case 1:
|
||||
// socialPerJson.append(iCategoryPO.getId().toString()).append(":").append(entry.getValue().toString()).append(",");
|
||||
// break;
|
||||
// case 2:
|
||||
// fundPerJson.append(iCategoryPO.getId().toString()).append(":").append(entry.getValue().toString()).append(",");
|
||||
// break;
|
||||
// case 3:
|
||||
// otherPerJson.append(iCategoryPO.getId().toString()).append(":").append(entry.getValue().toString()).append(",");
|
||||
// break;
|
||||
// }
|
||||
// } else if ("单位".equals(payScope)) {
|
||||
// switch (welfareType) {
|
||||
// case 1:
|
||||
// socialComJson.append(iCategoryPO.getId().toString()).append(":").append(entry.getValue().toString()).append(",");
|
||||
// break;
|
||||
// case 2:
|
||||
// fundComJson.append(iCategoryPO.getId().toString()).append(":").append(entry.getValue().toString()).append(",");
|
||||
// break;
|
||||
// case 3:
|
||||
// otherComJson.append(iCategoryPO.getId().toString()).append(":").append(entry.getValue().toString()).append(",");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
if ("个人".equals(payScope)) {
|
||||
switch (welfareType) {
|
||||
case 1:
|
||||
|
|
@ -1292,6 +1258,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
case 3:
|
||||
otherPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString());
|
||||
break;
|
||||
default:
|
||||
throw new SalaryRunTimeException("福利类型不存在");
|
||||
}
|
||||
} else if ("单位".equals(payScope)) {
|
||||
switch (welfareType) {
|
||||
|
|
@ -1304,91 +1272,96 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
case 3:
|
||||
otherComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString());
|
||||
break;
|
||||
default:
|
||||
throw new SalaryRunTimeException("福利类型不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//解密insuranceAccountDetailPO
|
||||
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
|
||||
// //解密insuranceAccountDetailPO
|
||||
// InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
|
||||
//组装新的insuranceAccountDetailPO对象数据
|
||||
if (!socialPerMap.isEmpty()) {
|
||||
//对比新旧json中数据,并输出最终json
|
||||
checkjsonMap(socialPerMap, insuranceAccountDetailPO.getSocialPerJson());
|
||||
checkJsonMap(socialPerMap, insuranceAccountDetailPO.getSocialPerJson());
|
||||
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap));
|
||||
}
|
||||
|
||||
if (!socialComMap.isEmpty()) {
|
||||
checkjsonMap(socialComMap, insuranceAccountDetailPO.getSocialComJson());
|
||||
checkJsonMap(socialComMap, insuranceAccountDetailPO.getSocialComJson());
|
||||
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap));
|
||||
}
|
||||
|
||||
if (!fundPerMap.isEmpty()) {
|
||||
checkjsonMap(fundPerMap, insuranceAccountDetailPO.getFundPerJson());
|
||||
checkJsonMap(fundPerMap, insuranceAccountDetailPO.getFundPerJson());
|
||||
insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap));
|
||||
}
|
||||
|
||||
if (!fundComMap.isEmpty()) {
|
||||
checkjsonMap(fundComMap, insuranceAccountDetailPO.getFundComJson());
|
||||
checkJsonMap(fundComMap, insuranceAccountDetailPO.getFundComJson());
|
||||
insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComMap));
|
||||
}
|
||||
|
||||
if (!otherPerMap.isEmpty()) {
|
||||
checkjsonMap(otherPerMap, insuranceAccountDetailPO.getOtherPerJson());
|
||||
checkJsonMap(otherPerMap, insuranceAccountDetailPO.getOtherPerJson());
|
||||
insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap));
|
||||
}
|
||||
|
||||
if (!otherComMap.isEmpty()) {
|
||||
checkjsonMap(otherComMap, insuranceAccountDetailPO.getOtherComJson());
|
||||
checkJsonMap(otherComMap, insuranceAccountDetailPO.getOtherComJson());
|
||||
insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComMap));
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setPerSum(map.get("个人合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setPerSum(baseMap.get("个人合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("社保个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setSocialPerSum(map.get("社保个人合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("社保个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setSocialPerSum(baseMap.get("社保个人合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("公积金个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setFundPerSum(map.get("公积金个人合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setFundPerSum(baseMap.get("公积金个人合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("其他福利个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setOtherPerSum(map.get("其他福利个人合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利个人合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setOtherPerSum(baseMap.get("其他福利个人合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setComSum(map.get("单位合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setComSum(baseMap.get("单位合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("社保单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setSocialComSum(map.get("社保单位合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("社保单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setSocialComSum(baseMap.get("社保单位合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("公积金单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setFundComSum(map.get("公积金单位合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setFundComSum(baseMap.get("公积金单位合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(map.getOrDefault("其他福利单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setOtherComSum(map.get("其他福利单位合计").toString());
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利单位合计", "").toString())) {
|
||||
insuranceAccountDetailPO.setOtherComSum(baseMap.get("其他福利单位合计").toString());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(baseMap.getOrDefault("账单月份", "").toString())) {
|
||||
insuranceAccountDetailPO.setBillMonth(baseMap.get("账单月份").toString());
|
||||
}
|
||||
|
||||
insuranceAccountDetailPO.setUpdateTime(new Date());
|
||||
|
||||
return insuranceAccountDetailPO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对比新旧两份数据,并更新数据
|
||||
* @param newMap
|
||||
* @param oldJson
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> checkjsonMap(Map<String, String> newMap, String oldJson) {
|
||||
Map<String, String> oldMap = JSON.parseObject(oldJson, new HashMap<String, String>().getClass());
|
||||
private Map<String, String> checkJsonMap(Map<String, String> newMap, String oldJson) {
|
||||
Map<String, String> oldMap = JSON.parseObject(oldJson, HashMap.class);
|
||||
for (Map.Entry<String, String> oldEntry : oldMap.entrySet()) {
|
||||
|
||||
//保留无变动数据,更新已变动数据
|
||||
if (!newMap.containsKey(oldEntry.getKey())) {
|
||||
newMap.put(oldEntry.getKey(), oldEntry.getValue());
|
||||
}
|
||||
|
|
@ -1399,10 +1372,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
/**
|
||||
* 校验福利核算的账单月份输入格式是否正确
|
||||
*/
|
||||
|
||||
public boolean checkBillMonth(String billMonth) {
|
||||
|
||||
String connector = "";
|
||||
//校验内容:billMonth的长度是否为7、年月连接符是否为“-”
|
||||
String connector;
|
||||
if(billMonth.length() == 7){
|
||||
connector = billMonth.substring(4,5);
|
||||
return "-".equals(connector);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.engine.salary.entity.salaryformula.param.SalaryFormulaFieldQueryParam
|
|||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO;
|
||||
import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO;
|
||||
import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO;
|
||||
import com.engine.salary.entity.siaccount.param.*;
|
||||
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
|
|
@ -394,26 +395,18 @@ public class SIAccountController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 社保福利项列表
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* 社保福利(核算)项列表
|
||||
*/
|
||||
@GET
|
||||
@Path("/getWelfareList")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getWelfareList(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
SalaryFormulaFieldQueryParam param = new SalaryFormulaFieldQueryParam();
|
||||
param.setSourceId("welfare");
|
||||
return new ResponseResult<SalaryFormulaFieldQueryParam, List<FormulaVar>>(user).run(getSalaryFormulaWrapper(user)::fieldList, param);
|
||||
return new ResponseResult<String,List<InsuranceAcctDetailImportFieldDTO>>(user).run(getSalaryFormulaWrapper(user)::welfareList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出“福利核算导入”模板
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/welfare/importtemplate/export")
|
||||
|
|
@ -422,9 +415,9 @@ public class SIAccountController {
|
|||
try {
|
||||
InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam();
|
||||
|
||||
String salaryItemIds = request.getParameter("salaryItemIds");
|
||||
if (StringUtils.isNotBlank(salaryItemIds)) {
|
||||
param.setSalaryItemIds(Arrays.stream(salaryItemIds.split(",")).map(Long::valueOf).collect(Collectors.toList()));
|
||||
String welfareNames = request.getParameter("welfareNames");
|
||||
if (StringUtils.isNotBlank(welfareNames)) {
|
||||
param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
|
@ -449,12 +442,15 @@ public class SIAccountController {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将通过“福利核算导入”模板导入的数据更新到hrsa_bill_detail表中
|
||||
*/
|
||||
@POST
|
||||
@Path("/welfare/importInsuranceAcctDetail")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String importInsuranceAcctDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctImportParam importParam) {
|
||||
public String importInsuranceAcctDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctImportParam insuranceAcctImportParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<InsuranceAcctImportParam, Map<String, Object>>(user).run(getService(user)::importInsuranceAcctDetail, importParam);
|
||||
return new ResponseResult<InsuranceAcctImportParam, Map<String, Object>>(user).run(getService(user)::importInsuranceAcctDetail, insuranceAcctImportParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.engine.salary.wrapper;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.biz.SalaryItemBiz;
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.bo.SalaryFormulaBO;
|
||||
import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO;
|
||||
|
|
@ -9,6 +10,8 @@ import com.engine.salary.entity.salaryformula.param.SalaryFormulaFieldQueryParam
|
|||
import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaPO;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.service.RemoteExcelService;
|
||||
import com.engine.salary.service.SalaryFormulaService;
|
||||
|
|
@ -18,10 +21,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import weaver.hrm.User;
|
||||
import weaver.servicefiles.DataSourceXML;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 薪资项目
|
||||
|
|
@ -41,6 +41,7 @@ public class SalaryFormulaWrapper extends Service {
|
|||
return (SalaryFormulaService) ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryItemBiz salaryItemBiz = new SalaryItemBiz();
|
||||
|
||||
/**
|
||||
* 公式字段列表
|
||||
|
|
@ -80,4 +81,25 @@ public class SalaryFormulaWrapper extends Service {
|
|||
ArrayList pointArrayList = dataSourceXML.getPointArrayList();
|
||||
return pointArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取薪资项目中福利类项目
|
||||
*/
|
||||
public List<InsuranceAcctDetailImportFieldDTO> welfareList() {
|
||||
|
||||
List<InsuranceAcctDetailImportFieldDTO> welfareList = new ArrayList<>();
|
||||
SalaryFormulaFieldQueryParam param = new SalaryFormulaFieldQueryParam();
|
||||
param.setSourceId("welfare");
|
||||
//获取福利类薪资项目
|
||||
List<FormulaVar> list = getRemoteExcelService(user).fieldList(param.getSourceId(), param.getExtendParam());
|
||||
//提取出福利类项目名称
|
||||
for(FormulaVar formulaVar : list) {
|
||||
InsuranceAcctDetailImportFieldDTO insuranceAcctDetailImportFieldDTO = new InsuranceAcctDetailImportFieldDTO();
|
||||
// insuranceAcctDetailImportFieldDTO.setFieldId(formulaVar.getFieldId());
|
||||
insuranceAcctDetailImportFieldDTO.setSalaryItemName(formulaVar.getName());
|
||||
welfareList.add(insuranceAcctDetailImportFieldDTO);
|
||||
|
||||
}
|
||||
return welfareList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue