Merge remote-tracking branch 'remotes/origin/feature/230901-福利台账-调差,支持一个人存在多个调差记录' into release/2.9.5.2309.01

This commit is contained in:
sy 2023-09-21 14:09:54 +08:00
commit 5f84ed451b
21 changed files with 740 additions and 102 deletions

View File

@ -1,7 +1,7 @@
package com.engine.salary.action;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.impl.SISchemeServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
@ -66,7 +66,7 @@ public class CheckEditSIArchiveAction implements Action {
//福利执行状态
String runStatus = list.stream().filter(f -> f.salaryName.equals("档案状态")).findFirst().map(CheckEditSIArchiveAction.SalaryField::getValue).orElse("1");
SIArchiveImportActionParam build = SIArchiveImportActionParam.builder()
SIArchiveImportParam build = SIArchiveImportParam.builder()
.importDatas(importData)
.runStatus(runStatus)
.build();

View File

@ -1,7 +1,7 @@
package com.engine.salary.action;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.impl.SISchemeServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
@ -65,7 +65,7 @@ public class EditSIArchiveAction implements Action {
//福利执行状态
String runStatus = list.stream().filter(f -> f.salaryName.equals("档案状态")).findFirst().map(EditSIArchiveAction.SalaryField::getValue).orElse("1");
SIArchiveImportActionParam build = SIArchiveImportActionParam.builder()
SIArchiveImportParam build = SIArchiveImportParam.builder()
.importDatas(importData)
.runStatus(runStatus)
.build();

View File

@ -0,0 +1,181 @@
package com.engine.salary.action;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import com.engine.salary.service.SIArchivesService;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.impl.SIArchivesServiceImpl;
import com.engine.salary.service.impl.SISchemeServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: sy
* @Description: 编辑并增员福利档案
* @Date: 2023/9/8
**/
@Slf4j
public class EditToPaySIArchiveAction implements Action {
private SISchemeService getSISchemeService(User user) {
return ServiceUtil.getService(SISchemeServiceImpl.class,user);
}
private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
private SIArchivesService getSIArchivesService(User user) {
return ServiceUtil.getService(SIArchivesServiceImpl.class,user);
}
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
private String tableName;
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public String execute(RequestInfo requestInfo) {
try {
Property[] properties = requestInfo.getMainTableInfo().getProperty();
Map<String, String> fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName,
property -> Util.null2String(property.getValue())));
RecordSet rs = new RecordSet();
String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?";
rs.executeQuery(queryImageId, requestInfo.getWorkflowid());
List<EditToPaySIArchiveAction.SalaryField> list = new ArrayList<>();
while (rs.next()) {
String processField = rs.getString("processfield");
String salaryName = rs.getString("salaryname");
String value = fieldMap.get(processField);
list.add(new EditToPaySIArchiveAction.SalaryField(processField, salaryName, value));
}
List<Map<String, Object>> importData = new ArrayList<>();
importData.add(SalaryEntityUtil.convert2Map(list, EditToPaySIArchiveAction.SalaryField::getSalaryName, EditToPaySIArchiveAction.SalaryField::getValue));
//福利执行状态
String runStatus = EmployeeStatusEnum.STAY_ADD.getValue();
SIArchiveImportParam build = SIArchiveImportParam.builder()
.importDatas(importData)
.runStatus(runStatus)
.build();
//操作人
String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(EditToPaySIArchiveAction.SalaryField::getValue).orElse("1");
//更新/新建档案数据
Map<String, Object> map = getSISchemeService(new User(Integer.parseInt(uid))).addSIArchive(build);
List errorNotice = (List) map.get("errorData");
if (CollectionUtils.isNotEmpty(errorNotice)) {
log.error("福利档案编辑并增员存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map);
List<Map<String, String>> excelComments = (List<Map<String, String>>) map.get("errorData");
StringBuilder message = new StringBuilder("");
for (Map<String, String> comments : excelComments) {
message.append(comments.get("message")).append("\n");
}
requestInfo.getRequestManager().setMessage(message.toString());
return FAILURE_AND_CONTINUE;
}
//增员
String taxAgentName = importData.get(0).get("个税扣缴义务人").toString();
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName);
if(CollectionUtils.isEmpty(taxAgentPOS)){
requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!");
return FAILURE_AND_CONTINUE;
}
Long taxAgentId = Long.valueOf(taxAgentPOS.get(0).getId());
Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(EditToPaySIArchiveAction.SalaryField::getValue).orElse("-1"));
User user = new User(Integer.parseInt(uid));
// 获取福利档案基础信息
InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId);
if(insuranceArchivesBaseInfoPO == null){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!");
return FAILURE_AND_CONTINUE;
} else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待增员,无法进行增员操作,请检查后重试!");
return FAILURE_AND_CONTINUE;
}
//增员
Map<String, Object> resultMap = getSIArchivesService(user).stayAddToPay(Collections.singletonList(insuranceArchivesBaseInfoPO.getId()));
if (resultMap.get("type").toString().equals("fail")) {
requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString());
return FAILURE_AND_CONTINUE;
}
} catch (Exception e) {
log.error("福利档案编辑并增员异常", e);
requestInfo.getRequestManager().setMessage(e.getMessage());
return FAILURE_AND_CONTINUE;
}
return SUCCESS;
}
class SalaryField {
private String processField;
private String salaryName;
private String value;
public String getProcessField() {
return processField;
}
public void setProcessField(String processField) {
this.processField = processField;
}
public String getSalaryName() {
return salaryName;
}
public void setSalaryName(String salaryName) {
this.salaryName = salaryName;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public SalaryField(String processField, String salaryName, String value) {
this.processField = processField;
this.salaryName = salaryName;
this.value = value;
}
}
}

