Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManagerImpl.java =================================================================== diff -u -r25091 -r25145 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManagerImpl.java (.../GodownEntryManagerImpl.java) (revision 25091) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/GodownEntryManagerImpl.java (.../GodownEntryManagerImpl.java) (revision 25145) @@ -728,6 +728,8 @@ disposableGoodsStock, disposableGoodsBatch, disposableGoodsBatchStock); objectDao.save(identification); + identification.setAncestorId(identification.getId()); + objectDao.update(identification); godownEntryItem.setIdentificationID(identification.getId()); } @@ -881,6 +883,8 @@ disposableGoodsStock, disposableGoodsBatch, disposableGoodsBatchStock); objectDao.save(identification); + identification.setAncestorId(identification.getId()); + objectDao.update(identification); godownEntryItem.setIdentificationID(identification.getId()); //记录各标识库存数量调整变动结果 DisposableGoodsStorageAdjustVo newDisposableGoodsStorageAdjustVo = new DisposableGoodsStorageAdjustVo(); @@ -898,6 +902,8 @@ disposableGoodsStock, disposableGoodsBatch, disposableGoodsBatchStock); objectDao.save(identification); + identification.setAncestorId(identification.getId()); + objectDao.update(identification); godownEntryItem.setIdentificationID(identification.getId()); //记录各标识库存数量调整变动结果 DisposableGoodsStorageAdjustVo disposableGoodsStorageAdjustVo = new DisposableGoodsStorageAdjustVo(); @@ -914,6 +920,9 @@ disposableGoodsStock, disposableGoodsBatch, disposableGoodsBatchStock); objectDao.save(identification); + identification.setAncestorId(identification.getId()); + objectDao.update(identification); + godownEntryItem.setIdentificationID(identification.getId()); //记录各标识库存数量调整变动结果 DisposableGoodsStorageAdjustVo disposableGoodsStorageAdjustVo = new DisposableGoodsStorageAdjustVo(); Index: ssts-returngoods/src/main/java/com/forgon/disinfectsystem/returngoodsrecord/service/ReturnGoodsRecordManagerImpl.java =================================================================== diff -u -r25091 -r25145 --- ssts-returngoods/src/main/java/com/forgon/disinfectsystem/returngoodsrecord/service/ReturnGoodsRecordManagerImpl.java (.../ReturnGoodsRecordManagerImpl.java) (revision 25091) +++ ssts-returngoods/src/main/java/com/forgon/disinfectsystem/returngoodsrecord/service/ReturnGoodsRecordManagerImpl.java (.../ReturnGoodsRecordManagerImpl.java) (revision 25145) @@ -274,11 +274,11 @@ String sql = String // .format(" select d from %s i,%s d where i.id = d.invoice.id and i.depart = '%s' and d.name = '%s' and d.batch = '%s' and (ABS(d.price-%s)<%s) and (d.amount > %s(d.returnedAmount,0)) and d.identificationID is not null and d.invoiceItemID is not null order by i.applicationTime desc", - .format(" select d from %s i,%s d where i.id = d.invoice.id and i.sourceWarehouseId=%s and i.settleAccountsDepart = '%s' and d.disposableGoodsBatchStockID=%s and (ABS(d.price-%s)<%s) and (d.amount > %s(d.returnedAmount,0)) and d.identificationID is not null and d.invoiceItemID is not null order by i.applicationTime desc", + .format(" select d from %s i,%s d where i.id = d.invoice.id and i.sourceWarehouseId=%s and i.settleAccountsDepart = '%s' and d.disposableGoodsBatchStockID=%s and (ABS(d.price-%s)<%s) and (d.amount > (%s(d.returnedAmount,0)+%s(d.useAmount,0))) and d.identificationID is not null and d.invoiceItemID is not null order by i.applicationTime desc", Invoice.class.getSimpleName(), DiposableGoodsItem.class.getSimpleName(), warehouseID,depart, disposableGoodsBatchStockID, price.toString(), - Constants.PRICE_TOLERANCE_0_001_STR, isNullFunction); + Constants.PRICE_TOLERANCE_0_001_STR, isNullFunction, isNullFunction); list = objectDao.findByHql(sql, 0, batchCount); return list; @@ -291,7 +291,7 @@ String sql = String // .format(" select d from %s i,%s d where i.id = d.invoice.id and i.depart = '%s' and d.name = '%s' and d.batch = '%s' and (ABS(d.price-%s)<%s) and (d.amount > %s(d.returnedAmount,0)) and d.identificationID is not null and d.invoiceItemID is not null order by i.applicationTime desc", - .format(" select d from %s i,%s d where i.id = d.invoice.id and i.sourceWarehouseId=%s and i.invoicePlan.id = %s and d.identificationID=%s and (d.amount > %s(d.returnedAmount,0)) and d.identificationID is not null and d.invoiceItemID is not null order by i.applicationTime desc", + .format(" select d from %s i,%s d where i.id = d.invoice.id and i.sourceWarehouseId=%s and i.invoicePlan.id = %s and d.identificationID=%s and (d.amount > (%s(d.returnedAmount,0)+%s(d.useAmount,0))) and d.identificationID is not null and d.invoiceItemID is not null order by i.applicationTime desc", Invoice.class.getSimpleName(), DiposableGoodsItem.class.getSimpleName(), warehouseID,invoicePlanId, identificationID, @@ -301,6 +301,18 @@ return list; } + private void addTargetWarehouseAmount( + DiposableGoodsItem sendOutDiposableGoodsItem, long amountChange) { + Long targetIdentificationId = sendOutDiposableGoodsItem.getTargetIdentificationId(); + if(targetIdentificationId == null){ + return ;// 旧数据 + } + DisposableGoodsIdentification disposableGoodsIdentification = (DisposableGoodsIdentification)objectDao.getById(DisposableGoodsIdentification.class.getSimpleName(), targetIdentificationId); + if(disposableGoodsIdentification == null){ + throw new RuntimeException("目标标识号已被删除!"); + } + diposableGoodsManager.adjustAmount(disposableGoodsIdentification, amountChange); + } /** * 退货某一项物品(批次+价格),因为发货明细可能会很多,所以每次只取10个来退货,一直到所有物品退完 * @param warehouseID @@ -360,13 +372,17 @@ DiposableGoodsItem sendOutDiposableGoodsItem = list.get(i);// 发货明细 Integer amount = sendOutDiposableGoodsItem.getAmount(); Long returnedAmount = sendOutDiposableGoodsItem.getReturnedAmount(); + Long useAmount = sendOutDiposableGoodsItem.getUseAmount(); if(returnedAmount == null){ returnedAmount = 0L;// 兼容旧数据 } - if(amount <= returnedAmount){ + if(useAmount == null){ + useAmount = 0L; + } + if(amount <= returnedAmount+useAmount){ continue; } - Long sendOutItemAmountCanReturn = amount - returnedAmount;// 发货项可退货的数量 + Long sendOutItemAmountCanReturn = amount - (returnedAmount+useAmount);// 发货项可退货的数量 Long curAmountCanReturn = Math.min(sendOutItemAmountCanReturn, amountToReturn);// 当前可退货数量 String identificationIDStr = sendOutDiposableGoodsItem.getIdentificationID().toString(); @@ -380,6 +396,9 @@ } Long amountChange = curAmountCanReturn; diposableGoodsManager.adjustAmount(identification, amountChange); + + // 减少发货时的目标标识库存 + addTargetWarehouseAmount(sendOutDiposableGoodsItem, -amountChange); objectDao.update(identification); objectDao.update(identification.getBatchStock()); objectDao.update(identification.getBatchStock().getDiposableGoods()); @@ -1540,9 +1559,9 @@ throw new RuntimeException("一次性物品定义已被删除!"); } sql.append(String - .format("select d.price as price,d.fluctuationPrice as fluctuationPrice, sum(%s(d.amount,0)) as sumAmount, sum(%s(d.returnedAmount,0)) as sumReturnedAmount from invoice i inner join DiposableGoodsItem d" - + " on i.id = d.invoice_id inner join DisposableGoods dg on d.disposableGoodsID=dg.id where d.disposableGoodsBatchStockID=%s and %s(d.amount,0)>%s(d.returnedAmount,0) and d.identificationID is not null ", isNullFunction, - isNullFunction,disposableGoodsBatchStockID,isNullFunction,isNullFunction)); + .format("select d.price as price,d.fluctuationPrice as fluctuationPrice, sum(%s(d.amount,0)) as sumAmount, sum(%s(d.returnedAmount,0)+%s(d.useAmount,0)) as sumReturnedAmount from invoice i inner join DiposableGoodsItem d" + + " on i.id = d.invoice_id inner join DisposableGoods dg on d.disposableGoodsID=dg.id where d.disposableGoodsBatchStockID=%s and %s(d.amount,0)>(%s(d.returnedAmount,0)+%s(d.useAmount,0)) and d.identificationID is not null ", isNullFunction,isNullFunction, + isNullFunction,disposableGoodsBatchStockID,isNullFunction,isNullFunction,isNullFunction)); sql.append(" and i.settleAccountsDepart = '" + depart + "'");// 限定部门 sql.append(" group by d.price, d.fluctuationPrice"); ResultSet resultSet = objectDao.executeSql(sql.toString()); @@ -1581,10 +1600,10 @@ String isNullFunction = DatabaseUtil.getSqlIsNullFunctionName(dbConnection); String sql = String .format(" where po.id in(select distinct d.disposableGoodsBatchStockID from %s i,%s d" - + " where i.id = d.invoice.id and d.disposableGoodsID='%s' and %s(d.amount,0)>%s(d.returnedAmount,0) and i.sourceWarehouseId=%s and i.settleAccountsDepart ='%s')", + + " where i.id = d.invoice.id and d.disposableGoodsID='%s' and %s(d.amount,0)>(%s(d.returnedAmount,0)+%s(d.useAmount,0)) and i.sourceWarehouseId=%s and i.settleAccountsDepart ='%s')", Invoice.class.getSimpleName(), DiposableGoodsItem.class.getSimpleName(), - disposableGoodsID, isNullFunction, isNullFunction,warehouseID, + disposableGoodsID, isNullFunction, isNullFunction,isNullFunction,warehouseID, depart); List batchStocks = diposableGoodBatchStockManager .getDisposableGoodsBatchStockBySql(sql); @@ -1604,9 +1623,9 @@ String isNullFunction = DatabaseUtil.getSqlIsNullFunctionName(dbConnection); sql.append(String - .format("select dg.name,dg.specification,dg.applicationSpecification,dg.unit, dbs.barcode,dbs.batchNumber,dbs.expDate,dbs.disposableGoodsId,dbs.diposablegoods_id as disposableGoodsStockId,dbs.disposableGoodsBatchId,dbs.id as disposableGoodsBatchStockId,d.identificationID, d.price as price,d.fluctuationPrice as fluctuationPrice, %s(d.amount,0) as sumAmount, %s(d.returnedAmount,0) as sumReturnedAmount from invoice i inner join DiposableGoodsItem d" - + " on i.id = d.invoice_id inner join DisposableGoods dg on d.disposableGoodsID=dg.id inner join DisposableGoodsBatchStock dbs on d.disposableGoodsBatchStockID=dbs.id where i.invoicePlan_ID=%s and %s(d.amount,0)>%s(d.returnedAmount,0) and d.identificationID is not null ", isNullFunction, - isNullFunction,invoicePlanId,isNullFunction,isNullFunction)); + .format("select dg.name,dg.specification,dg.applicationSpecification,dg.unit, dbs.barcode,dbs.batchNumber,dbs.expDate,dbs.disposableGoodsId,dbs.diposablegoods_id as disposableGoodsStockId,dbs.disposableGoodsBatchId,dbs.id as disposableGoodsBatchStockId,d.identificationID, d.price as price,d.fluctuationPrice as fluctuationPrice, %s(d.amount,0) as sumAmount, (%s(d.returnedAmount,0)+%s(d.useAmount,0)) as sumReturnedAmount from invoice i inner join DiposableGoodsItem d" + + " on i.id = d.invoice_id inner join DisposableGoods dg on d.disposableGoodsID=dg.id inner join DisposableGoodsBatchStock dbs on d.disposableGoodsBatchStockID=dbs.id where i.invoicePlan_ID=%s and %s(d.amount,0)>(%s(d.returnedAmount,0)+%s(d.useAmount,0)) and d.identificationID is not null ", isNullFunction, + isNullFunction,isNullFunction,invoicePlanId,isNullFunction,isNullFunction,isNullFunction)); sql.append(" and i.sourceWarehouseId = " + warehouseID + "");// 限定仓库 // sql.append(" group by d.price, d.fluctuationPrice"); ResultSet resultSet = objectDao.executeSql(sql.toString()); Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/invoicemanager/DiposableGoodsItem.java =================================================================== diff -u -r23492 -r25145 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/invoicemanager/DiposableGoodsItem.java (.../DiposableGoodsItem.java) (revision 23492) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/invoicemanager/DiposableGoodsItem.java (.../DiposableGoodsItem.java) (revision 25145) @@ -1,8 +1,6 @@ package com.forgon.disinfectsystem.entity.invoicemanager; import javax.persistence.Entity; -import org.hibernate.annotations.DynamicInsert; -import org.hibernate.annotations.DynamicUpdate; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -14,13 +12,19 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; import com.forgon.tools.db.DatabaseUtil; /** * @author WangYi 2012-3-5 */ +/** + * @author dandan 2018年12月14日 上午11:10:10 + * + */ @Entity @DynamicInsert(false) @DynamicUpdate(true) @@ -36,6 +40,7 @@ ,@Index(columnList = "returnGoodsRecordID", name = "returnGoodsRecordID_index") ,@Index(columnList = "invoiceItemID", name = "invoiceItemID_index") ,@Index(columnList = "returnGoodsItemID", name = "returnGoodsItemID_index") +,@Index(columnList = "useAmount") }) @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class DiposableGoodsItem { @@ -48,12 +53,20 @@ private Long returnedAmount;// 退货数量 + /** + * 使用数量 + */ + private Long useAmount; + private String barcode; //一次性物品条码 private String expensiveDGBarcode;// 高值耗材条码 private Long identificationID;// 标识对象的ID + + private Long targetIdentificationId; + private Long expensiveDisposablegoodsId; private Long disposableGoodsID ;// 一次性物品id @@ -152,6 +165,14 @@ this.returnedAmount = returnedAmount; } + public Long getUseAmount() { + return useAmount; + } + + public void setUseAmount(Long useAmount) { + this.useAmount = useAmount; + } + public String getBarcode() { return barcode; } @@ -176,6 +197,14 @@ this.identificationID = identificationID; } + public Long getTargetIdentificationId() { + return targetIdentificationId; + } + + public void setTargetIdentificationId(Long targetIdentificationId) { + this.targetIdentificationId = targetIdentificationId; + } + public Long getExpensiveDisposablegoodsId() { return expensiveDisposablegoodsId; } @@ -335,6 +364,9 @@ if (!DatabaseUtil.isPoIdValid(identificationID)) { return false; } + if (!DatabaseUtil.isPoIdValid(targetIdentificationId)) { + return false; + } if (invoice == null) { return false; } Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodsManagerImpl.java =================================================================== diff -u -r25142 -r25145 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodsManagerImpl.java (.../DiposableGoodsManagerImpl.java) (revision 25142) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodsManagerImpl.java (.../DiposableGoodsManagerImpl.java) (revision 25145) @@ -2564,7 +2564,10 @@ disposableGoodsIdentification.setPrice(price); disposableGoodsIdentification.setWarehouseID(disposableGoodsBatchStock.getWarehouseID()); disposableGoodsIdentification.setWarehouseName(disposableGoodsBatchStock.getWarehouseName()); + objectDao.save(disposableGoodsIdentification); + disposableGoodsIdentification.setAncestorId(disposableGoodsIdentification.getId()); + objectDao.update(disposableGoodsIdentification); } } disposableGoods.setGoodsType(DisposableGoods.TYPE_DIPOSABLEGOODS); Index: forgon-tools/src/main/java/com/forgon/Constants.java =================================================================== diff -u -r25127 -r25145 --- forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 25127) +++ forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 25145) @@ -24,7 +24,7 @@ "4.5.9","4.6.0","4.6.1","4.6.2","4.6.3","4.6.4","4.6.5","4.6.6","4.6.7","4.6.8","4.6.9","4.7.0","4.7.1","4.7.2","4.7.3","4.7.4","4.7.5","4.7.6","4.7.7", "4.7.8","4.7.9","4.8.0","4.8.1","4.8.2","4.8.3","4.8.4","4.8.5","4.8.6","4.8.7","4.8.8","4.8.9","4.9.0","4.9.1","4.9.2","4.9.3","4.9.4","4.9.5","4.9.6", "4.9.7","4.9.8","4.9.9","4.9.10","4.9.11","4.9.12","4.9.13","4.9.14","4.9.15","4.9.16","4.9.17","4.9.18","4.9.19","4.9.20","4.9.21","4.9.22","4.9.23","4.9.24", - "4.9.25","4.9.26"}; + "4.9.25","4.9.26","4.9.27"}; // 版本列表(4.0版本升级4.1版需要分两步:先从4.0升到4.1.0、然后从4.1.0升级4.1最新版本) /*public final static String[] SOFTWARE_VERSION_ARRAY = new String[] { Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/DisposableGoodsIdentification.java =================================================================== diff -u -r25091 -r25145 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/DisposableGoodsIdentification.java (.../DisposableGoodsIdentification.java) (revision 25091) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/DisposableGoodsIdentification.java (.../DisposableGoodsIdentification.java) (revision 25145) @@ -9,6 +9,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; +import javax.persistence.UniqueConstraint; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; @@ -22,7 +23,7 @@ @Entity @DynamicInsert(false) @DynamicUpdate(true) -@Table(name="DisposableGoodsIdentification") +@Table(name="DisposableGoodsIdentification",uniqueConstraints = { @UniqueConstraint(columnNames = { "batch_id","ancestorId" }) }) @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class DisposableGoodsIdentification implements Comparable { @@ -63,9 +64,13 @@ /** * 源标识id,发货时,目标仓库可能会增加库存,创建新的标识,新的标识会记住对应的源标识 + * 已废弃,源标识id记录在DiposableGoodsItem里面了 */ + @Deprecated private Long srcIdentification; + private Long ancestorId; + @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { @@ -88,6 +93,15 @@ return srcIdentification; } + public void setAncestorId(Long ancestorId) { + this.ancestorId = ancestorId; + } + +// @Column(nullable=false) + public Long getAncestorId() { + return ancestorId; + } + public void setSrcIdentification(Long srcIdentification) { this.srcIdentification = srcIdentification; } Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java =================================================================== diff -u -r25141 -r25145 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 25141) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 25145) @@ -3486,10 +3486,7 @@ diposableGoodsItem.setInvoice(invoice);// 和发货单关联 diposableGoodsItem .setInvoiceItemID(invoiceItem.getId());// 明细汇总关联 - if (!diposableGoodsItem - .isAssociatedInfoValidForInvoice()) { - throw new RuntimeException("关联信息不正确!"); - } + // objectDao.save(diposableGoodsItem); autoDeductionDisposableGoodsItems .add(diposableGoodsItem); @@ -3505,9 +3502,15 @@ DisposableGoodsBatch diposableGoodBatch = idToDisposableGoodsBatchMap.get(identification.getDisposableGoodsBatchID()); // 增加目标库存 - addTargetWarehouseAmount(submitInvoiceContext, + DisposableGoodsIdentification targetDisposableGoodsIdentification = addTargetWarehouseAmount(submitInvoiceContext, identification, diposableGoodBatch, disposableGoodsBatchStock, amountChange); + + diposableGoodsItem.setTargetIdentificationId(targetDisposableGoodsIdentification.getId()); + if (!diposableGoodsItem + .isAssociatedInfoValidForInvoice()) { + throw new RuntimeException("关联信息不正确!"); + } // 发货物品单项总价 BigDecimal itemPrice = MathTools.mul(fluctuationPrice, diposableGoodsItem.getAmount()); totalPrice = MathTools.add(totalPrice, itemPrice); @@ -3744,6 +3747,17 @@ disposableGoodsServiceContext.getDisposableGoodsBatchStockList().add(disposableGoodsBatchStock); return disposableGoodsBatchStock; } + + private boolean identificationsAreFromSameSource(DisposableGoodsIdentification identification1,DisposableGoodsIdentification identification2){ + Long srcIdentification1 = identification1.getSrcIdentification(); + Long srcIdentification2 = identification2.getSrcIdentification(); + if(srcIdentification1 != null && (srcIdentification1.equals(srcIdentification2))){ + return true; + }else if(srcIdentification2 != null && (srcIdentification2.equals(srcIdentification1))){ + return true; + } + return false; + } private DisposableGoodsIdentification getOrCreateIdentificationOfDisposableGoods( SubmitInvoiceContext submitInvoiceContext, Long disposableGoodsId, DisposableGoodsStock disposableGoodsStock, @@ -3759,7 +3773,7 @@ Map idToIdentificationMap = disposableGoodsServiceContext.getIdToIdentificationMap(); if(idToIdentificationMap != null){ for (DisposableGoodsIdentification identification : idToIdentificationMap.values()) { - if(disposableGoodsBatchStock.getId().equals(identification.getBatchStock().getId()) && srcIdentification.getId().equals(identification.getSrcIdentification())){ + if(disposableGoodsBatchStock.getId().equals(identification.getBatchStock().getId()) && identificationsAreFromSameSource(srcIdentification, identification)){ return identification; } } @@ -3772,6 +3786,7 @@ identification.setDisposableGoodsID(disposableGoodsId); identification.setDisposableGoodsBatchID(disposableGoodsBatch.getId()); identification.setDisposableGoodsStockID(disposableGoodsStock.getId()); + identification.setAncestorId(srcIdentification.getAncestorId()); identification.setSrcIdentification(srcIdentification.getId()); identification.setBatchStock(disposableGoodsBatchStock); disposableGoodsBatchStock.getIdentifications().add(identification); @@ -3782,6 +3797,7 @@ identification.setPrice(srcIdentification.getPrice()); identification.setWarehouseID(targetWareHouse.getId()); identification.setWarehouseName(targetWareHouse.getName()); + objectDao.saveOrUpdate(identification); idToIdentificationMap.put(identification.getId(), identification); @@ -4096,10 +4112,7 @@ diposableGoodsItem.setInvoice(invoice);// 和发货单关联 diposableGoodsItem .setInvoiceItemID(invoiceItem.getId());// 明细汇总关联 - if (!diposableGoodsItem - .isAssociatedInfoValidForInvoice()) { - throw new RuntimeException("关联信息不正确!"); - } + diposableGoodsItems.add(diposableGoodsItem); // 库存调整 @@ -4117,9 +4130,15 @@ disposableGoodsStorageAdjustVoTotalList.add(vo); // 增加目标仓库库存,省医需求,发货到一二级供应室时需要增加库存 - addTargetWarehouseAmount(submitInvoiceContext, + DisposableGoodsIdentification targetDisposableGoodsIdentification = addTargetWarehouseAmount(submitInvoiceContext, identification, diposableGoodBatch, disposableGoodsBatchStock, amountChange); + + diposableGoodsItem.setTargetIdentificationId(targetDisposableGoodsIdentification.getId()); + if (!diposableGoodsItem + .isAssociatedInfoValidForInvoice()) { + throw new RuntimeException("关联信息不正确!"); + } // 发货物品单项总价 BigDecimal itemPrice = MathTools.mul(fluctuationPrice, diposableGoodsItem.getAmount()); @@ -4437,7 +4456,7 @@ * @param disposableGoodsBatchStock * @param amountChange */ - private void addTargetWarehouseAmount( + private DisposableGoodsIdentification addTargetWarehouseAmount( SubmitInvoiceContext submitInvoiceContext, DisposableGoodsIdentification identification, DisposableGoodsBatch diposableGoodBatch, @@ -4457,6 +4476,8 @@ objectDao.update(targetDisposableGoodsIdentification); objectDao.update(targetDisposableGoodsBatchStock); objectDao.update(targetDisposableGoodsStock); + + return targetDisposableGoodsIdentification; }