为兼容TDSQL数据库,约定以下修改
1、在mybatis.xml
或java
代码内的sql,表名
二边去掉双引号,字段名
二边去掉双引号 ,字段后的as 的名称可以加双引号(字段二边加双引号后表示不转大小写,而TDSQL默认把字段转成大写,会导致字段不存在错误)
-- ✅正确写法
select my_Name as "myName" from my_table where my_sex_id = 1
2、未承继com.mediway.his.api.entity.BaseEntity的PO类,要的PO类中指定id属性,且一定对应大写ID字段;如果承继了不用修改
// ✅正确写法
@TableId(value="ID",type=IdType.AUTO)
private Long id;
技术说明(建表时不加双引号时,字段默认强制转成大写)
CREATE TABLE my_table (field_name VARCHAR(255),"field_name2" varchar(255));
-- 在默认大写字段名情况下,实现列名为FIELD_NAME,field_name2
-- ✅
SELECT field_name,"field_name2" FROM my_table; -- 肯定工作正常
SELECT FIELD_NAME,"field_name2" FROM my_table; -- 可能工作正常(列名默认转成大写)
-- 查询时也必须使用相同的大小写和双引号
3、now()修改成CURRENT_TIMESTAMP
-- ❌错误写法
update my_table set update_datetime=now() where id=1; -- 在tdsql下运行会报错
修改成
-- ✅ [增加与修改]语句要修改,删除与查询暂时不作要求
update my_table set update_datetime=CURRENT_TIMESTAMP where id=1;
4、select
语句查询count(*
),sum(*
),int类型字段,bigint字段时,返回列值默认为bigdecimal
类型
<!-- ✅ 正确写法 resultType="int" -->
<select id='mybatisMethod' resultType="int">
select count(*) from my_table where userid=#{userid}
</select>
<select id="getPriority" resultType="java.util.HashMap">
SELECT amount, display_name as "caption" FROM my_table
where activity = true and (end_date >= now() or end_date is null)
</select>
java中获取数量
值写法
// ❌错误写法, 兼容性差
Long amount = myMap.get("amount"); // TDSQL下报错,因为BigDecimal类型转成Long报错
修改成
// ✅正确写法
Object value = myMap.get("amount"); // TDSQL下value为BigDecimal类型,人大金仓下为Long
Long amount = 0L;
if (value instanceof BigDecimal) {
amount = ((BigDecimal) value).longValueExact();
}else{
amount = (Long)value;
}
或
// ✅正确写法
import cn.hutool.core.convert.Convert; // 引入hutool的类
Long amount = Convert.toLong(myMap.get("amount"),0L);
sql查询优化测试
-- 当test_patient表patient_id为varchar类型时
explain analyze
select p.name from cf_bsp_test_patient t
left join pa_pat_mast p on p.id=t.patient_id -- 125ms
explain analyze
SELECT p.name FROM pa_pat_mast p WHERE EXISTS ( -- 70ms
SELECT 1 FROM cf_bsp_test_patient t WHERE p.id = t.patient_id
)
explain analyze
select p.name from pa_pat_mast p where p.id in ( -- 76ms
select t.patient_id from cf_bsp_test_patient t
)
explain analyze
select p.name from pa_pat_mast p where p.id in ( -- 0.099ms
'72258','3','1','2'
)
-- 强转类型再联接 或 字段类型修改成bigint后查询
explain analyze
select p.name from cf_bsp_test_patient t
left join pa_pat_mast p on p.id=CAST(t.patient_id as bigint) -- 0.09ms
或
-- ✅正确方式, 要连表的字段的类型与原表字段保持一致
alter table cf_bsp_test_patient modify patient_id bigint null;
explain analyze
select p.name from cf_bsp_test_patient t
left join pa_pat_mast p on p.id=CAST(t.patient_id as bigint) -- 0.07ms
::text
控制台
也会抛出异常,通过控制台
的堆栈信息,可以定义到自己的代码。修改成websys_setMenuForm({EpisodeID:2,PatientID:1,admType:'I',PPRowId:1});
这种格式即可。 读取值功能
不受影响。切换数据库大小写敏感方式后,like匹配是大小写敏感的,修改like功能
如果别名中有大小写字符时,使用双引号包裹处,以防数据库把列名转成全小写
-- ✅正确写法,别名使用双引号包裹
select locId as "ctLocId" from ct_org_location
如果使用模糊查询功能可以使用ilike
功能,来忽略大小查询
-- ✅正确写法, like修改成ilike,以便忽略大小查询
(code ilike concat('%', #{dto.code}, '%') or description ilike concat('%',#{dto.code},'%'))
登录界面路径修改成/imedical/his
前台代码中写死路径的地方要修改
nginx中以前/his
的代理修改为以下代理
location /imedical/his {
alias D:/his-mediway-front/hisfront/static;
if ($request_filename ~* ^.+\.(?:html|js|css|png|jpg|gif|woff)$){
break;
}
if ($request_filename ~* "(.*?)(undefined)$"){
return 200 '{"message":""}';
}
try_files $uri $uri/ /imedical/his/hos/index.html;
index index.html index.htm;
}
查询his内数据时,mapper
文件中不写死数据库schema名称ho_his
feign类与controller类的路径要一致
// Feign内path
@FeignClient(value="${mediway.application.emnur}",path="${server.servlet.context-path}/comem/emer/nurorder")
// Controller
@RequestMapping("/comem/emer/nurorder")
晚间19点会议
<optional>
<scope>
<dependency>
<groupId>com.mediway.his</groupId>
<artifactId>xx-xxx</artifactId>
<version>1.0-SNAPSHOT</version>
<!--<optional>true</optional> 不使用-->
<!--<scope>provided</scope> 不使用--> <!--compile值可以-->
</dependency>
api
模块应该包含Configuration
类及spring.factories
配置文件gitlab
删除addins/plugin
目录的管理,移到84服务器/home/his/base/addins/plugin
下.gitignore
文件忽略plugin目录,防止有人提交插件大文件nacos
服务器地址不再使用188的了,统一改成了http://81.70.230.87:8848/nacosct_ar_item_addinfo
-> ct_mat_item
以下表没有做维护,只是迁移his里之前有的但是业务含义不明确或者不确定是否在用的字段,请用到的同事联系我确认
ct_oe_itmmast_addinfo
-> ct_oe_itmmast_ext
ct_org_location
-> ct_org_location_ext
ct_org_useraccount_addinfo
-> ct_org_useraccount_ext
ct_org_healthorg_addinfo
-> ct_org_healthorg_ext
ct_rb_careprov_addinfo
-> ct_rb_careprov_ext
ct_or_operation_addinfo
-> ct_or_operation_ext
ct_mr_icddx_addinfo
-> ct_mr_icddx_ext
注意事项:
(1)医护人员的手机号,请大家优先取hos_org_person
人员表里的mobile
(2)是否麻醉师 请取医护人员表ct_rb_careprov
的 anaesthetist_flag
(3)医嘱项的通用名方式获取方式联系药房药库,不要取自ct_oe_itmmast_ext
表错误日志平台
,查看详细说明在高斯
数据库中关于 field=''
问题
如果表字段非varchar类型,高斯不允许使用field=''
, 应该使用field is null
select field1 from t_test where field_varchar='' -- 可以运行
select field1 from t_test where field_amount='' -- 人大金仓可以,高斯报错 field_amount为int类型
select field1 from t_test where start_date='' -- 人大金仓可以,高斯报错 start_date为date类型
应使用以下方式
-- ✅正确写法,非varchar字段不会存入''值
select field1 from t_test where field_varchar is null or field_varchar=''
select field1 from t_test where field_amount is null
select field1 from t_test where start_date is null
关于count(*)
与order by
使用
-- ❌兼容性差,高斯数据库下报错
select count(*) as total from oe_ord_exec order by ex_stdatetime desc
以上代码可以在人大金仓
上运行,在高斯
数据库下报错,正确的写法应该如下:
-- ✅正确写法
select count(*) as total from oe_ord_exec
存在group by
时,count
与order by
可以同时存在
-- ✅正确写法
select count(*) as total, rule_alias from bsp_cache_tables where 1=1
group by rule_alias order by rule_alias;
### 2024-08-24
111.205.6.225
修改为111.205.100.74
, 只修改ip地址即可,其他不变关于LISTAGG
方法兼容性问题
-- ❌兼容性差,高斯数据库下报错
SELECT LISTAGG(doc.id,",") FROM mr_emrdb0_docdata doc
以上SQL在KingBase下可以执行,但在GaussDB下会报missing WITHIN keyword
,应该使用以下兼容写法
-- ✅正确写法
SELECT LISTAGG(doc.id,",") WITHIN GROUP (ORDER BY doc.id ASC)
FROM mr_emrdb0_docdata doc
大家删一下本地maven仓库中的hos-app-config的包,昨天hos修改了bug
因为高斯
数据库不支持datetime数据类型,所以在导入时崔工统一修改成了date,但是测试发现date转LocalDatetime会报这个错,提个脚本将数据类型转成timestamp就可以解决这个问题
cannot convert the column of type DATE to requested type java.time.LocalDateTime
因为高斯
数据库中没有current_date()函数,所以要检查sql语句中是否使用了current_date()函数,如果有都修改成current_date
-- ✅正确写法 使用current_date,不使用current_date()
where end_date>=current_date or end_date is null
current_date变量取得当天日期
,时分秒
都为0,now()是取的当前的时间,精确到毫秒,按实际场景选择使用
因为高斯
数据库中日期字段名=’’写法不被允许,需要删除相关代码
-- ❌兼容性差
start_date is null or start_date='' or start_date>=current_date -- start_date=''兼容性差
删除start_date=’’,修改成
-- ✅正确写法 删除start_date=''
start_date is null or start_date>=current_date
引入hisui方式支持
<script type="text/javascript" src="../../../base/scripts/hisui.js"></script>
实际引入了所有hisui相关js及css,也引入了websys.jquery.bsp.js
http://106.63.4.7:8000/his-mediway-java/his-document/-/tree/master/润乾打印
界面查看说明