diff --git a/.gitignore b/.gitignore index 40148cdcd..25c382a22 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ target/ ### IntelliJ IDEA ### .idea +/src/test +/src/META-INF + diff --git a/src/com/api/salary/web/SISchemeController.java b/src/com/api/salary/web/SISchemeController.java new file mode 100644 index 000000000..48509bc54 --- /dev/null +++ b/src/com/api/salary/web/SISchemeController.java @@ -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 { +} diff --git a/src/com/engine/salary/biz/SISchemeBiz.java b/src/com/engine/salary/biz/SISchemeBiz.java new file mode 100644 index 000000000..a3ae82f25 --- /dev/null +++ b/src/com/engine/salary/biz/SISchemeBiz.java @@ -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(); + } + } +} diff --git a/src/com/engine/salary/cmd/sischeme/SISchemeGetFormCmd.java b/src/com/engine/salary/cmd/sischeme/SISchemeGetFormCmd.java new file mode 100644 index 000000000..1ed8c8a0c --- /dev/null +++ b/src/com/engine/salary/cmd/sischeme/SISchemeGetFormCmd.java @@ -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> { + + public SISchemeGetFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map 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; + } +} diff --git a/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDTO.java b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDTO.java new file mode 100644 index 000000000..af6916e70 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDTO.java @@ -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; + + + +} + diff --git a/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDetailDTO.java b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDetailDTO.java new file mode 100644 index 000000000..16ff6e206 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDetailDTO.java @@ -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; +} diff --git a/src/com/engine/salary/entity/sischeme/po/InsuranceSchemePO.java b/src/com/engine/salary/entity/sischeme/po/InsuranceSchemePO.java new file mode 100644 index 000000000..1ec074190 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/po/InsuranceSchemePO.java @@ -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; +} diff --git a/src/com/engine/salary/entity/sischeme/vo/InsuranceSchemeFormVO.java b/src/com/engine/salary/entity/sischeme/vo/InsuranceSchemeFormVO.java new file mode 100644 index 000000000..1fa351a08 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/vo/InsuranceSchemeFormVO.java @@ -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 schemeDetailList; +} diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java new file mode 100644 index 000000000..09c03503d --- /dev/null +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java @@ -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); + +} diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml new file mode 100644 index 000000000..fdef1ac8e --- /dev/null +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SISchemeService.java b/src/com/engine/salary/service/SISchemeService.java new file mode 100644 index 000000000..269a9fa69 --- /dev/null +++ b/src/com/engine/salary/service/SISchemeService.java @@ -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 getForm(Map params); +} diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java new file mode 100644 index 000000000..56c748e8f --- /dev/null +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -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 getForm(Map params) { + return commandExecutor.execute(new SISchemeGetFormCmd(params,user)); + } +} diff --git a/src/com/engine/salary/util/PoToDtoUtil.java b/src/com/engine/salary/util/PoToDtoUtil.java new file mode 100644 index 000000000..90167c3dc --- /dev/null +++ b/src/com/engine/salary/util/PoToDtoUtil.java @@ -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; + } +} diff --git a/src/com/engine/salary/web/SISchemeController.java b/src/com/engine/salary/web/SISchemeController.java new file mode 100644 index 000000000..04df4a2a7 --- /dev/null +++ b/src/com/engine/salary/web/SISchemeController.java @@ -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)); + } +}