Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
钱涛 2022-09-07 09:46:02 +08:00
commit 06f6dcf8f2
10 changed files with 663 additions and 6 deletions

View File

@ -1687,4 +1687,11 @@ public class SIAccountBiz extends Service {
getInsuranceAccountBatchMapper().updateById(param);
}
/**
* 批量更新福利台账
*/
public void batchUpdateByEmployeeIdAndBillMonth(List<InsuranceAccountDetailPO> insuranceAccountDetailPOS) {
getInsuranceAccountDetailMapper().batchUpdateByEmployeeIdAndBillMonth(insuranceAccountDetailPOS);
}
}

View File

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

View File

@ -0,0 +1,25 @@
package com.engine.salary.entity.siaccount.param;
import com.engine.salary.util.valid.DataCheck;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Collection;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class InsuranceAcctDetailImportTemplateParam {
/**
* 薪资项目id薪资项目包含了福利项
*/
@DataCheck(require = true,message = "福利核算项目name不能为空")
private Collection<String> welfareNames;
}

View File

@ -0,0 +1,25 @@
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/1
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InsuranceAcctImportParam {
/**
* 上传文件id
*/
@DataCheck(require = true,message = "imageId为空")
String imageId;
}

View File

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

View File

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

View File

@ -7,6 +7,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.Collection;
import java.util.List;
@ -207,5 +208,14 @@ public interface SIAccountService {
void socialSecurityBenefitsRecalculate(InsuranceAccountBatchPO param);
/**
* 导出福利核算导入模板
*/
XSSFWorkbook exportImportTemplate(InsuranceAcctDetailImportTemplateParam param);
/**
* 将福利核算模板导入的数据更新到数据库
*/
Map<String, Object> importInsuranceAcctDetail(InsuranceAcctImportParam insuranceAcctImportParam);
}

View File

