Merge branch 'release/2.16.1.2410.01' into release/个税版本

# Conflicts:
#	src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java
This commit is contained in:
钱涛 2024-10-18 11:08:18 +08:00
commit 517d1e8d0b
25 changed files with 257 additions and 157 deletions

View File

@ -1,5 +1,5 @@
log=false
defaultCloseNonStandard149=true
AESEncryptScrect=990EB004A1C862721C1513AE90038C9E
version=2.15.2.2409.01
version=2.16.1.2410.01
openFormulaForcedEditing=false

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_acct_emp add lock_items varchar2(4000) NULL;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_acct_emp add lock_items varchar2(4000) NULL;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_acct_emp add lock_items varchar2(4000) NULL;
/

View File

@ -0,0 +1 @@
ALTER TABLE hrsa_salary_acct_emp ADD COLUMN lock_items varchar(4000);

View File

@ -0,0 +1,2 @@
alter table hrsa_salary_acct_emp add lock_items varchar2(4000) NULL
/

View File

@ -0,0 +1 @@
alter table hrsa_salary_acct_emp add lock_items varchar(4000);

View File

@ -0,0 +1,2 @@
ALTER TABLE hrsa_salary_acct_emp ADD lock_items varchar(4000)
GO

View File

@ -0,0 +1,3 @@
alter table hrsa_salary_acct_emp add lock_items varchar2(4000) NULL;
/

View File

