限制薪资项目的删除

This commit is contained in:
钱涛 2022-03-30 20:27:17 +08:00
parent 93686e38c5
commit 4167cb55ee
9 changed files with 420 additions and 84 deletions

View File

@ -77,6 +77,7 @@ public class SalarySobAdjustRuleBO {
* @return
*/
public static List<SalarySobAdjustRulePO> convert2PO(SalarySobAdjustRuleSaveParam saveParam, Long employeeId) {
employeeId.toString();
if (CollectionUtils.isEmpty(saveParam.getRuleParams())) {
return Collections.emptyList();
}

View File

@ -0,0 +1,292 @@
package com.engine.salary.entity.salarysob.bo;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.salarysob.po.*;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 薪资账套复制
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@AllArgsConstructor
public class SalarySobDuplicateBO {
/**
* 薪资账套
*/
private SalarySobPO salarySob;
/**
* 薪资账套的员工信息字段
*/
private List<SalarySobEmpFieldPO> salarySobEmpFields;
/**
* 薪资账套的薪资项目副本
*/
private List<SalarySobItemPO> salarySobItems;
/**
* 薪资账套的薪资项目分类
*/
private List<SalarySobItemGroupPO> salarySobItemGroups;
/**
* 薪资账套的调薪计薪规则
*/
private List<SalarySobAdjustRulePO> salaryAdjustmentRules;
/**
* 薪资账套的校验规则
*/
private List<SalarySobCheckRulePO> salarySobCheckRules;
/**
* 复制
*
* @param employeeId
* @return
*/
public Result duplicate( Long employeeId) {
Result result = new Result();
// 复制基础设置
duplicateBase(result, salarySob, employeeId);
// 复制员工信息字段
duplicateEmpField(result, salarySobEmpFields, employeeId);
// 复制薪资项目分类
Map<Long, Long> groupIdMap = duplicateSalarySobItemGroup(result, salarySobItemGroups, employeeId);
// 复制薪资项目副本
duplicateSalarySobItem(result, salarySobItems, groupIdMap, employeeId);
// 复制调薪计薪规则
duplicateSalaryAdjustmentRule(result, salaryAdjustmentRules, employeeId);
// 复制校验规则
duplicateSalarySobCheckRule(result, salarySobCheckRules, employeeId);
duplicateEmpField(result, salarySobEmpFields, employeeId);
return result;
}
/**
* 复制薪资账套的基础设置
*
* @param salarySobPO 薪资账套po
* @param employeeId 人员id
* @return
*/
private void duplicateBase(Result result, SalarySobPO salarySobPO, Long employeeId) {
Date now = new Date();
result.setSalarySob(salarySobPO);
}
/**
* 复制员工信息字段
*
* @param result
* @param salarySobEmpFieldPOS
* @param employeeId
*/
private void duplicateEmpField(Result result, List<SalarySobEmpFieldPO> salarySobEmpFieldPOS, Long employeeId) {
if (CollectionUtils.isEmpty(salarySobEmpFieldPOS)) {
return;
}
Date now = new Date();
List<SalarySobEmpFieldPO> newSalarySobEmpFieldPOS = salarySobEmpFieldPOS.stream()
.map(salarySobEmpFieldPO -> new SalarySobEmpFieldPO()
// .setId(IdGenerator.generate())
.setSalarySobId(result.getSalarySob().getId())
.setFieldCode(salarySobEmpFieldPO.getFieldCode())
.setSortedIndex(salarySobEmpFieldPO.getSortedIndex())
.setCanDelete(salarySobEmpFieldPO.getCanDelete())
.setCreator(employeeId)
.setCreateTime(now)
.setUpdateTime(now)
.setDeleteType(NumberUtils.INTEGER_ZERO)
.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
).collect(Collectors.toList());
result.setSalarySobEmpFields(newSalarySobEmpFieldPOS);
}
/**
* 复制薪资项目分组
*
* @param result 结果集
* @param salarySobItemGroups 薪资项目分类po
* @param employeeId 人员id
租户key
* @return
*/
private Map<Long, Long> duplicateSalarySobItemGroup(Result result, List<SalarySobItemGroupPO> salarySobItemGroups, Long employeeId) {
Date now = new Date();
if (CollectionUtils.isEmpty(salarySobItemGroups)) {
return Collections.emptyMap();
}
Map<Long, Long> oldIdKeyNewIdValueMap = Maps.newHashMapWithExpectedSize(salarySobItemGroups.size());
List<SalarySobItemGroupPO> newSalarySobItemGroups = Lists.newArrayListWithExpectedSize(salarySobItemGroups.size());
for (SalarySobItemGroupPO salarySobItemGroup : salarySobItemGroups) {
SalarySobItemGroupPO newSalarySobItemGroup = SalarySobItemGroupPO.builder()
// .id(IdGenerator.generate())
.name(salarySobItemGroup.getName())
.salarySobId(result.getSalarySob().getId())
.sortedIndex(salarySobItemGroup.getSortedIndex())
.description(salarySobItemGroup.getDescription())
.creator(employeeId)
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(NumberUtils.INTEGER_ZERO)
.build();
newSalarySobItemGroups.add(newSalarySobItemGroup);
oldIdKeyNewIdValueMap.put(salarySobItemGroup.getId(), newSalarySobItemGroup.getId());
}
result.setSalarySobItemGroups(newSalarySobItemGroups);
return oldIdKeyNewIdValueMap;
}
/**
* 复制薪资账套的薪资项目副本
*
* @param salarySobItems 薪资项目副本po
* @param employeeId 人员id
租户key
* @return
*/
private void duplicateSalarySobItem(Result result, List<SalarySobItemPO> salarySobItems, Map<Long, Long> groupIdMap, Long employeeId) {
Date now = new Date();
if (CollectionUtils.isEmpty(salarySobItems)) {
return;
}
List<SalarySobItemPO> newSalarySobItems = Lists.newArrayListWithExpectedSize(salarySobItems.size());
for (SalarySobItemPO salarySobItem : salarySobItems) {
SalarySobItemPO newSalarySobItem = SalarySobItemPO.builder()
// .id(IdGenerator.generate())
.salarySobId(result.getSalarySob().getId())
.salarySobItemGroupId(groupIdMap.getOrDefault(salarySobItem.getSalarySobItemGroupId(), NumberUtils.LONG_ZERO))
.salaryItemId(salarySobItem.getSalaryItemId())
.formulaId(salarySobItem.getFormulaId())
.sortedIndex(salarySobItem.getSortedIndex())
.description(salarySobItem.getDescription())
.canDelete(salarySobItem.getCanDelete())
.creator(employeeId)
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(NumberUtils.INTEGER_ZERO)
.build();
newSalarySobItems.add(newSalarySobItem);
}
result.setSalarySobItems(newSalarySobItems);
}
/**
* 复制调薪计薪规则
*
* @param result 结果集
* @param salaryAdjustmentRules 调薪计薪规则po
* @param employeeId 人员id
租户key
*/
private void duplicateSalaryAdjustmentRule(Result result, List<SalarySobAdjustRulePO> salaryAdjustmentRules, Long employeeId) {
Date now = new Date();
if (CollectionUtils.isEmpty(salaryAdjustmentRules)) {
return;
}
List<SalarySobAdjustRulePO> newSalaryAdjustmentRules = Lists.newArrayListWithExpectedSize(salaryAdjustmentRules.size());
for (SalarySobAdjustRulePO salaryAdjustmentRule : salaryAdjustmentRules) {
SalarySobAdjustRulePO newSalaryAdjustmentRule = new SalarySobAdjustRulePO()
// .setId(IdGenerator.generate())
.setSalarySobId(result.getSalarySob().getId())
.setSalaryItemId(salaryAdjustmentRule.getSalaryItemId())
.setDayOfMonth(salaryAdjustmentRule.getDayOfMonth())
.setBeforeAdjustmentType(salaryAdjustmentRule.getBeforeAdjustmentType())
.setAfterAdjustmentType(salaryAdjustmentRule.getAfterAdjustmentType())
.setCreator(employeeId)
.setCreateTime(now)
.setUpdateTime(now)
.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.setDeleteType(NumberUtils.INTEGER_ZERO);
newSalaryAdjustmentRules.add(newSalaryAdjustmentRule);
}
result.setSalaryAdjustmentRules(newSalaryAdjustmentRules);
}
/**
* 复制校验规则
*
* @param result 结果集
* @param salarySobCheckRules 校验规则po
* @param employeeId 人员id
租户key
* @return
*/
private void duplicateSalarySobCheckRule(Result result, List<SalarySobCheckRulePO> salarySobCheckRules, Long employeeId) {
if (CollectionUtils.isEmpty(salarySobCheckRules)) {
return;
}
Date now = new Date();
List<SalarySobCheckRulePO> newSalarySobCheckRules = salarySobCheckRules.stream()
.map(e -> SalarySobCheckRulePO.builder()
// .id(IdGenerator.generate())
.salarySobId(result.getSalarySob().getId())
.name(e.getName())
.formulaId(e.getFormulaId())
.description(e.getDescription())
.creator(employeeId)
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(0)
.build())
.collect(Collectors.toList());
result.setSalarySobCheckRules(newSalarySobCheckRules);
}
@Data
public static class Result {
/**
* 薪资账套
*/
private SalarySobPO salarySob;
/**
* 员工信息字段
*/
private List<SalarySobEmpFieldPO> salarySobEmpFields;
/**
* 薪资项目副本
*/
private List<SalarySobItemPO> salarySobItems;
/**
* 薪资项目分类
*/
private List<SalarySobItemGroupPO> salarySobItemGroups;
/**
* 调薪计薪规则
*/
private List<SalarySobAdjustRulePO> salaryAdjustmentRules;
/**
* 校验规则
*/
private List<SalarySobCheckRulePO> salarySobCheckRules;
}
}

View File

@ -1,10 +1,11 @@
package com.engine.salary.exception;
import lombok.extern.slf4j.Slf4j;
public class SalaryRunTimeException extends RuntimeException {
public SalaryRunTimeException(String message) {
super(message);
}
public SalaryRunTimeException(Throwable cause) {
super(cause);
}
}

View File

@ -9,6 +9,7 @@
//import com.engine.salary.entity.salaryarchive.bo.SalaryArchiveBO;
//import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
//import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportDTO;
//import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportSameDTO;
//import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
//import com.engine.salary.entity.salaryarchive.param.*;
//import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO;
@ -37,13 +38,13 @@
//import org.apache.commons.lang3.StringUtils;
//import org.apache.poi.ss.usermodel.Sheet;
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//import weaver.file.ExcelSheet;
//import weaver.file.ImageFileManager;
//
//import java.io.InputStream;
//import java.text.SimpleDateFormat;
//import java.util.*;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.atomic.AtomicInteger;
//import java.util.stream.Collectors;
//
//import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
@ -489,8 +490,6 @@
// // 4.数据入库处理
// handleImportData(isInit, importHandleParam);
//
// // 发送导入回调信息
// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets);
// }
//
// /**
@ -550,8 +549,6 @@
// * @param successCount
// * @param errorData
// * @param initImportData
// * @param currentEmployeeId
// * @param tenantKey
// * @param importHandleParam
// */
// private Map<String, Object> validInitImportData(boolean isError, int rowNo, Map<String, Object> map, List<ExcelComment> excelComments, int errorCount, int successCount, List<Map<String, Object>> errorData, List<SalaryArchiveInitImportDTO> initImportData, SalaryArchiveImportHandleParam importHandleParam) {

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalaryItemBiz;
import com.engine.salary.biz.SysSalaryItemBiz;
@ -8,15 +9,18 @@ import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.enums.SalarySystemTypeEnum;
import com.engine.salary.enums.SalaryValueTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.SalaryItemService;
import com.engine.salary.service.SalarySobItemService;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import weaver.hrm.User;
import java.util.*;
@ -31,8 +35,12 @@ import java.util.*;
public class SalaryItemServiceImpl extends Service implements SalaryItemService {
private SalaryItemBiz salaryItemBiz = new SalaryItemBiz();
// @Autowired
// private SalarySobItemService salarySobItemService;
private SalarySobItemService getSalarySobItemService(User user) {
return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user);
}
private SysSalaryItemBiz sysSalaryItemBiz = new SysSalaryItemBiz();
// @Autowired
// private LoggerTemplate salaryItemLoggerTemplate;
@ -180,11 +188,10 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
if (CollectionUtils.isEmpty(salaryItemPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "参数错误,薪资项目不存在或已被删除"));
}
// todo 查询薪资账套的薪资项目副本被薪资账套引用的薪资项目不允许删除
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalaryItemIds(ids, tenantKey);
// if (CollectionUtils.isNotEmpty(salarySobItemPOS)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98322, "薪资账套正在使用该薪资项目,不允许删除"));
// }
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalaryItemIds(ids);
if (CollectionUtils.isNotEmpty(salarySobItemPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98322, "薪资账套正在使用该薪资项目,不允许删除"));
}
// 删除薪资项目
ids = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getId);
salaryItemBiz.deleteByIds(ids);

