diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java index 0418671..0927302 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java @@ -22,6 +22,8 @@ import java.io.LineNumberReader; import java.net.InetAddress; import java.net.NetworkInterface; import java.sql.*; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; import java.util.Date; @@ -34,6 +36,8 @@ import static com.lyms.hospitalapi.whfy.ConnTools.makeHisConnection; @Service("virtualCallService") public class VirtualCallService { + + @Autowired private UsersService usersService; @@ -72,19 +76,12 @@ public class VirtualCallService { conn = makeHisConnection(); //1.1 普通登录 '1','200.200.3.164','05030101','产二门诊','10018','滕振娟' //exec usp_mzhs_hsfzinterface '1','192.168.1.219','2052','儿科门诊','00','supervisor','D8-9E-F3-13-A5-86','0',@sex='男' - cs = conn.prepareCall("{call usp_mzhs_hsfzinterface(?,?,?,?,?,?)}"); - cs.setString(1, "1"); - cs.setString(2, "200.200.3.53"); - cs.setString(3, "0501"); - cs.setString(4, "产二门诊"); - cs.setString(5, "10120"); - cs.setString(6, "李文学"); -// -// cs.setString(2, ip); -// cs.setString(3, code); -// cs.setString(4, deptName); -// cs.setString(5, doctorAccount); -// cs.setString(6, doctorName); + cs = conn.prepareCall("{call usp_hzfz_hsfzinterface(?,?,?,?,?,?)}"); + cs.setString(2, ip); + cs.setString(3, code); + cs.setString(4, deptName); + cs.setString(5, doctorAccount); + cs.setString(6, doctorName); cs.execute(); ResultSet rs = cs.getResultSet(); @@ -114,9 +111,7 @@ public class VirtualCallService { ConnTools.close(conn,cs); } result.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); - result.setErrormsg("登陆异常"); - - VirtualUtil.sendVoice("登陆成功"); + result.setErrormsg("登陆失败"); return result; } @@ -132,9 +127,9 @@ public class VirtualCallService { conn = makeHisConnection(); //5 退出登录 //exec usp_mzhs_hsfzinterface 5,'192.168.1.219' - cs = conn.prepareCall("{call usp_mzhs_hsfzinterface(?,?)}"); + cs = conn.prepareCall("{call usp_hzfz_hsfzinterface(?,?)}"); cs.setString(1, "5"); - cs.setString(2, "200.200.3.53"); + cs.setString(2, ip); cs.execute(); ResultSet rs = cs.getResultSet(); @@ -181,10 +176,10 @@ public class VirtualCallService { conn = makeHisConnection(); //14 更改诊间状态 --0 修改当前诊间为停诊,1 修改当前诊间为开诊,2 获取当前诊间状态(0 停诊 1 开诊) //exec usp_mzhs_hsfzinterface_km 14,'192.16.1.111',@zjzt=2 - cs = conn.prepareCall("{call usp_mzhs_hsfzinterface_km(?,?,?)}"); + cs = conn.prepareCall("{call usp_hzfz_hsfzinterface(?,?,@zjzt=?)}"); cs.setString(1, "14"); - cs.setString(2, "200.200.3.53"); - cs.setString(3, "@zjzt=" + status); + cs.setString(2, ip); + cs.setString(3, status); cs.execute(); ResultSet rs = cs.getResultSet(); @@ -228,11 +223,14 @@ public class VirtualCallService { conn = makeHisConnection(); // 7 复呼 // exec usp_mzhs_hsfzinterface 7,'10.58.99.246',@ghxh=2795541 - cs = conn.prepareCall("{call usp_mzhs_hsfzinterface(?,?,?)}"); + cs = conn.prepareCall("{call usp_hzfz_hsfzinterface(?,?,@ghxh=?)}"); cs.setString(1, "7"); - cs.setString(2, "200.200.3.53"); - cs.setString(3, "@ghxh=18441"); + cs.setString(2, ip); + cs.setString(3, patientId); cs.execute(); + StringBuffer content = new StringBuffer(); + content.append("请"); + boolean isSuccess = false; ResultSet rs = cs.getResultSet(); int count = rs.getMetaData().getColumnCount(); while (rs.next()) { @@ -241,15 +239,27 @@ public class VirtualCallService { String columnName = rs.getMetaData().getColumnName(i); Object value = rs.getObject(columnName); System.out.println(ip+";rebackCall columName=" + columnName+ ";value="+value); - if (columnName != null && "GHXH".equals(String.valueOf(columnName))) - { - result.setErrorcode(ErrorCodeConstants.SUCCESS); - result.setErrormsg("登陆成功"); - return result; - } + } + String hzxm = rs.getString("HZXM"); + if (StringUtils.isNotEmpty(hzxm)) + { + isSuccess = true; + content.append(hzxm); + content.append("到"); + content.append(rs.getString("ZJMC")); + content.append("就诊"); } } + if (isSuccess) + { + System.out.println("复呼内容:"+content.toString()); + VirtualUtil.sendVoice(content.toString()); + result.setErrorcode(ErrorCodeConstants.SUCCESS); + result.setErrormsg("复呼成功"); + return result; + } + } catch (Exception e) { @@ -260,7 +270,7 @@ public class VirtualCallService { ConnTools.close(conn,cs); } result.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); - result.setErrormsg("复呼异常"); + result.setErrormsg("复呼失败"); return result; } @@ -273,7 +283,7 @@ public class VirtualCallService { Departments departments = departmentsService.getDepartments(user.getDeptId()); String code = departments.getShortCode(); - String doctorAccount = user.getAccount(); + String doctorAccount = user.getRemarks(); String ip = getIp(request); System.out.println("waitPatientList time=" + DateUtil.getyyyy_MM_dd_hms(new Date()) + ";ip=" + ip); @@ -286,11 +296,11 @@ public class VirtualCallService { conn = makeHisConnection(); //6 获取队列列表 //exec usp_mzhs_hsfzinterface 6,'192.168.1.219',@ksdm='2052',@ysdm='00' - cs = conn.prepareCall("{call usp_mzhs_hsfzinterface_km(?,?,?,?)}"); + cs = conn.prepareCall("{call usp_hzfz_hsfzinterface(?,?,@ksdm=?,@ysdm=?)}"); cs.setString(1, "6"); - cs.setString(2, "200.200.3.53"); - cs.setString(3, "@ksdm=0501"); - cs.setString(4, "@ysdm=10120"); + cs.setString(2, ip); + cs.setString(3, code); + cs.setString(4, doctorAccount); cs.execute(); ResultSet rs = cs.getResultSet(); @@ -307,9 +317,9 @@ public class VirtualCallService { { Map map = new HashMap<>(); map.put("patientId",rs.getString("GHXH")); - map.put("vcCardNo",rs.getString("GHHX")); + map.put("vcCardNo", rs.getString("CARDNO")); map.put("name", rs.getString("HZXM")); - map.put("time", rs.getString("ZJDLXH")); + map.put("time", formatDate(rs.getString("JLRQ"))); datas.add(map); } } @@ -331,8 +341,6 @@ public class VirtualCallService { result.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); result.setErrormsg("获取候诊队列失败"); return result; - - } @@ -369,9 +377,9 @@ public class VirtualCallService { conn = makeHisConnection(); //16 已叫号病人列表 //exec usp_mzhs_hsfzinterface 16,'192.168.1.219' - cs = conn.prepareCall("{call usp_mzhs_hsfzinterface(?,?)}"); + cs = conn.prepareCall("{call usp_hzfz_hsfzinterface(?,?)}"); cs.setString(1, "16"); - cs.setString(2, "200.200.3.53"); + cs.setString(2, ip); cs.execute(); ResultSet rs = cs.getResultSet(); @@ -386,9 +394,9 @@ public class VirtualCallService { if (isExistColumn(rs,"GHXH")) { Map map = new HashMap<>(); map.put("patientId", rs.getString("GHXH")); - map.put("vcCardNo", rs.getString("GHHX")); + map.put("vcCardNo", rs.getString("CARDNO")); map.put("name", rs.getString("HZXM")); - map.put("time", rs.getString("ZJDLXH")); + map.put("time", formatDate(rs.getString("JLRQ"))); datas.add(map); } } @@ -423,20 +431,35 @@ public class VirtualCallService { //exec usp_mzhs_hsfzinterface '2','192.168.1.219' cs = conn.prepareCall("{call usp_mzhs_hsfzinterface(?,?)}"); cs.setString(1, "2"); - cs.setString(2, "200.200.3.53"); + cs.setString(2, ip); cs.execute(); ResultSet rs = cs.getResultSet(); int count = rs.getMetaData().getColumnCount(); - String content = ""; + StringBuffer content = new StringBuffer(); + content.append("请"); + boolean isSuccess = false; while (rs.next()) { for (int i = 1; i <= count; i++) { String columnName = rs.getMetaData().getColumnName(i); Object value = rs.getObject(columnName); System.out.println("nextPatient columName=" + columnName + ";value=" + value); } + String hzxm = rs.getString("HZXM"); + if (StringUtils.isNotEmpty(hzxm)) + { + isSuccess = true; + content.append(hzxm); + content.append("到"); + content.append(rs.getString("ZJMC")); + content.append("就诊"); + } + } + if (isSuccess) + { + System.out.println("下一个内容:"+content.toString()); + VirtualUtil.sendVoice(content.toString()); + return true; } - VirtualUtil.sendVoice(content); - return true; } catch (Exception e) { @@ -500,6 +523,24 @@ public class VirtualCallService { } + private String formatDate(String time) + { + if (!StringUtils.isNotEmpty(time)) + { + return ""; + } + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH:mm:ss"); + SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date date = format.parse(time); + return format1.format(date); + } catch (ParseException e) { + System.out.println(time+"解析时间格式出错"+e); + return ""; + } + } + + }