薪资核算编辑 手动编辑后自动锁定
This commit is contained in:
parent
54ca46c653
commit
b0084cad9c
|
|
@ -15,10 +15,7 @@ import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO;
|
|||
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
||||
import com.engine.salary.entity.salarysob.po.*;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.enums.salaryaccounting.LockStatusEnum;
|
||||
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
||||
|
|
@ -369,6 +366,7 @@ public class SalaryAcctResultBO {
|
|||
TaxAgentPO taxAgentPO,
|
||||
SalaryAcctEmployeePO salaryAcctEmployee,
|
||||
List<SalarySobEmpFieldPO> salarySobEmpFields,
|
||||
List<SalarySobItemGroupPO> salarySobItemGroupPOS,
|
||||
List<SalarySobItemPO> salarySobItemPOS,
|
||||
List<SalaryItemPO> salaryItems,
|
||||
List<SalaryAcctResultPO> salaryAcctResults,
|
||||
|
|
@ -391,6 +389,26 @@ public class SalaryAcctResultBO {
|
|||
Map<Long, String> resultValueMap = SalaryEntityUtil.convert2Map(salaryAcctResults, SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
|
||||
Map<Long, SalaryItemPO> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId);
|
||||
Map<Long, SalaryItemPO> salaryBackItemMap = SalaryEntityUtil.convert2Map(salaryBackItemPOS, SalaryItemPO::getId);
|
||||
Map<Long, List<SalarySobItemPO>> salarySobItemPOMap = SalaryEntityUtil.group2Map(salarySobItemPOS, SalarySobItemPO::getSalarySobItemGroupId);
|
||||
|
||||
// 对分组进行排序
|
||||
salarySobItemGroupPOS = sortGroup(salarySobItemGroupPOS);
|
||||
// 对分组内薪资项目排序
|
||||
sortItem(salarySobItemPOMap);
|
||||
// 根据账套分组封装薪资项目的值
|
||||
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemByGroupDTO> itemsByGroup = new ArrayList<>();
|
||||
for(SalarySobItemGroupPO groupPO : salarySobItemGroupPOS){
|
||||
List<SalarySobItemPO> groupItems = salarySobItemPOMap.getOrDefault(groupPO.getId(),Collections.emptyList());
|
||||
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> items = groupItems.stream()
|
||||
.map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap))
|
||||
.collect(Collectors.toList());
|
||||
itemsByGroup.add(SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemByGroupDTO.builder()
|
||||
.salarySobItemGroupId(groupPO.getId())
|
||||
.salarySobItemGroupName(groupPO.getName())
|
||||
.salaryItems(items)
|
||||
.sortedIndex(groupPO.getSortedIndex()).build() );
|
||||
}
|
||||
|
||||
// 公式项的值(不根据salaryItemPO的valueType判断是因为薪资项目的valueType属性改变后并不会同步更新薪资账套中的薪资项目的formulaId字段)
|
||||
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> formulaItems = salarySobItemPOS.stream()
|
||||
.filter(salarySobItemPO -> salarySobItemPO.getFormulaId() > 0)
|
||||
|
|
@ -415,10 +433,32 @@ public class SalaryAcctResultBO {
|
|||
.employeeInfos(employeeInfos)
|
||||
.formulaItems(formulaItems)
|
||||
.inputItems(inputItems)
|
||||
.itemsByGroup(itemsByGroup)
|
||||
.issuedAndReissueItems(issuedAndReissueItems)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static List<SalarySobItemGroupPO> sortGroup(List<SalarySobItemGroupPO> salarySobItemGroupPOS) {
|
||||
if(CollectionUtils.isEmpty(salarySobItemGroupPOS)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return salarySobItemGroupPOS.stream().sorted(Comparator.comparingInt(SalarySobItemGroupPO::getSortedIndex)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 薪资账套的薪资项目按照sortedIndex排序
|
||||
*
|
||||
*/
|
||||
private static void sortItem(Map<Long, List<SalarySobItemPO>> salarySobItemPOMap) {
|
||||
for(Map.Entry<Long, List<SalarySobItemPO>> entry : salarySobItemPOMap.entrySet()){
|
||||
List<SalarySobItemPO> items = entry.getValue();
|
||||
if (CollectionUtils.isNotEmpty(items)) {
|
||||
List<SalarySobItemPO> sortedValue = items.stream().sorted(Comparator.comparingInt(SalarySobItemPO::getSortedIndex)).collect(Collectors.toList());
|
||||
salarySobItemPOMap.put(entry.getKey(), sortedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换成薪资核算结果详情dto
|
||||
*
|
||||
|
|
@ -436,7 +476,8 @@ public class SalaryAcctResultBO {
|
|||
.salaryItemName(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY))
|
||||
.resultValue(resultValueMap.getOrDefault(salarySobItemPO.getSalaryItemId(), StringUtils.EMPTY))
|
||||
.dataType(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue()))
|
||||
.canEdit(Objects.equals(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getUseInEmployeeSalary).orElse(0), 0))
|
||||
// .canEdit(Objects.equals(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getUseInEmployeeSalary).orElse(0), 0))
|
||||
.canEdit(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -492,7 +533,7 @@ public class SalaryAcctResultBO {
|
|||
.salaryAcctEmpId(salaryAcctEmployee.getId())
|
||||
.employeeId(salaryAcctEmployee.getEmployeeId())
|
||||
.taxAgentId(salaryAcctEmployee.getTaxAgentId())
|
||||
.resultValue(e.getResultValue())
|
||||
.resultValue(StringUtils.trim(e.getResultValue()))
|
||||
.originResultValue(salaryAcctResultOldPOMap.get(saveParam.getSalaryAcctEmpId() + "-" + e.getSalaryItemId()))
|
||||
.creator(employeeId)
|
||||
.createTime(now)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ public class SalaryAcctResultDetailDTO {
|
|||
//输入项")
|
||||
private List<SalaryAcctResultDetailItemDTO> inputItems;
|
||||
|
||||
// 根据账套分组的薪资项目
|
||||
private List<SalaryAcctResultDetailItemByGroupDTO> itemsByGroup;
|
||||
|
||||
//已发补发
|
||||
private List<SalaryAcctResultDetailItemDTO> issuedAndReissueItems;
|
||||
|
||||
|
|
@ -66,4 +69,23 @@ public class SalaryAcctResultDetailDTO {
|
|||
//是否可编辑
|
||||
private Boolean canEdit;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SalaryAcctResultDetailItemByGroupDTO {
|
||||
|
||||
//薪资账套分组id")
|
||||
private Long salarySobItemGroupId;
|
||||
|
||||
//薪资项目分组名称")
|
||||
private String salarySobItemGroupName;
|
||||
|
||||
//分组中包含的薪资项目
|
||||
private List<SalaryAcctResultDetailItemDTO> salaryItems;
|
||||
|
||||
//分组顺序
|
||||
private Integer sortedIndex;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,10 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryAcctResultService getSalaryAcctResultService(User user) {
|
||||
return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
private SalaryCheckResultService salaryCheckResultService;
|
||||
|
||||
|
|
@ -271,7 +275,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
TaxAgentPO taxAgent = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId());
|
||||
|
||||
// 转换成薪资核算结果详情dto
|
||||
return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgent, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS, salarySobBackItemPOList, salaryBackItemPOS, salaryBackItemFormula);
|
||||
return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgent, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemGroupPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS, salarySobBackItemPOList, salaryBackItemPOS, salaryBackItemFormula);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -523,9 +527,24 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
encryptUtil.decryptList(salaryAcctResultPOSOld, SalaryAcctResultPO.class);
|
||||
// 保存参数转换成薪资核算结果po
|
||||
List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2PO(salaryAcctResultPOSOld, saveParam, salaryAcctEmployeePO, (long) user.getUID());
|
||||
// 对比核算结果提取修改了哪些薪资项目
|
||||
Set<Long> needLockItems = new HashSet<>();
|
||||
Map<Long, SalaryAcctResultPO> oldResutMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOSOld, SalaryAcctResultPO::getSalaryItemId);
|
||||
salaryAcctResultPOS.stream().forEach(PO -> {
|
||||
String oldValue = oldResutMap.get(PO.getSalaryItemId()).getResultValue();
|
||||
if(!StringUtils.equals(oldValue,PO.getResultValue())){
|
||||
needLockItems.add(PO.getSalaryItemId());
|
||||
}
|
||||
});
|
||||
|
||||
// 编辑的列都自动锁定
|
||||
SalaryAcctResultUpdateLockStatusParam updateLockStatusParam = SalaryAcctResultUpdateLockStatusParam.builder()
|
||||
.salaryItemIds(needLockItems)
|
||||
.salaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId())
|
||||
.lockStatus(LockStatusEnum.LOCK).build();
|
||||
getSalaryAcctResultService(user).updateLockStatusByParam(updateLockStatusParam);
|
||||
|
||||
SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId());
|
||||
// SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId());
|
||||
// 若保存编辑时一同传已发补发,则删除以下代码
|
||||
// if(byId.getBackCalcStatus() != null && Objects.equals(byId.getBackCalcStatus(),1)){
|
||||
// // 是回算
|
||||
|
|
@ -927,4 +946,4 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
// }
|
||||
return salaryItemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue