Kaynağa Gözat

socket 提出,药库出库调整

WANGJIALIANG 2 yıl önce
ebeveyn
işleme
86b0fc0191

+ 21 - 0
src/main/java/cn/hnthyy/thmz/Utils/HttpUtil.java

@@ -91,6 +91,27 @@ public class HttpUtil {
         return responseContent;
     }
 
+    /**
+     * POST 请求
+     * @param url
+     * @param JSONBody
+     * @return
+     * @throws Exception
+     */
+    public static String sendHttpPost(String url, String JSONBody,Integer timeOut,String charset) throws Exception {
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost(url);
+        httpPost.addHeader("Content-Type", "application/json");
+        httpPost.setEntity(new StringEntity(JSONBody,charset));
+        httpPost.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, timeOut);
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        HttpEntity entity = response.getEntity();
+        String responseContent = EntityUtils.toString(entity, "UTF-8");
+        response.close();
+        httpClient.close();
+        return responseContent;
+    }
+
     /**
      * POST 请求 非JSON 数据
      * @param url

+ 15 - 1
src/main/java/cn/hnthyy/thmz/controller/CommonController.java

@@ -1,7 +1,6 @@
 package cn.hnthyy.thmz.controller;
 
 import cn.hnthyy.thmz.comment.UserLoginToken;
-import cn.hnthyy.thmz.entity.his.zd.ZdIcdCode;
 import cn.hnthyy.thmz.enums.*;
 import cn.hnthyy.thmz.service.his.mz.*;
 import cn.hnthyy.thmz.service.his.zd.*;
@@ -49,6 +48,9 @@ public class CommonController {
     //websocket 地址前半部分
     @Value("${webSocketHost}")
     private String webSocketHost;
+    //websocket 药房地址前半部分
+    @Value("${webSocketPrescriptionHost}")
+    private String webSocketPrescriptionHost;
 
     //门诊结算单地址
     @Value("${mzjsdHost}")
@@ -838,6 +840,18 @@ public class CommonController {
         return resultMap;
     }
 
+    /**
+     * 获取webSocket地址 药房调用,不用鉴权
+     */
+    @RequestMapping(value = "/getWebSocketPrescriptionHost", method = {RequestMethod.GET})
+    public Map<String, Object> getWebSocketPrescriptionHost() {
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("code", 0);
+        resultMap.put("message", "查询webSocket地址成功");
+        resultMap.put("data", webSocketPrescriptionHost);
+        return resultMap;
+    }
+
 
     /**
      * 获取门诊结算单地址

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpInPlanMapper.java

@@ -160,6 +160,7 @@ public interface YpInPlanMapper {
     @Select({"<script>",
             "SELECT plan_date,plan_seri,charge_code,serial,group_no,group_yk,amount,amount_out,drawer,status_flag,draw_no,confirm_id,confirm_date,input_id,sys_date FROM yp_in_plan WITH(NOLOCK) " +
                     "<where>" +
+                    "   draw_no = #{drawNo}" +
                     "   <if test=\"chargeCode != null and chargeCode != ''\">" +
                     "        AND charge_code = #{chargeCode}" +
                     "   </if>" +
@@ -167,7 +168,6 @@ public interface YpInPlanMapper {
                     "        AND serial = #{serial}" +
                     "   </if>" +
                     "   <if test=\"drawNo != null and drawNo != ''\">" +
-                    "        AND draw_no = #{drawNo}" +
                     "   </if>" +
                     "</where>" +
                     "</script>"})

+ 33 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpZdGroupNameMapper.java

@@ -53,6 +53,39 @@ public interface YpZdGroupNameMapper {
             "</script>"})
     List<YpZdGroupNameVo> selectYpZdGroupNamePage(YpZdGroupNamePageDto ypZdGroupNamePageDto);
 
+
+    /**
+     * 查询药房库字典列表
+     *
+     * @return
+     */
+    @Select({"<script>",
+            "SELECT group_no,dept_code,py_code,d_code wb_code,group_name,mz_flag,yf_flag " +
+                    "from yp_zd_group_name WITH(NOLOCK) where 1=1 " +
+                    "<when test='ypZdGroupName.groupNo!=null'>" +
+                    " and group_no =#{ypZdGroupName.groupNo}" +
+                    "</when>" +
+                    "<when test='ypZdGroupName.groupName!=null'>" +
+                    " and group_name =#{ypZdGroupName.groupName}" +
+                    "</when>" +
+                    "<when test='ypZdGroupName.deptCode!=null'>" +
+                    " and dept_code =#{ypZdGroupName.deptCode}" +
+                    "</when>" +
+                    "<when test='ypZdGroupName.pyCode!=null'>" +
+                    " and py_code =#{ypZdGroupName.pyCode}" +
+                    "</when>" +
+                    "<when test='ypZdGroupName.wbCode!=null'>" +
+                    " and d_code =#{ypZdGroupName.wbCode}" +
+                    "</when>" +
+                    "<when test='ypZdGroupName.mzFlag!=null'>" +
+                    " and mz_flag =#{ypZdGroupName.mzFlag}" +
+                    "</when>" +
+                    "<when test='ypZdGroupName.yfFlag!=null'>" +
+                    " and yf_flag =#{ypZdGroupName.yfFlag}" +
+                    "</when>" +
+            "</script>"})
+    List<YpZdGroupName> selectYpZdGroupNameList(@Param("ypZdGroupName") YpZdGroupName ypZdGroupName);
+
     /**
      * 查询药房库字典列表
      *

+ 25 - 15
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpOutDetlServiceImpl.java

@@ -106,16 +106,18 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
         }
         String drawNo = sdf.format(new Date()) + str + ykOutNo;
         int j = 1;
-        YpInPlan ypInPlan = new YpInPlan();
+
         Date now = new Date();
         for (int i = 0; i < list.size(); i++) {
             Map m = list.get(i);
             String chargeCode = m.get("chargeCode").toString();
+            String serial = m.get("serial").toString();
             if (!(i > 0 && chargeCode.equals(list.get(i - 1).get("chargeCode").toString())
                     && StringUtils.isBlank(m.get("drawNo").toString())) && StringUtils.isNotBlank(m.get("drawNo").toString())) {
+                YpInPlan ypInPlan = new YpInPlan();
                 ypInPlan.setStatusFlag("2");
                 ypInPlan.setChargeCode(chargeCode);
-                ypInPlan.setSerial((String) m.get("serial"));
+                ypInPlan.setSerial(serial);
                 ypInPlan.setDrawNo(m.get("drawNo").toString());
                 ypInPlan.setAmountOut(Double.parseDouble(nmap.get(ypInPlan.getChargeCode()).toString()));
                 int num = ypInPlanMapper.updateYpInPlan(ypInPlan);
@@ -131,19 +133,29 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
                 ypOutDetl.setInSeri(Integer.parseInt(m.get("inSeri").toString()));
                 ypOutDetl.setManuNo((String) m.get("manuNo"));
                 ypOutDetl.setDrawNo(drawNo);
-                YpInPlan inPlan = new YpInPlan();
-                inPlan.setChargeCode((String) m.get("chargeCode"));
-                inPlan.setSerial((String) m.get("serial"));
-                inPlan.setDrawNo(m.get("drawNo").toString());
-                YpInPlanDrugVo ypInPlanDrugVo = ypInPlanMapper.selectYpInPlanDrug(inPlan).get(0);
-                ypOutDetl.setDrawYf(m.get("drawNo").toString());
+                if(StringUtils.isNotBlank(m.get("drawNo").toString())){
+                    YpInPlan inPlan = new YpInPlan();
+                    inPlan.setChargeCode((String) m.get("chargeCode"));
+                    inPlan.setSerial((String) m.get("serial"));
+                    inPlan.setDrawNo(m.get("drawNo").toString());
+                    YpInPlanDrugVo ypInPlanDrugVo = ypInPlanMapper.selectYpInPlanDrug(inPlan).get(0);
+                    ypOutDetl.setDrawer(ypInPlanDrugVo.getDrawer());
+                    ypOutDetl.setGroupNo(ypInPlanDrugVo.getGroupYk());
+                    ypOutDetl.setGroupNoOut(ypInPlanDrugVo.getGroupNo());
+                    ypOutDetl.setDrawYf(m.get("drawNo").toString());
+                }else{
+                    ypOutDetl.setGroupNo(map.get("outType").toString());
+                    YpZdGroupName ypZdGroupName = new YpZdGroupName();
+                    ypZdGroupName.setDeptCode(map.get("deptCode").toString());
+                    List<YpZdGroupName> ypZdGroupNames = ypZdGroupNameMapper.selectYpZdGroupNameList(ypZdGroupName);
+                    ypOutDetl.setGroupNoOut(ypZdGroupNames.size()>0?ypZdGroupNames.get(0).getGroupNo():null);
+                }
                 ypOutDetl.setDeptCode(map.get("deptCode").toString());
-                ypOutDetl.setChargeCode(ypInPlan.getChargeCode());
-                ypOutDetl.setSerial(ypInPlan.getSerial());
-                YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(ypInPlan.getChargeCode(), ypInPlan.getSerial());
+                ypOutDetl.setChargeCode(chargeCode);
+                ypOutDetl.setSerial(serial);
+                YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(chargeCode, serial);
                 ypOutDetl.setPackRetprice(ypZdDict.getPackRetprice());
                 ypOutDetl.setOutAmt(StringUtils.isBlank(m.get("amountOut").toString()) ? 0 : Double.parseDouble(m.get("amountOut").toString()));
-                ypOutDetl.setDrawer(ypInPlanDrugVo.getDrawer());
                 ypOutDetl.setKeeper(userId);
                 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                 try {
@@ -152,10 +164,8 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
                     throw new MzException("有效期转换异常!");
                 }
                 ypOutDetl.setOutType((String) map.get("outType"));
-                Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetl.getChargeCode(), ypOutDetl.getSerial(), ypInPlanDrugVo.getGroupYk());
+                Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetl.getChargeCode(), ypOutDetl.getSerial(), ypOutDetl.getGroupNo());
                 ypOutDetl.setStockAmount(Double.parseDouble(String.format("%.2f", stockAmount - ypOutDetl.getOutAmt())));
-                ypOutDetl.setGroupNo(ypInPlanDrugVo.getGroupYk());
-                ypOutDetl.setGroupNoOut(ypInPlanDrugVo.getGroupNo());
                 ypOutDetl.setBuyPrice(ypZdDict.getBuyPrice());
                 ypOutDetl.setInputId(userId);
                 ypOutDetl.setSysDate(now);

+ 29 - 8
src/main/java/cn/hnthyy/thmz/service/impl/thmz/DispensingSocketServiceImpl.java

@@ -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);
+    }
+
 }

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

@@ -152,4 +152,10 @@ soap_url: "http://172.16.32.178:622/pushservice.asmx?wsdl"
 webSocketHost: "ws://172.16.30.33:8089/thmz/"
 
 #门诊结算单地址
-mzjsdHost: http://172.16.30.26:3000
+mzjsdHost: http://172.16.30.26:3000
+
+#websocket 药房地址前半部分
+webSocketPrescriptionHost: "ws://172.16.30.22:9000/"
+
+#websocket 药房发送信息接口地址
+webSocketServiceUrl: "http://172.16.30.22:9000/api/v1/sendMessage"

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

@@ -150,3 +150,9 @@ soap_url: "http://172.16.32.178:622/pushservice.asmx?wsdl"
 webSocketHost: "ws://webhis.thyy.cn:81/thmz/"
 #门诊结算单地址
 mzjsdHost: http://webhis.thyy.cn:8080
+
+#websocket 药房地址前半部分
+webSocketPrescriptionHost: "ws://172.16.32.161:9000/"
+
+#websocket 药房发送信息接口地址
+webSocketServiceUrl: "http://172.16.32.161:9000/api/v1/sendMessage"

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

@@ -14,7 +14,7 @@ function openSocket(type) {
         if ('WebSocket' in window) {
             $.ajax({
                 type: "GET",
-                url: '/thmz/getWebSocketHost',
+                url: '/thmz/getWebSocketPrescriptionHost',
                 contentType: "application/json;charset=UTF-8",
                 dataType: "json",
                 headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},