Commit 773f804a32d4e20e75f034b454750b3ffc1c42b4
1 parent
7934e954f0
Exists in
master
and in
6 other branches
秦皇岛天英接口修改
Showing 2 changed files with 139 additions and 0 deletions
platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/ConnTools.java
View file @
773f804
... | ... | @@ -60,6 +60,13 @@ |
60 | 60 | private static String jbgwPassword = "LYMS_QHD_JBGW"; |
61 | 61 | |
62 | 62 | |
63 | + private static String tyDirverClassName = "oracle.jdbc.driver.OracleDriver"; | |
64 | + private static String tyUrl = "jdbc:oracle:thin:@13.14.12.82:1526:orcl"; | |
65 | + private static String tyUser = "dzhy"; | |
66 | + private static String tyPassword = "sjzDzhy975"; | |
67 | + | |
68 | + | |
69 | + | |
63 | 70 | public static Connection makeHisConnection() { |
64 | 71 | Connection conn = null; |
65 | 72 | try { |
... | ... | @@ -130,6 +137,23 @@ |
130 | 137 | } |
131 | 138 | try { |
132 | 139 | conn = DriverManager.getConnection(jbgwUrl, jbgwUser, jbgwPassword); |
140 | + } catch (SQLException e) { | |
141 | + e.printStackTrace(); | |
142 | + } | |
143 | + return conn; | |
144 | + } | |
145 | + | |
146 | + | |
147 | + | |
148 | + public static Connection makeQhdTyConnection() { | |
149 | + Connection conn = null; | |
150 | + try { | |
151 | + Class.forName(tyDirverClassName); | |
152 | + } catch (ClassNotFoundException e) { | |
153 | + e.printStackTrace(); | |
154 | + } | |
155 | + try { | |
156 | + conn = DriverManager.getConnection(tyUrl, tyUser, tyPassword); | |
133 | 157 | } catch (SQLException e) { |
134 | 158 | e.printStackTrace(); |
135 | 159 | } |
platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdTyInterface.java
View file @
773f804
1 | +package com.lyms.hospitalapi.qhdfy; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.BasicConfigService; | |
4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
5 | +import com.lyms.platform.common.result.BaseObjectResponse; | |
6 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
7 | +import com.lyms.platform.pojo.Patients; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.stereotype.Service; | |
10 | + | |
11 | +import java.sql.*; | |
12 | + | |
13 | +/** | |
14 | + * Created by Administrator on 2018/8/27. | |
15 | + */ | |
16 | +@Service("qhdTyInterface") | |
17 | +public class QhdTyInterface { | |
18 | + | |
19 | + @Autowired | |
20 | + private BasicConfigService basicConfigService; | |
21 | + | |
22 | + /** | |
23 | + * 基本信息 | |
24 | + * @param patient | |
25 | + * @return | |
26 | + */ | |
27 | + public BaseObjectResponse savePERSONS(Patients patient){ | |
28 | + BaseObjectResponse br = new BaseObjectResponse(); | |
29 | + Connection conn = ConnTools.makeQhdTyConnection(); | |
30 | + PreparedStatement ps = null; | |
31 | + ResultSet rs = null; | |
32 | + int result = 0; | |
33 | + if(patient != null){ | |
34 | + try{ | |
35 | + String selSql = "select count(*) from PERSONS where PK='"+patient.getId()+"'"; | |
36 | + ps = conn.prepareStatement(selSql); | |
37 | + rs = ps.executeQuery(); | |
38 | + while(rs.next()){ | |
39 | + result = rs.getInt(1); | |
40 | + } | |
41 | + if(result > 0){ | |
42 | + String delSql = "delete from PERSONS where PK='"+patient.getId()+"'"; | |
43 | + ps = conn.prepareStatement(delSql); | |
44 | + int delCount = ps.executeUpdate(); | |
45 | + if(delCount > 0){ | |
46 | + System.out.print("基本信息数据删除完毕,请重新插入数据!"); | |
47 | + } | |
48 | + } | |
49 | + //户籍地址 | |
50 | + String hjSheng = CommonsHelper.getName1(patient.getProvinceId(), basicConfigService); | |
51 | + String hjShi = CommonsHelper.getName1(patient.getCityId(), basicConfigService); | |
52 | + String hjXian = CommonsHelper.getName1(patient.getAreaId(), basicConfigService); | |
53 | + String hjXiang = CommonsHelper.getName1(patient.getStreetId(), basicConfigService); | |
54 | + String hQuan = hjSheng+hjShi+hjXian+hjXiang; | |
55 | + //插入数据 | |
56 | + String inSql = "insert into PERSONS(PK,XM,XB_DM,CSRQ,SFZJLB,SFZHM,MZ_DM,HKXZ_DM,HYZK_DM,DWXZ_DM,GZDW,HJDDZ,\n" + | |
57 | + "HJDDM,HYS,SYS,XYZNS,CREATEDATE,SOURCE,MODIFYDATE) " + | |
58 | + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; | |
59 | + ps = conn.prepareStatement(inSql); | |
60 | + ps.setString(1,patient.getId()); | |
61 | + ps.setString(2,patient.getUsername()); | |
62 | + ps.setString(3,"1"); | |
63 | + ps.setDate(4, new Date(patient.getBirth().getTime())); | |
64 | + ps.setString(5, "1"); | |
65 | + ps.setString(6, patient.getCardNo()); | |
66 | + ps.setString(7, null); | |
67 | + ps.setString(8, null); | |
68 | + ps.setString(9, null); | |
69 | + ps.setString(10, null); | |
70 | + ps.setString(11,null); | |
71 | + ps.setString(12,hQuan); | |
72 | + ps.setString(13,null); | |
73 | + ps.setString(14,null); | |
74 | + ps.setString(15,null); | |
75 | + ps.setString(16,null); | |
76 | + ps.setDate(17,new Date(patient.getCreated().getTime())); | |
77 | + ps.setString(18,null); | |
78 | + if(patient.getModified() != null){ | |
79 | + ps.setDate(19,new Date(patient.getModified().getTime())); | |
80 | + }else{ | |
81 | + ps.setNull(19, Types.DATE); | |
82 | + } | |
83 | + int inCount = ps.executeUpdate(); | |
84 | + if(inCount > 0){ | |
85 | + br.setErrorcode(ErrorCodeConstants.SUCCESS); | |
86 | + br.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); | |
87 | + return br; | |
88 | + } | |
89 | + }catch (Exception e){ | |
90 | + e.printStackTrace(); | |
91 | + }finally { | |
92 | + try{ | |
93 | + if(conn != null){ | |
94 | + conn.close(); | |
95 | + } | |
96 | + if(ps != null){ | |
97 | + ps.close(); | |
98 | + } | |
99 | + if(rs != null){ | |
100 | + rs.close(); | |
101 | + } | |
102 | + }catch (Exception e){ | |
103 | + e.printStackTrace(); | |
104 | + } | |
105 | + } | |
106 | + } | |
107 | + | |
108 | + | |
109 | + return null; | |
110 | + } | |
111 | + | |
112 | + | |
113 | + | |
114 | + | |
115 | +} |