修复账套根据名称查询bug

去除调整前后值的限制
This commit is contained in:
钱涛 2023-02-15 16:38:54 +08:00
parent 4f0dc060ee
commit a2e9c482a4
4 changed files with 70 additions and 42 deletions

View File

@ -824,20 +824,22 @@ public class SalaryArchiveExcelBO extends Service {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowindex + key + salaryItemNoBeforeCurrentEffectiveTime);
excelComments.add(errorMessageMap);
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemNoBeforeCurrentEffectiveTime, errorCount + 1, errorCount + 1, effectiveTimeIndex, effectiveTimeIndex);
isError = true;
} else if (salaryItemAdjustValid.isSame()) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSame);
excelComments.add(errorMessageMap);
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemAdjustNoSame, errorCount + 1, errorCount + 1, j, j);
isError = true;
// Map<String, String> errorMessageMap = Maps.newHashMap();
// errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSame);
// excelComments.add(errorMessageMap);
// isError = true;
//调整前后相同的值都不做处理
cellVal = "";
} else if (salaryItemAdjustValid.isSameIneffective()) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSameIneffective);
excelComments.add(errorMessageMap);
// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemAdjustNoSameIneffective, errorCount + 1, errorCount + 1, j, j);
isError = true;
// Map<String, String> errorMessageMap = Maps.newHashMap();
// errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSameIneffective);
// excelComments.add(errorMessageMap);
// isError = true;
//调整前后相同的值都不做处理
cellVal = "";
}
}
// 导入时不需要处理的薪资项目

View File

@ -71,8 +71,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
return ServiceUtil.getService(SalarySendServiceImpl.class, user);
}
private SalarySysConfService getSalarySysConfService(User user){
return ServiceUtil.getService(SalarySysConfServiceImpl.class,user);
private SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
}
// private SalaryCheckResultService salaryCheckResultService;
@ -132,7 +132,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
@Override
public List<SalaryAcctRecordPO> listByTaxCycle(LocalDateRange taxCycleDateRange,Collection<Long> salarySobIds) {
public List<SalaryAcctRecordPO> listByTaxCycle(LocalDateRange taxCycleDateRange, Collection<Long> salarySobIds) {
return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().taxCycleDateRange(taxCycleDateRange).salarySobIds(salarySobIds).build());
}
@ -170,12 +170,15 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
if (needAuth) {
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByAdmin();
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
List<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId, Collectors.toList());
if (CollectionUtils.isEmpty(salarySobIds)) {
return new PageInfo<>();
}
Collection<Long> sobIds = po.getSalarySobIds();
if (CollectionUtils.isNotEmpty(sobIds)) {
salarySobIds = (List<Long>) SalaryEntityUtil.intersectionForList(salarySobIds, sobIds);
}
po.setSalarySobIds(salarySobIds);
}
@ -226,7 +229,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
// 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle());
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listByTaxCycle(taxCycleDateRange,salarySobIds);
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listByTaxCycle(taxCycleDateRange, salarySobIds);
// 除开本次薪资核算记录之外的其他薪资核算记录
return salaryAcctRecordPOS.stream().filter(po -> !Objects.equals(po.getId(), salaryAcctRecordPO.getId())).collect(Collectors.toList());
}
@ -259,7 +262,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
// 查询税款所属期所在年的所有薪资核算记录
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listByTaxCycle(yearRange,Collections.singleton(saveParam.getSalarySobId()));
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listByTaxCycle(yearRange, Collections.singleton(saveParam.getSalarySobId()));
// 计算当前所选的薪资账套是当前薪资所属月的核算次数
long acctTimes = salaryAcctRecordPOS.stream()
@ -310,12 +313,12 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId);
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
//获取账套下的所有核算结果
List<SalaryAcctRecordPO> salaryAcctRecords = listByTaxCycle(taxCycleYearRange,salarySobIds);
List<SalaryAcctRecordPO> salaryAcctRecords = listByTaxCycle(taxCycleYearRange, salarySobIds);
// 获取个税申报功能状态
TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration();
if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){
if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())) {
// 关闭了个税申报功能
// 如果某个月薪资所属期还未归档不可以新建之后月份的薪资核算
SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
@ -323,10 +326,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
&& e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
.findAny()
.orElse(null);
if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){
if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算")
.replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}",salarySobCycleDTO.getTaxCycle().toString()));
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果有某个月薪资所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO havaSalaryAcctRecordPO = salaryAcctRecords.stream()
@ -334,14 +337,14 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
&& e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
.findAny()
.orElse(null);
if(Objects.nonNull(havaSalaryAcctRecordPO)){
if (Objects.nonNull(havaSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98755, "薪资所属期{0}的薪资核算结果已经归档,不能新建薪资所属期{1}的薪资核算")
.replace("{0}",SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString())
.replace("{1}",salarySobCycleDTO.getSalaryMonth().toString()));
.replace("{0}", SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString())
.replace("{1}", salarySobCycleDTO.getSalaryMonth().toString()));
}
}
if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){
if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())) {
// 开启了个税申报功能
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
@ -377,7 +380,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
}
if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){
if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())) {
// 重启了个税申报功能不去校验重启之前是否申报数据
// 如果某个月薪资所属期还未归档不可以新建之后月份的薪资核算
SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
@ -385,10 +388,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
&& e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
.findAny()
.orElse(null);
if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){
if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算")
.replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}",salarySobCycleDTO.getTaxCycle().toString()));
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
@ -404,7 +407,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
// 如果某个月税款所属期还未申报不可以新建之后月份的薪资核算
//获取账套下从重启月至所在年的最后一天的所有核算结果
Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate();
if(taxDeclarationRebootDate == null){
if (taxDeclarationRebootDate == null) {
throw new SalaryRunTimeException("个税申报功能异常");
}
@ -413,7 +416,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
.endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate))
.build();
// List<SalaryAcctRecordPO> salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds);
List<SalaryAcctRecordPO> salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange,salarySobIds);
List<SalaryAcctRecordPO> salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange, salarySobIds);
SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream()
.filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
@ -442,7 +445,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
private List<SalaryAcctRecordPO> listByCreateDate(LocalDateRange taxCycleRebootYearRange, Set<Long> salarySobIds) {
return getSalaryAcctRecordMapper().listByCreateDate(taxCycleRebootYearRange,salarySobIds);
return getSalaryAcctRecordMapper().listByCreateDate(taxCycleRebootYearRange, salarySobIds);
}
@ -541,7 +544,6 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
getSalarySendService(user).generateSalaryBill(salaryAcctRecordId);
// 记录日志
// String targetName = getLogTargetNameById(salaryAcctRecordId);
// LoggerContext<SalaryAcctRecordPO> loggerContext = new LoggerContext<>();
@ -604,7 +606,6 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
private void reCalcOrBackCalc(SalaryAcctRecordPO salaryAcctRecordPO, boolean isReCalc) {
// 如果薪资核算记录还未归档不允许重新核算
if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
@ -622,7 +623,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
//查询扣缴义务人下的所有账套
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId);
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listByTaxCycle(yearRange,salarySobIds);
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listByTaxCycle(yearRange, salarySobIds);
List<SalaryAcctRecordPO> selfSalaryAcctRecordPOS = filterByAuthority(salaryAcctRecordPOS);
// 如果已经存在之后月份的薪资核算记录了就不允许重新核算本月了
@ -654,7 +655,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
List<Long> needUpdateSalaryAcctRecordIds = selfSalaryAcctRecordPOS.stream().filter(po -> po.getTaxCycle().equals(salaryAcctRecordPO.getTaxCycle()))
.map(SalaryAcctRecordPO::getId).collect(Collectors.toList());
if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())) {
if(needUpdateSalaryAcctRecordIds != null && needUpdateSalaryAcctRecordIds.size()>0){
if (needUpdateSalaryAcctRecordIds != null && needUpdateSalaryAcctRecordIds.size() > 0) {
// 更新薪资核算记录的状态
updateStatusByIds(needUpdateSalaryAcctRecordIds, SalaryAcctRecordStatusEnum.ARCHIVED);
}
@ -730,14 +731,14 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
// 获取该账套该月核算的所有记录
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salaryMonth(salaryAcctRecordPO.getSalaryMonth()).salarySobId(salaryAcctRecordPO.getSalarySobId()).deleteType(0).build());
// 只有该账套在此月的最后一次核算才能进行回算
if(!salaryAcctRecordPO.getAcctTimes().equals(salaryAcctRecordPOS.size())){
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"只有核算次数为最后一次时,才能进行回算"));
if (!salaryAcctRecordPO.getAcctTimes().equals(salaryAcctRecordPOS.size())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "只有核算次数为最后一次时,才能进行回算"));
}
// 只有正常核算全部发送完才能进行回算
SalarySendPO build = SalarySendPO.builder().salaryAccountingId(salaryAcctRecordId).deleteType(0).build();
List<SalarySendPO> salarySends = getSalarySendMapper().listSome(build);
salarySends.stream().forEach(salarySend -> {
if(salarySend.getSendNum() < salarySend.getSendTotal()){
if (salarySend.getSendNum() < salarySend.getSendTotal()) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139702, "正常核算工资单尚未全部发送完成,不能进行回算"));
}
});

