常量修改

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,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) {