自定义福利接口 getCustomCategoryForm createSICategory....

This commit is contained in:
Chengliang 2022-03-10 15:09:44 +08:00
parent 784f58533a
commit 04cf94e498
19 changed files with 574 additions and 11 deletions

View File

@ -1,13 +1,20 @@
package com.engine.salary.biz;
import com.engine.salary.entity.sicategory.bo.ICategoryBO;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.enums.sicategory.IsPaymentEnum;
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.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
@ -45,7 +52,7 @@ public class SICategoryBiz {
* @param id
* @return
*/
private ICategoryPO getByID(Long id) {
public ICategoryPO getByID(Long id) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class);
@ -56,4 +63,117 @@ public class SICategoryBiz {
sqlSession.close();
}
}
/**
* 保存
* @param iCategoryFormDTO
* @param employeeId DataTypeEnum.SYSTEM.getValue()
*/
public void save(ICategoryFormDTO iCategoryFormDTO, long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class);
List<ICategoryPO> iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName());
if (CollectionUtils.isNotEmpty(iCategoryPOS)) {
throw new SalaryRunTimeException("福利名称不允许重复");
}
ICategoryPO iCategoryPO = ICategoryBO.convertToInsuranceCategoryPO(iCategoryFormDTO, employeeId);
iCategoryMapper.insert(iCategoryPO);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
/**
* 根据名称获取
* @param insuranceName
* @return
*/
public List<ICategoryPO> listByName(String insuranceName) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try{
ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class);
List<ICategoryPO> iCategoryPOS = iCategoryMapper.listByName(insuranceName);
return iCategoryPOS;
} finally {
sqlSession.close();
}
}
/**
* 更新
* @param iCategoryFormDTO
* @param employeeId
*/
public void update(ICategoryFormDTO iCategoryFormDTO, long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try{
if (iCategoryFormDTO.getId() == null) {
throw new SalaryRunTimeException("id is required");
}
ICategoryPO iCategoryPO = getByID(iCategoryFormDTO.getId());
if (Objects.isNull(iCategoryPO)) {
throw new SalaryRunTimeException("数据不存在");
}
List<ICategoryPO> iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName());
if (CollectionUtils.isNotEmpty(iCategoryPOS)) {
throw new SalaryRunTimeException("福利名称不允许重复");
}
iCategoryPO.setInsuranceName(iCategoryFormDTO.getInsuranceName());
iCategoryPO.setWelfareType(iCategoryFormDTO.getWelfareType().getValue());
iCategoryPO.setPaymentScope(SalaryEnumUtil.enumArrToString(iCategoryFormDTO.getPaymentScope()));
iCategoryPO.setUpdateTime(new Date());
ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class);
iCategoryMapper.update(iCategoryPO);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
/**
* 更新状态
* @param id
* @param isUse
* @param employeeId
*/
public void updateStatusById(Long id, Integer isUse, long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
if(id == null) {
throw new SalaryRunTimeException("id is required");
}
if (isUse == null) {
throw new SalaryRunTimeException("isUse is required");
}
List<InsuranceSchemeDetailPO> insuranceSchemeDetailPOS = new SISchemeBiz().queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue());
if(CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) {
throw new SalaryRunTimeException("该福利开启缴费,不可删除(或停用");
}
ICategoryPO iCategoryPO = getByID(id);
if (Objects.isNull(iCategoryPO)) {
throw new SalaryRunTimeException("数据记录不存在");
}
iCategoryPO.setIsUse(isUse);
ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class);
iCategoryMapper.updateById(iCategoryPO);
sqlSession.commit();
}finally {
sqlSession.close();
}
}
}

View File