View File

@ -0,0 +1,184 @@
package com.engine.salary.action;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import com.engine.salary.service.SIArchivesService;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.impl.SIArchivesServiceImpl;
import com.engine.salary.service.impl.SISchemeServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: sy
* @Description: 编辑并减员福利档案
* @Date: 2023/9/8
**/
@Slf4j
public class EditToStopSIArchiveAction implements Action {
private SISchemeService getSISchemeService(User user) {
return ServiceUtil.getService(SISchemeServiceImpl.class,user);
}
private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
private SIArchivesService getSIArchivesService(User user) {
return ServiceUtil.getService(SIArchivesServiceImpl.class,user);
}
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
private String tableName;
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public String execute(RequestInfo requestInfo) {
try {
Property[] properties = requestInfo.getMainTableInfo().getProperty();
Map<String, String> fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName,
property -> Util.null2String(property.getValue())));
RecordSet rs = new RecordSet();
String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?";
rs.executeQuery(queryImageId, requestInfo.getWorkflowid());
List<EditToStopSIArchiveAction.SalaryField> list = new ArrayList<>();
while (rs.next()) {
String processField = rs.getString("processfield");
String salaryName = rs.getString("salaryname");
String value = fieldMap.get(processField);
list.add(new EditToStopSIArchiveAction.SalaryField(processField, salaryName, value));
}
List<Map<String, Object>> importData = new ArrayList<>();
importData.add(SalaryEntityUtil.convert2Map(list, EditToStopSIArchiveAction.SalaryField::getSalaryName, EditToStopSIArchiveAction.SalaryField::getValue));
//福利执行状态
String runStatus = EmployeeStatusEnum.PAYING.getValue();
SIArchiveImportParam build = SIArchiveImportParam.builder()
.importDatas(importData)
.runStatus(runStatus)
.build();
//操作人
String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(EditToStopSIArchiveAction.SalaryField::getValue).orElse("1");
User user = new User(Integer.parseInt(uid));
//更新/新建档案数据
Map<String, Object> map = getSISchemeService(new User(Integer.parseInt(uid))).addSIArchive(build);
List errorNotice = (List) map.get("errorData");
if (CollectionUtils.isNotEmpty(errorNotice)) {
log.error("福利档案编辑并减员存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map);
List<Map<String, String>> excelComments = (List<Map<String, String>>) map.get("errorData");
StringBuilder message = new StringBuilder("");
for (Map<String, String> comments : excelComments) {
message.append(comments.get("message")).append("\n");
}
requestInfo.getRequestManager().setMessage(message.toString());
return FAILURE_AND_CONTINUE;
}
//刷新福利档案状态
getSIArchivesService(user).handleStayDelData(Integer.parseInt(uid));
//减员
String taxAgentName = importData.get(0).get("个税扣缴义务人").toString();
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName);
if(CollectionUtils.isEmpty(taxAgentPOS)){
requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!");
return FAILURE_AND_CONTINUE;
}
Long taxAgentId = Long.valueOf(taxAgentPOS.get(0).getId());
Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(EditToStopSIArchiveAction.SalaryField::getValue).orElse("-1"));
// 获取福利档案
InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId);
if(insuranceArchivesBaseInfoPO == null){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!");
return FAILURE_AND_CONTINUE;
} else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待减员,无法进行减员操作,请检查后重试!");
return FAILURE_AND_CONTINUE;
}
//减员
Map<String, Object> resultMap = getSIArchivesService(user).stayDelToStop(Collections.singletonList(insuranceArchivesBaseInfoPO.getId()));
if (resultMap.get("type").toString().equals("fail")) {
requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString());
return FAILURE_AND_CONTINUE;
}
} catch (Exception e) {
log.error("福利档案编辑并减员异常", e);
requestInfo.getRequestManager().setMessage(e.getMessage());
return FAILURE_AND_CONTINUE;
}
return SUCCESS;
}
class SalaryField {
private String processField;
private String salaryName;
private String value;
public String getProcessField() {
return processField;
}
public void setProcessField(String processField) {
this.processField = processField;
}
public String getSalaryName() {
return salaryName;
}
public void setSalaryName(String salaryName) {
this.salaryName = salaryName;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public SalaryField(String processField, String salaryName, String value) {
this.processField = processField;
this.salaryName = salaryName;
this.value = value;
}
}
}

View File

@ -82,7 +82,7 @@ public class StayAddToPaySIArchiveAction implements Action {
requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!");
return FAILURE_AND_CONTINUE;
}
Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() );
Long taxAgentId = Long.valueOf(taxAgentPOS.get(0).getId());
Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString());
//操作人

View File

