liuqq 3 лет назад
Родитель
Сommit
4dd0419dd0

+ 5 - 0
src/main/java/com/diagbot/facade/his/FeedbackHosFacade.java

@@ -1,6 +1,7 @@
 package com.diagbot.facade.his;
 
 import com.diagbot.dto.RespDTO;
+import com.diagbot.util.PushFeedbackConn;
 import com.diagbot.vo.his.FeedbackHosVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -9,15 +10,19 @@ import org.springframework.stereotype.Component;
 @Slf4j
 public class FeedbackHosFacade {
 
+    PushFeedbackConn conn=new PushFeedbackConn();
 
     public RespDTO pushFeedback(FeedbackHosVO feedbackHosVO){
         try{
             if("1".equals(feedbackHosVO.getOperationType())){
                 //修改
+                conn.UpdateQcMessAge(feedbackHosVO);
             } else if("2".equals(feedbackHosVO.getOperationType())){
                 //his那边物理删除
+                conn.DeleteQcMessAge(feedbackHosVO);
             } else{
                 //其他情况新增
+                conn.setQcMessAge(feedbackHosVO);
             }
             return RespDTO.onSuc("推送缺陷反馈完成!");
         }catch (Exception e){

+ 236 - 0
src/main/java/com/diagbot/util/PushFeedbackConn.java

@@ -0,0 +1,236 @@
+package com.diagbot.util;
+
+import com.diagbot.vo.his.FeedbackHosVO;
+
+import java.sql.*;
+import java.util.ResourceBundle;
+
+public class PushFeedbackConn {
+    private static final String DRIVER = getValue("jdbc.driverClassName1");
+    private static final String URL = getValue("jdbc.url1");
+    private static final String USERNAME = getValue("jdbc.username1");
+    private static final String PASSWORD = getValue("jdbc.password1");
+
+    public static final Long HOSPITAL_ID=Long.valueOf("35");//1:长兴,2:邵逸夫,3:台州市立医院
+
+    private static Connection connection = null;
+    private static PreparedStatement sta = null;
+    private static ResultSet rs = null;
+
+    /**
+     * 读取属性文件中的信息
+     *
+     * @param key
+     * @return
+     */
+    private static String getValue(String key) {
+        // 资源包绑定
+        ResourceBundle bundle = ResourceBundle.getBundle("jdbc");
+        return bundle.getString(key);
+    }
+
+    /**
+     * 加载驱动程序
+     */
+    static {
+        try {
+            Class.forName(DRIVER);
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * @return 连接对象
+     */
+    public Connection getConnection() {
+        try {
+            connection = DriverManager.getConnection(URL,USERNAME,PASSWORD);
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return connection;
+    }
+
+    /**
+     * @param sql sql语句
+     * @param obj 参数
+     * @return 数据集合
+     */
+    public ResultSet Query(String sql,Object...obj){
+        connection=getConnection();
+        try {
+            sta=connection.prepareStatement(sql);
+            if(obj!=null){
+                for(int i=0;i<obj.length;i++){
+                    sta.setObject(i+1, obj[i]);
+                }
+            }
+            rs=sta.executeQuery();
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return rs;
+    }
+
+    /**
+     * 关闭资源
+     */
+    public void close() {
+        try {
+            if (rs != null) {
+                rs.close();
+            }
+        } catch (SQLException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (sta != null) {
+                    sta.close();
+                }
+            } catch (SQLException e2) {
+                e2.printStackTrace();
+            } finally {
+                if (connection != null) {
+                    try {
+                        connection.close();
+                    } catch (SQLException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 关闭数据库
+     * @param conn
+     */
+    public void closeConnection(Connection conn){
+        try{
+            if(conn != null){
+                conn.close();
+            }
+        }
+        catch(Exception e){
+            System.out.println("数据库关闭失败");
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 新赠评分插入表中
+     * @return
+     */
+    public Integer setQcMessAge(FeedbackHosVO feedbackHosVO) throws SQLException {
+        try {
+            String patientId=feedbackHosVO.getBehospitalCode().split("_")[0];
+            String visitId=feedbackHosVO.getBehospitalCode().split("_")[1];
+            int re=0;
+            connection = getConnection();
+            connection.setAutoCommit(false);//事物开始
+            PreparedStatement state=connection.prepareStatement("insert into MEDICAL_QC_MSG " +
+                    "(PATIENT_ID,VISIT_ID,DOCTOR_IN_CHARGE,QA_EVENT_TYPE,QC_MSG_CODE,MESSAGE,ISSUED_BY,ISSUED_DATE_TIME,TOPIC_ID,DEPT_STAYED,MSG_STATUS)"+
+                    "values(?,?,?,?,?,?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss'),?,?,?)");
+            state.setString(1, patientId);
+            state.setString(2, visitId);
+            state.setString(3,feedbackHosVO.getSenderName());
+            state.setString(4,feedbackHosVO.getModeName());
+            state.setInt(5,1511);
+            state.setString(6,feedbackHosVO.getQcresultDetailMsg());
+            state.setString(7,"评价质控");
+            state.setString(8, DateUtil.formatDateTime(DateUtil.now()));
+            state.setString(9,feedbackHosVO.getModeName());
+            state.setString(10,feedbackHosVO.getDeptId());
+            state.setInt(11,0);
+            re = state.executeUpdate();
+            if(re < 0){               //插入失败
+                connection.rollback();      //回滚
+                state.close();
+                closeConnection(connection);
+                return re;
+            }
+            connection.commit();            //插入正常
+            state.close();
+            closeConnection(connection);
+            return re;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }finally {
+            close();
+        }
+
+    }
+
+    /**
+     * 删除评分表中的对应数据
+     * @return
+     */
+    public Integer DeleteQcMessAge(FeedbackHosVO feedbackHosVO) throws SQLException {
+        try {
+            String patientId=feedbackHosVO.getBehospitalCode().split("_")[0];
+            String visitId=feedbackHosVO.getBehospitalCode().split("_")[1];
+            int re=0;
+            connection = getConnection();
+            connection.setAutoCommit(false);//事物开始
+            String sql ="delete from MEDICAL_QC_MSG  where  PATIENT_ID = '"+patientId+"' and VISIT_ID = '"
+                    +visitId+"' and MESSAGE = '"+feedbackHosVO.getExplainInfo()+"'";
+            PreparedStatement state=connection.prepareStatement(sql);
+            re = state.executeUpdate();
+            if(re < 0){               //删除失败
+                connection.rollback();      //回滚
+                state.close();
+                closeConnection(connection);
+                return re;
+            }
+            connection.commit();            //删除正常
+            state.close();
+            closeConnection(connection);
+            return re;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }finally {
+            close();
+        }
+
+    }
+
+    /**
+     * 修改评分表中对应数据
+     * @return
+     */
+    public Integer UpdateQcMessAge(FeedbackHosVO feedbackHosVO) throws SQLException {
+        try {
+            String patientId=feedbackHosVO.getBehospitalCode().split("_")[0];
+            String visitId=feedbackHosVO.getBehospitalCode().split("_")[1];
+            int re=0;
+            connection = getConnection();
+            connection.setAutoCommit(false);//事物开始
+            String sql =" update MEDICAL_QC_MSG set MESSAGE = '"+feedbackHosVO.getExplainInfo()+"' where PATIENT_ID = '"+patientId+"' and VISIT_ID = '"
+                    +visitId+"'" ;
+            PreparedStatement state=connection.prepareStatement(sql);
+            re = state.executeUpdate();
+            if(re < 0){               //修改失败
+                connection.rollback();      //回滚
+                state.close();
+                closeConnection(connection);
+                return re;
+            }
+            connection.commit();            //修改正常
+            state.close();
+            closeConnection(connection);
+            return re;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }finally {
+            close();
+        }
+
+    }
+
+}

+ 5 - 0
src/main/resources/jdbc.properties

@@ -14,6 +14,11 @@ jdbc.url=jdbc:sqlserver://192.168.100.39\\tzmhemr;DatabaseName=bigemr
 jdbc.username=zjlt
 jdbc.password=zjlt@2020
 
+jdbc.driverClassName1=oracle.jdbc.OracleDriver
+jdbc.url1=jdbc:oracle:thin:@132.147.254.5:1521/dbserver
+jdbc.username1=langtong
+jdbc.password1=langtong
+
 #\u6570\u636e\u670d\u52a1\u6a21\u5f0f
 remote.address.ver=http://192.18.101.207:2030/index.html
 remote.address.hor=http://192.18.101.207:2030/indexHorizontal.html