回算薪资项(薪资账套部分),剩余处理历史数据

This commit is contained in:
Harryxzy 2022-11-18 14:20:18 +08:00
parent 57f8bb6a6a
commit a5ae8c8ea6
11 changed files with 319 additions and 75 deletions

View File

@ -1,10 +1,19 @@
package com.engine.salary.entity.salarysob.bo;
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobDefaultBackItemPO;
import com.engine.salary.util.SalaryEntityUtil;
import com.google.common.collect.Lists;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* @author Harryxzy
@ -27,34 +36,35 @@ public class SalarySobBackItemBO {
.backCalcType(1).build());
}
// public static List<SalarySobBackItemDTO> convert2DTO(List<SalarySobBackItemPO> salarySobBackItems, List<SalaryItemPO> salaryItems, List<ExpressFormula> expressFormulas) {
// if (CollectionUtils.isEmpty(salarySobBackItems)) {
// return Collections.emptyList();
// }
// List<SalarySobBackItemDTO> dtos = Lists.newArrayList();
// Map<Long, SalaryItemPO> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId);
// Map<Long, String> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
// for (SalarySobBackItemPO salarySobBackItem : salarySobBackItems) {
// SalaryItemPO salaryItem = salaryItemMap.get(salarySobBackItem.getSalaryItemId());
// SalarySobBackItemDTO dto = new SalarySobBackItemDTO()
// .setId(salarySobBackItem.getId())
// .setSalaryItemId(salaryItem.getId())
// .setSysSalaryItemId(salaryItem.getSysSalaryItemId())
// .setSalarySobItemGroupId(0L)
// .setName(salaryItem.getName())
// .setFormulaId(salarySobBackItem.getFormulaId())
// .setFormulaContent(expressFormulaMap.getOrDefault(salarySobBackItem.getFormulaId(), "输入"))
// .setDataType(salaryItem.getDataType())
// .setPattern(salarySobBackItem.getPattern())
// .setTaxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItem.getCode()))
// .setSortedIndex(0)
// .setCanEdit(true)
// .setCanDelete(false)
// .setIncomeCategory("0")
// .setBackCalcType(salarySobBackItem.getBackCalcType());
// dtos.add(dto);
// }
// return dtos;
// }
public static List<SalarySobBackItemDTO> convert2DTO(List<SalarySobBackItemPO> salarySobBackItems, List<SalaryItemPO> salaryItems, List<ExpressFormula> expressFormulas) {
if (CollectionUtils.isEmpty(salarySobBackItems)) {
return Collections.emptyList();
}
List<SalarySobBackItemDTO> dtos = Lists.newArrayList();
Map<Long, SalaryItemPO> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId);
Map<Long, String> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
for (SalarySobBackItemPO salarySobBackItem : salarySobBackItems) {
SalaryItemPO salaryItem = salaryItemMap.get(salarySobBackItem.getSalaryItemId());
SalarySobBackItemDTO dto = SalarySobBackItemDTO.builder()
.id(salarySobBackItem.getId())
.salaryItemId(salaryItem.getId())
.sysSalaryItemId(salaryItem.getSysSalaryItemId())
.salarySobItemGroupId(0L)
.name(salaryItem.getName())
.formulaId(salarySobBackItem.getFormulaId())
.formulaContent(expressFormulaMap.getOrDefault(salarySobBackItem.getFormulaId(), "输入"))
.dataType(salaryItem.getDataType())
.pattern(salarySobBackItem.getPattern())
.taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItem.getCode()))
.sortedIndex(0)
.canEdit(true)
.canDelete(false)
.incomeCategory("0")
.backCalcType(salarySobBackItem.getBackCalcType()).build();
dtos.add(dto);
}
return dtos;
}
}

View File

@ -0,0 +1,64 @@
package com.engine.salary.entity.salarysob.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Harryxzy
* @date 2022/11/18 9:52
* @description 薪资回算项目
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SalarySobBackItemDTO {
// 主键id
private Long id;
// 薪资项目的id
private Long salaryItemId;
// 系统薪资项目的id
private Long sysSalaryItemId;
// 薪资项目分组id
private Long salarySobItemGroupId;
// 薪资类型
private String incomeCategory;
// 名称
private String name;
// 公式
private Long formulaId;
// 公式内容
private String formulaContent;
// 字段类型
private String dataType;
// 小数位数
private Integer pattern;
// 小数位数
private String taxDeclarationColumn;
// 排序字段
private Integer sortedIndex;
// 是否可以编辑
private boolean canEdit;
// 是否可以删除
private boolean canDelete;
// 回算类型
private Integer backCalcType;
}

