131 lines
5.4 KiB
Java
131 lines
5.4 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.WmsRawMaterialBo;
|
||
|
|
import com.klp.domain.vo.WmsRawMaterialVo;
|
||
|
|
import com.klp.domain.WmsRawMaterial;
|
||
|
|
import com.klp.mapper.WmsRawMaterialMapper;
|
||
|
|
import com.klp.service.IWmsRawMaterialService;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
import java.util.Collection;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 原材料Service业务层处理
|
||
|
|
*
|
||
|
|
* @author Joshi
|
||
|
|
* @date 2025-07-18
|
||
|
|
*/
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
@Service
|
||
|
|
public class WmsRawMaterialServiceImpl implements IWmsRawMaterialService {
|
||
|
|
|
||
|
|
private final WmsRawMaterialMapper baseMapper;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询原材料
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public WmsRawMaterialVo queryById(Long rawMaterialId){
|
||
|
|
return baseMapper.selectVoById(rawMaterialId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询原材料列表
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public TableDataInfo<WmsRawMaterialVo> queryPageList(WmsRawMaterialBo bo, PageQuery pageQuery) {
|
||
|
|
LambdaQueryWrapper<WmsRawMaterial> lqw = buildQueryWrapper(bo);
|
||
|
|
Page<WmsRawMaterialVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||
|
|
return TableDataInfo.build(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询原材料列表
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public List<WmsRawMaterialVo> queryList(WmsRawMaterialBo bo) {
|
||
|
|
LambdaQueryWrapper<WmsRawMaterial> lqw = buildQueryWrapper(bo);
|
||
|
|
return baseMapper.selectVoList(lqw);
|
||
|
|
}
|
||
|
|
|
||
|
|
private LambdaQueryWrapper<WmsRawMaterial> buildQueryWrapper(WmsRawMaterialBo bo) {
|
||
|
|
Map<String, Object> params = bo.getParams();
|
||
|
|
LambdaQueryWrapper<WmsRawMaterial> lqw = Wrappers.lambdaQuery();
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getRawMaterialCode()), WmsRawMaterial::getRawMaterialCode, bo.getRawMaterialCode());
|
||
|
|
lqw.like(StringUtils.isNotBlank(bo.getRawMaterialName()), WmsRawMaterial::getRawMaterialName, bo.getRawMaterialName());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSteelGrade()), WmsRawMaterial::getSteelGrade, bo.getSteelGrade());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTargetColdGrade()), WmsRawMaterial::getTargetColdGrade, bo.getTargetColdGrade());
|
||
|
|
lqw.eq(bo.getBaseMaterialId() != null, WmsRawMaterial::getBaseMaterialId, bo.getBaseMaterialId());
|
||
|
|
lqw.eq(bo.getSurfaceTreatmentId() != null, WmsRawMaterial::getSurfaceTreatmentId, bo.getSurfaceTreatmentId());
|
||
|
|
lqw.eq(bo.getThickness() != null, WmsRawMaterial::getThickness, bo.getThickness());
|
||
|
|
lqw.eq(bo.getThicknessDeviation() != null, WmsRawMaterial::getThicknessDeviation, bo.getThicknessDeviation());
|
||
|
|
lqw.eq(bo.getWidth() != null, WmsRawMaterial::getWidth, bo.getWidth());
|
||
|
|
lqw.eq(bo.getTargetColdWidth() != null, WmsRawMaterial::getTargetColdWidth, bo.getTargetColdWidth());
|
||
|
|
lqw.eq(bo.getTargetColdThickness() != null, WmsRawMaterial::getTargetColdThickness, bo.getTargetColdThickness());
|
||
|
|
lqw.eq(bo.getCrown() != null, WmsRawMaterial::getCrown, bo.getCrown());
|
||
|
|
lqw.eq(bo.getCoilWeight() != null, WmsRawMaterial::getCoilWeight, bo.getCoilWeight());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceQuality()), WmsRawMaterial::getSurfaceQuality, bo.getSurfaceQuality());
|
||
|
|
lqw.eq(bo.getHardnessHv5() != null, WmsRawMaterial::getHardnessHv5, bo.getHardnessHv5());
|
||
|
|
lqw.eq(bo.getHardnessDiff() != null, WmsRawMaterial::getHardnessDiff, bo.getHardnessDiff());
|
||
|
|
lqw.eq(bo.getCompositionMn() != null, WmsRawMaterial::getCompositionMn, bo.getCompositionMn());
|
||
|
|
lqw.eq(bo.getCompositionP() != null, WmsRawMaterial::getCompositionP, bo.getCompositionP());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getGrainSize()), WmsRawMaterial::getGrainSize, bo.getGrainSize());
|
||
|
|
lqw.eq(bo.getHeadTailCutFlag() != null, WmsRawMaterial::getHeadTailCutFlag, bo.getHeadTailCutFlag());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getInspectionResult()), WmsRawMaterial::getInspectionResult, bo.getInspectionResult());
|
||
|
|
lqw.eq(bo.getIsEnabled() != null, WmsRawMaterial::getIsEnabled, bo.getIsEnabled());
|
||
|
|
return lqw;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 新增原材料
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean insertByBo(WmsRawMaterialBo bo) {
|
||
|
|
WmsRawMaterial add = BeanUtil.toBean(bo, WmsRawMaterial.class);
|
||
|
|
validEntityBeforeSave(add);
|
||
|
|
boolean flag = baseMapper.insert(add) > 0;
|
||
|
|
if (flag) {
|
||
|
|
bo.setRawMaterialId(add.getRawMaterialId());
|
||
|
|
}
|
||
|
|
return flag;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 修改原材料
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean updateByBo(WmsRawMaterialBo bo) {
|
||
|
|
WmsRawMaterial update = BeanUtil.toBean(bo, WmsRawMaterial.class);
|
||
|
|
validEntityBeforeSave(update);
|
||
|
|
return baseMapper.updateById(update) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 保存前的数据校验
|
||
|
|
*/
|
||
|
|
private void validEntityBeforeSave(WmsRawMaterial entity){
|
||
|
|
//TODO 做一些数据校验,如唯一约束
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 批量删除原材料
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||
|
|
if(isValid){
|
||
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||
|
|
}
|
||
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||
|
|
}
|
||
|
|
}
|