浏览代码

语音生成接口地址放入配置文件

WANGJIALIANG 3 年之前
父节点
当前提交
c035dd4e64

+ 41 - 2
src/main/java/cn/hnthyy/thmz/controller/mz/MzPharmacyController.java

@@ -4,16 +4,16 @@ import cn.hnthyy.thmz.Utils.DateUtil;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.MzException;
-import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
 import cn.hnthyy.thmz.entity.his.mz.*;
+import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
 import cn.hnthyy.thmz.entity.thmz.DispensingWindows;
 import cn.hnthyy.thmz.entity.thmz.RadSendRecord;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.enums.ConfirmFlagEnum;
+import cn.hnthyy.thmz.service.his.mz.*;
 import cn.hnthyy.thmz.service.his.yp.YpZdDictService;
 import cn.hnthyy.thmz.service.his.yp.YpZdManufactoryService;
-import cn.hnthyy.thmz.service.his.mz.*;
 import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.thmz.DispensingSocketService;
 import cn.hnthyy.thmz.service.thmz.DispensingWindowsService;
@@ -21,6 +21,7 @@ import cn.hnthyy.thmz.vo.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
+import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -894,6 +895,44 @@ public class MzPharmacyController {
         }
     }
 
+    /**
+     * 叫号语音生成
+     *
+     * @param name
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/callNumberAudio", method = {RequestMethod.GET})
+    public Map<String, Object> callNumberAudio(@RequestParam("name") String name,@RequestParam("winNo") String winNo) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (name == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "叫号语音生成失败,病人姓名为空");
+                return resultMap;
+            }
+            String res = mzPharmacyService.callNumberAudio("请"+name+"到"+winNo+"号窗口取药");
+            JSONObject resObj=new JSONObject(res);
+            Integer code = (Integer)resObj.get("code");
+            if(code != 200){
+                log.error("叫号语音生成失败,接口错误信息:{}", resObj.get("message").toString());
+                resultMap.put("code", -1);
+                resultMap.put("message", "叫号语音生成失败");
+                return resultMap;
+            }
+            resultMap.put("code", 0);
+            resultMap.put("data", resObj.get("data").toString());
+            resultMap.put("message", "叫号语音生成成功");
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("叫号语音生成失败,错误信息{}", e.getMessage());
+            resultMap.put("code", -1);
+            resultMap.put("message", "叫号语音生成失败");
+            return resultMap;
+        }
+    }
+
     @UserLoginToken
     @RequestMapping(value = "/getRadSendRecord", method = {RequestMethod.POST})
     public Map<String, Object> getRadSendRecord(@RequestBody RadSendRecord radSendRecord) {

+ 7 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/MzPharmacyService.java

@@ -162,4 +162,11 @@ public interface MzPharmacyService {
      * @return
      */
     int sendMedicineProcessingRad(User user);
+
+    /**
+     * 语音生成
+     * @param text
+     * @return
+     */
+    String callNumberAudio(String text);
 }

+ 23 - 5
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzPharmacyServiceImpl.java

@@ -1,28 +1,31 @@
 package cn.hnthyy.thmz.service.impl.his.mz;
 
 import cn.hnthyy.thmz.Utils.DateUtil;
+import cn.hnthyy.thmz.Utils.HttpUtil;
 import cn.hnthyy.thmz.entity.MzException;
-import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
-import cn.hnthyy.thmz.entity.his.yp.YpMzFytj;
 import cn.hnthyy.thmz.entity.his.mz.Employee;
 import cn.hnthyy.thmz.entity.his.mz.MzChargeDetail;
+import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
+import cn.hnthyy.thmz.entity.his.yp.YpMzFytj;
 import cn.hnthyy.thmz.entity.thmz.RadSendRecord;
 import cn.hnthyy.thmz.entity.thmz.User;