View File

@ -1,42 +1,47 @@
package com.engine.salary.entity.salarysob.param;
import com.engine.salary.enums.SalaryRoundingModeEnum;
import com.engine.salary.enums.SalaryValueTypeEnum;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Harryxzy
* @date 2022/11/16 15:14
* @description 薪资项目回算项目保存参数
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SalarySobBackItemSaveParam {
// @ApiModelProperty("主键id")
// @NotNull(message = "主键id不允许为空")
// @JsonSerialize(using = ToStringSerializer.class)
// private Long id;
//
// @NotNull(message = "薪资账套id不允许为空")
// @ApiModelProperty("薪资账套id")
// private Long salarySobId;
//
// @NotNull(message = "薪资项目id不允许为空")
// @ApiModelProperty("薪资项目")
// private Long salaryItemId;
//
// @ApiModelProperty("字段类型")
// @NotNull(message = "LABEL:105096")
// private SalaryDataTypeEnum dataType;
//
// @ApiModelProperty("舍入规则")
// private SalaryRoundingModeEnum roundingMode;
//
// @ApiModelProperty("保留小数位")
// @Max(value = 5, message = "LABEL:85611")
// private Integer pattern;
//
// @ApiModelProperty("取值方式")
// @NotNull(message = "LABEL:85612")
// private SalaryValueTypeEnum valueType;
//
// @ApiModelProperty("公式")
// private Long formulaId;
//
// @ApiModelProperty("备注")
// private String description;
// 主键id
private Long id;
// 薪资账套id
private Long salarySobId;
// 薪资项目
private Long salaryItemId;
// 字段类型
private SalaryDataTypeEnum dataType;
// 舍入规则
private SalaryRoundingModeEnum roundingMode;
// 保留小数位
private Integer pattern;
// 取值方式
private SalaryValueTypeEnum valueType;
// 公式
private Long formulaId;
// 备注
private String description;
}

View File

@ -3,6 +3,7 @@ package com.engine.salary.mapper.salarysob;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
@ -68,4 +69,15 @@ public interface SalarySobBackItemMapper {
int delete(SalarySobBackItemPO salarySobBackItem);
void batchInsert(@Param("collection") List<SalarySobBackItemPO> needInsertSalarySobBackItems);
/**
* @description 根据薪资账套获取回算薪资项目数
* @return Long
* @author Harryxzy
* @date 2022/11/18 13:57
*/
Long countBySalarySobIdIn(@Param("salarySobIdCollection")Collection<Long> salarySobIdCollection);
}

View File

