Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/instrumentinstance/service/InstrumentInstanceManagerImpl.java =================================================================== diff -u -r35256 -r35260 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/instrumentinstance/service/InstrumentInstanceManagerImpl.java (.../InstrumentInstanceManagerImpl.java) (revision 35256) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/instrumentinstance/service/InstrumentInstanceManagerImpl.java (.../InstrumentInstanceManagerImpl.java) (revision 35260) @@ -304,7 +304,7 @@ } //查询器械实例的最新一轮的器械循环实例 Map instrumentInstanceIdToMaxInstrumentInstanceIdMap = - getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(null, instrumentInstanceList); + getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(null, instrumentInstanceList,cls); List> mapList = new ArrayList>(); instrumentInstanceList.stream().forEach(instance -> { Map dataMap = new HashMap(); @@ -436,7 +436,7 @@ } //否则不为清洗,则更新器械循环实例相关环节字段的id值(如果该标识牌实例中有新添加的器械实例,则对新加的器械实例生成器械循环实例并更新其相关环节字段的id值) Map instrumentInstanceIdToMaxInstrumentInstanceIdMap = - getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(idCardInstance,instrumentInstanceList); + getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(idCardInstance,instrumentInstanceList, cls); //如果材料不完整的处理(有点复杂,后续完善) List> datMapList = new ArrayList>(); //对于map中存在器械实例对应的最大的循环实例id的键值对对象时,执行update.对于map中不存的则需要新创建循环实例然后再插入其循环实例的清洗数据 @@ -504,7 +504,7 @@ idColumnValue = "hibernate_sequence.nextval,"; } Map instrumentInstanceIdToMaxInstrumentInstanceIdMap = - getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(idCardInstance,instrumentInstanceList); + getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(idCardInstance,instrumentInstanceList, cls); //如果材料不完整的处理(有点复杂,后续完善) List> mapList = new ArrayList>(); //对于map中存在器械实例对应的最大的循环实例id的键值对对象时,执行update.对于map中不存的则需要新创建循环实例然后再插入其循环实例的清洗数据 @@ -524,7 +524,7 @@ if(CollectionUtils.isNotEmpty(instrumentInstanceIdListOfNeedGenerateInstrumentCycleInstance)){ batchInsertInstrumentCycleInstance(idCardInstance, instrumentInstanceIdListOfNeedGenerateInstrumentCycleInstance, idCardInstanceIdTousseInstanceMap, cls, recordId); //查询最新生成的器械循环实例数据 - Map newInstrumentInstanceIdToMaxInstrumentInstanceIdMap = getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(idCardInstance, instrumentInstanceIdListOfNeedGenerateInstrumentCycleInstance); + Map newInstrumentInstanceIdToMaxInstrumentInstanceIdMap = getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(idCardInstance, instrumentInstanceIdListOfNeedGenerateInstrumentCycleInstance, cls); Optional.of(newInstrumentInstanceIdToMaxInstrumentInstanceIdMap).orElse(new HashMap()).entrySet().forEach(entry -> { Map dataMap = new HashMap(); dataMap.put("instrumentCycleInstanceId", entry.getValue()); @@ -555,13 +555,20 @@ /** * 根据器械实例集合得出器械实例对应的该标识牌实例的最新器械循环实例id的map数据 * @param instrumentInstanceList + * @param cls * @return */ - private Map getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(IDCardInstance idCardInstance, List instrumentInstanceList){ + private Map getInstrumentInstanceIdToMaxInstrumentInstanceIdMap(IDCardInstance idCardInstance, List instrumentInstanceList, Class cls){ //查询器械实例的最新一轮的器械循环实例 List instrumentInstanceIdList = instrumentInstanceList.stream().map(InstrumentInstance::getId).collect(Collectors.toList()); - List> map = jdbcTemplate.queryForList(String.format("select instrumentInstanceId,max(id) id from %s where %s and %s group by instrumentInstanceId", + //自定义装配时,查询没有回收记录的器械循环记录 + String recyclingRecordSql = ""; + if(StringUtils.equals(cls.getSimpleName(), PackingRecord.class.getSimpleName())){ + recyclingRecordSql = " (recyclingRecordId is not null) "; + } + List> map = jdbcTemplate.queryForList(String.format("select instrumentInstanceId,max(id) id from %s where %s %s and %s group by instrumentInstanceId", InstrumentCycleInstance.class.getSimpleName(), idCardInstance == null ? "1=1" : String.format("idCardInstanceId=%s", idCardInstance.getId()), + recyclingRecordSql, SqlUtils.getNonStringFieldInLargeCollectionsPredicate("instrumentInstanceId", instrumentInstanceIdList))); Map instrumentInstanceIdToMaxInstrumentInstanceIdMap = new HashMap(); Optional.of(map).orElse(new ArrayList>()).stream().forEach(item -> {