Merge remote-tracking branch 'remotes/origin/develop' into feature/addSiArchivesBaseInfo_sy

This commit is contained in:
sy 2022-10-14 16:34:25 +08:00
commit 3d714c2b8d
10 changed files with 227 additions and 13 deletions

View File

@ -8,7 +8,6 @@ import com.engine.salary.enums.sicategory.IsPaymentEnum;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.util.SalaryEnumUtil;
import com.mzlion.core.utils.BeanUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -133,8 +132,8 @@ public class SICategoryBiz {
}
iCategoryPO.setInsuranceName(iCategoryFormDTO.getInsuranceName());
iCategoryPO.setWelfareType(iCategoryFormDTO.getWelfareType().getValue());
iCategoryPO.setPaymentScope(SalaryEnumUtil.enumArrToString(iCategoryFormDTO.getPaymentScope()));
// iCategoryPO.setWelfareType(iCategoryFormDTO.getWelfareType().getValue());
// iCategoryPO.setPaymentScope(SalaryEnumUtil.enumArrToString(iCategoryFormDTO.getPaymentScope()));
iCategoryPO.setUpdateTime(new Date());
ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class);
iCategoryMapper.update(iCategoryPO);

View File

@ -0,0 +1,53 @@
package com.engine.salary.entity.sicategory.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Harryxzy
* @date 2022/10/14 13:54
* @description
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ICategoryDTO {
/**
* 主键id
*/
private Long id;
/**
* 福利名称
*/
private String insuranceName;
/**
* 福利类型
*/
private Integer welfareType;
/**
* 福利类型
*/
private String welfareTypeSpan;
/**
* 缴纳对象
*/
private String paymentScope;
/**
* 缴纳对象
*/
private String paymentScopeSpan;
/**
* 是否启用
*/
private Integer isUse;
}

View File

@ -3,6 +3,8 @@ package com.engine.salary.enums.sicategory;
import com.engine.salary.enums.BaseEnum;
import java.util.Arrays;
public enum PaymentScopeEnum implements BaseEnum<Integer> {
SCOPE_COMPANY(1, "公司", 87158),
SCOPE_PERSON(2, "个人", 87159);
@ -28,4 +30,17 @@ public enum PaymentScopeEnum implements BaseEnum<Integer> {
public String getDefaultLabel() {
return this.defaultLable;
}
public static String getDefaultLabelByValue(Integer value){
if (value == null) {
return "";
};
PaymentScopeEnum[] enumAry = PaymentScopeEnum.values();
for(int i = 0; i < Arrays.asList(enumAry).size(); i++){
if (Integer.valueOf(enumAry[i].getValue()).equals(value)) {
return enumAry[i].getDefaultLabel();
}
}
return "";
}
}

View File

@ -2,6 +2,8 @@ package com.engine.salary.enums.sicategory;
import com.engine.salary.enums.BaseEnum;
import java.util.Arrays;
public enum WelfareTypeEnum implements BaseEnum<Integer> {
SOCIAL_SECURITY(1, "社保", 86568),
@ -35,4 +37,17 @@ public enum WelfareTypeEnum implements BaseEnum<Integer> {
public String getDefaultLabel() {
return this.defaultLabel;
}
public static String getDefaultLabelByValue(Integer value){
if (value == null) {
return "";
};
WelfareTypeEnum[] enumAry = WelfareTypeEnum.values();
for(int i = 0; i < Arrays.asList(enumAry).size(); i++){
if (Integer.valueOf(enumAry[i].getValue()).equals(value)) {
return enumAry[i].getDefaultLabel();
}
}
return "";
}
}

View File

@ -23,6 +23,9 @@ public interface ICategoryMapper {
ICategoryPO getById(Long id);
ICategoryPO getByIdAndDataType(@Param("id") Long id,@Param("dataType") Integer dataType);
/**
* 查询所有
* @return
@ -59,6 +62,13 @@ public interface ICategoryMapper {
*/
void updateById(ICategoryPO iCategoryPO);
/**
* 根据id更新福利名称
* @param iCategoryPO
*/
void updateNameById(ICategoryPO iCategoryPO);
/**
* 根据类型查询福利类型
*
@ -73,4 +83,6 @@ public interface ICategoryMapper {
* @return
*/
List<ICategoryPO> listByDataType(@Param("dataType") Integer dataType);
void getByName(String insuranceName);
}

View File

@ -145,6 +145,13 @@
WHERE delete_type = 0
</select>
<select id="getByIdAndDataType" resultType="com.engine.salary.entity.sicategory.po.ICategoryPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_category t
WHERE id = #{id} AND data_type = #{dataType} AND delete_type = 0
</select>
<!-- 更新,更新修改字段 -->
<update id="update" parameterType="com.engine.salary.entity.sicategory.po.ICategoryPO">
UPDATE hrsa_insurance_category
@ -163,7 +170,12 @@
SET is_use = #{isUse}
WHERE id = #{id}
</update>
<!--更新自定义福利名称-->
<update id="updateNameById">
UPDATE hrsa_insurance_category
SET insurance_name = #{insuranceName}
WHERE id = #{id} AND data_type = 0
</update>
</mapper>

View File

@ -1,5 +1,7 @@
package com.engine.salary.service;
import com.engine.salary.entity.sicategory.dto.ICategoryDTO;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import java.util.Map;
@ -37,4 +39,20 @@ public interface SICategoryService {
* @return map
*/
Map<String, String> categoryIdNameMap();
/**
* @description 根据ID获取自定义福利
* @return void
* @author Harryxzy
* @date 2022/10/14 11:40
*/
ICategoryDTO getByID(Long customCategoryId);
/***
* @description 修改自定义福利 名称
* @return void
* @author Harryxzy
* @date 2022/10/14 14:50
*/
Map<String, Object> updateCategoryName(ICategoryFormDTO iCategoryFormDTO);
}

View File

@ -2,13 +2,24 @@ package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
import com.engine.salary.cmd.sicategory.*;
import com.engine.salary.entity.sicategory.dto.ICategoryDTO;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.enums.sicategory.DataTypeEnum;
import com.engine.salary.enums.sicategory.PaymentScopeEnum;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.service.SICategoryService;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -75,4 +86,42 @@ public class SICategoryServiceImpl extends Service implements SICategoryService
return result;
}
@Override
public ICategoryDTO getByID(Long customCategoryId) {
ICategoryPO categoryPO = getICategoryMapper().getByIdAndDataType(customCategoryId, DataTypeEnum.CUSTOM.getValue());
ICategoryDTO categoryDTO = convertICategoryPO2DTO(categoryPO);
return categoryDTO;
}
@Override
public Map<String, Object> updateCategoryName(ICategoryFormDTO iCategoryFormDTO) {
ICategoryPO categoryPO = getICategoryMapper().getByIdAndDataType(iCategoryFormDTO.getId(), DataTypeEnum.CUSTOM.getValue());
if(categoryPO == null){
throw new SalaryRunTimeException("自定义福利不存在");
}
// 判断福利名称是否重复
List<ICategoryPO> iCategoryPOS = getICategoryMapper().listByName(iCategoryFormDTO.getInsuranceName());
if(CollectionUtils.isNotEmpty(iCategoryPOS)){
throw new SalaryRunTimeException("福利名称不能重复");
}
ICategoryPO iCategoryPO = ICategoryPO.builder().id(iCategoryFormDTO.getId()).insuranceName(iCategoryFormDTO.getInsuranceName()).build();
getICategoryMapper().updateNameById(iCategoryPO);
return null;
}
private ICategoryDTO convertICategoryPO2DTO(ICategoryPO iCategoryPO){
return ICategoryDTO.builder().id(iCategoryPO.getId()).insuranceName(iCategoryPO.getInsuranceName())
.welfareType(iCategoryPO.getWelfareType())
.welfareTypeSpan(WelfareTypeEnum.getDefaultLabelByValue(iCategoryPO.getWelfareType()))
.paymentScope(iCategoryPO.getPaymentScope())
.paymentScopeSpan(buildPaymentScope(iCategoryPO.getPaymentScope()))
.isUse(iCategoryPO.getIsUse()).build();
}
private String buildPaymentScope(String paymentScope) {
List<String> paymentScopes = Arrays.asList(paymentScope.split(","));
List<String> collect = paymentScopes.stream().map(scope -> PaymentScopeEnum.getDefaultLabelByValue(SalaryEntityUtil.string2Integer(scope))).collect(Collectors.toList());
return StringUtils.join(collect, ",");
}
}

