|
@ -1,264 +0,0 @@
|
|
package com.yihu.hos.ws.service;
|
|
|
|
|
|
|
|
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
|
|
|
|
import com.yihu.hos.resource.util.StringUtil;
|
|
|
|
import com.yihu.hos.ws.model.DataSource;
|
|
|
|
import com.yihu.hos.ws.model.WSReturnModel;
|
|
|
|
import org.apache.commons.dbcp2.BasicDataSource;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Administrator on 2016/5/19.
|
|
|
|
*/
|
|
|
|
public class ExcuteService {
|
|
|
|
public static JdbcTemplate jdbcTemplate = null;
|
|
|
|
|
|
|
|
public void initJDBC() throws Exception {
|
|
|
|
if (jdbcTemplate == null) {
|
|
|
|
//jdbc:oracle:thin:hos/hos@//172.19.103.71:1521/orcl
|
|
|
|
//jdbc:mysql://172.19.103.71:1521/orcl?user=hos&password=hos&useUnicode=true&characterEncoding=UTF-8
|
|
|
|
//jdbc:sqlserver://172.19.103.71:1521/orcl?user=hos&password=hos
|
|
|
|
DBHelper dbTemp = new DBHelper();
|
|
|
|
DataSource source = dbTemp.load(DataSource.class, "select * from system_datasource");
|
|
|
|
String config = source.getConfig();
|
|
|
|
BasicDataSource dasicDataSource = new BasicDataSource();
|
|
|
|
if (config.contains("oracle")) {
|
|
|
|
//oracle数据库
|
|
|
|
dasicDataSource.setUrl(source.getConfig());
|
|
|
|
dasicDataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
|
|
|
|
String[] s1 = config.split("@");
|
|
|
|
String[] s2 = s1[0].split(":");
|
|
|
|
String[] s3 = s2[3].split("/");
|
|
|
|
dasicDataSource.setUsername(s3[0]);
|
|
|
|
dasicDataSource.setPassword(s3[1]);
|
|
|
|
} else if (config.contains("mysql")) {
|
|
|
|
//mysql数据库
|
|
|
|
dasicDataSource.setUrl(source.getConfig());
|
|
|
|
dasicDataSource.setDriverClassName("com.mysql.jdbc.Driver");
|
|
|
|
String[] s1 = config.split("\\?");
|
|
|
|
String[] s2 = s1[1].split("&");
|
|
|
|
dasicDataSource.setUsername(s2[0].split("=")[1]);
|
|
|
|
dasicDataSource.setPassword(s2[1].split("=")[1]);
|
|
|
|
} else if (config.contains("sqlserver")) {
|
|
|
|
//sqlserver数据库
|
|
|
|
dasicDataSource.setUrl(source.getConfig());
|
|
|
|
dasicDataSource.setDriverClassName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
|
|
|
|
String[] s1 = config.split("\\?");
|
|
|
|
String[] s2 = s1[1].split("&");
|
|
|
|
dasicDataSource.setUsername(s2[0].split("=")[1]);
|
|
|
|
dasicDataSource.setPassword(s2[1].split("=")[1]);
|
|
|
|
}
|
|
|
|
jdbcTemplate = new JdbcTemplate();
|
|
|
|
jdbcTemplate.setDataSource(dasicDataSource);
|
|
|
|
System.out.println(jdbcTemplate.queryForMap("select 1 from dual"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 执行sql语句
|
|
|
|
*
|
|
|
|
* @param sql
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String excuteSQL(String TransactionCode,
|
|
|
|
String sql) {
|
|
|
|
WSReturnModel wsReturnModel = new WSReturnModel();
|
|
|
|
wsReturnModel.setTransactionCode(TransactionCode);
|
|
|
|
try {
|
|
|
|
initJDBC();
|
|
|
|
wsReturnModel.setData(jdbcTemplate.queryForList(sql));
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
} catch (Exception e1) {
|
|
|
|
wsReturnModel.setRespCode("-30000");
|
|
|
|
wsReturnModel.setRespMessage(e1.getMessage());
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取检查报告单的列表
|
|
|
|
*
|
|
|
|
* @param cardType
|
|
|
|
* @param cardNo
|
|
|
|
* @param startDate
|
|
|
|
* @param endDate
|
|
|
|
* @param mobile
|
|
|
|
* @param reportType 1是检查 2是检验
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String GetReportList(
|
|
|
|
String TransactionCode,
|
|
|
|
String cardType,
|
|
|
|
String cardNo,
|
|
|
|
String startDate,
|
|
|
|
String endDate,
|
|
|
|
String mobile,
|
|
|
|
String reportType) {
|
|
|
|
WSReturnModel wsReturnModel = new WSReturnModel();
|
|
|
|
wsReturnModel.setTransactionCode(TransactionCode);
|
|
|
|
try {
|
|
|
|
initJDBC();
|
|
|
|
if ("2".equals(reportType)) {
|
|
|
|
//检验
|
|
|
|
StringBuffer sb = new StringBuffer("select * from HDSD02_01 where 1=1 ");
|
|
|
|
if (!StringUtils.isEmpty(endDate)) {
|
|
|
|
sb.append(" and HDSD00_05_026 < '" + endDate + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(startDate)) {
|
|
|
|
sb.append(" and HDSD00_01_001 > '" + startDate + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(mobile)) {
|
|
|
|
sb.append(" and HDSD00_01_001 = '" + mobile + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(cardNo)) {
|
|
|
|
sb.append(" and HDSD00_01_001 = '" + cardNo + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(cardType)) {
|
|
|
|
sb.append(" and HDSD00_01_001 = '" + cardType + "'");
|
|
|
|
}
|
|
|
|
wsReturnModel.setData(jdbcTemplate.queryForList(sb.toString()));
|
|
|
|
} else {
|
|
|
|
//检查
|
|
|
|
StringBuffer sb = new StringBuffer("select * from HDSD01_01 where 1=1 ");
|
|
|
|
if (!StringUtils.isEmpty(endDate)) {
|
|
|
|
sb.append(" and HDSD00_05_026 < '" + endDate + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(startDate)) {
|
|
|
|
sb.append(" and HDSD00_01_001 > '" + startDate + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(mobile)) {
|
|
|
|
sb.append(" and HDSD00_01_001 = '" + mobile + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(cardNo)) {
|
|
|
|
sb.append(" and HDSD00_01_001 = '" + cardNo + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(cardType)) {
|
|
|
|
sb.append(" and HDSD00_01_001 = '" + cardType + "'");
|
|
|
|
}
|
|
|
|
wsReturnModel.setData(jdbcTemplate.queryForList(sb.toString()));
|
|
|
|
}
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
} catch (Exception e) {
|
|
|
|
wsReturnModel.setRespCode("-30000");
|
|
|
|
wsReturnModel.setRespMessage(e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 检查报告单/检验报告单明细
|
|
|
|
*
|
|
|
|
* @param reportId
|
|
|
|
* @param reportType //报告单类型
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String GetReportInfo(
|
|
|
|
String TransactionCode,
|
|
|
|
String reportId,
|
|
|
|
String reportType) {
|
|
|
|
WSReturnModel wsReturnModel = new WSReturnModel();
|
|
|
|
wsReturnModel.setTransactionCode(TransactionCode);
|
|
|
|
try {
|
|
|
|
initJDBC();
|
|
|
|
if ("1".equals(reportType)) {
|
|
|
|
//检验
|
|
|
|
StringBuffer sb = new StringBuffer("select * from REPORT_JY where 1=1 ");
|
|
|
|
if (!StringUtils.isEmpty(reportId)) {
|
|
|
|
sb.append(" and REPORT_ID = '" + reportId + "'");
|
|
|
|
}
|
|
|
|
List<Map<String, Object>> returnData = jdbcTemplate.queryForList(sb.toString());
|
|
|
|
|
|
|
|
for (Map<String, Object> oneM : returnData) {
|
|
|
|
//检验-图片报告单
|
|
|
|
sb = new StringBuffer("select * from REPORT_JY_MX where 1=1 ");
|
|
|
|
if (!StringUtils.isEmpty(oneM.get("REPORT_ID"))) {
|
|
|
|
sb.append(" and REPORT_ID = '" + reportId + "'");
|
|
|
|
}
|
|
|
|
oneM.put("Data_1", jdbcTemplate.queryForList(sb.toString()));
|
|
|
|
}
|
|
|
|
wsReturnModel.setData(returnData);
|
|
|
|
} else {
|
|
|
|
//检查
|
|
|
|
StringBuffer sb = new StringBuffer("select * from REPORT_JC where 1=1 ");
|
|
|
|
if (!StringUtils.isEmpty(reportId)) {
|
|
|
|
sb.append(" and REPORT_ID = '" + reportId + "'");
|
|
|
|
}
|
|
|
|
List<Map<String, Object>> returnData = jdbcTemplate.queryForList(sb.toString());
|
|
|
|
wsReturnModel.setData(returnData);
|
|
|
|
}
|
|
|
|
System.out.println(wsReturnModel);
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
} catch (Exception e) {
|
|
|
|
wsReturnModel.setRespCode("-30000");
|
|
|
|
wsReturnModel.setRespMessage(e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 人口学信息查询
|
|
|
|
*
|
|
|
|
* @param TransactionCode
|
|
|
|
* @param CardType
|
|
|
|
* @param CardNo
|
|
|
|
* @param Mobile
|
|
|
|
* @param PatientId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String QueryUserInfo(String TransactionCode, String CardType, String CardNo, String Mobile, String PatientId) {
|
|
|
|
WSReturnModel wsReturnModel = new WSReturnModel();
|
|
|
|
wsReturnModel.setTransactionCode(TransactionCode);
|
|
|
|
try {
|
|
|
|
|
|
|
|
initJDBC();
|
|
|
|
//人口学信息
|
|
|
|
StringBuffer sb = new StringBuffer("select * from PATIENT_INFO a where 1=1 ");
|
|
|
|
if (!StringUtil.isEmpty(CardNo)) {
|
|
|
|
sb.append(" and a.CARD_NO = '" + CardNo + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtil.isEmpty(CardType)) {
|
|
|
|
sb.append(" and a.CARD_TYPE = '" + CardType + "'");
|
|
|
|
}
|
|
|
|
List<Map<String, Object>> RKXMap = jdbcTemplate.queryForList(sb.toString());
|
|
|
|
wsReturnModel.setData(RKXMap);
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
} catch (Exception e) {
|
|
|
|
wsReturnModel.setRespCode("-30000");
|
|
|
|
wsReturnModel.setRespMessage(e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String QueryRegInfo(String TransactionCode, String CardType,String CardNo, String IdCardNo, String OrderId, String ClinicCard, String TimeSlice, String StartTime, String EndTime, String RegFlag) {
|
|
|
|
WSReturnModel wsReturnModel = new WSReturnModel();
|
|
|
|
wsReturnModel.setTransactionCode(TransactionCode);
|
|
|
|
try {
|
|
|
|
initJDBC();
|
|
|
|
//预约信息查询
|
|
|
|
StringBuffer sb = new StringBuffer("select * from REG_INFO a where 1=1 ");
|
|
|
|
if (!StringUtil.isEmpty(CardNo)) {
|
|
|
|
sb.append(" and a.CARD_NO = '" + CardNo + "'");
|
|
|
|
}
|
|
|
|
if (!StringUtil.isEmpty(CardType)) {
|
|
|
|
sb.append(" and a.CARD_TYPE = '" + CardType + "'");
|
|
|
|
}
|
|
|
|
List<Map<String, Object>> RKXMap = jdbcTemplate.queryForList(sb.toString());
|
|
|
|
|
|
|
|
wsReturnModel.setData(RKXMap);
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
} catch (Exception e) {
|
|
|
|
wsReturnModel.setRespCode("-30000");
|
|
|
|
wsReturnModel.setRespMessage(e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
return WSReturnModel.toXml(wsReturnModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|