修改镀层物料申报

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")
private Double silverPotassiumResidue;
private BigDecimal silverPotassiumResidue;
/**
* 银钾系数

@ -99,44 +99,98 @@ public class PlateGoodsRecordServiceImpl extends BaseServiceImpl<PlateGoodsRecor
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
@Transactional(rollbackFor = Exception.class)
public boolean save(PlateGoodsRecord entity, List<PlateGoodsRecordDetail> 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

Loading…
Cancel
Save