feat(oa): 实现奖金池与项目批量关联功能
- 新增奖金池与项目关联的批量插入接口 - 调整奖金池BO类,增加项目ID集合字段 - 移除旧的奖金池项目关联批量插入逻辑 - 优化项目进度步骤查询排序逻辑 - 在代码生成器中默认添加创建时间降序排序 - 增加排序字段sortNum以支持自定义排序
This commit is contained in:
@@ -86,6 +86,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
lqw.orderByDesc(${ClassName}::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.oa.domain.bo.OaBonusProjectRelBo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
@@ -99,5 +100,13 @@ public class OaBonusPoolController extends BaseController {
|
||||
return toAjax(iOaBonusPoolService.deleteWithValidByIds(Arrays.asList(poolIds), true));
|
||||
}
|
||||
|
||||
//使用这个方法批量绑定奖金池id和项目id
|
||||
@Log(title = "奖金池与项目关联", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/batchAdd")
|
||||
public R<Void> batchAdd(@Validated(AddGroup.class) @RequestBody OaBonusPoolBo bo) {
|
||||
return toAjax(iOaBonusPoolService.batchAdd(bo));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -99,11 +99,5 @@ public class OaBonusProjectRelController extends BaseController {
|
||||
return toAjax(iOaBonusProjectRelService.deleteWithValidByIds(Arrays.asList(relIds), true));
|
||||
}
|
||||
|
||||
//使用这个方法批量绑定奖金池id和项目id
|
||||
@Log(title = "奖金池与项目关联", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/batchAdd")
|
||||
public R<Void> batchAdd(@Validated(AddGroup.class) @RequestBody OaBonusProjectRelBo bo) {
|
||||
return toAjax(iOaBonusProjectRelService.batchAdd(bo));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,4 +57,7 @@ public class OaScheduleTemplateStep extends BaseEntity {
|
||||
*/
|
||||
private String description;
|
||||
|
||||
//排序字段
|
||||
private Integer sortNum;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.Date;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
@@ -60,4 +62,8 @@ public class OaBonusPoolBo extends BaseEntity {
|
||||
private String remark;
|
||||
|
||||
|
||||
private List<Long> projectIds;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class OaBonusProjectRelBo extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
private List<Long> projectIds;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -151,4 +151,8 @@ public class OaProjectScheduleStepBo extends BaseEntity {
|
||||
*/
|
||||
private String specification;
|
||||
|
||||
|
||||
//排序字段
|
||||
private Integer sortNum;
|
||||
|
||||
}
|
||||
|
||||
@@ -162,4 +162,7 @@ public class OaProjectScheduleStepVo extends BaseEntity {
|
||||
private String specification;
|
||||
|
||||
|
||||
//排序字段
|
||||
private Integer sortNum;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.ruoyi.oa.domain.vo.OaBonusPoolVo;
|
||||
import com.ruoyi.oa.domain.bo.OaBonusPoolBo;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import liquibase.pro.packaged.B;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -46,4 +47,6 @@ public interface IOaBonusPoolService {
|
||||
* 校验并批量删除奖金池信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
Boolean batchAdd(OaBonusPoolBo bo);
|
||||
}
|
||||
|
||||
@@ -47,5 +47,4 @@ public interface IOaBonusProjectRelService {
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
boolean batchAdd(OaBonusProjectRelBo bo);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package com.ruoyi.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.oa.domain.OaBonusProjectRel;
|
||||
import com.ruoyi.oa.domain.bo.OaBonusProjectRelBo;
|
||||
import com.ruoyi.oa.mapper.OaBonusProjectRelMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.oa.domain.bo.OaBonusPoolBo;
|
||||
import com.ruoyi.oa.domain.vo.OaBonusPoolVo;
|
||||
import com.ruoyi.oa.domain.OaBonusPool;
|
||||
import com.ruoyi.oa.mapper.OaBonusPoolMapper;
|
||||
import com.ruoyi.oa.service.IOaBonusPoolService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -31,6 +37,9 @@ public class OaBonusPoolServiceImpl implements IOaBonusPoolService {
|
||||
|
||||
private final OaBonusPoolMapper baseMapper;
|
||||
|
||||
@Autowired
|
||||
private OaBonusProjectRelMapper bonusProjectRelMapper;
|
||||
|
||||
/**
|
||||
* 查询奖金池
|
||||
*/
|
||||
@@ -110,4 +119,36 @@ public class OaBonusPoolServiceImpl implements IOaBonusPoolService {
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean batchAdd(OaBonusPoolBo bo) {
|
||||
// 先插入主表信息
|
||||
OaBonusPool pool = BeanUtil.toBean(bo, OaBonusPool.class);
|
||||
validEntityBeforeSave(pool);
|
||||
boolean flag = baseMapper.insert(pool) > 0;
|
||||
if (!flag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取插入后的主键
|
||||
Long poolId = pool.getPoolId();
|
||||
//批量插入奖金池id和项目id属于一对多的关系
|
||||
if (CollUtil.isEmpty(bo.getProjectIds())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean success = true;
|
||||
for (Long projectId : bo.getProjectIds()) {
|
||||
OaBonusProjectRel rel = new OaBonusProjectRel();
|
||||
rel.setPoolId(bo.getPoolId());
|
||||
rel.setProjectId(projectId);
|
||||
int result = bonusProjectRelMapper.insert(rel);
|
||||
if (result <= 0) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,26 +111,5 @@ public class OaBonusProjectRelServiceImpl implements IOaBonusProjectRelService {
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean batchAdd(OaBonusProjectRelBo bo) {
|
||||
//批量插入奖金池id和项目id属于一对多的关系
|
||||
if (CollUtil.isEmpty(bo.getProjectIds())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean success = true;
|
||||
for (Long projectId : bo.getProjectIds()) {
|
||||
OaBonusProjectRel rel = new OaBonusProjectRel();
|
||||
rel.setPoolId(bo.getPoolId());
|
||||
rel.setProjectId(projectId);
|
||||
rel.setAllocatedAmount(bo.getAllocatedAmount());
|
||||
int result = baseMapper.insert(rel);
|
||||
if (result <= 0) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
|
||||
lqw.eq(bo.getStepOrder() != null, "opss.step_order", bo.getStepOrder());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getStepName()), "opss.step_name", bo.getStepName());
|
||||
lqw.eq(bo.getStatus() != null, "opss.status", bo.getStatus());
|
||||
//排序字段sort_num根据这个降序排序
|
||||
lqw.orderByDesc("opss.sort_num");
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user