From 104dedeb2391d260e508eccea8e234edcac5a718 Mon Sep 17 00:00:00 2001 From: liweidong-hj Date: Thu, 4 Jun 2026 14:27:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=95=80=E5=B1=82=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=94=B3=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/pojo/entity/PlateGoodsRecord.java | 2 +- .../impl/PlateGoodsRecordServiceImpl.java | 84 +++++++++++++++---- 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/order/pojo/entity/PlateGoodsRecord.java b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/order/pojo/entity/PlateGoodsRecord.java index 8fb9e14ee..15aa90f25 100644 --- a/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/order/pojo/entity/PlateGoodsRecord.java +++ b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/order/pojo/entity/PlateGoodsRecord.java @@ -60,7 +60,7 @@ public class PlateGoodsRecord extends BaseEntity { * 上报银钾剩余量 */ @TableField(value = "SILVER_POTASSIUM_RESIDUE") - private Double silverPotassiumResidue; + private BigDecimal silverPotassiumResidue; /** * 银钾系数 diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/order/service/impl/PlateGoodsRecordServiceImpl.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/order/service/impl/PlateGoodsRecordServiceImpl.java index 7fbe8e27c..c8bbaa372 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/order/service/impl/PlateGoodsRecordServiceImpl.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/order/service/impl/PlateGoodsRecordServiceImpl.java @@ -99,44 +99,98 @@ public class PlateGoodsRecordServiceImpl extends BaseServiceImpl detailList) { +// +// String goodsCode = entity.getGoodsCode(); +// BigDecimal silverPotassium = entity.getSilverPotassium(); +// BigDecimal coefficient = entity.getCoefficient(); +// +// BigDecimal sunGoodsDemand = entity.getGoodsDemand(); +// +// if (goodsCode.equals(PlateGoodsConst.SILVER_PLATE) && silverPotassium.compareTo(BigDecimal.ZERO) > 0) { +// BigDecimal silverPotassiumProduct = silverPotassium.multiply(coefficient); +// +// if (sunGoodsDemand.subtract(silverPotassiumProduct).compareTo(BigDecimal.ZERO) >= 0) { +// sunGoodsDemand = sunGoodsDemand.subtract(silverPotassiumProduct); +// } else { +// throw new ServiceException("上报银钾转换后大于银板需求数,请减小上报银钾数"); +// } +// +// entity.setSilverPotassium(silverPotassium); +// entity.setSilverPotassiumResidue(silverPotassium.doubleValue()); +// entity.setCoefficient(coefficient); +// } +// +// entity.setGoodsDemand(sunGoodsDemand); +// entity.setSurplus(sunGoodsDemand); +// entity.setDemandCode(generateCode()); +// entity.setStatus(PlateGoodsEnum.STATUS_WAITING.getCode()); +// entity.setApprovalStatus(PlateGoodsEnum.STATUS_WAITING.getCode()); +// if (StringUtils.isEmpty(entity.getGoodsName())) { +// entity.setGoodsName(PlateGoodsConst.GOODS_NAME_MAP.get(entity.getGoodsCode())); +// } +// if (this.save(entity)) { +// for (PlateGoodsRecordDetail detail : detailList) { +// detail.setPgrdId(entity.getId()); +// } +// return detailService.saveBatch(detailList); +// } +// return Boolean.FALSE; +// } + @Override + @Transactional(rollbackFor = Exception.class) public boolean save(PlateGoodsRecord entity, List detailList) { + if (entity == null || StringUtils.isEmpty(entity.getGoodsCode())) { + throw new ServiceException("参数错误"); + } String goodsCode = entity.getGoodsCode(); - BigDecimal silverPotassium = entity.getSilverPotassium(); - BigDecimal coefficient = entity.getCoefficient(); + BigDecimal goodsDemand = entity.getGoodsDemand(); - BigDecimal sunGoodsDemand = entity.getGoodsDemand(); + // 银板特殊处理 + if (PlateGoodsConst.SILVER_PLATE.equals(goodsCode) + && entity.getSilverPotassium() != null + && entity.getSilverPotassium().compareTo(BigDecimal.ZERO) > 0) { - if (goodsCode.equals(PlateGoodsConst.SILVER_PLATE) && silverPotassium.compareTo(BigDecimal.ZERO) > 0) { + BigDecimal silverPotassium = entity.getSilverPotassium(); + BigDecimal coefficient = entity.getCoefficient(); BigDecimal silverPotassiumProduct = silverPotassium.multiply(coefficient); - if (sunGoodsDemand.subtract(silverPotassiumProduct).compareTo(BigDecimal.ZERO) >= 0) { - sunGoodsDemand = sunGoodsDemand.subtract(silverPotassiumProduct); + if (goodsDemand.compareTo(silverPotassiumProduct) >= 0) { + goodsDemand = goodsDemand.subtract(silverPotassiumProduct); } else { throw new ServiceException("上报银钾转换后大于银板需求数,请减小上报银钾数"); } entity.setSilverPotassium(silverPotassium); - entity.setSilverPotassiumResidue(silverPotassium.doubleValue()); + entity.setSilverPotassiumResidue(silverPotassium); entity.setCoefficient(coefficient); } - entity.setGoodsDemand(sunGoodsDemand); - entity.setSurplus(sunGoodsDemand); + entity.setGoodsDemand(goodsDemand); + entity.setSurplus(goodsDemand); entity.setDemandCode(generateCode()); entity.setStatus(PlateGoodsEnum.STATUS_WAITING.getCode()); entity.setApprovalStatus(PlateGoodsEnum.STATUS_WAITING.getCode()); + if (StringUtils.isEmpty(entity.getGoodsName())) { entity.setGoodsName(PlateGoodsConst.GOODS_NAME_MAP.get(entity.getGoodsCode())); } - if (this.save(entity)) { - for (PlateGoodsRecordDetail detail : detailList) { - detail.setPgrdId(entity.getId()); - } - return detailService.saveBatch(detailList); + + if (!this.save(entity)) { + return false; } - return Boolean.FALSE; + + if (detailList == null || detailList.isEmpty()) { + return true; + } + + for (PlateGoodsRecordDetail detail : detailList) { + detail.setPgrdId(entity.getId()); + } + return detailService.saveBatch(detailList); } @Override