bihuisong пре 1 година
родитељ
комит
3e529fb474
21 измењених фајлова са 972 додато и 364 уклоњено
  1. 2 0
      src/main/java/com/sooka/sponest/songhuahu/SookaSonghuahuApplication.java
  2. 179 0
      src/main/java/com/sooka/sponest/songhuahu/constant/Constants.java
  3. 195 100
      src/main/java/com/sooka/sponest/songhuahu/exchange/controller/ExchangeController.java
  4. 92 0
      src/main/java/com/sooka/sponest/songhuahu/exchange/domian/ActiveGpsData.java
  5. 19 0
      src/main/java/com/sooka/sponest/songhuahu/exchange/domian/GPSEquipment.java
  6. 99 0
      src/main/java/com/sooka/sponest/songhuahu/exchange/domian/ShipSaveDTO.java
  7. 243 0
      src/main/java/com/sooka/sponest/songhuahu/redis/RedisCache.java
  8. 35 0
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/RemoteSonghuahuServiceFallbackFactory.java
  9. 0 36
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/auth/RemoteAuthBaseServiceFallbackFactory.java
  10. 0 19
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/data/RemoteDataBaseServiceFallbackFactory.java
  11. 0 40
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/event/RemoteEventBaseServiceFallbackFactory.java
  12. 0 53
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/system/RemoteSystemBaseServiceFallbackFactory.java
  13. 37 0
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/RemoteSonghuahuService.java
  14. 0 25
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/auth/RemoteAuthBaseService.java
  15. 0 16
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/data/RemoteDataBaseService.java
  16. 0 29
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/event/RemoteEventBaseService.java
  17. 0 44
      src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/system/RemoteSystemService.java
  18. 52 0
      src/main/java/com/sooka/sponest/songhuahu/util/MD5Encryptor.java
  19. 17 0
      src/main/java/com/sooka/sponest/songhuahu/util/URLEncodeExampleUtil.java
  20. 1 1
      src/main/resources/banner.txt
  21. 1 1
      src/main/resources/bootstrap.yml

+ 2 - 0
src/main/java/com/sooka/sponest/songhuahu/SookaSonghuahuApplication.java

@@ -8,6 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.boot.web.servlet.MultipartConfigFactory;
 import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.util.unit.DataSize;
 
 import javax.servlet.MultipartConfigElement;
@@ -15,6 +16,7 @@ import javax.servlet.MultipartConfigElement;
 @EnableCustomConfig
 @EnableCustomSwagger2
 @EnableRyFeignClients
