Merge branch 'release/2.15.2.2409.01' into feature/权限

# Conflicts:
#	src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java
This commit is contained in:
钱涛 2024-09-29 10:46:04 +08:00
commit 541546f5c8
7 changed files with 88 additions and 42 deletions

View File

@ -8,12 +8,6 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author weaver_cl
*
* @Date 2022/4/18
* @Version V1.0
**/
public interface InsuranceExportMapper {
List<ExcelAccountExportPO> exportExcelAccount(@Param("param") InsuranceComparisonResultQueryParam param);

View File

@ -0,0 +1,18 @@
package com.engine.salary.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* SQLMapper
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface SQLMapper {
List<Map> runSQL(@Param("sql") String sql);
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.engine.salary.mapper.SQLMapper">
<select id="runSQL" resultType="java.util.Map">
${sql}
</select>
</mapper>

View File

@ -9,9 +9,11 @@ import com.engine.salary.enums.salaryformula.ReferenceTypeEnum;
import com.engine.salary.formlua.core.QlExpress;
import com.engine.salary.formlua.entity.parameter.DataType;
import com.engine.salary.formlua.entity.standard.ExcelResult;
import com.engine.salary.mapper.SQLMapper;
import com.engine.salary.service.FormulaRunService;
import com.engine.salary.sys.enums.OpenEnum;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.ql.util.express.DefaultContext;
import com.ql.util.express.ExpressRunner;
import lombok.extern.slf4j.Slf4j;
@ -41,6 +43,9 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService
QlExpress express = new QlExpress();
private SQLMapper getSQLMapper(){
return MapperProxyFactory.getProxy(SQLMapper.class);
}
@Override
public ExcelResult run(ExpressFormula expressFormula, List<FormulaVar> formulaVars, DataCollectionEmployee simpleEmployee) {
@ -123,6 +128,12 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService
}
}
} else {
// List<Map> list = getSQLMapper().runSQL(sql);
// if(CollectionUtil.isNotEmpty(list)){
// result = Util.null2String(list.get(0).get(sqlReturnKey));
// }
RecordSet rs = new RecordSet();
if (rs.execute(sql)) {
if (rs.next()) {

View File

@ -458,6 +458,11 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
@Override
public void deleteByIds(Collection<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
// 删除薪资核算人员
getSalaryAcctEmployeeMapper().deleteByIds(ids);
// 删除薪资核算人员对应的薪资核算结果
@ -558,36 +563,47 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
@Override
public void refresh(Long salaryAcctRecordId) {
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listBySalaryAcctRecordId(salaryAcctRecordId);
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
return;
}
List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 根据薪资账套查询人员
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
if (CollectionUtils.isEmpty(salaryEmployees)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "未查询到账套下关联人员"));
}
// 根据薪资账套查询薪资周期
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
//查询账套对应的扣缴义务人
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
//过滤掉不属于当前账套扣缴义务人的人员
List<Long> taxAgentIds = salarySobPO.getTaxAgentIds();
Long taxAgentId = salarySobPO.getTaxAgentId();
// 查询薪资核算记录所用的帐套的薪资周期
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
// 查询薪资档案获取人员的个税扣缴义务人
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
List<Long> employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList());
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId);
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> newSalaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(employees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po ->taxAgentIds.contains(po.getTaxAgentId())).collect(Collectors.toList());
// 删除以前的薪资核算人员
getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
// 插入新的薪资核算人员
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) {
batchSave(newSalaryAcctEmployeePOS);
}
List<SalaryAcctEmployeePO> newEmps = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
//过滤掉不属于当前账套扣缴义务人的人员
newEmps = newEmps.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList());
Map<String, SalaryAcctEmployeePO> newEmpMap = SalaryEntityUtil.convert2Map(newEmps, e -> e.getTaxAgentId() + "_" + e.getEmployeeId());
// 查询薪资核算人员
List<SalaryAcctEmployeePO> oldEmps = listBySalaryAcctRecordId(salaryAcctRecordId);
Map<String, SalaryAcctEmployeePO> oldEmpMap = SalaryEntityUtil.convert2Map(oldEmps, e -> e.getTaxAgentId() + "_" + e.getEmployeeId());
//新增
List<SalaryAcctEmployeePO> addEmps = newEmps.stream().filter(po -> !oldEmpMap.containsKey(po.getTaxAgentId() + "_" + po.getEmployeeId())).collect(Collectors.toList());
//删除
List<Long> delIds = oldEmps.stream().filter(po -> !newEmpMap.containsKey(po.getTaxAgentId() + "_" + po.getEmployeeId())).map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
deleteByIds(delIds);
batchSave(addEmps);
}
@ -724,20 +740,20 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
// }
// list = list.stream().filter(po -> employeeIdsByGradeFilter.contains(po.getEmployeeId())).collect(Collectors.toList());
// }
// 岗位过滤
// 岗位过滤
List<Long> position = param.getPosition();
if (CollectionUtils.isNotEmpty(position)) {
// Set<Long> employeeIdsByPostionFilter = new HashSet<>();
// simpleEmployeeList.forEach(simpleEmployee -> {
// if (simpleEmployee.getPosition() != null && param.getPosition().contains(simpleEmployee.getPosition().getId())) {
// employeeIdsByPostionFilter.add(simpleEmployee.getEmployeeId());
// }
// });
// if (CollectionUtils.isEmpty(employeeIdsByPostionFilter)) {
// return Lists.newArrayList();
// }
// Set<Long> employeeIdsByPostionFilter = new HashSet<>();
// simpleEmployeeList.forEach(simpleEmployee -> {
// if (simpleEmployee.getPosition() != null && param.getPosition().contains(simpleEmployee.getPosition().getId())) {
// employeeIdsByPostionFilter.add(simpleEmployee.getEmployeeId());
// }
// });
// if (CollectionUtils.isEmpty(employeeIdsByPostionFilter)) {
// return Lists.newArrayList();
// }
employeeList = employeeList.stream().filter(emp -> position.contains(emp.getJobtitleId())).collect(Collectors.toList());
}
}
// 人事状态过滤
if (CollectionUtils.isNotEmpty(param.getStatus())) {
Set<Long> employeeIdsByStatus = new HashSet<>();

View File

@ -247,13 +247,13 @@ public class SalaryAcctController {
return new ResponseResult<Long, String>(user).run(getSalaryAcctEmployeeWrapper(user)::checkTaxAgent, param.getSalaryAcctRecordId());
}
//刷新薪资核算人员的个税扣缴义务人
//刷新薪资核算人员
@POST
@Path("/acctemployee/refreshTaxAgent")
@Path("/acctemployee/refresh")
@Produces(MediaType.APPLICATION_JSON)
public String refreshTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmpRefreshTaxAgentParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, String>(user).run(getSalaryAcctEmployeeWrapper(user)::refreshTaxAgent, param.getSalaryAcctRecordId());
return new ResponseResult<Long, String>(user).run(getSalaryAcctEmployeeWrapper(user)::refresh, param.getSalaryAcctRecordId());
}
//从环比上月减少添加薪资核算人员

View File

@ -184,11 +184,11 @@ public class SalaryAcctEmployeeWrapper extends Service {
}
/**
* 刷新个税扣缴义务人
* 刷新核算人员
*
* @param salaryAcctRecordId 薪资核算记录的id
*/
public void refreshTaxAgent(Long salaryAcctRecordId) {
public void refresh(Long salaryAcctRecordId) {
getSalaryAcctEmployeeService(user).refresh(salaryAcctRecordId);
}