View File

@ -7,12 +7,15 @@ import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam;
import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobAdjustRuleMapper;
import com.engine.salary.mapper.salarysob.SalarySobMapper;
import com.engine.salary.service.SalarySobAdjustRuleService;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.SalarySqlProxyHandle;
import com.engine.salary.util.valid.ValidUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
import java.util.Collection;
import java.util.Collections;
@ -29,8 +32,6 @@ import java.util.Objects;
**/
public class SalarySobAdjustRuleServiceImpl extends Service implements SalarySobAdjustRuleService {
SalarySobMapper salarySobMapper = SalarySqlProxyHandle.getProxy(SalarySobMapper.class);
private SalarySobAdjustRuleBiz salarySobAdjustRuleMapper = new SalarySobAdjustRuleBiz();
// private LoggerTemplate salarySobLoggerTemplate;
@ -50,20 +51,26 @@ public class SalarySobAdjustRuleServiceImpl extends Service implements SalarySob
ValidUtil.doValidator(saveParam);
// 查询薪资账套
SalarySobPO salarySobPO = salarySobMapper.getById(saveParam.getSalarySobId());
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
}
// 删除之前的调薪计薪规则
salarySobAdjustRuleMapper.deleteBySalarySobIds(Collections.singleton(saveParam.getSalarySobId()));
// 保存参数转换成薪资账套的调薪计薪规则po
List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = SalarySobAdjustRuleBO.convert2PO(saveParam, (long) user.getUID());
// 保存
if (CollectionUtils.isNotEmpty(salarySobAdjustRulePOS)) {
salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS);
}
// 记录日志
//开启事务
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalarySobMapper salarySobMapper = SalarySqlProxyHandle.getProxy(SalarySobMapper.class, sqlSession);
// 查询薪资账套
SalarySobPO salarySobPO = salarySobMapper.getById(saveParam.getSalarySobId());
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
}
// 删除之前的调薪计薪规则
SalarySobAdjustRuleMapper salarySobAdjustRuleMapper = SalarySqlProxyHandle.getProxy(SalarySobAdjustRuleMapper.class, sqlSession);
salarySobAdjustRuleMapper.deleteBySalarySobIds(Collections.singleton(saveParam.getSalarySobId()));
// 保存参数转换成薪资账套的调薪计薪规则po
List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = SalarySobAdjustRuleBO.convert2PO(saveParam, null);
// 保存
if (CollectionUtils.isNotEmpty(salarySobAdjustRulePOS)) {
salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS);
}
// 记录日志
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(salarySobPO.getId()));
// loggerContext.setTargetName(salarySobPO.getName());
@ -71,6 +78,13 @@ public class SalarySobAdjustRuleServiceImpl extends Service implements SalarySob
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98614, "保存调薪计薪规则"));
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98614, "保存调薪计薪规则"));
// salarySobLoggerTemplate.write(loggerContext);
} catch (Exception e) {
sqlSession.rollback();
throw new SalaryRunTimeException(e);
}finally {
sqlSession.commit();
sqlSession.close();
}
}
@Override