@ -8,12 +8,21 @@ import com.cloudstore.eccom.pc.table.*;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SIAccountBiz;
import com.engine.salary.biz.SIArchivesBiz;
import com.engine.salary.biz.*;
import com.engine.salary.component.SalaryWeaTable;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.encrypt.siaccount.InsuranceAccountDetailPOEncrypt;
import com.engine.salary.encrypt.siaccount.SiAccountEncrypt;
import com.engine.salary.entity.datacollection.AddUpDeduction;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO;
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctImportTemplateParam;
import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO;
@ -24,6 +33,7 @@ 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.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.siaccount.BillStatusEnum;
@ -36,24 +46,44 @@ 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;
import com.engine.salary.util.SalaryFormItemUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelParseHelper;
import com.engine.salary.util.excel.ExcelSupport;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.page.Column;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.engine.salary.util.valid.ValidUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.icbc.api.internal.apache.http.impl.cookie.S;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import weaver.file.ImageFileManager;
import weaver.general.Util;
import weaver.hrm.User;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
/**
* @Author weaver_cl
@ -95,6 +125,16 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class);
}
private SalaryItemService getSalaryItemService(User user) {
return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
SICategoryBiz siCategoryBiz = new SICategoryBiz();
@Override
public Map<String, Object> listPage(InsuranceAccountBatchParam queryParam) {
Long employeeId = (long) user.getUID();
@ -954,4 +994,394 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
param.setBillStatus(0);
getSiAccountBiz(user).updateById(param);
}
/**
* 导出福利核算导入模板
*/
@Override
public XSSFWorkbook exportImportTemplate(InsuranceAcctDetailImportTemplateParam param) {
ValidUtil.doValidator(param);
// 必须选择导入模板所需的薪资项目(福利项)
if (CollectionUtils.isEmpty(param.getWelfareNames())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的福利项目核算项"));
}
// 模板表头(默认必带"个税扣缴义务人""姓名")
List<Object> headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"),
"部门",
SalaryI18nUtil.getI18nLabel(86186, "手机号"),
SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"),
"账单月份");
// 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<>();
rows.add(headerList);
String sheetName = "福利核算导入模板";
return ExcelUtil.genWorkbookV2(rows, sheetName);
}
/**
* 将福利核算模板导入的数据更新到数据库
*/
@Override
public Map<String, Object> importInsuranceAcctDetail(InsuranceAcctImportParam importParam) {
// long currentEmployeeId = user.getUID();
// Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
Map<String, Object> apidatas = new HashMap<String, Object>();
EmployBiz employBiz = new EmployBiz();
//检验参数
//excel文件id
String imageId = Util.null2String(importParam.getImageId());
if (StringUtils.isBlank(imageId)) {
throw new SalaryRunTimeException("文件不存在");
}
// // 获取所有个税扣缴义务人
// List<TaxAgentPO> taxAgents = getTaxAgentService(user).listAll();
// Map<String, Long> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId);
// 获取租户下所有的人员
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("无数据");
}
//存储待更新的InsuranceAccountDetailPO数据
List<InsuranceAccountDetailPO> updateInsuranceAccountDetailList = 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;
// Long taxAgentId = 0L;
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;
if (dataKey == null) {
continue;
}
String dataValue = (String) map.getOrDefault(dataKey.toString(), "");
String deparmentName = (String) map.getOrDefault("部门", "");
String mobile = (String) map.getOrDefault("手机号", "");
if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) {
if (StringUtils.isEmpty(dataValue)) {
isError = true;
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"));
excelComments.add(errorMessageMap);
} 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)))
.collect(Collectors.toList());
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();
}
}
}else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "部门"), dataKey.toString())) {
} else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), dataKey.toString())) {
}
}
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);
} else {
successCount++;
}
}
//将待更新列表加密
InsuranceAccountDetailPOEncrypt.encryptInsuranceAccountDetailPOList(updateInsuranceAccountDetailList);
//更新
getSiAccountBiz(user).batchUpdateByEmployeeIdAndBillMonth(updateInsuranceAccountDetailList);
apidatas.put("successCount", successCount);
apidatas.put("errorCount", failCount);
apidatas.put("errorData", excelComments);
} finally {
IOUtils.closeQuietly(fileInputStream);
}
return apidatas;
}
/**
* 将更新的数据设置到老的insuranceAccountDetailPO对象中
*/
private InsuranceAccountDetailPO handleInsuranceAccountDetail(InsuranceAccountDetailPO insuranceAccountDetailPO, Map<String, Object> baseMap) {
//组装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<>();
//筛选出福利核算项
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() - 2);
//获取福利类型
Integer welfareType;
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:
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("福利类型不存在");
}
} else if ("单位".equals(payScope)) {
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("福利类型不存在");
}
}
}
}
// //解密insuranceAccountDetailPO
// InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
//组装新的insuranceAccountDetailPO对象数据
if (!socialPerMap.isEmpty()) {
//对比新旧json中数据并输出最终json
checkJsonMap(socialPerMap, insuranceAccountDetailPO.getSocialPerJson());
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap));
}
if (!socialComMap.isEmpty()) {
checkJsonMap(socialComMap, insuranceAccountDetailPO.getSocialComJson());
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap));
}
if (!fundPerMap.isEmpty()) {
checkJsonMap(fundPerMap, insuranceAccountDetailPO.getFundPerJson());
insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap));
}
if (!fundComMap.isEmpty()) {
checkJsonMap(fundComMap, insuranceAccountDetailPO.getFundComJson());
insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComMap));
}
if (!otherPerMap.isEmpty()) {
checkJsonMap(otherPerMap, insuranceAccountDetailPO.getOtherPerJson());
insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap));
}
if (!otherComMap.isEmpty()) {
checkJsonMap(otherComMap, insuranceAccountDetailPO.getOtherComJson());
insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComMap));
}
if (!StringUtils.isEmpty(baseMap.getOrDefault("个人合计", "").toString())) {
insuranceAccountDetailPO.setPerSum(baseMap.get("个人合计").toString());
}
if (!StringUtils.isEmpty(baseMap.getOrDefault("社保个人合计", "").toString())) {
insuranceAccountDetailPO.setSocialPerSum(baseMap.get("社保个人合计").toString());
}
if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金个人合计", "").toString())) {
insuranceAccountDetailPO.setFundPerSum(baseMap.get("公积金个人合计").toString());
}
if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利个人合计", "").toString())) {
insuranceAccountDetailPO.setOtherPerSum(baseMap.get("其他福利个人合计").toString());
}
if (!StringUtils.isEmpty(baseMap.getOrDefault("单位合计", "").toString())) {
insuranceAccountDetailPO.setComSum(baseMap.get("单位合计").toString());
}
if (!StringUtils.isEmpty(baseMap.getOrDefault("社保单位合计", "").toString())) {
insuranceAccountDetailPO.setSocialComSum(baseMap.get("社保单位合计").toString());
}
if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金单位合计", "").toString())) {
insuranceAccountDetailPO.setFundComSum(baseMap.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;
}
/**
* 对比新旧两份数据并更新数据
*/
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());
}
}
return newMap;
}
/**
* 校验福利核算的账单月份输入格式是否正确
*/
public boolean checkBillMonth(String billMonth) {
//校验内容billMonth的长度是否为7年月连接符是否为-
String connector;
if(billMonth.length() == 7){
connector = billMonth.substring(4,5);
return "-".equals(connector);
} else {
return false;
}
}
}

