鲁控数字冲突

This commit is contained in:
Harryxzy 2024-04-03 15:23:40 +08:00
parent bc7ebf868d
commit da4959861c
7 changed files with 128 additions and 1 deletions

View File

@ -70,15 +70,18 @@ public class SalaryAcctRecordBO {
btnList.add(new WeaTableOperate("删除", null, "1"));
}
btnList.add(new WeaTableOperate("归档", null, "2"));
btnList.add(new WeaTableOperate("结转", null, "6"));
} else if (SalaryAcctRecordStatusEnum.ARCHIVED == salaryAcctRecordStatusEnum && ( salarySendMap.get(salaryAcctRecordPO.getId()) ==Boolean.TRUE ) ){
btnList.add(new WeaTableOperate("查看", null, "3"));
btnList.add(new WeaTableOperate("重新核算", null, "4"));
if(salaryAcctRecordPO.getBackCalcStatus() == null || salaryAcctRecordPO.getBackCalcStatus() == NumberUtils.INTEGER_ZERO) {
btnList.add(new WeaTableOperate("回算", null, "5"));
}
btnList.add(new WeaTableOperate("结转", null, "6"));
} else {
btnList.add(new WeaTableOperate("查看", null, "3"));
btnList.add(new WeaTableOperate("重新核算", null, "4"));
btnList.add(new WeaTableOperate("结转", null, "6"));
}
return SalaryAcctRecordListDTO.builder()
.id(salaryAcctRecordPO.getId())

View File

@ -207,4 +207,10 @@ public interface SalaryAcctRecordService {
List<SalaryAcctRecordPO> listSome(SalaryAcctRecordPO po);
/**
* 鲁控数字-结转
* @param salaryAcctRecordId
*/
void lkszJz(Long salaryAcctRecordId);
}

View File

