Index: ssts-web/src/main/webapp/js/globalKeyDown.js =================================================================== diff -u --- ssts-web/src/main/webapp/js/globalKeyDown.js (revision 0) +++ ssts-web/src/main/webapp/js/globalKeyDown.js (revision 15437) @@ -0,0 +1,64 @@ +/** + * 全局扫描条码的处理,以keydown事件处理。当按下enter键的时候,调用callback,参数为条码内容. + * 调用此方法后,需要再调用focus方法获取焦点,以便触发onkeydown事件 + * @param callback + */ +function globalOnKeyDown(callback){ + document.onkeydown = showKeyDown; + + /*--------------------------- + 功能:停止事件冒泡 + ---------------------------*/ + function stopBubble(e) { + //如果提供了事件对象,则这是一个非IE浏览器 + if ( e && e.stopPropagation ) + //因此它支持W3C的stopPropagation()方法 + e.stopPropagation(); + else + //否则,我们需要使用IE的方式来取消事件冒泡 + window.event.cancelBubble = true; + } + //阻止浏览器的默认行为 + function stopDefault( e ) { + //阻止默认浏览器动作(W3C) + if ( e && e.preventDefault ) + e.preventDefault(); + //IE中阻止函数器默认动作的方式 + else + window.event.returnValue = false; + return false; + } + + //在页面无需将光标定位在输入框相应全局的扫描枪事件 + var barcodeTemp = ''; + function showKeyDown(){ + if(event.keyCode == 48 || event.keyCode == 96){ + barcodeTemp += '0'; + }else if(event.keyCode == 49 || event.keyCode == 97){ + barcodeTemp += '1'; + }else if(event.keyCode == 50 || event.keyCode == 98){ + barcodeTemp += '2'; + }else if(event.keyCode == 51 || event.keyCode == 99){ + barcodeTemp += '3'; + }else if(event.keyCode == 52 || event.keyCode == 100){ + barcodeTemp += '4'; + }else if(event.keyCode == 53 || event.keyCode == 101){ + barcodeTemp += '5'; + }else if(event.keyCode == 54 || event.keyCode == 102){ + barcodeTemp += '6'; + }else if(event.keyCode == 55 || event.keyCode == 103){ + barcodeTemp += '7'; + }else if(event.keyCode == 56 || event.keyCode == 104){ + barcodeTemp += '8'; + }else if(event.keyCode == 57 || event.keyCode == 105){ + barcodeTemp += '9'; + }else if(event.keyCode == 13){ + if(callback){ + callback(barcodeTemp); + } + barcodeTemp = ''; + } + stopBubble(event); + stopDefault(event); + } +} \ No newline at end of file Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java =================================================================== diff -u -r15173 -r15437 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 15173) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 15437) @@ -7,6 +7,9 @@ import java.util.List; import java.util.Set; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseInstance; import com.forgon.disinfectsystem.entity.invoicemanager.Invoice; import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; @@ -45,7 +48,7 @@ * @param tousseType 物品类型,如是或否,是代码为一次性物品,否代码非一次性物品 * @return Collection> 里面的List集合由两位元素组成,发货单的id用申请单序列号+类型 */ - public Collection> getInvoicePlansByOrgAndTousseType( + public JSONArray getInvoicePlansByOrgAndTousseType( Collection departCodes, String applyDate, String tousseType); public int getInvoicePlanAmount(String sql); @@ -136,5 +139,11 @@ public void computeAndSetPrintStatus(InvoicePlan invoicePlan); public List getExpressRecyclingTousse(int supplyRoomType, String handleDepartCodings); + /** + * 发货计划列表扫描科室条码或者单号条码,打开对应的发货单。先按条码找科室,找不到科室就按流水号找申请单 + * @param barcode 科室条码或者单号条码 + * @return + */ + public JSONObject invoicePlanListScanBarcode(String barcode); } Index: ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.js =================================================================== diff -u -r15261 -r15437 --- ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.js (.../invoicePlanExtractedView.js) (revision 15261) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.js (.../invoicePlanExtractedView.js) (revision 15437) @@ -56,6 +56,35 @@ var depart = records[0].data['depart']; addAndEditInvoicePlan(departCode,depart); } +/** + * 通过扫描条码打开发货计划单。条码可以是科室条码(不是科室编码),也可以是单号 + */ +function openInvoicePlanByBarcode(barcode){ + if(isUndefinedOrNullOrEmpty(barcode)){ + showResult("请扫描科室条码或申请单条码"); + return; + } + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/invoicePlanAction!getScanResult.do', + params : {barcode : barcode}, + success : function(response, options) { + var result = Ext.decode(response.responseText); + if(result){ + if(result.success){ + addAndEditInvoicePlan(result.data.departCode,result.data.depart,result.data.invoicePlanId); + showResult(result.data.depart + "的发货单"); + }else{ + showResult(result.message); + } + } + }, + failure : function(form, action) { + if(action.result && action.result.message){ + showResult(action.result.message); + } + } + }); +} Ext.onReady(function() { Ext.QuickTips.init(); @@ -235,5 +264,6 @@ items:grid }] }); - + globalOnKeyDown(openInvoicePlanByBarcode); + window.focus(); }); \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/config/gdsy/print/printConfig.js =================================================================== diff -u -r15286 -r15437 --- ssts-web/src/main/webapp/disinfectsystem/config/gdsy/print/printConfig.js (.../printConfig.js) (revision 15286) +++ ssts-web/src/main/webapp/disinfectsystem/config/gdsy/print/printConfig.js (.../printConfig.js) (revision 15437) @@ -196,7 +196,15 @@ {label : " 收物者:", dataIndex : ''}, {label : " 打印时间:", dataIndex : 'printTime'} ] - } + }, + barcodes : [ + {codeType : "128Auto", dataIndex : 'serialNumber', position : ["1mm","74%","40mm","8mm"], + styles : [{itemNameID: 0, styleName: 'ShowBarText', styleValue: true}, + {itemNameID: 0, styleName: 'FontSize', styleValue: 6}, + {itemNameID: 0, styleName: 'NotOnlyHighPrecision', styleValue: true} + ] + } + ] } //打印外部代理灭菌单 var foreignProxyDisinfectionApplicationPrintConfig = { Index: ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.jsp =================================================================== diff -u -r15144 -r15437 --- ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.jsp (.../invoicePlanExtractedView.jsp) (revision 15144) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.jsp (.../invoicePlanExtractedView.jsp) (revision 15437) @@ -53,6 +53,8 @@ + + Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/InvoicePlanAction.java =================================================================== diff -u -r14828 -r15437 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/InvoicePlanAction.java (.../InvoicePlanAction.java) (revision 14828) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/InvoicePlanAction.java (.../InvoicePlanAction.java) (revision 15437) @@ -389,16 +389,9 @@ e1.printStackTrace(); } - Collection> vos = invoicePlanManager + JSONArray jsonArray = invoicePlanManager .getInvoicePlansByOrgAndTousseType(Arrays.asList(departCodes),applyDate ,tousseType); - JSONArray jsonArray = JSONArray.fromObject(vos); - try { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - response.getWriter().println(jsonArray.toString()); - } catch (IOException e) { - e.printStackTrace(); - } + StrutsResponseUtils.output(jsonArray); } /** @@ -575,4 +568,14 @@ } } + public void getScanResult(){ + String barcode = StrutsParamUtils.getPraramValue("barcode", null); + try{ + JSONObject json = invoicePlanManager.invoicePlanListScanBarcode(barcode); + StrutsResponseUtils.output(json); + }catch(Exception ex){ + StrutsResponseUtils.output(false, ex.getMessage()); + } + } + } Index: ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedForm.js =================================================================== diff -u -r15405 -r15437 --- ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedForm.js (.../invoicePlanExtractedForm.js) (revision 15405) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedForm.js (.../invoicePlanExtractedForm.js) (revision 15437) @@ -364,6 +364,11 @@ top.Ext.getCmp('scanTextEnd').focus();//否则不清除,条码/篮筐(尾)获得焦点 } } + if(barcodeEnd != ''){ + top.Ext.getCmp('scanText').setValue("");//尾条码输入完成,所有条码都取消,要输入确认取消条码了 + top.Ext.getCmp('scanTextEnd').setValue("");//清除尾条码,以输入确认取消条码 + top.Ext.getCmp('scanText').focus();//否则不清除,条码/篮筐(尾)获得焦点 + } } function getApplicationGoodsByName(goodsName){ var record = findRecordByNameAndValueFromStore(recyclingapplicationStore,"name",goodsName); @@ -649,8 +654,9 @@ * 发货单窗口 * @param orgUnitCoding 科室编码 * @param depart 科室名称 + * @param invoicePlanId 发货计划id */ -function addAndEditInvoicePlan(orgUnitCoding,depart) { +function addAndEditInvoicePlan(orgUnitCoding,depart,invoicePlanId) { lastLoadWarehouseId = null; defaultFocusedFieldOnInvoiceForm = getStrValueFromJs('sstsConfig.defaultFocusedFieldOnInvoiceForm',defaultFocusedFieldOnInvoiceForm); // 发货物品 @@ -694,7 +700,35 @@ {name : 'invoicePlanType'} ] }); - + //科室申请单的store + var departApplicationStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoicePlanAction!getInvoicePlansByOrgAndTousseType.do?departCode=' + + orgUnitCoding + '&applyDate=' + + selectedApplyDate + '&tousseType=' + + encodeURI(selectedTousseType), + method : 'POST' + }), + reader : new Ext.data.JsonReader({fields : [{name : 'id'},{name : 'typeAndserialNumber'}]}), + listeners: { + load: function(thiz,records,options){ + if(records.length > 0 && invoicePlanId){ + var index; + for(var index = 0; index < records.length;++index){ + if(records[index].data.id == invoicePlanId){ + break; + } + } + if(index < records.length){ + var combo = top.Ext.getCmp('invoicePlanId'); + combo.setValue(records[index].data.id); + combo.fireEvent('select', combo,records[index],index); + } + } + } + } + }); + //申请物品 recyclingapplicationStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ @@ -788,7 +822,52 @@ }, dataIndex:'button' }]); - + function doSaveAction(){ + if (!form.getForm().isValid()) { + showResult('请正确填写表单各值'); + return false; + } + //验证发货物品表格 + if(!sendOutGoodsStore || sendOutGoodsStore.getCount() == 0){ + showResult('发货物品不能为空!'); + return false; + } + /*var b = validTousseGridData(); + if(!b){ + return false; + }*/ + var bool = validGridAmount(); + if(!bool){ + return false; + } + + getTousseGridData(); + form.form.submit( { + //url : WWWROOT + '/disinfectSystem/invoiceAction!saveDepartInvoice.do', + url : WWWROOT + '/disinfectSystem/invoiceAction!saveInvoiceByDepartOrInvoicePlanId.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + // 一定要事务提交成功才返回发货计划列表界面 + showResult(action.result.message); + if(action.result.success){ + window.close(); + grid.getStore().reload(); + } + }, + failure : function(form, action) { + if(!isUndefinedOrNullOrEmpty(action.result) && !isUndefinedOrNullOrEmpty(action.result.message)){ + showResult(action.result.message); + }else{ + showResult("发货超时,请稍后查看发货单以确定发货是否成功,避免重复发货!"); + window.close(); + grid.getStore().reload(); + } + } + }); + } + var barcodeBtn = new BarcodeBtn(function(){doSaveAction();},function(){window.close();}); var form = new top.Ext.FormPanel({ id : 'recyclingApplicationForm', frame : true, @@ -841,7 +920,7 @@ value:selectedTousseType },{ xtype :'hidden', - name : 'invoicePlanId', + name : 'invoicePlanIdHidden', id : 'invoicePlanIdHidden', value:selectedInvoicePlanId },{ @@ -972,6 +1051,7 @@ } top.Ext.getCmp('personInCharge').setValue(result.fullName); top.Ext.getCmp('personInChargeCode').setValue(result.name); + top.Ext.getCmp('scanText').focus(); }else{ showResult('找不到该条码所对应的人员信息'); } @@ -1129,7 +1209,9 @@ c.getEl().on('keypress',function(e) { if (e.getKey() == 13) {// 输入;号键,grid重新加载 if(top.Ext.getCmp("scanText").getValue() != ''){ - loadGoodsByBarcode(orgUnitCoding); + if(!barcodeBtn.processBarcode(top.Ext.getCmp("scanText").getValue())){ + loadGoodsByBarcode(orgUnitCoding); + } }else{ showResult("请扫描输入器械包/篮筐(首)条码!"); } @@ -1155,7 +1237,9 @@ c.getEl().on('keypress',function(e) { if (e.getKey() == 13) {// 输入;号键,grid重新加载 if(top.Ext.getCmp("scanTextEnd").getValue() != ''){ - loadGoodsByBarcode(orgUnitCoding); + if(!barcodeBtn.processBarcode(top.Ext.getCmp("scanTextEnd").getValue())){ + loadGoodsByBarcode(orgUnitCoding); + } }else{ showResult("请扫描输入器械包/篮筐(尾)条码!"); } @@ -1228,13 +1312,7 @@ displayField : 'typeAndserialNumber', allowBlank : true, editable : false, - store : new Ext.data.SimpleStore({ - fields : ['id', 'typeAndserialNumber' ], - url : WWWROOT + '/disinfectSystem/invoicePlanAction!getInvoicePlansByOrgAndTousseType.do?departCode=' + - orgUnitCoding + '&applyDate=' + - selectedApplyDate + '&tousseType=' + - encodeURI(selectedTousseType) - }), + store : departApplicationStore, forceSelection : true, triggerAction : 'all', listeners : { @@ -1287,51 +1365,7 @@ buttons : [{ text : '保存', id:'saveButton', - handler : function() { - if (!form.getForm().isValid()) { - showResult('请正确填写表单各值'); - return false; - } - //验证发货物品表格 - if(!sendOutGoodsStore || sendOutGoodsStore.getCount() == 0){ - showResult('发货物品不能为空!'); - return false; - } - /*var b = validTousseGridData(); - if(!b){ - return false; - }*/ - var bool = validGridAmount(); - if(!bool){ - return false; - } - - getTousseGridData(); - form.form.submit( { - //url : WWWROOT + '/disinfectSystem/invoiceAction!saveDepartInvoice.do', - url : WWWROOT + '/disinfectSystem/invoiceAction!saveInvoiceByDepartOrInvoicePlanId.do', - method : 'POST', - waitMsg : '正在保存数据,请稍候', - waitTitle : '提交表单', - success : function(form, action) { - // 一定要事务提交成功才返回发货计划列表界面 - showResult(action.result.message); - if(action.result.success){ - window.close(); - grid.getStore().reload(); - } - }, - failure : function(form, action) { - if(!isUndefinedOrNullOrEmpty(action.result) && !isUndefinedOrNullOrEmpty(action.result.message)){ - showResult(action.result.message); - }else{ - showResult("发货超时,请稍后查看发货单以确定发货是否成功,避免重复发货!"); - window.close(); - grid.getStore().reload(); - } - } - }); - } + handler : function(){doSaveAction();} }, { text : '取消', handler : function() { @@ -1373,6 +1407,7 @@ window.on('close',function(w){ //切记注意:按取消关闭window后,一定要把已选择的申请单号变量清空 selectedInvoicePlanId = ""; + top.getCurrentTab().focus(); }); window.show(); @@ -1391,6 +1426,7 @@ buffer : 250 }); wareHouseStore.load(); + departApplicationStore.load(); } //展示器械包信息 Index: ssts-web/src/main/webapp/js/barcodeBtn.js =================================================================== diff -u --- ssts-web/src/main/webapp/js/barcodeBtn.js (revision 0) +++ ssts-web/src/main/webapp/js/barcodeBtn.js (revision 15437) @@ -0,0 +1,26 @@ +/** + * 条码按钮。通过扫描条码实现按钮点击功能。 + * @param okcallback 确定条码的处理函数 + * @param cancelcallback 取消条码的处理函数 + */ +function BarcodeBtn(okcallback,cancelcallback){ + var saveBarcode = '999999999'; + var cancelBarcode = '888888888'; + /** + * 处理条码。如果是保存或者退出的条码,则返回true,否则返回false + */ + this.processBarcode = function(barcode){ + if(barcode == saveBarcode){ + if(okcallback){ + okcallback(); + } + return true; + }else if(barcode == cancelBarcode){ + if(cancelcallback){ + cancelcallback(); + } + return true; + } + return false; + } +} \ No newline at end of file Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r15425 -r15437 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 15425) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 15437) @@ -15,6 +15,11 @@ import java.util.Set; import java.util.stream.Collectors; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import net.sf.json.util.JSONBuilder; +import net.sf.json.util.JSONStringer; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.PredicateUtils; @@ -34,6 +39,8 @@ import com.forgon.Constants; import com.forgon.databaseadapter.service.DateQueryAdapter; import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.directory.model.OrgUnit; +import com.forgon.directory.service.OrgUnitManager; import com.forgon.directory.vo.LoginUserData; import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; import com.forgon.disinfectsystem.common.CssdUtils; @@ -72,6 +79,7 @@ import com.forgon.tools.SqlBuilder; import com.forgon.tools.date.DateTools; import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.json.JSONUtil; import com.forgon.tools.string.StringTools; import com.forgon.tools.util.SqlUtils; @@ -100,9 +108,15 @@ private HttpOptionManager httpOptionManager; + private OrgUnitManager orgUnitManager; + private static final String FOREIGNTOUSSE_APP_AWAITRECEIVE = "(待接收)外来器械包申请单"; private static final String FOREIGNTOUSSE_APP_AWAITRECYCLE = "(待回收)外来器械包申请单"; + public void setOrgUnitManager(OrgUnitManager orgUnitManager) { + this.orgUnitManager = orgUnitManager; + } + public void setHttpOptionManager(HttpOptionManager httpOptionManager) { this.httpOptionManager = httpOptionManager; } @@ -214,25 +228,25 @@ * @return Collection> 里面的List集合由两位元素组成,发货单的id用申请单序列号+类型 */ @Override - public Collection> getInvoicePlansByOrgAndTousseType( + public JSONArray getInvoicePlansByOrgAndTousseType( Collection departCodes, String applyDate, String tousseType) { //查询发货计划 Collection invoicePlans = getInvoicePlanListByOrgUnitCodingsAndTousseType( departCodes, applyDate, tousseType); - Collection> invoicePlansList = new ArrayList>(); - List invoicePlanTempList = new ArrayList(); - invoicePlanTempList.add(""); - invoicePlanTempList.add("全部"); - invoicePlansList.add(invoicePlanTempList); + JSONArray invoicePlanArray = new JSONArray(); + JSONObject invoicePlanTemp = new JSONObject(); + invoicePlanTemp.put("id",""); + invoicePlanTemp.put("typeAndserialNumber","全部"); + invoicePlanArray.add(invoicePlanTemp); if(CollectionUtils.isNotEmpty(invoicePlans)){ for(InvoicePlan invoicePlan : invoicePlans){ - invoicePlanTempList = new ArrayList(); - invoicePlanTempList.add(String.valueOf(invoicePlan.getId())); - invoicePlanTempList.add(invoicePlan.getSerialNumber() + " " + invoicePlan.getType()); - invoicePlansList.add(invoicePlanTempList); + invoicePlanTemp = new JSONObject(); + invoicePlanTemp.put("id",String.valueOf(invoicePlan.getId())); + invoicePlanTemp.put("typeAndserialNumber",invoicePlan.getSerialNumber() + " " + invoicePlan.getType()); + invoicePlanArray.add(invoicePlanTemp); } } - return invoicePlansList; + return invoicePlanArray; } @Override @@ -1765,4 +1779,45 @@ invoicePlan.setPrinted(printStatus); } + @Override + public JSONObject invoicePlanListScanBarcode(String barcode) { + if (StringUtils.isBlank(barcode)) { + throw new RuntimeException("缺失参数barcode"); + } + OrgUnit orgUnit = orgUnitManager.getOrgUnitByBarcode(barcode); + if (orgUnit != null) { + int invoicePlanAmount = getInvoicePlanByOrgUnitCodings( + Collections.singleton(orgUnit.getOrgUnitCoding()), + TimeQuantum.All).size(); + if (invoicePlanAmount <= 0) { + throw new RuntimeException("该科室没有申请物品"); + } + + JSONObject orgUnitJSONObject = new JSONObject(); + orgUnitJSONObject.put("depart", orgUnit.getName()); + orgUnitJSONObject.put("departCode", orgUnit.getOrgUnitCoding()); + + JSONObject json = JSONUtil.buildJsonObject(true); + JSONUtil.addProperty(json, "barcode", barcode); + JSONUtil.addProperty(json, "type", "orgUnit"); + JSONUtil.addProperty(json, "data", orgUnitJSONObject); + return json; + } else { + InvoicePlan invoicePlan = (InvoicePlan) objectDao.getByProperty( + InvoicePlan.class.getSimpleName(), "serialNumber", barcode); + if (invoicePlan == null) + throw new RuntimeException("请扫描科室条码或申请单条码"); + + JSONObject orgUnitJSONObject = new JSONObject(); + orgUnitJSONObject.put("depart", invoicePlan.getDepart()); + orgUnitJSONObject.put("departCode", invoicePlan.getDepartCoding()); + orgUnitJSONObject.put("invoicePlanId", invoicePlan.getId()); + + JSONObject json = JSONUtil.buildJsonObject(true); + JSONUtil.addProperty(json, "barcode", barcode); + JSONUtil.addProperty(json, "type", "invoicePlan"); + JSONUtil.addProperty(json, "data", orgUnitJSONObject); + return json; + } + } }