diff --git a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java index 770ac9c..f3d7898 100644 --- a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java +++ b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java @@ -116,6 +116,7 @@ public interface ErrorCodeConstants { ErrorCode MAINTAIN_BACK_NOT_EXISTS = new ErrorCode(1_000_020_042, "设备保养变更记录不存在"); ErrorCode LOCATION_CAN_NOT_DELETE = new ErrorCode(1_000_020_043, "该库区已经存在于其他库位,不允许删除"); ErrorCode LOCATION_CAN_NOT_REPLACE = new ErrorCode(1_000_020_043, "该备件编号已存在于其他库位中!"); + ErrorCode ITEM_REPLACE = new ErrorCode(1_000_020_043, "该备件编号已存在"); ErrorCode DEVICE_NO_EXISTS = new ErrorCode(1_000_020_044, "该设备不存在"); ErrorCode DEVICE_TYPE_NO_NORMAL = new ErrorCode(1_000_020_045, "该设备与类型不符"); diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemBaseVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemBaseVO.java index a4a4969..f113d73 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemBaseVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemBaseVO.java @@ -43,6 +43,7 @@ public class ItemBaseVO { private Integer procurementCycle; @Schema(description = "ABC分类") + @NotNull(message = "ABC分类不能为空") private String classification; @Schema(description = "使用地点") diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java index 91aa7e0..3c5c355 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java @@ -114,7 +114,7 @@ public interface ItemAccountsMapper extends BaseMapperX { } } if (inQty.compareTo(BigDecimal.ZERO) == 0) {//账内库存不存在 - if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) >= 0) {//新到货存在且足够差额 + if (newQty.compareTo(BigDecimal.ZERO) > 0 && newQty.compareTo(subtractOutQty) >= 0) {//新到货存在且足够差额 BigDecimal subtractNewQty = newQty.subtract(subtractOutQty);//减去之后的数量 newLocation.setQty(subtractNewQty); result = this.updateById(newLocation); diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java index a901342..9e3a1ba 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java @@ -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.itemorder.ItemOrderDetailDO; 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.itemaccounts.ItemAccountsMapper; import com.win.module.eam.dal.mysql.itemorder.ItemOrderDetailMapper; @@ -67,8 +68,15 @@ public class ItemServiceImpl implements ItemService { public Long createItem(ItemCreateReqVO createReqVO) { // 插入 ItemDO item = ItemConvert.INSTANCE.convert(createReqVO); - String number = serialNumberApi.generateCode(RuleCodeEnum.Item.getCode()); - item.setNumber(number); + //String number = serialNumberApi.generateCode(RuleCodeEnum.Item.getCode()); + //item.setNumber(number); + QueryWrapper objectQueryWrapper = new QueryWrapper<>(); + objectQueryWrapper.eq("number", createReqVO.getNumber().trim()); + objectQueryWrapper.eq("deleted", 0); + List itemDOS = itemMapper.selectList(objectQueryWrapper); + if (itemDOS.size() > 0) { + throw exception(ITEM_REPLACE); + } item.setCreateTime(LocalDateTime.now()); //是否全局,备件没匹配设备时,默认是全局的 itemMapper.insert(item); @@ -80,6 +88,14 @@ public class ItemServiceImpl implements ItemService { public Integer updateItem(ItemUpdateReqVO updateReqVO) { // 校验存在 validateItemExists(updateReqVO.getId()); + QueryWrapper objectQueryWrapper = new QueryWrapper<>(); + objectQueryWrapper.eq("number", updateReqVO.getNumber().trim()); + objectQueryWrapper.eq("deleted", 0); + objectQueryWrapper.ne("id", updateReqVO.getId()); + List itemDOS = itemMapper.selectList(objectQueryWrapper); + if (itemDOS.size() > 0) { + throw exception(ITEM_REPLACE); + } // 更新 ItemDO updateObj = ItemConvert.INSTANCE.convert(updateReqVO); return itemMapper.updateById(updateObj); diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java index c736499..90f8d8f 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java @@ -56,7 +56,7 @@ public class LocationServiceImpl implements LocationService { // 插入 LocationDO location = LocationConvert.INSTANCE.convert(createReqVO); QueryWrapper objectQueryWrapper = new QueryWrapper<>(); - objectQueryWrapper.eq("number", createReqVO.getNumber()); + objectQueryWrapper.eq("number", createReqVO.getNumber().trim()); objectQueryWrapper.eq("deleted", 0); List locationDOList = locationMapper.selectList(objectQueryWrapper); if (locationDOList.size() > 0) { @@ -73,6 +73,14 @@ public class LocationServiceImpl implements LocationService { // 校验存在 validateLocationExists(updateReqVO.getId()); // 更新 + QueryWrapper objectQueryWrapper = new QueryWrapper<>(); + objectQueryWrapper.eq("number", updateReqVO.getNumber().trim()); + objectQueryWrapper.eq("deleted", 0); + objectQueryWrapper.ne("id", updateReqVO.getId()); + List locationDOList = locationMapper.selectList(objectQueryWrapper); + if (locationDOList.size() > 0) { + throw ServiceExceptionUtil.exception(LOCATION_HAVE_EXISTS); + } LocationDO updateObj = LocationConvert.INSTANCE.convert(updateReqVO); return locationMapper.updateById(updateObj); } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java index 4de9e36..b6f70c9 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java @@ -50,7 +50,7 @@ public class LocationAreaServiceImpl implements LocationAreaService { // 插入 LocationAreaDO locationArea = LocationAreaConvert.INSTANCE.convert(createReqVO); QueryWrapper objectQueryWrapper = new QueryWrapper<>(); - objectQueryWrapper.eq("number", createReqVO.getNumber()); + objectQueryWrapper.eq("number", createReqVO.getNumber().trim()); objectQueryWrapper.eq("deleted", 0); List locationAreaList = locationAreaMapper.selectList(objectQueryWrapper); if (locationAreaList.size() > 0) { @@ -67,6 +67,14 @@ public class LocationAreaServiceImpl implements LocationAreaService { // 校验存在 //validateLocationAreaExists(updateReqVO.getId()); // 更新 + QueryWrapper objectQueryWrapper = new QueryWrapper<>(); + objectQueryWrapper.eq("number", updateReqVO.getNumber().trim()); + objectQueryWrapper.eq("deleted", 0); + objectQueryWrapper.ne("id", updateReqVO.getId()); + List locationAreaList = locationAreaMapper.selectList(objectQueryWrapper); + if (locationAreaList.size() > 0) { + throw exception(LOCATION_AREA_HAVE_EXISTS); + } LocationAreaDO updateObj = LocationAreaConvert.INSTANCE.convert(updateReqVO); return locationAreaMapper.updateById(updateObj); }