@ -1,7 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.salarysob.SalarySobBackItemMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.salarysob.po.SalarySobBackItemPO">
<sql id="Base_Column_List">
id,
salary_sob_id,
salary_item_id,
salary_item_code,
data_type,
rounding_mode,
pattern,
value_type,
formula_id,
back_calc_type,
tenant_key,
creator,
delete_type,
create_time,
update_time
</sql><resultMap id="BaseResultMap" type="com.engine.salary.entity.salarysob.po.SalarySobBackItemPO">
<result column="id" property="id" />
<result column="salary_sob_id" property="salarySobId" />
<result column="salary_item_id" property="salaryItemId" />
@ -106,15 +122,18 @@
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
ORDER BY id DESC
</select>
<select id="count" resultType="java.lang.Integer">
select count(1) from hrsa_salary_sob_back_item;
</select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salarysob.po.SalarySobBackItemPO">
@ -343,5 +362,16 @@
WHERE id = #{id} AND delete_type = 0
</delete>
<!--根据薪资账套获取回算薪资项目数-->
<select id="countBySalarySobIdIn" resultType="java.lang.Long">
select count(1)
from hrsa_salary_sob_back_item
where salary_sob_id in
<foreach item="item" index="index" collection="salarySobIdCollection"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@ -1,7 +1,10 @@
package com.engine.salary.service;
import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO;
import com.engine.salary.entity.salarysob.param.SalarySobBackItemSaveParam;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import java.util.Collection;
import java.util.List;
/**
@ -19,6 +22,14 @@ public interface SalarySobBackItemService {
*/
List<SalarySobBackItemPO> listBySalarySobId(Long salarySobId);
/**
* @description 查询所有回算项目
* @return List<SalarySackItemPO>
* @author Harryxzy
* @date 2022/11/18 11:31
*/
List<SalarySobBackItemPO> listAll();
void batchInsert(List<SalarySobBackItemPO> needInsertSalarySobBackItems);
/**
@ -28,4 +39,22 @@ public interface SalarySobBackItemService {
* @date 2022/11/16 14:36
*/
SalarySobBackItemPO getById(Long salarySobBackItemId);
/**
* @description 保存薪资账套的回算项目
* @return List<SalarySackItemDTO>
* @author Harryxzy
* @date 2022/11/18 10:43
*/
List<SalarySobBackItemDTO> save(SalarySobBackItemSaveParam saveParam);
/**
* @description 获取回算薪资项目数
* @return Integer
* @author Harryxzy
* @date 2022/11/18 11:39
*/
Long getCountBySalarySobIdIn(Collection<Long> salarySobIds);
}

View File

@ -1,12 +1,32 @@
package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.bo.SalarySobBackItemBO;
import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO;
import com.engine.salary.entity.salarysob.param.SalarySobBackItemSaveParam;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.enums.SalaryValueTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobBackItemMapper;
import com.engine.salary.service.SalaryFormulaService;
import com.engine.salary.service.SalaryItemService;
import com.engine.salary.service.SalarySobBackItemService;
import com.engine.salary.service.SalarySobService;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* @author Harryxzy
@ -19,11 +39,28 @@ public class SalarySobBackItemServiceImpl extends Service implements SalarySobBa
return MapperProxyFactory.getProxy(SalarySobBackItemMapper.class);
}
private SalarySobService getSalarySobService(User user) {
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
}
private SalaryItemService getSalaryItemService(User user) {
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
private SalaryFormulaService getSalaryFormulaService(User user) {
return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
}
@Override
public List<SalarySobBackItemPO> listBySalarySobId(Long salarySobId) {
return getSalarySobBackItemMapper().listSome(SalarySobBackItemPO.builder().salarySobId(salarySobId).build());
}
@Override
public List<SalarySobBackItemPO> listAll() {
return getSalarySobBackItemMapper().listAll();
}
@Override
public void batchInsert(List<SalarySobBackItemPO> needInsertSalarySobBackItems) {
getSalarySobBackItemMapper().batchInsert(needInsertSalarySobBackItems);
@ -34,4 +71,38 @@ public class SalarySobBackItemServiceImpl extends Service implements SalarySobBa
return getSalarySobBackItemMapper().getById(salarySobBackItemId);
}
@Override
public List<SalarySobBackItemDTO> save(SalarySobBackItemSaveParam saveParam) {
// 查询薪资账套是否存在
SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId());
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除"));
}
// 查询薪资账套下的回算薪资项目
SalarySobBackItemPO salarySobBackItem = getById(saveParam.getId());
if (Objects.isNull(salarySobBackItem)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "回算薪资项目不存在或已被删除"));
}
// 查询薪资项目
SalaryItemPO salaryItem = getSalaryItemService(user).getById(saveParam.getSalaryItemId());
if (salaryItem == null) {
throw new SalaryRunTimeException("参数错误,项目不存在或已被删除");
}
salarySobBackItem.setRoundingMode(saveParam.getRoundingMode().getValue());
salarySobBackItem.setPattern(saveParam.getPattern());
salarySobBackItem.setValueType(saveParam.getValueType().getValue());
salarySobBackItem.setFormulaId(saveParam.getValueType() == SalaryValueTypeEnum.INPUT ? NumberUtils.LONG_ZERO : saveParam.getFormulaId());
salarySobBackItem.setUpdateTime(SalaryDateUtil.localDateTimeToDate(LocalDateTime.now()));
getSalarySobBackItemMapper().updateIgnoreNull(salarySobBackItem);
// 查询公式
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(Collections.singleton(salarySobBackItem.getFormulaId()));
return SalarySobBackItemBO.convert2DTO(Collections.singletonList(salarySobBackItem), Collections.singletonList(salaryItem), expressFormulas);
}
@Override
public Long getCountBySalarySobIdIn(Collection<Long> salarySobIds) {
return getSalarySobBackItemMapper().countBySalarySobIdIn(salarySobIds);
}
}