View File

@ -163,6 +163,7 @@ public class SalaryEntityUtil {
/**
* LinkedHashMap有序去重
*
* @param keyExtractor
* @param <T>
* @return
@ -174,6 +175,7 @@ public class SalaryEntityUtil {
/**
* ConcurrentHashMap无序去重
*
* @param keyExtractor
* @param <T>
* @return
@ -325,4 +327,26 @@ public class SalaryEntityUtil {
return new Double("0.0");
}
/**
* 两个集合交集forEasy
*
* @param arr1
* @param arr2
* @return
*/
public static <T> Collection<T> intersectionForList(Collection<T> arr1, Collection<T> arr2) {
Collection<T> resultList = new ArrayList<>();
if (CollectionUtils.isEmpty(arr1) || CollectionUtils.isEmpty(arr1)) {
return resultList;
}
arr1.forEach(a1 -> {
if (arr2.contains(a1)) {
resultList.add(a1);
}
});
return resultList;
}
}

View File

@ -31,6 +31,7 @@ import com.engine.salary.util.valid.RuntimeTypeEnum;
import com.engine.salary.util.valid.ValidUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.hrm.User;
import java.util.*;
@ -96,7 +97,7 @@ public class SalaryItemWrapper extends Service {
List<SalaryItemListDTO> salaryItemListDTOS = SalaryItemBO.convert2ListDTO(salaryItemList, expressFormulas, sysSalaryItemPOS);
//薪资档案引用时不能删除
salaryItemListDTOS.forEach(dto -> {
if (dto.getUseInEmployeeSalary() == 1) {
if (dto.getUseInEmployeeSalary() == 1|| StringUtils.isNotBlank(dto.getSystemName())) {
dto.setCanDelete(false);
}
});