feat: 发放模板获取可用分组或项目

This commit is contained in:
fcli 2023-02-01 11:22:38 +08:00
parent 80019a029c
commit dec7c89856
4 changed files with 71 additions and 18 deletions

View File

@ -0,0 +1,18 @@
package com.engine.salary.entity.salaryBill.param;
import com.engine.salary.common.BaseQueryParam;
import lombok.*;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryBillSalaryGroupQueryParam extends BaseQueryParam {
private Long salarySobId;
private List<String> existSalaryGroupIds;
}

View File

@ -3,14 +3,18 @@ package com.engine.salary.entity.salaryBill.param;
import com.engine.salary.common.BaseQueryParam;
import lombok.*;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryBillItemQueryParam extends BaseQueryParam {
public class SalaryBillSalaryItemQueryParam extends BaseQueryParam {
private Long salarySobId;
private Long groupId;
private List<String> existSalaryItemIds;
}

View File

@ -105,21 +105,29 @@ public class SalaryBillController {
}
/**
* 获取薪资项目设置
*
* @param salarySobId
* @return
* 获取可用的薪资项目
*/
@GET
@Path("/template/getGroupedSalaryItemSet")
@Path("/template/getAvailableSalaryGroupSet")
@Produces(MediaType.APPLICATION_JSON)
public String getSalaryItemSet(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("salarySobId") Long salarySobId, @QueryParam("groupId") Long groupId) {
public String getAvailableSalaryGroupSet(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SalaryBillSalaryGroupQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryBillItemQueryParam, List<SalaryTemplateSalaryItemListDTO>>(user)
.run(getSalaryTemplateWrapper(user)::getSalaryItemSetGrouped,
SalaryBillItemQueryParam.builder()
.salarySobId(salarySobId).groupId(groupId).build());
return new ResponseResult<SalaryBillSalaryGroupQueryParam, List<SalaryTemplateSalaryItemSetListDTO>>(user)
.run(getSalaryTemplateWrapper(user)::getSalaryGroupSet, param);
}
/**
* 获取可用的薪资项目
*/
@GET
@Path("/template/getAvailableSalaryItemSet")
@Produces(MediaType.APPLICATION_JSON)
public String getAvailableSalaryItemSet(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SalaryBillSalaryItemQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryBillSalaryItemQueryParam, List<SalaryTemplateSalaryItemListDTO>>(user)
.run(getSalaryTemplateWrapper(user)::getSalaryItemSetGrouped, param);
}
/**

View File

@ -337,7 +337,7 @@ public class SalaryTemplateWrapper extends Service {
}
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salarySobBackItems.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList()));
String ruleTip = "(" + SalaryI18nUtil.getI18nLabel( 140142, "不等于0")+")";
String ruleTip = "(" + SalaryI18nUtil.getI18nLabel(140142, "不等于0") + ")";
List<Map<String, String>> result = salaryItemPOS.stream().map(m -> {
Map<String, String> map = new HashMap<>(2);
@ -368,9 +368,9 @@ public class SalaryTemplateWrapper extends Service {
if (id != null) {
SalaryTemplatePO po = getSalaryTemplateService(user).getById(id);
if (po == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100533, "工资单模板不存在")+"[id:%s]", id));
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100533, "工资单模板不存在") + "[id:%s]", id));
}
BeanUtils.copyProperties(po, salaryTemplateReplenishSetDTO);
BeanUtils.copyProperties(po, salaryTemplateReplenishSetDTO);
if (StringUtils.isNotEmpty(po.getReplenishSalaryItemSetting())) {
replenishSalaryItemSetting = JsonUtil.fromJson(po.getReplenishSalaryItemSetting(), List.class);
} else {
@ -386,14 +386,37 @@ public class SalaryTemplateWrapper extends Service {
.build();
}
public List<SalaryTemplateSalaryItemListDTO> getSalaryItemSetGrouped(SalaryBillItemQueryParam param) {
/**
* 获取单个分组下没有被加入到模板的薪资项目
* @param param 入参
* @return 单个分组下剩余的薪资项目
*/
public List<SalaryTemplateSalaryItemListDTO> getSalaryItemSetGrouped(SalaryBillSalaryItemQueryParam param) {
List<SalaryTemplateSalaryItemSetListDTO> salaryItemSet
= getSalaryTemplateService(user).getSalaryItemSet(param.getSalarySobId(), false);
Long groupId = param.getGroupId();
return salaryItemSet.stream()
.filter(s-> Objects.equals(s.getGroupId(), groupId+""))
.filter(s -> Objects.equals(s.getGroupId(), groupId + ""))
.map(SalaryTemplateSalaryItemSetListDTO::getItems)
.findFirst()
.orElse(Collections.emptyList());
.orElse(Collections.emptyList())
.stream()
.filter(item -> !Optional.ofNullable(param.getExistSalaryItemIds()).orElse(Collections.emptyList())
.contains(item.getId())
).collect(Collectors.toList());
}
/**
* 获取账套下没有被加入的分组
* @param param 入参
* @return 分组与下属
*/
public List<SalaryTemplateSalaryItemSetListDTO> getSalaryGroupSet(SalaryBillSalaryGroupQueryParam param) {
return getSalaryTemplateService(user).getSalaryItemSet(param.getSalarySobId(), false)
.stream()
.filter(group -> !Optional.ofNullable(param.getExistSalaryGroupIds()).orElse(Collections.emptyList())
.contains(group.getGroupId())
)
.collect(Collectors.toList());
}
}