|
@@ -1,5 +1,6 @@
|
|
|
package cn.hnthyy.thmz.service.impl.thmz;
|
|
|
|
|
|
+import cn.hnthyy.thmz.Utils.HttpUtil;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzChargeDetail;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzPatientMi;
|
|
|
import cn.hnthyy.thmz.enums.SocketSenderTypeEnum;
|
|
@@ -7,7 +8,9 @@ import cn.hnthyy.thmz.service.his.mz.MzChargeDetailService;
|
|
|
import cn.hnthyy.thmz.service.his.mz.MzPatientMiService;
|
|
|
import cn.hnthyy.thmz.service.thmz.DispensingSocketService;
|
|
|
import cn.hnthyy.thmz.socket.PrescriptionPrintSocket;
|
|
|
+import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
@@ -21,7 +24,9 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
MzPatientMiService mzPatientMiService;
|
|
|
@Autowired
|
|
|
MzChargeDetailService mzChargeDetailService;
|
|
|
-
|
|
|
+ //websocket 发送信息接口地址
|
|
|
+ @Value("${webSocketServiceUrl}")
|
|
|
+ private String webSocketServiceUrl;
|
|
|
|
|
|
@Override
|
|
|
public int sendToMedicine(String patientId, String winNo) {
|
|
@@ -33,7 +38,7 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
msgMap.put("type",SocketSenderTypeEnum.SEND_MEDICINE.code);
|
|
|
List<String> objTypes = new ArrayList<>();
|
|
|
objTypes.add(SocketSenderTypeEnum.CALL_NUMBER.code);
|
|
|
- return prescriptionPrintSocket.sendMessage(msgMap,objTypes);
|
|
|
+ return sendMessage(msgMap,objTypes);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -46,7 +51,7 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
msgMap.put("type",SocketSenderTypeEnum.CALL_NUMBER.code);
|
|
|
List<String> objTypes = new ArrayList<>();
|
|
|
objTypes.add(SocketSenderTypeEnum.CALL_NUMBER.code);
|
|
|
- return prescriptionPrintSocket.sendMessage(msgMap,objTypes);
|
|
|
+ return sendMessage(msgMap,objTypes);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -59,7 +64,7 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
msgMap.put("type",SocketSenderTypeEnum.PRINT.code);
|
|
|
List<String> objTypes = new ArrayList<>();
|
|
|
objTypes.add(SocketSenderTypeEnum.CALL_NUMBER.code);
|
|
|
- return prescriptionPrintSocket.sendMessage(msgMap,objTypes);
|
|
|
+ return sendMessage(msgMap,objTypes);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -97,7 +102,7 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
objTypes.add(SocketSenderTypeEnum.CALL_NUMBER.code);
|
|
|
}
|
|
|
objTypes.add(SocketSenderTypeEnum.DISPENSING_MEDICINE.code);
|
|
|
- prescriptionPrintSocket.sendMessage(msgMap,objTypes);
|
|
|
+ sendMessage(msgMap,objTypes);
|
|
|
}
|
|
|
if(ycChargeDetail.size() > 0){
|
|
|
Set<Integer> orderNos = ycChargeDetail.stream().map(MzChargeDetail::getOrderNo).collect(Collectors.toSet());
|
|
@@ -105,7 +110,7 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
msgMap.put("groupNo",ycChargeDetail.get(0).getGroupNo());
|
|
|
List<String> objTypes = new ArrayList<>();
|
|
|
objTypes.add(SocketSenderTypeEnum.DISPENSING_MEDICINE.code);
|
|
|
- prescriptionPrintSocket.sendMessage(msgMap,objTypes);
|
|
|
+ sendMessage(msgMap,objTypes);
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
@@ -121,7 +126,7 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
List<String> objTypes = new ArrayList<>();
|
|
|
objTypes.add(SocketSenderTypeEnum.CALL_NUMBER.code);
|
|
|
objTypes.add(SocketSenderTypeEnum.SEND_MEDICINE.code);
|
|
|
- return prescriptionPrintSocket.sendMessage(msgMap,objTypes);
|
|
|
+ return sendMessage(msgMap,objTypes);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -132,6 +137,22 @@ public class DispensingSocketServiceImpl implements DispensingSocketService {
|
|
|
List<String> objTypes = new ArrayList<>();
|
|
|
objTypes.add(SocketSenderTypeEnum.CALL_NUMBER.code);
|
|
|
objTypes.add(SocketSenderTypeEnum.SEND_MEDICINE.code);
|
|
|
- return prescriptionPrintSocket.sendMessage(msgMap,objTypes);
|
|
|
+ return sendMessage(msgMap,objTypes);
|
|
|
}
|
|
|
+
|
|
|
+ public int sendMessage(Object msgObj, List<String> objTypes) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("msgMap", msgObj);
|
|
|
+ map.put("objTypes", objTypes);
|
|
|
+ //Map 转成 JSONObject 字符串
|
|
|
+ JSONObject jsonObj = new JSONObject(map);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = HttpUtil.sendHttpPost(webSocketServiceUrl, jsonObj.toString(), 6000,"utf-8");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Integer.parseInt(result);
|
|
|
+ }
|
|
|
+
|
|
|
}
|