From df3ab75b43647969fe8addb410574959c51905c5 Mon Sep 17 00:00:00 2001 From: xuhx <1216720373@qq.com> Date: Fri, 24 Sep 2021 18:17:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2Oracle=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=EF=BC=8C=E8=8E=B7=E5=8F=96=E6=9C=80=E5=90=8E=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E6=97=B6=E9=97=B4=EF=BC=8C=E5=B7=B2=E7=BB=8F=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=80=9A=E8=BF=87=EF=BC=8C=E8=AF=B7=E5=85=B7=E4=BD=93?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 12 +++++ .../com/emr/dao/FinishedDateTimeMapper.java | 8 ++++ .../java/com/emr/entity/FinishedDateTime.java | 39 ++++++++++++++++ .../emr/service/FinishedDateTimeService.java | 8 ++++ .../ipml/FinishedDateTimeServiceImpl.java | 44 +++++++++++++++++++ .../resources/config/applicationContext.xml | 2 +- src/main/resources/config/jdbc.properties | 11 +++++ src/main/resources/config/mybatis-config.xml | 17 ++++++- .../mapper/FinishedDateTimeMapper.xml | 14 ++++++ 9 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/emr/dao/FinishedDateTimeMapper.java create mode 100644 src/main/java/com/emr/entity/FinishedDateTime.java create mode 100644 src/main/java/com/emr/service/FinishedDateTimeService.java create mode 100644 src/main/java/com/emr/service/ipml/FinishedDateTimeServiceImpl.java create mode 100644 src/main/resources/mapper/FinishedDateTimeMapper.xml diff --git a/pom.xml b/pom.xml index 9fd30987..7da2ad94 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,18 @@ + + + com.oracle.database.jdbc + ojdbc8 + 19.8.0.0 + + + + cn.easyproject + orai18n + 12.1.0.2.0 + org.apache.commons diff --git a/src/main/java/com/emr/dao/FinishedDateTimeMapper.java b/src/main/java/com/emr/dao/FinishedDateTimeMapper.java new file mode 100644 index 00000000..1255462b --- /dev/null +++ b/src/main/java/com/emr/dao/FinishedDateTimeMapper.java @@ -0,0 +1,8 @@ +package com.emr.dao; + +import com.emr.entity.FinishedDateTime; + + +public interface FinishedDateTimeMapper { + FinishedDateTime findByID(Long INP_NO, Long VISIT_ID); +} diff --git a/src/main/java/com/emr/entity/FinishedDateTime.java b/src/main/java/com/emr/entity/FinishedDateTime.java new file mode 100644 index 00000000..b8b08aaf --- /dev/null +++ b/src/main/java/com/emr/entity/FinishedDateTime.java @@ -0,0 +1,39 @@ +package com.emr.entity; + +import java.util.Date; + +/** + * oracle,数据交互实体类 + * INP_NO,Long VISIT_ID,这两个属性为预留,现在并没有使用 + */ +public class FinishedDateTime { + private Long INP_NO; + private Long VISIT_ID; + private Date FINISHED_DATE_TIME; + + public Long getINP_NO() { + return INP_NO; + } + + public void setINP_NO(Long INP_NO) { + this.INP_NO = INP_NO; + } + + public Long getVISIT_ID() { + return VISIT_ID; + } + + public void setVISIT_ID(Long VISIT_ID) { + this.VISIT_ID = VISIT_ID; + } + + public Date getFINISHED_DATE_TIME() { + return FINISHED_DATE_TIME; + } + + public void setFINISHED_DATE_TIME(Date FINISHED_DATE_TIME) { + this.FINISHED_DATE_TIME = FINISHED_DATE_TIME; + } + + +} diff --git a/src/main/java/com/emr/service/FinishedDateTimeService.java b/src/main/java/com/emr/service/FinishedDateTimeService.java new file mode 100644 index 00000000..c3d999f3 --- /dev/null +++ b/src/main/java/com/emr/service/FinishedDateTimeService.java @@ -0,0 +1,8 @@ +package com.emr.service; + +import java.io.IOException; +import java.util.Date; + +public interface FinishedDateTimeService { + Date findByID(Long INP_NO, Long VISIT_ID) throws IOException; +} diff --git a/src/main/java/com/emr/service/ipml/FinishedDateTimeServiceImpl.java b/src/main/java/com/emr/service/ipml/FinishedDateTimeServiceImpl.java new file mode 100644 index 00000000..86a8f229 --- /dev/null +++ b/src/main/java/com/emr/service/ipml/FinishedDateTimeServiceImpl.java @@ -0,0 +1,44 @@ +package com.emr.service.ipml; + +import com.emr.dao.FinishedDateTimeMapper; +import com.emr.entity.FinishedDateTime; +import com.emr.service.FinishedDateTimeService; +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.SqlSessionFactoryBuilder; + +import java.io.IOException; +import java.io.Reader; +import java.util.Date; + +/** + * oracle数据获取 + */ +public class FinishedDateTimeServiceImpl implements FinishedDateTimeService { + /** + * 实际查询方法 + * + * @param INP_NO 编号 + * @param VISIT_ID 住院次数 + * @return 最后完成时间 + * @throws IOException 注意传入两个参数都是Long,返回一条date类型数据或null,可用tostring()转 + */ + @Override + public Date findByID(Long INP_NO, Long VISIT_ID) throws IOException { + //加载资源 + String resource = "config/mybatis-config.xml"; + Reader reader = Resources.getResourceAsReader(resource); + //创建session + SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(reader); + SqlSession session = factory.openSession(); + //获取映射对象 + FinishedDateTimeMapper mapper = session.getMapper(FinishedDateTimeMapper.class); + FinishedDateTime result = mapper.findByID(INP_NO, VISIT_ID); + if (result != null) { + Date dateTime = result.getFINISHED_DATE_TIME(); + return dateTime; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/resources/config/applicationContext.xml b/src/main/resources/config/applicationContext.xml index 640dcc3a..93701740 100644 --- a/src/main/resources/config/applicationContext.xml +++ b/src/main/resources/config/applicationContext.xml @@ -54,7 +54,7 @@ - + diff --git a/src/main/resources/config/jdbc.properties b/src/main/resources/config/jdbc.properties index fd919642..d89b888b 100644 --- a/src/main/resources/config/jdbc.properties +++ b/src/main/resources/config/jdbc.properties @@ -13,6 +13,17 @@ hibernate.current_session_context_class=thread hibernate.jdbc.batch_size=50 hibernate.enable_lazy_load_no_trans=true + +//oracle连接需要的所有信息,实际直接写死在mybatis-config。xml中 +//驱动 +#driverClass="oracle.jdbc.OracleDriver"; +//地址 +#url="jdbc:oracle:thin:@10.6.0.150:1521:jhemr"; +//用户名 +#username="jswzh"; +//密码 +#password="jswzh123"; + #图片地址 pictureUrl=D:\\test\\uploadImage #本地自动生成PDF地址D:\tesst\autoPdf diff --git a/src/main/resources/config/mybatis-config.xml b/src/main/resources/config/mybatis-config.xml index 03aea53f..1815bb10 100644 --- a/src/main/resources/config/mybatis-config.xml +++ b/src/main/resources/config/mybatis-config.xml @@ -21,5 +21,20 @@ - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/FinishedDateTimeMapper.xml b/src/main/resources/mapper/FinishedDateTimeMapper.xml new file mode 100644 index 00000000..2b28a2a6 --- /dev/null +++ b/src/main/resources/mapper/FinishedDateTimeMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file