福利核算干预功能开发v1
This commit is contained in:
parent
749279e372
commit
79cab3629e
|
|
@ -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 = "薪资项目id不能为空")
|
||||
private Collection<Long> salaryItemIds;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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,8 @@ public interface SIAccountService {
|
|||
void socialSecurityBenefitsRecalculate(InsuranceAccountBatchPO param);
|
||||
|
||||
|
||||
XSSFWorkbook exportImportTemplate(InsuranceAcctDetailImportTemplateParam param);
|
||||
|
||||
Map<String, Object> importInsuranceAcctDetail(InsuranceAcctImportParam insuranceAcctImportParam);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -38,22 +48,40 @@ import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper;
|
|||
import com.engine.salary.mapper.sicategory.ICategoryMapper;
|
||||
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 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 +123,12 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
|
|||
return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class);
|
||||
}
|
||||
|
||||
private SalaryItemService getSalaryItemService(User user) {
|
||||
return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
||||
}
|
||||
|
||||
SICategoryBiz siCategoryBiz = new SICategoryBiz();
|
||||
|
||||
@Override
|
||||
public Map<String, Object> listPage(InsuranceAccountBatchParam queryParam) {
|
||||
Long employeeId = (long) user.getUID();
|
||||
|
|
@ -954,4 +988,307 @@ 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.getSalaryItemIds())) {
|
||||
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<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds());
|
||||
for (SalaryItemPO salaryItemPO : salaryItemPOS) {
|
||||
headerList.add(salaryItemPO.getName());
|
||||
dataIndexList.add("" + salaryItemPO.getId());
|
||||
}
|
||||
|
||||
// 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();
|
||||
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<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;
|
||||
// 成功的数量
|
||||
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("无数据");
|
||||
}
|
||||
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;
|
||||
|
||||
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 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 {
|
||||
|
||||
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);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名"), i, i, j, j);
|
||||
} 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 (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);
|
||||
}
|
||||
|
||||
//如果福利核算信息查询不到唯一匹配数据,不支持导入
|
||||
//todo,根据员工id和账单月份查询
|
||||
if (!isError){
|
||||
|
||||
List<Long> employeeIds = new ArrayList<>();
|
||||
employeeIds.add(employeeId);
|
||||
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 {
|
||||
//todo,update
|
||||
updateInsuranceAccountDetail(list.get(0), map);
|
||||
}
|
||||
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102842, "本次薪资核算不包含该人员"), i, i, usernameIndex, usernameIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
failCount++;
|
||||
errorDatas.add(map);
|
||||
continue;
|
||||
} else {
|
||||
|
||||
//todo,更新数据
|
||||
successCount++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
apidatas.put("successCount", successCount);
|
||||
apidatas.put("errorCount", failCount);
|
||||
apidatas.put("errorData", excelComments);
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateInsuranceAccountDetail(InsuranceAccountDetailPO insuranceAccountDetailPO, Map<String, Object> map) {
|
||||
|
||||
//组装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();
|
||||
|
||||
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
//判断元素是否属于福利类
|
||||
String keyName = entry.getKey();
|
||||
//获取元素名后缀,方便之后判断“个人”或“单位”
|
||||
String payScope = keyName.substring(keyName.length() - 1, keyName.length() + 1);
|
||||
//获取福利类型
|
||||
Integer welfareType;
|
||||
List<ICategoryPO> categoryPOList = siCategoryBiz.listByName(entry.getKey().substring(0, keyName.length() - 1));
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//组装新的insuranceAccountDetailPO对象数据
|
||||
// insuranceAccountDetailPO.
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验福利核算的账单月份输入格式是否正确
|
||||
*/
|
||||
|
||||
public boolean checkBillMonth(String billMonth) {
|
||||
|
||||
String connector = "";
|
||||
if(billMonth.length() == 7){
|
||||
connector = billMonth.substring(4,5);
|
||||
return "-".equals(connector);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,27 @@ 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.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 +32,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 +57,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 +393,68 @@ public class SIAccountController {
|
|||
return new ResponseResult<InsuranceAccountBatchPO, String>(user).run(getService(user)::socialSecurityBenefitsRecalculate,insuranceAccountDetailParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 社保福利项列表
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出“福利核算导入”模板
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@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 salaryItemIds = request.getParameter("salaryItemIds");
|
||||
if (StringUtils.isNotBlank(salaryItemIds)) {
|
||||
param.setSalaryItemIds(Arrays.stream(salaryItemIds.split(",")).map(Long::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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/welfare/importInsuranceAcctDetail")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String importInsuranceAcctDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctImportParam importParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<InsuranceAcctImportParam, Map<String, Object>>(user).run(getService(user)::importInsuranceAcctDetail, importParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue