Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java =================================================================== diff -u -r32914 -r32915 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 32914) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 32915) @@ -3781,16 +3781,18 @@ cal.set(Calendar.MINUTE, timeoutNoticeMinutes.intValue()); lastDate = cal.getTime(); } - String querySql = "select ip.serialNumber,ip.type,ip.depart,ip.applicationTime,ti.id,ti.tousseName,ti.isRecycling," + String querySql = "select case when aer.id is null then ip.id else null end ipId, ip.serialNumber,ip.type,ip.depart,ip.applicationTime,ti.id,ti.tousseName,ti.isRecycling," + " ti.amount,ti.recyclingAmount,ti.unit,ip.recyclingStatus " + " from invoicePlan ip join TousseItem ti on ip.id=ti.recyclingApplication_ID " + + " left join " + AdverseEventRecord.class.getSimpleName() + " aer on aer.recyclingApplication_ID=ip.id " + " where ip.handleDepartCoding='"+ AcegiHelper.getCurrentOrgUnitCode() +"' and ti.timeoutprocesstype is null " + " and (ip.type='"+ InvoicePlan.TYPE_FOREIGNTOUSSEAPPLIACTION +"' and ip.recyclingStatus in ('"+ InvoicePlan.RECYCLINGSTATUS_AWAITRECEIVE +"','"+ InvoicePlan.RECYCLINGSTATUS_PARTAWAITRECEIVE +"') " + " or (ip.type<>'"+ InvoicePlan.TYPE_FOREIGNTOUSSEAPPLIACTION +"' and ip.recyclingStatus in ('"+ InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE +"','"+ InvoicePlan.RECYCLINGSTATUS_PARTRECYCLE +"'))) " + " and ti.isRecycling='"+ Constants.STR_YES +"' and (ti.recyclingAmount is null or (ti.recyclingAmount <> 0 and ti.recyclingAmount < ti.amount)) " + " and ip.applicationTime <= "+ dateQueryAdapter.dateAdapter(lastDate); rs = objectDao.executeSql(querySql); JSONArray rows = new JSONArray(); + Set ipIds = new HashSet(); while (rs.next()) { JSONObject dataJsonObject = new JSONObject(); dataJsonObject.put("serialNumber", rs.getString("serialNumber")); @@ -3802,7 +3804,19 @@ dataJsonObject.put("recyclingAmount", rs.getInt("recyclingAmount")); dataJsonObject.put("unit", rs.getString("unit")); rows.add(dataJsonObject); + ipIds.add(rs.getLong("ipId")); } + if(CollectionUtils.isNotEmpty(ipIds)){ + List ips = objectDao.findByHql("select po from " + InvoicePlan.class.getSimpleName() + " po where " + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("po.id", ipIds)); + for (InvoicePlan ip : ips) { + AdverseEventRecord adverseEventRecord = new AdverseEventRecord(); + adverseEventRecord.setEventCode(AdverseEventRecord.EVENTNAME_RECYCLINGTIMEOUTCODE); + adverseEventRecord.setEventName(AdverseEventRecord.EVENTNAME_RECYCLINGTIMEOUT); + adverseEventRecord.setEventTime(new Date()); + adverseEventRecord.setInvoicePlan(ip); + objectDao.save(adverseEventRecord); + } + } result.put("success", true); result.put("rows", rows); result.put("total", rows.size()); @@ -3911,8 +3925,6 @@ try { if(DatabaseUtil.isPoIdValid(id)){ objectDao.executeUpdate("update TousseItem set timeoutProcessType='"+ timeoutProcessType +"' where id=" + id); - InvoicePlan ip = (InvoicePlan)objectDao.findByHql("select po.invoicePlan from " + TousseItem.class.getSimpleName() + " po where po.id=" + id).get(0); - adverseEventRecordManager.saveAdverseEventRecord(ip, AdverseEventRecord.EVENTNAME_RECYCLINGTIMEOUTCODE, AdverseEventRecord.EVENTNAME_RECYCLINGTIMEOUT, null); JSONUtil.addSuccess(result, true); }else{ JSONUtil.addProperty(result, JSONUtil.JSON_KEY_MESSAGE, "id不合法");