View File

@ -258,6 +258,19 @@ public class SalaryEntityUtil {
return null;
}
/**
* String转Integer
*
* @param obj
* @return
*/
public static Integer string2Integer(String obj) {
if (NumberUtils.isCreatable(obj)) {
return Integer.valueOf(obj);
}
return null;
}
/**
* String转BigDecimal
*

View File

@ -2,6 +2,7 @@ package com.engine.salary.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.sicategory.dto.ICategoryDTO;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import com.engine.salary.entity.sicategory.param.UpdateStatusParam;
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO;
@ -86,23 +87,50 @@ public class SICategoryController {
return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::insert, map);
}
/**
* 编辑
* @param request
* @param response
* @param iCategoryFormDTO
* @return
* @description 获取指定自定义福利信息
* @return String
* @author Harryxzy
* @date 2022/10/14 11:34
*/
@POST
@Path("/updateCustomCategory")
@Path("/getCustomCategoryByID")
@Produces(MediaType.APPLICATION_JSON)
public String update(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) {
public String getCustomCategoryByID(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult< Long, ICategoryDTO>(user).run(getService(user)::getByID, iCategoryFormDTO.getId());
}
/**
* @description 编辑自定义福利名称
* @return String
* @author Harryxzy
* @date 2022/10/14 11:37
*/
@POST
@Path("/updateCustomCategoryName")
@Produces(MediaType.APPLICATION_JSON)
public String updateCustomCategoryName(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("iCategoryFormDTO",iCategoryFormDTO);
return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::update, map);
return new ResponseResult< ICategoryFormDTO, Map<String, Object>>(user).run(getService(user)::updateCategoryName, iCategoryFormDTO);
}
// @POST
// @Path("/updateCustomCategory")
// @Produces(MediaType.APPLICATION_JSON)
// public String update(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) {
// User user = HrmUserVarify.getUser(request, response);
// Map<String, Object> map = ParamUtil.request2Map(request);
// map.put("iCategoryFormDTO",iCategoryFormDTO);
// return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::update, map);
// }
/**
* 该接口暂时没用删除福利类型对档案和台账核算都有很大的影响暂时还没考虑好怎么做
* 删除福利类型