Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/instrumentinstance/service/InstrumentInstanceManagerImpl.java =================================================================== diff -u -r35260 -r35267 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/instrumentinstance/service/InstrumentInstanceManagerImpl.java (.../InstrumentInstanceManagerImpl.java) (revision 35260) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/instrumentinstance/service/InstrumentInstanceManagerImpl.java (.../InstrumentInstanceManagerImpl.java) (revision 35267) @@ -564,7 +564,7 @@ //自定义装配时,查询没有回收记录的器械循环记录 String recyclingRecordSql = ""; if(StringUtils.equals(cls.getSimpleName(), PackingRecord.class.getSimpleName())){ - recyclingRecordSql = " (recyclingRecordId is not null) "; + recyclingRecordSql = " and (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()), @@ -1540,14 +1540,12 @@ pageNum = 1; } - String fromSql = String.format(" from %s ii " - + "join %s ici on ici.instrumentInstanceId =ii.id " + String fromSql = String.format(" from %s ici " + "join %s ur on ur.id = ici.useRecordId " + "join %s ti on ti.useRecord_id = ur.id " + "join %s bd on bd.id = ti.id " + "left join %s ou on ou.orgUnitCoding = ur.departCodeOfpatient " - + "where ti.idCardInstanceID = ii.idCardInstanceId and ii.id = %s", - InstrumentInstance.class.getSimpleName(), + + "where ti.idCardInstanceID = ici.idCardInstanceId and ici.instrumentInstanceId = %s", InstrumentCycleInstance.class.getSimpleName(), UseRecord.class.getSimpleName(), TousseInstance.class.getSimpleName(), @@ -1563,20 +1561,20 @@ + "or bd.barcode like '%" + spell + "%') "; } - String countSql = String.format("select count(*) %s ", fromSql); + String countSql = String.format("select count(distinct ti.id) %s ", fromSql); int rowCount = objectDao.countBySql(countSql); int pageCount = rowCount % pageSize == 0 ? rowCount / pageSize : rowCount / pageSize + 1; JSONObject result = new JSONObject(); JSONArray data = new JSONArray(); if(rowCount > 0){ - String querySql = String.format("select ur.id useRecordId, ur.enteringDate,ur.patientArea,ur.doctorName, ur.operation, " + String querySql = String.format("select distinct ur.id useRecordId, ur.enteringDate,ur.patientArea,ur.doctorName, ur.operation, " + "(case when ur.departCodeOfpatient is not null then ou.name else ur.ascriptionDepartment end) departNameOfpatient, " - + "ti.tousseName, bd.barcode %s", + + "ti.id tiId, ti.tousseName, bd.barcode %s", fromSql); - String pageColumnName = "useRecordId"; - String orderSql = " order by enteringDate desc "; + String pageColumnName = "tiId"; + String orderSql = " order by tiId desc "; int start = (pageNum-1) * pageSize; int limit = pageSize; if(dbConnection.isSqlServer()){ @@ -1673,11 +1671,10 @@ String fromSql = String.format(" from %s ii " + "join %s md on md.id = ii.materialDefinitionId " + "left join %s me on me.id = ii.materialEntryId " - + "left join %s mei on mei.materialEntry_id = me.id and mei.materialDefinition_id = md.id where 1=1 ", + + "where 1=1 ", InstrumentInstance.class.getSimpleName(), MaterialDefinition.class.getSimpleName(), - MaterialEntry.class.getSimpleName(), - MaterialEntryItem.class.getSimpleName()); + MaterialEntry.class.getSimpleName()); if(StringUtils.isNotBlank(materialDefinitonName) && !DatabaseUtil.isPoIdValid(materialDefinitonId)){ fromSql += " and md.name like '%" + materialDefinitonName + "%' "; }