|
@ -14,6 +14,7 @@ import com.win.module.eam.dal.dataobject.item.ItemDO; |
|
|
import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; |
|
|
import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; |
|
|
import com.win.module.eam.dal.dataobject.itemorder.ItemOrderDetailDO; |
|
|
import com.win.module.eam.dal.dataobject.itemorder.ItemOrderDetailDO; |
|
|
import com.win.module.eam.dal.dataobject.itemorder.ItemOrderMainDO; |
|
|
import com.win.module.eam.dal.dataobject.itemorder.ItemOrderMainDO; |
|
|
|
|
|
import com.win.module.eam.dal.dataobject.locationarea.LocationAreaDO; |
|
|
import com.win.module.eam.dal.mysql.item.ItemMapper; |
|
|
import com.win.module.eam.dal.mysql.item.ItemMapper; |
|
|
import com.win.module.eam.dal.mysql.itemaccounts.ItemAccountsMapper; |
|
|
import com.win.module.eam.dal.mysql.itemaccounts.ItemAccountsMapper; |
|
|
import com.win.module.eam.dal.mysql.itemorder.ItemOrderDetailMapper; |
|
|
import com.win.module.eam.dal.mysql.itemorder.ItemOrderDetailMapper; |
|
@ -67,8 +68,15 @@ public class ItemServiceImpl implements ItemService { |
|
|
public Long createItem(ItemCreateReqVO createReqVO) { |
|
|
public Long createItem(ItemCreateReqVO createReqVO) { |
|
|
// 插入
|
|
|
// 插入
|
|
|
ItemDO item = ItemConvert.INSTANCE.convert(createReqVO); |
|
|
ItemDO item = ItemConvert.INSTANCE.convert(createReqVO); |
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.Item.getCode()); |
|
|
//String number = serialNumberApi.generateCode(RuleCodeEnum.Item.getCode());
|
|
|
item.setNumber(number); |
|
|
//item.setNumber(number);
|
|
|
|
|
|
QueryWrapper<ItemDO> objectQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
objectQueryWrapper.eq("number", createReqVO.getNumber().trim()); |
|
|
|
|
|
objectQueryWrapper.eq("deleted", 0); |
|
|
|
|
|
List<ItemDO> itemDOS = itemMapper.selectList(objectQueryWrapper); |
|
|
|
|
|
if (itemDOS.size() > 0) { |
|
|
|
|
|
throw exception(ITEM_REPLACE); |
|
|
|
|
|
} |
|
|
item.setCreateTime(LocalDateTime.now()); |
|
|
item.setCreateTime(LocalDateTime.now()); |
|
|
//是否全局,备件没匹配设备时,默认是全局的
|
|
|
//是否全局,备件没匹配设备时,默认是全局的
|
|
|
itemMapper.insert(item); |
|
|
itemMapper.insert(item); |
|
@ -80,6 +88,14 @@ public class ItemServiceImpl implements ItemService { |
|
|
public Integer updateItem(ItemUpdateReqVO updateReqVO) { |
|
|
public Integer updateItem(ItemUpdateReqVO updateReqVO) { |
|
|
// 校验存在
|
|
|
// 校验存在
|
|
|
validateItemExists(updateReqVO.getId()); |
|
|
validateItemExists(updateReqVO.getId()); |
|
|
|
|
|
QueryWrapper<ItemDO> objectQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
objectQueryWrapper.eq("number", updateReqVO.getNumber().trim()); |
|
|
|
|
|
objectQueryWrapper.eq("deleted", 0); |
|
|
|
|
|
objectQueryWrapper.ne("id", updateReqVO.getId()); |
|
|
|
|
|
List<ItemDO> itemDOS = itemMapper.selectList(objectQueryWrapper); |
|
|
|
|
|
if (itemDOS.size() > 0) { |
|
|
|
|
|
throw exception(ITEM_REPLACE); |
|
|
|
|
|
} |
|
|
// 更新
|
|
|
// 更新
|
|
|
ItemDO updateObj = ItemConvert.INSTANCE.convert(updateReqVO); |
|
|
ItemDO updateObj = ItemConvert.INSTANCE.convert(updateReqVO); |
|
|
return itemMapper.updateById(updateObj); |
|
|
return itemMapper.updateById(updateObj); |
|
|