feat(wms): 增加版本管理功能和操作按钮
在规程主表的操作列中新增“版本与方案”按钮,点击后可跳转至版本管理页面。更新了操作列的宽度以适应新按钮。同时,在后端服务中添加了对规程版本存在性的校验,确保在删除规程时不会影响相关版本数据。
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
package com.klp.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.exception.ServiceException;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.WmsProcessPlan;
|
||||
import com.klp.domain.WmsProcessSpecVersion;
|
||||
import com.klp.domain.bo.WmsProcessPlanBo;
|
||||
import com.klp.domain.vo.WmsProcessPlanVo;
|
||||
import com.klp.mapper.WmsProcessPlanMapper;
|
||||
import com.klp.mapper.WmsProcessSpecVersionMapper;
|
||||
import com.klp.service.IWmsProcessPlanService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 方案点位Service实现
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WmsProcessPlanServiceImpl implements IWmsProcessPlanService {
|
||||
|
||||
private final WmsProcessPlanMapper baseMapper;
|
||||
private final WmsProcessSpecVersionMapper wmsProcessSpecVersionMapper;
|
||||
|
||||
@Override
|
||||
public WmsProcessPlanVo queryById(Long planId) {
|
||||
return baseMapper.selectVoById(planId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WmsProcessPlanVo> queryPageList(WmsProcessPlanBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WmsProcessPlan> lqw = buildQueryWrapper(bo);
|
||||
Page<WmsProcessPlanVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WmsProcessPlanVo> queryList(WmsProcessPlanBo bo) {
|
||||
return baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WmsProcessPlan> buildQueryWrapper(WmsProcessPlanBo bo) {
|
||||
LambdaQueryWrapper<WmsProcessPlan> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getVersionId() != null, WmsProcessPlan::getVersionId, bo.getVersionId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSegmentType()), WmsProcessPlan::getSegmentType, bo.getSegmentType());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getPointName()), WmsProcessPlan::getPointName, bo.getPointName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPointCode()), WmsProcessPlan::getPointCode, bo.getPointCode());
|
||||
lqw.orderByAsc(WmsProcessPlan::getSortOrder).orderByAsc(WmsProcessPlan::getPlanId);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(WmsProcessPlanBo bo) {
|
||||
WmsProcessSpecVersion ver = wmsProcessSpecVersionMapper.selectById(bo.getVersionId());
|
||||
if (ver == null) {
|
||||
throw new ServiceException("规程版本不存在");
|
||||
}
|
||||
WmsProcessPlan add = BeanUtil.toBean(bo, WmsProcessPlan.class);
|
||||
if (add.getSortOrder() == null) {
|
||||
add.setSortOrder(0);
|
||||
}
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setPlanId(add.getPlanId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(WmsProcessPlanBo bo) {
|
||||
WmsProcessPlan update = BeanUtil.toBean(bo, WmsProcessPlan.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
private void validEntityBeforeSave(WmsProcessPlan entity) {
|
||||
LambdaQueryWrapper<WmsProcessPlan> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(WmsProcessPlan::getVersionId, entity.getVersionId());
|
||||
lqw.eq(WmsProcessPlan::getPointCode, entity.getPointCode());
|
||||
if (entity.getPlanId() != null) {
|
||||
lqw.ne(WmsProcessPlan::getPlanId, entity.getPlanId());
|
||||
}
|
||||
if (baseMapper.selectCount(lqw) > 0) {
|
||||
throw new ServiceException("同一版本下点位编码已存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (Boolean.TRUE.equals(isValid)) {
|
||||
// 可扩展业务校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user