|
|
@@ -201,7 +201,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
//赋值箱片
|
|
|
for (OutboundItemVO outboundItemVO : outboundIngList) {
|
|
|
//箱
|
|
|
- outboundItemVO.setOutingBox(Integer.valueOf(outboundItemVO.getOutingQty().divide(outboundItemVO.getPackBox(),0,RoundingMode.DOWN).toString()) );
|
|
|
+ outboundItemVO.setOutingBox(Integer.valueOf(outboundItemVO.getOutingQty().divide(outboundItemVO.getPackBox(), 0, RoundingMode.DOWN).toString()));
|
|
|
//片
|
|
|
outboundItemVO.setOutingPiece(outboundItemVO.getOutingQty().remainder(outboundItemVO.getPackBox()));
|
|
|
}
|
|
|
@@ -218,7 +218,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
for (OutboundItemVO outboundItemVO : itemList) {
|
|
|
if (outboundItemVO.getSkuId() != null) { //过滤外协品 外协品没有箱片
|
|
|
//箱
|
|
|
- outboundItemVO.setOutBox(Integer.valueOf(outboundItemVO.getOutingQty().divide(outboundItemVO.getPackBox(),0,RoundingMode.DOWN).toString()) );
|
|
|
+ outboundItemVO.setOutBox(Integer.valueOf(outboundItemVO.getOutingQty().divide(outboundItemVO.getPackBox(), 0, RoundingMode.DOWN).toString()));
|
|
|
//片
|
|
|
outboundItemVO.setOutPiece(outboundItemVO.getOutingQty().remainder(outboundItemVO.getPackBox()));
|
|
|
}
|
|
|
@@ -990,82 +990,142 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
Map<String, List<OutboundItemVO>> delOrderOutItemVOListMap = deleteItemList.stream().collect(Collectors.groupingBy(OutboundItemVO::getFromId));
|
|
|
//出库明细汇总循环
|
|
|
for (String fromId : orderOutItemVOListMap.keySet()) {
|
|
|
- //出库明细删除汇总循环
|
|
|
- for (String delFromId : delOrderOutItemVOListMap.keySet()) {
|
|
|
- //新建出库明细来源Id = 删除出库明细来源Id
|
|
|
- if (fromId.equals(delFromId)) {
|
|
|
- //region 提取新建分组后的明细
|
|
|
- List<OutboundItemVO> orderOutItemVOListGroup = orderOutItemVOListMap.get(fromId);
|
|
|
- //分组后的明细 出库数量和金额总和
|
|
|
- BigDecimal orderSumQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal orderSumAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- //分组后的明细 原出库数量和金额总和
|
|
|
- BigDecimal updateOrderOutQty = BigDecimal.ZERO;
|
|
|
- BigDecimal updateOrderOutAmt = BigDecimal.ZERO;
|
|
|
- BigDecimal updateOrderOutingQty = BigDecimal.ZERO;
|
|
|
- BigDecimal updateOrderOutingAmt = BigDecimal.ZERO;
|
|
|
- //已出库
|
|
|
- if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
- updateOrderOutQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- updateOrderOutAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- //出库中
|
|
|
- else {
|
|
|
- updateOrderOutingQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- updateOrderOutingAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- //endregion
|
|
|
+ //有需要删除的修改数据
|
|
|
+ if(delOrderOutItemVOListMap!=null && delOrderOutItemVOListMap.keySet().size()>0){
|
|
|
+ //出库明细删除汇总循环
|
|
|
+ for (String delFromId : delOrderOutItemVOListMap.keySet()) {
|
|
|
+ //新建出库明细来源Id = 删除出库明细来源Id
|
|
|
+ if (fromId.equals(delFromId)) {
|
|
|
+
|
|
|
+ //region 提取新建分组后的明细
|
|
|
+ List<OutboundItemVO> orderOutItemVOListGroup = orderOutItemVOListMap.get(fromId);
|
|
|
+ //分组后的明细 出库数量和金额总和
|
|
|
+ BigDecimal orderSumQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderSumAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //分组后的明细 原出库数量和金额总和
|
|
|
+ BigDecimal updateOrderOutQty = BigDecimal.ZERO;
|
|
|
+ BigDecimal updateOrderOutAmt = BigDecimal.ZERO;
|
|
|
+ BigDecimal updateOrderOutingQty = BigDecimal.ZERO;
|
|
|
+ BigDecimal updateOrderOutingAmt = BigDecimal.ZERO;
|
|
|
+ //已出库
|
|
|
+ if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ updateOrderOutQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ updateOrderOutAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //出库中
|
|
|
+ else {
|
|
|
+ updateOrderOutingQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ updateOrderOutingAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
|
|
|
- //region 提取删除分组后的明细
|
|
|
- List<OutboundItemVO> delOrderOutItemVOListGroup = delOrderOutItemVOListMap.get(delFromId);
|
|
|
- BigDecimal orderDelOutQty = BigDecimal.ZERO;
|
|
|
- BigDecimal orderDelOutAmt = BigDecimal.ZERO;
|
|
|
- //已出库
|
|
|
- if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
- orderDelOutQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- orderDelOutAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- //出库中
|
|
|
- else if (Constant.OutStatus.CHUKUZHONG.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
- orderDelOutQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- orderDelOutAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- //endregion
|
|
|
+ //region 提取删除分组后的明细
|
|
|
+ List<OutboundItemVO> delOrderOutItemVOListGroup = delOrderOutItemVOListMap.get(delFromId);
|
|
|
+ BigDecimal orderDelOutQty = BigDecimal.ZERO;
|
|
|
+ BigDecimal orderDelOutAmt = BigDecimal.ZERO;
|
|
|
+ //已出库
|
|
|
+ if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ orderDelOutQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ orderDelOutAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //出库中
|
|
|
+ else if (Constant.OutStatus.CHUKUZHONG.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ orderDelOutQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ orderDelOutAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
|
|
|
- //region 反写订单数据
|
|
|
- //根据id查询
|
|
|
- OrderResponse orderResponse = orderMapper.selectById(fromId);
|
|
|
- Order order = new Order();
|
|
|
- order.setOrderId(fromId);
|
|
|
- //已出库
|
|
|
- if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
- order.setOutQty(updateOrderOutQty.negate().add(orderSumQty).subtract(orderDelOutQty));
|
|
|
- order.setOutAmt(updateOrderOutAmt.negate().add(orderSumAmt).subtract(orderDelOutAmt));
|
|
|
- order.setOutingQty(orderDelOutQty);
|
|
|
- order.setOutingAmt(orderDelOutAmt);
|
|
|
- //出库状态
|
|
|
- String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
- orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
- order.setOutStatus(outStatus);
|
|
|
- }
|
|
|
- //出库中
|
|
|
- else if (Constant.OutStatus.CHUKUZHONG.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
- order.setOutingQty(updateOrderOutingQty.negate().add(orderSumQty).subtract(orderDelOutQty));
|
|
|
- order.setOutingAmt(updateOrderOutingAmt.negate().add(orderSumQty).subtract(orderDelOutAmt));
|
|
|
- //出库状态
|
|
|
- String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
- orderResponse.getOutQty(), orderResponse.getSumQuantity());
|
|
|
- order.setOutStatus(outStatus);
|
|
|
- }
|
|
|
- //修改
|
|
|
- int countRow = orderMapper.updateById(order);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
+ //region 反写订单数据
|
|
|
+ //根据id查询
|
|
|
+ OrderResponse orderResponse = orderMapper.selectById(fromId);
|
|
|
+ Order order = new Order();
|
|
|
+ order.setOrderId(fromId);
|
|
|
+ //已出库
|
|
|
+ if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ order.setOutQty(updateOrderOutQty.negate().add(orderSumQty).subtract(orderDelOutQty));
|
|
|
+ order.setOutAmt(updateOrderOutAmt.negate().add(orderSumAmt).subtract(orderDelOutAmt));
|
|
|
+ order.setOutingQty(orderDelOutQty);
|
|
|
+ order.setOutingAmt(orderDelOutAmt);
|
|
|
+ //出库状态
|
|
|
+ String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
+ orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
+ order.setOutStatus(outStatus);
|
|
|
+ }
|
|
|
+ //出库中
|
|
|
+ else if (Constant.OutStatus.CHUKUZHONG.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ order.setOutingQty(updateOrderOutingQty.negate().add(orderSumQty).subtract(orderDelOutQty));
|
|
|
+ order.setOutingAmt(updateOrderOutingAmt.negate().add(orderSumQty).subtract(orderDelOutAmt));
|
|
|
+ //出库状态
|
|
|
+ String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
+ orderResponse.getOutQty(), orderResponse.getSumQuantity());
|
|
|
+ order.setOutStatus(outStatus);
|
|
|
+ }
|
|
|
+ //修改
|
|
|
+ int countRow = orderMapper.updateById(order);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
}
|
|
|
- //endregion
|
|
|
}
|
|
|
}
|
|
|
+ //没有需要删除的修改数据
|
|
|
+ else{
|
|
|
+
|
|
|
+ //region 提取新建分组后的明细
|
|
|
+ List<OutboundItemVO> orderOutItemVOListGroup = orderOutItemVOListMap.get(fromId);
|
|
|
+ //分组后的明细 出库数量和金额总和
|
|
|
+ BigDecimal orderSumQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderSumAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //分组后的明细 原出库数量和金额总和
|
|
|
+ BigDecimal updateOrderOutQty = BigDecimal.ZERO;
|
|
|
+ BigDecimal updateOrderOutAmt = BigDecimal.ZERO;
|
|
|
+ BigDecimal updateOrderOutingQty = BigDecimal.ZERO;
|
|
|
+ BigDecimal updateOrderOutingAmt = BigDecimal.ZERO;
|
|
|
+ //已出库
|
|
|
+ if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ updateOrderOutQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ updateOrderOutAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //出库中
|
|
|
+ else {
|
|
|
+ updateOrderOutingQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ updateOrderOutingAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 反写订单数据
|
|
|
+ //根据id查询
|
|
|
+ OrderResponse orderResponse = orderMapper.selectById(fromId);
|
|
|
+ Order order = new Order();
|
|
|
+ order.setOrderId(fromId);
|
|
|
+ //已出库
|
|
|
+ if (Constant.OutStatus.YICHUKU.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ order.setOutQty(updateOrderOutQty.negate().add(orderSumQty));
|
|
|
+ order.setOutAmt(updateOrderOutAmt.negate().add(orderSumAmt));
|
|
|
+ //出库状态
|
|
|
+ String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
+ orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
+ order.setOutStatus(outStatus);
|
|
|
+ }
|
|
|
+ //出库中
|
|
|
+ else if (Constant.OutStatus.CHUKUZHONG.getName().equals(outboundResponse.getOutStatus())) {
|
|
|
+ order.setOutingQty(updateOrderOutingQty.negate().add(orderSumQty));
|
|
|
+ order.setOutingAmt(updateOrderOutingAmt.negate().add(orderSumQty));
|
|
|
+ //出库状态
|
|
|
+ String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
+ orderResponse.getOutQty(), orderResponse.getSumQuantity());
|
|
|
+ order.setOutStatus(outStatus);
|
|
|
+ }
|
|
|
+ //修改
|
|
|
+ int countRow = orderMapper.updateById(order);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1241,6 +1301,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
Map<String, List<OutboundItemResponse>> orderOutItemListMap = itemList.stream().collect(Collectors.groupingBy(OutboundItemResponse::getFromId));
|
|
|
//出库明细汇总循环
|
|
|
for (String fromId : orderOutItemListMap.keySet()) {
|
|
|
+
|
|
|
//region 提取新建分组后的明细
|
|
|
//分组后的明细 原出库数量和金额总和
|
|
|
List<OutboundItemResponse> orderOutItemListGroup = orderOutItemListMap.get(fromId);
|
|
|
@@ -1542,51 +1603,88 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
Map<String, List<OutboundItemVO>> delOrderOutItemVOListMap = deleteItemList.stream().collect(Collectors.groupingBy(OutboundItemVO::getFromId));
|
|
|
//出库明细汇总循环
|
|
|
for (String fromId : orderOutItemVOListMap.keySet()) {
|
|
|
- //出库明细删除汇总循环
|
|
|
- for (String delFromId : delOrderOutItemVOListMap.keySet()) {
|
|
|
- //新建出库明细来源Id = 删除出库明细来源Id
|
|
|
- if (fromId.equals(delFromId)) {
|
|
|
- //region 提取新建分组后的明细
|
|
|
- List<OutboundItemVO> orderOutItemVOListGroup = orderOutItemVOListMap.get(fromId);
|
|
|
- //分组后的明细 出库数量和金额总和
|
|
|
- BigDecimal orderSumQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal orderSumAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- //分组后的明细 原出库数量和金额总和
|
|
|
- BigDecimal updateOrderOutingQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal updateOrderOutingAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- //endregion
|
|
|
+ //有需要删除的办理数据
|
|
|
+ if (delOrderOutItemVOListMap != null && delOrderOutItemVOListMap.keySet().size() > 0) {
|
|
|
+ //出库明细删除汇总循环
|
|
|
+ for (String delFromId : delOrderOutItemVOListMap.keySet()) {
|
|
|
+ //新建出库明细来源Id = 删除出库明细来源Id
|
|
|
+ if (fromId.equals(delFromId)) {
|
|
|
+ //region 提取新建分组后的明细
|
|
|
+ List<OutboundItemVO> orderOutItemVOListGroup = orderOutItemVOListMap.get(fromId);
|
|
|
+ //分组后的明细 出库数量和金额总和
|
|
|
+ BigDecimal orderSumQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderSumAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //分组后的明细 原出库数量和金额总和
|
|
|
+ BigDecimal updateOrderOutingQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal updateOrderOutingAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //endregion
|
|
|
|
|
|
- //region 提取删除分组后的明细
|
|
|
- List<OutboundItemVO> delOrderOutItemVOListGroup = delOrderOutItemVOListMap.get(delFromId);
|
|
|
- BigDecimal orderDelOutingQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal orderDelOutingAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal orderDelOutQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal orderDelOutAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- //endregion
|
|
|
+ //region 提取删除分组后的明细
|
|
|
+ List<OutboundItemVO> delOrderOutItemVOListGroup = delOrderOutItemVOListMap.get(delFromId);
|
|
|
+ BigDecimal orderDelOutingQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderDelOutingAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderDelOutQty = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderDelOutAmt = delOrderOutItemVOListGroup.stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //endregion
|
|
|
|
|
|
- //region 反写订单数据
|
|
|
- //根据id查询
|
|
|
- OrderResponse orderResponse = orderMapper.selectById(fromId);
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- Order order = new Order();
|
|
|
- order.setOrderId(fromId);
|
|
|
- order.setOutQty(orderSumQty.subtract(orderDelOutQty));
|
|
|
- order.setOutAmt(orderSumAmt.subtract(orderDelOutAmt));
|
|
|
- order.setOutingQty((updateOrderOutingQty.add(orderDelOutingQty)).negate());
|
|
|
- order.setOutingAmt((updateOrderOutingAmt.add(orderDelOutingAmt)).negate());
|
|
|
- //出库状态
|
|
|
- String orderOutStatus = this.setOutStatus(orderResponse.getOutingQty().subtract(orderSumQty).add(orderDelOutQty),
|
|
|
- orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
- order.setOutStatus(orderOutStatus);
|
|
|
- //修改
|
|
|
- int countRow = orderMapper.updateById(order);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
+ //region 反写订单数据
|
|
|
+ //根据id查询
|
|
|
+ OrderResponse orderResponse = orderMapper.selectById(fromId);
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ Order order = new Order();
|
|
|
+ order.setOrderId(fromId);
|
|
|
+ order.setOutQty(orderSumQty.subtract(orderDelOutQty));
|
|
|
+ order.setOutAmt(orderSumAmt.subtract(orderDelOutAmt));
|
|
|
+ order.setOutingQty((updateOrderOutingQty.add(orderDelOutingQty)).negate());
|
|
|
+ order.setOutingAmt((updateOrderOutingAmt.add(orderDelOutingAmt)).negate());
|
|
|
+ //出库状态
|
|
|
+ String orderOutStatus = this.setOutStatus(orderResponse.getOutingQty().subtract(orderSumQty).add(orderDelOutQty),
|
|
|
+ orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
+ order.setOutStatus(orderOutStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = orderMapper.updateById(order);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
}
|
|
|
- //endregion
|
|
|
}
|
|
|
}
|
|
|
+ //没有需要删除的办理数据
|
|
|
+ else {
|
|
|
+ //region 提取新建分组后的明细
|
|
|
+ List<OutboundItemVO> orderOutItemVOListGroup = orderOutItemVOListMap.get(fromId);
|
|
|
+ //分组后的明细 出库数量和金额总和
|
|
|
+ BigDecimal orderSumQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderSumAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //分组后的明细 原出库数量和金额总和
|
|
|
+ BigDecimal updateOrderOutingQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal updateOrderOutingAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getUpdateOrderOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 反写订单数据
|
|
|
+ //根据id查询
|
|
|
+ OrderResponse orderResponse = orderMapper.selectById(fromId);
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ Order order = new Order();
|
|
|
+ order.setOrderId(fromId);
|
|
|
+ order.setOutQty(orderSumQty);
|
|
|
+ order.setOutAmt(orderSumAmt);
|
|
|
+ order.setOutingQty(updateOrderOutingQty.negate());
|
|
|
+ order.setOutingAmt(updateOrderOutingAmt.negate());
|
|
|
+ //出库状态
|
|
|
+ String orderOutStatus = this.setOutStatus(orderResponse.getOutingQty().subtract(orderSumQty),
|
|
|
+ orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
+ order.setOutStatus(orderOutStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = orderMapper.updateById(order);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1787,7 +1885,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
//出库状态
|
|
|
String outStatus = null;
|
|
|
//出库中+已出库 小于 总数 或者 出库中数量小于等于订单总数量
|
|
|
- if (intoingQty.compareTo(sumQty) <= 0 && intoingQty.add(intoQty).compareTo(sumQty) <= 0 ) {
|
|
|
+ if (intoingQty.compareTo(sumQty) <= 0 && intoingQty.add(intoQty).compareTo(sumQty) <= 0 && intoQty.compareTo(sumQty) < 0) {
|
|
|
//出库中
|
|
|
outStatus = Constant.OutStatus.CHUKUZHONG.getName();
|
|
|
}
|