package cn.iocoder.yudao.module.mes.service.mdm;
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
|
import cn.iocoder.yudao.module.mes.dal.dataobject.mdm.MesMdmItemDO;
|
import cn.iocoder.yudao.module.mes.dal.mysql.mdm.MesMdmItemMapper;
|
import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
|
import jakarta.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.validation.annotation.Validated;
|
|
import java.util.Collection;
|
import java.util.Collections;
|
import java.util.List;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MD_ITEM_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MD_ITEM_IS_DISABLE;
|
|
/**
|
* MDM 物料 Service 实现类
|
*
|
* 专门用于查询 mdm_item 表
|
*/
|
@Service
|
@Validated
|
public class MesMdmItemServiceImpl implements MesMdmItemService {
|
|
@Resource
|
private MesMdmItemMapper mesMdmItemMapper;
|
@Autowired
|
private MesMdItemService mesMdItemService;
|
|
@Override
|
public MesMdmItemDO getItem(Long id) {
|
return mesMdmItemMapper.selectById(id);
|
}
|
|
@Override
|
public MesMdmItemDO validateItemExists(Long id) {
|
MesMdmItemDO item = mesMdmItemMapper.selectById(id);
|
if (item == null) {
|
throw exception(MD_ITEM_NOT_EXISTS);
|
}
|
return item;
|
}
|
|
@Override
|
public MesMdmItemDO mesValidateItemExists(Long itemId) {
|
MesMdItemDO mesItem = mesMdItemService.getItem(itemId);
|
if (mesItem == null) {
|
throw exception(MD_ITEM_NOT_EXISTS);
|
}
|
MesMdmItemDO item = mesMdmItemMapper.selectById(mesItem.getMdmItemId());
|
if (item == null) {
|
throw exception(MD_ITEM_NOT_EXISTS);
|
}
|
return item;
|
}
|
|
@Override
|
public MesMdmItemDO validateItemExistsAndEnable(Long id) {
|
MesMdmItemDO item = validateItemExists(id);
|
if (item.getStatus() != null && item.getStatus() == 1) {
|
throw exception(MD_ITEM_IS_DISABLE);
|
}
|
return item;
|
}
|
|
@Override
|
public List<MesMdmItemDO> getItemList(Collection<Long> ids) {
|
if (ids == null || ids.isEmpty()) {
|
return Collections.emptyList();
|
}
|
return mesMdmItemMapper.selectListByIds(ids);
|
}
|
|
}
|