@ -21,6 +21,8 @@ public interface SalaryAcctReportService {
*/
void batchSave(Collection<SalaryAcctResultReportPO> pos);
void lkszBatchSave(Collection<SalaryAcctResultReportPO> pos);
/**
* 根据核算记录删除
* @param salaryAcctRecordIds

View File

@ -1,11 +1,15 @@
package com.engine.salary.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
import com.engine.salary.entity.salaryBill.po.SalarySendPO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctRecordBO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam;
@ -14,6 +18,7 @@ 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.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.enums.OperateTypeEnum;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
@ -30,6 +35,7 @@ import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.IdGenerator;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
@ -39,6 +45,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
import java.time.YearMonth;
import java.util.*;
import java.util.stream.Collectors;
@ -824,4 +831,87 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
public List<SalaryAcctRecordPO> listSome(SalaryAcctRecordPO po) {
return getSalaryAcctRecordMapper().listSome(po);
}
@Override
public void lkszJz(Long salaryAcctRecordId) {
SalaryAcctRecordPO salaryAcctRecordPO = getById(salaryAcctRecordId);
if (ObjectUtil.isEmpty(salaryAcctRecordPO)) {
throw new SalaryRunTimeException("薪资核算记录不存在或已被删除");
}
YearMonth salaryMonth = SalaryDateUtil.toYearMonth(SalaryDateUtil.dateToLocalDate(salaryAcctRecordPO.getSalaryMonth()).plusMonths(1));
// 创建下一个月的薪资核算记录
Long newSalaryAcctRecordId = save(SalaryAcctRecordSaveParam.builder().salarySobId(salaryAcctRecordPO.getSalarySobId()).salaryMonth(salaryMonth).build());
// 查询下个月的薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(newSalaryAcctRecordId);
List<Long> acctEmpIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList());
// 获取原来的薪资核算结果
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
List<Long> salarySobItemIds = salarySobItemPOS.stream().map(SalarySobItemPO::getSalaryItemId).collect(Collectors.toList());
List<SalaryAcctResultPO> resultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndSalaryItemIds(Collections.singletonList(salaryAcctRecordId), salarySobItemIds);
// 过滤掉新的核算记录中不存在的人
resultPOS = resultPOS.stream().filter(result -> acctEmpIds.contains(result.getEmployeeId())).collect(Collectors.toList());
Map<Long, List<SalaryAcctResultPO>> resultMap = SalaryEntityUtil.group2Map(resultPOS, SalaryAcctResultPO::getEmployeeId);
// 查询人员信息供报表使用
List<DataCollectionEmployee> dataCollectionEmployees = getSalaryEmployeeService(user).listAllForReport();
Map<Long, DataCollectionEmployee> emps = SalaryEntityUtil.convert2Map(dataCollectionEmployees, DataCollectionEmployee::getEmployeeId);
// 需要保存的核算结果
List<SalaryAcctResultPO> needInsertResultList = new ArrayList<>();
// 报表
List<SalaryAcctResultReportPO> needInsertResultReportList = new ArrayList<>();
Date now = new Date();
Long uid = Long.valueOf(user.getUID());
salaryAcctEmployeePOList.stream().forEach(acctEmp -> {
List<SalaryAcctResultPO> oldResultList = resultMap.get(acctEmp.getEmployeeId());
oldResultList.stream().forEach(oldResult -> {
// 薪资核算结果
needInsertResultList.add(SalaryAcctResultPO.builder()
.salarySobId(salaryAcctRecordPO.getSalarySobId())
.salaryItemId(oldResult.getSalaryItemId())
.salaryAcctRecordId(newSalaryAcctRecordId)
.salaryAcctEmpId(acctEmp.getId())
.employeeId(acctEmp.getEmployeeId())
.taxAgentId(acctEmp.getTaxAgentId())
.resultValue(StringUtils.trim(oldResult.getResultValue()))
.originResultValue(oldResult.getOriginResultValue())
.creator(uid)
.createTime(now)
.updateTime(now)
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build());
// 报表结果
SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder()
.id(IdGenerator.generate())
.salarySobId(salaryAcctRecordPO.getSalarySobId())
.salaryItemId(oldResult.getSalaryItemId())
.salaryAcctRecordId(newSalaryAcctRecordId)
.salaryAcctEmpId(acctEmp.getId().toString())
.employeeId(acctEmp.getEmployeeId().toString())
.taxAgentId(acctEmp.getTaxAgentId())
.resultValue(StringUtils.trim(oldResult.getResultValue()))
.creator(uid)
.createTime(now)
.updateTime(now)
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
DataCollectionEmployee dataCollectionEmployee = emps.get(acctEmp.getEmployeeId());
if (dataCollectionEmployee != null) {
po.setDepartmentId(dataCollectionEmployee.getDepartmentId());
po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid());
po.setCostcenterId(dataCollectionEmployee.getCostcenterId());
po.setJobtitleId(dataCollectionEmployee.getJobtitleId());
po.setLocationId(dataCollectionEmployee.getLocationId());
}
needInsertResultReportList.add(po);
});
});
// 入库
getSalaryAcctResultService(user).batchSave(needInsertResultList);
getSalaryAcctReportService(user).lkszBatchSave(needInsertResultReportList);
}
}

View File

@ -62,6 +62,19 @@ public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctRe
}
}
@Override
public void lkszBatchSave(Collection<SalaryAcctResultReportPO> pos) {
if (CollectionUtils.isNotEmpty(pos)) {
SalarySysConfPO disPlay = getSalarySysConfService(user).getOneByCode(DISPLAY_EMP_INFO_REPORT);
//默认不显示关闭状态
if (disPlay == null || OpenEnum.OFF.getValue().equals(disPlay.getConfValue())) {
pos = encryptUtil.encryptList(new ArrayList<>(pos), SalaryAcctResultReportPO.class);
}
List<List<SalaryAcctResultReportPO>> partition = Lists.partition((List) pos, 100);
partition.forEach(getSalaryAcctResultReportMapper()::batchInsert);
}
}
@Override
public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
if (CollectionUtils.isNotEmpty(salaryAcctRecordIds)) {

View File

@ -159,6 +159,15 @@ public class SalaryAcctController {
return new ResponseResult<Long, String>(user).run(getSalaryAcctRecordWrapper(user)::backCalculate, param.getSalaryAcctRecordId());
}
// 结转
@GET
@Path("/lkszJz")
@Produces(MediaType.APPLICATION_JSON)
public String lkszJz(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, String>(user).run(getSalaryAcctRecordWrapper(user)::lkszJz, id);
}
/* ********************************薪资核算记录相关 end*********************************/

View File

@ -266,4 +266,8 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord
public void backCalculate(Long salaryAcctRecordId){
getSalaryAcctRecordService(user).backCalculate(salaryAcctRecordId);
}
public void lkszJz(Long id) {
getSalaryAcctRecordService(user).lkszJz(id);
}
}