Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r33237 -r33242 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 33237) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 33242) @@ -13230,7 +13230,6 @@ + "between %s and %s or tit.invoiceSendTime2 is null " + "and tit.invoiceSendTime between %s and %s)", startDay,endDay,startDay,endDay); - timeFieldName = "tit.invoiceSendTime"; }else{ timeFieldName = "f.receiveTime"; timeSql = String.format("and (f.receiveTime between %s and %s)", startDay, endDay); @@ -13249,7 +13248,32 @@ String customTimePeriodSql = ""; if(DatabaseUtil.isPoIdValid(customTimePeriodId)){ CustomTimePeriod customTimePeriod = (CustomTimePeriod)objectDao.getById(CustomTimePeriod.class.getSimpleName(), customTimePeriodId); - customTimePeriodSql = getTimeFieldQueryStatement(dbConnection, customTimePeriod.getStartTime(), customTimePeriod.getEndTime(), timeFieldName); + if("发货时间".equals(timeType)){ + if(dbConnection.isSqlServer()){ + String[] startTimeArr = startTime.split(":"); + String startTimeHour = startTimeArr[0]; + String startTimeMinute = startTimeArr[1]; + String[] endTimeArr = endTime.split(":"); + String endTimeHour = endTimeArr[0]; + String endTimeMinute = endTimeArr[1]; + customTimePeriodSql = " and (tit.invoiceSendTime2 is not null and (datepart(hour,tit.invoiceSendTime2)="+ startTimeHour +" and datepart(MINUTE,tit.invoiceSendTime2)>="+ startTimeMinute + + " or datepart(hour,tit.invoiceSendTime2)="+ endTimeHour +" and datepart(MINUTE,tit.invoiceSendTime2)<= " + endTimeMinute + + " or datepart(hour,tit.invoiceSendTime2)>"+ startTimeHour +" and datepart(hour,tit.invoiceSendTime2)< " + endTimeHour + " ) or tit.invoiceSendTime2 is null and " + + " (datepart(hour,tit.invoiceSendTime)="+ startTimeHour +" and datepart(MINUTE,tit.invoiceSendTime)>="+ startTimeMinute + + " or datepart(hour,tit.invoiceSendTime)="+ endTimeHour +" and datepart(MINUTE,tit.invoiceSendTime)<= " + endTimeMinute + + " or datepart(hour,tit.invoiceSendTime)>"+ startTimeHour +" and datepart(hour,tit.invoiceSendTime)< " + endTimeHour + ")) "; + }else if(dbConnection.isOracle()){ + customTimePeriodSql = " and (tit.invoiceSendTime2 is not null and TO_CHAR(tit.invoiceSendTime2, 'hh24:mi:ss') BETWEEN '" + + startTime +":00' AND '" + + endTime +":00' or tit.invoiceSendTime2 is null and tit.invoiceSendTime BETWEEN '" + + startTime +":00' AND '" + + endTime + ":00')"; + }else{ + customTimePeriodSql = ""; + } + }else{ + customTimePeriodSql = getTimeFieldQueryStatement(dbConnection, customTimePeriod.getStartTime(), customTimePeriod.getEndTime(), timeFieldName); + } } String sql = String .format("select i.applicationtime,case when tit.invoiceSendTime2 is not null then tit.invoiceSendTime2 else tit.invoiceSendTime end invoiceSendTime,f.receiveTime,tit.tousseName,tit.price,f.id,ti.supplierName,i.applicant,i.remark,f.patient,f.surgery,f.hospitalNumber,i.depart,i.deliverStatus %s,f.doctor,f.processType,count(distinct tit.id) amount,f.bedNumber,tit.useRecord_id %s %s from %s f join %s i on f.id=i.id left join %s ti on ti.recyclingApplication_ID=i.id left join %s tit on tit.foreignTousseApp_id=f.id left join TousseDefinition td on td.id = tit.tousseDefinition_id %s %s where (tit.id is null or td.parentID is null and ti.tousseDefinitionId=tit.tousseDefinition_id or ti.tousseDefinitionId=td.parentID) %s %s %s %s %s ",