|
|
@ -48,7 +48,7 @@ public class DockServiceImpl implements DockService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public Long createDock(DockCreateReqVO createReqVO) { |
|
|
|
validateDockForCreateOrUpdate(createReqVO.getId(), createReqVO.getCode(), createReqVO.getType(), createReqVO.getWarehouseCode(), createReqVO.getDefaultLocationCode(), createReqVO.getAvailable()); |
|
|
|
validateDockForCreateOrUpdate(createReqVO.getCode(), createReqVO.getType(), createReqVO.getWarehouseCode(), createReqVO.getDefaultLocationCode(), createReqVO.getAvailable()); |
|
|
|
|
|
|
|
// 插入
|
|
|
|
DockDO dock = DockConvert.INSTANCE.convert(createReqVO); |
|
|
@ -59,8 +59,9 @@ public class DockServiceImpl implements DockService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateDock(DockUpdateReqVO updateReqVO) { |
|
|
|
validateDockExists(updateReqVO.getId()); |
|
|
|
// 校验存在
|
|
|
|
validateDockForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getCode(), updateReqVO.getType(), updateReqVO.getWarehouseCode(), updateReqVO.getDefaultLocationCode(), updateReqVO.getAvailable()); |
|
|
|
validateDockForCreateOrUpdate( updateReqVO.getCode(), updateReqVO.getType(), updateReqVO.getWarehouseCode(), updateReqVO.getDefaultLocationCode(), updateReqVO.getAvailable()); |
|
|
|
// 更新
|
|
|
|
DockDO updateObj = DockConvert.INSTANCE.convert(updateReqVO); |
|
|
|
dockMapper.updateById(updateObj); |
|
|
@ -102,12 +103,7 @@ public class DockServiceImpl implements DockService { |
|
|
|
public String valitedock(DockDO dock) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
validateDockExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null, dock.getCode()); |
|
|
|
validateCodeExists( dock.getCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
@ -167,12 +163,11 @@ public class DockServiceImpl implements DockService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void validateDockForCreateOrUpdate(Long id, String code, String type, String warehouseCode, |
|
|
|
private void validateDockForCreateOrUpdate(String code, String type, String warehouseCode, |
|
|
|
String defaultLocationCode, String available) { |
|
|
|
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
|
|
|
DataPermissionUtils.executeIgnore(() -> { |
|
|
|
validateDockExists(id); |
|
|
|
validateCodeExists(id, code); |
|
|
|
validateCodeExists(code); |
|
|
|
// 校验code唯一
|
|
|
|
validateTypeExists(type); |
|
|
|
validateWareHouseCodeExists(warehouseCode); |
|
|
@ -193,7 +188,7 @@ public class DockServiceImpl implements DockService { |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateCodeExists(Long id, String code) { |
|
|
|
private void validateCodeExists( String code) { |
|
|
|
if (code == null) { |
|
|
|
throw exception(DOCK_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|