@ -614,6 +614,14 @@ public class SIAccountBiz extends Service {
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(otherPerson.size() > 0) {
otherPerson.forEach((id, object) -> {
if (!needArchivesPerson.contains(id)) {
needArchivesPerson.add(id);
}
});
}
//判断核算周期核算月福利起始缴纳月的关系
checkCycleSettingWithStartMonth(otherPerson, billMonth, otherPO.getOtherStartTime());
@ -676,6 +684,14 @@ public class SIAccountBiz extends Service {
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(otherCom.size() > 0) {
otherCom.forEach((id, object) -> {
if (!needArchivesCom.contains(id)) {
needArchivesCom.add(id);
}
});
}
//判断核算周期核算月福利起始缴纳月的关系
checkCycleSettingWithStartMonth(otherCom, billMonth, otherPO.getOtherStartTime());
@ -756,6 +772,14 @@ public class SIAccountBiz extends Service {
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(fundperson.size() > 0) {
fundperson.forEach((id, object) -> {
if (!needArchivesPerson.contains(id)) {
needArchivesPerson.add(id);
}
});
}
//判断核算周期核算月福利起始缴纳月的关系
checkCycleSettingWithStartMonth(fundperson, billMonth, fundPO.getFundStartTime());
@ -817,6 +841,14 @@ public class SIAccountBiz extends Service {
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(fundCom.size() > 0) {
fundCom.forEach((id, object) -> {
if (!needArchivesCom.contains(id)) {
needArchivesCom.add(id);
}
});
}
//判断核算周期核算月福利起始缴纳月的关系
checkCycleSettingWithStartMonth(fundCom, billMonth, fundPO.getFundStartTime());
@ -900,6 +932,14 @@ public class SIAccountBiz extends Service {
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(schemeperson.size() > 0) {
schemeperson.forEach((id, object) -> {
if (!needArchivesPerson.contains(id)) {
needArchivesPerson.add(id);
}
});
}
//判断核算周期核算月福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime());
@ -961,6 +1001,14 @@ public class SIAccountBiz extends Service {
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(schemeCom.size() > 0) {
schemeCom.forEach((id, object) -> {
if (!needArchivesCom.contains(id)) {
needArchivesCom.add(id);
}
});
}
//判断核算周期核算月福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime());

View File

@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class InsuranceAcctDetailImportFieldDTO {
//字段id
// private String fieldId;
private String fieldId;
//薪资项目名称
private String salaryItemName;

View File

@ -0,0 +1,56 @@
package com.engine.salary.entity.siarchives.param;
import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.util.valid.DataCheck;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
/**
* @Author: sy
* @Description: 社保福利档案导入处理参数
* @Date: 2022/11/10
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SIArchiveImportParam {
/**
* 上传文件id
*/
String imageId;
/**
* 导入类型
*
* @see EmployeeStatusEnum
*/
String runStatus;
/**
* 导入数据
*
*/
List<Map<String,Object>> importDatas;
private boolean addData;
/**
* 待生成的人员范围
*/
List<TaxAgentRangeSaveParam> taxAgentRanges;
/**
* 是否是流程
*/
boolean isProcess;
}

View File

@ -17,6 +17,7 @@ public interface InsuranceCompensationMapper {
List<InsuranceCompensationPO> queryByBillMonthAndPayOrg(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization);
InsuranceCompensationPO getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO insuranceCompensationPO);
List<InsuranceCompensationPO> getListByBillMonthPayOrgEmpId(InsuranceCompensationPO insuranceCompensationPO);
List<InsuranceCompensationPO> getByBillMonthPayOrgEmpIds(InsuranceCompensationPO insuranceCompensationPO);

View File

@ -208,6 +208,7 @@
WHERE t.bill_month = #{billMonth}
AND t.payment_organization = #{paymentOrganization}
AND t.delete_type = 0
ORDER BY t.employee_id, t.create_time
</select>
<!-- 根据账单月份、个税扣缴义务人、人员id获取单条记录 -->
@ -221,6 +222,17 @@
AND t.delete_type = 0
</select>
<!-- 根据账单月份、个税扣缴义务人、人员id获取多条记录 -->
<select id="getListByBillMonthPayOrgEmpId" resultMap="BaseResultMap" parameterType="com.engine.salary.entity.siaccount.po.InsuranceCompensationPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_compensation_log t
WHERE t.bill_month = #{billMonth}
AND t.payment_organization = #{paymentOrganization}
AND t.employee_id = #{employeeId}
AND t.delete_type = 0
</select>
<!-- 根据账单月份、个税扣缴义务人、人员ids获取记录list -->
<select id="getByBillMonthPayOrgEmpIds" resultMap="BaseResultMap" parameterType="com.engine.salary.entity.siaccount.po.InsuranceCompensationPO">
SELECT

View File

@ -1,7 +1,7 @@
package com.engine.salary.process.siArchives;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.impl.SISchemeServiceImpl;
@ -40,11 +40,11 @@ public class SIArchiveActionAPI {
@POST
@Path("/checkImportSIArchiveListAdd")
@Produces(MediaType.APPLICATION_JSON)
public String checkImportSIArchiveListAdd(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportActionParam importData) {
public String checkImportSIArchiveListAdd(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam importData) {
User user = HrmUserVarify.getUser(request, response);
importData.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue());
importData.setAddData(false);
return new ResponseResult<SIArchiveImportActionParam, Map<String, Object>>(user).run(getService(user)::checkSIArchiveAdd, importData);
return new ResponseResult<SIArchiveImportParam, Map<String, Object>>(user).run(getService(user)::checkSIArchiveAdd, importData);
}
/**
@ -55,10 +55,10 @@ public class SIArchiveActionAPI {
@POST
@Path("/addSIArchive")
@Produces(MediaType.APPLICATION_JSON)
public String addSIArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportActionParam importData) {
public String addSIArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam importData) {
User user = HrmUserVarify.getUser(request, response);
importData.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue());
importData.setAddData(true);
return new ResponseResult<SIArchiveImportActionParam, Map<String, Object>>(user).run(getService(user)::addSIArchive, importData);
return new ResponseResult<SIArchiveImportParam, Map<String, Object>>(user).run(getService(user)::addSIArchive, importData);
}
}

View File

@ -101,4 +101,6 @@ public interface SIArchivesService {
* @param longs
*/
void deleteArchive(Collection<Long> longs);
void handleStayDelData(long currentEmployeeId);
}

View File

@ -1,8 +1,12 @@
package com.engine.salary.service;
import com.engine.salary.entity.siexport.param.InsuranceExportParam;
import com.engine.salary.entity.siexport.po.AccountExportPO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.List;
import java.util.Map;
/**
* @Author weaver_cl
* @Description:
@ -25,4 +29,6 @@ public interface SIExportService {
* @return
*/
XSSFWorkbook exportAccount(Integer paymentStatus, InsuranceExportParam param);
List<Map<String, Object>> buildCommonRecords(List<AccountExportPO> list);
}

View File

@ -2,12 +2,11 @@ package com.engine.salary.service;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeDetailUpdateParam;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam;
import com.engine.salary.entity.sischeme.param.SISchemaImportParam;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -66,15 +65,15 @@ public interface SISchemeService {
List<WeaTableColumn> buildWeaTableColumns(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS, Long employeeId);
Map<String, Object> preview(SISchemaImportParam siSchemaImportParam);
Map<String, Object> preview(SIArchiveImportParam param);
Map<String, Object> batchImportEbatch(SISchemaImportParam param);
Map<String, Object> batchImportEbatch(SIArchiveImportParam param);
XSSFWorkbook exportTemplate(InsuranceArchivesListParam param);
Map<String, Object> checkSIArchiveAdd(SIArchiveImportActionParam siArchiveImportActionParam);
Map<String, Object> checkSIArchiveAdd(SIArchiveImportParam param);
Map<String, Object> addSIArchive(SIArchiveImportActionParam siArchiveImportActionParam);
Map<String, Object> addSIArchive(SIArchiveImportParam param);
/**
* 编辑方案明细表数据

View File

@ -18,6 +18,7 @@ import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO;
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.dto.InsuranceAcctDetailImportFieldDTO;
import com.engine.salary.entity.siaccount.param.*;
import com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
@ -71,8 +72,10 @@ 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.engine.salary.wrapper.SalaryFormulaWrapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mzlion.core.utils.BeanUtils;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -197,6 +200,14 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class);
}
private SalaryFormulaWrapper getSalaryFormulaWrapper(User user) {
return (SalaryFormulaWrapper) ServiceUtil.getService(SalaryFormulaWrapper.class, user);
}
public SIExportService getSIExportService(User user) {
return ServiceUtil.getService(SIExportServiceImpl.class, user);
}
@Override
public Map<String, Object> listPage(InsuranceAccountBatchParam queryParam) {
Long employeeId = (long) user.getUID();
@ -1475,7 +1486,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
@Override
public XSSFWorkbook exportImportTemplate(InsuranceAcctDetailImportTemplateParam param) {
ValidUtil.doValidator(param);
Long employeeId = (long) user.getUID();
// 必须选择导入模板所需的薪资项目(福利项)
if (CollectionUtils.isEmpty(param.getWelfareNames())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的福利项目核算项"));
@ -1488,18 +1499,52 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
SalaryI18nUtil.getI18nLabel(86317, "工号"),
SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"),
"账单月份");
List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName", "billMonth");
// List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName", "billMonth");
List<String> dataIndexList = Lists.newArrayList("userName", "department", "mobile", "workcode", "socialPayOrg", "billMonth");
// 查询福利核算项目
List<String> welfareNames = (List<String>) param.getWelfareNames();
headerList.addAll(welfareNames);
//匹配welfareName对应的id
List<InsuranceAcctDetailImportFieldDTO> welfareList = getSalaryFormulaWrapper(user).welfareList();
Map<String, String> welfareNameMap = welfareList.stream().collect(Collectors.toMap(InsuranceAcctDetailImportFieldDTO::getSalaryItemName, InsuranceAcctDetailImportFieldDTO::getFieldId, (key1, key2) -> key2));
welfareNames.forEach(f -> {
if (StringUtils.isNotBlank(welfareNameMap.get(f))) {
dataIndexList.add(welfareNameMap.get(f));
}
});
// excel导出的数据
// //查询当前已有的正常缴纳数据
// List<Map<String, Object>> resultMapList = getNormalDataByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
// // excel导出的数据
// List<List<Object>> rows = Lists.newArrayListWithExpectedSize(resultMapList.size());
// rows.add(headerList);
// for (Map<String, Object> map : resultMapList) {
// List<Object> row = Lists.newArrayListWithExpectedSize(headerList.size());
// for (String dataIndex : dataIndexList) {
// row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY));
// }
// rows.add(row);
// }
InsuranceExportParam exportParam = new InsuranceExportParam();
//排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
exportParam.setOrderRule(orderRule);
exportParam.setBillMonth(param.getBillMonth());
exportParam.setPaymentOrganization(param.getPaymentOrganization().toString());
List<AccountExportPO> accountExportPOS = new ArrayList<>();
accountExportPOS = getInsuranceExportMapper().exportAccount(PaymentStatusEnum.COMMON.getValue(), exportParam);
//非系统人员核算明细
List<AccountExportPO> extAccountExportPOS = getInsuranceExportMapper().exportExtAccount(PaymentStatusEnum.COMMON.getValue(), exportParam);
accountExportPOS.addAll(extAccountExportPOS);
encryptUtil.decryptList(accountExportPOS, AccountExportPO.class);
// 数据组装
List<Map<String, Object>> records = getSIExportService(user).buildCommonRecords(accountExportPOS);
// excel导出的数据
//查询当前已有的正常缴纳数据
List<Map<String, Object>> resultMapList = getNormalDataByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
// excel导出的数据
List<List<Object>> rows = Lists.newArrayListWithExpectedSize(resultMapList.size());
List<List<Object>> rows = Lists.newArrayListWithExpectedSize(records.size());
rows.add(headerList);
for (Map<String, Object> map : resultMapList) {
for (Map<String, Object> map : records) {
List<Object> row = Lists.newArrayListWithExpectedSize(headerList.size());
for (String dataIndex : dataIndexList) {
row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY));

View File

@ -209,8 +209,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
* 福利档案中待减员数据自动处理
* @param currentEmployeeId
*/
@Override
@Transactional(rollbackFor = Exception.class)
private void handleStayDelData(long currentEmployeeId) {
public void handleStayDelData(long currentEmployeeId) {
log.info("福利档案中待减员数据自动处理逻辑开始:");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
String today = simpleDateFormat.format(new Date());

View File

@ -17,6 +17,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO;
import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
@ -25,10 +26,7 @@ import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
import com.engine.salary.mapper.siaccount.InsuranceCompensationConfigMapper;
import com.engine.salary.mapper.siaccount.InsuranceCompensationMapper;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.service.ColumnBuildService;
import com.engine.salary.service.SIAccountService;
import com.engine.salary.service.SICategoryService;
import com.engine.salary.service.SICompensationService;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
@ -84,6 +82,9 @@ public class SICompensationServiceImpl extends Service implements SICompensation
return MapperProxyFactory.getProxy(ICategoryMapper.class);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
/**
* 可调差人员
*/
@ -200,20 +201,21 @@ public class SICompensationServiceImpl extends Service implements SICompensation
} else {
encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class);
//判断是否已有调差数据个税扣缴义务人+账单月份+人员id
InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder()
.billMonth(insuranceAccountDetailPO.getBillMonth())
.paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization())
.employeeId(insuranceAccountDetailPO.getEmployeeId())
.build());
if (nowCompensation != null) {
temp.put("error", SalaryI18nUtil.getI18nLabel(121039, "当前月在该缴纳组织下已存在调差数据"));
}
// InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder()
// .billMonth(insuranceAccountDetailPO.getBillMonth())
// .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization())
// .employeeId(insuranceAccountDetailPO.getEmployeeId())
// .build());
//
// if (nowCompensation != null) {
// temp.put("error", SalaryI18nUtil.getI18nLabel(121039, "当前月在该缴纳组织下已存在调差数据"));
// }
//处理调差数据
BigDecimal total = new BigDecimal("0");
List<String> categoryTypeList = Arrays.asList(compensation.getCategoryType().split(","));
if (nowCompensation == null && StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) {
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) {
Map<String, String> socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap<String, String>().getClass());
for (Map.Entry<String, String> entry : socialJson.entrySet()) {
String insuranceId = entry.getKey();
@ -272,7 +274,8 @@ public class SICompensationServiceImpl extends Service implements SICompensation
public Map<String, Object> compensationAccount(List<InsuranceCompensationDTO> list) {
long currentEmployeeId = user.getUID();
List<DataCollectionEmployee> allEmployees = getEmployMapper().listAll();
// List<DataCollectionEmployee> allEmployees = getEmployMapper().listAll();
List<DataCollectionEmployee> allEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL);
Map<Long, String> usernameMap = SalaryEntityUtil.convert2Map(allEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername);
Map<String, Object> result = new HashMap<>();
@ -281,9 +284,49 @@ public class SICompensationServiceImpl extends Service implements SICompensation
//过滤
list = list.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(InsuranceCompensationDTO::getTarget))), ArrayList::new));
new TreeSet<>(Comparator.comparing((o -> o.getTarget() + ";" + o.getAdjustTo() + ";" + o.getCategoryType())))), ArrayList::new));
//根据target分组
Map<Long, List<InsuranceCompensationDTO>> compensationGroupInfoMap= list.stream().collect(Collectors.groupingBy(InsuranceCompensationDTO::getTarget));
//取福利项id和name的关联map
List<ICategoryPO> socialWelfareList = getICategoryMapper().listAll().stream().filter(e -> e.getWelfareType() == 1).collect(Collectors.toList());
Map<Long, String> welfareNameMap = socialWelfareList.stream().collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName, (key1, key2) -> key2));
for (InsuranceCompensationDTO param : list) {
//判断统计调差福利类型即categoryType中是否存在同保存批次重复福利项
List<InsuranceCompensationDTO> waitJudgeCompensations = compensationGroupInfoMap.get(param.getTarget()).stream().
filter(f -> !f.getTarget().equals(param.getTarget()) && !f.getAdjustTo().equals(param.getAdjustTo()) && !f.getCategoryType().equals(param.getCategoryType())).collect(Collectors.toList());
if (waitJudgeCompensations.size() > 0) {
boolean judgeResult = true;
for (InsuranceCompensationDTO judgeParam : waitJudgeCompensations) {
List<String> toDealWelfareTypeList = Arrays.asList(param.getCategoryType().split(","));
List<String> toJudgeWelfareTypeList = Arrays.asList(judgeParam.getCategoryType().split(","));
// toDealWelfareTypeList.retainAll(toJudgeWelfareTypeList);
List<String> intersectionList = (List<String>) SalaryEntityUtil.intersectionForList(toDealWelfareTypeList, toJudgeWelfareTypeList);
if (intersectionList.size() > 0) {
StringBuilder toDealWelfareNames = new StringBuilder();
StringBuilder sameWelfareNames = new StringBuilder();
for(String str : toDealWelfareTypeList) {
if (welfareNameMap.get(Long.valueOf(str)) != null) {
toDealWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("");
}
}
for(String str : intersectionList) {
if (welfareNameMap.get(Long.valueOf(str)) != null) {
sameWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("");
}
}
errorList.add(usernameMap.get(param.getEmployeeId()) + "-" + toDealWelfareNames.deleteCharAt(toDealWelfareNames.length() - 1)
+ "-调差失败:提交数据中,统计调差福利类型有重合部分!" + "重合福利部分为:" + sameWelfareNames.deleteCharAt(sameWelfareNames.length() - 1));
judgeResult = false;
break;
}
}
if (!judgeResult) {
continue;
}
}
if (StringUtils.isBlank(param.getAdjustmentTotal()) || "0".equals(param.getAdjustmentTotal()) || "0.00".equals(param.getAdjustmentTotal())) {
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差数额不正确!");
continue;
@ -292,23 +335,68 @@ public class SICompensationServiceImpl extends Service implements SICompensation
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败公司核算金额为0请检查数据是否属实或者当前人员已存在该月调差数据");
continue;
}
if (param.getAdjustTo() == null) {
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差到的福利未设置!");
continue;
}
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(param.getTarget());
if (insuranceAccountDetailPO == null) {
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差对象不存在!");
continue;
}
if (!param.getCategoryType().contains(param.getAdjustTo().toString())) {
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差到的福利未正确设置!");
continue;
}
//判断是否已有调差数据个税扣缴义务人+账单月份+人员id
InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder()
// InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder()
// .billMonth(insuranceAccountDetailPO.getBillMonth())
// .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization())
// .employeeId(insuranceAccountDetailPO.getEmployeeId())
// .build());
// if (nowCompensation != null) {
// errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差对象在当前月该缴纳组织下已存在调差数据!");
// continue;
// }
List<InsuranceCompensationPO> nowCompensationList = getInsuranceCompensationMapper().getListByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder()
.billMonth(insuranceAccountDetailPO.getBillMonth())
.paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization())
.employeeId(insuranceAccountDetailPO.getEmployeeId())
.build());
if (nowCompensation != null) {
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差对象在当前月该缴纳组织下已存在调差数据!");
continue;
if (nowCompensationList.size() > 0) {
boolean judgeResult = true;
for (InsuranceCompensationPO judgePO : nowCompensationList) {
List<String> toDealWelfareTypeList = Arrays.asList(param.getCategoryType().split(","));
List<String> toJudgeWelfareTypeList = Arrays.asList(judgePO.getCategoryType().split(","));
List<String> intersectionList = (List<String>) SalaryEntityUtil.intersectionForList(toDealWelfareTypeList, toJudgeWelfareTypeList);
if (intersectionList.size() > 0) {
StringBuilder toDealWelfareNames = new StringBuilder();
StringBuilder sameWelfareNames = new StringBuilder();
for(String str : toDealWelfareTypeList) {
if (welfareNameMap.get(Long.valueOf(str)) != null) {
toDealWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("");
}
}
for(String str : intersectionList) {
if (welfareNameMap.get(Long.valueOf(str)) != null) {
sameWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("");
}
}
errorList.add(usernameMap.get(param.getEmployeeId()) + "-" + toDealWelfareNames.deleteCharAt(toDealWelfareNames.length() - 1)
+ "-调差失败:相同福利不可以多次调差!" + "相同部分为:" + sameWelfareNames.deleteCharAt(sameWelfareNames.length() - 1));
judgeResult = false;
break;
}
}
if (!judgeResult) {
continue;
}
}
encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class);
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) {
Map<String, String> socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap<String, String>().getClass());
@ -373,7 +461,7 @@ public class SICompensationServiceImpl extends Service implements SICompensation
if (errorList.size() == 0) {
result.put("data", "全部调差成功!");
} else {
result.put("data", "存在调差失败项!");
result.put("data", "存在调差失败项!" + "失败数量为:" + errorList.size() + "。具体有以下:");
}
result.put("errorMessage", errorList);
result.put("successIds", idList);

