常量修改

This commit is contained in:
Zhang.WH
2025-02-25 11:32:50 +08:00
parent 9e700b42c9
commit 10b44933ab
15 changed files with 229 additions and 278 deletions

View File

@@ -1,18 +1,52 @@
package com.openhis.common.constant;
/**
* 共通常量
* 常量
*
* @author system
*/
public class CommonConstants {
/**
* 租户ID字段名称
* 共同常量
*/
public static final String TENANT_ID = "tenant_id";
public interface Common {
/**
* 租户ID字段名称
*/
String TENANT_ID = "tenant_id";
public static final String S_TIME = "STime";
/**
* 开始时间(用于分页条件查询)
*/
String S_TIME = "STime";
public static final String E_TIME = "ETime";
/**
* 结束时间(用于分页条件查询)
*/
String E_TIME = "ETime";
}
/**
* 表名常量
*/
public interface TableName {
/**
* 服务管理
*/
String ADM_HEALTHCARE_SERVICE = "adm_healthcare_service";
}
/**
* 字段名常量
*/
public interface FieldName {
/**
* 业务编码
*/
String BusNo = "bus_no";
}
}

View File

@@ -1,52 +0,0 @@
package com.openhis.common.constant;
/**
* APL消息ID常量类
*/
public interface PromptMsgConstant {
/**
* 共用
*/
interface Common {
/**
* {0}添加成功
*/
String M00001 = "apl.common.M00001";
/**
* {0}保存成功
*/
String M00002 = "apl.common.M00002";
/**
* {0}已经存在
*/
String M00003 = "apl.common.M00003";
/**
* {0}操作成功
*/
String M00004 = "apl.common.M00004";
/**
* {0}删除成功
*/
String M00005 = "apl.common.M00005";
/**
* 操作失败,该数据已被他人删除,请刷新后重试
*/
String M00006 = "apl.common.M00006";
/**
* 操作失败,该数据已被他人更改,请刷新后重试
*/
String M00007 = "apl.common.M00007";
/**
* 请勿重复提交
*/
String M00008 = "apl.common.M00008";
/**
* 查询成功
*/
String M00009 = "apl.common.M00009";
}
}

View File

@@ -1,14 +0,0 @@
package com.openhis.common.constant;
/**
* 表名常量
*
* @author system
*/
public class TableNameConstants {
/**
* 服务管理
*/
public static final String ADM_HEALTHCARE_SERVICE = "adm_healthcare_service";
}

View File

@@ -1,11 +1,5 @@
package com.openhis.common.utils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.utils.DateUtils;
import com.core.common.utils.SecurityUtils;
import com.openhis.common.constant.CommonConstants;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -15,6 +9,13 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.utils.DateUtils;
import com.core.common.utils.SecurityUtils;
import com.openhis.common.constant.CommonConstants;
/**
* His查询工具类
*/
@@ -23,16 +24,17 @@ public class HisQueryUtils {
/**
* 条件查询构造器
*
* @param entity 传参实体
* @param searchKey 模糊查询关键字
* @param entity 传参实体
* @param searchKey 模糊查询关键字
* @param searchFields 支持模糊查询的字段集合 ; 不需要模糊查询传 null 即可
* @param request 请求
* @param request 请求
* @return 构造条件
*/
public static <T> QueryWrapper<T> buildQueryWrapper(T entity, String searchKey, HashSet<String> searchFields, HttpServletRequest request) {
public static <T> QueryWrapper<T> buildQueryWrapper(T entity, String searchKey, HashSet<String> searchFields,
HttpServletRequest request) {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
// 添加租户id查询条件
queryWrapper.eq(CommonConstants.TENANT_ID, getCurrentTenantId());
queryWrapper.eq(CommonConstants.Common.TENANT_ID, getCurrentTenantId());
if (entity == null) {
return queryWrapper;
}
@@ -43,7 +45,7 @@ public class HisQueryUtils {
try {
Object value = field.get(entity);
if (value != null && !value.toString().equals("")) {
//String fieldName = field.getName();
// String fieldName = field.getName();
// 将驼峰命名的字段名转换为下划线命名的数据库字段名
String fieldName = camelToUnderline(field.getName());
// 处理等于条件
@@ -68,14 +70,15 @@ public class HisQueryUtils {
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
String paramName = entry.getKey();
// 检查参数名是否以 "STime" 或 "ETime" 结尾
if (paramName.endsWith(CommonConstants.S_TIME) || paramName.endsWith(CommonConstants.E_TIME)) {
if (paramName.endsWith(CommonConstants.Common.S_TIME)
|| paramName.endsWith(CommonConstants.Common.E_TIME)) {
// 提取字段名(去掉 "STime" 或 "ETime" 后缀)
String fieldName = paramName.substring(0, paramName.length() - 5);
// 驼峰转下划线
String dbFieldName = camelToUnderline(fieldName);
// 获取对应的 STime 和 ETime 值
String startValue = getParameterValue(request, fieldName + CommonConstants.S_TIME);
String endValue = getParameterValue(request, fieldName + CommonConstants.E_TIME);
String startValue = getParameterValue(request, fieldName + CommonConstants.Common.S_TIME);
String endValue = getParameterValue(request, fieldName + CommonConstants.Common.E_TIME);
// 如果 Start 和 End 都有值,则添加时间段查询条件
if (startValue != null && endValue != null) {
try {
@@ -88,7 +91,7 @@ public class HisQueryUtils {
Date startDate = dateFormat.parse(startValue);
Date endDate = dateFormat.parse(endValue);
queryWrapper.ge(dbFieldName, startDate); // 大于等于 STime
queryWrapper.le(dbFieldName, endDate); // 小于等于 ETime
queryWrapper.le(dbFieldName, endDate); // 小于等于 ETime
} catch (ParseException e) {
e.printStackTrace();
}
@@ -102,7 +105,7 @@ public class HisQueryUtils {
* 检查时间字符串是否符合指定格式
*
* @param formatter 时间格式
* @param dateStr 时间字符串
* @param dateStr 时间字符串
* @return 是否匹配
*/
private static boolean isValidFormat(DateTimeFormatter formatter, String dateStr) {