@ -138,6 +138,10 @@ public class SISchemeBiz {
}
//福利方案名称重复待写
List<InsuranceSchemePO> insuranceSchemePOList = insuranceSchemeMapper.listByName(updateParam.getInsuranceScheme().getSchemeName());
if (CollectionUtils.isNotEmpty(insuranceSchemePOList)) {
throw new SalaryRunTimeException("福利方案名称重复");
}
//更新福利方案主表
InsuranceSchemePO insuranceSchemePO1 = InsuranceSchemeBO.buildInsuranceSchemePO(insuranceSchemePO, updateParam.getInsuranceScheme());
@ -229,11 +233,27 @@ public class SISchemeBiz {
detailPOS.forEach(insuranceSchemeDetailMapper::insert);
}
sqlSession.commit();
}finally {
sqlSession.close();
}
}
/**
* 根据险种id和是否缴费查询社保方案明细表
* @param insuranceId 险种id
* @param isPayment 是否缴费
* @return list
*/
public List<InsuranceSchemeDetailPO> queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class);
List<InsuranceSchemeDetailPO> insuranceSchemeDetailPOList = insuranceSchemeDetailMapper.queryListByInsuranceIdIsPayment(insuranceId,isPayment);
return insuranceSchemeDetailPOList;
}finally {
sqlSession.close();
}
}
}

View File

@ -1,4 +1,4 @@
package com.engine.salary.cmd.sischeme;
package com.engine.salary.cmd.sicategory;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;

View File

@ -0,0 +1,39 @@
package com.engine.salary.cmd.sicategory;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.salary.biz.SICategoryBiz;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.Map;
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/3/9
* @Version V1.0
**/
public class SICategoryInsertCmd extends AbstractCommonCommand<Map<String, Object>> {
public SICategoryInsertCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> apidatas = new HashMap<>(16);
SICategoryBiz siCategoryBiz = new SICategoryBiz();
ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO)params.get("iCategoryFormDTO");
siCategoryBiz.save(iCategoryFormDTO,(long) user.getUID());
return apidatas;
}
}

View File

@ -0,0 +1,39 @@
package com.engine.salary.cmd.sicategory;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.salary.biz.SICategoryBiz;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.Map;
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/3/10
* @Version V1.0
**/
public class SICategoryUpdateCmd extends AbstractCommonCommand<Map<String, Object>> {
public SICategoryUpdateCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> apidatas = new HashMap<String, Object>(16);
SICategoryBiz siCategoryBiz = new SICategoryBiz();
ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO) params.get("iCategoryFormDTO");
siCategoryBiz.update(iCategoryFormDTO, (long) user.getUID());
return apidatas;
}
}

View File

@ -0,0 +1,40 @@
package com.engine.salary.cmd.sicategory;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.salary.biz.SICategoryBiz;
import com.engine.salary.entity.sicategory.param.UpdateStatusParam;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.Map;
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/3/10
* @Version V1.0
**/
public class SICategoryUpdateStatusByIdCmd extends AbstractCommonCommand<Map<String, Object>>{
public SICategoryUpdateStatusByIdCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> apidatas = new HashMap<String, Object>(16);
SICategoryBiz siCategoryBiz = new SICategoryBiz();
Long id = (Long) params.get("id");
Integer isUse = (Integer) params.get("isUse");
siCategoryBiz.updateStatusById(id, isUse,(long) user.getUID());
return apidatas;
}
}

View File

@ -0,0 +1,39 @@
package com.engine.salary.entity.sicategory.bo;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
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.util.SalaryEnumUtil;
import java.util.Date;
import java.util.Objects;
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/3/10
* @Version V1.0
**/
public class ICategoryBO {
public static ICategoryPO convertToInsuranceCategoryPO(ICategoryFormDTO dto, Long employeeId) {
if (Objects.isNull(dto)) {
return null;
}
return ICategoryPO.builder()
//.id(IdGenerator.generate())
.paymentScope(SalaryEnumUtil.enumArrToString(dto.getPaymentScope()))
.welfareType(dto.getWelfareType().getValue())
.insuranceName(dto.getInsuranceName())
.isUse(dto.getIsUse())
.dataType(DataTypeEnum.CUSTOM.getValue())
.createTime(new Date())
.updateTime(new Date())
.creator(employeeId)
.dataType(0)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
}
}

View File

@ -0,0 +1,29 @@
package com.engine.salary.entity.sicategory.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author weaver_cl
* @Description: TODO 自定义福利状态更新
* @Date 2022/3/10
* @Version V1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UpdateStatusParam {
/**
* id
*/
private Long id;
/**
* 状态
*/
private Integer isUse;
}

View File

