|
|
@ -165,6 +165,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("1"); |
|
|
|
warehouseStorageOrder.setWarehouseEmployee(loginName); |
|
|
|
//设置暂存时间
|
|
|
|
warehouseStorageOrder.setTemporaryTime(new Date()); |
|
|
|
updateWarehouseStorageOrderDetails(warehouseStorageOrder); |
|
|
@ -250,6 +251,80 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
return updateResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存暂收-采购单(采购入库) |
|
|
|
* */ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int temporaryPurchaseSave(WarehouseStorageOrder warehouseStorageOrder) { |
|
|
|
|
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//改变状态为已暂收
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("1"); |
|
|
|
//设置品质状态,为待品质
|
|
|
|
warehouseStorageOrder.setWarehouseQualityStatus("0"); |
|
|
|
warehouseStorageOrder.setWarehouseEmployee(loginName); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
//入库单主表的实际到货数为子表的合计
|
|
|
|
int actualArriveNum = warehouseStorageOrderDetailList.stream().mapToInt(WarehouseStorageOrderDetail::getActualArriveNum).sum(); |
|
|
|
//入库单主表的暂收合格数为子表的合计
|
|
|
|
int temporaryQualifiedNum = warehouseStorageOrderDetailList.stream().mapToInt(WarehouseStorageOrderDetail::getTemporaryQualifiedNum).sum(); |
|
|
|
if (actualArriveNum < temporaryQualifiedNum) { |
|
|
|
throw new BusinessException("暂收合格数不能大于实际到货数"); |
|
|
|
} |
|
|
|
|
|
|
|
//插入实际到货数
|
|
|
|
warehouseStorageOrder.setActualArrivedNum(actualArriveNum); |
|
|
|
//插入暂收合格数
|
|
|
|
warehouseStorageOrder.setTemporaryQualifiedNum(temporaryQualifiedNum); |
|
|
|
//插入暂收不合格数
|
|
|
|
warehouseStorageOrder.setTemporaryUnqualifiedNum(Math.max(0, actualArriveNum - temporaryQualifiedNum)); |
|
|
|
//设置暂存时间
|
|
|
|
warehouseStorageOrder.setTemporaryTime(new Date()); |
|
|
|
int updateDetailResult = updateTemporaryPurchaseDetails(warehouseStorageOrder); |
|
|
|
if (updateDetailResult != warehouseStorageOrder.getWarehouseStorageOrderDetailList().size()) { |
|
|
|
throw new BusinessException("更新入库单明细记录失败"); |
|
|
|
} |
|
|
|
int updateResult = warehouseStorageOrderMapper.updateWarehouseStorageOrder(warehouseStorageOrder); |
|
|
|
if (updateResult <= 0) { |
|
|
|
throw new BusinessException("更新入库单主记录失败"); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
qualityOrderService.insertQualityOrderByWarehouseStorageOrder(warehouseStorageOrder, warehouseStorageOrder.getWarehouseStorageOrderDetailList()); |
|
|
|
} catch (Exception e) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
log.error("生成品质单时发生错误", e); |
|
|
|
throw new BusinessException("生成品质单时发生错误"); |
|
|
|
} |
|
|
|
|
|
|
|
return updateResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存暂收-采购单(采购入库) 子表数据 |
|
|
|
* */ |
|
|
|
private int updateTemporaryPurchaseDetails(WarehouseStorageOrder warehouseStorageOrder) { |
|
|
|
int updateResultDetails = 0; |
|
|
|
List<WarehouseStorageOrderDetail> details = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
if (org.springframework.util.CollectionUtils.isEmpty(details)){ |
|
|
|
return 0; |
|
|
|
} |
|
|
|
for (WarehouseStorageOrderDetail detail : details) { |
|
|
|
detail.setWarehouseStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); |
|
|
|
Integer actualArriveNum = detail.getActualArriveNum(); |
|
|
|
Integer temporaryQualifiedNum = detail.getTemporaryQualifiedNum(); |
|
|
|
if (actualArriveNum < temporaryQualifiedNum){ |
|
|
|
throw new BusinessException("暂收合格数要小于等于实际到货数"); |
|
|
|
} |
|
|
|
updateResultDetails += storageOrderDetailMapper.updateWarehouseStorageOrderDetailByObject(detail); |
|
|
|
} |
|
|
|
return updateResultDetails; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
* 更新仓库入库单详情的数据 |
|
|
|
* */ |
|
|
|