2026-04-20 18:20:29 +08:00
|
|
|
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.WmsProcessSpec;
|
2026-04-20 19:14:50 +08:00
|
|
|
import com.klp.domain.WmsProcessSpecVersion;
|
2026-04-20 18:20:29 +08:00
|
|
|
import com.klp.domain.bo.WmsProcessSpecBo;
|
|
|
|
|
import com.klp.domain.vo.WmsProcessSpecVo;
|
|
|
|
|
import com.klp.mapper.WmsProcessSpecMapper;
|
2026-04-20 19:14:50 +08:00
|
|
|
import com.klp.mapper.WmsProcessSpecVersionMapper;
|
2026-04-20 18:20:29 +08:00
|
|
|
import com.klp.service.IWmsProcessSpecService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 规程主表Service业务层处理
|
|
|
|
|
*
|
|
|
|
|
* @author klp
|
|
|
|
|
*/
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Service
|
|
|
|
|
public class WmsProcessSpecServiceImpl implements IWmsProcessSpecService {
|
|
|
|
|
|
|
|
|
|
private final WmsProcessSpecMapper baseMapper;
|
2026-04-20 19:14:50 +08:00
|
|
|
private final WmsProcessSpecVersionMapper wmsProcessSpecVersionMapper;
|
2026-04-20 18:20:29 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public WmsProcessSpecVo queryById(Long specId) {
|
|
|
|
|
return baseMapper.selectVoById(specId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TableDataInfo<WmsProcessSpecVo> queryPageList(WmsProcessSpecBo bo, PageQuery pageQuery) {
|
|
|
|
|
LambdaQueryWrapper<WmsProcessSpec> lqw = buildQueryWrapper(bo);
|
|
|
|
|
Page<WmsProcessSpecVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
|
return TableDataInfo.build(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<WmsProcessSpecVo> queryList(WmsProcessSpecBo bo) {
|
|
|
|
|
LambdaQueryWrapper<WmsProcessSpec> lqw = buildQueryWrapper(bo);
|
|
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<WmsProcessSpec> buildQueryWrapper(WmsProcessSpecBo bo) {
|
|
|
|
|
LambdaQueryWrapper<WmsProcessSpec> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSpecCode()), WmsProcessSpec::getSpecCode, bo.getSpecCode());
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getSpecName()), WmsProcessSpec::getSpecName, bo.getSpecName());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSpecType()), WmsProcessSpec::getSpecType, bo.getSpecType());
|
|
|
|
|
lqw.eq(bo.getLineId() != null, WmsProcessSpec::getLineId, bo.getLineId());
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getProductType()), WmsProcessSpec::getProductType, bo.getProductType());
|
|
|
|
|
lqw.eq(bo.getIsEnabled() != null, WmsProcessSpec::getIsEnabled, bo.getIsEnabled());
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean insertByBo(WmsProcessSpecBo bo) {
|
|
|
|
|
WmsProcessSpec add = BeanUtil.toBean(bo, WmsProcessSpec.class);
|
|
|
|
|
if (add.getIsEnabled() == null) {
|
|
|
|
|
add.setIsEnabled(1);
|
|
|
|
|
}
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setSpecId(add.getSpecId());
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateByBo(WmsProcessSpecBo bo) {
|
|
|
|
|
WmsProcessSpec update = BeanUtil.toBean(bo, WmsProcessSpec.class);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void validEntityBeforeSave(WmsProcessSpec entity) {
|
|
|
|
|
LambdaQueryWrapper<WmsProcessSpec> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
lqw.eq(WmsProcessSpec::getSpecCode, entity.getSpecCode());
|
|
|
|
|
if (entity.getSpecId() != null) {
|
|
|
|
|
lqw.ne(WmsProcessSpec::getSpecId, entity.getSpecId());
|
|
|
|
|
}
|
|
|
|
|
if (baseMapper.selectCount(lqw) > 0) {
|
|
|
|
|
throw new ServiceException("规程编号已存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
if (Boolean.TRUE.equals(isValid)) {
|
2026-04-20 19:14:50 +08:00
|
|
|
for (Long specId : ids) {
|
|
|
|
|
LambdaQueryWrapper<WmsProcessSpecVersion> vq = Wrappers.lambdaQuery();
|
|
|
|
|
vq.eq(WmsProcessSpecVersion::getSpecId, specId);
|
|
|
|
|
if (wmsProcessSpecVersionMapper.selectCount(vq) > 0) {
|
|
|
|
|
throw new ServiceException("规程下存在版本数据,请先删除版本及方案");
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-20 18:20:29 +08:00
|
|
|
}
|
|
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|