diff --git a/src/com/engine/salary/biz/SICategoryBiz.java b/src/com/engine/salary/biz/SICategoryBiz.java index 6311c02b9..36cb4f218 100644 --- a/src/com/engine/salary/biz/SICategoryBiz.java +++ b/src/com/engine/salary/biz/SICategoryBiz.java @@ -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); diff --git a/src/com/engine/salary/entity/sicategory/dto/ICategoryDTO.java b/src/com/engine/salary/entity/sicategory/dto/ICategoryDTO.java new file mode 100644 index 000000000..b63254f4c --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/dto/ICategoryDTO.java @@ -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; +} diff --git a/src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java b/src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java index 5510fcfda..0a4cdd74b 100644 --- a/src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java +++ b/src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java @@ -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 { SCOPE_COMPANY(1, "公司", 87158), SCOPE_PERSON(2, "个人", 87159); @@ -28,4 +30,17 @@ public enum PaymentScopeEnum implements BaseEnum { 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 ""; + } } diff --git a/src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java b/src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java index 86424cbd7..fea16dc65 100644 --- a/src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java +++ b/src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java @@ -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 { SOCIAL_SECURITY(1, "社保", 86568), @@ -35,4 +37,17 @@ public enum WelfareTypeEnum implements BaseEnum { 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 ""; + } } diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java index cf3ed47ca..e1e7ea54c 100644 --- a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java @@ -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 listByDataType(@Param("dataType") Integer dataType); + + void getByName(String insuranceName); } diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml index d41ca1336..fa2b9e87b 100644 --- a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml @@ -145,6 +145,13 @@ WHERE delete_type = 0 + + UPDATE hrsa_insurance_category @@ -163,7 +170,12 @@ SET is_use = #{isUse} WHERE id = #{id} - + + + UPDATE hrsa_insurance_category + SET insurance_name = #{insuranceName} + WHERE id = #{id} AND data_type = 0 + \ No newline at end of file diff --git a/src/com/engine/salary/service/SICategoryService.java b/src/com/engine/salary/service/SICategoryService.java index 9f5cf2102..5b2ba05f8 100644 --- a/src/com/engine/salary/service/SICategoryService.java +++ b/src/com/engine/salary/service/SICategoryService.java @@ -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 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 updateCategoryName(ICategoryFormDTO iCategoryFormDTO); } diff --git a/src/com/engine/salary/service/impl/SICategoryServiceImpl.java b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java index ee6a04515..fefa94652 100644 --- a/src/com/engine/salary/service/impl/SICategoryServiceImpl.java +++ b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java @@ -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 updateCategoryName(ICategoryFormDTO iCategoryFormDTO) { + ICategoryPO categoryPO = getICategoryMapper().getByIdAndDataType(iCategoryFormDTO.getId(), DataTypeEnum.CUSTOM.getValue()); + if(categoryPO == null){ + throw new SalaryRunTimeException("自定义福利不存在"); + } + // 判断福利名称是否重复 + List 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 paymentScopes = Arrays.asList(paymentScope.split(",")); + List collect = paymentScopes.stream().map(scope -> PaymentScopeEnum.getDefaultLabelByValue(SalaryEntityUtil.string2Integer(scope))).collect(Collectors.toList()); + return StringUtils.join(collect, ","); + } } diff --git a/src/com/engine/salary/util/SalaryEntityUtil.java b/src/com/engine/salary/util/SalaryEntityUtil.java index 6a38480f1..6f172cecb 100644 --- a/src/com/engine/salary/util/SalaryEntityUtil.java +++ b/src/com/engine/salary/util/SalaryEntityUtil.java @@ -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 * diff --git a/src/com/engine/salary/web/SICategoryController.java b/src/com/engine/salary/web/SICategoryController.java index 866fd6dd4..8bab23fd4 100644 --- a/src/com/engine/salary/web/SICategoryController.java +++ b/src/com/engine/salary/web/SICategoryController.java @@ -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, Map>(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 map = ParamUtil.request2Map(request); - map.put("iCategoryFormDTO",iCategoryFormDTO); - return new ResponseResult< Map, Map>(user).run(getService(user)::update, map); + return new ResponseResult< ICategoryFormDTO, Map>(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 map = ParamUtil.request2Map(request); +// map.put("iCategoryFormDTO",iCategoryFormDTO); +// return new ResponseResult< Map, Map>(user).run(getService(user)::update, map); +// } + + /** * 该接口暂时没用,删除福利类型对档案和台账核算都有很大的影响,暂时还没考虑好怎么做 * 删除福利类型