@ -4,7 +4,6 @@ import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
import com.engine.salary.entity.datacollection.po.VariableItemPO;
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.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
@ -49,13 +48,6 @@ public class SalaryAcctCalculateBO {
*/
private SalarySobCycleDTO salarySobCycleDTO;
/**
* 核算锁定值
*/
private Map<String, SalaryAcctResultPO> salaryAcctLockResultPOS;
private List<Long> lockSalaryItemIds;
/**
* 相同税款所属期内其他薪资核算记录薪资类型为工资薪金的账套的
*/

View File

@ -316,8 +316,8 @@ public class SalaryAcctResultBO {
}
// 主键id
map.put("id", e.getId());
//锁定状态
map.put("lockStatus", LockStatusEnum.getByValue(e.getLockStatus()).getDefaultLabel());
//锁定数据
map.put("lockItems", e.getLockItems() != null ? e.getLockItems().stream().filter(Objects::nonNull).map(Object::toString).collect(Collectors.toList()) : new ArrayList<>());
//人员id
map.put("employeeId", e.getEmployeeId());
// 个税扣缴义务人

View File

@ -0,0 +1,34 @@
package com.engine.salary.entity.salaryacct.param;
import com.engine.salary.enums.salaryaccounting.LockStatusEnum;
import com.engine.salary.util.valid.DataCheck;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 薪资数据单元格锁定
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SalaryAcctResultLockParam {
//锁定状态
@DataCheck(require = true,message = "锁定状态不能为空")
private LockStatusEnum lockStatus;
//薪资核算人员Id
@DataCheck(require = true,message = "薪资核算人员不能为空")
private Long acctEmpId;
//薪资项目的Id
@DataCheck(require = true,message = "薪资项目不能为空")
private Long salaryItemId;
}

View File

@ -12,6 +12,7 @@ import lombok.experimental.Accessors;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/**
* 薪资核算人员
@ -121,6 +122,7 @@ public class SalaryAcctEmployeePO {
private Date updateTime;
@Deprecated
@ElogTransform(name = "锁定状态")
private Integer lockStatus;
@ -153,6 +155,9 @@ public class SalaryAcctEmployeePO {
*/
private String status;
//锁定的项目
private List<Long> lockItems;
//--------条件----------
//主键id集合

View File

@ -131,6 +131,7 @@ public class SalaryAcctRecordPO {
/**
* 锁定的薪资项目
*/
@Deprecated
private List<Long> lockSalaryItemIds;
//查询条件-------------------------------

View File

@ -268,8 +268,11 @@ public class SalaryAcctManager extends Service {
// 7查询考勤引用的所有字段
List<AttendQuoteFieldListDTO> attendQuoteFieldListDTOS = getAttendQuoteFieldService(user).listAll();
// //核算锁定值
// List<Long> lockSalaryItemIds = salaryAcctRecordPO.getLockSalaryItemIds();
//fixme 先全部锁定
// //将除重新核算的项目外的所有的值都锁定
// List<Long> salaryItemIds = calculateParam.getSalaryItemIds();
// List<Long> lockSalaryItemIds = salaryItemPOS.stream().map(SalaryItemPO::getId).filter(id -> !salaryItemIds.contains(id)).collect(Collectors.toList());
// Map<String, SalaryAcctResultPO> acctResults = new HashMap<>();
// if (CollectionUtils.isNotEmpty(lockSalaryItemIds)) {
// List<SalaryAcctResultPO> acctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
@ -280,19 +283,6 @@ public class SalaryAcctManager extends Service {
// .collect(Collectors.toMap(po -> po.getSalaryItemId() + "_" + po.getSalaryAcctEmpId(), a -> a, (a, b) -> a));
// }
//将除重新核算的项目外的所有的值都锁定
List<Long> salaryItemIds = calculateParam.getSalaryItemIds();
List<Long> lockSalaryItemIds = salaryItemPOS.stream().map(SalaryItemPO::getId).filter(id -> !salaryItemIds.contains(id)).collect(Collectors.toList());
Map<String, SalaryAcctResultPO> acctResults = new HashMap<>();
if (CollectionUtils.isNotEmpty(lockSalaryItemIds)) {
List<SalaryAcctResultPO> acctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
acctResults = Optional.ofNullable(acctResultPOS)
.orElse(new ArrayList<>())
.stream()
.filter(po -> lockSalaryItemIds.contains(po.getSalaryItemId()))
.collect(Collectors.toMap(po -> po.getSalaryItemId() + "_" + po.getSalaryAcctEmpId(), a -> a, (a, b) -> a));
}
// 8查询公式详情
Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
@ -331,8 +321,6 @@ public class SalaryAcctManager extends Service {
.setSalarySobPO(salarySobPO)
.setSalarySobCycleDTO(salarySobCycleDTO)
.setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS)
.setSalaryAcctLockResultPOS(MapUtils.emptyIfNull(acctResults))
.setLockSalaryItemIds(lockSalaryItemIds)
.setSalarySobItemPOS(salarySobItemPOS)
.setSalaryItemIdWithPriorityList(salarySobItemsWithPriority)
.setExpressFormulas(expressFormulas)

View File

@ -130,4 +130,6 @@ public interface SalaryAcctEmployeeMapper {
int countNotDeclareByParam(@Param("param") AbnormalEmployeeListQueryParam queryParam);
void updateIgnoreNull(@Param("salaryAcctEmployeePO")SalaryAcctEmployeePO salaryAcctEmployeePO);
void lock(SalaryAcctEmployeePO salaryAcctEmployeePO);
}

View File

@ -25,6 +25,7 @@
<result column="jobcall" property="jobcall"/>
<result column="jobcall_id" property="jobcallId"/>
<result column="status" property="status"/>
<result column="lock_items" property="lockItems" typeHandler="com.engine.salary.handle.SalaryListTypeHandler"/>
</resultMap>
<resultMap id="SalaryAccEmployeeCountMap"
@ -58,7 +59,8 @@
t.jobtitle_id,
t.jobcall,
t.jobcall_id,
t.status
t.status,
t.lock_items
</sql>
<sql id="emp1Column">
@ -967,6 +969,7 @@
<result column="jobcall" property="jobcall"/>
<result column="jobcall_id" property="jobcallId"/>
<result column="status" property="status"/>
<result column="lock_items" property="lockItems" typeHandler="com.engine.salary.handle.SalaryListTypeHandler"/>
</resultMap>
<!-- 表字段 -->
@ -995,6 +998,7 @@
, t.jobcall
, t.jobcall_id
, t.status
, t.lock_items
</sql>
@ -1214,4 +1218,13 @@
WHERE id = #{salaryAcctEmployeePO.id} AND delete_type = 0
</update>
<update id="lock" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO">
UPDATE hrsa_salary_acct_emp
<set>
lock_items =
#{lockItems, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
</mapper>

View File

@ -280,4 +280,6 @@ public interface SalaryAcctEmployeeService {
* @param salaryAcctEmployeePO
*/
void updateIgnoreNull(SalaryAcctEmployeePO salaryAcctEmployeePO);
void lock(SalaryAcctEmployeePO salaryAcctEmployeePO);
}

View File

@ -167,6 +167,13 @@ public interface SalaryAcctResultService {
*/
List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndTaxAgentIds(Collection<Long> salaryAcctRecordIds, Collection<Long> taxAgentIds);
/**
* 锁定单元格
* @param param
*/
void lock(SalaryAcctResultLockParam param);
/**
* 锁定项目
*

View File

@ -31,7 +31,6 @@ import com.engine.salary.util.SalaryEntityUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.util.StopWatch;
@ -162,6 +161,7 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
sw.start("查询薪资核算人员的薪资核算结果");
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList());
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
Map<String, String> empItemValueMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOS, p -> p.getSalaryAcctEmpId() + "_" + p.getSalaryItemId(), SalaryAcctResultPO::getResultValue);
sw.stop();
// 查询浮动薪资
sw.start("查询浮动薪资");
@ -174,8 +174,6 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
for (Map.Entry<String, List<SalaryAcctResultPO>> et : collect.entrySet()) {
salaryAcctResultPOMap.put(et.getKey(), et.getValue().get(0).getOriginResultValue());
}
//核算锁定的值
Map<String, SalaryAcctResultPO> salaryAcctLockResultPOS = MapUtils.emptyIfNull(salaryAcctCalculateBO.getSalaryAcctLockResultPOS());
sw.stop();
// 9查询相同税款所属期内涉及合并计税的其他薪资核算结果
sw.start("查询相同税款所属期内涉及合并计税的其他薪资核算结果");
@ -213,6 +211,7 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
StringBuffer noticeMsg = new StringBuffer();
for (SalaryAcctEmployeePO salaryAcctEmployeePO : salaryAcctCalculateBO.getSalaryAcctEmployeePOS()) {
Long salaryAcctEmployeePOId = salaryAcctEmployeePO.getId();
List<Long> lockItems = salaryAcctEmployeePO.getLockItems();
//1 获取当前薪资核算人员的公式中的变量的值
List<CalculateFormulaVarBO.FormulaVarValue> formulaVarValues = formulaVarMap.get(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId());
//2 人员信息
@ -282,8 +281,8 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
// 处理小数点
resultValue = SalaryAcctFormulaBO.roundResultValue(resultValue, salaryItemPO, salarySobBackItems, salarySobBackItemMap, salaryItemIdKeySalarySobItemPOMap);
//是否锁定
if (salaryAcctLockResultPOS.get(salaryItemId + "_" + salaryAcctEmployeePOId) != null) {
resultValue = salaryAcctLockResultPOS.get(salaryItemId + "_" + salaryAcctEmployeePOId).getResultValue();
if (lockItems != null && lockItems.contains(salaryItemId)) {
resultValue = empItemValueMap.get(salaryAcctEmployeePOId + "_" + salaryItemId);
}
// 将已经计算过的薪资项目的值转换成公式变量的值添加到集合中
String key = SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItemPO.getCode();

View File

@ -9,6 +9,7 @@ import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
import com.engine.salary.entity.salaryacct.dto.AbnormalEmployeeListDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
@ -17,6 +18,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
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.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.OperateTypeEnum;
@ -109,6 +111,11 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
return ServiceUtil.getService(SalaryCacheServiceImpl.class, user);
}
private SalaryAcctSobConfigService getSalaryAcctSobConfigService(User user) {
return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user);
}
private boolean isRealOrg = "1".equals(getSalaryCacheService(user).get(REPORT_ORGANIZATIN_TYPE));
@Override
@ -701,7 +708,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
if (isRealOrg) {
employeeList = employeeList.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyid())).collect(Collectors.toList());
} else {
list.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyId())).collect(Collectors.toList());
list = list.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyId())).collect(Collectors.toList());
}
}
@ -775,12 +782,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
@Override
public void lockEmp(SalaryAcctResultUpdateLockStatusParam updateParam) {
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(updateParam.getSalaryAcctRecordId());
if (CollectionUtils.isEmpty(salaryAcctRecord.getLockSalaryItemIds())) {
salaryAcctRecord.setLockSalaryItemIds(new ArrayList<>());
}
List<SalaryAcctEmployeePO> salaryAcctEmployees = listBySalaryAcctRecordId(updateParam.getSalaryAcctRecordId());
List<SalaryAcctEmployeePO> salaryAcctEmployees = listByIds(updateParam.getAcctEmpIds());
if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
return;
}
@ -790,13 +792,20 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
throw new SalaryRunTimeException("锁定状态异常!");
}
Set<Long> acctEmpIds = updateParam.getAcctEmpIds();
if (CollUtil.isNotEmpty(acctEmpIds)) {
//锁定指定人员
getSalaryAcctEmployeeMapper().lockByAcctEmpIds(lockStatus.getValue(), acctEmpIds);
} else {
//锁定全部
getSalaryAcctEmployeeMapper().lockByRecordId(lockStatus.getValue(), updateParam.getSalaryAcctRecordId());
if (updateParam.getLockStatus() == LockStatusEnum.LOCK){
SalaryAcctConfig salaryAcctSobConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(updateParam.getSalaryAcctRecordId());
List<SalarySobItemPO> salarySobItems = salaryAcctSobConfig.getSalarySobItems();
List<Long> itemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId,Collectors.toList());
salaryAcctEmployees.forEach(salaryAcctEmployeePO -> {
salaryAcctEmployeePO.setLockItems(itemIds);
lock(salaryAcctEmployeePO);
});
}else {
salaryAcctEmployees.forEach(salaryAcctEmployeePO -> {
salaryAcctEmployeePO.setLockItems(new ArrayList<>());
lock(salaryAcctEmployeePO);
});
}
}
@ -830,4 +839,9 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
public void updateIgnoreNull(SalaryAcctEmployeePO salaryAcctEmployeePO) {
getSalaryAcctEmployeeMapper().updateIgnoreNull(salaryAcctEmployeePO);
}
@Override
public void lock(SalaryAcctEmployeePO salaryAcctEmployeePO) {
getSalaryAcctEmployeeMapper().lock(salaryAcctEmployeePO);
}
}

View File

@ -58,11 +58,9 @@ import com.engine.salary.wrapper.SalarySobItemWrapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.wbi.util.Util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
@ -70,7 +68,7 @@ import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StopWatch;
import weaver.file.ImageFileManager;
import weaver.hrm.User;
@ -1036,6 +1034,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
}
private Map<String, Object> batchImport(SalaryAcctImportParam param, String importType) {
StopWatch stopWatch = new StopWatch("导入核算数据");
stopWatch.start("数据准备");
Map<String, Object> apidatas = new HashMap<String, Object>();
ValidUtil.doValidator(param);
Date now = new Date();
@ -1053,27 +1053,38 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (salaryAcctRecordPO == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
stopWatch.stop();
// 薪资账套下的薪资项目副本
stopWatch.start("薪资账套下的薪资项目副本");
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
// 薪资项目
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
List<SalaryItemPO> salaryItems = getSalaryItemService(user).listByIds(salaryItemIds);
Map<String, Long> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getName, SalaryItemPO::getId);
stopWatch.stop();
// 薪资核算确认的人员
stopWatch.start("薪资核算确认的人员");
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId);
Map<String, SalaryAcctEmployeePO> salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, e -> e.getEmployeeId() + "-" + e.getTaxAgentId());
stopWatch.stop();
// 租户下所有的人员
stopWatch.start("薪资核算确认的人员");
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listAllForReport();
Map<String, Long> salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getUsername, DataCollectionEmployee::getEmployeeId);
Map<Long, DataCollectionEmployee> emps = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getEmployeeId);
stopWatch.stop();
// 租户下所有的个税扣缴义务人
stopWatch.start("租户下所有的个税扣缴义务人");
List<TaxAgentPO> taxAgents = getTaxAgentService(user).listAll();
Map<String, Long> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId);
stopWatch.stop();
// 薪资核算人员信息字段
stopWatch.start("薪资核算人员信息字段");
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
List<String> salarySobEmpFields = SalaryEntityUtil.properties(new SalarySobItemAggregateBO().buildEmpField(salarySobEmpFieldPOS), SalarySobEmpFieldDTO::getFieldName, Collectors.toList());
List<String> excludeFields = Arrays.asList("个税扣缴义务人", "部门", "姓名");
salarySobEmpFields = salarySobEmpFields.stream().filter(field -> !excludeFields.contains(field)).collect(Collectors.toList());
stopWatch.stop();
// 索引(用于计算进度)
int index = 0;
// 失败的数量
@ -1103,10 +1114,10 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
stopWatch.start("解析文件");
Workbook workbook = ExcelSupport.parseFile(fileInputStream, EXCEL_TYPE_XLSX);
Sheet sheet = workbook.getSheetAt(0);
stopWatch.stop();
// 错误提示信息
List<Map> excelComments = Lists.newArrayList();
@ -1136,6 +1147,7 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (CollectionUtils.isEmpty(data)) {
throw new RuntimeException("无数据");
}
stopWatch.start("解析数据");
for (int i = 0; i < data.size(); i++) {
String row = "" + (i + 3) + "";
@ -1257,19 +1269,19 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
salaryAcctResultsOfOneEmp.add(salaryAcctResult);
SalaryAcctResultReportPO reportPO = SalaryAcctResultReportPO.builder()
.id(IdGenerator.generate())
.salaryAcctRecordId(salaryAcctRecordPO.getId())
.salarySobId(salaryAcctRecordPO.getSalarySobId())
.salaryItemId(salaryItemId)
.resultValue(dataValue)
.creator(currentEmployeeId)
.createTime(now)
.updateTime(now)
.deleteType(0)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
salaryAcctResultReportOfOneEmp.add(reportPO);
// SalaryAcctResultReportPO reportPO = SalaryAcctResultReportPO.builder()
// .id(IdGenerator.generate())
// .salaryAcctRecordId(salaryAcctRecordPO.getId())
// .salarySobId(salaryAcctRecordPO.getSalarySobId())
// .salaryItemId(salaryItemId)
// .resultValue(dataValue)
// .creator(currentEmployeeId)
// .createTime(now)
// .updateTime(now)
// .deleteType(0)
// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
// .build();
// salaryAcctResultReportOfOneEmp.add(reportPO);
}
}
}
@ -1346,29 +1358,31 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
salaryAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId);
}
for (SalaryAcctResultReportPO po : salaryAcctResultReportOfOneEmp) {
po.setEmployeeId(Util.null2String(employeeId));
po.setTaxAgentId(taxAgentId);
po.setSalaryAcctEmpId(Util.null2String(salaryAcctEmpId));
DataCollectionEmployee emp = emps.get(employeeId);
po.setSubcompanyId(emp.getSubcompanyid());
po.setDepartmentId(emp.getDepartmentId());
po.setCostcenterId(emp.getCostcenterId());
po.setJobtitleId(emp.getJobtitleId());
po.setLocationId(emp.getLocationId());
}
// for (SalaryAcctResultReportPO po : salaryAcctResultReportOfOneEmp) {
// po.setEmployeeId(Util.null2String(employeeId));
// po.setTaxAgentId(taxAgentId);
// po.setSalaryAcctEmpId(Util.null2String(salaryAcctEmpId));
//
// DataCollectionEmployee emp = emps.get(employeeId);
// po.setSubcompanyId(emp.getSubcompanyid());
// po.setDepartmentId(emp.getDepartmentId());
// po.setCostcenterId(emp.getCostcenterId());
// po.setJobtitleId(emp.getJobtitleId());
// po.setLocationId(emp.getLocationId());
//
// }
salaryAcctEmpIds.add(salaryAcctEmpId);
salaryAcctResults.addAll(salaryAcctResultsOfOneEmp);
salaryAcctReports.addAll(salaryAcctResultReportOfOneEmp);
// salaryAcctReports.addAll(salaryAcctResultReportOfOneEmp);
}
successCount++;
}
stopWatch.stop();
// 如果sheet包含错误数据
// if (CollectionUtils.isNotEmpty(errorDatas)) {
// salaryBatchService.createErrorExcelSheet(headers, errorDatas, excelSheet.getName(), excelComments, errorExcelSheets);
// }
stopWatch.start("插入数据");
if (StringUtils.equals("importExcelAcctResult", importType)) {
getSalaryComparisonResultService(user).deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
if (CollectionUtils.isNotEmpty(excelAcctResults)) {
@ -1392,16 +1406,9 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (CollectionUtils.isNotEmpty(salaryAcctResults)) {
// 处理导入薪资项的回算值
handleOriginResultValue(deleteResults, salaryAcctResults);
// 备份一份加密前的值
List<SalaryAcctResultPO> list4log = new ArrayList<>();
salaryAcctResults.stream().forEach(source -> {
SalaryAcctResultPO target = new SalaryAcctResultPO();
BeanUtils.copyProperties(source, target);
list4log.add(target);
});
getSalaryAcctResultService(user).batchSave(salaryAcctResults);
// 记录操作日志 TODO 这里的数据没有idid是自增的重新查数据太多效率太低
// 记录操作日志
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth());
LoggerContext loggerContext = new LoggerContext<>();
@ -1411,16 +1418,17 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue());
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入薪资核算数据"));
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入薪资核算数据 ") + targetName);
loggerContext.setOldValueList(list4log);
SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext);
//报表
getSalaryAcctReportService(user).batchSave(salaryAcctReports);
// //报表
// getSalaryAcctReportService(user).batchSave(salaryAcctReports);
}
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployees)) {
getSalaryAcctEmployeeService(user).batchSave(newSalaryAcctEmployees);
}
}
stopWatch.stop();
stopWatch.start("锁定数据");
SalarySysConfPO autoLock = getSalarySysConfService(user).getOneByCode(SalarySysConstant.EDIT_IMPORT_AUTO_LOCK);
if (autoLock != null && StringUtils.equals(autoLock.getConfValue(), "1")) {
// 导入的列都自动锁定
@ -1430,6 +1438,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
.lockStatus(LockStatusEnum.LOCK).build();
getSalaryAcctResultService(user).updateLockStatusByParam(updateLockStatusParam);
}
stopWatch.stop();
log.info(stopWatch.prettyPrint());
apidatas.put("successCount", successCount);
apidatas.put("errorCount", failCount);

View File

@ -1,6 +1,5 @@
package com.engine.salary.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
@ -17,7 +16,6 @@ import com.engine.salary.entity.hrm.JobCallInfo;
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.hrm.SubCompanyInfo;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.entity.report.bo.SalaryAcctResultReportBO;
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
import com.engine.salary.entity.salaryacct.bo.*;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
@ -56,7 +54,6 @@ 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;
@ -695,12 +692,12 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
List<List<SalaryAcctResultPO>> partition = Lists.partition(salaryAcctResultPOS, 100);
partition.forEach(getSalaryAcctResultMapper()::batchInsert);
}
//报表 todo
getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(Collections.singletonList(saveParam.getSalaryAcctEmpId()), saveItemIds);
List<SalaryAcctResultReportPO> salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2PO(saveParam, salaryAcctEmployeePO, (long) user.getUID(), emps);
if (CollectionUtils.isNotEmpty(salaryAcctResultReportPOS)) {
getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
}
//报表
// getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(Collections.singletonList(saveParam.getSalaryAcctEmpId()), saveItemIds);
// List<SalaryAcctResultReportPO> salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2PO(saveParam, salaryAcctEmployeePO, (long) user.getUID(), emps);
// if (CollectionUtils.isNotEmpty(salaryAcctResultReportPOS)) {
// getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
// }
// 存储薪资核算结果数据来源日志
@ -859,21 +856,6 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空"));
}
//核算锁定值
List<Long> lockSalaryItemIds = salaryAcctRecordPO.getLockSalaryItemIds();
Map<String, SalaryAcctResultPO> acctResults = new HashMap<>();
if (CollUtil.isNotEmpty(lockSalaryItemIds)) {
List<SalaryAcctResultPO> acctResultPOS = listBySalaryAcctRecordIdsAndSalaryItemIds(Collections.singleton(calculateParam.getSalaryAcctRecordId()), lockSalaryItemIds);
acctResults = Optional.ofNullable(acctResultPOS).orElse(new ArrayList<>()).stream().filter(po -> lockSalaryItemIds.contains(po.getSalaryItemId())).collect(Collectors.toMap(po -> po.getSalaryItemId() + "_" + po.getSalaryAcctEmpId(), a -> a, (a, b) -> a));
}
List<Long> lockEmpIds = salaryAcctEmployeePOS.stream().filter(po -> LockStatusEnum.LOCK.getValue().equals(po.getLockStatus())).map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(lockEmpIds)) {
List<SalaryAcctResultPO> acctResultPOS = listBySalaryAcctEmployeeIds(lockEmpIds);
Map<String, SalaryAcctResultPO> acctResultMaps = Optional.ofNullable(acctResultPOS).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(po -> po.getSalaryItemId() + "_" + po.getSalaryAcctEmpId(), a -> a, (a, b) -> a));
acctResults.putAll(acctResultMaps);
}
stopWatch.stop();
stopWatch.start("核算耗时");
@ -902,8 +884,6 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
.setSalarySobPO(salarySobPO)
.setSalarySobCycleDTO(salarySobCycleDTO)
.setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS)
.setSalaryAcctLockResultPOS(MapUtils.emptyIfNull(acctResults))
.setLockSalaryItemIds(lockSalaryItemIds)
.setSalarySobItemPOS(salarySobItemPOS)
.setSalaryItemIdWithPriorityList(salarySobItemsWithPriority)
.setExpressFormulas(expressFormulas)
@ -1282,13 +1262,32 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
// return salaryAcctEmployeeService.filterByAuthority(salaryAcctEmployees, employeeId);
// }
@Override
public void lock(SalaryAcctResultLockParam param) {
ValidUtil.doValidator(param);
SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(param.getAcctEmpId());
if (salaryAcctEmployeePO == null) {
return;
}
List<Long> lockItemIds = salaryAcctEmployeePO.getLockItems() == null ? new ArrayList<>() : salaryAcctEmployeePO.getLockItems();
Long salaryItemId = param.getSalaryItemId();
if (param.getLockStatus() == LockStatusEnum.LOCK) {
lockItemIds.add(salaryItemId);
} else {
lockItemIds.remove(salaryItemId);
}
salaryAcctEmployeePO.setLockItems(lockItemIds);
getSalaryAcctEmployeeService(user).lock(salaryAcctEmployeePO);
}
@Override
public void updateLockStatusByParam(SalaryAcctResultUpdateLockStatusParam updateParam) {
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(updateParam.getSalaryAcctRecordId());
if (CollectionUtils.isEmpty(salaryAcctRecord.getLockSalaryItemIds())) {
salaryAcctRecord.setLockSalaryItemIds(new ArrayList<>());
}
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(updateParam.getSalaryAcctRecordId());
if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
return;
@ -1300,15 +1299,18 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
} else {
salaryItemIds = Collections.singleton(updateParam.getSalaryItemId());
}
if (updateParam.getLockStatus() == LockStatusEnum.LOCK) {
Set<Long> lockSalaryItemIds = new HashSet<>();
lockSalaryItemIds.addAll(salaryAcctRecord.getLockSalaryItemIds());
lockSalaryItemIds.addAll(salaryItemIds);
salaryAcctRecord.setLockSalaryItemIds(new ArrayList<Long>(lockSalaryItemIds));
} else {
salaryAcctRecord.getLockSalaryItemIds().removeAll(salaryItemIds);
}
getSalaryAcctRecordService(user).updateLockSalaryItemIds(salaryAcctRecord);
salaryAcctEmployees.forEach(salaryAcctEmployeePO -> {
List<Long> lockItemIds = salaryAcctEmployeePO.getLockItems() == null ? new ArrayList<>() : salaryAcctEmployeePO.getLockItems();
if (updateParam.getLockStatus() == LockStatusEnum.LOCK) {
lockItemIds.addAll(salaryItemIds);
} else {
lockItemIds.removeAll(salaryItemIds);
}
salaryAcctEmployeePO.setLockItems(lockItemIds);
getSalaryAcctEmployeeService(user).lock(salaryAcctEmployeePO);
});
}
@ -1451,30 +1453,30 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
}
// 报表
SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder()
.id(IdGenerator.generate())
.salarySobId(salaryAcctRecordPO.getSalarySobId())
.salaryItemId(param.getSalaryItemId())
.salaryAcctRecordId(param.getSalaryAcctRecordId())
.salaryAcctEmpId(salaryAcctEmployeePO.getId().toString())
.employeeId(salaryAcctEmployeePO.getEmployeeId().toString())
.taxAgentId(salaryAcctEmployeePO.getTaxAgentId())
.resultValue(param.getValue())
.creator(Long.valueOf(user.getUID()))
.createTime(now)
.updateTime(now)
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
DataCollectionEmployee dataCollectionEmployee = emps.get(salaryAcctEmployeePO.getEmployeeId());
if (dataCollectionEmployee != null) {
po.setDepartmentId(dataCollectionEmployee.getDepartmentId());
po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid());
po.setCostcenterId(dataCollectionEmployee.getCostcenterId());
po.setJobtitleId(dataCollectionEmployee.getJobtitleId());
po.setLocationId(dataCollectionEmployee.getLocationId());
}
salaryAcctResultReportPOS.add(po);
// SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder()
// .id(IdGenerator.generate())
// .salarySobId(salaryAcctRecordPO.getSalarySobId())
// .salaryItemId(param.getSalaryItemId())
// .salaryAcctRecordId(param.getSalaryAcctRecordId())
// .salaryAcctEmpId(salaryAcctEmployeePO.getId().toString())
// .employeeId(salaryAcctEmployeePO.getEmployeeId().toString())
// .taxAgentId(salaryAcctEmployeePO.getTaxAgentId())
// .resultValue(param.getValue())
// .creator(Long.valueOf(user.getUID()))
// .createTime(now)
// .updateTime(now)
// .deleteType(NumberUtils.INTEGER_ZERO)
// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
// .build();
// DataCollectionEmployee dataCollectionEmployee = emps.get(salaryAcctEmployeePO.getEmployeeId());
// if (dataCollectionEmployee != null) {
// po.setDepartmentId(dataCollectionEmployee.getDepartmentId());
// po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid());
// po.setCostcenterId(dataCollectionEmployee.getCostcenterId());
// po.setJobtitleId(dataCollectionEmployee.getJobtitleId());
// po.setLocationId(dataCollectionEmployee.getLocationId());
// }
// salaryAcctResultReportPOS.add(po);
});
// 入库
@ -1487,8 +1489,8 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
batchSave(needInsertList);
// 报表入库前先删除
getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(param.getIdList(), Collections.singletonList(param.getSalaryItemId()));
getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
// getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(param.getIdList(), Collections.singletonList(param.getSalaryItemId()));
// getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
}
}

View File

@ -476,6 +476,14 @@ public class SalaryAcctController {
}
@POST
@Path("/acctresult/lock")
@Produces(MediaType.APPLICATION_JSON)
public String lock(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultLockParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryAcctResultLockParam, String>(user).run(getSalaryAcctResultWrapper(user)::lock, param);
}
//更新薪资项目锁定状态
@POST
@Path("/acctresult/updateLockStatus")

View File

@ -194,6 +194,11 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult
getSalaryAcctResultService(user).save(saveParam);
}
public void lock(SalaryAcctResultLockParam param) {
getSalaryAcctResultService(user).lock(param);
}
/**
* 更新薪资核算结果的值的锁定状态
*