修改镀层物料申报

liweidong
liweidong-hj 4 days ago
parent 61936c50f3
commit 104dedeb23
  1. 2
      blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/order/pojo/entity/PlateGoodsRecord.java
  2. 84
      blade-service/blade-desk/src/main/java/org/springblade/desk/order/service/impl/PlateGoodsRecordServiceImpl.java

@ -60,7 +60,7 @@ public class PlateGoodsRecord extends BaseEntity {
* 上报银钾剩余量 * 上报银钾剩余量
*/ */
@TableField(value = "SILVER_POTASSIUM_RESIDUE") @TableField(value = "SILVER_POTASSIUM_RESIDUE")
private Double silverPotassiumResidue; private BigDecimal silverPotassiumResidue;
/** /**
* 银钾系数 * 银钾系数

@ -99,44 +99,98 @@ public class PlateGoodsRecordServiceImpl extends BaseServiceImpl<PlateGoodsRecor
return dataList; return dataList;
} }
// @Override
// public boolean save(PlateGoodsRecord entity, List<PlateGoodsRecordDetail> 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 @Override
@Transactional(rollbackFor = Exception.class)
public boolean save(PlateGoodsRecord entity, List<PlateGoodsRecordDetail> detailList) { public boolean save(PlateGoodsRecord entity, List<PlateGoodsRecordDetail> detailList) {
if (entity == null || StringUtils.isEmpty(entity.getGoodsCode())) {
throw new ServiceException("参数错误");
}
String goodsCode = entity.getGoodsCode(); String goodsCode = entity.getGoodsCode();
BigDecimal silverPotassium = entity.getSilverPotassium(); BigDecimal goodsDemand = entity.getGoodsDemand();
BigDecimal coefficient = entity.getCoefficient();
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); BigDecimal silverPotassiumProduct = silverPotassium.multiply(coefficient);
if (sunGoodsDemand.subtract(silverPotassiumProduct).compareTo(BigDecimal.ZERO) >= 0) { if (goodsDemand.compareTo(silverPotassiumProduct) >= 0) {
sunGoodsDemand = sunGoodsDemand.subtract(silverPotassiumProduct); goodsDemand = goodsDemand.subtract(silverPotassiumProduct);
} else { } else {
throw new ServiceException("上报银钾转换后大于银板需求数,请减小上报银钾数"); throw new ServiceException("上报银钾转换后大于银板需求数,请减小上报银钾数");
} }
entity.setSilverPotassium(silverPotassium); entity.setSilverPotassium(silverPotassium);
entity.setSilverPotassiumResidue(silverPotassium.doubleValue()); entity.setSilverPotassiumResidue(silverPotassium);
entity.setCoefficient(coefficient); entity.setCoefficient(coefficient);
} }
entity.setGoodsDemand(sunGoodsDemand); entity.setGoodsDemand(goodsDemand);
entity.setSurplus(sunGoodsDemand); entity.setSurplus(goodsDemand);
entity.setDemandCode(generateCode()); entity.setDemandCode(generateCode());
entity.setStatus(PlateGoodsEnum.STATUS_WAITING.getCode()); entity.setStatus(PlateGoodsEnum.STATUS_WAITING.getCode());
entity.setApprovalStatus(PlateGoodsEnum.STATUS_WAITING.getCode()); entity.setApprovalStatus(PlateGoodsEnum.STATUS_WAITING.getCode());
if (StringUtils.isEmpty(entity.getGoodsName())) { if (StringUtils.isEmpty(entity.getGoodsName())) {
entity.setGoodsName(PlateGoodsConst.GOODS_NAME_MAP.get(entity.getGoodsCode())); entity.setGoodsName(PlateGoodsConst.GOODS_NAME_MAP.get(entity.getGoodsCode()));
} }
if (this.save(entity)) {
for (PlateGoodsRecordDetail detail : detailList) { if (!this.save(entity)) {
detail.setPgrdId(entity.getId()); return false;
}
return detailService.saveBatch(detailList);
} }
return Boolean.FALSE;
if (detailList == null || detailList.isEmpty()) {
return true;
}
for (PlateGoodsRecordDetail detail : detailList) {
detail.setPgrdId(entity.getId());
}
return detailService.saveBatch(detailList);
} }
@Override @Override

Loading…
Cancel
Save