@ -2,6 +2,8 @@ package com.engine.salary.mapper.sicategory;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import java.util.List;
/**
* @Author weaver_cl
* @Description: TODO
@ -18,4 +20,34 @@ public interface ICategoryMapper {
* @return 返回记录没有返回null
*/
ICategoryPO getById(Long id);
/**
* 根据福利名称获取
* @param insuranceName
* @return
*/
List<ICategoryPO> listByName(String insuranceName);
/**
* 新增插入所有字段
*
* @param iCategoryPO 新增的记录
* @return 返回影响行数
*/
int insert(ICategoryPO iCategoryPO);
/**
* 更新更新修改的字段
* @param iCategoryPO
* @return
*/
void update(ICategoryPO iCategoryPO);
/**
* 根据id更新状态
* @param iCategoryPO
*/
void updateById(ICategoryPO iCategoryPO);
}

View File

@ -39,6 +39,67 @@
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 插入全部字段 -->
<insert id="insert" parameterType="com.engine.salary.entity.sicategory.po.ICategoryPO"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_insurance_category
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
insurance_name,
welfare_type,
is_use,
payment_scope,
data_type,
create_time,
update_time,
creator,
delete_type,
tenant_key,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{id},
#{insuranceName},
#{welfareType},
#{isUse},
#{paymentScope},
#{dataType},
#{createTime},
#{updateTime},
#{creator},
#{deleteType},
#{tenantKey},
</trim>
</insert>
<select id="listByName" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_category t
WHERE insurance_name= #{insuranceName} AND delete_type = 0
ORDER BY id DESC
</select>
<!-- 更新,更新修改字段 -->
<update id="update" parameterType="com.engine.salary.entity.sicategory.po.ICategoryPO">
UPDATE hrsa_insurance_category
<set>
update_time=#{updateTime},
insurance_name=#{insuranceName},
welfare_type=#{welfareType},
payment_scope=#{paymentScope},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新状态 -->
<update id="updateById" parameterType="com.engine.salary.entity.sicategory.po.ICategoryPO">
UPDATE hrsa_insurance_category
SET is_use = #{isUse}
WHERE id = #{id}
</update>
</mapper>

View File

@ -14,7 +14,11 @@ import java.util.List;
**/
public interface InsuranceSchemeDetailMapper {
/**
* 查询当前方案下面配置的福利类型明细
*
* @return list
*/
List<InsuranceSchemeDetailPO> listByPrimaryId(Long primaryId);
/**
@ -31,4 +35,14 @@ public interface InsuranceSchemeDetailMapper {
* @param primaryIds
*/
void batchDeleteByPrimaryIds(@Param("primaryIds") Collection<Long> primaryIds);
/**
* 根据险种id和是否缴费查询社保方案明细表
*
* @param insuranceId 险种id
* @param isPayment 是否缴费
* @return list
*/
List<InsuranceSchemeDetailPO> queryListByInsuranceIdIsPayment(@Param("insuranceId") Long insuranceId, @Param("isPayment") Integer isPayment);
}

View File

@ -110,6 +110,14 @@
</foreach>
</update>
<!-- 根据险种id和是否缴费查询社保方案明细表 -->
<select id="queryListByInsuranceIdIsPayment" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t
WHERE t.insuranceId = #{insuranceId} AND t.is_payment = #{isPayment} AND delete_type = 0
</select>
</mapper>

View File

@ -2,6 +2,8 @@ package com.engine.salary.mapper.sischeme;
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
import java.util.List;
/**
* @Author weaver_cl
* @Description: TODO
@ -31,4 +33,11 @@ public interface InsuranceSchemeMapper {
* @return
*/
int update(InsuranceSchemePO insuranceSchemePO);
/**
* 根据名称查询
* @param schemeName
* @return
*/
List<InsuranceSchemePO> listByName(String schemeName);
}

View File

@ -41,6 +41,16 @@
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 根据名称获取记录 -->
<select id="listByName" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_social_security_scheme t
WHERE scheme_name = #{schemeName} AND delete_type = 0
ORDER BY id DESC
</select>
<!-- 插入全部字段 -->
<insert id="insert" parameterType="com.engine.salary.entity.sischeme.po.InsuranceSchemePO"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"

View File

@ -11,4 +11,10 @@ import java.util.Map;
public interface SICategoryService {
Map<String, Object> getForm(Map<String, Object> params);
Map<String, Object> insert(Map<String, Object> params);
Map<String, Object> update(Map<String, Object> params);
Map<String, Object> updateStatusById(Map<String, Object> params);
}

