Index: ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/service/UseRecordManagerImpl.java =================================================================== diff -u -r31644 -r31739 --- ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/service/UseRecordManagerImpl.java (.../UseRecordManagerImpl.java) (revision 31644) +++ ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/service/UseRecordManagerImpl.java (.../UseRecordManagerImpl.java) (revision 31739) @@ -3638,7 +3638,7 @@ + operationRoomSql + "and type in ('"+ InvoicePlan.TYPE_TOUSSE_APPLICATION_FORM +"') " + "and (endStatus is null) " + deliverStatusCondition - + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "') " + + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "' or recyclingStatus is null) " + "and (po.id not in (select invoicePlan.id from "+ TousseItem.class.getSimpleName() +" where prepareRecycleAmount is not null)) " + " order by po.id desc"); //会否合并转换申请单(如果找到符合条件的待合并申请,且合并后的备注与条码长度不超4000就会合并) @@ -3741,7 +3741,7 @@ if(useRecordList.size() == 1){ //追加申请项(相同物品的,则数量进行叠加) List tousseTransitionPlanItemList = - recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true); + recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true, false); if(CollectionUtils.isNotEmpty(tousseTransitionPlanItemList)){ List list = new ArrayList(); @@ -3755,7 +3755,7 @@ } } } - + recyclingApplicationManager.saveOrUpdateRecyclingApplication(recyclingApplication, true); //将转换后申请单对象保存至集合中 recyclingApplicationListAfterConvert.add(recyclingApplication); } @@ -3772,7 +3772,7 @@ + "and (sterilizationMode is null or "+ SqlUtils.getStringFieldNotInCollectionsPredicate("sterilizationMode", lowTempSterilizationModesJSONArray) +")" + "and type in ('"+ InvoicePlan.TYPE_TOUSSE_APPLICATION_FORM +"') " + "and (endStatus is null) " + deliverStatusCondition - + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "') " + + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "' or recyclingStatus is null) " + "and (po.id not in (select invoicePlan.id from "+ TousseItem.class.getSimpleName() +" where prepareRecycleAmount is not null)) " + "order by po.id desc"); //会否合并转换申请单(如果找到符合条件的待合并申请,且合并后的备注与条码长度不超4000就会合并) @@ -3875,7 +3875,7 @@ if(useRecordList.size() == 1){ //追加申请项(相同物品的,则数量进行叠加) List tousseTransitionPlanItemList = - recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true); + recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true, false); if(CollectionUtils.isNotEmpty(tousseTransitionPlanItemList)){ List list = new ArrayList(); @@ -3889,7 +3889,7 @@ } } } - + recyclingApplicationManager.saveOrUpdateRecyclingApplication(recyclingApplication, true); //将转换后申请单对象保存至集合中 recyclingApplicationListAfterConvert.add(recyclingApplication); } @@ -3979,7 +3979,7 @@ + operationRoomSql + "and type in ('"+ InvoicePlan.TYPE_COMBO_FORM +"') " + "and (endStatus is null) " + deliverStatusCondition - + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "') " + + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "' or recyclingStatus is null) " + "and (po.id not in (select invoicePlan.id from "+ TousseItem.class.getSimpleName() +" where prepareRecycleAmount is not null)) " + "order by po.id desc"); //会否合并转换申请单(如果找到符合条件的待合并申请,且合并后的备注与条码长度不超4000就会合并) @@ -4080,7 +4080,7 @@ if(useRecordList.size() == 1){ //追加申请项(相同物品的,则数量进行叠加) List tousseTransitionPlanItemList = - recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true); + recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true, false); if(CollectionUtils.isNotEmpty(tousseTransitionPlanItemList)){ List list = new ArrayList(); @@ -4094,7 +4094,7 @@ } } } - + recyclingApplicationManager.saveOrUpdateRecyclingApplication(recyclingApplication, true); //将转换后申请单对象保存至集合中 recyclingApplicationListAfterConvert.add(recyclingApplication); } @@ -4110,7 +4110,7 @@ "where 1=1 and useRecord is not null and departCoding='"+ departCoding + "'" + "and type in ('"+ InvoicePlan.TYPE_COMBO_FORM +"') " + "and (endStatus is null) " + deliverStatusCondition - + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "') " + + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "' or recyclingStatus is null) " + "and (po.id not in (select invoicePlan.id from "+ TousseItem.class.getSimpleName() +" where prepareRecycleAmount is not null)) " + "order by po.id desc"); //会否合并转换申请单(如果找到符合条件的待合并申请,且合并后的备注与条码长度不超4000就会合并) @@ -4211,7 +4211,7 @@ if(useRecordList.size() == 1){ //追加申请项(相同物品的,则数量进行叠加) List tousseTransitionPlanItemList = - recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true); + recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true, false); if(CollectionUtils.isNotEmpty(tousseTransitionPlanItemList)){ List list = new ArrayList(); @@ -4225,7 +4225,7 @@ } } } - + recyclingApplicationManager.saveOrUpdateRecyclingApplication(recyclingApplication, true); //将转换后申请单对象保存至集合中 recyclingApplicationListAfterConvert.add(recyclingApplication); } @@ -4309,15 +4309,17 @@ ? " and deliverStatus='" + InvoicePlan.DELIVERSTATUS_AWAITDELIVER + "' " : " and (deliverStatus is null or deliverStatus = '')"; + String sql = "where 1=1 and useRecord is not null and departCoding='"+ departCoding + "'" + + operationRoomSql + + "and type in ('"+ InvoicePlan.TYPE_COMBO_FORM +"') " + + "and (endStatus is null) " + deliverStatusCondition + + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "' or recyclingStatus is null) " + + "and (po.id not in (select invoicePlan.id from "+ TousseItem.class.getSimpleName() +" where prepareRecycleAmount is not null)) " + + "order by po.id desc"; + //查询该科室的手术间与当前使用记录的手术单相同的申请单(且未终止、待回收、未发货、未做预回收),也是使用记录转换的申请单 RecyclingApplication recyclingApplication = (RecyclingApplication)objectDao.getBySql(RecyclingApplication.class.getSimpleName(), - "where 1=1 and useRecord is not null and departCoding='"+ departCoding + "'" - + operationRoomSql - + "and type in ('"+ InvoicePlan.TYPE_COMBO_FORM +"') " - + "and (endStatus is null) " + deliverStatusCondition - + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "') " - + "and (po.id not in (select invoicePlan.id from "+ TousseItem.class.getSimpleName() +" where prepareRecycleAmount is not null)) " - + "order by po.id desc"); + sql); //会否合并转换申请单(如果找到符合条件的待合并申请,且合并后的备注与条码长度不超4000就会合并) boolean willMergeConvertApplication = false; if(recyclingApplication != null){ @@ -4415,7 +4417,7 @@ if(useRecordList.size() == 1){ //追加申请项(相同物品的,则数量进行叠加) List tousseTransitionPlanItemList = - recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true); + recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true, false); if(CollectionUtils.isNotEmpty(tousseTransitionPlanItemList)){ List list = new ArrayList(); @@ -4430,6 +4432,7 @@ } } + recyclingApplicationManager.saveOrUpdateRecyclingApplication(recyclingApplication, true); //将转换后申请单对象保存至集合中 recyclingApplicationListAfterConvert.add(recyclingApplication); } @@ -4445,7 +4448,7 @@ "where 1=1 and useRecord is not null and departCoding='"+ departCoding + "'" + "and type in ('"+ InvoicePlan.TYPE_COMBO_FORM +"') " + "and (endStatus is null) " + deliverStatusCondition - + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "') " + + "and (recyclingStatus='" + InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE + "' or recyclingStatus is null) " + "and (po.id not in (select invoicePlan.id from "+ TousseItem.class.getSimpleName() +" where prepareRecycleAmount is not null)) " + "order by po.id desc"); //会否合并转换申请单(如果找到符合条件的待合并申请,且合并后的备注与条码长度不超4000就会合并) @@ -4545,7 +4548,7 @@ if(useRecordList.size() == 1){ //追加申请项(相同物品的,则数量进行叠加) List tousseTransitionPlanItemList = - recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true); + recyclingApplication.appendTousseItemFromUseRecord(objectDao , true , true, false); if(CollectionUtils.isNotEmpty(tousseTransitionPlanItemList)){ List list = new ArrayList(); @@ -4559,7 +4562,7 @@ } } } - + recyclingApplicationManager.saveOrUpdateRecyclingApplication(recyclingApplication, true); //将转换后申请单对象保存至集合中 recyclingApplicationListAfterConvert.add(recyclingApplication); } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recyclingapplication/RecyclingApplication.java =================================================================== diff -u -r29237 -r31739 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recyclingapplication/RecyclingApplication.java (.../RecyclingApplication.java) (revision 29237) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recyclingapplication/RecyclingApplication.java (.../RecyclingApplication.java) (revision 31739) @@ -281,6 +281,18 @@ * 如果不是,则原申请项的数量保持不变,否则原申请项的基础上进行数据叠加 */ public List appendTousseItemFromUseRecord(ObjectDao objectDao , boolean otherUseRecord , boolean needAddUrgentAmountFromTousseInstance){ + return appendTousseItemFromUseRecord(objectDao, otherUseRecord, needAddUrgentAmountFromTousseInstance, true); + } + + /** + * 追加申请项,并持久化 + * @param objectDao + * @param otherUseRecord 是否为第一个使用记录外的另一个使用记录(即转换申请单合并的第二条或第二条以上的使用记录) + * @param needAddUrgentAmountFromTousseInstance 是否把包实例加急数量累加到申请项(对于新创建的申请单,不需要。合并转换到已有申请单则需要) + * @param updateAmount 是否直接修改tousseItem的数量,值为true时,直接修改amount;值为false时,只修改editAmount + * 如果不是,则原申请项的数量保持不变,否则原申请项的基础上进行数据叠加 + */ + public List appendTousseItemFromUseRecord(ObjectDao objectDao , boolean otherUseRecord , boolean needAddUrgentAmountFromTousseInstance, boolean updateAmount){ if(useRecord != null){ List tousseItemList = this.getApplicationItems(); if(tousseItemList == null){ @@ -333,9 +345,12 @@ //自定义器械包只能用祖先id进行比较(申请项的包定义id为根据申请单创建的包定义id,而包实例的) if(tousseItemCutomerTd.getAncestorID() != null && (tdId.longValue() == tousseItemCutomerTd.getAncestorID().longValue())){ //是否为第二个或第二个以后的使用记录转换合并到本申请单 - if(otherUseRecord){ + if(otherUseRecord && updateAmount){ tousseItem.setAmount(tousseItem.getAmount() + 1); } + if(!updateAmount){ + tousseItem.setEditAmount(tousseItem.getAmount() + 1); + } /*if(Constants.STR_YES.equals(tousseInstance.getIsUrgentForUseRecord())){ tousseItem.setUrgentAmount(tousseItem.getUrgentAmount() + 1); }*/