115 lines
3.8 KiB
Java
115 lines
3.8 KiB
Java
package com.klp.service.impl;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
import com.klp.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.klp.common.utils.StringUtils;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import com.klp.domain.bo.WmsPurchasePlanDetailBo;
|
|
import com.klp.domain.vo.WmsPurchasePlanDetailVo;
|
|
import com.klp.domain.WmsPurchasePlanDetail;
|
|
import com.klp.mapper.WmsPurchasePlanDetailMapper;
|
|
import com.klp.service.IWmsPurchasePlanDetailService;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Collection;
|
|
|
|
/**
|
|
* 采购计划明细Service业务层处理
|
|
*
|
|
* @author Joshi
|
|
* @date 2025-07-18
|
|
*/
|
|
@RequiredArgsConstructor
|
|
@Service
|
|
public class WmsPurchasePlanDetailServiceImpl implements IWmsPurchasePlanDetailService {
|
|
|
|
private final WmsPurchasePlanDetailMapper baseMapper;
|
|
|
|
/**
|
|
* 查询采购计划明细
|
|
*/
|
|
@Override
|
|
public WmsPurchasePlanDetailVo queryById(Long detailId){
|
|
return baseMapper.selectVoById(detailId);
|
|
}
|
|
|
|
/**
|
|
* 查询采购计划明细列表
|
|
*/
|
|
@Override
|
|
public TableDataInfo<WmsPurchasePlanDetailVo> queryPageList(WmsPurchasePlanDetailBo bo, PageQuery pageQuery) {
|
|
LambdaQueryWrapper<WmsPurchasePlanDetail> lqw = buildQueryWrapper(bo);
|
|
Page<WmsPurchasePlanDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
return TableDataInfo.build(result);
|
|
}
|
|
|
|
/**
|
|
* 查询采购计划明细列表
|
|
*/
|
|
@Override
|
|
public List<WmsPurchasePlanDetailVo> queryList(WmsPurchasePlanDetailBo bo) {
|
|
LambdaQueryWrapper<WmsPurchasePlanDetail> lqw = buildQueryWrapper(bo);
|
|
return baseMapper.selectVoList(lqw);
|
|
}
|
|
|
|
private LambdaQueryWrapper<WmsPurchasePlanDetail> buildQueryWrapper(WmsPurchasePlanDetailBo bo) {
|
|
Map<String, Object> params = bo.getParams();
|
|
LambdaQueryWrapper<WmsPurchasePlanDetail> lqw = Wrappers.lambdaQuery();
|
|
lqw.eq(bo.getPlanId() != null, WmsPurchasePlanDetail::getPlanId, bo.getPlanId());
|
|
lqw.eq(bo.getRawMaterialId() != null, WmsPurchasePlanDetail::getRawMaterialId, bo.getRawMaterialId());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getOwner()), WmsPurchasePlanDetail::getOwner, bo.getOwner());
|
|
lqw.eq(bo.getQuantity() != null, WmsPurchasePlanDetail::getQuantity, bo.getQuantity());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getUnit()), WmsPurchasePlanDetail::getUnit, bo.getUnit());
|
|
return lqw;
|
|
}
|
|
|
|
/**
|
|
* 新增采购计划明细
|
|
*/
|
|
@Override
|
|
public Boolean insertByBo(WmsPurchasePlanDetailBo bo) {
|
|
|
|
WmsPurchasePlanDetail add = BeanUtil.toBean(bo, WmsPurchasePlanDetail.class);
|
|
validEntityBeforeSave(add);
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
if (flag) {
|
|
bo.setDetailId(add.getDetailId());
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
/**
|
|
* 修改采购计划明细
|
|
*/
|
|
@Override
|
|
public Boolean updateByBo(WmsPurchasePlanDetailBo bo) {
|
|
WmsPurchasePlanDetail update = BeanUtil.toBean(bo, WmsPurchasePlanDetail.class);
|
|
validEntityBeforeSave(update);
|
|
return baseMapper.updateById(update) > 0;
|
|
}
|
|
|
|
/**
|
|
* 保存前的数据校验
|
|
*/
|
|
private void validEntityBeforeSave(WmsPurchasePlanDetail entity){
|
|
//TODO 做一些数据校验,如唯一约束
|
|
}
|
|
|
|
/**
|
|
* 批量删除采购计划明细
|
|
*/
|
|
@Override
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
if(isValid){
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
}
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
}
|
|
}
|