View File

@ -207,7 +207,7 @@ public class SIExportServiceImpl extends Service implements SIExportService {
records = buildCommonRecords(accountExportPOS);
List<List<Object>> excelSheetData = new ArrayList<>();
//工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案");
String sheetName = SalaryI18nUtil.getI18nLabel(0, "社保福利台账");
excelSheetData.add(Arrays.asList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new)));
//合计
boolean total = false;
@ -245,8 +245,8 @@ public class SIExportServiceImpl extends Service implements SIExportService {
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName, total);
}
private List<Map<String, Object>> buildCommonRecords(List<AccountExportPO> list) {
@Override
public List<Map<String, Object>> buildCommonRecords(List<AccountExportPO> list) {
List<Map<String, Object>> result = new ArrayList<>();
List<TaxAgentPO> paymentList = getTaxAgentMapper().listAll();

View File

@ -14,19 +14,21 @@ import com.engine.salary.encrypt.AESEncryptUtil;
import com.engine.salary.encrypt.EncryptUtil;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.entity.siarchives.po.*;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeDetailUpdateParam;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam;
import com.engine.salary.entity.sischeme.param.SISchemaImportParam;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
import com.engine.salary.entity.taxagent.param.TaxAgentManageRangeSaveParam;
import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.salarysob.TargetTypeEnum;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.enums.sicategory.*;
import com.engine.salary.exception.SalaryRunTimeException;
@ -39,10 +41,7 @@ import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper;
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.SIImportService;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.*;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.service.SalarySysConfService;
@ -146,6 +145,10 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
public TaxAgentManageRangeService getTaxAgentManageRangeService(User user) {
return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user);
}
@Override
public Map<String, Object> getForm(Map<String, Object> params) {
return commandExecutor.execute(new SISchemeGetFormCmd(params, user));
@ -608,7 +611,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
* 导入的数据插入到数据库中
*/
@Override
public Map<String, Object> preview(SISchemaImportParam param) {
public Map<String, Object> preview(SIArchiveImportParam param) {
ValidUtil.doValidator(param);
InputStream fileInputStream = null;
try {
@ -626,15 +629,16 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
/**
* 导入的数据插入到数据库中
*/
public Map<String, Object> batchImportEbatch(SISchemaImportParam param) {
public Map<String, Object> batchImportEbatch(SIArchiveImportParam param) {
ValidUtil.doValidator(param);
param.setProcess(false);
if (StringUtils.isBlank(param.getRunStatus())) {
throw new SalaryRunTimeException("福利档案执行状态未在导入条件设置中添加!");
}
// List<ExcelSheet> excelSheets = message.getBatchFile().getExcelSheets();
// 租户key
// String tenantKey = message.getTenantKey().toLowerCase();
// String tenantKey = message.getTenantKey().toLowerCase();EditSIArchiveAction
//操作员id
Long creator = (long) user.getUID();
//获取所有福利类型的id-name结合
@ -699,7 +703,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
singleAccount.add(cellData);
}
isError = singleAccountCheck(singleAccount, welfareMap, insuranceArchivesAccountPOS, employeeByIds, excelComments, errorCount + 1, schemeNameIdMap, paymentNameIdMap, creator, i + 2, openDevolution, taxAgentManageRangeEmployeeTree, param.getRunStatus());
isError = singleAccountCheck(singleAccount, welfareMap, insuranceArchivesAccountPOS, employeeByIds, excelComments, errorCount + 1, schemeNameIdMap, paymentNameIdMap, creator, i + 2, openDevolution, taxAgentManageRangeEmployeeTree, param);
if (isError) {
errorCount += 1;
// 添加错误数据
@ -716,7 +720,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
// }
// 数据入库处理
handleImportData(insuranceArchivesAccountPOS);
handleImportData(insuranceArchivesAccountPOS, param);
// 发送导入回调信息
// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets);
@ -755,8 +759,14 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
return userState;
}
public boolean singleAccountCheck(List<Map<String, Object>> singleAccount, Map<Long, String> welfareMap, List<InsuranceArchivesAccountPO> insuranceArchivesAccountPOS, List<DataCollectionEmployee> employeeByIds, List<Map<String, String>> excelComments, int i, Map<String, Long> schemeNameIdMap, Map<String, Long> paymentNameIdMap, Long creator, int index, Boolean openDevolution, List<TaxAgentManageRangeEmployeeDTO> taxAgentManageRangeEmployeeTree, String runStatus) {
public boolean singleAccountCheck(List<Map<String, Object>> singleAccount, Map<Long, String> welfareMap,
List<InsuranceArchivesAccountPO> insuranceArchivesAccountPOS, List<DataCollectionEmployee> employeeByIds,
List<Map<String, String>> excelComments, int i, Map<String, Long> schemeNameIdMap,
Map<String, Long> paymentNameIdMap, Long creator, int index, Boolean openDevolution,
List<TaxAgentManageRangeEmployeeDTO> taxAgentManageRangeEmployeeTree, SIArchiveImportParam param) {
boolean isError = false;
String runStatus = param.getRunStatus();
// String userName = (String) singleAccount.get(0).get(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
// String deparmentName = (String) singleAccount.get(1).get(SalaryI18nUtil.getI18nLabel(86185, "部门"));
// String mobile = (String) singleAccount.get(2).get(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
@ -878,27 +888,33 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
isError = true;
}
if (openDevolution && !isError) {
if (!isError) {
Long paymentOrgId = paymentNameIdMap.get(paymentOrg);
TaxAgentManageRangeEmployeeDTO taxAgentManageRangeEmployeeDTO = taxAgentManageRangeEmployeeTree.stream().filter(tax -> tax.getTaxAgentId().equals(paymentOrgId)).findFirst().get();
Optional<Long> o = taxAgentManageRangeEmployeeDTO.getEmployeeList().stream().map(TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee::getEmployeeId).filter(e -> e.equals(employeeId)).findFirst();
if (!o.isPresent()) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, "该条数据不在个税扣缴义务人人员范围内,不可导入"));
excelComments.add(errorMessageMap);
isError = true;
if (param.isProcess()) {
//流程中自动将人员添加进个税扣缴义务人中
TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam taxAgentSubAdminRangeTargetParam = new TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam();
taxAgentSubAdminRangeTargetParam.setTargetId(employeeId);
taxAgentSubAdminRangeTargetParam.setTargetType(TargetTypeEnum.EMPLOYEE);
TaxAgentRangeSaveParam taxAgentRangeSaveParam = new TaxAgentRangeSaveParam();
taxAgentRangeSaveParam.setTaxAgentId(paymentOrgId);
taxAgentRangeSaveParam.setIncludeType(1);
taxAgentRangeSaveParam.setEmployeeStatus(Arrays.asList("0", "1", "2", "3", "4", "5", "6"));
taxAgentRangeSaveParam.setTargetParams(Collections.singletonList(taxAgentSubAdminRangeTargetParam));
taxAgentRangeSaveParam.setSync(true);
param.setTaxAgentRanges(Collections.singletonList(taxAgentRangeSaveParam));
} else {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, "该条数据不在个税扣缴义务人人员范围内,不可导入"));
excelComments.add(errorMessageMap);
isError = true;
}
}
// //判断是否存在其他个税扣缴义务人下的该员工福利档案
// // 所有福利档案基础信息数据
// List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
// List<InsuranceArchivesBaseInfoPO> otherTaxBaseInfos = baseInfoPOList.stream().filter(f -> f.getEmployeeId().equals(employeeId) && !f.getPaymentOrganization().equals(paymentOrgId)).collect(Collectors.toList());
// if (otherTaxBaseInfos.size() > 0) {
// Map<String, String> errorMessageMap = Maps.newHashMap();
// errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, "该条数据相关人员已存在其他个税扣缴义务人下的福利档案,不可导入"));
// excelComments.add(errorMessageMap);
// isError = true;
// }
}
@ -1353,7 +1369,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
return insuranceArchivesBaseInfoPO;
}
public void handleImportData(List<InsuranceArchivesAccountPO> insuranceArchivesAccountPOS) {
public void handleImportData(List<InsuranceArchivesAccountPO> insuranceArchivesAccountPOS, SIArchiveImportParam param) {
//导入社保档案
List<InsuranceArchivesSocialSchemePO> socialSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getSocial).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(socialSchemePOS)) {
@ -1433,6 +1449,10 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
List<List<InsuranceArchivesBaseInfoPO>> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100);
partition.forEach(getInsuranceBaseInfoMapper()::batchSave);
}
//新增人员范围会自动生成人员档案
if (CollectionUtils.isNotEmpty(param.getTaxAgentRanges())) {
param.getTaxAgentRanges().forEach(getTaxAgentManageRangeService(user)::save);
}
}
@ -1459,31 +1479,26 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
/**
* 校验待新增的社保福利档案数据
*
* @param siArchiveImportActionParam
* @return
*/
@Override
public Map<String, Object> checkSIArchiveAdd(SIArchiveImportActionParam siArchiveImportActionParam) {
siArchiveImportActionParam.setAddData(false);
return processAddSIArchive(siArchiveImportActionParam);
public Map<String, Object> checkSIArchiveAdd(SIArchiveImportParam param) {
param.setAddData(false);
return processAddSIArchive(param);
}
/**
* 新增社保福利档案
*
* @param siArchiveImportActionParam
* @return
*/
@Override
public Map<String, Object> addSIArchive(SIArchiveImportActionParam siArchiveImportActionParam) {
siArchiveImportActionParam.setAddData(true);
return processAddSIArchive(siArchiveImportActionParam);
public Map<String, Object> addSIArchive(SIArchiveImportParam param) {
param.setAddData(true);
return processAddSIArchive(param);
}
private Map<String, Object> processAddSIArchive(SIArchiveImportActionParam param) {
private Map<String, Object> processAddSIArchive(SIArchiveImportParam param) {
ValidUtil.doValidator(param);
param.setProcess(true);
if (StringUtils.isBlank(param.getRunStatus())) {
throw new SalaryRunTimeException("福利档案执行状态未在导入条件设置中添加!");
@ -1566,7 +1581,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
singleAccount.add(cellData);
}
isError = singleAccountCheck(singleAccount, welfareMap, insuranceArchivesAccountPOS, employeeByIds, excelComments, errorCount + 1, schemeNameIdMap, paymentNameIdMap, creator, i + 2, openDevolution, taxAgentManageRangeEmployeeTree, param.getRunStatus());
isError = singleAccountCheck(singleAccount, welfareMap, insuranceArchivesAccountPOS, employeeByIds, excelComments, errorCount + 1, schemeNameIdMap, paymentNameIdMap, creator, i + 2, openDevolution, taxAgentManageRangeEmployeeTree, param);
if (isError) {
errorCount += 1;
// 添加错误数据
@ -1584,7 +1599,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
// 数据入库处理
if (param.isAddData()) {
handleImportData(insuranceArchivesAccountPOS);
handleImportData(insuranceArchivesAccountPOS, param);
}
// 发送导入回调信息
// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets);

View File

@ -4,11 +4,11 @@ import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportParam;
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeDetailUpdateParam;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam;
import com.engine.salary.entity.sischeme.param.SISchemaImportParam;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import com.engine.salary.service.SIAccountService;
@ -231,18 +231,18 @@ public class SISchemeController {
@POST
@Path("/preview")
@Produces(MediaType.APPLICATION_JSON)
public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SISchemaImportParam queryParam) {
public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SISchemaImportParam, Map<String, Object>>(user).run(getService(user)::preview, queryParam);
return new ResponseResult<SIArchiveImportParam, Map<String, Object>>(user).run(getService(user)::preview, queryParam);
}
@POST
@Path("/importBatch")
@Produces(MediaType.APPLICATION_JSON)
public String batchImportEbatch(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SISchemaImportParam queryParam) {
public String batchImportEbatch(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SISchemaImportParam, Map<String, Object>>(user).run(getService(user)::batchImportEbatch, queryParam);
return new ResponseResult<SIArchiveImportParam, Map<String, Object>>(user).run(getService(user)::batchImportEbatch, queryParam);
}

View File

@ -111,20 +111,20 @@ public class SalaryFormulaWrapper extends Service {
param.setSourceId("welfare");
//获取福利类薪资项目
List<FormulaVar> list = getRemoteExcelService(user).fieldList(param.getSourceId(), param.getExtendParam());
list = list.stream().filter(f -> !(f.getName().contains("正常缴纳") || f.getName().contains("补缴") || f.getName().contains("补差"))).collect(Collectors.toList());
list = list.stream().filter(f -> !(f.getName().contains("正常缴纳") || f.getName().contains("补缴") || f.getName().contains("补差") || f.getName().contains("申报基数"))).collect(Collectors.toList());
//提取出福利类项目名称
for (FormulaVar formulaVar : list) {
InsuranceAcctDetailImportFieldDTO insuranceAcctDetailImportFieldDTO = new InsuranceAcctDetailImportFieldDTO();
// insuranceAcctDetailImportFieldDTO.setFieldId(formulaVar.getFieldId());
insuranceAcctDetailImportFieldDTO.setFieldId(formulaVar.getFieldId().contains("welfare_") ? formulaVar.getFieldId().substring(8) : formulaVar.getFieldId());
insuranceAcctDetailImportFieldDTO.setSalaryItemName(formulaVar.getName());
welfareList.add(insuranceAcctDetailImportFieldDTO);
}
welfareList.add(new InsuranceAcctDetailImportFieldDTO("社保合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("公积金合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("其他福利合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("socialSum","社保合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("fundSum","公积金合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("otherSum","其他福利合计"));
welfareList.add(new InsuranceAcctDetailImportFieldDTO("total","合计"));
return welfareList;
}