From 773f804a32d4e20e75f034b454750b3ffc1c42b4 Mon Sep 17 00:00:00 2001 From: gengxiaokai Date: Mon, 27 Aug 2018 21:56:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=A6=E7=9A=87=E5=B2=9B=E5=A4=A9=E8=8B=B1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lyms/hospitalapi/qhdfy/ConnTools.java | 24 +++++ .../com/lyms/hospitalapi/qhdfy/QhdTyInterface.java | 115 +++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdTyInterface.java diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/ConnTools.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/ConnTools.java index d0e16c9..48ad99b 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/ConnTools.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/ConnTools.java @@ -60,6 +60,13 @@ public class ConnTools { private static String jbgwPassword = "LYMS_QHD_JBGW"; + private static String tyDirverClassName = "oracle.jdbc.driver.OracleDriver"; + private static String tyUrl = "jdbc:oracle:thin:@13.14.12.82:1526:orcl"; + private static String tyUser = "dzhy"; + private static String tyPassword = "sjzDzhy975"; + + + public static Connection makeHisConnection() { Connection conn = null; try { @@ -138,6 +145,23 @@ public class ConnTools { + public static Connection makeQhdTyConnection() { + Connection conn = null; + try { + Class.forName(tyDirverClassName); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + try { + conn = DriverManager.getConnection(tyUrl, tyUser, tyPassword); + } catch (SQLException e) { + e.printStackTrace(); + } + return conn; + } + + + public static Connection makeClConnection() { Connection conn = null; if ("4".equals(HIS_VERSION)) diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdTyInterface.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdTyInterface.java new file mode 100644 index 0000000..455bb80 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdTyInterface.java @@ -0,0 +1,115 @@ +package com.lyms.hospitalapi.qhdfy; + +import com.lyms.platform.biz.service.BasicConfigService; +import com.lyms.platform.common.constants.ErrorCodeConstants; +import com.lyms.platform.common.result.BaseObjectResponse; +import com.lyms.platform.operate.web.utils.CommonsHelper; +import com.lyms.platform.pojo.Patients; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.sql.*; + +/** + * Created by Administrator on 2018/8/27. + */ +@Service("qhdTyInterface") +public class QhdTyInterface { + + @Autowired + private BasicConfigService basicConfigService; + + /** + * 基本信息 + * @param patient + * @return + */ + public BaseObjectResponse savePERSONS(Patients patient){ + BaseObjectResponse br = new BaseObjectResponse(); + Connection conn = ConnTools.makeQhdTyConnection(); + PreparedStatement ps = null; + ResultSet rs = null; + int result = 0; + if(patient != null){ + try{ + String selSql = "select count(*) from PERSONS where PK='"+patient.getId()+"'"; + ps = conn.prepareStatement(selSql); + rs = ps.executeQuery(); + while(rs.next()){ + result = rs.getInt(1); + } + if(result > 0){ + String delSql = "delete from PERSONS where PK='"+patient.getId()+"'"; + ps = conn.prepareStatement(delSql); + int delCount = ps.executeUpdate(); + if(delCount > 0){ + System.out.print("基本信息数据删除完毕,请重新插入数据!"); + } + } + //户籍地址 + String hjSheng = CommonsHelper.getName1(patient.getProvinceId(), basicConfigService); + String hjShi = CommonsHelper.getName1(patient.getCityId(), basicConfigService); + String hjXian = CommonsHelper.getName1(patient.getAreaId(), basicConfigService); + String hjXiang = CommonsHelper.getName1(patient.getStreetId(), basicConfigService); + String hQuan = hjSheng+hjShi+hjXian+hjXiang; + //插入数据 + String inSql = "insert into PERSONS(PK,XM,XB_DM,CSRQ,SFZJLB,SFZHM,MZ_DM,HKXZ_DM,HYZK_DM,DWXZ_DM,GZDW,HJDDZ,\n" + + "HJDDM,HYS,SYS,XYZNS,CREATEDATE,SOURCE,MODIFYDATE) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + ps = conn.prepareStatement(inSql); + ps.setString(1,patient.getId()); + ps.setString(2,patient.getUsername()); + ps.setString(3,"1"); + ps.setDate(4, new Date(patient.getBirth().getTime())); + ps.setString(5, "1"); + ps.setString(6, patient.getCardNo()); + ps.setString(7, null); + ps.setString(8, null); + ps.setString(9, null); + ps.setString(10, null); + ps.setString(11,null); + ps.setString(12,hQuan); + ps.setString(13,null); + ps.setString(14,null); + ps.setString(15,null); + ps.setString(16,null); + ps.setDate(17,new Date(patient.getCreated().getTime())); + ps.setString(18,null); + if(patient.getModified() != null){ + ps.setDate(19,new Date(patient.getModified().getTime())); + }else{ + ps.setNull(19, Types.DATE); + } + int inCount = ps.executeUpdate(); + if(inCount > 0){ + br.setErrorcode(ErrorCodeConstants.SUCCESS); + br.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); + return br; + } + }catch (Exception e){ + e.printStackTrace(); + }finally { + try{ + if(conn != null){ + conn.close(); + } + if(ps != null){ + ps.close(); + } + if(rs != null){ + rs.close(); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + } + + + return null; + } + + + + +} -- 1.8.3.1