Index: ssts-web/src/main/webapp/debug/speech/speechDebug.js =================================================================== diff -u -r22554 -r22567 --- ssts-web/src/main/webapp/debug/speech/speechDebug.js (.../speechDebug.js) (revision 22554) +++ ssts-web/src/main/webapp/debug/speech/speechDebug.js (.../speechDebug.js) (revision 22567) @@ -501,11 +501,15 @@ printDiposableGoodsInfo(barcode,name,expDate,supplierName,batchNumber,printType,specification); } function startRecognize(){ + Ext.getCmp('textfield_speechRecognized').setValue('开始识别'); + return; if(DemoActiveX){ DemoActiveX.startRecord(); } } function stopRecognize(){ + Ext.getCmp('textfield_speechRecognized').setValue('停止识别'); + return; if(DemoActiveX){ DemoActiveX.stopRecord(); } @@ -516,13 +520,35 @@ var obj = DemoActiveX; if (obj) { alert(obj.SayHello()); + initGrammer(); } else { alert("Object is not created!"); } } catch (ex) { alert("Some error happens, error message is: " + ex.Description); } } +function initGrammer() { +// var testGrammer = '{"userInfo":{"nameList":["cyf","hyh","wxm"],"fullNameList":["陈月芳","何泳红","吴雪梅"]},"orgUnitInfo":{"nameList":["东川急诊","综合病区","妇科一区"]}}'; +// DemoActiveX.initGrammer(testGrammer); +// return; + Ext4.Ajax.request({ + dataType : "json", + async: false, +// params : {'names': ''}, + url: WWWROOT + "/system/speechAction!getSpeechData.do", + success: function(response) { + var speechData = Ext4.decode(response.responseText); + if(DemoActiveX){ + var testGrammer = response.responseText; + var testGrammer = Ext4.encode(speechData); +// var testGrammer = '{"userInfo":{"nameList":["cyf","hyh","wxm"],"fullNameList":["陈月芳","何泳红","吴雪梅"]},"orgUnitInfo":{"nameList":["东川急诊","综合病区","妇科一区"]}}'; +// DemoActiveX.initGrammer(response.responseText); + DemoActiveX.initGrammer(testGrammer); + } + } + }); +} Ext.onReady(function() { Ext.QuickTips.init(); Ext.apply(Ext.QuickTips.getQuickTip(), { @@ -535,7 +561,7 @@ dismissDelay : 0 }); var rowHeight = 40; - var form = new top.Ext.Panel({ + var form = new Ext.Panel({ title : '语音识别调试', labelAlign : 'right', buttonAlign : 'center', @@ -563,7 +589,7 @@ layout : 'form', labelWidth :60, items : [ { - id : '识别结果', + id : 'textfield_speechRecognized', xtype : 'textfield', fieldLabel :'识别结果', text : '', @@ -573,10 +599,11 @@ },{ height : rowHeight, layout : 'form', - labelWidth :60, + labelWidth :300, items : [ { id : 'SpeechRecognitionRejected', - xtype : 'textareafield', +// xtype : 'textareafield', + xtype : 'textfield', fieldLabel :'SpeechRecognitionRejected', text : '', cls : 'css_printBtns', @@ -946,4 +973,6 @@ items : [form] } ] }); + + initSpeech(); }); \ No newline at end of file Index: ssts-web/src/main/webapp/debug/speech/speechDebug.jsp =================================================================== diff -u -r22554 -r22567 --- ssts-web/src/main/webapp/debug/speech/speechDebug.jsp (.../speechDebug.jsp) (revision 22554) +++ ssts-web/src/main/webapp/debug/speech/speechDebug.jsp (.../speechDebug.jsp) (revision 22567) @@ -33,19 +33,23 @@ - + Index: ssts-web/src/main/java/com/forgon/disinfectsystem/speech/action/SpeechAction.java =================================================================== diff -u --- ssts-web/src/main/java/com/forgon/disinfectsystem/speech/action/SpeechAction.java (revision 0) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/speech/action/SpeechAction.java (revision 22567) @@ -0,0 +1,120 @@ +package com.forgon.disinfectsystem.speech.action; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.commons.lang3.StringUtils; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import com.forgon.databaseadapter.service.DateQueryAdapter; +import com.forgon.directory.model.OrgUnit; +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; +import com.forgon.disinfectsystem.recyclingapplication.service.InvoicePlanManager; +import com.forgon.security.model.User; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.hibernate.ObjectDao; + + +/** + * @author Jeff Li 2018年2月27日 下午2:07:45 + * + */ +@ParentPackage(value = "default") +@Namespace(value = "/system") +@Action(value = "speechAction") +public class SpeechAction { + + private SupplyRoomConfigManager supplyRoomConfigManager; + + private DateQueryAdapter dateQueryAdapter;; + + private ObjectDao objectDao; + + private InvoicePlanManager invoicePlanManager; + + public void setInvoicePlanManager(InvoicePlanManager invoicePlanManager) { + this.invoicePlanManager = invoicePlanManager; + } + + public void setSupplyRoomConfigManager( + SupplyRoomConfigManager supplyRoomConfigManager) { + this.supplyRoomConfigManager = supplyRoomConfigManager; + } + + public void setDateQueryAdapter(DateQueryAdapter dateQueryAdapter) { + this.dateQueryAdapter = dateQueryAdapter; + } + + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } + + public void getSpeechData() { + JSONObject obj = new JSONObject(); + { + // 人員 + JSONObject userInfo = new JSONObject(); + Set nameSet = new HashSet(); + Set fullNameSet = new HashSet(); + String sql = String.format(" select distinct po from %s po inner join fetch po.userAttribute ", User.class.getSimpleName()); +// List allUser = objectDao.findAllObjects(User.class.getSimpleName()); + List allUser = objectDao.findByHql(sql); + if(allUser != null){ + for (User user : allUser) { + String name = user.getName(); + String fullName = user.getFullName(); + if(StringUtils.isNotBlank(name)){ + nameSet.add(name); + } + if(StringUtils.isNotBlank(fullName)){ + fullNameSet.add(fullName); + } + } + } + // test + nameSet.clear(); + nameSet.add("cyf"); + nameSet.add("hyh"); + nameSet.add("wxm"); + fullNameSet.clear(); + fullNameSet.add("陈月芳"); + fullNameSet.add("何泳红"); + fullNameSet.add("吴雪梅"); + //test + JSONArray nameJSONArray = JSONArray.fromObject(nameSet); + JSONArray fullNameJSONArray = JSONArray.fromObject(fullNameSet); + userInfo.put("nameList", nameJSONArray); + userInfo.put("fullNameList", fullNameJSONArray); + + obj.put("userInfo", userInfo); + } + { + // 科室 + JSONObject orgUnitInfo = new JSONObject(); + Set nameSet = new HashSet(); + List allOrgUnit = objectDao.findAllObjects(OrgUnit.class.getSimpleName()); + if(allOrgUnit != null){ + for (OrgUnit orgUnit : allOrgUnit) { + String name = orgUnit.getName(); + if(StringUtils.isNotBlank(name)){ + nameSet.add(name); + } + } + } + JSONArray nameJSONArray = JSONArray.fromObject(nameSet); + orgUnitInfo.put("nameList", nameJSONArray); + + obj.put("orgUnitInfo", orgUnitInfo); + } + + // 包名 + StrutsResponseUtils.output(obj); + } + +}