Commit 95702c74 authored by hongguangwu's avatar hongguangwu

基数配置提交2

parent 2d515686
......@@ -18,6 +18,7 @@ package com.yifu.cloud.plus.v1.yifu.social.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
......@@ -28,6 +29,7 @@ import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 社保、公积金基数配置
......@@ -450,4 +452,8 @@ public class SysBaseSetInfo extends BaseEntity {
@ExcelProperty("社保户名称")
private String departName;
@Schema(description = "公积金比例List(保存时前端传参用)")
@TableField(exist = false)
private List<SysPayProportion> fundProList;
}
......@@ -25,7 +25,9 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.social.entity.SysBaseSetInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.SysPayProportion;
import com.yifu.cloud.plus.v1.yifu.social.service.SysBaseSetInfoService;
import com.yifu.cloud.plus.v1.yifu.social.service.SysPayProportionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
......@@ -50,6 +52,7 @@ import java.util.List;
public class SysBaseSetInfoController {
private final SysBaseSetInfoService sysBaseSetInfoService;
private final SysPayProportionService sysPayProportionService;
/**
......@@ -73,7 +76,6 @@ public class SysBaseSetInfoController {
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage")
//@PreAuthorize("@pms.hasPermission('social_sysbasesetinfo_get')" )
public R<List<SysBaseSetInfo>> getSysBaseSetInfoNoPage(@RequestBody SysBaseSetInfo sysBaseSetInfo) {
return R.ok(sysBaseSetInfoService.list(Wrappers.query(sysBaseSetInfo).orderByDesc(CommonConstants.CREATE_TIME)));
}
......@@ -88,7 +90,11 @@ public class SysBaseSetInfoController {
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('social_sysbasesetinfo_get')")
public R<SysBaseSetInfo> getById(@PathVariable("id") String id) {
return R.ok(sysBaseSetInfoService.getById(id));
SysBaseSetInfo baseSetInfo = sysBaseSetInfoService.getById(id);
if (null != baseSetInfo && CommonConstants.ONE_STRING.equals(baseSetInfo.getBaseType())){
baseSetInfo.setFundProList(sysPayProportionService.list(Wrappers.<SysPayProportion>query().lambda().eq(SysPayProportion::getSysBaseSetId,id)));
}
return R.ok(baseSetInfo);
}
/**
......@@ -133,4 +139,22 @@ public class SysBaseSetInfoController {
return R.ok(sysBaseSetInfoService.removeById(id));
}
/**
* 通过id禁用启用一条记录
* @param id
* @return R
*/
@Operation(summary = "启用禁用", description = "启用禁用:hasPermission('social_sysbasesetinfo_enable') 0.在用 1.终止 2.过期")
@SysLog("禁用启用基数设置表")
@PostMapping("/disableOrEnableById")
@PreAuthorize("@pms.hasPermission('wxhr:social_sysbasesetinfo_enable')")
public R disableOrEnableById(@RequestParam String id, @RequestParam Integer status) {
SysBaseSetInfo baseSetInfo = sysBaseSetInfoService.getById(id);
if (null == baseSetInfo){
return R.failed("无对应ID的数据!");
}
baseSetInfo.setStatus(status);
return new R<>(sysBaseSetInfoService.updateById(baseSetInfo));
}
}
......@@ -17,19 +17,25 @@
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.social.entity.SysBaseSetInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.SysPayProportion;
import com.yifu.cloud.plus.v1.yifu.social.mapper.SysBaseSetInfoMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.SysBaseSetInfoService;
import com.yifu.cloud.plus.v1.yifu.social.service.SysPayProportionService;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 基数设置表
*
......@@ -41,6 +47,9 @@ import org.springframework.stereotype.Service;
public class SysBaseSetInfoServiceImpl extends ServiceImpl<SysBaseSetInfoMapper, SysBaseSetInfo> implements SysBaseSetInfoService {
private final TSocialLogService tSocialLogService;
private final SysPayProportionService sysPayProportionService;
/**
* 基数设置表简单分页查询
*
......@@ -54,21 +63,129 @@ public class SysBaseSetInfoServiceImpl extends ServiceImpl<SysBaseSetInfoMapper,
@Override
public R<String> saveSysBase(SysBaseSetInfo sysBaseSetInfo) {
YifuUser user = SecurityUtils.getUser();
if (null == user) {
return R.failed("获取用户登录信息失败!");
}
SysBaseSetInfo baseSetInfo = null;
if (null != sysBaseSetInfo.getTown()) {
baseSetInfo = this.getOne(Wrappers.<SysBaseSetInfo>query().lambda()
.eq(SysBaseSetInfo::getBaseType, sysBaseSetInfo.getBaseType())
.eq(SysBaseSetInfo::getDepartId, sysBaseSetInfo.getDepartId())
.eq(SysBaseSetInfo::getTown, sysBaseSetInfo.getTown())
.le(SysBaseSetInfo::getApplyStartDate, sysBaseSetInfo.getApplyStartDate())
.ge(SysBaseSetInfo::getApplyEndDate, sysBaseSetInfo.getApplyStartDate())
.last(CommonConstants.LAST_ONE_SQL));
}
if (null != sysBaseSetInfo.getCity() && null == sysBaseSetInfo.getTown()) {
baseSetInfo = this.getOne(Wrappers.<SysBaseSetInfo>query().lambda()
.eq(SysBaseSetInfo::getBaseType, sysBaseSetInfo.getBaseType())
.eq(SysBaseSetInfo::getDepartId, sysBaseSetInfo.getDepartId())
.eq(SysBaseSetInfo::getCity, sysBaseSetInfo.getCity())
.isNull(SysBaseSetInfo::getTown)
.le(SysBaseSetInfo::getApplyStartDate, sysBaseSetInfo.getApplyStartDate())
.ge(SysBaseSetInfo::getApplyEndDate, sysBaseSetInfo.getApplyStartDate())
.last(CommonConstants.LAST_ONE_SQL));
}
if (null != sysBaseSetInfo.getProvince() && null == sysBaseSetInfo.getCity()) {
baseSetInfo = this.getOne(Wrappers.<SysBaseSetInfo>query().lambda()
.eq(SysBaseSetInfo::getBaseType, sysBaseSetInfo.getBaseType())
.eq(SysBaseSetInfo::getDepartId, sysBaseSetInfo.getDepartId())
.eq(SysBaseSetInfo::getProvince, sysBaseSetInfo.getProvince())
.isNull(SysBaseSetInfo::getCity)
.le(SysBaseSetInfo::getApplyStartDate, sysBaseSetInfo.getApplyStartDate())
.ge(SysBaseSetInfo::getApplyEndDate, sysBaseSetInfo.getApplyStartDate())
.last(CommonConstants.LAST_ONE_SQL));
}
if (null != baseSetInfo) {
return R.failed("对应户、地市、有效期的基数配置已存在!");
}
this.save(sysBaseSetInfo);
this.saveOrUpdateBaseAndFundPro(sysBaseSetInfo);
return R.ok();
}
@Override
public R<String> updateSysBase(SysBaseSetInfo sysBaseSetInfo) {
YifuUser user = SecurityUtils.getUser();
if (null == user) {
return R.failed("获取用户登录信息失败!");
}
SysBaseSetInfo old = this.getById(sysBaseSetInfo.getId());
if (old == null || Common.isEmpty(old.getId())) {
return R.failed("根据id未找到基数配置!" + sysBaseSetInfo.getId());
}
this.updateById(sysBaseSetInfo);
SysBaseSetInfo baseSetInfo = null;
if (null != sysBaseSetInfo.getTown()) {
baseSetInfo = this.getOne(Wrappers.<SysBaseSetInfo>query().lambda()
.eq(SysBaseSetInfo::getBaseType, sysBaseSetInfo.getBaseType())
.eq(SysBaseSetInfo::getDepartId, sysBaseSetInfo.getDepartId())
.eq(SysBaseSetInfo::getTown, sysBaseSetInfo.getTown())
.le(SysBaseSetInfo::getApplyStartDate, sysBaseSetInfo.getApplyStartDate())
.ge(SysBaseSetInfo::getApplyEndDate, sysBaseSetInfo.getApplyStartDate())
.ne(SysBaseSetInfo::getId, sysBaseSetInfo.getId())
.eq(SysBaseSetInfo::getStatus, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
}
if (null != sysBaseSetInfo.getCity() && null == sysBaseSetInfo.getTown()) {
baseSetInfo = this.getOne(Wrappers.<SysBaseSetInfo>query().lambda()
.eq(SysBaseSetInfo::getBaseType, sysBaseSetInfo.getBaseType())
.eq(SysBaseSetInfo::getDepartId, sysBaseSetInfo.getDepartId())
.eq(SysBaseSetInfo::getCity, sysBaseSetInfo.getCity())
.isNull(SysBaseSetInfo::getTown)
.le(SysBaseSetInfo::getApplyStartDate, sysBaseSetInfo.getApplyStartDate())
.ge(SysBaseSetInfo::getApplyEndDate, sysBaseSetInfo.getApplyStartDate())
.ne(SysBaseSetInfo::getId, sysBaseSetInfo.getId())
.eq(SysBaseSetInfo::getStatus, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
}
if (null != sysBaseSetInfo.getProvince() && null == sysBaseSetInfo.getCity()) {
baseSetInfo = this.getOne(Wrappers.<SysBaseSetInfo>query().lambda()
.eq(SysBaseSetInfo::getBaseType, sysBaseSetInfo.getBaseType())
.eq(SysBaseSetInfo::getDepartId, sysBaseSetInfo.getDepartId())
.eq(SysBaseSetInfo::getProvince, sysBaseSetInfo.getProvince())
.isNull(SysBaseSetInfo::getCity)
.le(SysBaseSetInfo::getApplyStartDate, sysBaseSetInfo.getApplyStartDate())
.ge(SysBaseSetInfo::getApplyEndDate, sysBaseSetInfo.getApplyStartDate())
.ne(SysBaseSetInfo::getId, sysBaseSetInfo.getId())
.eq(SysBaseSetInfo::getStatus, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
}
if (null != baseSetInfo) {
return R.failed("对应户、地市、有效期的基数配置已存在!");
}
this.saveOrUpdateBaseAndFundPro(sysBaseSetInfo);
// 记录变更日志
tSocialLogService.saveModificationRecord(CommonConstants.ONE_INT, old.getId(), old, sysBaseSetInfo);
return R.ok();
}
/**
* @param sysBaseSetInfo
* @Description: 新增、编辑社保、公积金基数
* @Author: hgw
* @Date: 2022/7/12 14:33
* @return: void
**/
private void saveOrUpdateBaseAndFundPro(SysBaseSetInfo sysBaseSetInfo) {
if (Common.isNotNull(sysBaseSetInfo.getId())) {
baseMapper.updateById(sysBaseSetInfo);
} else {
sysBaseSetInfo.setStatus(CommonConstants.ZERO_INT);
sysBaseSetInfo.setDeleteFlag(CommonConstants.ZERO_STRING);
baseMapper.insert(sysBaseSetInfo);
}
List<SysPayProportion> payProportionList = sysBaseSetInfo.getFundProList();
if (Common.isNotNull(payProportionList)) {
for (SysPayProportion payProportion : payProportionList) {
if (Common.isNotNull(payProportion.getId())) {
sysPayProportionService.updateById(payProportion);
} else {
payProportion.setSysBaseSetId(sysBaseSetInfo.getId());
sysPayProportionService.save(payProportion);
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment