115 lines
3.9 KiB
Java
115 lines
3.9 KiB
Java
|
|
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.WmsFurnace;
|
||
|
|
import com.klp.domain.bo.WmsFurnaceBo;
|
||
|
|
import com.klp.domain.vo.WmsFurnaceVo;
|
||
|
|
import com.klp.mapper.WmsFurnaceMapper;
|
||
|
|
import com.klp.service.IWmsFurnaceService;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
import java.util.Collection;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 退火炉Service业务层处理
|
||
|
|
*
|
||
|
|
* @author klp
|
||
|
|
* @date 2026-03-14
|
||
|
|
*/
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
@Service
|
||
|
|
public class WmsFurnaceServiceImpl implements IWmsFurnaceService {
|
||
|
|
|
||
|
|
private final WmsFurnaceMapper baseMapper;
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public WmsFurnaceVo queryById(Long furnaceId) {
|
||
|
|
return baseMapper.selectVoById(furnaceId);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public TableDataInfo<WmsFurnaceVo> queryPageList(WmsFurnaceBo bo, PageQuery pageQuery) {
|
||
|
|
LambdaQueryWrapper<WmsFurnace> lqw = buildQueryWrapper(bo);
|
||
|
|
Page<WmsFurnaceVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||
|
|
return TableDataInfo.build(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public List<WmsFurnaceVo> queryList(WmsFurnaceBo bo) {
|
||
|
|
LambdaQueryWrapper<WmsFurnace> lqw = buildQueryWrapper(bo);
|
||
|
|
return baseMapper.selectVoList(lqw);
|
||
|
|
}
|
||
|
|
|
||
|
|
private LambdaQueryWrapper<WmsFurnace> buildQueryWrapper(WmsFurnaceBo bo) {
|
||
|
|
LambdaQueryWrapper<WmsFurnace> lqw = Wrappers.lambdaQuery();
|
||
|
|
lqw.like(StringUtils.isNotBlank(bo.getFurnaceCode()), WmsFurnace::getFurnaceCode, bo.getFurnaceCode());
|
||
|
|
lqw.like(StringUtils.isNotBlank(bo.getFurnaceName()), WmsFurnace::getFurnaceName, bo.getFurnaceName());
|
||
|
|
lqw.eq(bo.getStatus() != null, WmsFurnace::getStatus, bo.getStatus());
|
||
|
|
lqw.eq(bo.getBusyFlag() != null, WmsFurnace::getBusyFlag, bo.getBusyFlag());
|
||
|
|
lqw.orderByAsc(WmsFurnace::getFurnaceCode);
|
||
|
|
return lqw;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Boolean insertByBo(WmsFurnaceBo bo) {
|
||
|
|
WmsFurnace add = BeanUtil.toBean(bo, WmsFurnace.class);
|
||
|
|
validEntityBeforeSave(add, true);
|
||
|
|
boolean flag = baseMapper.insert(add) > 0;
|
||
|
|
if (flag) {
|
||
|
|
bo.setFurnaceId(add.getFurnaceId());
|
||
|
|
}
|
||
|
|
return flag;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Boolean updateByBo(WmsFurnaceBo bo) {
|
||
|
|
WmsFurnace update = BeanUtil.toBean(bo, WmsFurnace.class);
|
||
|
|
validEntityBeforeSave(update, false);
|
||
|
|
return baseMapper.updateById(update) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void validEntityBeforeSave(WmsFurnace entity, boolean isNew) {
|
||
|
|
LambdaQueryWrapper<WmsFurnace> lqw = Wrappers.lambdaQuery();
|
||
|
|
lqw.eq(WmsFurnace::getFurnaceCode, entity.getFurnaceCode());
|
||
|
|
if (!isNew) {
|
||
|
|
lqw.ne(WmsFurnace::getFurnaceId, entity.getFurnaceId());
|
||
|
|
}
|
||
|
|
if (baseMapper.selectCount(lqw) > 0) {
|
||
|
|
throw new ServiceException("炉编号已存在");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Boolean updateStatus(Long furnaceId, Integer status) {
|
||
|
|
WmsFurnace update = new WmsFurnace();
|
||
|
|
update.setFurnaceId(furnaceId);
|
||
|
|
update.setStatus(status);
|
||
|
|
return baseMapper.updateById(update) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Boolean updateBusy(Long furnaceId, Integer busyFlag) {
|
||
|
|
WmsFurnace update = new WmsFurnace();
|
||
|
|
update.setFurnaceId(furnaceId);
|
||
|
|
update.setBusyFlag(busyFlag);
|
||
|
|
return baseMapper.updateById(update) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||
|
|
if (isValid && ids != null && !ids.isEmpty()) {
|
||
|
|
// 暂无额外校验
|
||
|
|
}
|
||
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||
|
|
}
|
||
|
|
}
|