|
@ -579,70 +579,86 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService |
|
|
public int updateRefundsExchangesOutWarehouse(WarehouseOutOrder warehouseOutOrder) { |
|
|
public int updateRefundsExchangesOutWarehouse(WarehouseOutOrder warehouseOutOrder) { |
|
|
|
|
|
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
|
|
WarehouseOutOrder oldOutOrder = warehouseOutOrderMapper.selectWarehouseOutOrderByCode(warehouseOutOrder.getOutOrderCode()); |
|
|
List<WarehouseOutOrderDetail> warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); |
|
|
List<WarehouseOutOrderDetail> warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); |
|
|
if (StringUtils.isEmpty(warehouseOutOrderDetailList)){ |
|
|
if (CollectionUtils.isEmpty(warehouseOutOrderDetailList)){ |
|
|
throw new BusinessException("出库失败,出库单物料详情为空!"); |
|
|
throw new BusinessException("出库单详情数据为空"); |
|
|
|
|
|
} |
|
|
|
|
|
// 检查outOrderSum是否含有null值
|
|
|
|
|
|
List<WarehouseOutOrderDetail> filtList = warehouseOutOrderDetailList.stream() |
|
|
|
|
|
.filter(item ->item.getActualOutOrderSum() != null).collect(Collectors.toList()); |
|
|
|
|
|
if (filtList.size()==0) { |
|
|
|
|
|
throw new BusinessException("实际出库数不能全为空,请检查!"); |
|
|
} |
|
|
} |
|
|
|
|
|
// 检查总出库数是否超出申请数
|
|
|
|
|
|
for (WarehouseOutOrderDetail detail: filtList) { |
|
|
|
|
|
int hasOutNum = Optional.ofNullable(detail.getHasOutOrderSum()).orElse(0); |
|
|
|
|
|
int allOutNum = hasOutNum + detail.getActualOutOrderSum(); |
|
|
|
|
|
int applyNum = Optional.ofNullable(detail.getApplyOutOrderSum()).orElse(0); |
|
|
|
|
|
if(allOutNum > applyNum){ |
|
|
|
|
|
throw new BusinessException("物料"+detail.getMaterialNo()+"总出库数超出申请出库数,请检查!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int updateRows = 0; |
|
|
int updateRows = 0; |
|
|
for (WarehouseOutOrderDetail warehouseOutOrderDetail : warehouseOutOrderDetailList) { |
|
|
for (WarehouseOutOrderDetail detail : filtList) { |
|
|
warehouseOutOrderDetail.setUpdateBy(loginName); |
|
|
detail.setUpdateBy(loginName); |
|
|
warehouseOutOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
detail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
|
detail.setRemark(warehouseOutOrder.getRemark()); |
|
|
//设置已出库数
|
|
|
//设置已出库数
|
|
|
warehouseOutOrderDetail.setHasOutOrderSum(warehouseOutOrderDetail.getActualOutOrderSum()); |
|
|
int hasOutNum = Optional.ofNullable(detail.getHasOutOrderSum()).orElse(0); |
|
|
//设置仓库员
|
|
|
hasOutNum = hasOutNum + detail.getActualOutOrderSum(); |
|
|
warehouseOutOrderDetail.setWarehouseName(loginName); |
|
|
detail.setHasOutOrderSum(hasOutNum); |
|
|
//更新数据库记录
|
|
|
detail.setWarehouseName(loginName); |
|
|
updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); |
|
|
updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(detail); |
|
|
if (updateRows <= 0) { |
|
|
if (updateRows <= 0){ |
|
|
throw new BusinessException("更新出库单详情数据失败"); |
|
|
throw new BusinessException("更新出库单详情数据失败"); |
|
|
} |
|
|
} |
|
|
|
|
|
//更新库存查询记录,新增库存历史
|
|
|
|
|
|
String materialNo = detail.getMaterialNo(); |
|
|
|
|
|
WarehouseInventoryInquiry inventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo); |
|
|
|
|
|
if(inventoryInquiry == null){ |
|
|
|
|
|
throw new BusinessException("更新库存查询数据失败!该物料不存在库存数据"); |
|
|
} |
|
|
} |
|
|
warehouseOutOrder.setUpdateBy(loginName); |
|
|
int inquiryUpdateResult = updateWarehouseInventoryInquiry(oldOutOrder,detail,inventoryInquiry); |
|
|
warehouseOutOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
if (inquiryUpdateResult <= 0){ |
|
|
//表明已出库
|
|
|
throw new BusinessException("更新库存查询数据失败"); |
|
|
warehouseOutOrder.setWarehouseOutStatus("7"); |
|
|
|
|
|
//设置出库时间
|
|
|
|
|
|
warehouseOutOrder.setOutOrderTime(DateUtils.getNowDate()); |
|
|
|
|
|
//设置仓库员
|
|
|
|
|
|
warehouseOutOrder.setWarehouseName(loginName); |
|
|
|
|
|
//计算出库单主表的出库数
|
|
|
|
|
|
Integer outOrderSum = 0; |
|
|
|
|
|
|
|
|
|
|
|
// 检查outOrderSum是否含有null值
|
|
|
|
|
|
boolean hasOutOrderSumNull = warehouseOutOrderDetailList.stream() |
|
|
|
|
|
.anyMatch(item -> item.getActualOutOrderSum() == null); |
|
|
|
|
|
|
|
|
|
|
|
if (hasOutOrderSumNull) { |
|
|
|
|
|
throw new BusinessException("存在实际出库数为空,请检查!"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 检查库存是否超出
|
|
|
|
|
|
boolean hasOutOrderSumOver = warehouseOutOrderDetailList.stream() |
|
|
|
|
|
.anyMatch(item -> item.getActualOutOrderSum() > item.getApplyOutOrderSum()); |
|
|
|
|
|
|
|
|
|
|
|
if (hasOutOrderSumOver) { |
|
|
|
|
|
throw new BusinessException("存在实际出库数大于申请出库数,请检查!"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
//计算出库单主表的出库数
|
|
|
|
|
|
Integer outOrderSum = oldOutOrder.getOutOrderSum() != null ? oldOutOrder.getOutOrderSum() : 0; |
|
|
// 计算各个字段的总和
|
|
|
// 计算各个字段的总和
|
|
|
outOrderSum = warehouseOutOrderDetailList.stream() |
|
|
Integer detailOutOrderSum = filtList.stream() |
|
|
.mapToInt(WarehouseOutOrderDetail::getActualOutOrderSum) |
|
|
.mapToInt(WarehouseOutOrderDetail::getActualOutOrderSum) |
|
|
.sum(); |
|
|
.sum(); |
|
|
|
|
|
outOrderSum = outOrderSum + detailOutOrderSum; |
|
|
//设置出库单主表的出库数
|
|
|
//设置出库单主表的出库数
|
|
|
warehouseOutOrder.setOutOrderSum(outOrderSum); |
|
|
oldOutOrder.setOutOrderSum(outOrderSum); |
|
|
|
|
|
|
|
|
QualityRefundsExchanges tempExchanges = new QualityRefundsExchanges(); |
|
|
/** 更新关联退换货单状态*/ |
|
|
tempExchanges.setOutStorageCode(warehouseOutOrder.getOutOrderCode()); |
|
|
QualityRefundsExchanges refundsExchanges = refundsExchangesMapper.selectQualityRefundsExchangesByCode(oldOutOrder.getRelatedOrderCode()); |
|
|
List<QualityRefundsExchanges> tempExchangesList = refundsExchangesMapper.selectQualityRefundsExchangesList(tempExchanges); |
|
|
if(refundsExchanges == null){ |
|
|
QualityRefundsExchanges refundsExchanges = tempExchangesList.get(0); |
|
|
throw new BusinessException("关联退换货单为空,请检查"); |
|
|
refundsExchanges.setQualityWarehouseStatus("4"); |
|
|
} |
|
|
refundsExchanges.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
if(outOrderSum == oldOutOrder.getEnterpriseSum()){ |
|
|
|
|
|
oldOutOrder.setWarehouseOutStatus("6");//全部出库
|
|
|
|
|
|
refundsExchanges.setQualityWarehouseStatus("4");//全部出库
|
|
|
|
|
|
}else if(outOrderSum < oldOutOrder.getEnterpriseSum()){ |
|
|
|
|
|
oldOutOrder.setWarehouseOutStatus("5");//部分出库
|
|
|
|
|
|
refundsExchanges.setQualityWarehouseStatus("3");//部分出库
|
|
|
|
|
|
} |
|
|
|
|
|
refundsExchanges.setUpdateBy(loginName); |
|
|
refundsExchanges.setUpdateTime(DateUtils.getNowDate()); |
|
|
refundsExchanges.setUpdateTime(DateUtils.getNowDate()); |
|
|
int updateRefundResult = refundsExchangesMapper.updateQualityRefundsExchanges(refundsExchanges); |
|
|
int updateResult = refundsExchangesMapper.updateQualityRefundsExchanges(refundsExchanges); |
|
|
if(updateRefundResult<=0){ |
|
|
if(updateResult<=0){ |
|
|
throw new BusinessException("更新关联退换货订单仓库状态失败!"); |
|
|
throw new BusinessException("更新退换货单失败!"); |
|
|
} |
|
|
} |
|
|
return warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); |
|
|
|
|
|
|
|
|
oldOutOrder.setUpdateBy(loginName); |
|
|
|
|
|
oldOutOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
|
oldOutOrder.setOutOrderTime(DateUtils.getNowDate()); |
|
|
|
|
|
oldOutOrder.setWarehouseName(loginName); |
|
|
|
|
|
return warehouseOutOrderMapper.updateWarehouseOutOrder(oldOutOrder); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
@ -1573,6 +1589,15 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService |
|
|
if (insertDetailResult <= 0){ |
|
|
if (insertDetailResult <= 0){ |
|
|
throw new BusinessException("新增库存履历失败!"); |
|
|
throw new BusinessException("新增库存履历失败!"); |
|
|
} |
|
|
} |
|
|
|
|
|
}else if ("4".equals(oldWarehouseOutOrder.getWarehouseOrderType())){ //退换货单
|
|
|
|
|
|
WarehouseInventoryInquiryDetail inquiryDetail = createInquiryDetail(materialNo,outOrderCode,outOrderDetail.getActualOutOrderSum()); |
|
|
|
|
|
inquiryDetail.setInquiryWarehouseType("15");//公司退货出库
|
|
|
|
|
|
inquiryDetail.setInquiryOrderType("15");//退换货单
|
|
|
|
|
|
inquiryDetail.setInquiryBusinessType("3");//退换货
|
|
|
|
|
|
int insertDetailResult = inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); |
|
|
|
|
|
if (insertDetailResult <= 0){ |
|
|
|
|
|
throw new BusinessException("新增库存履历失败!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return inquiryUpdateResult; |
|
|
return inquiryUpdateResult; |
|
|
} |
|
|
} |
|
|