+@EnableScheduling
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
 public class SookaSonghuahuApplication {
     public static void main(String[] args) {

+ 179 - 0
src/main/java/com/sooka/sponest/songhuahu/constant/Constants.java

@@ -0,0 +1,179 @@
+package com.sooka.sponest.songhuahu.constant;
+
+import io.jsonwebtoken.Claims;
+
+import java.util.Locale;
+
+/**
+ * 通用常量信息
+ * 
+ * @author ruoyi
+ */
+public class Constants
+{
+    /**
+     * UTF-8 字符集
+     */
+    public static final String UTF8 = "UTF-8";
+
+    /**
+     * GBK 字符集
+     */
+    public static final String GBK = "GBK";
+
+    /**
+     * 系统语言
+     */
+    public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE;
+
+    /**
+     * www主域
+     */
+    public static final String WWW = "www.";
+
+    /**
+     * http请求
+     */
+    public static final String HTTP = "http://";
+
+    /**
+     * https请求
+     */
+    public static final String HTTPS = "https://";
+
+    /**
+     * 通用成功标识
+     */
+    public static final String SUCCESS = "0";
+
+    /**
+     * 通用失败标识
+     */
+    public static final String FAIL = "1";
+
+    /**
+     * 登录成功
+     */
+    public static final String LOGIN_SUCCESS = "Success";
+
+    /**
+     * 注销
+     */
+    public static final String LOGOUT = "Logout";
+
+    /**
+     * 注册
+     */
+    public static final String REGISTER = "Register";
+
+    /**
+     * 登录失败
+     */
+    public static final String LOGIN_FAIL = "Error";
+
+    /**
+     * 所有权限标识
+     */
+    public static final String ALL_PERMISSION = "*:*:*";
+
+    /**
+     * 管理员角色权限标识
+     */
+    public static final String SUPER_ADMIN = "admin";
+
+    /**
+     * 角色权限分隔符
+     */
+    public static final String ROLE_DELIMETER = ",";
+
+    /**
+     * 权限标识分隔符
+     */
+    public static final String PERMISSION_DELIMETER = ",";
+
+    /**
+     * 验证码有效期(分钟)
+     */
+    public static final Integer CAPTCHA_EXPIRATION = 2;
+
+    /**
+     * GPS获取令牌间隔时间(分钟)
+     */
+    public static final Integer GPS_ACCESS_TOKEN_EXPIRATION = 240;
+
+    /**
+     * 令牌
+     */
+    public static final String TOKEN = "token";
+
+    /**
+     * 令牌前缀
+     */
+    public static final String TOKEN_PREFIX = "Bearer ";
+
+    /**
+     * 令牌前缀
+     */
+    public static final String LOGIN_USER_KEY = "login_user_key";
+
+    /**
+     * 用户ID
+     */
+    public static final String JWT_USERID = "userid";
+
+    /**
+     * 用户名称
+     */
+    public static final String JWT_USERNAME = Claims.SUBJECT;
+
+    /**
+     * 用户头像
+     */
+    public static final String JWT_AVATAR = "avatar";
+
+    /**
+     * 创建时间
+     */
+    public static final String JWT_CREATED = "created";
+
+    /**
+     * 用户权限
+     */
+    public static final String JWT_AUTHORITIES = "authorities";
+
+    /**
+     * 资源映射路径 前缀
+     */
+    public static final String RESOURCE_PREFIX = "/profile";
+
+    /**
+     * RMI 远程方法调用
+     */
+    public static final String LOOKUP_RMI = "rmi:";
+
+    /**
+     * LDAP 远程方法调用
+     */
+    public static final String LOOKUP_LDAP = "ldap:";
+
+    /**
+     * LDAPS 远程方法调用
+     */
+    public static final String LOOKUP_LDAPS = "ldaps:";
+
+    /**
+     * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
+     */
+    public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.songhua" };
+
+    /**
+     * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
+     */
+    public static final String[] JOB_WHITELIST_STR = { "com.songhua.quartz.task", "com.songhua.web.quzrtz" };
+
+    /**
+     * 定时任务违规的字符
+     */
+    public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
+            "org.springframework", "org.apache", "com.songhua.common.utils.file", "com.songhua.common.config", "com.songhua.generator" };
+}

+ 195 - 100
src/main/java/com/sooka/sponest/songhuahu/exchange/controller/ExchangeController.java

@@ -1,139 +1,234 @@
 package com.sooka.sponest.songhuahu.exchange.controller;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.common.core.exception.file.FileException;
-import com.ruoyi.common.core.utils.file.FilePrefixUtils;
-import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.system.api.RemoteConfigService;
-import com.ruoyi.system.api.RemoteFileService;
-import com.ruoyi.system.api.domain.SysFile;
-import com.sooka.sponest.songhuahu.exchange.domian.DataExchangeEntity;
-import com.sooka.sponest.songhuahu.exchange.domian.LoginBody;
-import com.sooka.sponest.songhuahu.remoteapi.service.center.auth.RemoteAuthBaseService;
-import com.sooka.sponest.songhuahu.remoteapi.service.center.event.RemoteEventBaseService;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.sooka.sponest.songhuahu.constant.Constants;
+import com.sooka.sponest.songhuahu.exchange.domian.GPSEquipment;
+import com.sooka.sponest.songhuahu.exchange.domian.ShipSaveDTO;
+import com.sooka.sponest.songhuahu.redis.RedisCache;
+import com.sooka.sponest.songhuahu.util.MD5Encryptor;
 import com.sooka.sponest.songhuahu.util.RestUtil;
-import com.sooka.sponest.songhuahu.util.spring.SpringUtils;
+import com.sooka.sponest.songhuahu.util.URLEncodeExampleUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.util.CollectionUtils;
 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.ResponseBody;
-import org.springframework.web.multipart.MultipartFile;
 
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import static com.ruoyi.common.core.web.domain.AjaxResult.error;
+import static com.ruoyi.common.core.web.domain.AjaxResult.success;
 
 @Slf4j
 @Controller
 @RequestMapping("/data/exchange")
 public class ExchangeController {
 
-    @Resource
-    private RemoteAuthBaseService remoteAuthBaseService;
-    @Resource
-    private RemoteEventBaseService remoteEventBaseService;
-    @Resource
-    private RemoteConfigService remoteConfigService;
+    @Autowired
+    private RedisCache redisCache;
+
+    private final List<String> keys = Arrays.asList("gps_address", "app_key", "app_secret", "account", "password");
+
+    private final String ip = "http://127.0.0.1";
+
+    private final String port = "10001";
 
-    //    @Value("${}")
-    private String url;
 
     /**
-     * 获取秘钥接口
+     * 获取访问令牌
      */
-    @PostMapping("/getRemoteSecretKey")
-    @ResponseBody
-    public R<?> getRemoteSecretKey() {
-        R<?> result = remoteAuthBaseService.getRemoteSecretKey();
-        log.info("result:{}", result.getData());
-        if (result.getCode() == 200) {
-            return R.ok(result.getData().toString(), "获取成功");
-        } else {
-            return R.fail("获取失败");
+    public AjaxResult getToken() {
+        Date date = new Date();
+        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
+        String dateStr = format.replace(" ", "%20");
+        Map<String, String> configMap = getStringStringMap();
+        String password = MD5Encryptor.md5EncryptToLowercase(configMap.get("password").toString());
+        String sign = MD5Encryptor.md5EncryptToUppercase(configMap.get("app_secret") +
+                "account" + configMap.get("account") +
+                "app_key" + configMap.get("app_key") +
+                "formatjsonmethodwicare.user.access_token" +
+                "password" + password +
+                "sign_methodmd5" +
+                "timestamp" + dateStr +
+                "type2v2.0" +
+                configMap.get("app_secret"));
+        String apiUrl = configMap.get("gps_address") +
+                "account=" + configMap.get("account") +
+                "&app_key=" + configMap.get("app_key") +
+                "&format=json&method=wicare.user.access_token&" +
+                "password=" + password +
+                "&sign_method=md5&" +
+                "timestamp=" + dateStr +
+                "&type=2&v=2.0&" +
+                "sign=" + sign;
+        try {
+            // 创建 URL 对象
+            URL url = new URL(apiUrl);
+            // 打开连接
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            // 设置请求方法
+            connection.setRequestMethod("GET");
+            // 获取响应状态码
+            int responseCode = connection.getResponseCode();
+            if (responseCode == HttpURLConnection.HTTP_OK) {
+                // 读取响应内容
+                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+                String line;
+                StringBuilder response = new StringBuilder();
+                while ((line = reader.readLine()) != null) {
+                    response.append(line);
+                }
+                reader.close();
+                // 存入redis中
+                redisCache.setCacheObject("access_token", JSONObject.parseObject(response.toString()).get("access_token"), Constants.GPS_ACCESS_TOKEN_EXPIRATION, TimeUnit.MINUTES);
+                return success(JSONObject.parseObject(response.toString()).get("access_token"));
+            } else {
+                log.error("获取访问令牌接口返回错误代码:{}", responseCode);
+            }
+            // 关闭连接
+            connection.disconnect();
+        } catch (Exception e) {
+            log.error("获取访问令牌接口失败:{}", e);
+            e.printStackTrace();
         }
+        return error("获取访问令牌接口失败");
     }
 
-    /**
-     * 获取token
-     */
-    @PostMapping("/getToken")
-    @ResponseBody
-    public R<?> getToken(@RequestBody LoginBody form) {
-        R<?> result = remoteAuthBaseService.loginRemote(form);
-        log.info("result:{}", result.getData());
-        if (result.getCode() == 200) {
-            Map<String, Object> json = (Map<String, Object>) result.getData();
-            return R.ok(json.get("access_token").toString(), "获取成功");
+
+    @PostMapping("/getEquipment")
+    public void getEquipment() {
+        log.info("获取单个设备或多个设备的信息开始");
+        AjaxResult result;
+        Object obj;
+        if (!redisCache.hasKey("access_token")) {
+            result = getToken();
+            obj = result.get("data");
         } else {
-            return R.fail("获取失败");
+            obj = redisCache.getCacheObject("access_token");
         }
-    }
-
-    @PostMapping("/straightPushData")
-    @ResponseBody
-    public R<?> straightPushData(@RequestBody DataExchangeEntity dataExchangeEntity) {
-        log.info("dataExchangeEntity:{}", dataExchangeEntity);
-        List<String> pictureList = new ArrayList<>();
-        if (StringUtils.isNotEmpty(SecurityUtils.getToken()) && !CollectionUtils.isEmpty(dataExchangeEntity.getEventPicture())) {
-            log.info("token:{}", StringUtils.isNotEmpty(SecurityUtils.getToken()));
-            for (String picture : dataExchangeEntity.getEventPicture()) {
-                if (!"image".equals(FilePrefixUtils.getUrlSuffix(picture))) {
-                    log.error("事件图片必须为图片格式---{}", dataExchangeEntity);
-                    return R.fail("事件图片必须为图片格式");
-                } else {
-                    MultipartFile multipartFile = FilePrefixUtils.urlToMultipartFile(picture, System.currentTimeMillis() + ".jpg");
-                    log.info("multipartFile:{}", multipartFile);
-                    try {
-                        SysFile sysFile = SpringUtils.getBean(RemoteFileService.class).upload(multipartFile).getData();
-                        log.info("sysFile:{}", sysFile);
-                        pictureList.add(sysFile.getUrl());
-                    } catch (FileException e) {
-                        log.info("上传附件失败");
-                    }
 
+        Date date = new Date();
+        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
+        Map<String, String> configMap = getStringStringMap();
+        String dateStr = format.replace(" ", "%20");
+        String sign = MD5Encryptor.md5EncryptToUppercase(configMap.get("app_secret") +
+                "access_token" + obj +
+                "app_key" + configMap.get("app_key") +
+                "dev_key59346d400236ab95e95193f35f3df6a4" +
+                "fieldsdid,activeGpsDataformatjsonlimit-1mapBAIDU" +
+                "methodwicare.device.listpagedidpage_no1sign_methodmd5sortsdid" +
+                "timestamp" + dateStr +
+                "v2.0" +
+                configMap.get("app_secret"));
+        log.info("singStr:{}", configMap.get("app_secret") +
+                "access_token" + obj +
+                "app_key" + configMap.get("app_key") +
+                "dev_key59346d400236ab95e95193f35f3df6a4" +
+                "fieldsdid,activeGpsDataformatjsonlimit-1mapBAIDU" +
+                "methodwicare.device.listpagedidpage_no1sign_methodmd5sortsdid" +
+                "timestamp" + dateStr +
+                "v2.0" +
+                configMap.get("app_secret"));
+        log.info("sign:{}", sign);
+        String apiUrl = configMap.get("gps_address") +
+                "timestamp=" + dateStr +
+                "&format=json&" +
+                "app_key=" +
+                configMap.get("app_key") +
+                "&v=2.0&sign_method=md5&method=wicare.device.list&dev_key=59346d400236ab95e95193f35f3df6a4&access_token=" + URLEncodeExampleUtil.URLEncodeExample(obj) +
+                "&map=BAIDU&fields=did,activeGpsData&sorts=did&page=did&page_no=1&limit=-1&sign=" +
+                sign;
+        log.info("apiUrl:{}", apiUrl);
+        log.info("URLEncodeExampleUtil.URLEncodeExample(obj):{}", URLEncodeExampleUtil.URLEncodeExample(obj));
+        try {
+            // 创建 URL 对象
+            URL url = new URL(apiUrl);
+            // 打开连接
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            // 设置请求方法
+            connection.setRequestMethod("GET");
+            // 获取响应状态码
+            int responseCode = connection.getResponseCode();
+            log.info("connection.getResponseMessage():{}", connection.getResponseMessage());
+            log.info("connection:{}", connection);
+            if (responseCode == HttpURLConnection.HTTP_OK) {
+                // 读取响应内容
+                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+                String line;
+                StringBuilder response = new StringBuilder();
+                while ((line = reader.readLine()) != null) {
+                    response.append(line);
+                }
+                log.info("获取单个设备或多个设备的信息返回信息:{}", response);
+                reader.close();
+                List<GPSEquipment> objectList = JSONArray.parseArray(JSONObject.parseObject(response.toString()).getString("data").toString(), GPSEquipment.class);
+                List<ShipSaveDTO> saveList = new ArrayList<>();
+                for (GPSEquipment var : objectList) {
+                    ShipSaveDTO saveEntity = new ShipSaveDTO();
+                    saveEntity.setDid(var.getDid());
+                    saveEntity.setLongitude(String.valueOf(var.getActiveGpsData().getLon()));
+                    saveEntity.setLatitude(String.valueOf(var.getActiveGpsData().getLat()));
+                    saveEntity.setGpsFlag(var.getActiveGpsData().getGpsFlag());
+                    saveEntity.setLon(var.getActiveGpsData().get_lon());
+                    saveEntity.setLat(var.getActiveGpsData().get_lat());
+                    saveEntity.setSignal(var.getActiveGpsData().getSignal());
+                    saveEntity.setSpeed(var.getActiveGpsData().getSpeed());
+                    saveEntity.setDirect(var.getActiveGpsData().getDirect());
+                    saveEntity.setMileage(var.getActiveGpsData().getMileage());
+                    saveEntity.setBattery(var.getActiveGpsData().getBattery());
+                    saveEntity.setPower(var.getActiveGpsData().getPower());
+                    saveEntity.setStatus(String.join(",", var.getActiveGpsData().getStatus().stream().map(String::valueOf).collect(Collectors.toList())));
+                    saveEntity.setAlerts(String.join(",", var.getActiveGpsData().getAlerts().stream().map(String::valueOf).collect(Collectors.toList())));
+                    saveEntity.setGpsTime(var.getActiveGpsData().getGpsTime());
+                    saveEntity.setRcvTime(var.getActiveGpsData().getRcvTime());
+                    saveList.add(saveEntity);
+                }
+                if (!CollectionUtils.isEmpty(saveList)) {
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("list", saveList);
+                    JSONObject json = RestUtil.post(ip + ":" + port + "/shipMapping/remote/saveCruiseShipMapping", jsonObject);
+                    System.out.println("result" + json);
                 }
-            }
-            dataExchangeEntity.setPictureUrlList(pictureList);
-            R<?> result = remoteEventBaseService.insert3rdSystemEvent(dataExchangeEntity);
-            log.info("insert3rdSystemEvent:{}", result);
-            if (result.getCode() == 200) {
-                return R.ok(null, "推送成功");
             } else {
-                return R.fail(result.getMsg());
+                log.error("获取单个设备或多个设备的信息返回错误代码:{}", responseCode);
             }
-        } else {
-            return R.fail("推送失败");
+            // 关闭连接
+            connection.disconnect();
+        } catch (Exception e) {
+            log.error("获取单个设备或多个设备的信息接口失败:{}", e);
+            e.printStackTrace();
         }
+        log.info("获取单个设备或多个设备的信息结束");
     }
 
 
-    @PostMapping("/receiveEventData")
-    @ResponseBody
-    public R<?> receiveEventData(@RequestBody DataExchangeEntity dataExchangeEntity) {
-        System.out.println(dataExchangeEntity);
-        R<String> appUrl = remoteConfigService.remotegetConfigKey("appUrl");
-        List<String> pictureList = new ArrayList<>();
-        for (String picture : dataExchangeEntity.getEventPicture()) {
-            pictureList.add(appUrl.getData().toString() + picture);
-        }
-        dataExchangeEntity.setEventPicture(pictureList);
-        // TODO: 2024/1/9 0009 待修改
+    /**
+     * 根据参数编号获取详细信息
+     *
+     * @return
+     */
+    private Map<String, String> getStringStringMap() {
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("", dataExchangeEntity);
-        try {
-            JSONObject result = RestUtil.post(url, jsonObject);
-            log.info("远程调用119:{}", result);
-        } catch (Exception e) {
-            log.info("远程调用119报错");
+        jsonObject.put("keys", keys);
+        JSONObject result = RestUtil.post(ip + ":" + port + "/system/config/remote/configKey", jsonObject);
+        if (result.get("code").equals(200)) {
+            Map<String, String> configMap = (Map<String, String>) result.get("data");
+            return configMap;
+        } else {
+            return null;
         }
-        return R.ok(null, "接收成功");
     }
 
+
 }

+ 92 - 0
src/main/java/com/sooka/sponest/songhuahu/exchange/domian/ActiveGpsData.java

@@ -0,0 +1,92 @@
+package com.sooka.sponest.songhuahu.exchange.domian;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+
+@Data
+public class ActiveGpsData {
+    /**
+     * 定位标志:
+     * 1: 非精确定位
+     * 2:GPS 精确定位
+     * 3:基站定位
+     */
+    private int gpsFlag;
+    /**
+     * 原始经度
+     */
+    private double lon;
+    /**
+     * 原始纬度
+     */
+    private double lat;
+    /**
+     * 百度修正经度
+     */
+    private double _lon;
+    /**
+     * 百度修正纬度
+     */
+    private double _lat;
+    /**
+     * 通讯信号:
+     * <15:信号弱
+     * 15– 25:信号良
+     * >25:	 信号强
+     */
+    private int signal;
+    /**
+     * 速度(单位:km/h)
+     */
+    private int speed;
+    /**
+     * 方向(正北为 0)
+     */
+    private int direct;
+    /**
+     * 累计里程
+     */
+    private double mileage;
+    /**
+     *
+     */
+    private double battery;
+    /**
+     *
+     */
+    private double power;
+    /**
+     * 车辆状态:
+     * 0x2001:	 设防状态
+     * 0x2004:	 车辆启动状态
+     * 0x2005:	 设备进入省电状态
+     */
+    private List<Integer> status;
+    /**
+     * 车辆报警:
+     * 0x3001:	 紧急报警
+     * 0x3002:	 超速报警
+     * 0x3003:	 震动报警
+     * 0x3004:	 移位报警
+     * 0x3007:	 进区域报警
+     * 0x3008:	 出区域报警
+     * 0x3009:	 断电报警
+     * 0x300A:	 电瓶电压低报警
+     */
+    private List<String> alerts;
+    /**
+     * 定位时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date gpsTime;
+    /**
+     * 接收时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date rcvTime;
+
+}

+ 19 - 0
src/main/java/com/sooka/sponest/songhuahu/exchange/domian/GPSEquipment.java

@@ -0,0 +1,19 @@
+package com.sooka.sponest.songhuahu.exchange.domian;
+
+
+import lombok.Data;
+
+@Data
+public class GPSEquipment {
+
+    /**
+     * 设备 ID
+     */
+    private Long did;
+    /**
+     * 定位及空气数据
+     */
+
+    private ActiveGpsData activeGpsData;
+
+}

+ 99 - 0
src/main/java/com/sooka/sponest/songhuahu/exchange/domian/ShipSaveDTO.java

@@ -0,0 +1,99 @@
+package com.sooka.sponest.songhuahu.exchange.domian;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+
+@Data
+public class ShipSaveDTO {
+
+    /**
+     * 车船标识id
+     */
+    private Long did;
+
+    /**
+     * 经度
+     */
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    private String latitude;
+
+    /**
+     * 定位标志:
+     * 1: 非精确定位
+     * 2:GPS 精确定位
+     * 3:基站定位
+     */
+    private int gpsFlag;
+
+    /**
+     * 百度修正经度
+     */
+    private double lon;
+    /**
+     * 百度修正纬度
+     */
+    private double lat;
+    /**
+     * 通讯信号:
+     * <15:信号弱
+     * 15– 25:信号良
+     * >25:	 信号强
+     */
+    private int signal;
+    /**
+     * 速度(单位:km/h)
+     */
+    private int speed;
+    /**
+     * 方向(正北为 0)
+     */
+    private int direct;
+    /**
+     * 累计里程
+     */
+    private double mileage;
+    /**
+     *
+     */
+    private double battery;
+    /**
+     *
+     */
+    private double power;
+    /**
+     * 车辆状态:
+     * 0x2001:	 设防状态
+     * 0x2004:	 车辆启动状态
+     * 0x2005:	 设备进入省电状态
+     */
+    private String status;
+    /**
+     * 车辆报警:
+     * 0x3001:	 紧急报警
+     * 0x3002:	 超速报警
+     * 0x3003:	 震动报警
+     * 0x3004:	 移位报警
+     * 0x3007:	 进区域报警
+     * 0x3008:	 出区域报警
+     * 0x3009:	 断电报警
+     * 0x300A:	 电瓶电压低报警
+     */
+    private String alerts;
+    /**
+     * 定位时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date gpsTime;
+    /**
+     * 接收时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date rcvTime;
+}

+ 243 - 0
src/main/java/com/sooka/sponest/songhuahu/redis/RedisCache.java

@@ -0,0 +1,243 @@
+package com.sooka.sponest.songhuahu.redis;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.BoundSetOperations;
+import org.springframework.data.redis.core.HashOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * spring redis 工具类
+ *
+ * @author ruoyi
+ **/
+@SuppressWarnings(value = {"unchecked", "rawtypes"})
+@Component
+public class RedisCache {
+    @Autowired
+    public RedisTemplate redisTemplate;
+
+    /**
+     * 缓存基本的对象,Integer、String、实体类等
+     *
+     * @param key   缓存的键值
+     * @param value 缓存的值
+     */
+    public <T> void setCacheObject(final String key, final T value) {
+        redisTemplate.opsForValue().set(key, value);
+    }
+
+    /**
+     * 缓存基本的对象,Integer、String、实体类等
+     *
+     * @param key      缓存的键值
+     * @param value    缓存的值
+     * @param timeout  时间
+     * @param timeUnit 时间颗粒度
+     */
+    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
+        redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
+    }
+
+    /**
+     * 设置有效时间
+     *
+     * @param key     Redis键
+     * @param timeout 超时时间
+     * @return true=设置成功;false=设置失败
+     */
+    public boolean expire(final String key, final long timeout) {
+        return expire(key, timeout, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 设置有效时间
+     *
+     * @param key     Redis键
+     * @param timeout 超时时间
+     * @param unit    时间单位
+     * @return true=设置成功;false=设置失败
+     */
+    public boolean expire(final String key, final long timeout, final TimeUnit unit) {
+        return redisTemplate.expire(key, timeout, unit);
+    }
+
+    /**
+     * 获取有效时间
+     *
+     * @param key Redis键
+     * @return 有效时间
+     */
+    public long getExpire(final String key) {
+        return redisTemplate.getExpire(key);
+    }
+
+    /**
+     * 判断 key是否存在
+     *
+     * @param key 键
+     * @return true 存在 false不存在
+     */
+    public Boolean hasKey(String key) {
+        return redisTemplate.hasKey(key);
+    }
+
+    /**
+     * 获得缓存的基本对象。
+     *
+     * @param key 缓存键值
+     * @return 缓存键值对应的数据
+     */
+    public <T> T getCacheObject(final String key) {
+        ValueOperations<String, T> operation = redisTemplate.opsForValue();
+        return operation.get(key);
+    }
+
+    /**
+     * 删除单个对象
+     *
+     * @param key
+     */
+    public boolean deleteObject(final String key) {
+        return redisTemplate.delete(key);
+    }
+
+    /**
+     * 删除集合对象
+     *
+     * @param collection 多个对象
+     * @return
+     */
+    public boolean deleteObject(final Collection collection) {
+        return redisTemplate.delete(collection) > 0;
+    }
+
+    /**
+     * 缓存List数据
+     *
+     * @param key      缓存的键值
+     * @param dataList 待缓存的List数据
+     * @return 缓存的对象
+     */
+    public <T> long setCacheList(final String key, final List<T> dataList) {
+        Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
+        return count == null ? 0 : count;
+    }
+
+    /**
+     * 获得缓存的list对象
+     *
+     * @param key 缓存的键值
+     * @return 缓存键值对应的数据
+     */
+    public <T> List<T> getCacheList(final String key) {
+        return redisTemplate.opsForList().range(key, 0, -1);
+    }
+
+    /**
+     * 缓存Set
+     *
+     * @param key     缓存键值
+     * @param dataSet 缓存的数据
+     * @return 缓存数据的对象
+     */
+    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
+        BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
+        Iterator<T> it = dataSet.iterator();
+        while (it.hasNext()) {
+            setOperation.add(it.next());
+        }
+        return setOperation;
+    }
+
+    /**
+     * 获得缓存的set
+     *
+     * @param key
+     * @return
+     */
+    public <T> Set<T> getCacheSet(final String key) {
+        return redisTemplate.opsForSet().members(key);
+    }
+
+    /**
+     * 缓存Map
+     *
+     * @param key
+     * @param dataMap
+     */
+    public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
+        if (dataMap != null) {
+            redisTemplate.opsForHash().putAll(key, dataMap);
+        }
+    }
+
+    /**
+     * 获得缓存的Map
+     *
+     * @param key
+     * @return
+     */
+    public <T> Map<String, T> getCacheMap(final String key) {
+        return redisTemplate.opsForHash().entries(key);
+    }
+
+    /**
+     * 往Hash中存入数据
+     *
+     * @param key   Redis键
+     * @param hKey  Hash键
+     * @param value 值
+     */
+    public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
+        redisTemplate.opsForHash().put(key, hKey, value);
+    }
+
+    /**
+     * 获取Hash中的数据
+     *
+     * @param key  Redis键
+     * @param hKey Hash键
+     * @return Hash中的对象
+     */
+    public <T> T getCacheMapValue(final String key, final String hKey) {
+        HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
+        return opsForHash.get(key, hKey);
+    }
+
+    /**
+     * 获取多个Hash中的数据
+     *
+     * @param key   Redis键
+     * @param hKeys Hash键集合
+     * @return Hash对象集合
+     */
+    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
+        return redisTemplate.opsForHash().multiGet(key, hKeys);
+    }
+
+    /**
+     * 删除Hash中的某条数据
+     *
+     * @param key  Redis键
+     * @param hKey Hash键
+     * @return 是否成功
+     */
+    public boolean deleteCacheMapValue(final String key, final String hKey) {
+        return redisTemplate.opsForHash().delete(key, hKey) > 0;
+    }
+
+    /**
+     * 获得缓存的基本对象列表
+     *
+     * @param pattern 字符串前缀
+     * @return 对象列表
+     */
+    public Collection<String> keys(final String pattern) {
+        return redisTemplate.keys(pattern);
+    }
+}

+ 35 - 0
src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/RemoteSonghuahuServiceFallbackFactory.java

@@ -0,0 +1,35 @@
+package com.sooka.sponest.songhuahu.remoteapi.fallback.center;
+
+
+import com.ruoyi.common.core.domain.R;
+import com.sooka.sponest.songhuahu.remoteapi.service.center.RemoteSonghuahuService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+@Component
+public class RemoteSonghuahuServiceFallbackFactory implements FallbackFactory<RemoteSonghuahuService> {
+    private static final Logger log = LoggerFactory.getLogger(RemoteSonghuahuServiceFallbackFactory.class);
+
+    @Override
+    public RemoteSonghuahuService create(Throwable cause) {
+
+        return new RemoteSonghuahuService() {
+
+            @Override
+            public R getConfigMap(List<String> keys) {
+                return null;
+            }
+
+            @Override
+            public R saveCruiseShipMapping(List list) {
+                return null;
+            }
+
+        };
+    }
+}

+ 0 - 36
src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/auth/RemoteAuthBaseServiceFallbackFactory.java

@@ -1,36 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.fallback.center.auth;
-
-
-import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.songhuahu.exchange.domian.LoginBody;
-import com.sooka.sponest.songhuahu.remoteapi.service.center.auth.RemoteAuthBaseService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.openfeign.FallbackFactory;
-import org.springframework.stereotype.Component;
-
-
-@Component
-public class RemoteAuthBaseServiceFallbackFactory implements FallbackFactory<RemoteAuthBaseService> {
-    private static final Logger log = LoggerFactory.getLogger(RemoteAuthBaseServiceFallbackFactory.class);
-
-    @Override
-    public RemoteAuthBaseService create(Throwable cause) {
-        log.error("认证中心-服务调用失败:{}", cause.getMessage());
-
-
-        return new RemoteAuthBaseService() {
-
-            @Override
-            public R<?> loginRemote(LoginBody form) {
-                return null;
-            }
-
-            @Override
-            public R<?> getRemoteSecretKey() {
-                return null;
-            }
-
-        };
-    }
-}

+ 0 - 19
src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/data/RemoteDataBaseServiceFallbackFactory.java

@@ -1,19 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.fallback.center.data;
-
-
-import com.sooka.sponest.songhuahu.remoteapi.service.center.data.RemoteDataBaseService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.openfeign.FallbackFactory;
-import org.springframework.stereotype.Component;
-
-
-@Component
-public class RemoteDataBaseServiceFallbackFactory implements FallbackFactory<RemoteDataBaseService> {
-    private static final Logger log = LoggerFactory.getLogger(RemoteDataBaseServiceFallbackFactory.class);
-
-    @Override
-    public RemoteDataBaseService create(Throwable cause) {
-        return null;
-    }
-}

+ 0 - 40
src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/event/RemoteEventBaseServiceFallbackFactory.java

@@ -1,40 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.fallback.center.event;
-
-
-import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.songhuahu.exchange.domian.DataExchangeEntity;
-import com.sooka.sponest.songhuahu.remoteapi.service.center.event.RemoteEventBaseService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.openfeign.FallbackFactory;
-import org.springframework.stereotype.Component;
-
-
-@Component
-public class RemoteEventBaseServiceFallbackFactory implements FallbackFactory<RemoteEventBaseService> {
-    private static final Logger log = LoggerFactory.getLogger(RemoteEventBaseServiceFallbackFactory.class);
-
-    @Override
-    public RemoteEventBaseService create(Throwable cause) {
-        log.error("事件中心-服务调用失败:{}", cause.getMessage());
-
-        return new RemoteEventBaseService() {
-
-            @Override
-            public R<?> insert3rdSystemEvent(DataExchangeEntity dataExchangeEntity) {
-                return null;
-            }
-
-            @Override
-            public R<?> subscribeTo(String list) {
-                return null;
-            }
-
-            @Override
-            public R<?> getDataSubscribeTo() {
-                return null;
-            }
-
-        };
-    }
-}

+ 0 - 53
src/main/java/com/sooka/sponest/songhuahu/remoteapi/fallback/center/system/RemoteSystemBaseServiceFallbackFactory.java

@@ -1,53 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.fallback.center.system;
-
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.system.api.domain.SysUser;
-import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
-import com.sooka.sponest.songhuahu.remoteapi.service.center.system.RemoteSystemService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.openfeign.FallbackFactory;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * @program: ruoyi
- * @description: yy
- * @author: yy
- * @create: 2022-06-16 11:05
- **/
-@Component
-public class RemoteSystemBaseServiceFallbackFactory implements FallbackFactory<RemoteSystemService> {
-
-    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
-
-    @Override
-    public RemoteSystemService create(Throwable cause) {
-        log.error("维护中心-服务调用失败:{}", cause.getMessage());
-
-        return new RemoteSystemService() {
-
-            @Override
-            public R<List<SysUser>> userFeginlist(SysUser user) {
-                return null;
-            }
-
-            @Override
-            public R<String> selectConfigKey_insectPestsUrl() {
-                return null;
-            }
-
-            @Override
-            public R<String> selectConfigKey_fileUrl() {
-                return null;
-            }
-
-            @Override
-            public R<String> remotegetConfigKey(String configKey) {
-                return null;
-            }
-
-        };
-    }
-}

+ 37 - 0
src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/RemoteSonghuahuService.java

@@ -0,0 +1,37 @@
+package com.sooka.sponest.songhuahu.remoteapi.service.center;
+
+
+import com.ruoyi.common.core.domain.R;
+import com.sooka.sponest.songhuahu.remoteapi.fallback.center.RemoteSonghuahuServiceFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+
+
+@FeignClient(
+        name = "RemoteSonghuahuService",
+        url = "http://127.0.0.1",
+        fallbackFactory = RemoteSonghuahuServiceFallbackFactory.class
+)
+public interface RemoteSonghuahuService {
+
+    /**
+     * 远程根据参数键名查询参数值
+     * @param keys
+     * @return
+     */
+    @PostMapping("/system/config/remote/configKey")
+    R getConfigMap(@RequestBody List<String> keys);
+
+    /**
+     * 远程根据参数键名查询参数值
+     * @param list
+     * @return
+     */
+    @PostMapping("/shipMapping/remote/saveCruiseShipMapping")
+    R saveCruiseShipMapping(@RequestBody List list);
+
+}

+ 0 - 25
src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/auth/RemoteAuthBaseService.java

@@ -1,25 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.service.center.auth;
-
-
-import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.songhuahu.exchange.domian.LoginBody;
-import com.sooka.sponest.songhuahu.remoteapi.fallback.center.auth.RemoteAuthBaseServiceFallbackFactory;
-import com.sooka.sponest.songhuahu.remoteapi.service.ModulesServiceNameContants;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-
-
-@FeignClient(
-        contextId = "RemoteAuthBaseService",
-        value = ModulesServiceNameContants.CENTER_AUTH,
-        fallbackFactory = RemoteAuthBaseServiceFallbackFactory.class
-)
-public interface RemoteAuthBaseService {
-
-    @PostMapping("/loginRemote")
-    public R<?> loginRemote(LoginBody form);
-
-    @PostMapping("/getRemoteSecretKey")
-    public R<?> getRemoteSecretKey();
-
-}

+ 0 - 16
src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/data/RemoteDataBaseService.java

@@ -1,16 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.service.center.data;
-
-
-import com.sooka.sponest.songhuahu.remoteapi.fallback.center.data.RemoteDataBaseServiceFallbackFactory;
-import com.sooka.sponest.songhuahu.remoteapi.service.ModulesServiceNameContants;
-import org.springframework.cloud.openfeign.FeignClient;
-
-
-@FeignClient(
-        contextId = "RemoteDataBaseService",
-        value = ModulesServiceNameContants.CENTER_DATA,
-        fallbackFactory = RemoteDataBaseServiceFallbackFactory.class
-)
-public interface RemoteDataBaseService {
-
-}

+ 0 - 29
src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/event/RemoteEventBaseService.java

@@ -1,29 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.service.center.event;
-
-
-import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.songhuahu.exchange.domian.DataExchangeEntity;
-import com.sooka.sponest.songhuahu.remoteapi.fallback.center.event.RemoteEventBaseServiceFallbackFactory;
-import com.sooka.sponest.songhuahu.remoteapi.service.ModulesServiceNameContants;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-
-
-@FeignClient(
-        contextId = "RemoteEventBaseService",
-        value = ModulesServiceNameContants.CENTER_EVENT,
-        fallbackFactory = RemoteEventBaseServiceFallbackFactory.class
-)
-public interface RemoteEventBaseService {
-
-    @PostMapping("/fireIncident/insert3rdSystemEvent")
-    public R<?> insert3rdSystemEvent(DataExchangeEntity dataExchangeEntity);
-
-    @PostMapping("/subscribeTo")
-    public R<?> subscribeTo(String list);
-
-
-    @PostMapping("/getDataSubscribeTo")
-    public R<?> getDataSubscribeTo();
-
-}

+ 0 - 44
src/main/java/com/sooka/sponest/songhuahu/remoteapi/service/center/system/RemoteSystemService.java

@@ -1,44 +0,0 @@
-package com.sooka.sponest.songhuahu.remoteapi.service.center.system;
-
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.system.api.domain.SysUser;
-import com.sooka.sponest.songhuahu.remoteapi.fallback.center.system.RemoteSystemBaseServiceFallbackFactory;
-import com.sooka.sponest.songhuahu.remoteapi.service.ModulesServiceNameContants;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-
-import java.util.List;
-
-@FeignClient(contextId = "remoteSystemService", fallbackFactory = RemoteSystemBaseServiceFallbackFactory.class, value = ModulesServiceNameContants.SYSTEM_SERVICE)
-public interface RemoteSystemService {
-    /**
-     * 获取系统用户
-     *
-     * @param user
-     * @return com.ruoyi.common.core.domain.R<java.util.List < com.ruoyi.system.api.domain.SysUser>>
-     * @author pengyu
-     * @date 2023/3/8 16:27
-     **/
-    @PostMapping("/user/userFeginlist")
-    public R<List<SysUser>> userFeginlist(@RequestBody SysUser user);
-
-    /**
-     * 获取系统参数配置
-     *
-     * @return com.ruoyi.common.core.domain.R<java.lang.String>
-     * @author pengyu
-     * @date 2023/3/8 16:27
-     **/
-    @GetMapping("/config/selectConfigKey/insectPestsUrl")
-    public R<String> selectConfigKey_insectPestsUrl();
-
-    @GetMapping("/config/selectConfigKey/fileUrl")
-    public R<String> selectConfigKey_fileUrl();
-
-    @PostMapping(value = "/config/remotegetConfigKey")
-    R<String> remotegetConfigKey(@RequestBody String configKey);
-
-
-}

+ 52 - 0
src/main/java/com/sooka/sponest/songhuahu/util/MD5Encryptor.java

@@ -0,0 +1,52 @@
+package com.sooka.sponest.songhuahu.util;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class MD5Encryptor {
+
+    // MD5 加密(32 位小写)
+    public static String md5EncryptToLowercase(String str) {
+        return md5Encrypt(str).toLowerCase();
+    }
+
+    // MD5 加密(32 位大写)
+    public static String md5EncryptToUppercase(String str) {
+        return md5Encrypt(str).toUpperCase();
+    }
+
+    // MD5 加密
+    private static String md5Encrypt(String str) {
+        try {
+            // 创建 MessageDigest 对象
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            // 将输入字符串转换为字节数组
+            byte[] inputBytes = str.getBytes();
+            // 计算 MD5 哈希值
+            byte[] hashBytes = md.digest(inputBytes);
+            // 将字节数组转换为十六进制字符串
+            StringBuilder hexString = new StringBuilder();
+            for (byte hashByte : hashBytes) {
+                String hex = Integer.toHexString(0xFF & hashByte);
+                if (hex.length() == 1) {
+                    hexString.append('0');
+                }
+                hexString.append(hex);
+            }
+            return hexString.toString();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static void main(String[] args) {
+        String str = "123456";
+        // 封装 MD5 加密结果(32 位小写)
+        String encryptedLowercase = md5EncryptToLowercase(str);
+        System.out.println("32-bit Lowercase: " + encryptedLowercase);
+        // 封装 MD5 加密结果(32 位大写)
+        String encryptedUppercase = md5EncryptToUppercase(str);
+        System.out.println("32-bit Uppercase: " + encryptedUppercase);
+    }
+}

+ 17 - 0
src/main/java/com/sooka/sponest/songhuahu/util/URLEncodeExampleUtil.java

@@ -0,0 +1,17 @@
+package com.sooka.sponest.songhuahu.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+public class URLEncodeExampleUtil {
+
+    public static String URLEncodeExample(Object token) {
+        try {
+            return URLEncoder.encode(token.toString(), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return "token进行url编码失败";
+    }
+
+}

+ 1 - 1
src/main/resources/banner.txt

@@ -1,2 +1,2 @@
 Spring Boot Version: ${spring-boot.version}
-Spring Application Name: ${spring.application.name}
+Spring Application Name: ${spring.application.name}

+ 1 - 1
src/main/resources/bootstrap.yml

@@ -9,7 +9,7 @@ server:
 spring:
   application:
     # 应用名称
-    name: sooka-sponest-dataexchange
+    name: sooka-songhuahu
   profiles:
     # 环境配置
     active: dev