Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java =================================================================== diff -u -r36477 -r36479 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 36477) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 36479) @@ -589,8 +589,8 @@ recyclingItem.setErrorDamageQmKey(vo.getErrorDamageQmKey()); } objectDao.saveOrUpdate(recyclingItem); - updateRelativeTousseInstanceRecyclingItemId(recyclingItem); } + updateRelativeTousseInstanceRecyclingItemId(items); recyclingRecord.setItems(items); setCameraPhotoInfo(cameraPhotoInfo, tousseIdToRecyclingItemIdMap); //判断回记录的所有回收项的数量和申请数量、以及对应的申请单的所有申请项的申请数量与回收数量是否大于0,如果没有数量大于0的项,则删除回收记录及对应的申请单 @@ -730,19 +730,6 @@ return false; } /** - * 设置相关的器械包实例的回收项id的值 - * @param recyclingItem - */ - private void updateRelativeTousseInstanceRecyclingItemId(RecyclingItem recyclingItem){ - if(recyclingItem != null && recyclingItem.getRecyclingRecord() != null && recyclingItem.getRecyclingRecord().getRecyclingApplication() != null){ - String updateSql = "update "+ TousseInstance.class.getSimpleName() +" set recyclingItemId="+ recyclingItem.getId() +" where recyclingItemId is null " - + "and tousseItemId in (select id from "+ TousseItem.class.getSimpleName() +" ti where ti.recyclingApplication_id="+ recyclingItem.getRecyclingRecord().getRecyclingApplication().getId() - +") and tousseDefinition_id=" + recyclingItem.getTousseDefinitionId(); - objectDao.excuteSQL(updateSql); - } - } - - /** * 获取包定义id和数量的Map * @param recyclingBasketItems 放入篮筐的物品(已将非整包清洗放入篮筐的材料组合成器械包) * @return @@ -9901,4 +9888,43 @@ } } } + /** + * 批量设置相关的器械包实例的回收项id的值 + * @param recyclingItems + */ + private void updateRelativeTousseInstanceRecyclingItemId(List recyclingItems){ + if(CollectionUtils.isEmpty(recyclingItems)){ + return; + } + List updateRecyclingItems = new ArrayList(); + for(RecyclingItem recyclingItem : recyclingItems){ + if(recyclingItem != null && recyclingItem.getRecyclingRecord() != null && recyclingItem.getRecyclingRecord().getRecyclingApplication() != null){ + updateRecyclingItems.add(recyclingItem); + } + } + if(CollectionUtils.isEmpty(recyclingItems)){ + return; + } + StringBuffer sbf = new StringBuffer(); + sbf.append("update "); + sbf.append(TousseInstance.class.getSimpleName()); + sbf.append(" set recyclingItemId=? where recyclingItemId is null and tousseItemId in (select id from "); + sbf.append(TousseItem.class.getSimpleName()); + sbf.append(" ti where ti.recyclingApplication_id=? ) and tousseDefinition_id=?;"); + jdbcTemplate.batchUpdate(sbf.toString(), new BatchPreparedStatementSetter() { + + @Override + public void setValues(PreparedStatement ps, int i) throws SQLException { + RecyclingItem recyclingItem = updateRecyclingItems.get(i); + ps.setLong(1, recyclingItem.getId()); + ps.setLong(2, recyclingItem.getRecyclingRecord().getRecyclingApplication().getId()); + ps.setLong(3, recyclingItem.getTousseDefinitionId()); + } + + @Override + public int getBatchSize() { + return updateRecyclingItems.size(); + } + }); + } }