Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java =================================================================== diff -u -r41188 -r41319 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 41188) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 41319) @@ -7140,7 +7140,9 @@ extraQuery += sbf.toString(); } boolean showORRoomColumnInHistoryRecyclingRecordList = CssdUtils.getSystemSetConfigByNameBool("showORRoomColumnInHistoryRecyclingRecordList", false); - RecyclingRecordListSqlGenerator sqlGenerator = new RecyclingRecordListSqlGenerator(enableUrgentFunction, dbConnection,start,end,filterJson,extraQuery,groupByInvoicePlanId,objectDao,pageSize,extraQuerys); + SupplyRoomConfig supplyRoomConfig = supplyRoomConfigManager.getSystemParamsObj(); + String[] todayDates = supplyRoomConfigManager.getStartDateAndEndDate(supplyRoomConfig, DateTools.YMDFORMAT.get().format(new Date())); + RecyclingRecordListSqlGenerator sqlGenerator = new RecyclingRecordListSqlGenerator(todayDates, enableUrgentFunction, dbConnection,start,end,filterJson,extraQuery,groupByInvoicePlanId,objectDao,pageSize,extraQuerys); int totalCount = objectDao.countBySql(sqlGenerator.getCountSql()); Set recordIds = new HashSet(); List recordVos = new ArrayList(); Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r41086 -r41319 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 41086) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 41319) @@ -4628,6 +4628,25 @@ if(enableExtendedInformationOfUrgentFunction){ extraOrder = " po.urgentAddnlInfoExptUseTime desc, " + extraOrder; } + boolean enableAdditionalRecycleStatusSorting = CssdUtils.getSystemSetConfigByNameBool("enableAdditionalRecycleStatusSorting", false); + if(enableAdditionalRecycleStatusSorting){ + if(CssdUtils.getSystemSetConfigByNameBool("enablePartRecycle", false) || CssdUtils.getSystemSetConfigByNameBool("enableForeignToussePartRecycle", false)){ + //必须有一个开启 否则 enableAdditionalRecycleStatusSorting开启了也不加入排序 + String[] dates = supplyRoomConfigManager.getStartDateAndEndDate(null, DateTools.YMDFORMAT.get().format(new Date())); + if(dates != null && dates.length == 2){ + extraOrder += " case when po.recyclingStatus in ('" + + InvoicePlan.RECYCLINGSTATUS_PARTRECYCLE + +"','" + + InvoicePlan.RECYCLINGSTATUS_PARTAWAITRECEIVE + +"') and po.submitTime between " + + dateQueryAdapter.dateAdapter(dates[0]) + + " and " + dateQueryAdapter.dateAdapter(dates[1]) + + " then 0 else 1 end asc, "; + } + } + } + + String queryColumnSql = " select " + InvoicePlan.buildConstructionMethodSql("po.id,po.depart,po.settleAccountsDepart,po.applicationTime,po.submitTime,po.applicant" + ",po.type,po.operationRoom,po.patient,po.hospitalNumber,po.remark,po.isPrepareRecycled,po.recyclingStatus" Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordListSqlGenerator.java =================================================================== diff -u -r40541 -r41319 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordListSqlGenerator.java (.../RecyclingRecordListSqlGenerator.java) (revision 40541) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordListSqlGenerator.java (.../RecyclingRecordListSqlGenerator.java) (revision 41319) @@ -51,6 +51,10 @@ private Integer pageSize; private Set extraQuerys = null; /** + * 一天的开始和结束时间 + */ + private String[] todayDates = null; + /** * 使用union all 的方式进行过滤条码比较效率 * 如果回收物品上有记条码则显示此回收物品所在的回收记录(也就是扫码回收的回收记录),否则显示包含此条码的申请单关联的回收记录 * 回收物品所在的回收记录(也就是扫码回收的回收记录)的条码过滤 @@ -61,9 +65,10 @@ */ private String barcodeInInvoicePlan = ""; private String orgUnitCodingFromSupplyRoomConfig; - public RecyclingRecordListSqlGenerator(boolean enableUrgentFunction, InitDbConnection dbConnection,long start,long end,String filterJsonStr, String extraQuery, boolean groupByInvoicePlanId,ObjectDao objectDao, Integer pageSize, Set extraQuerys) { + public RecyclingRecordListSqlGenerator(String[] todayDates, boolean enableUrgentFunction, InitDbConnection dbConnection,long start,long end,String filterJsonStr, String extraQuery, boolean groupByInvoicePlanId,ObjectDao objectDao, Integer pageSize, Set extraQuerys) { this.pageSize = pageSize; this.objectDao = objectDao; + this.todayDates = todayDates; this.dbConnection = dbConnection; this.orgUnitCodingFromSupplyRoomConfig = AcegiHelper.getLoginUser() .getOrgUnitCodingFromSupplyRoomConfig(); @@ -292,16 +297,47 @@ boolean tousseMaterialsLostMustConfirm = CssdUtils.getSystemSetConfigByNameBool("tousseMaterialsLostMustConfirm", true); String tousseMaterialsLostMustConfirmOrder = tousseMaterialsLostMustConfirm? "case when r.status='"+ RecyclingRecord.STATUS_UNCONFIRMED +"' then 0 else 1 end,":""; + boolean enableAdditionalRecycleStatusSorting = CssdUtils.getSystemSetConfigByNameBool("enableAdditionalRecycleStatusSorting", false); + String enableAdditionalRecycleStatusSortingSql = null; + String todayDatesBetweenSql = null; + if(enableAdditionalRecycleStatusSorting){ + boolean enablePartRecycle = CssdUtils.getSystemSetConfigByNameBool("enablePartRecycle", false); + boolean enableForeignToussePartRecycle = CssdUtils.getSystemSetConfigByNameBool("enableForeignToussePartRecycle", false); + if(!enablePartRecycle && !enableForeignToussePartRecycle){ + enableAdditionalRecycleStatusSorting = false; + }else{ + todayDatesBetweenSql = " between " + dateQueryAdapter.dateAdapter(todayDates[0]) + " and " + dateQueryAdapter.dateAdapter(todayDates[1]); + enableAdditionalRecycleStatusSortingSql = " case when p.recyclingStatus in ('"+ InvoicePlan.RECYCLINGSTATUS_PARTRECYCLE +"','"+ InvoicePlan.RECYCLINGSTATUS_PARTAWAITRECEIVE +"') " + + "and exists (select 1 from TousseItem ti " + + "join RecyclingItem ri1 on ri1.tousseDefinitionId=ti.tousseDefinitionId " + + "where ti.recyclingApplication_ID=p.id and ri1.recyclingRecord_id=r.id " + + "and ti.amount>ri1.amount and r.recyclingTime " + + todayDatesBetweenSql + + ") then 0 else 1 end asc,"; + } + }else{ + todayDatesBetweenSql = StringUtils.EMPTY; + enableAdditionalRecycleStatusSortingSql = StringUtils.EMPTY; + } + if (dbConnection.isSqlServer() || dbConnection.isMySQLOrTiDB()) { if(StringUtils.isNotBlank(barcodeInRecyclingRecordSql)){ sql = " SELECT * FROM (SELECT * " + ",ROW_NUMBER() OVER (order by " + +(enableAdditionalRecycleStatusSorting?" case when t3.recyclingStatus in ('"+ InvoicePlan.RECYCLINGSTATUS_PARTRECYCLE +"','"+ InvoicePlan.RECYCLINGSTATUS_PARTAWAITRECEIVE +"') " + + "and exists (select 1 from TousseItem ti " + + "join RecyclingItem ri1 on ri1.tousseDefinitionId=ti.tousseDefinitionId " + + "where ti.recyclingApplication_ID=t3.pid and ri1.recyclingRecord_id=t3.id " + + "and ti.amount>ri1.amount and t3.recyclingTime " + + todayDatesBetweenSql + + ") then 0 else 1 end asc,":"") +(tousseMaterialsLostMustConfirm?"case when t3.status='"+ RecyclingRecord.STATUS_UNCONFIRMED +"' then 0 else 1 end,":"") +(confirmRecyclingAmount?"case t3.recycleAmountNeedConfirm when '" + Constants.STR_YES + "' then 0 else 1 end,":"") +" t3.recyclingTime desc,t3.id desc) AS RowNum " + "from (" + "SELECT " + " r.*,p.applicationTime, p.type,p.remark,p.submitTime,p.recyclingStatus,p.specialInfection,p.operationRoom,p.patient,p.hospitalNumber,p.serialNumber,p.applicant "+ extraQuery +" " + +" , p.id pid " + "FROM " + RecyclingRecord.class.getSimpleName() + " r left join " + InvoicePlan.class.getSimpleName() + " p on r.recyclingApplication_id = p.id " + joinSqlOfUrgent + (enableUrgentFunction?" left join (select ri.recyclingRecord_id from RecyclingItem ri where ri.urgentAmount>0 group by ri.recyclingRecord_id) b on b.recyclingRecord_id=r.id ":"") @@ -313,7 +349,7 @@ + " union all " + "SELECT " + " r.*,p.applicationTime, p.type,p.remark,p.submitTime,p.recyclingStatus,p.specialInfection,p.operationRoom,p.patient,p.hospitalNumber,p.serialNumber,p.applicant "+ extraQuery +" " - + "FROM " + RecyclingRecord.class.getSimpleName() + " r left join " + InvoicePlan.class.getSimpleName() + + ", p.id pid FROM " + RecyclingRecord.class.getSimpleName() + " r left join " + InvoicePlan.class.getSimpleName() + " p on r.recyclingApplication_id = p.id " + joinSqlOfUrgent + (enableUrgentFunction?" left join (select ri.recyclingRecord_id from RecyclingItem ri where ri.urgentAmount>0 group by ri.recyclingRecord_id) b on b.recyclingRecord_id=r.id ":"") + "where r.orgUnitCoding = '" @@ -325,7 +361,7 @@ }else{ sql = " SELECT * FROM (SELECT " + " r.*,p.applicationTime, p.type,p.remark,p.submitTime,p.recyclingStatus,p.specialInfection,p.operationRoom,p.patient,p.hospitalNumber,p.serialNumber,p.applicant "+ extraQuery +" " - + ",ROW_NUMBER() OVER (order by " +tousseMaterialsLostMustConfirmOrder +recyclingAmountNeedConfirmOrder+" r.recyclingTime desc,r.id desc) AS RowNum " + + ",ROW_NUMBER() OVER (order by " + enableAdditionalRecycleStatusSortingSql +tousseMaterialsLostMustConfirmOrder +recyclingAmountNeedConfirmOrder+" r.recyclingTime desc,r.id desc) AS RowNum " + "FROM " + RecyclingRecord.class.getSimpleName() + " r left join " + InvoicePlan.class.getSimpleName() + " p on r.recyclingApplication_id = p.id " + joinSqlOfUrgent + (enableUrgentFunction?" left join (select ri.recyclingRecord_id from RecyclingItem ri where ri.urgentAmount>0 group by ri.recyclingRecord_id) b on b.recyclingRecord_id=r.id ":"") @@ -339,7 +375,7 @@ } else if (dbConnection.isOracle()) { if(StringUtils.isNotBlank(barcodeInRecyclingRecordSql)){ sql = " SELECT * FROM (SELECT * from (SELECT ROWNUM RN,t3.* from (" - + "SELECT r.*,p.applicationTime,p.type,p.remark,p.submitTime,p.recyclingStatus,p.specialInfection,p.operationRoom,p.patient,p.hospitalNumber,p.serialNumber "+ extraQuery +" FROM " + RecyclingRecord.class.getSimpleName() + + "SELECT r.*,p.applicationTime,p.type,p.remark,p.submitTime,p.recyclingStatus,p.specialInfection,p.operationRoom,p.patient,p.hospitalNumber,p.serialNumber "+ extraQuery +" , p.id pid FROM " + RecyclingRecord.class.getSimpleName() + " r left join " + InvoicePlan.class.getSimpleName() + " p on r.recyclingApplication_id = p.id " + joinSqlOfUrgent + (enableUrgentFunction?" left join (select ri.recyclingRecord_id from RecyclingItem ri where ri.urgentAmount>0 group by ri.recyclingRecord_id) b on b.recyclingRecord_id=r.id ":"") + "where r.orgUnitCoding = '" @@ -348,7 +384,7 @@ + filterSql + barcodeInRecyclingRecordSql + " union all " - + "SELECT r.*,p.applicationTime,p.type,p.remark,p.submitTime,p.recyclingStatus,p.specialInfection,p.operationRoom,p.patient,p.hospitalNumber,p.serialNumber "+ extraQuery +" FROM " + RecyclingRecord.class.getSimpleName() + + "SELECT r.*,p.applicationTime,p.type,p.remark,p.submitTime,p.recyclingStatus,p.specialInfection,p.operationRoom,p.patient,p.hospitalNumber,p.serialNumber "+ extraQuery +", p.id pid FROM " + RecyclingRecord.class.getSimpleName() + " r left join " + InvoicePlan.class.getSimpleName() + " p on r.recyclingApplication_id = p.id " + joinSqlOfUrgent + (enableUrgentFunction?" left join (select ri.recyclingRecord_id from RecyclingItem ri where ri.urgentAmount>0 group by ri.recyclingRecord_id) b on b.recyclingRecord_id=r.id ":"") + "where r.orgUnitCoding = '" @@ -357,6 +393,13 @@ + filterSql + barcodeInInvoicePlan + ") t3 order by " + +(enableAdditionalRecycleStatusSorting?" case when t3.recyclingStatus in ('"+ InvoicePlan.RECYCLINGSTATUS_PARTRECYCLE +"','"+ InvoicePlan.RECYCLINGSTATUS_PARTAWAITRECEIVE +"') " + + "and exists (select 1 from TousseItem ti " + + "join RecyclingItem ri1 on ri1.tousseDefinitionId=ti.tousseDefinitionId " + + "where ti.recyclingApplication_ID=t3.pid and ri1.recyclingRecord_id=t3.id " + + "and ti.amount>ri1.amount and t3.recyclingTime " + + todayDatesBetweenSql + + ") then 0 else 1 end asc,":"") +(tousseMaterialsLostMustConfirm?"case when t3.status='"+ RecyclingRecord.STATUS_UNCONFIRMED +"' then 0 else 1 end,":"") +(confirmRecyclingAmount?"case t3.recycleAmountNeedConfirm when '" + Constants.STR_YES + "' then 0 else 1 end,":"") +" t3.recyclingTime desc" @@ -371,7 +414,7 @@ + orgUnitCodingFromSupplyRoomConfig + "' and " + filterSql - + " order by " + tousseMaterialsLostMustConfirmOrder + recyclingAmountNeedConfirmOrder+" r.recyclingTime desc) A WHERE ROWNUM <= " + + " order by " + enableAdditionalRecycleStatusSortingSql + tousseMaterialsLostMustConfirmOrder + recyclingAmountNeedConfirmOrder+" r.recyclingTime desc) A WHERE ROWNUM <= " + end + ")WHERE RN >= " + start + " order by RN asc "; }