feat: 新增水温接口
This commit is contained in:
parent
b856b39d9d
commit
337da0c445
@ -0,0 +1,59 @@
|
|||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用常量
|
||||||
|
*
|
||||||
|
* @author zwl
|
||||||
|
* @date 2023/07/13
|
||||||
|
*/
|
||||||
|
public interface CommonConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kendo 默认分组
|
||||||
|
*/
|
||||||
|
String DEFAULT = "default";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算标识
|
||||||
|
*/
|
||||||
|
String CALCULATE_FLAG = "calculateFlag";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算成功
|
||||||
|
*/
|
||||||
|
String CALCULATE_SUCCESS = "1";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时
|
||||||
|
*/
|
||||||
|
String HOUR = "HOUR";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天
|
||||||
|
*/
|
||||||
|
String DAY = "DAY";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 旬
|
||||||
|
*/
|
||||||
|
String TEN = "TEN";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月
|
||||||
|
*/
|
||||||
|
String MON = "MON";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 季
|
||||||
|
*/
|
||||||
|
String QUA = "QUA";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年
|
||||||
|
*/
|
||||||
|
String YEAR = "YEAR";
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
public interface CommonConstants {
|
||||||
|
String UTF_8 = "UTF-8";
|
||||||
|
String CONTENT_TYPE_NAME = "Content-type";
|
||||||
|
String CONTENT_TYPE = "application/json;charset=utf-8";
|
||||||
|
String TENANT_ID = "_TenantId";
|
||||||
|
String SYSTEM_ID = "_SysId";
|
||||||
|
String PROJECT_GROUP_ID = "_PgId";
|
||||||
|
String BELOND_PROJECT_ID = "_ProjectId";
|
||||||
|
String OLD_BELOND_PROJECT_ID = "_LoginProjectId";
|
||||||
|
String APPLICATION_ID = "_AppId";
|
||||||
|
String PLATFORM_ID = "_PlatformId";
|
||||||
|
String ISOLATE_LEVEL_CODE = "_IsolateLevelCode";
|
||||||
|
String ISOLATE_ID = "_IsolateId";
|
||||||
|
String TEMPLATE_ID = "_TemplateId";
|
||||||
|
String VERSION = "VERSION";
|
||||||
|
String DEFAULT_TENANT_ID = "00000000-0000-0000-0000-000000000000";
|
||||||
|
String DEFAULT_BELONG_PROJECT_ID = "00000000-0000-0000-0000-000000000000";
|
||||||
|
String DEFAULT_GUID = "00000000-0000-0000-0000-000000000000";
|
||||||
|
String STATUS_DEL = "1";
|
||||||
|
String STATUS_NORMAL = "0";
|
||||||
|
String DB_NOT_DELETED = "0";
|
||||||
|
String DB_IS_DELETED = "1";
|
||||||
|
String LOG_NORMAL_TYPE = "1";
|
||||||
|
String STATUS_LOCK = "9";
|
||||||
|
String MENU = "0";
|
||||||
|
Integer MENU_TREE_ROOT_ID = -1;
|
||||||
|
String UTF8 = "UTF-8";
|
||||||
|
String FRONT_END_PROJECT = "dec-ui";
|
||||||
|
String BACK_END_PROJECT = "dec";
|
||||||
|
String DEC_PUBLIC_PARAM_KEY = "DEC_PUBLIC_PARAM_KEY";
|
||||||
|
Integer SUCCESS = 0;
|
||||||
|
Integer FAIL = 1;
|
||||||
|
Integer YES = 1;
|
||||||
|
Integer NO = 0;
|
||||||
|
String BUCKET_NAME = "dec";
|
||||||
|
String DEFAULT_CROWN_CODE = "+86";
|
||||||
|
String DEFAULT_TIME_ZONE = "GMT+8";
|
||||||
|
|
||||||
|
public interface Symbol {
|
||||||
|
String SIGH = "!";
|
||||||
|
String AT = "@";
|
||||||
|
String WELL = "#";
|
||||||
|
String DOLLAR = "$";
|
||||||
|
String RMB = "¥";
|
||||||
|
String SPACE = " ";
|
||||||
|
String LB = System.getProperty("line.separator");
|
||||||
|
String PERCENTAGE = "%";
|
||||||
|
String AND = "&";
|
||||||
|
String STAR = "*";
|
||||||
|
String MIDDLE_LINE = "-";
|
||||||
|
String LOWER_LINE = "_";
|
||||||
|
String EQUAL = "=";
|
||||||
|
String PLUS = "+";
|
||||||
|
String COLON = ":";
|
||||||
|
String SEMICOLON = ";";
|
||||||
|
String COMMA = ",";
|
||||||
|
String POINT = ".";
|
||||||
|
String SLASH = "/";
|
||||||
|
String VERTICAL_BAR = "|";
|
||||||
|
String DOUBLE_SLASH = "//";
|
||||||
|
String BACKSLASH = "\\";
|
||||||
|
String QUESTION = "?";
|
||||||
|
String LEFT_BIG_BRACE = "{";
|
||||||
|
String RIGHT_BIG_BRACE = "}";
|
||||||
|
String LEFT_MIDDLE_BRACE = "[";
|
||||||
|
String RIGHT_MIDDLE_BRACE = "]";
|
||||||
|
String BACKQUOTE = "`";
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Digital {
|
||||||
|
int NEGATIVE_ONE = -1;
|
||||||
|
int ZERO = 0;
|
||||||
|
int ONE = 1;
|
||||||
|
int TWO = 2;
|
||||||
|
int FOUR = 4;
|
||||||
|
int EIGHT = 8;
|
||||||
|
int SIXTEEN = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Pattern {
|
||||||
|
String DATE = "yyyy-MM-dd";
|
||||||
|
String DATETIME = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
String DATETIME_MM = "yyyy-MM-dd HH:mm";
|
||||||
|
String DATETIME_SSS = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||||
|
String TIME = "HH:mm";
|
||||||
|
String TIME_SS = "HH:mm:ss";
|
||||||
|
String SYS_DATE = "yyyy/MM/dd";
|
||||||
|
String SYS_DATETIME = "yyyy/MM/dd HH:mm:ss";
|
||||||
|
String SYS_DATETIME_MM = "yyyy/MM/dd HH:mm";
|
||||||
|
String SYS_DATETIME_SSS = "yyyy/MM/dd HH:mm:ss.SSS";
|
||||||
|
String NONE_DATE = "yyyyMMdd";
|
||||||
|
String NONE_DATETIME = "yyyyMMddHHmmss";
|
||||||
|
String NONE_DATETIME_MM = "yyyyMMddHHmm";
|
||||||
|
String NONE_DATETIME_SSS = "yyyyMMddHHmmssSSS";
|
||||||
|
String CST_DATETIME = "EEE MMM dd HH:mm:ss 'CST' yyyy";
|
||||||
|
String NONE_DECIMAL = "0";
|
||||||
|
String ONE_DECIMAL = "0.0";
|
||||||
|
String TWO_DECIMAL = "0.00";
|
||||||
|
String TB_NONE_DECIMAL = "#,##0";
|
||||||
|
String TB_ONE_DECIMAL = "#,##0.0";
|
||||||
|
String TB_TWO_DECIMAL = "#,##0.00";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.yfd.platform.common.entity.baseInterface;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public interface ILogicalDeleteEntity<TKey> {
|
||||||
|
Boolean isDeleted();
|
||||||
|
|
||||||
|
Integer getIsDeleted();
|
||||||
|
|
||||||
|
void setIsDeleted(Integer isDeleted);
|
||||||
|
|
||||||
|
TKey getDeleteUser();
|
||||||
|
|
||||||
|
void setDeleteUser(TKey deleteUser);
|
||||||
|
|
||||||
|
Date getDeleteTime();
|
||||||
|
|
||||||
|
void setDeleteTime(Date deleteTime);
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.yfd.platform.common.entity.baseInterface;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public interface IModifyEntity<TKey> {
|
||||||
|
TKey getModifyUser();
|
||||||
|
|
||||||
|
void setModifyUser(TKey modifyUser);
|
||||||
|
|
||||||
|
Date getModifyTime();
|
||||||
|
|
||||||
|
void setModifyTime(Date modifyTime);
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.yfd.platform.common.entity.baseInterface;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public interface IRecordEntity<TKey> {
|
||||||
|
TKey getRecordUser();
|
||||||
|
|
||||||
|
void setRecordUser(TKey recordUser);
|
||||||
|
|
||||||
|
Date getRecordTime();
|
||||||
|
|
||||||
|
void setRecordTime(Date recordTime);
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package com.yfd.platform.common.enums;
|
||||||
|
|
||||||
|
import com.yfd.platform.common.exception.IResultCode;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用结果码枚举
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum ResultCodeEnum implements IResultCode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功
|
||||||
|
*/
|
||||||
|
SUCCESS(200, "success", "操作成功"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 失败
|
||||||
|
*/
|
||||||
|
FAILED(500, "failed", "操作失败"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数错误
|
||||||
|
*/
|
||||||
|
PARAM_ERROR(400, "param_error", "参数错误"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未授权
|
||||||
|
*/
|
||||||
|
UNAUTHORIZED(401, "unauthorized", "未授权"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁止访问
|
||||||
|
*/
|
||||||
|
FORBIDDEN(403, "forbidden", "禁止访问"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源不存在
|
||||||
|
*/
|
||||||
|
NOT_FOUND(404, "not_found", "资源不存在"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务异常
|
||||||
|
*/
|
||||||
|
BIZ_ERROR(500, "biz_error", "业务异常"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统异常
|
||||||
|
*/
|
||||||
|
SYSTEM_ERROR(500, "system_error", "系统异常"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务不可用
|
||||||
|
*/
|
||||||
|
SERVICE_UNAVAILABLE(503, "service_unavailable", "服务不可用");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误码
|
||||||
|
*/
|
||||||
|
private final int code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误key
|
||||||
|
*/
|
||||||
|
private final String errorKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误消息
|
||||||
|
*/
|
||||||
|
private final String message;
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.yfd.platform.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务异常类
|
||||||
|
*/
|
||||||
|
public class BizException extends DecException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private static final String DEFAULT_ERR_CODE = "biz_error";
|
||||||
|
|
||||||
|
public BizException(String message) {
|
||||||
|
super(DEFAULT_ERR_CODE, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(String message, Object... parameters) {
|
||||||
|
super(DEFAULT_ERR_CODE, message, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(int errorCode, Object... parameters) {
|
||||||
|
super(errorCode, DEFAULT_ERR_CODE, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(int errorCode, String message) {
|
||||||
|
super(errorCode, DEFAULT_ERR_CODE, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(String errorKey, String message) {
|
||||||
|
super(errorKey, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(IResultCode resultCode) {
|
||||||
|
super(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(IResultCode resultCode, Throwable cause) {
|
||||||
|
super(resultCode, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(String message, Throwable cause) {
|
||||||
|
super(DEFAULT_ERR_CODE, message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(String errorKey, String message, Throwable cause) {
|
||||||
|
super(errorKey, message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,109 @@
|
|||||||
|
package com.yfd.platform.common.exception;
|
||||||
|
|
||||||
|
import com.yfd.platform.common.CommonConstants;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础异常类
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class DecException extends RuntimeException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误码
|
||||||
|
*/
|
||||||
|
private int errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误key
|
||||||
|
*/
|
||||||
|
private String errorKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误消息
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public DecException(String errorKey, String message) {
|
||||||
|
super(message);
|
||||||
|
this.errorKey = errorKey;
|
||||||
|
this.message = message;
|
||||||
|
this.errorCode = CommonConstants.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(String errorKey, String message, Object... parameters) {
|
||||||
|
super(formatMessage(message, parameters));
|
||||||
|
this.errorKey = errorKey;
|
||||||
|
this.message = formatMessage(message, parameters);
|
||||||
|
this.errorCode = CommonConstants.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(int errorCode, String errorKey, Object... parameters) {
|
||||||
|
super(errorKey);
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorKey = errorKey;
|
||||||
|
this.message = formatMessage(errorKey, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(int errorCode, String errorKey, String message) {
|
||||||
|
super(message);
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorKey = errorKey;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(IResultCode resultCode) {
|
||||||
|
super(resultCode.getMessage());
|
||||||
|
this.errorCode = resultCode.getCode();
|
||||||
|
this.errorKey = resultCode.getErrorKey();
|
||||||
|
this.message = resultCode.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(IResultCode resultCode, Throwable cause) {
|
||||||
|
super(resultCode.getMessage(), cause);
|
||||||
|
this.errorCode = resultCode.getCode();
|
||||||
|
this.errorKey = resultCode.getErrorKey();
|
||||||
|
this.message = resultCode.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
this.errorCode = 500;
|
||||||
|
this.errorKey = "system_error";
|
||||||
|
this.message = cause.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(String errorKey, String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
this.errorKey = errorKey;
|
||||||
|
this.message = message;
|
||||||
|
this.errorCode = 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
this.errorKey = "system_error";
|
||||||
|
this.message = message;
|
||||||
|
this.errorCode = 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化消息
|
||||||
|
* @param message 消息模板
|
||||||
|
* @param parameters 参数
|
||||||
|
* @return 格式化后的消息
|
||||||
|
*/
|
||||||
|
private static String formatMessage(String message, Object... parameters) {
|
||||||
|
if (parameters == null || parameters.length == 0) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
String result = message;
|
||||||
|
for (Object param : parameters) {
|
||||||
|
result = result.replaceFirst("\\{\\}", String.valueOf(param != null ? param : "null"));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common.exception;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public interface IResultCode extends Serializable {
|
||||||
|
String getMessage();
|
||||||
|
|
||||||
|
int getCode();
|
||||||
|
|
||||||
|
String getErrorKey();
|
||||||
|
}
|
||||||
@ -54,6 +54,8 @@ public class SecurityConfig {
|
|||||||
.requestMatchers("/user/login").anonymous()
|
.requestMatchers("/user/login").anonymous()
|
||||||
.requestMatchers("/user/code").permitAll()
|
.requestMatchers("/user/code").permitAll()
|
||||||
.requestMatchers("/eng/**").permitAll()
|
.requestMatchers("/eng/**").permitAll()
|
||||||
|
.requestMatchers("/env/**").permitAll()
|
||||||
|
.requestMatchers("/sw/**").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, "/").permitAll()
|
.requestMatchers(HttpMethod.GET, "/").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET,
|
.requestMatchers(HttpMethod.GET,
|
||||||
"/*.html",
|
"/*.html",
|
||||||
|
|||||||
51
backend/src/main/java/com/yfd/platform/env/controller/SdAlongListController.java
vendored
Normal file
51
backend/src/main/java/com/yfd/platform/env/controller/SdAlongListController.java
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.yfd.platform.env.controller;
|
||||||
|
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.env.service.AlongListService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 沿程水温变化一级折线图
|
||||||
|
*
|
||||||
|
* @author lyl
|
||||||
|
* @date 2023/04/18 19:22
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sw/alongList")
|
||||||
|
@Tag(name = "沿程水温变化一级折线图")
|
||||||
|
@Validated
|
||||||
|
public class SdAlongListController{
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AlongListService alongListService;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping({"/limit"})
|
||||||
|
@Operation(summary = "获取流域沿程水温限值")
|
||||||
|
public ResponseResult getWtLimit(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(alongListService.getWtLimit(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/default/rvcd"})
|
||||||
|
@Operation(summary = "获取沿程水温变化默认有数据的河流")
|
||||||
|
public ResponseResult getDefaultStcd(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
|
||||||
|
return ResponseResult.successData(alongListService.getDefaultRvcd(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/qgc/GetKendoListCust"})
|
||||||
|
@Operation(summary = "按时间范围查询沿程水温站最新数据时间的数据")
|
||||||
|
public ResponseResult getALongKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(this.alongListService.getALongKendoListCust(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
54
backend/src/main/java/com/yfd/platform/env/entity/vo/SdAlongVO.java
vendored
Normal file
54
backend/src/main/java/com/yfd/platform/env/entity/vo/SdAlongVO.java
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package com.yfd.platform.env.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.FieldNameConstants;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@FieldNameConstants
|
||||||
|
@Schema(description = "沿程水温变化一级折线图VO")
|
||||||
|
public class SdAlongVO {
|
||||||
|
|
||||||
|
@Schema(description = "站码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "站名")
|
||||||
|
private String stnm;
|
||||||
|
|
||||||
|
@Schema(description = "电站编码")
|
||||||
|
private String rstcd;
|
||||||
|
|
||||||
|
@Schema(description = "水温")
|
||||||
|
private BigDecimal temperature;
|
||||||
|
|
||||||
|
@Schema(description = "类型:1:电站 2:测站")
|
||||||
|
private String sttp;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
private String tm;
|
||||||
|
|
||||||
|
@Schema(description = "最小时间")
|
||||||
|
private String minTm;
|
||||||
|
|
||||||
|
@Schema(description = "实测值水温")
|
||||||
|
private BigDecimal actualTemp;
|
||||||
|
|
||||||
|
@Schema(description = "去年同期水温")
|
||||||
|
private BigDecimal lastTemp;
|
||||||
|
|
||||||
|
@Schema(description = "天然水温")
|
||||||
|
private BigDecimal naturalTemp;
|
||||||
|
|
||||||
|
@Schema(description = "电站水温出库站")
|
||||||
|
private String engDwtCode;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
public static final String TYPE_ENG = "1";
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
public static final String TYPE_ENV = "2";
|
||||||
|
}
|
||||||
105
backend/src/main/java/com/yfd/platform/env/mapper/AlongListMapper.java
vendored
Normal file
105
backend/src/main/java/com/yfd/platform/env/mapper/AlongListMapper.java
vendored
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package com.yfd.platform.env.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.yfd.platform.env.entity.vo.SdAlongVO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 沿程水温变化一级数据接口
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2023-04-23 09:32:10
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AlongListMapper extends BaseMapper<SdAlongVO> {
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
"select to_char(max(TM),'yyyy-MM-dd HH24:mi:ss') tm from SD_WTRV_R " +
|
||||||
|
"where STCD in " +
|
||||||
|
"(select STCD from V_MS_STBPRP_T a " +
|
||||||
|
"where STTP_CODE='WTRV' " +
|
||||||
|
"and ENG_DWT_CODE is not null " +
|
||||||
|
"and IS_DELETED=0 " +
|
||||||
|
"and RSTCDSTEPSORT is not null " +
|
||||||
|
"<if test='rvcd != null and rvcd != \"\"'>" +
|
||||||
|
"and HBRVCD=#{rvcd} " +
|
||||||
|
"</if>" +
|
||||||
|
")" +
|
||||||
|
"</script>")
|
||||||
|
String getAlongLatestTm(@Param("rvcd") String rvcd);
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
"SELECT SARC.stcd, " +
|
||||||
|
"SARC.rstcd, " +
|
||||||
|
"MAB.RVCD, " +
|
||||||
|
"MAB.ORDER_INDEX AS rvcdSort, " +
|
||||||
|
"SARC.sort, " +
|
||||||
|
"CASE WHEN SARC.STTP = 'ENG' THEN '1' WHEN SARC.STTP = 'WTRV' THEN '2' END AS sttp, " +
|
||||||
|
"SWR.WT AS temperature, " +
|
||||||
|
"SWR.TM, " +
|
||||||
|
"SWR.TM AS minTm, " +
|
||||||
|
"MST.STNM " +
|
||||||
|
"FROM MS_ALONG_B MAB " +
|
||||||
|
"INNER JOIN MS_ALONGDET_B SARC ON MAB.ID = SARC.ALONG_ID " +
|
||||||
|
"INNER JOIN MS_STBPRP_T MST ON MST.stcd = SARC.STCD " +
|
||||||
|
"LEFT JOIN (" +
|
||||||
|
"SELECT * FROM SD_WTRV_R where is_deleted=0 " +
|
||||||
|
"<if test='maxTime != null'>" +
|
||||||
|
"and TM = #{maxTime} " +
|
||||||
|
"</if>" +
|
||||||
|
"<if test='maxTime == null'>" +
|
||||||
|
"and TM is null " +
|
||||||
|
"</if>" +
|
||||||
|
") SWR ON SWR.STCD = SARC.STCD " +
|
||||||
|
"WHERE MAB.CODE = 'common' " +
|
||||||
|
"AND (SARC.STTP = 'ENG' OR SARC.STTP = 'WTRV') " +
|
||||||
|
"AND SARC.IS_DELETED = 0 " +
|
||||||
|
"AND MST.IS_DELETED = 0 " +
|
||||||
|
"AND MAB.IS_DELETED = 0 " +
|
||||||
|
"<if test='rvcd != null and rvcd != \"\"'>" +
|
||||||
|
"and MAB.rvcd=#{rvcd} " +
|
||||||
|
"</if>" +
|
||||||
|
"<if test='baseId != null and baseId != \"\"'>" +
|
||||||
|
"and MAB.RVCD in (select WBS_CODE from SD_WBS_B where WBS_TYPE='PSB_RVCD' and is_deleted=0 and OBJ_ID=#{baseId}) " +
|
||||||
|
"</if>" +
|
||||||
|
"order by MAB.order_index asc, SARC.sort asc" +
|
||||||
|
"</script>")
|
||||||
|
List<SdAlongVO> getAlongListData(@Param("rvcd") String rvcd,@Param("baseId") String baseId,@Param("maxTime") Date maxTime);
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
"select TM from (" +
|
||||||
|
"SELECT MST.STCD, SWR.TM " +
|
||||||
|
"FROM MS_ALONG_B MAB " +
|
||||||
|
"INNER JOIN MS_ALONGDET_B SARC ON MAB.ID = SARC.ALONG_ID " +
|
||||||
|
"INNER JOIN MS_STBPRP_T MST ON MST.stcd = SARC.STCD " +
|
||||||
|
"INNER JOIN (" +
|
||||||
|
"select * from SD_WTRV_R where is_deleted = 0 " +
|
||||||
|
"<if test='startTime != null and endTime != null'>" +
|
||||||
|
"and tm between #{startTime} and #{endTime} " +
|
||||||
|
"</if>" +
|
||||||
|
") SWR ON SWR.STCD = SARC.STCD " +
|
||||||
|
"WHERE MAB.CODE = 'common' " +
|
||||||
|
"and MST.IS_DELETED=0 " +
|
||||||
|
"AND SARC.STTP = 'WTRV' " +
|
||||||
|
"AND SARC.IS_DELETED = 0 " +
|
||||||
|
"AND MAB.IS_DELETED = 0 " +
|
||||||
|
"<if test='rvcd != null and rvcd != \"\"'>" +
|
||||||
|
"and MAB.rvcd=#{rvcd} " +
|
||||||
|
"</if>" +
|
||||||
|
"<if test='baseId != null and baseId != \"\"'>" +
|
||||||
|
"and MAB.RVCD in (select WBS_CODE from SD_WBS_B where WBS_TYPE='PSB_RVCD' and is_deleted=0 and OBJ_ID=#{baseId}) " +
|
||||||
|
"</if>" +
|
||||||
|
"order by MAB.order_index asc, SARC.SORT asc, SWR.TM desc" +
|
||||||
|
") where ROWNUM=1" +
|
||||||
|
"</script>")
|
||||||
|
Date getMaxTime(@Param("rvcd") String rvcd,@Param("baseId") String baseId,@Param("startTime") Date startTime,@Param("endTime") Date endTime);
|
||||||
|
|
||||||
|
// List<SdAlongVO> getAvgAlongListData(@Param("rvcd") String rvcd,@Param("baseId") String baseId,@Param("startTime") Date startTime,@Param("endTime") Date endTime);
|
||||||
|
}
|
||||||
21
backend/src/main/java/com/yfd/platform/env/service/AlongListService.java
vendored
Normal file
21
backend/src/main/java/com/yfd/platform/env/service/AlongListService.java
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.yfd.platform.env.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 沿程水温变化一级折线图服务
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2023-04-23 09:32:10
|
||||||
|
*/
|
||||||
|
public interface AlongListService {
|
||||||
|
|
||||||
|
Map<String,Object> getWtLimit(DataSourceRequest dataSourceRequest);
|
||||||
|
DataSourceResult getDefaultRvcd(@RequestBody DataSourceRequest dataSourceRequest);
|
||||||
|
DataSourceResult getALongKendoListCust(DataSourceRequest dataSourceRequest);
|
||||||
|
}
|
||||||
147
backend/src/main/java/com/yfd/platform/env/service/impl/AlongListServiceImpl.java
vendored
Normal file
147
backend/src/main/java/com/yfd/platform/env/service/impl/AlongListServiceImpl.java
vendored
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
package com.yfd.platform.env.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.yfd.platform.common.DataSourceLoadOptionsBase;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.common.DynamicSQLMapper;
|
||||||
|
import com.yfd.platform.common.exception.BizException;
|
||||||
|
import com.yfd.platform.env.entity.vo.SdAlongVO;
|
||||||
|
import com.yfd.platform.env.mapper.AlongListMapper;
|
||||||
|
import com.yfd.platform.env.service.AlongListService;
|
||||||
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
|
import com.yfd.platform.utils.QueryWrapperUtil;
|
||||||
|
import com.yfd.platform.utils.SqlUtil;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 沿程水温一级数据接口服务
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2023-04-23 09:32:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AlongListServiceImpl extends ServiceImpl<AlongListMapper, SdAlongVO> implements AlongListService {
|
||||||
|
@Resource
|
||||||
|
private DynamicSQLMapper dynamicSQLMapper;
|
||||||
|
@Resource
|
||||||
|
private AlongListMapper alongListMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String,Object> getWtLimit(DataSourceRequest dataSourceRequest) {
|
||||||
|
String sql = "SELECT\n" +
|
||||||
|
"\tt2.MIN_VAL AS min,\n" +
|
||||||
|
"\tt2.MAX_VAL AS max\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
"\tMS_WARN_RULE_B t1\n" +
|
||||||
|
"INNER JOIN MS_WARN_RULE_DETAIL_B t2 ON\n" +
|
||||||
|
"\tt1.ID = t2.RULE_ID\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
"\tt1.RULE_TYPE = 'WTMN'";
|
||||||
|
List<Map<String,Object>> resultList = dynamicSQLMapper.getAllList(sql, null);
|
||||||
|
if(!CollectionUtils.isEmpty(resultList)){
|
||||||
|
return resultList.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult getDefaultRvcd(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult<Map<String, String>> dataSourceResult = new DataSourceResult<>();
|
||||||
|
String sqlTemplate ="\tSELECT RVCD FROM " +
|
||||||
|
"\t( SELECT RVCD,SORT FROM " +
|
||||||
|
"\t(select MAB.RVCD,SAB.STCD,CASE WHEN MAB.RVCD #{rvcd} THEN 0 ELSE 1 END AS SORT from MS_ALONG_B MAB inner join MS_ALONGDET_B SAB on SAB.ALONG_ID = MAB.ID WHERE SAB.IS_DELETED =0 AND MAB.IS_DELETED =0 AND SAB.STTP IN ('WTRV', 'ENG') and MAB.CODE='common') t1 " +
|
||||||
|
"\tINNER JOIN " +
|
||||||
|
"\t(SELECT WBS_CODE FROM SD_WBS_B WHERE wbs_type = 'PSB_RVCD' #{full_path} AND WBS_NAME IS NOT NULL) t2 " +
|
||||||
|
"\tON t1.RVCD = t2.WBS_CODE " +
|
||||||
|
"\tINNER JOIN " +
|
||||||
|
"\t(SELECT STCD FROM SD_WTRV_R WHERE TM >= #{tm} AND TM <= #{tm_1} AND WT IS NOT NULL ) t3 " +
|
||||||
|
"\tON t1.STCD = t3.STCD ORDER BY SORT ASC " +
|
||||||
|
"\t) WHERE ROWNUM = 1 ";
|
||||||
|
Map<String,Object> sqlWhereMap = new HashMap<>();
|
||||||
|
SqlUtil.getWhereCondition(dataSourceRequest,sqlWhereMap);
|
||||||
|
Object full_path = sqlWhereMap.get("full_path");
|
||||||
|
if(full_path !=null){
|
||||||
|
String fullPathStr = full_path.toString();
|
||||||
|
if(fullPathStr.startsWith("'") && fullPathStr.endsWith("'")){
|
||||||
|
fullPathStr = fullPathStr.substring(1,fullPathStr.length()-1);
|
||||||
|
}
|
||||||
|
sqlWhereMap.put("full_path","AND OBJ_ID = '"+fullPathStr+"'");
|
||||||
|
}else{
|
||||||
|
sqlWhereMap.put("full_path"," ");
|
||||||
|
}
|
||||||
|
Object rvcd = sqlWhereMap.get("rvcd");
|
||||||
|
if(rvcd == null || StringUtils.isBlank(rvcd.toString())){
|
||||||
|
sqlWhereMap.put("rvcd"," IS NOT NULL ");
|
||||||
|
}else{
|
||||||
|
sqlWhereMap.put("rvcd"," = "+rvcd);
|
||||||
|
}
|
||||||
|
String sql = SqlUtil.getSqlByTemplate(sqlTemplate, sqlWhereMap);
|
||||||
|
List<Map<String, String>> list = dynamicSQLMapper.pageAllList(null, sql, null);
|
||||||
|
dataSourceResult.setData(list);
|
||||||
|
dataSourceResult.setTotal(list.size());
|
||||||
|
return dataSourceResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult getALongKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult dataSourceResult = new DataSourceResult<>();
|
||||||
|
DataSourceLoadOptionsBase loadOptionsBase = dataSourceRequest.toDevRequest();
|
||||||
|
String rvcd = QgcQueryWrapperUtil.getFilterFieldValue(loadOptionsBase, "rvcd");
|
||||||
|
String baseId = QgcQueryWrapperUtil.getFilterFieldValue(loadOptionsBase,"baseId");
|
||||||
|
String tm = QgcQueryWrapperUtil.getFilterFieldValue(loadOptionsBase,"tm");
|
||||||
|
if(StrUtil.isBlank(tm)){
|
||||||
|
throw new BizException("时间(tm)不能为空.");
|
||||||
|
}
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date startTime = null;
|
||||||
|
Date endTime = null;
|
||||||
|
if(StrUtil.isNotBlank(tm)){
|
||||||
|
String[] ll=tm.split(",");
|
||||||
|
if(ll.length==2){
|
||||||
|
try{
|
||||||
|
Date st = sdf.parse(ll[0]);
|
||||||
|
Date et = sdf.parse(ll[1]);
|
||||||
|
if(st.after(et)){
|
||||||
|
startTime= et;
|
||||||
|
endTime=st;
|
||||||
|
}else {
|
||||||
|
startTime =st;endTime=et;
|
||||||
|
}
|
||||||
|
}catch (Exception ex){
|
||||||
|
log.error("日期格式错误! {}",ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Date maxTm = this.alongListMapper.getMaxTime(rvcd,baseId,startTime,endTime);
|
||||||
|
String maxTmStr;
|
||||||
|
if(maxTm!=null){
|
||||||
|
maxTmStr = sdf.format(maxTm);
|
||||||
|
} else {
|
||||||
|
maxTmStr = null;
|
||||||
|
}
|
||||||
|
List<SdAlongVO> alongVOList = this.alongListMapper.getAlongListData(rvcd,baseId,maxTm);
|
||||||
|
//过滤掉无水温测站关联的电站
|
||||||
|
Set<String> rstcdSet = alongVOList.stream().filter(sdAlongVO -> SdAlongVO.TYPE_ENV.equals(sdAlongVO.getSttp())).map(SdAlongVO::getRstcd).collect(Collectors.toSet());
|
||||||
|
alongVOList =alongVOList.stream().filter(sdAlongVO -> SdAlongVO.TYPE_ENV.equals(sdAlongVO.getSttp()) || rstcdSet.contains(sdAlongVO.getStcd())).collect(Collectors.toList());
|
||||||
|
alongVOList.forEach(it->{
|
||||||
|
it.setMinTm(maxTmStr);
|
||||||
|
it.setTm(maxTmStr);
|
||||||
|
});
|
||||||
|
dataSourceResult.setTotal(alongVOList.size());
|
||||||
|
dataSourceResult.setData(alongVOList);
|
||||||
|
return dataSourceResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
127
backend/src/main/java/com/yfd/platform/utils/SqlUtil.java
Normal file
127
backend/src/main/java/com/yfd/platform/utils/SqlUtil.java
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
package com.yfd.platform.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SqlUtil {
|
||||||
|
|
||||||
|
|
||||||
|
public static StringBuilder getWhereCondition(DataSourceRequest dataSourceRequest, Map<String, Object> sqlWhereMap) {
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
DataSourceRequest.FilterDescriptor filterDescriptor = dataSourceRequest.getFilter();
|
||||||
|
String logic = filterDescriptor.getLogic();
|
||||||
|
for (DataSourceRequest.FilterDescriptor filter : filterDescriptor.getFilters()) {
|
||||||
|
StringBuilder keyStr = new StringBuilder();
|
||||||
|
String field = filter.getField();
|
||||||
|
field = StrUtil.toUnderlineCase(field);
|
||||||
|
Object value = filter.getValue();
|
||||||
|
String operator = filter.getOperator();
|
||||||
|
String dataType = filter.getDataType();
|
||||||
|
if (StringUtils.isBlank(dataType)) {
|
||||||
|
dataType = "string";
|
||||||
|
}
|
||||||
|
//value值不为空并且operator不是isnull和isnotnull,则忽略。
|
||||||
|
if ((value == null || StringUtils.isBlank(value.toString())) && !("isnull").equals(operator) && !("isnotnull").equals(operator)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
keyStr.append(String.format(" %s %s", logic, field));
|
||||||
|
if ("date".equals(dataType)) {
|
||||||
|
if (String.valueOf(value).length() == 10) {
|
||||||
|
value = value + " 00:00:00";
|
||||||
|
}
|
||||||
|
value = "TO_DATE('" + value + "'," + "'YYYY-MM-DD HH24:MI:SS'" + ")";
|
||||||
|
}
|
||||||
|
if ("string".equals(dataType)) {
|
||||||
|
value = "'" + value + "'";
|
||||||
|
}
|
||||||
|
switch (filter.getOperator()) {
|
||||||
|
case "eq":
|
||||||
|
operator = "=";
|
||||||
|
break;
|
||||||
|
case "ne":
|
||||||
|
operator = "!=";
|
||||||
|
break;
|
||||||
|
case "isnull":
|
||||||
|
operator = "is null";
|
||||||
|
break;
|
||||||
|
case "isnotnull":
|
||||||
|
operator = "is not null";
|
||||||
|
break;
|
||||||
|
case "lt":
|
||||||
|
operator = "<";
|
||||||
|
break;
|
||||||
|
case "lte":
|
||||||
|
operator = "<=";
|
||||||
|
break;
|
||||||
|
case "ge":
|
||||||
|
operator = ">";
|
||||||
|
break;
|
||||||
|
case "gte":
|
||||||
|
operator = ">=";
|
||||||
|
break;
|
||||||
|
case "contains":
|
||||||
|
operator = "like";
|
||||||
|
value = "'%" + filter.getValue() + "%'";
|
||||||
|
break;
|
||||||
|
case "in":
|
||||||
|
operator = "in";
|
||||||
|
value = "(" + getInCondition(filter.getValue().toString()) + ")";
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
keyStr.append(String.format(" %s ", operator));
|
||||||
|
StringBuffer sqlBuffer = new StringBuffer();
|
||||||
|
sqlBuffer.append(keyStr).append(value);
|
||||||
|
if ("or".equalsIgnoreCase(filterDescriptor.getLogic())) {
|
||||||
|
sb.append(String.format("%s%s%s", " or (", sqlBuffer, ")"));
|
||||||
|
} else {
|
||||||
|
sb.append(sqlBuffer);
|
||||||
|
if (sqlWhereMap != null) {
|
||||||
|
if (sqlWhereMap.containsKey(field)) {
|
||||||
|
field = field + "_1";
|
||||||
|
}
|
||||||
|
sqlWhereMap.put(field, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getInCondition(String value) {
|
||||||
|
if (value.startsWith("[") && value.endsWith("]")) {
|
||||||
|
value = value.substring(1, value.length() - 1);
|
||||||
|
}
|
||||||
|
List<String> valueList = Arrays.asList(value.split(","));
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < valueList.size(); i++) {
|
||||||
|
sb.append("'").append(valueList.get(i).trim()).append("'");
|
||||||
|
if (i != valueList.size() - 1) {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSqlByTemplate(String sqlTemplate, Map<String, Object> paramMap) {
|
||||||
|
if (StringUtils.isBlank(sqlTemplate) || MapUtil.isEmpty(paramMap)) {
|
||||||
|
return sqlTemplate;
|
||||||
|
}
|
||||||
|
for(String key : paramMap.keySet()){
|
||||||
|
String value = paramMap.get(key).toString();
|
||||||
|
String replcaeKey = "#{"+key+"}";
|
||||||
|
sqlTemplate = sqlTemplate.replace(replcaeKey,value);
|
||||||
|
|
||||||
|
}
|
||||||
|
return sqlTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDateFormat(String date){
|
||||||
|
return " TO_DATE('"+date+"','YYYY-MM-DD HH24:MI:SS') ";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user