福利模块getForm接口
This commit is contained in:
parent
ce6a8cec69
commit
2b61b030d7
|
|
@ -8,3 +8,6 @@ target/
|
|||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
|
||||
/src/test
|
||||
/src/META-INF
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.api.salary.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Path("/bs/hrmsalary/scheme/")
|
||||
public class SISchemeController extends com.engine.salary.web.SISchemeController {
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.engine.salary.biz;
|
||||
|
||||
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO;
|
||||
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
|
||||
import com.engine.salary.entity.sischeme.vo.InsuranceSchemeFormVO;
|
||||
|
||||
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
|
||||
|
||||
import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper;
|
||||
import com.engine.salary.util.PoToDtoUtil;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import weaver.conn.mybatis.MyBatisFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class SISchemeBiz {
|
||||
|
||||
|
||||
/**
|
||||
* 获取社保方案
|
||||
* @param id
|
||||
* @param welfareType
|
||||
* @return
|
||||
*/
|
||||
public InsuranceSchemeFormVO getForm(Long id, WelfareTypeEnum welfareType) {
|
||||
|
||||
try {
|
||||
if (id != null) {
|
||||
//查询社保方案基础信息表单
|
||||
InsuranceSchemePO insuranceSchemePO = getById(id);
|
||||
InsuranceSchemeDTO insuranceSchemeDTO = new InsuranceSchemeDTO();
|
||||
insuranceSchemeDTO = (InsuranceSchemeDTO)PoToDtoUtil.poToDto(insuranceSchemePO,insuranceSchemeDTO);
|
||||
return InsuranceSchemeFormVO.builder().schemeBatch(insuranceSchemeDTO).build();
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return InsuranceSchemeFormVO.builder().build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private InsuranceSchemePO getById(Long id) {
|
||||
|
||||
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
||||
try {
|
||||
InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class);
|
||||
InsuranceSchemePO insuranceSchemePO = insuranceSchemeMapper.getById(id);
|
||||
|
||||
return insuranceSchemePO;
|
||||
} finally {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.engine.salary.cmd.sischeme;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.salary.biz.SISchemeBiz;
|
||||
import com.engine.salary.entity.sischeme.vo.InsuranceSchemeFormVO;
|
||||
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class SISchemeGetFormCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
public SISchemeGetFormCmd(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);
|
||||
SISchemeBiz siSchemeBiz = new SISchemeBiz();
|
||||
Long id = Long.valueOf(Util.null2String(params.get("id")));
|
||||
WelfareTypeEnum welfareType = (WelfareTypeEnum)params.get("welfareTypeEnum");
|
||||
InsuranceSchemeFormVO form = siSchemeBiz.getForm(id, welfareType);
|
||||
apidatas.put("form",form);
|
||||
return apidatas;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.engine.salary.entity.sischeme.dto;
|
||||
|
||||
import com.engine.salary.enums.sicategory.PaymentTypeEnum;
|
||||
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO 社保方案基础信息表单
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InsuranceSchemeDTO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 缴纳地区
|
||||
*/
|
||||
private String paymentArea;
|
||||
|
||||
/**
|
||||
* 缴纳类型
|
||||
*/
|
||||
private PaymentTypeEnum paymentType;
|
||||
|
||||
/**
|
||||
* 方案名称
|
||||
*/
|
||||
private String schemeName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 福利类型
|
||||
*/
|
||||
private WelfareTypeEnum welfareType;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package com.engine.salary.entity.sischeme.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO 福利方案明细表单
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InsuranceSchemeDetailDTO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 社保方案主表id
|
||||
*/
|
||||
private Long primaryId;
|
||||
|
||||
/**
|
||||
* 险种id
|
||||
*/
|
||||
private Long insuranceId;
|
||||
|
||||
/**
|
||||
* 险种名称
|
||||
*/
|
||||
private String insuranceName;
|
||||
|
||||
/**
|
||||
* 是否缴费
|
||||
*/
|
||||
private Boolean isPayment;
|
||||
|
||||
/**
|
||||
* 生效年月(含)
|
||||
*/
|
||||
private String effectiveTime;
|
||||
|
||||
/**
|
||||
* 失效年月(不含)
|
||||
*/
|
||||
private String expirationTime;
|
||||
|
||||
/**
|
||||
* 缴纳对象枚举label 1-公司 2-个人
|
||||
*/
|
||||
private String paymentScope;
|
||||
|
||||
/**
|
||||
* 缴纳对象枚举value 1-公司 2-个人
|
||||
*/
|
||||
private Integer paymentScopeValue;
|
||||
|
||||
/**
|
||||
* 基数上限
|
||||
*/
|
||||
private BigDecimal upperLimit;
|
||||
|
||||
/**
|
||||
* 基数下限
|
||||
*/
|
||||
private BigDecimal lowerLimit;
|
||||
|
||||
/**
|
||||
* 缴纳比例
|
||||
*/
|
||||
private BigDecimal paymentProportion;
|
||||
|
||||
/**
|
||||
* 固定费用
|
||||
*/
|
||||
private BigDecimal fixedCost;
|
||||
|
||||
/**
|
||||
* 有效小数位
|
||||
*/
|
||||
private Integer validNum;
|
||||
|
||||
/**
|
||||
* 进位规则
|
||||
*/
|
||||
private String rententionRule;
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package com.engine.salary.entity.sischeme.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO hrsa_social_security_scheme 社保方案主表
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InsuranceSchemePO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 缴纳地区
|
||||
*/
|
||||
private String paymentArea;
|
||||
|
||||
/**
|
||||
* 方案名称
|
||||
*/
|
||||
private String schemeName;
|
||||
|
||||
/**
|
||||
* 缴纳类型
|
||||
*/
|
||||
private Integer paymentType;
|
||||
|
||||
/**
|
||||
* 福利类型
|
||||
*/
|
||||
private Integer welfareType;
|
||||
|
||||
/**
|
||||
* 是否启用 0-停用 1-启用
|
||||
*/
|
||||
private Integer isUse;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer deleteType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 租户key
|
||||
*/
|
||||
private String tenantKey;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.engine.salary.entity.sischeme.vo;
|
||||
|
||||
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO;
|
||||
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InsuranceSchemeFormVO {
|
||||
|
||||
//福利方案基本设置
|
||||
private InsuranceSchemeDTO schemeBatch;
|
||||
|
||||
//福利方案设置
|
||||
private List<InsuranceSchemeDetailDTO> schemeDetailList;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.engine.salary.mapper.sischeme;
|
||||
|
||||
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
public interface InsuranceSchemeMapper {
|
||||
|
||||
InsuranceSchemePO getById(Long id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?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.sischeme.InsuranceSchemeMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.salary.entity.sischeme.po.InsuranceSchemePO">
|
||||
<result column="id" property="id"/>
|
||||
<result column="payment_area" property="paymentArea"/>
|
||||
<result column="payment_type" property="paymentType"/>
|
||||
<result column="schemeName" property="schemeName"/>
|
||||
<result column="welfare_type" property="welfareType"/>
|
||||
<result column="is_use" property="isUse"/>
|
||||
<result column="remarks" property="remarks"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="delete_type" property="deleteType"/>
|
||||
<result column="tenant_key" property="tenantKey"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.payment_area
|
||||
, t.payment_type
|
||||
, t.schemeName
|
||||
, t.welfare_type
|
||||
, t.is_use
|
||||
, t.remarks
|
||||
, t.create_time
|
||||
, t.update_time
|
||||
, t.creator
|
||||
, t.delete_type
|
||||
, t.tenant_key
|
||||
</sql>
|
||||
|
||||
|
||||
<!-- 根据主键获取单条记录 -->
|
||||
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_social_security_scheme t
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
public interface SISchemeService {
|
||||
|
||||
Map<String, Object> getForm(Map<String, Object> params);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.cmd.sischeme.SISchemeGetFormCmd;
|
||||
import com.engine.salary.service.SISchemeService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class SISchemeServiceImpl extends Service implements SISchemeService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getForm(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new SISchemeGetFormCmd(params,user));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.engine.salary.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class PoToDtoUtil {
|
||||
/**
|
||||
* 将po对象的属性值赋值给dto对象相同属性名的属性
|
||||
* 此方法能将第一个转第二个无论是否DTO
|
||||
* @param po 赋值的对象
|
||||
* @param dto 被赋值的对象
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Object poToDto(Object po, Object dto) throws Exception {
|
||||
Class poClass = po.getClass();
|
||||
Class dtoClass = dto.getClass();
|
||||
// 取得po对象的所有属性
|
||||
Field[] poFields = poClass.getDeclaredFields();
|
||||
//取父类的所有属性
|
||||
Field[] superPoFields = poClass.getSuperclass().getDeclaredFields();
|
||||
//合并数组
|
||||
poFields = (Field[]) mergeArray(poFields,superPoFields);
|
||||
|
||||
// 遍历拼接dto的set方法字段表示
|
||||
for (Field f : poFields) {
|
||||
String fieldName = f.getName();
|
||||
//取得当前get,set字符串表达形式
|
||||
String dtoSetMethodName = "set" + firstToBig(fieldName);
|
||||
String poGetMethodName = "get"+firstToBig(fieldName);
|
||||
|
||||
//System.out.println(fieldName + "=====" + dtoSetMethodName);
|
||||
// 取得DTO对象的set方法
|
||||
Method dtoSetMethod=null;
|
||||
try {
|
||||
dtoSetMethod = dtoClass.getMethod(dtoSetMethodName, f.getType());
|
||||
}catch (NoSuchMethodException e) {//如果不存在此方法跳过,
|
||||
continue;
|
||||
}
|
||||
//取得Po对象的get方法
|
||||
Method poGetMethod = poClass.getMethod(poGetMethodName, null);
|
||||
// 将po对象的属性值set到dto对象中去
|
||||
dtoSetMethod.invoke(dto, poGetMethod.invoke(po, null));
|
||||
}
|
||||
return dto;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并数组
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
public static Object[] mergeArray(Object[] a,Object[] b) {
|
||||
Object[] c = Arrays.copyOf(a, a.length+b.length);
|
||||
System.arraycopy(b, 0, c, a.length, b.length);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首字母大写
|
||||
*
|
||||
* @param fieldName
|
||||
* @return
|
||||
*/
|
||||
public static String firstToBig(String fieldName) {
|
||||
if (fieldName != null && fieldName != "") {
|
||||
fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
|
||||
}
|
||||
return fieldName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.engine.salary.web;
|
||||
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.service.SISchemeService;
|
||||
import com.engine.salary.service.impl.SISchemeServiceImpl;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
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.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
* @Date 2022/3/7
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class SISchemeController {
|
||||
|
||||
private SISchemeService getService(User user) {
|
||||
return ServiceUtil.getService(SISchemeServiceImpl.class,user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询福利方案表单
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/getForm")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ResponseResult.run(getService(user)::getForm, ParamUtil.request2Map(request));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue