删除 BaseConstants.java,常量内联到各调用处

This commit is contained in:
wzy-warehouse
2026-06-18 18:13:46 +08:00
parent a7c4615227
commit b6bdc913ec
5 changed files with 14 additions and 121 deletions
@@ -1,102 +0,0 @@
package com.gis.xian.constant;
import java.util.HashMap;
import java.util.Map;
/**
* @author zzw
* @description: 公共常量类
* @date 2026/5/25 下午5:30
*/
public class BaseConstants {
// 提示语
public static final String PARAMS_ERROR = "参数有误,请重新传入!";
public static final String RESULT_ERROR = "结果空值!";
public static final String QUEUE_ID_ERROR = "queueId不能为空!";
public static final String PRODUCTS_ERROR = "获取产品失败!";
public static final String POM_ERROR = "经纬度坐标错误!";
public static final String EQ_SERVER_ERROR = "地震业务出错!";
public static final String RAIN_SERVER_ERROR = "暴雨业务出错!";
public static final String ASSESS_SERVER_ERROR = "评估业务出错!";
public static final String INFLUENCE_CONVERT_ERROR = "影响场转换GeoJson出错!";
public static final String UPLOAD_FAILED = "文件上传失败";
public static final String FILE_NOT_FOUND_ERROR = "文件不存在";
public static final String EQ_DISASTER_MAP = "地震专题图";
public static final String RAIN_DISASTER_MAP = "暴雨专题图";
public static final String EQ_DISASTER_DOCUMENT = "地震评估文档";
public static final String RAIN_DISASTER_DOCUMENT = "暴雨评估文档";
public static final String THEMATIC_FAILED = "专题图获取失败";
public static final String FILE_FAILED = "评估报告获取失败";
// 功能常量
public static final int TOKEN_EXPIRED = 30; // token过期时间
public static final String AUTH_USERNAME = "authorize_user"; // 授权用户名
public static final String AUTH_PWD = "ApiOpen#123";
public static final int NUM_VERTICES = 100; // 椭圆边缘顶点数
public static final String CITY_CODE = "511800"; // 西安市行政编码
public static final Integer AUTOMATIC = 0; // 自动
public static final Integer MANUAL = 1; // 手动
public static final Integer EQ_TOTAL_FILES = 20; // 38张地震专题图(A3、A4) + 1个影响场文件
public static final Integer RAIN_TOTAL_FILES = 15; // 30张地震专题图(A3、A4)
public static final Map<Integer, String> SEISMIC_INTENSITY_MAPPING = new HashMap<Integer, String>() // 烈度映射
{{
put(4, "");
put(5, "");
put(6, "");
put(7, "");
put(8, "");
put(9, "");
put(10, "");
put(11, "");
put(12, "");
}};
public static final Map<String, String> ADMINISTRATIVE_CODE = new HashMap<String, String>() {{ // 西安行政区划代码
put("新城区", "610102");
put("碑林区", "610103");
put("莲湖区", "610104");
put("雁塔区", "610113");
put("灞桥区", "610111");
put("未央区", "610112");
put("阎良区", "610114");
put("临潼区", "610115");
put("长安区", "610116");
put("高陵区", "610117");
put("鄠邑区", "610118");
put("蓝田县", "610122");
put("周至县", "610124");
}};
// RabbitMQ 常量
public final static String MAPS_QUEUE = "maps"; // 专题图类队列
public final static String DOCUMENTS_QUEUE = "documents"; // 文档类队列
public final static String DLQ_QUEUE = "dlq"; // 死信队列
public final static String ASSESS_EXCHANGE = "assess"; // 定义普通交换机名称
public final static String DLX_EXCHANGE = "dlx"; // 定义普通交换机名称
// 制图参数常量
public final static String MAP_LAYOUT_A3 = "A3"; // A3 画幅尺寸
public final static String MAP_LAYOUT_A4 = "A4"; // A4 画幅尺寸
public final static String MAP_UNIT = "制图单位:西安市应急管理局";
public final static String MAP_TIME = "制图时间:";
public final static String EQ_TEST = "(测试地震)";
public final static String EQ_NORMAL = "(真实地震)";
public final static String EQ_EXERCISE = "(演练地震)";
public final static String RAIN_TEST = "(测试降雨)";
public final static String RAIN_NORMAL = "(真实降雨)";
public final static String RAIN_EXERCISE = "(演练降雨)";
public static final Map<String, String> EQ_TYPE = new HashMap<String, String>() // 地震类型映射
{{
put("T", EQ_TEST);
put("Z", EQ_NORMAL);
put("Y", EQ_EXERCISE);
}};
public static final Map<String, String> RAIN_TYPE = new HashMap<String, String>() // 暴雨类型映射
{{
put("T", RAIN_TEST);
put("Z", RAIN_NORMAL);
put("Y", RAIN_EXERCISE);
}};
}
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gis.xian.config.DataSource;
import com.gis.xian.constant.BaseConstants;
import com.gis.xian.dto.qgis.earthquake.EarthquakeCenterDTO;
import com.gis.xian.dto.qgis.earthquake.EarthquakeTriggerDTO;
import com.gis.xian.entity.qgis.earthquake.EarthquakeEvent;
@@ -41,7 +40,7 @@ public class EarthquakeEventServiceImpl extends ServiceImpl<EarthquakeEventMappe
public EarthquakeQuery trigger(EarthquakeTriggerDTO trigger) {
log.info("地震参数:{}", trigger);
if (trigger == null) {
throw new ParmaException(BaseConstants.PARAMS_ERROR);
throw new ParmaException("参数有误,请重新传入!");
}
String code = BaseUtils.generationCode(trigger.getEqTime());
@@ -58,7 +57,7 @@ public class EarthquakeEventServiceImpl extends ServiceImpl<EarthquakeEventMappe
log.info("地震基本信息已存库...");
} catch (Exception ex) {
log.error(ex.getMessage());
throw new ServeException(BaseConstants.EQ_SERVER_ERROR);
throw new ServeException("地震业务出错!");
}
String batch = BaseUtils.generationBatchCode(code);
@@ -69,7 +68,7 @@ public class EarthquakeEventServiceImpl extends ServiceImpl<EarthquakeEventMappe
@Override
public Boolean deletedById(Long Id) {
if (Id == null) {
throw new ParmaException(BaseConstants.PARAMS_ERROR);
throw new ParmaException("参数有误,请重新传入!");
}
LambdaQueryWrapper<EarthquakeEvent> lambdaQuery = Wrappers.lambdaQuery(EarthquakeEvent.class);
lambdaQuery.eq(EarthquakeEvent::getId, Id);
@@ -2,7 +2,6 @@ package com.gis.xian.service.qgis.earthquake.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gis.xian.config.DataSource;
import com.gis.xian.constant.BaseConstants;
import com.gis.xian.dto.qgis.earthquake.EarthquakeCenterDTO;
import com.gis.xian.entity.qgis.earthquake.EarthquakeCenter;
import com.gis.xian.mapper.qgis.earthquake.EarthquakeCenterMapper;
@@ -31,7 +30,7 @@ public class EarthquakeInformationCenterServiceImpl extends ServiceImpl<Earthqua
public void handle(EarthquakeCenterDTO dzxxdto) {
// 抛出异常
if (dzxxdto == null) {
throw new ParmaException(BaseConstants.PARAMS_ERROR);
throw new ParmaException("参数有误,请重新传入!");
}
try {
@@ -50,7 +49,7 @@ public class EarthquakeInformationCenterServiceImpl extends ServiceImpl<Earthqua
} catch (Exception ex) {
log.error("地震触发:震中位置信息保存失败!", ex.getMessage());
ex.printStackTrace();
throw new ServiceException(BaseConstants.EQ_SERVER_ERROR);
throw new ServiceException("地震业务出错!");
}
}
}
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gis.xian.config.DataSource;
import com.gis.xian.constant.BaseConstants;
import com.gis.xian.dto.qgis.rain.RainEventDTO;
import com.gis.xian.dto.qgis.rain.RainTriggerDTO;
import com.gis.xian.entity.qgis.rain.RainEvent;
@@ -41,7 +40,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
public RainQuery trigger(RainTriggerDTO trigger) {
log.info("暴雨参数:{}", trigger);
if (trigger == null) {
throw new ParmaException(BaseConstants.PARAMS_ERROR);
throw new ParmaException("参数有误,请重新传入!");
}
String code = BaseUtils.generationRainCode(trigger.getOccurrenceTime());
@@ -54,7 +53,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
handle(eventdto);
} catch (Exception ex) {
log.error(ex.getMessage());
throw new ServeException(BaseConstants.RAIN_SERVER_ERROR);
throw new ServeException("暴雨业务出错!");
}
String batch = BaseUtils.generationBatchCode(code);
@@ -65,7 +64,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
@Override
public Boolean deletedById(Long Id) {
if (Id == null) {
throw new ParmaException(BaseConstants.PARAMS_ERROR);
throw new ParmaException("参数有误,请重新传入!");
}
LambdaQueryWrapper<RainEvent> lambdaQuery = Wrappers.lambdaQuery(RainEvent.class);
lambdaQuery.eq(RainEvent::getId, Id);
@@ -74,7 +73,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
private void handle(RainEventDTO eventdto) {
if (eventdto == null) {
throw new ParmaException(BaseConstants.PARAMS_ERROR);
throw new ParmaException("参数有误,请重新传入!");
}
try {
RainEvent revent = new RainEvent();
@@ -89,7 +88,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
log.info("暴雨基本信息已存库...");
} catch (Exception ex) {
log.error("暴雨触发:暴雨基本信息保存失败!", ex.getMessage());
throw new ServiceException(BaseConstants.RAIN_SERVER_ERROR);
throw new ServiceException("暴雨业务出错!");
}
}
}
@@ -1,7 +1,5 @@
package com.gis.xian.utils;
import com.gis.xian.constant.BaseConstants;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -16,7 +14,7 @@ public class BaseUtils {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String timestamp = time.format(formatter);
String code = "T" + timestamp + BaseConstants.CITY_CODE;
String code = "T" + timestamp + "511800";
return code;
}
@@ -54,7 +52,7 @@ public class BaseUtils {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String timestamp = time.format(formatter);
String code = "R" + timestamp + BaseConstants.CITY_CODE;
String code = "R" + timestamp + "511800";
return code;
}
@@ -62,9 +60,9 @@ public class BaseUtils {
// 计算评估进度 0:地震、1:暴雨
public static double compute(int finish, int type) {
if (type == 0) {
return (double) finish / BaseConstants.EQ_TOTAL_FILES * 100;
return (double) finish / 20 * 100;
}
return (double) finish / BaseConstants.RAIN_TOTAL_FILES * 100;
return (double) finish / 15 * 100;
}
}