View File

@ -3,7 +3,6 @@ package com.engine.salary.util;
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.service.impl.SalarySobRangeServiceImpl;
import com.engine.workflow.util.CollectionUtil;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
@ -16,7 +15,6 @@ import java.util.List;
*/
public class SalarySobUtil {
// 处理历史数据将薪资账套中将关联人员状态转换为List
public static void handleEmployeeStatusHistory(){
// 根据薪资账套查询人员
@ -54,4 +52,6 @@ public class SalarySobUtil {
}
}

View File

@ -304,7 +304,6 @@ public class SalarySobController {
public String getSalarySobBackItemForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value ="id") Long id) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long,SalarySobBackItemFormDTO>(user).run(getSalarySobBackItemWrapper(user)::getForm, id);
}
/**
@ -318,8 +317,7 @@ public class SalarySobController {
@Produces(MediaType.APPLICATION_JSON)
public String saveSalarySobBackItem(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody SalarySobBackItemSaveParam saveParam) {
User user = HrmUserVarify.getUser(request, response);
// return new ResponseResult<SalarySobBackItemSaveParam,List<SalarySobBackItemDTO>>(user).run(getSalarySobBackItemWrapper(user)::save, saveParam);
return null;
return new ResponseResult<SalarySobBackItemSaveParam,List<SalarySobBackItemDTO>>(user).run(getSalarySobBackItemWrapper(user)::save, saveParam);
}
/**********************************薪资账套的回算项目 end*********************************/

View File

@ -6,7 +6,9 @@ import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobBackItemAggregateDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobBackItemFormDTO;
import com.engine.salary.entity.salarysob.param.SalarySobBackItemSaveParam;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.enums.SalaryRoundingModeEnum;
import com.engine.salary.enums.SalaryValueTypeEnum;
@ -125,4 +127,8 @@ public class SalarySobBackItemWrapper extends Service {
.taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItem.getCode())).build();
return salarySobBackItemFormDTO;
}
public List<SalarySobBackItemDTO> save(SalarySobBackItemSaveParam saveParam) {
return getSalarySobBackItemService(user).save(saveParam);
}
}

View File

@ -13,8 +13,10 @@ import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.SalarySobBackItemService;
import com.engine.salary.service.SalarySobService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.impl.SalarySobBackItemServiceImpl;
import com.engine.salary.service.impl.SalarySobServiceImpl;
import com.engine.salary.service.impl.TaxAgentServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
@ -44,6 +46,12 @@ public class SalarySobWrapper extends Service {
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalarySobBackItemService getSalarySobBackItemService(User user) {
return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user);
}
/**
* 薪资账套列表
*
@ -52,8 +60,10 @@ public class SalarySobWrapper extends Service {
*/
public PageInfo<SalarySobListDTO> listPage(SalarySobListQueryParam queryParam) {
// 处理历史数据将薪资账套中将关联人员状态转换为List
// 处理历史数据将薪资账套中将关联人员状态转换为List
SalarySobUtil.handleEmployeeStatusHistory();
// 处理历史数据为薪资账套默认添加回算薪资项目
// handleSalarySobBackItemHistory();
// 查询薪资账套
PageInfo<SalarySobPO> page = getSalarySobService(user).listPageByParam(queryParam);
@ -71,6 +81,15 @@ public class SalarySobWrapper extends Service {
return dtoPage;
}
// private void handleSalarySobBackItemHistory() {
// // 获取个税扣缴义务人下所有的薪资账套
// Long count = getSalarySobBackItemService(user).getCountBySalarySobIdIn();
// if(count.equals(0)){
// //没有回算薪资项目数据给所有薪资账套初始化
//
// }
// }
/**
* 薪资账套详情
*