-import cn.hnthyy.thmz.mapper.his.yp.YpBaseYfMapper;
-import cn.hnthyy.thmz.mapper.his.yp.YpZdManufactoryMapper;
 import cn.hnthyy.thmz.mapper.his.mz.EmployeeMapper;
 import cn.hnthyy.thmz.mapper.his.mz.MzPharmacyMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpBaseYfMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpZdManufactoryMapper;
 import cn.hnthyy.thmz.service.his.mz.MzPharmacyService;
 import cn.hnthyy.thmz.vo.*;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
-
+@Slf4j
 @Service
 public class MzPharmacyServiceImpl implements MzPharmacyService {
     @SuppressWarnings("all")
@@ -37,6 +40,9 @@ public class MzPharmacyServiceImpl implements MzPharmacyService {
     @SuppressWarnings("all")
     @Autowired
     private YpBaseYfMapper ypBaseYfMapper;
+    //语音生成接口地址
+    @Value("${audioServiceUrl}")
+    private String audioServiceUrl;
 
     @Override
     public List<MzChargeDetail> getMzChargeOrder(ChargeDetailPharmacyVo chargeDetailPharmacyVo) {
@@ -275,4 +281,16 @@ public class MzPharmacyServiceImpl implements MzPharmacyService {
         }
         return number;
     }
+
+    @Override
+    public String callNumberAudio(String text) {
+        String res="";
+        try {
+            res = HttpUtil.sendHttpGet(audioServiceUrl+"?text="+text, "utf-8");
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.info("语音生成失败,内容:{}", text);
+        }
+        return res;
+    }
 }

+ 4 - 1
src/main/resources/application-dev.yml

@@ -130,4 +130,7 @@ lxbdcwjUrl: "http://192.168.3.20:8081/assessments/covid/"
 callBackYJYYUrl: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbde6b16acad84204&redirect_uri=http://172.16.30.26:8805/wxserver/redirect/page2?to=resignOrRefund_"
 
 #叫号通知接口地址
-notifyServiceUrl: "http://172.16.30.26:8706/triage/notify"
+notifyServiceUrl: "http://172.16.30.26:8706/triage/notify"
+
+#语音生成接口地址
+audioServiceUrl: "http://172.16.30.26:8706/voice/textToSpeech"

+ 3 - 0
src/main/resources/application-prod.yml

@@ -127,3 +127,6 @@ callBackYJYYUrl: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbd
 
 #叫号通知接口地址
 notifyServiceUrl: "http://webhis.thyy.cn:8706/triage/notify"
+
+#语音生成接口地址
+audioServiceUrl: "http://webhis.thyy.cn:8706/voice/textToSpeech"

+ 3 - 3
src/main/resources/static/js/common/socket-com.js

@@ -132,12 +132,12 @@ function call(data) {
     //生成语音
     $.ajax({
         type: "GET",
-        url: 'http://webhis.thyy.cn:8706/voice/textToSpeech?text='+"请"+data.name+"到四号窗口取药",
+        url: '/thmz/callNumberAudio?name='+data.name+'&winNo='+winNo,
         contentType: "application/json;charset=UTF-8",
         dataType: "json",
         headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
         success: function (res) {
-            if (res.code == 200) {
+            if (res.code == 0) {
                 //播放后台生成的叫号语音
                 var mp3 = new Audio(res.data);
                 mp3.play();
@@ -145,4 +145,4 @@ function call(data) {
             }
         }
     });
-}
+}

+ 3 - 1
src/main/resources/static/js/mz/pharmacy-cell-number.js

@@ -16,6 +16,8 @@ var tempDispenseList = new Array();*/
 var fullscreen = false;//浏览器全屏状态
 //药房编号
 var groupNo = null;
+//窗口号
+var winNo = null;
 var timeInterval;
 var tableInterval;
 var getTableDateInterval;
@@ -150,7 +152,7 @@ function intClock() {
  * 实例化列表
  */
 function initTable() {
-    var winNo = $("#winNo").val();
+    winNo = $("#winNo").val();
     groupNo = $("#fyClass").val();
     if (groupNo == null || groupNo == "") {
         errorMesageSimaple("未选择药房!");