View File

@ -2,17 +2,28 @@ package com.engine.salary.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctImportTemplateParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultQueryParam;
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;
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
import com.engine.salary.service.impl.SIAccountServiceImpl;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.SIAccountWrapper;
import com.engine.salary.wrapper.SalaryFormulaWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import com.engine.salary.service.SIAccountService;
@ -22,14 +33,22 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 福利核算控制器
*/
@Slf4j
public class SIAccountController {
public SIAccountService getService(User user) {
@ -39,6 +58,10 @@ public class SIAccountController {
public SIAccountWrapper getSIAccountWrapper(User user) {
return ServiceUtil.getService(SIAccountWrapper.class,user);
}
private SalaryFormulaWrapper getSalaryFormulaWrapper(User user) {
return (SalaryFormulaWrapper) ServiceUtil.getService(SalaryFormulaWrapper.class, user);
}
/**
* 获取台账列表页
*
@ -371,4 +394,63 @@ public class SIAccountController {
return new ResponseResult<InsuranceAccountBatchPO, String>(user).run(getService(user)::socialSecurityBenefitsRecalculate,insuranceAccountDetailParam);
}
/**
* 社保福利核算项列表
*/
@GET
@Path("/getWelfareList")
@Produces(MediaType.APPLICATION_JSON)
public String getWelfareList(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String,List<InsuranceAcctDetailImportFieldDTO>>(user).run(getSalaryFormulaWrapper(user)::welfareList);
}
/**
* 导出福利核算导入模板
*/
@GET
@Path("/welfare/importtemplate/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam();
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);
XSSFWorkbook workbook = getService(user).exportImportTemplate(param);
String time = LocalDate.now().toString();
String fileName = "福利核算导入模板" + time;
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
StreamingOutput output = outputStream -> {
workbook.write(outputStream);
outputStream.flush();
};
response.setContentType("application/octet-stream");
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
} catch (Exception e) {
log.error("福利核算导入模板导出异常", e);
throw e;
}
}
/**
* 将通过福利核算导入模板导入的数据更新到hrsa_bill_detail表中
*/
@POST
@Path("/welfare/importInsuranceAcctDetail")
@Produces(MediaType.APPLICATION_JSON)
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, insuranceAcctImportParam);
}
}

View File

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