优化仓库删除的逻辑
This commit is contained in:
@@ -61,15 +61,9 @@ public class DepotService {
|
|||||||
|
|
||||||
public List<Depot> getDepotListByIds(String ids)throws Exception {
|
public List<Depot> getDepotListByIds(String ids)throws Exception {
|
||||||
List<Long> idList = StringUtil.strToLongList(ids);
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
List<Depot> list = new ArrayList<>();
|
|
||||||
try{
|
|
||||||
DepotExample example = new DepotExample();
|
DepotExample example = new DepotExample();
|
||||||
example.createCriteria().andIdIn(idList);
|
example.createCriteria().andIdIn(idList);
|
||||||
list = depotMapper.selectByExample(example);
|
return depotMapper.selectByExample(example);
|
||||||
}catch(Exception e){
|
|
||||||
JshException.readFail(logger, e);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Depot> getDepot()throws Exception {
|
public List<Depot> getDepot()throws Exception {
|
||||||
@@ -188,18 +182,14 @@ public class DepotService {
|
|||||||
int result=0;
|
int result=0;
|
||||||
String [] idArray=ids.split(",");
|
String [] idArray=ids.split(",");
|
||||||
//校验单据子表 jsh_depot_item
|
//校验单据子表 jsh_depot_item
|
||||||
List<DepotItem> depotItemList=null;
|
List<DepotItem> depotItemList = depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
|
||||||
try{
|
|
||||||
depotItemList = depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
|
|
||||||
}catch(Exception e){
|
|
||||||
JshException.readFail(logger, e);
|
|
||||||
}
|
|
||||||
if(depotItemList!=null&&depotItemList.size()>0){
|
if(depotItemList!=null&&depotItemList.size()>0){
|
||||||
logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
|
logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
|
||||||
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
|
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
|
||||||
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
|
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
|
||||||
}
|
}
|
||||||
|
try{
|
||||||
//记录日志
|
//记录日志
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
|
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
|
||||||
@@ -207,18 +197,18 @@ public class DepotService {
|
|||||||
for(Depot depot: list){
|
for(Depot depot: list){
|
||||||
sb.append("[").append(depot.getName()).append("]");
|
sb.append("[").append(depot.getName()).append("]");
|
||||||
}
|
}
|
||||||
logService.insertLog("仓库", sb.toString(),
|
|
||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
//校验通过执行删除操作
|
//校验通过执行删除操作
|
||||||
try{
|
|
||||||
//删除仓库关联的商品的初始库存
|
//删除仓库关联的商品的初始库存
|
||||||
materialInitialStockMapperEx.batchDeleteByDepots(idArray);
|
materialInitialStockMapperEx.batchDeleteByDepots(idArray);
|
||||||
//删除仓库关联的商品的当前库存
|
//删除仓库关联的商品的当前库存
|
||||||
materialCurrentStockMapperEx.batchDeleteByDepots(idArray);
|
materialCurrentStockMapperEx.batchDeleteByDepots(idArray);
|
||||||
//删除仓库
|
//删除仓库
|
||||||
result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||||
}catch(Exception e){
|
//记录日志
|
||||||
|
logService.insertLog("仓库", sb.toString(),
|
||||||
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
|
} catch (Exception e) {
|
||||||
JshException.writeFail(logger, e);
|
JshException.writeFail(logger, e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user