删除 BaseConstants.java,常量内联到各调用处
This commit is contained in:
@@ -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);
|
|
||||||
}};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
+3
-4
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.gis.xian.config.DataSource;
|
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.EarthquakeCenterDTO;
|
||||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeTriggerDTO;
|
import com.gis.xian.dto.qgis.earthquake.EarthquakeTriggerDTO;
|
||||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeEvent;
|
import com.gis.xian.entity.qgis.earthquake.EarthquakeEvent;
|
||||||
@@ -41,7 +40,7 @@ public class EarthquakeEventServiceImpl extends ServiceImpl<EarthquakeEventMappe
|
|||||||
public EarthquakeQuery trigger(EarthquakeTriggerDTO trigger) {
|
public EarthquakeQuery trigger(EarthquakeTriggerDTO trigger) {
|
||||||
log.info("地震参数:{}", trigger);
|
log.info("地震参数:{}", trigger);
|
||||||
if (trigger == null) {
|
if (trigger == null) {
|
||||||
throw new ParmaException(BaseConstants.PARAMS_ERROR);
|
throw new ParmaException("参数有误,请重新传入!");
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = BaseUtils.generationCode(trigger.getEqTime());
|
String code = BaseUtils.generationCode(trigger.getEqTime());
|
||||||
@@ -58,7 +57,7 @@ public class EarthquakeEventServiceImpl extends ServiceImpl<EarthquakeEventMappe
|
|||||||
log.info("地震基本信息已存库...");
|
log.info("地震基本信息已存库...");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error(ex.getMessage());
|
log.error(ex.getMessage());
|
||||||
throw new ServeException(BaseConstants.EQ_SERVER_ERROR);
|
throw new ServeException("地震业务出错!");
|
||||||
}
|
}
|
||||||
|
|
||||||
String batch = BaseUtils.generationBatchCode(code);
|
String batch = BaseUtils.generationBatchCode(code);
|
||||||
@@ -69,7 +68,7 @@ public class EarthquakeEventServiceImpl extends ServiceImpl<EarthquakeEventMappe
|
|||||||
@Override
|
@Override
|
||||||
public Boolean deletedById(Long Id) {
|
public Boolean deletedById(Long Id) {
|
||||||
if (Id == null) {
|
if (Id == null) {
|
||||||
throw new ParmaException(BaseConstants.PARAMS_ERROR);
|
throw new ParmaException("参数有误,请重新传入!");
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<EarthquakeEvent> lambdaQuery = Wrappers.lambdaQuery(EarthquakeEvent.class);
|
LambdaQueryWrapper<EarthquakeEvent> lambdaQuery = Wrappers.lambdaQuery(EarthquakeEvent.class);
|
||||||
lambdaQuery.eq(EarthquakeEvent::getId, Id);
|
lambdaQuery.eq(EarthquakeEvent::getId, Id);
|
||||||
|
|||||||
+2
-3
@@ -2,7 +2,6 @@ package com.gis.xian.service.qgis.earthquake.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.gis.xian.config.DataSource;
|
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.EarthquakeCenterDTO;
|
||||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeCenter;
|
import com.gis.xian.entity.qgis.earthquake.EarthquakeCenter;
|
||||||
import com.gis.xian.mapper.qgis.earthquake.EarthquakeCenterMapper;
|
import com.gis.xian.mapper.qgis.earthquake.EarthquakeCenterMapper;
|
||||||
@@ -31,7 +30,7 @@ public class EarthquakeInformationCenterServiceImpl extends ServiceImpl<Earthqua
|
|||||||
public void handle(EarthquakeCenterDTO dzxxdto) {
|
public void handle(EarthquakeCenterDTO dzxxdto) {
|
||||||
// 抛出异常
|
// 抛出异常
|
||||||
if (dzxxdto == null) {
|
if (dzxxdto == null) {
|
||||||
throw new ParmaException(BaseConstants.PARAMS_ERROR);
|
throw new ParmaException("参数有误,请重新传入!");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -50,7 +49,7 @@ public class EarthquakeInformationCenterServiceImpl extends ServiceImpl<Earthqua
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("地震触发:震中位置信息保存失败!", ex.getMessage());
|
log.error("地震触发:震中位置信息保存失败!", ex.getMessage());
|
||||||
ex.printStackTrace();
|
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.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.gis.xian.config.DataSource;
|
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.RainEventDTO;
|
||||||
import com.gis.xian.dto.qgis.rain.RainTriggerDTO;
|
import com.gis.xian.dto.qgis.rain.RainTriggerDTO;
|
||||||
import com.gis.xian.entity.qgis.rain.RainEvent;
|
import com.gis.xian.entity.qgis.rain.RainEvent;
|
||||||
@@ -41,7 +40,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
|
|||||||
public RainQuery trigger(RainTriggerDTO trigger) {
|
public RainQuery trigger(RainTriggerDTO trigger) {
|
||||||
log.info("暴雨参数:{}", trigger);
|
log.info("暴雨参数:{}", trigger);
|
||||||
if (trigger == null) {
|
if (trigger == null) {
|
||||||
throw new ParmaException(BaseConstants.PARAMS_ERROR);
|
throw new ParmaException("参数有误,请重新传入!");
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = BaseUtils.generationRainCode(trigger.getOccurrenceTime());
|
String code = BaseUtils.generationRainCode(trigger.getOccurrenceTime());
|
||||||
@@ -54,7 +53,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
|
|||||||
handle(eventdto);
|
handle(eventdto);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error(ex.getMessage());
|
log.error(ex.getMessage());
|
||||||
throw new ServeException(BaseConstants.RAIN_SERVER_ERROR);
|
throw new ServeException("暴雨业务出错!");
|
||||||
}
|
}
|
||||||
|
|
||||||
String batch = BaseUtils.generationBatchCode(code);
|
String batch = BaseUtils.generationBatchCode(code);
|
||||||
@@ -65,7 +64,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
|
|||||||
@Override
|
@Override
|
||||||
public Boolean deletedById(Long Id) {
|
public Boolean deletedById(Long Id) {
|
||||||
if (Id == null) {
|
if (Id == null) {
|
||||||
throw new ParmaException(BaseConstants.PARAMS_ERROR);
|
throw new ParmaException("参数有误,请重新传入!");
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<RainEvent> lambdaQuery = Wrappers.lambdaQuery(RainEvent.class);
|
LambdaQueryWrapper<RainEvent> lambdaQuery = Wrappers.lambdaQuery(RainEvent.class);
|
||||||
lambdaQuery.eq(RainEvent::getId, Id);
|
lambdaQuery.eq(RainEvent::getId, Id);
|
||||||
@@ -74,7 +73,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
|
|||||||
|
|
||||||
private void handle(RainEventDTO eventdto) {
|
private void handle(RainEventDTO eventdto) {
|
||||||
if (eventdto == null) {
|
if (eventdto == null) {
|
||||||
throw new ParmaException(BaseConstants.PARAMS_ERROR);
|
throw new ParmaException("参数有误,请重新传入!");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
RainEvent revent = new RainEvent();
|
RainEvent revent = new RainEvent();
|
||||||
@@ -89,7 +88,7 @@ public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent
|
|||||||
log.info("暴雨基本信息已存库...");
|
log.info("暴雨基本信息已存库...");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("暴雨触发:暴雨基本信息保存失败!", ex.getMessage());
|
log.error("暴雨触发:暴雨基本信息保存失败!", ex.getMessage());
|
||||||
throw new ServiceException(BaseConstants.RAIN_SERVER_ERROR);
|
throw new ServiceException("暴雨业务出错!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.gis.xian.utils;
|
package com.gis.xian.utils;
|
||||||
|
|
||||||
import com.gis.xian.constant.BaseConstants;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
@@ -16,7 +14,7 @@ public class BaseUtils {
|
|||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||||
String timestamp = time.format(formatter);
|
String timestamp = time.format(formatter);
|
||||||
String code = "T" + timestamp + BaseConstants.CITY_CODE;
|
String code = "T" + timestamp + "511800";
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
@@ -54,7 +52,7 @@ public class BaseUtils {
|
|||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||||
String timestamp = time.format(formatter);
|
String timestamp = time.format(formatter);
|
||||||
String code = "R" + timestamp + BaseConstants.CITY_CODE;
|
String code = "R" + timestamp + "511800";
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
@@ -62,9 +60,9 @@ public class BaseUtils {
|
|||||||
// 计算评估进度 0:地震、1:暴雨
|
// 计算评估进度 0:地震、1:暴雨
|
||||||
public static double compute(int finish, int type) {
|
public static double compute(int finish, int type) {
|
||||||
if (type == 0) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user