Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/RealTimeBulletinBoardWorkloadHelper.java =================================================================== diff -u -r37151 -r38630 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/RealTimeBulletinBoardWorkloadHelper.java (.../RealTimeBulletinBoardWorkloadHelper.java) (revision 37151) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/RealTimeBulletinBoardWorkloadHelper.java (.../RealTimeBulletinBoardWorkloadHelper.java) (revision 38630) @@ -6,11 +6,14 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -28,10 +31,12 @@ import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseInstance; import com.forgon.disinfectsystem.entity.becleanitem.ClassifiedItem; import com.forgon.disinfectsystem.entity.becleanitem.ClassifyBasket; +import com.forgon.disinfectsystem.entity.foreigntousseapplication.ForeignTousseApplication; import com.forgon.disinfectsystem.entity.invoicemanager.Invoice; import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; import com.forgon.disinfectsystem.entity.packing.PackingTask; import com.forgon.disinfectsystem.entity.packing.ReviewedBasket; +import com.forgon.disinfectsystem.entity.recyclingrecord.RecyclingItem; import com.forgon.disinfectsystem.entity.recyclingrecord.RecyclingRecord; import com.forgon.disinfectsystem.entity.sterilizationmanager.proxydisinfection.ProxyDisinfection; import com.forgon.disinfectsystem.entity.sterilizationmanager.sterilizationrecord.SterilizationRecord; @@ -1029,4 +1034,601 @@ DatabaseUtil.closeResultSetAndStatement(rs); } } + /** + * 获取器械包汇总(今日器械包处理量) + * @return + */ + public JSONObject getTousseSummary(){ + //获取当天开始时间 + SupplyRoomConfig systemParamsObj = supplyRoomConfigManager.getSystemParamsObj(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date today = new Date(); + String dateStr = sdf.format(today); + String startDate = ""; + if(StringUtils.isNotBlank(systemParamsObj.getDayStartTime())){ + startDate += dateStr + " " + systemParamsObj.getDayStartTime() + ":00"; + }else{ + startDate += dateStr + " 00:00:00"; + } + String endDate = dateStr + " 23:59:59"; + String betweenSql = " between "+ dateQueryAdapter.dateAdapter(startDate) + " and " + + dateQueryAdapter.dateAdapter(endDate); + String handleDepartCoding = supplyRoomConfigManager.getFirstSupplyRoomConfig().getOrgUnitCoding(); + ReportQueryParams params = new ReportQueryParams(); + params.haveCombo = false; + params.betweenSql = betweenSql; + params.querySupplyRoom = handleDepartCoding; + String sql = ""; + String toBeBetweenSql = ""; + Integer dashboardsQueryCycle = null; + if(systemParamsObj.getDashboardsQueryCycle() == null){ + dashboardsQueryCycle = 7; + }else{ + dashboardsQueryCycle = systemParamsObj.getDashboardsQueryCycle(); + } + if(dashboardsQueryCycle != 0){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_MONTH, -dashboardsQueryCycle); + String toBeStartDate = sdf.format(calendar.getTime()) + " 00:00:00"; + String toBeEndDate = sdf.format(today) + " 23:59:59"; + toBeBetweenSql = " between "+ dateQueryAdapter.dateAdapter(toBeStartDate) + " and " + + dateQueryAdapter.dateAdapter(toBeEndDate); + } + //申请数量 + String applyAmountSql = String.format("select 'applyAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("申请数量", params) + + ") tl"); + sql += " union all " + applyAmountSql; + //当天待回收的包数量 + String toBeRecycledAmountSql = "select 'toBeRecycledAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeRecycledAmountSql(handleDepartCoding, "", toBeBetweenSql, false) + ") tb "; + sql += " union all " + toBeRecycledAmountSql; + //当天已回收包数量 + String recycledAmountSql = String.format("select 'recycledAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("回收数量", params) + + ") tl"); + sql += " union all " + recycledAmountSql; + //当天已清点器械总包数 + String inventoryEdAmountSql = String.format("select 'inventoryEdAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("清点数量", params) + + ") tl "); + sql += " union all " + inventoryEdAmountSql; + //当天待清洗器械总包数 + String toBeWashAmountSql = " select 'tobeWashAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeWashAmountSql(handleDepartCoding, "", toBeBetweenSql, false) + ") tb "; + sql += " union all " + toBeWashAmountSql; + //当天已清洗器械总包数 + String washedAmountSql = String.format("select 'washedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("清洗数量", params) + + ") tl "); + sql += " union all " + washedAmountSql; + //当天待装配的总包数 + String toBePackAmountSql = " select 'toBePackAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBePackAmountSql(handleDepartCoding, "", toBeBetweenSql) + ") tb "; + sql += " union all " + toBePackAmountSql; + //当天已装配总包数 + String packedAmountSql = String.format("select 'packedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("配包数量", params) + + ") tl "); + sql += " union all " + packedAmountSql; + //当天已审核的总包数 + String reviewedAmountSql = String.format("select 'reviewedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("审核数量", params) + + ") tl "); + sql += " union all " + reviewedAmountSql; + //当天待灭菌的总包数 + String toBeSterilizationAmountSql = " select 'toBeSterilizationAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeSterilizationAmountSql(handleDepartCoding, "", toBeBetweenSql) + ") tb "; + sql += " union all " + toBeSterilizationAmountSql; + //当天已灭菌的总包数 + String sterilizationedAmountSql = String.format("select 'sterilizationedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("灭菌数量", params) + + ") tl "); + sql += " union all " + sterilizationedAmountSql; + //当天待发货的总包数 + String toBeInvoiceAmountSql = " select 'toBeInvoiceAmount' type,sum(amount) amount,sum(urgentAmount) urgentAmount from ( " + + getToBeInvoiceAmountSql(handleDepartCoding, "", toBeBetweenSql) + ") tb "; + sql += " union all " + toBeInvoiceAmountSql; + //当天已发货的总包数 + String invoicedAmountSql = String.format("select 'invoicedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("发货数量", params) + + ") tl "); + sql += " union all " + invoicedAmountSql; + //当天已签收的包数 + String signedAmountSql = String.format("select 'signedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("签收数量", params) + + ") tl "); + sql += " union all " + signedAmountSql; + ResultSet rs = null; + JSONObject obj = new JSONObject(); + try { + rs = objectDao.executeSql(sql); + while (rs.next()) { + String type = rs.getString("type"); + if("toBeInvoiceAmount".equals(type)){ + obj.put("toBeInvoiceUrgentAmount", rs.getInt("urgentAmount"));//待处理加急数量 + } + obj.put(type, rs.getInt("amount")); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + return obj; + } + /** + * 获取外来器械包汇总 + * @return + */ + public JSONObject getForeignTousseSummary() { + //获取当天开始时间 + SupplyRoomConfig systemParamsObj = supplyRoomConfigManager.getSystemParamsObj(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date today = new Date(); + String dateStr = sdf.format(today); + String startDate = ""; + if(StringUtils.isNotBlank(systemParamsObj.getDayStartTime())){ + startDate += dateStr + " " + systemParamsObj.getDayStartTime() + ":00"; + }else{ + startDate += dateStr + " 00:00:00"; + } + String endDate = dateStr + " 23:59:59"; + String betweenSql = " between "+ dateQueryAdapter.dateAdapter(startDate) + " and " + + dateQueryAdapter.dateAdapter(endDate); + String handleDepartCoding = supplyRoomConfigManager.getFirstSupplyRoomConfig().getOrgUnitCoding(); + String tousseType = "外来器械包,外来器械拆分小包"; + String tousseTypesql = SqlUtils.getWhereSqlByfilterFieldAndStringValueAndSeparator("td.tousseType", tousseType, ","); + ReportQueryParams foreignParams = new ReportQueryParams(); + foreignParams.haveCombo = false; + foreignParams.betweenSql = betweenSql; + foreignParams.querySupplyRoom = handleDepartCoding; + foreignParams.tousseTypes = tousseType; + foreignParams.tousseTypeAndPackageSizeSql = tousseTypesql; + + String sql = ""; + String toBeBetweenSql = ""; + Integer dashboardsQueryCycle = null; + if(systemParamsObj.getDashboardsQueryCycle() == null){ + dashboardsQueryCycle = 7; + }else{ + dashboardsQueryCycle = systemParamsObj.getDashboardsQueryCycle(); + } + if(dashboardsQueryCycle != 0){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_MONTH, -dashboardsQueryCycle); + String toBeStartDate = sdf.format(calendar.getTime()) + " 00:00:00"; + String toBeEndDate = sdf.format(today) + " 23:59:59"; + toBeBetweenSql = " between "+ dateQueryAdapter.dateAdapter(toBeStartDate) + " and " + + dateQueryAdapter.dateAdapter(toBeEndDate); + } + //外来器械申请数量 + String foreignApplyAmountSql = String.format("select 'foreignApplyAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("申请数量", foreignParams) + + ") tl"); + sql += foreignApplyAmountSql; + //外来器械当天待回收的包数量 + String foreignToBeRecycledAmountSql = "select 'foreignToBeRecycledAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeRecycledAmountSql(handleDepartCoding, tousseTypesql, toBeBetweenSql, true) + ") tb "; + sql += " union all " + foreignToBeRecycledAmountSql; + //外来器械当天已回收包数量 + foreignParams.extraQuery = " and rr.recyclingTimes is null "; + String foreignRecycledAmountSql = String.format("select 'foreignRecycledAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("回收数量", foreignParams) + + ") tl"); + sql += " union all " + foreignRecycledAmountSql; + foreignParams.extraQuery = ""; + //外来器械当天待清洗器械总包数 + String foreignToBeWashAmountSql = " select 'foreignTobeWashAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeWashAmountSql(handleDepartCoding, tousseTypesql, toBeBetweenSql, true) + ") tb "; + sql += " union all " + foreignToBeWashAmountSql; + //外来器械当天已清洗器械总包数 + foreignParams.extraQuery = " and ci.isSencondWashForForeignTousse=0 "; + String foreignWashedAmountSql = String.format("select 'foreignWashedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("清洗数量", foreignParams) + + ") tl "); + sql += " union all " + foreignWashedAmountSql; + foreignParams.extraQuery = ""; + //外来器械当天待装配的总包数 + String foreignToBePackAmountSql = " select 'foreignToBePackAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBePackAmountSql(handleDepartCoding, tousseTypesql, toBeBetweenSql) + ") tb "; + sql += " union all " + foreignToBePackAmountSql; + //外来器械当天已装配总包数 + String foreignPackedAmountSql = String.format("select 'foreignPackedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("配包数量", foreignParams) + + ") tl "); + sql += " union all " + foreignPackedAmountSql; + //外来器械当天待灭菌的总包数 + String foreignToBeSterilizationAmountSql = " select 'foreignToBeSterilizationAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeSterilizationAmountSql(handleDepartCoding, tousseTypesql, toBeBetweenSql) + ") tb "; + sql += " union all " + foreignToBeSterilizationAmountSql; + //外来器械当天已灭菌的总包数 + String foreignSterilizationedAmountSql = String.format("select 'foreignSterilizationedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("灭菌数量", foreignParams) + + ") tl "); + sql += " union all " + foreignSterilizationedAmountSql; + //外来器械当天待发货的总包数 + String foreignToBeInvoiceAmountSql = " select 'foreignToBeInvoiceAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeInvoiceAmountSql(handleDepartCoding, tousseTypesql, toBeBetweenSql) + ") tb "; + sql += " union all " + foreignToBeInvoiceAmountSql; + //外来器械当天已发货的总包数 + String foreignInvoicedAmountSql = String.format("select 'foreignInvoicedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("发货数量", foreignParams) + + ") tl "); + sql += " union all " + foreignInvoicedAmountSql; + //外来器械当天待签收的包数 + String foreignToBeSignAmountSql = " select 'foreignToBeSignAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getToBeSignAmountSql(handleDepartCoding, tousseTypesql, toBeBetweenSql) + ") tb "; + sql += " union all " + foreignToBeSignAmountSql; + //外来器械当天已签收的包数 + String foreignSignedAmountSql = String.format("select 'foreignSignedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("签收数量", foreignParams) + + ") tl "); + sql += " union all " + foreignSignedAmountSql; + ResultSet rs = null; + JSONObject obj = new JSONObject(); + try { + rs = objectDao.executeSql(sql); + while (rs.next()) { + obj.put(rs.getString("type"), rs.getInt("amount")); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + return obj; + } + /** + * 加急物品汇总功能数据 + * @return + */ + public JSONArray getUrgentgoodssummary(){ + ResultSet rs = null; + JSONArray arr = new JSONArray(); + String toBeBetweenSql = ""; + Integer dashboardsQueryCycle = null; + //获取当天开始时间 + SupplyRoomConfig systemParamsObj = supplyRoomConfigManager.getSystemParamsObj(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date today = new Date(); + if(systemParamsObj.getDashboardsQueryCycle() == null){ + dashboardsQueryCycle = 7; + }else{ + dashboardsQueryCycle = systemParamsObj.getDashboardsQueryCycle(); + } + if(dashboardsQueryCycle != 0){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_MONTH, -dashboardsQueryCycle); + String toBeStartDate = sdf.format(calendar.getTime()) + " 00:00:00"; + String toBeEndDate = sdf.format(today) + " 23:59:59"; + toBeBetweenSql = " between "+ dateQueryAdapter.dateAdapter(toBeStartDate) + " and " + + dateQueryAdapter.dateAdapter(toBeEndDate); + } + String handleDepartCoding = supplyRoomConfigManager.getFirstSupplyRoomConfig().getOrgUnitCoding(); + try { + String toBeInvoiceUrgentSumSql = " select sum(urgentAmount) urgentAmount,name,tousseName,colorCode from ( " + + getToBeInvoiceUrgentSumSql(handleDepartCoding, "", toBeBetweenSql) + ") tb group by name,tousseName,grade,colorCode order by grade desc "; + rs = objectDao.executeSql(toBeInvoiceUrgentSumSql); + while (rs.next()) { + JSONObject urgentItem = new JSONObject(); + urgentItem.put("urgentAmount", rs.getInt("urgentAmount")); + urgentItem.put("name", rs.getString("name")); + urgentItem.put("tousseName", rs.getString("tousseName")); + urgentItem.put("colorCode", rs.getString("colorCode")); + arr.add(urgentItem); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + return arr; + } + + /** + * 查询指定周期外来器械申请单数据汇总 + * @return + */ + public JSONObject getForeignTousseSummary_SpecifyPeriod(){ + //获取当天开始时间 + JSONObject obj = new JSONObject(); + SupplyRoomConfig systemParamsObj = supplyRoomConfigManager.getSystemParamsObj(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date today = new Date(); + String dateStr = sdf.format(today); + String startDate = ""; + if(StringUtils.isNotBlank(systemParamsObj.getDayStartTime())){ + startDate += dateStr + " " + systemParamsObj.getDayStartTime() + ":00"; + }else{ + startDate += dateStr + " 00:00:00"; + } + String endDate = dateStr + " 23:59:59"; + String betweenSql = " between "+ dateQueryAdapter.dateAdapter(startDate) + " and " + + dateQueryAdapter.dateAdapter(endDate); + String handleDepartCoding = supplyRoomConfigManager.getFirstSupplyRoomConfig().getOrgUnitCoding(); + String planAmountSql = "select count(*) invoicePlanAmount," + + "sum(case when ip.recyclingStatus in('" + +InvoicePlan.RECYCLINGSTATUS_SECRECYCLED + +"','" + +InvoicePlan.RECYCLINGSTATUS_AWAITRECEIVED + +"','" + +InvoicePlan.RECYCLINGSTATUS_RETURNEDINADVANCE + +"','" + +InvoicePlan.RECYCLINGSTATUS_RECYCLED + +"') then 1 else 0 end) recyAmount" + + ",sum(case when ip.deliverStatus='" + +InvoicePlan.DELIVERSTATUS_DELIVERED + +"' then 1 else 0 end) invoiceAmount from " + + InvoicePlan.class.getSimpleName() + +" ip join " + + ForeignTousseApplication.class.getSimpleName() + +" fta on fta.id=ip.id where ip.applicationTime " + + betweenSql + + SqlUtils.get_InSql_Extra("ip.handleDepartCoding", handleDepartCoding); + ResultSet rs = null; + try { + rs = objectDao.executeSql(planAmountSql); + while (rs.next()) { + int invoicePlanAmount = rs.getInt("invoicePlanAmount"); + int recyAmount = rs.getInt("recyAmount"); + int invoiceAmount = rs.getInt("invoiceAmount"); + obj.put("invoicePlanAmount", invoicePlanAmount); + obj.put("recyAmount", recyAmount); + obj.put("invoiceAmount", invoiceAmount); + obj.put("toBeInvoicePlanAmount", invoicePlanAmount - recyAmount); + break; + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + return obj; + } + /** + * 获取加急物品详细rgentGoodsDetails的数据源 + * @return + */ + public String getUrgentGoodsDetails(){ + SupplyRoomConfig systemParamsObj = supplyRoomConfigManager.getSystemParamsObj(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date today = new Date(); + String dateStr = sdf.format(today); + String startDate = ""; + if(StringUtils.isNotBlank(systemParamsObj.getDayStartTime())){ + startDate += dateStr + " " + systemParamsObj.getDayStartTime() + ":00"; + }else{ + startDate += dateStr + " 00:00:00"; + } + String endDate = dateStr + " 23:59:59"; + String betweenSql = " between "+ dateQueryAdapter.dateAdapter(startDate) + " and " + + dateQueryAdapter.dateAdapter(endDate); + String handleDepartCoding = supplyRoomConfigManager.getFirstSupplyRoomConfig().getOrgUnitCoding(); + String riUrgentAmountSql = "select ri.tousseName,sum(ri.urgentAmount) urgentAmount from " + + RecyclingItem.class.getSimpleName() + + " ri join " + + RecyclingRecord.class.getSimpleName() + + " rr on rr.id=ri.recyclingRecord_id join " + + InvoicePlan.class.getSimpleName() + + " ip on ip.id=rr.recyclingApplication_id " + + "where rr.recyclingTimes is null and ri.urgentAmount>0 " + + "and ip.applicationTime " + + betweenSql + +" and ip.handleDepartCoding = '" + + handleDepartCoding + +"' group by ri.tousseName"; + ResultSet rs2 = null; + Map tousseMap = new HashMap(); + try { + rs2 = objectDao.executeSql(riUrgentAmountSql); + while (rs2.next()) { + String tousseName = rs2.getString("tousseName"); + int urgentAmount = rs2.getInt("urgentAmount"); + JSONObject tousseObj = new JSONObject(); + tousseObj.put("recyUrgentAmount", urgentAmount); + tousseObj.put("tousseName", tousseName); + tousseMap.put(tousseName, tousseObj); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs2); + } + + String tousseInstanceAmountSql = "select ti.tousseName" + + ",sum(case when ti.status ='" + + TousseInstance.STATUS_PACKED + + "' then 1 else 0 end) packamount" + + ",sum(case when ti.status ='" + + TousseInstance.STATUS_STERILED + + "' then 1 else 0 end) steMount" + + ",sum(case when ti.invoice_id is not null then 1 else 0 end) invoiceAmount from " + + TousseInstance.class.getSimpleName() + + " ti where ti.urgentlevel_id is not null " + + "and exists (select 1 from " + + InvoicePlan.class.getSimpleName() + + " ip where ip.applicationTime " + + betweenSql + +" and ip.handleDepartCoding = '" + + handleDepartCoding + +"') group by ti.tousseName "; + ResultSet rsOfTousseInstanceAmount = null; + int invoicePlanUrgentAmount = 0; + int sendOutUrgentAmount = 0; + try { + rsOfTousseInstanceAmount = objectDao.executeSql(tousseInstanceAmountSql); + while (rsOfTousseInstanceAmount.next()) { + String tousseName = rsOfTousseInstanceAmount.getString("tousseName"); + JSONObject tousseObj = null; + int recyUrgentAmount = 0; + if(tousseMap.containsKey(tousseName)){ + tousseObj = tousseMap.get(tousseName); + recyUrgentAmount = tousseObj.optInt("recyUrgentAmount"); + }else{ + tousseObj = new JSONObject(); + tousseObj.put("tousseName", tousseName); + tousseObj.put("recyUrgentAmount", 0); + } + int packamount = rsOfTousseInstanceAmount.getInt("packamount"); + int steMount = rsOfTousseInstanceAmount.getInt("steMount"); + int invoiceAmount = rsOfTousseInstanceAmount.getInt("invoiceAmount"); + int surplusRecyUrgentAmount = 0;//回收加急数量-装配数量 + if(recyUrgentAmount > packamount){ + surplusRecyUrgentAmount = recyUrgentAmount - packamount; + }else{ + surplusRecyUrgentAmount = 0; + } + int totalAmount = packamount +steMount + invoiceAmount + surplusRecyUrgentAmount; + tousseObj.put("packAmount", packamount); + tousseObj.put("steMount", steMount); + tousseObj.put("invoiceAmount", invoiceAmount); + sendOutUrgentAmount+=invoiceAmount; + tousseObj.put("totalAmount", totalAmount); + invoicePlanUrgentAmount+=totalAmount; + tousseMap.put(tousseName, tousseObj); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rsOfTousseInstanceAmount); + } + JSONObject obj = new JSONObject(); + obj.put("urgentGoodsDetailsData", tousseMap.values().toString()); + JSONObject sumObj = new JSONObject(); + sumObj.put("invoicePlanUrgentAmount", invoicePlanUrgentAmount); + sumObj.put("sendOutUrgentAmount", sendOutUrgentAmount); + sumObj.put("toBeSendOutUrgentAmount", invoicePlanUrgentAmount - sendOutUrgentAmount); + obj.put("urgentSumInfo", sumObj); + return obj.toString(); + } + /** + * 获取加急物品处理信息 + * @return + */ + public String getUrgentToussehandleInfo(){ + //获取当天开始时间 + SupplyRoomConfig systemParamsObj = supplyRoomConfigManager.getSystemParamsObj(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date today = new Date(); + String dateStr = sdf.format(today); + String startDate = ""; + if(StringUtils.isNotBlank(systemParamsObj.getDayStartTime())){ + startDate += dateStr + " " + systemParamsObj.getDayStartTime() + ":00"; + }else{ + startDate += dateStr + " 00:00:00"; + } + String endDate = dateStr + " 23:59:59"; + String betweenSql = " between "+ dateQueryAdapter.dateAdapter(startDate) + " and " + + dateQueryAdapter.dateAdapter(endDate); + String handleDepartCoding = supplyRoomConfigManager.getFirstSupplyRoomConfig().getOrgUnitCoding(); + ReportQueryParams params = new ReportQueryParams(); + params.haveCombo = false; + params.betweenSql = betweenSql; + params.querySupplyRoom = handleDepartCoding; + String sql = ""; + String toBeBetweenSql = ""; + Integer dashboardsQueryCycle = null; + if(systemParamsObj.getDashboardsQueryCycle() == null){ + dashboardsQueryCycle = 7; + }else{ + dashboardsQueryCycle = systemParamsObj.getDashboardsQueryCycle(); + } + if(dashboardsQueryCycle != 0){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_MONTH, -dashboardsQueryCycle); + String toBeStartDate = sdf.format(calendar.getTime()) + " 00:00:00"; + String toBeEndDate = sdf.format(today) + " 23:59:59"; + toBeBetweenSql = " between "+ dateQueryAdapter.dateAdapter(toBeStartDate) + " and " + + dateQueryAdapter.dateAdapter(toBeEndDate); + } + //当天待发货的总包数 + String toBeInvoiceAmountSql = " select 'toBeInvoiceAmount' type,sum(amount) amount,sum(urgentAmount) urgentAmount from ( " + + getToBeInvoiceAmountSql(handleDepartCoding, "", toBeBetweenSql) + ") tb "; + sql += " union all " + toBeInvoiceAmountSql; + //当天已发货的总包数 + String invoicedAmountSql = String.format("select 'invoicedAmount' type,sum(amount) amount,0 urgentAmount from (" + +dataIndex.getWorkAmountByPackageSQL("发货数量", params) + + ") tl "); + sql += " union all " + invoicedAmountSql; + //当天已处理加急物品的总包数 + String invoicedUrgentAmountSql = " select 'invoicedUrgentAmount' type,sum(amount) amount,0 urgentAmount from ( " + + getInvoicedUrgentAmountSql(handleDepartCoding, betweenSql) + ") tb "; + sql += " union all " + invoicedUrgentAmountSql; + ResultSet rs = null; + JSONObject obj = new JSONObject(); + try { + rs = objectDao.executeSql(sql); + while (rs.next()) { + String type = rs.getString("type"); + if("toBeInvoiceAmount".equals(type)){ + obj.put("toBeInvoiceUrgentAmount", rs.getInt("urgentAmount"));//待处理加急数量 + } + obj.put(type, rs.getInt("amount")); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + return obj.toString(); + } + /** + * 获取数据看板数据源 + * @param requestParameters + * @return + */ + public String getDataByDataSources(Map requestParameters) { + String dataSources = requestParameters.get("dataSources"); + if(StringUtils.isBlank(dataSources)){ + return null; + } + String result = null; + if("foreigntoussesummary".equalsIgnoreCase(dataSources)){//外来器械包汇总 + JSONObject resultObj = getForeignTousseSummary(); + if(resultObj != null){ + result = resultObj.toString(); + } + }else if("toussesummary".equalsIgnoreCase(dataSources)){//器械包汇总(今日器械包处理量) + JSONObject resultObj = getTousseSummary(); + if(resultObj != null){ + result = resultObj.toString(); + } + }else if("deviceusagesummary".equalsIgnoreCase(dataSources)){//设备使用情况汇总 + List list = getEquipmentData(); + if(CollectionUtils.isNotEmpty(list)){ + result = list.toString(); + } + }else if("urgentgoodssummary".equalsIgnoreCase(dataSources)){//加急物品汇总功能 + JSONArray resultArr = getUrgentgoodssummary(); + if(resultArr != null){ + result = resultArr.toString(); + } + }else if("foreigntoussesummary_specifyperiod".equalsIgnoreCase(dataSources)){//查询指定周期外来器械申请单数据汇总 + JSONObject foreignTousseSummaryObj = getForeignTousseSummary(); + JSONObject foreignTousseSummary_SpecifyPeriodObj = getForeignTousseSummary_SpecifyPeriod(); + foreignTousseSummaryObj.put("invoicePlanAmount", foreignTousseSummary_SpecifyPeriodObj.optInt("invoicePlanAmount")); + foreignTousseSummaryObj.put("recyAmount", foreignTousseSummary_SpecifyPeriodObj.optInt("recyAmount")); + foreignTousseSummaryObj.put("invoiceAmount", foreignTousseSummary_SpecifyPeriodObj.optInt("invoiceAmount")); + foreignTousseSummaryObj.put("toBeInvoicePlanAmount", foreignTousseSummary_SpecifyPeriodObj.optInt("toBeInvoicePlanAmount")); + return foreignTousseSummaryObj.toString(); + }else if("workloadsummary".equalsIgnoreCase(dataSources)){//工作量汇总(今日工作量统计) + JSONObject resultObj = getRealTimeBulletinBoardWorkloadData(); + if(resultObj != null){ + result = resultObj.toString(); + } + }else if("urgentgoodsdetails".equalsIgnoreCase(dataSources)){//加急物品明细追溯模式 + return getUrgentGoodsDetails(); + }else if("urgentToussehandleInfo".equals(dataSources)){ + return getUrgentToussehandleInfo(); + } + if(result == null){ + return StringUtils.EMPTY; + } + return result.toString(); + } }