Index: forgon-tools/src/main/java/com/forgon/tools/util/ForgonMapUtils.java =================================================================== diff -u --- forgon-tools/src/main/java/com/forgon/tools/util/ForgonMapUtils.java (revision 0) +++ forgon-tools/src/main/java/com/forgon/tools/util/ForgonMapUtils.java (revision 17950) @@ -0,0 +1,34 @@ +package com.forgon.tools.util; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author zhonghaowen + * @apiNote + * @since 2017-04-28 + */ +public class ForgonMapUtils { + + /** + * 给出要过滤的key属性,返回不存在该key的新map,例子如下:
+ *

原来的map = [id=1,name=abc,dept=ccc]

+ *

getMapByFilterProperties(map,"id"),返回结果是[name=abc,dept=ccc]

+ * + * @param map 要过滤的map + * @param keys 要过滤的key + */ + + public static Map getMapByFilterProperties(Map map, Object... keys) { + Map newMap = new HashMap(); + for (Object key : map.keySet()) { + for (Object property : keys) { + if (!key.equals(property)) { + newMap.put(key, map.get(key)); + } + } + } + return newMap; + } + +} Index: ssts-web/src/main/webapp/disinfectsystem/config/dgsdhyy/config.js =================================================================== diff -u -r17502 -r17950 --- ssts-web/src/main/webapp/disinfectsystem/config/dgsdhyy/config.js (.../config.js) (revision 17502) +++ ssts-web/src/main/webapp/disinfectsystem/config/dgsdhyy/config.js (.../config.js) (revision 17950) @@ -73,5 +73,8 @@ //是否隐藏灭菌管理-外部代理灭菌里的制作人(只有为true时才隐藏,false或不配置都显示) hideCssdForeignProxyDisinfectionMaker : true, //科室申领是否启用黑白名单过滤物品(目前只支持器械包) - appIsUseBwList : true + appIsUseBwList : true, + //主页是否弹出未归还告警 + isShowUnReturnWarning : true + } \ No newline at end of file Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r17793 -r17950 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 17793) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 17950) @@ -19,12 +19,14 @@ import com.forgon.exception.OperationException; import com.forgon.strategyMode.DateStrategyContext; import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.util.ForgonMapUtils; import com.forgon.tools.util.IntegerUtils; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.PredicateUtils; import org.apache.commons.collections4.Transformer; @@ -119,7 +121,9 @@ private HttpOptionManager httpOptionManager; private OrgUnitManager orgUnitManager; - + + private RecyclingApplicationManager recyclingApplicationManagerTarget; + private static final String FOREIGNTOUSSE_APP_AWAITRECEIVE = "(待接收)外来器械包申请单"; private static final String FOREIGNTOUSSE_APP_AWAITRECYCLE = "(待回收)外来器械包申请单"; @@ -168,6 +172,10 @@ this.dateQueryAdapter = dateQueryAdapter; } + public void setRecyclingApplicationManagerTarget(RecyclingApplicationManager recyclingApplicationManagerTarget) { + this.recyclingApplicationManagerTarget = recyclingApplicationManagerTarget; + } + @Override public InvoicePlan getInvoicePlanById(String id) { if(StringUtils.isNotBlank(id)){ @@ -2075,4 +2083,142 @@ String hql = "from TousseItem po where po.id in(:ids)"; return objectDao.getHibernateSession().createQuery(hql).setParameterList("ids", tousseItemIds).list(); } + + @Override + public JSONObject getUnReturnTips(String departCode) { + try { + List condition = new ArrayList<>(); + condition.add(InvoicePlan.TYPE_BORROWINGSINGLE); + condition.add(InvoicePlan.RETURN_STATUS_UNRETURNED); + condition.add(InvoicePlan.RETURN_STATUS_PARTIALLY_RETURNED); + /* String sql = "select ip.departCoding as \"departCoding\",ti.tousseName as \"tousseName\",ou.name as \"name\", sum(ti.amount) as \"amount\" " + + " from invoicePlan ip " + + " join TousseItem ti on ip.id = ti.recyclingApplication_ID " + + " join OrgUnit ou on ip.departCoding = ou.orgUnitCoding " + + " where ip.type = ? and (ip.returnStatus = ? or ip.returnStatus = ?) "; + sql += " group by ip.departCoding,ou.name,ti.tousseName"; + */ + StringBuilder sql = new StringBuilder(); + sql.append(" select ip.id \"invoicePlanId\",ip.departCoding as \"departCoding\",ti.tousseName as \"tousseName\",ou.name as \"name\",ti.amount as \"amount\"") + .append(" from invoicePlan ip ") + .append(" join TousseItem ti on ip.id = ti.recyclingApplication_ID ") + .append(" join OrgUnit ou on ip.departCoding = ou.orgUnitCoding ") + .append(" where ip.type = ? and (ip.returnStatus = ? or ip.returnStatus = ?) "); + if (StringUtils.isNotBlank(departCode)){ + sql.append(" and ip.departCoding = ? "); + condition.add(departCode); + } + //先查出每张单的借物情况,状态是未归还或者待归还 + List> list = objectDao.findSqlByParam(sql.toString(), condition); + //然后计算出每张单的待还物情况 + List> newList = this.getUnReturnResult(list); + //最终按部门统计计算出每个部门的待还物情况 + Map> allUnReturn = this.calculateAllUnReturnByDepart(newList); + //构建返回页面的参数 + JSONObject result = new JSONObject(); + result.put("data", this.buildUnReturnResult(allUnReturn)); + logger.debug("未归还的结果是:" + result); + return result; + } + catch (Exception e) { + logger.error(e); + throw new RuntimeException(e); + } + } + + /** + * 构建结果返回格式 + * @param allUnReturn 按部门进行统计每个部门待还的物品 + * @return 格式如下:
+ * :[{"depart":"肾移植综合病区","spec":"小缝合包x3"},{"depart":"东川急诊室","spec":"骨活检针(EO)x3,骨穿包x3"}] + */ + private JSONArray buildUnReturnResult(Map> allUnReturn) { + JSONArray array = new JSONArray(); + for (Map.Entry> entry : allUnReturn.entrySet()) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("depart", entry.getKey()); + Map amountDetails = entry.getValue(); + StringBuilder sb = new StringBuilder(); + for (Map.Entry amountEntry : amountDetails.entrySet()) { + sb.append(amountEntry.getKey()).append("x").append(amountEntry.getValue()).append(","); + } + jsonObject.put("spec", sb.substring(0, sb.length() - 1)); + array.add(jsonObject); + } + return array; + } + + /** + * 按部门进行统计每个部门待还的物品 + * @param newList 每张单剩余归还的结果集 + * @return 格式如下:
+ * {肾移植综合病区={小缝合包=3}, 东川急诊室={骨活检针(EO)=3, 骨穿包=3}, 骨科病区={小缝合包=3}} + */ + private Map> calculateAllUnReturnByDepart(List> newList) { + //用来存放最终待还物品的结果集合map + Map> totalMap = new HashMap<>(); + for (Map map : newList) { + //map的格式如下:{骨活检针(EO)=1, 骨穿包=1, departName=东川急诊室} + String departName = MapUtils.getString(map, "departName"); + //这个是存放该部门下自己的待归还物品的状况,格式如下:{骨活检针(EO)=1, 骨穿包=1} + Map departMap = MapUtils.getObject(totalMap, departName, null); + //获得key不为departName的所有结果集map,格式如下:{骨活检针(EO)=2, 骨穿包=3} + Map newDepartMap = ForgonMapUtils.getMapByFilterProperties(map, "departName"); + if (departMap == null) { + //如果totalMap不存在该部门,则添加该部门的待归还物品结果集 + totalMap.put(departName, newDepartMap); + continue; + } + //如果存在该部门,则迭代该结果集重新统计该部门待归还物品的数量,用departMap的物品数量加上newDepartMap的物品数量 + for (Map.Entry entry : newDepartMap.entrySet()) { + String goodName = entry.getKey(); + Integer newAmount = Integer.parseInt(entry.getValue().toString()); + Integer oldAmount = MapUtils.getInteger(departMap, goodName, null); + if (oldAmount != null) { + newAmount += oldAmount; + } + departMap.put(goodName, newAmount); + } + totalMap.put(departName, departMap); + } + logger.debug("所有待还结果如下:" + totalMap); + return totalMap; + } + + /** + * 获得每张单剩余归还的结果 + * @param list 借物单的借物结果集 + * @return 返回一个listMap的类型,格式如下:
+ * [{心包=1, departName=心内七区},{骨穿包=1, departName=东川急诊室}, {骨穿包=2, departName=东川急诊室}, {骨活检针(EO)=1, 骨穿包=1, departName=东川急诊室}] + */ + private List> getUnReturnResult(List> list){ + //临时列表,用于存放借物id + List temp = new ArrayList<>(); + List> newList = new ArrayList<>(); + logger.debug("每张借物单的借物情况结果如下:" + list); + for (Map map : list) { + Long invoicePlanId = MapUtils.getLong(map, "invoicePlanId"); + //如果这个列表已经存在该借物id,则不说明已经计算过,这里就不再计算 + if (temp.contains(invoicePlanId)) { + continue; + } + temp.add(invoicePlanId); + //用借物id去查询这张借物单待归还情况 + Map canReturnAmount = recyclingApplicationManagerTarget.getCanReturnAmount(invoicePlanId); + Map newMap = new HashMap<>(); + newMap.put("departName", map.get("name")); + //把这张借物单待归还的物品情况放在这个新的map里,过滤掉数量为0的 + for (Map.Entry entry : canReturnAmount.entrySet()) { + Integer count = entry.getValue(); + if (count != 0) { + newMap.put(entry.getKey(), count); + } + } + newList.add(newMap); + } + logger.debug("每张单待还结果如下:" + newList); + return newList; + } + + } Index: ssts-web/src/main/webapp/homepage/portalPage.js =================================================================== diff -u -r17302 -r17950 --- ssts-web/src/main/webapp/homepage/portalPage.js (.../portalPage.js) (revision 17302) +++ ssts-web/src/main/webapp/homepage/portalPage.js (.../portalPage.js) (revision 17950) @@ -1,4 +1,5 @@ var warningWindow; //系统告警win +var unReturnWarningWindow; //未归还告警win var packingMenu ; var reviewPackingMenu ; var sterilizationRecordMenu ; @@ -277,6 +278,10 @@ });*/ //系统告警 initShowSystemWarningWin(); + + if (sstsConfig.isShowUnReturnWarning){ + showUnReturnWarning(); + } showUpToNeckSatisfactionSurveyWinTips(); if (sstsConfig.biologicalMonitoringWarning && currentOrgUnitIsFirstSupplyRoom) { //开启生物监测结束后的提示功能,目前只开发给当前科室为一级供应室的用户 @@ -1201,6 +1206,51 @@ function showSystemWarningWin(){ doShowSystemWarningWinByParam(false); } + +/** + * 显示未归还告警 + */ +function showUnReturnWarning() { + var departCode = globalIsSupplyRoomUser == "true" ? '' : currentDepartCode; + Ext4.Ajax.request({ + dataType : "json", + params : {'departCode': departCode}, + url: WWWROOT + "/system/systemWarningAction!getUnReturnWarning.do", + success: function(response) { + var result = Ext4.decode(response.responseText); + if(result.data && result.data.length > 0){ + var unReturnGrid = new Ext.grid.GridPanel({ + store: new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : ["depart", "spec"] + }) + }), + columns: [ + {header: "科室名称", width: 130, dataIndex: 'depart'}, + {header: "未归还的物品", width: 300,dataIndex: 'spec'}, + {header: "查看", width: 70,dataIndex: 'warningItemType',renderer : goBorrow} + ], + stripeRows: true, + viewConfig: {forceFit: true}, + height : 140 + }); + unReturnGrid.getStore().loadData(result.data); + unReturnWarningWindow = new Ext.Window({ + autoHeight:true, + title : '未归还提示', + width : 480, + draggable:true, + modal:true, + closeAction:'close', + items:[unReturnGrid] + }); + unReturnWarningWindow.show(); + } + } + }); +} + + var doSync = false; function doShowSystemWarningWinByParam(isFirstOnLoad){ if(doSync){ @@ -1332,6 +1382,14 @@ return ""+mess+""; } +/** + * 未归还告警窗口点击查看详细跳去借物管理页面 + */ +function goBorrow(v, p, record){ + var mess = "查看详细"; + return ""+mess+""; +} + function openSelectOrgUnitWindow(){ var data = new Array(); var orgUnitIdArray = directOrgUnitCodesWhereUserBelong.split(";"); Index: ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/action/SystemWarningAction.java =================================================================== diff -u -r17279 -r17950 --- ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/action/SystemWarningAction.java (.../SystemWarningAction.java) (revision 17279) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/action/SystemWarningAction.java (.../SystemWarningAction.java) (revision 17950) @@ -10,13 +10,16 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import com.forgon.disinfectsystem.recyclingapplication.service.InvoicePlanManager; +import com.forgon.tools.StrutsResponseUtils; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableCellFormat; import jxl.write.WritableFont; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; +import net.sf.json.JSONObject; import org.apache.commons.collections.iterators.ArrayListIterator; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; @@ -55,7 +58,13 @@ private DateQueryAdapter dateQueryAdapter;; private ObjectDao objectDao; - + + private InvoicePlanManager invoicePlanManager; + + public void setInvoicePlanManager(InvoicePlanManager invoicePlanManager) { + this.invoicePlanManager = invoicePlanManager; + } + public void setSystemWarningManager(SystemWarningManager systemWarningManager) { this.systemWarningManager = systemWarningManager; } @@ -86,6 +95,21 @@ } } + + /** + * 获取未归还的告警 + */ + public void getUnReturnWarning(){ + try { + String departCode = StrutsParamUtils.getPraramValue("departCode", null); + JSONObject unReturnTips = invoicePlanManager.getUnReturnTips(departCode); + StrutsResponseUtils.output(unReturnTips); + } + catch (Exception e) { + e.printStackTrace(); + StrutsResponseUtils.output(false); + } + } /** * 获取需要告警器械包,并且导出的excel文件 Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java =================================================================== diff -u -r17793 -r17950 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 17793) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 17950) @@ -216,4 +216,12 @@ * @param tousseItemIds 申请物品的id列表 */ void checkTousseItemCanCancel(Collection tousseItemIds); + + + /** + * 获得未归还的提示 + * departCode 部门编号 + * @return + */ + JSONObject getUnReturnTips(String departCode); }