|
|
@ -40,9 +40,9 @@ 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.getId(), createReqVO.getCode(), createReqVO.getType(), createReqVO.getWarehouseCode(), createReqVO.getDefaultLocationCode(), createReqVO.getAvailable()); |
|
|
|
|
|
|
|
// 插入
|
|
|
|
// 插入
|
|
|
|
DockDO dock = DockConvert.INSTANCE.convert(createReqVO); |
|
|
|
dockMapper.insert(dock); |
|
|
|
// 返回
|
|
|
@ -52,8 +52,8 @@ public class DockServiceImpl implements DockService { |
|
|
|
@Override |
|
|
|
public void updateDock(DockUpdateReqVO updateReqVO) { |
|
|
|
// 校验存在
|
|
|
|
validateDockForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getCode(),updateReqVO.getType(),updateReqVO.getWarehouseCode(),updateReqVO.getDefaultLocationCode(),updateReqVO.getAvailable()); |
|
|
|
// 更新
|
|
|
|
validateDockForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getCode(), updateReqVO.getType(), updateReqVO.getWarehouseCode(), updateReqVO.getDefaultLocationCode(), updateReqVO.getAvailable()); |
|
|
|
// 更新
|
|
|
|
DockDO updateObj = DockConvert.INSTANCE.convert(updateReqVO); |
|
|
|
dockMapper.updateById(updateObj); |
|
|
|
} |
|
|
@ -85,13 +85,13 @@ public class DockServiceImpl implements DockService { |
|
|
|
public PageResult<DockDO> getDockSenior(CustomConditions conditions) { |
|
|
|
return dockMapper.selectSenior(conditions); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public List<DockDO> getDockList(DockExportReqVO exportReqVO) { |
|
|
|
return dockMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
public String valitedock(DockDO dock){ |
|
|
|
public String valitedock(DockDO dock) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
validateDockExists(null); |
|
|
@ -99,7 +99,7 @@ public class DockServiceImpl implements DockService { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null,dock.getCode()); |
|
|
|
validateCodeExists(null, dock.getCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
@ -136,20 +136,19 @@ public class DockServiceImpl implements DockService { |
|
|
|
DockDO dockDO = DockConvert.INSTANCE.convert(dock); |
|
|
|
String message = this.valitedock(dockDO); |
|
|
|
boolean flag = true; |
|
|
|
if(!message.isEmpty()){ |
|
|
|
if (!message.isEmpty()) { |
|
|
|
DockImportErrorVO importErrorVO = DockConvert.INSTANCE.convert2(dockDO); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
importErrorVO.setImportRemark(message.substring(0, message.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
if(flag){ |
|
|
|
if (flag) { |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
DockDO existAccountcalendar = dockMapper.selectByItemCode(dockDO.getCode()); |
|
|
|
if (existAccountcalendar == null&& mode != 3) { |
|
|
|
DockDO existAccountcalendar = dockMapper.selectByItemCode(dockDO.getCode()); |
|
|
|
if (existAccountcalendar == null && mode != 3) { |
|
|
|
dockMapper.insert(DockConvert.INSTANCE.convert(dock)); |
|
|
|
} |
|
|
|
else if (existAccountcalendar != null && mode != 2) { |
|
|
|
} else if (existAccountcalendar != null && mode != 2) { |
|
|
|
// 如果存在,判断是否允许更新
|
|
|
|
dockDO.setId(existAccountcalendar.getId()); |
|
|
|
dockMapper.updateById(dockDO); |
|
|
@ -160,13 +159,12 @@ public class DockServiceImpl implements DockService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void validateDockForCreateOrUpdate(Long id, String code,String type, String warehouseCode, |
|
|
|
String defaultLocationCode,String available) { |
|
|
|
private void validateDockForCreateOrUpdate(Long id, String code, String type, String warehouseCode, |
|
|
|
String defaultLocationCode, String available) { |
|
|
|
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
|
|
|
DataPermissionUtils.executeIgnore(() -> { |
|
|
|
validateDockExists(id); |
|
|
|
validateCodeExists(id,code); |
|
|
|
validateCodeExists(id, code); |
|
|
|
// 校验code唯一
|
|
|
|
validateTypeExists(type); |
|
|
|
validateWareHouseCodeExists(warehouseCode); |
|
|
@ -174,6 +172,7 @@ public class DockServiceImpl implements DockService { |
|
|
|
validateAvailableExists(available); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateDockExists(Long id) { |
|
|
|
if (id == null) { |
|
|
@ -184,8 +183,9 @@ public class DockServiceImpl implements DockService { |
|
|
|
throw exception(DOCK_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateCodeExists(Long id,String code) { |
|
|
|
private void validateCodeExists(Long id, String code) { |
|
|
|
if (code.isEmpty()) { |
|
|
|
throw exception(DOCK_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
@ -204,24 +204,28 @@ public class DockServiceImpl implements DockService { |
|
|
|
throw exception(DOCK_CODE_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateTypeExists(String type) { |
|
|
|
if (type.isEmpty()) { |
|
|
|
throw exception(DOCK_TYPE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateWareHouseCodeExists(String warehouseCode) { |
|
|
|
if (warehouseCode.isEmpty()) { |
|
|
|
throw exception(DOCK_WARE_HOUSE_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateDefaultLocationCodeExists(String defaultLocationCode) { |
|
|
|
if (defaultLocationCode.isEmpty()) { |
|
|
|
throw exception(DOCK_DEFAULT_LOCATION_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateAvailableExists(String available) { |
|
|
|
if (available.isEmpty()) { |
|
|
@ -232,11 +236,25 @@ public class DockServiceImpl implements DockService { |
|
|
|
@Override |
|
|
|
public DockDO DockExist(String code) { |
|
|
|
QueryWrapper queryWrapper = new QueryWrapper(); |
|
|
|
queryWrapper.eq("code",code); |
|
|
|
queryWrapper.eq("code", code); |
|
|
|
DockDO dockDO = dockMapper.selectOne(queryWrapper); |
|
|
|
if (dockDO != null && "TRUE".equals(dockDO.getAvailable())) { |
|
|
|
return dockDO; |
|
|
|
} else { |
|
|
|
throw exception(DOCK_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public DockDO selectDockByTwoCode(String code, String toWarehouseCode) { |
|
|
|
QueryWrapper<DockDO> queryWrapper = new QueryWrapper(); |
|
|
|
queryWrapper.eq("code", code); |
|
|
|
queryWrapper.eq("warehouse_code", toWarehouseCode); |
|
|
|
queryWrapper.eq("available", "TRUE"); |
|
|
|
DockDO dockDO = dockMapper.selectOne(queryWrapper); |
|
|
|
if(dockDO != null&& "TRUE".equals(dockDO.getAvailable())){ |
|
|
|
if (dockDO != null && "TRUE".equals(dockDO.getAvailable())) { |
|
|
|
return dockDO; |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
throw exception(DOCK_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|