View File

@ -9,6 +9,7 @@ import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
import com.engine.salary.entity.salarysob.bo.SalarySobBO;
import com.engine.salary.entity.salarysob.bo.SalarySobCycleBO;
import com.engine.salary.entity.salarysob.bo.SalarySobDuplicateBO;
import com.engine.salary.entity.salarysob.bo.SalarySobItemBO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.param.SalarySobBasicSaveParam;
@ -18,7 +19,10 @@ import com.engine.salary.entity.salarysob.po.*;
import com.engine.salary.enums.SalarySystemTypeEnum;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.*;
import com.engine.salary.service.SalaryItemService;
import com.engine.salary.service.SalarySobCheckRuleService;
import com.engine.salary.service.SalarySobService;
import com.engine.salary.service.SysSalaryItemService;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.valid.RuntimeTypeEnum;
@ -63,10 +67,11 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
private SysSalaryItemService getSysSalaryItemService(User user) {
return (SysSalaryItemService) ServiceUtil.getService(SysSalaryItemServiceImpl.class, user);
}
//
// private SalarySobAdjustRuleService salarySobAdjustRuleService;
//
// private SalarySobCheckRuleService salarySobCheckRuleService;
private SalarySobAdjustRuleBiz salarySobAdjustRuleService = new SalarySobAdjustRuleBiz();
private SalarySobCheckRuleService getSalarySobCheckRuleService(User user) {
return (SalarySobCheckRuleService) ServiceUtil.getService(SalarySobCheckRuleServiceImpl.class, user);
}
//
// private LoggerTemplate salarySobLoggerTemplate;
//
@ -311,9 +316,9 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
// 删除薪资账套的薪资项目分类
salarySobItemGroupService.deleteBySalarySobIds(ids);
// 删除薪资账套的调薪计薪规则
// salarySobAdjustRuleService.deleteBySalarySobIds(ids, tenantKey);
salarySobAdjustRuleService.deleteBySalarySobIds(ids);
// // 删除薪资账套的校验规则
// salarySobCheckRuleService.deleteBySalarySobIds(ids, tenantKey);
getSalarySobCheckRuleService(user).deleteBySalarySobIds(ids);
// // 记录日志
// salarySobPOS.forEach(salarySobPO -> {
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
@ -339,43 +344,60 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
if (CollectionUtils.isNotEmpty(salarySobPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在"));
}
// // 查询薪资账套的员工信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(duplicateParam.getId());
// // 查询薪资账套的薪资项目副本
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(duplicateParam.getId());
// // 查询薪资账套的薪资项目分类
// List<SalarySobItemGroupPO> salarySobItemGroupPOS = salarySobItemGroupService.listBySalarySobId(duplicateParam.getId());
// // 查询薪资账套的调薪计薪规则
// List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(duplicateParam.getId());
// // 查询薪资账套的校验规则
// List<SalarySobCheckRulePO> salarySobCheckRulePOS = salarySobCheckRuleService.listBySalarySobId(duplicateParam.getId());
// 查询薪资账套的员工信息字段
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listSome(SalarySobEmpFieldPO.builder().salarySobId(duplicateParam.getId()).build());
// 查询薪资账套的薪资项目副本
List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listSome(SalarySobItemPO.builder().salarySobId(duplicateParam.getId()).build());
// 查询薪资账套的薪资项目分类
List<SalarySobItemGroupPO> salarySobItemGroupPOS = salarySobItemGroupService.listSome(SalarySobItemGroupPO.builder().salarySobId(duplicateParam.getId()).build());
// 查询薪资账套的调薪计薪规则
List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(duplicateParam.getId());
// 查询薪资账套的校验规则
List<SalarySobCheckRulePO> salarySobCheckRulePOS = getSalarySobCheckRuleService(user).listBySalarySobId(duplicateParam.getId());
// // 复制
// SalarySobDuplicateBO salarySobDuplicateBO = new SalarySobDuplicateBO(salarySobPO, salarySobEmpFieldPOS, salarySobItemPOS,
// salarySobItemGroupPOS, salarySobAdjustRulePOS, salarySobCheckRulePOS);
// SalarySobDuplicateBO.Result result = salarySobDuplicateBO.duplicate(duplicateParam.getName(), employeeId, tenantKey);
// // 复制薪资账套的基础设置
// salarySobMapper.insert(result.getSalarySob());
// // 复制薪资账套的员工信息字段
// if (CollectionUtils.isNotEmpty(result.getSalarySobEmpFields())) {
// salarySobEmpFieldService.batchSave(result.getSalarySobEmpFields());
// }
// // 复制薪资账套的薪资项目副本
// if (CollectionUtils.isNotEmpty(result.getSalarySobItems())) {
// salarySobItemService.batchSave(result.getSalarySobItems());
// }
// // 复制薪资账套的薪资项目分类
// if (CollectionUtils.isNotEmpty(result.getSalarySobItemGroups())) {
// salarySobItemGroupService.batchSave(result.getSalarySobItemGroups());
// }
// // 复制薪资账套的调薪计薪规则
// if (CollectionUtils.isNotEmpty(result.getSalaryAdjustmentRules())) {
// salarySobAdjustRuleService.batchSave(result.getSalaryAdjustmentRules());
// }
// // 复制薪资账套的校验规则
// if (CollectionUtils.isNotEmpty(result.getSalarySobCheckRules())) {
// salarySobCheckRuleService.batchSave(result.getSalarySobCheckRules());
// }
// 复制薪资账套的基础设置
SalarySobPO newSalarySob = SalarySobPO.builder()
.name(duplicateParam.getName())
.incomeCategory(salarySobPO.getIncomeCategory())
.salaryCycleType(salarySobPO.getSalaryCycleType())
.salaryCycleFromDay(salarySobPO.getSalaryCycleFromDay())
.taxCycleType(salarySobPO.getTaxCycleType())
.attendCycleType(salarySobPO.getAttendCycleType())
.attendCycleFromDay(salarySobPO.getAttendCycleFromDay())
.socialSecurityCycleType(salarySobPO.getSocialSecurityCycleType())
.disable(salarySobPO.getDisable())
.creator((long)user.getUID())
.createTime(new Date())
.updateTime(new Date())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(NumberUtils.INTEGER_ZERO)
.build();
salarySobMapper.insert(newSalarySob);
// 复制
SalarySobDuplicateBO salarySobDuplicateBO = new SalarySobDuplicateBO(newSalarySob, salarySobEmpFieldPOS, salarySobItemPOS,
salarySobItemGroupPOS, salarySobAdjustRulePOS, salarySobCheckRulePOS);
SalarySobDuplicateBO.Result result = salarySobDuplicateBO.duplicate((long)user.getUID());
// 复制薪资账套的员工信息字段
if (CollectionUtils.isNotEmpty(result.getSalarySobEmpFields())) {
salarySobEmpFieldService.batchInsert(result.getSalarySobEmpFields());
}
// 复制薪资账套的薪资项目副本
if (CollectionUtils.isNotEmpty(result.getSalarySobItems())) {
salarySobItemService.batchInsert(result.getSalarySobItems());
}
// 复制薪资账套的薪资项目分类
if (CollectionUtils.isNotEmpty(result.getSalarySobItemGroups())) {
salarySobItemGroupService.batchInsert(result.getSalarySobItemGroups());
}
// 复制薪资账套的调薪计薪规则
if (CollectionUtils.isNotEmpty(result.getSalaryAdjustmentRules())) {
salarySobAdjustRuleService.batchInsert(result.getSalaryAdjustmentRules());
}
// 复制薪资账套的校验规则
if (CollectionUtils.isNotEmpty(result.getSalarySobCheckRules())) {
getSalarySobCheckRuleService(user).batchSave(result.getSalarySobCheckRules());
}
// // 记录日志
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId("" + result.getSalarySob().getId());

View File

@ -9,7 +9,7 @@ import java.lang.reflect.Proxy;
public class SalarySqlProxyHandle<T> implements InvocationHandler {
private Class clazz;
private boolean isAutoCommit = true;
private boolean enableTransactions = false;
private SqlSession session;
public SalarySqlProxyHandle() {
@ -19,14 +19,14 @@ public class SalarySqlProxyHandle<T> implements InvocationHandler {
this.clazz = clazz;
}
public SalarySqlProxyHandle(Class clazz, boolean isAutoCommit) {
public SalarySqlProxyHandle(Class clazz, boolean enableTransactions) {
this.clazz = clazz;
this.isAutoCommit = isAutoCommit;
this.enableTransactions = enableTransactions;
}
public SalarySqlProxyHandle(Class clazz, boolean isAutoCommit, SqlSession session) {
public SalarySqlProxyHandle(Class clazz, boolean enableTransactions, SqlSession session) {
this.clazz = clazz;
this.isAutoCommit = isAutoCommit;
this.enableTransactions = enableTransactions;
this.session = session;
}
@ -38,12 +38,14 @@ public class SalarySqlProxyHandle<T> implements InvocationHandler {
try {
Object target = session.getMapper(clazz);
Object invoke = method.invoke(target, args);
if (isAutoCommit) {
if (!enableTransactions) {
session.commit();
}
return invoke;
} finally {
session.close();
if (!enableTransactions) {
session.close();
}
}
}
@ -74,8 +76,8 @@ public class SalarySqlProxyHandle<T> implements InvocationHandler {
return (T) handle.getProxy();
}
public static <T> T getProxy(Class<T> clazz, boolean isAutoSubmit) {
SalarySqlProxyHandle handle = new SalarySqlProxyHandle(clazz, isAutoSubmit);
public static <T> T getProxy(Class<T> clazz, SqlSession sqlSession) {
SalarySqlProxyHandle handle = new SalarySqlProxyHandle(clazz, true, sqlSession);
return (T) handle.getProxy();
}
}

View File

@ -44,8 +44,8 @@ import java.util.stream.Collectors;
public class SalaryArchiveWrapper extends Service {
private SalaryArchiveService getSalaryArchiveService(User user) {
return null;
// return (SalaryArchiveService) ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
return null;
}
private SalaryArchiveItemService getSalaryArchiveItemService(User user) {