|
|
@ -523,6 +523,58 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存暂收-采购单(仓库入库) |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int updateTemporaryPurchaseWarehouse(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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存暂收-采购单(采购入库) 子表数据 |
|
|
|
* */ |
|
|
|