View File

@ -1,5 +1,8 @@
package com.engine.salary.service;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import java.util.List;
import java.util.Map;
/**
@ -19,4 +22,6 @@ public interface SISchemeService {
Map<String, Object> delete(Map<String, Object> params);
Map<String, Object> copyScheme(Map<String, Object> params);
List<InsuranceSchemeDetailPO> queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment);
}

View File

@ -1,7 +1,10 @@
package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
import com.engine.salary.cmd.sischeme.SICategoryGetFormCmd;
import com.engine.salary.cmd.sicategory.SICategoryGetFormCmd;
import com.engine.salary.cmd.sicategory.SICategoryInsertCmd;
import com.engine.salary.cmd.sicategory.SICategoryUpdateCmd;
import com.engine.salary.cmd.sicategory.SICategoryUpdateStatusByIdCmd;
import com.engine.salary.service.SICategoryService;
import java.util.Map;
@ -18,4 +21,19 @@ public class SICategoryServiceImpl extends Service implements SICategoryService
public Map<String, Object> getForm(Map<String, Object> params) {
return commandExecutor.execute(new SICategoryGetFormCmd(params,user));
}
@Override
public Map<String, Object> insert(Map<String, Object> params) {
return commandExecutor.execute(new SICategoryInsertCmd(params,user));
}
@Override
public Map<String, Object> update(Map<String, Object> params) {
return commandExecutor.execute(new SICategoryUpdateCmd(params,user));
}
@Override
public Map<String, Object> updateStatusById(Map<String, Object> params) {
return commandExecutor.execute(new SICategoryUpdateStatusByIdCmd(params,user));
}
}

View File

@ -1,9 +1,12 @@
package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SISchemeBiz;
import com.engine.salary.cmd.sischeme.*;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.service.SISchemeService;
import java.util.List;
import java.util.Map;
/**
@ -38,4 +41,9 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
public Map<String, Object> copyScheme(Map<String, Object> params) {
return commandExecutor.execute(new SISchemeCopyCmd(params,user));
}
@Override
public List<InsuranceSchemeDetailPO> queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment) {
return new SISchemeBiz().queryListByInsuranceIdIsPayment(insuranceId,isPayment);
}
}

View File

@ -2,20 +2,21 @@ package com.engine.salary.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import com.engine.salary.entity.sicategory.param.UpdateStatusParam;
import com.engine.salary.service.SICategoryService;
import com.engine.salary.service.impl.SICategoryServiceImpl;
import com.engine.salary.util.ResponseResult;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
import java.util.Map;
/**
@ -38,7 +39,7 @@ public class SICategoryController {
* @return
*/
@GET
@Path("/getForm")
@Path("/customCategoryForm")
@Produces(MediaType.APPLICATION_JSON)
public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam(value = "id") Long id) {
@ -47,4 +48,69 @@ public class SICategoryController {
map.put("id",id);
return ResponseResult.run(getService(user)::getForm, map);
}
/**
* 新增
* @param request
* @param response
* @return
*/
@POST
@Path("/createSICategory")
@Produces(MediaType.APPLICATION_JSON)
public String insert(@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 ResponseResult.run(getService(user)::insert, map);
}
/**
* 编辑
* @param request
* @param response
* @param iCategoryFormDTO
* @return
*/
@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 ResponseResult.run(getService(user)::update, map);
}
/**
* 该接口暂时没用删除福利类型对档案和台账核算都有很大的影响暂时还没考虑好怎么做
* 删除福利类型
*
* @param request
* @param response
* @return
*/
@POST
@Path("/deleteCustomCategory")
@Produces(MediaType.APPLICATION_JSON)
public String deleteSoftById(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return null;
//return ResponseResult.run(getService(user)::delete, map);
}
@POST
@Path("/updateCustomCategoryStatus")
@Produces(MediaType.APPLICATION_JSON)
public String updateStatusById(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody UpdateStatusParam updateStatusParam) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("id",updateStatusParam.getId());
map.put("isUse",updateStatusParam.getIsUse());
return ResponseResult.run(getService(user)::updateStatusById, map);
}
}