From 1f03c113ee3bd3edcb6daf9fadf271ace5e01556 Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Thu, 13 Feb 2025 15:54:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=B3=E8=81=94ip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tc/controller/AssetCurrentController.java | 53 +++++---- .../tc/controller/WithoutController.java | 106 +++++++++--------- .../com/ruoyi/tc/entity/request/Acomma.java | 12 ++ .../service/impl/AssetCurrentServiceImpl.java | 15 ++- 4 files changed, 105 insertions(+), 81 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java index 4313a1f..6fd2570 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java @@ -2,6 +2,8 @@ package com.ruoyi.tc.controller; import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.controller.BaseController; @@ -27,9 +29,10 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.Serializable; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; /** * 现有资产表(AssetCurrent)表控制层 @@ -164,16 +167,12 @@ public class AssetCurrentController extends BaseController { }); } assetCurrent.setGlym(a.toString()); - StringBuilder b = new StringBuilder(); if (assetCurrent.getGlIpList() != null) { - assetCurrent.getGlIpList().forEach(x -> { - if (!Objects.equals(x.getKey(), "") && x.getKey() != null) { - b.append(x.getKey()); - b.append(","); - } - }); + assetCurrent.setGlIp(assetCurrent.getGlIpList().toString()); + } else { + assetCurrent.setGlIp(""); } - assetCurrent.setGlIp(b.toString()); +// assetCurrent.setGlIp(b.toString()); assetCurrentService.save(assetCurrent); //新增新监管业务形态 if (assetCurrent.getXjgywxt() != null) { @@ -389,16 +388,20 @@ public class AssetCurrentController extends BaseController { byId.setGlymList(new ArrayList<>()); } List a2 = new ArrayList<>(); - if (byId.getGlIp() != null) { - Arrays.asList(byId.getGlIp().split(",")).forEach(x -> { + if(byId.getGlIp()!=null&& !byId.getGlIp().isEmpty()){ + for (Object o : JSONArray.parseArray(byId.getGlIp())) { Acomma acomma = new Acomma(); - acomma.setKey(x); + JSONObject jsonObject = JSONObject.parseObject(o.toString()); + acomma.setKey(jsonObject.get("key").toString()); + acomma.setIpType(jsonObject.get("ipType").toString()); + acomma.setPort(jsonObject.get("port").toString()); a2.add(acomma); - }); + } byId.setGlIpList(a2); - } else { + }else { byId.setGlIpList(new ArrayList<>()); } + return success(byId); } @@ -535,16 +538,18 @@ public class AssetCurrentController extends BaseController { }); } assetCurrent.setGlym(a.toString()); - StringBuilder b = new StringBuilder(); if (assetCurrent.getGlIpList() != null) { - assetCurrent.getGlIpList().forEach(x -> { - if (!Objects.equals(x.getKey(), "") && x.getKey() != null) { - b.append(x.getKey()); - b.append(","); - } - }); +// assetCurrent.getGlIpList().forEach(x -> { +// if (!Objects.equals(x.getKey(), "") && x.getKey() != null) { +// b.append(x.getKey()); +// b.append(","); +// } +// }); + assetCurrent.setGlIp(assetCurrent.getGlIpList().toString()); + } else { + assetCurrent.setGlIp(""); } - assetCurrent.setGlIp(b.toString()); + if (!assetCurrent.getXtzt().equals("7")) { assetCurrent.setBtgyy(null); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/WithoutController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/WithoutController.java index d0c73b4..8d4db2c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/WithoutController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/WithoutController.java @@ -82,57 +82,57 @@ public class WithoutController extends BaseController { return AjaxResult.success(unitService.selectAllUnit(req)); } - /** - * 根据查询条件查询所有单位列表 - * - * @return 单位 - */ - @ApiOperation(value = "获取所有单位列表213", response = Unit.class) - @GetMapping("/test") - public void test() { - sendSms("123", "17638176947", "120ErrorMes"); - } - - /** - * 发送短信 - * - * @param content 短信内容 - * @param tel 手机号多个使用,拼接 - * @param errorMes 异常通知的类别 即redis的key - */ - public void sendSms(String content, String tel, String errorMes) { - if (errorMes != null) { - Integer minutes = redisCache.getCacheObject(errorMes); - if (minutes == null) { - redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES); - return; - } - if (minutes < 10) { - long expireTime = redisCache.getExpire(errorMes); - if (expireTime == -1 || expireTime == -2) { - redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES); - } else { - redisCache.setCacheObject(errorMes, minutes + 1, (int) expireTime, TimeUnit.SECONDS); - } - return; - } - } - // 限制每种tel每天只能发一次短信 - Map dataKey = redisCache.getCacheMap("dataKey"); - if (CollectionUtil.isNotEmpty(dataKey)) { - String sendDateStr = (String) dataKey.get(content); - LocalDate sendDate = LocalDate.parse(sendDateStr); - if (LocalDate.now().equals(sendDate)) { - return; - } else { - dataKey.put(content, LocalDate.now()); - redisCache.setCacheMap("dataKey", dataKey); - } - } else { - Map map = new HashMap<>(); - map.put(content, LocalDate.now()); - redisCache.setCacheMap("dataKey", map); - } - System.err.println("已经发送短信"); - } +// /** +// * 根据查询条件查询所有单位列表 +// * +// * @return 单位 +// */ +// @ApiOperation(value = "获取所有单位列表213", response = Unit.class) +// @GetMapping("/test") +// public void test() { +// sendSms("123", "17638176947", "120ErrorMes"); +// } +// +// /** +// * 发送短信 +// * +// * @param content 短信内容 +// * @param tel 手机号多个使用,拼接 +// * @param errorMes 异常通知的类别 即redis的key +// */ +// public void sendSms(String content, String tel, String errorMes) { +// if (errorMes != null) { +// Integer minutes = redisCache.getCacheObject(errorMes); +// if (minutes == null) { +// redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES); +// return; +// } +// if (minutes < 10) { +// long expireTime = redisCache.getExpire(errorMes); +// if (expireTime == -1 || expireTime == -2) { +// redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES); +// } else { +// redisCache.setCacheObject(errorMes, minutes + 1, (int) expireTime, TimeUnit.SECONDS); +// } +// return; +// } +// } +// // 限制每种tel每天只能发一次短信 +// Map dataKey = redisCache.getCacheMap("dataKey"); +// if (CollectionUtil.isNotEmpty(dataKey)) { +// String sendDateStr = (String) dataKey.get(content); +// LocalDate sendDate = LocalDate.parse(sendDateStr); +// if (LocalDate.now().equals(sendDate)) { +// return; +// } else { +// dataKey.put(content, LocalDate.now()); +// redisCache.setCacheMap("dataKey", dataKey); +// } +// } else { +// Map map = new HashMap<>(); +// map.put(content, LocalDate.now()); +// redisCache.setCacheMap("dataKey", map); +// } +// System.err.println("已经发送短信"); +// } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/Acomma.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/Acomma.java index 07a3ef3..5f5d3ae 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/Acomma.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/Acomma.java @@ -10,6 +10,18 @@ import lombok.Data; @Data public class Acomma { + @Override + public String toString() { + return "{\"key\": \"" + key + "\", \"ipType\": \"" + ipType + "\", \"port\": " + port + "}"; + } + @ApiModelProperty("key") private String key; + + @ApiModelProperty("ipType") + private String ipType; + + @ApiModelProperty("port") + private String port; + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java index 5cd2d25..0d0ac12 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java @@ -1,5 +1,7 @@ package com.ruoyi.tc.service.impl; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.tc.entity.*; @@ -83,17 +85,22 @@ public class AssetCurrentServiceImpl extends ServiceImpl()); } + List a2 = new ArrayList<>(); - if(byId.getGlIp()!=null){ - Arrays.asList(byId.getGlIp().split(",")).forEach(x -> { + if(byId.getGlIp()!=null&& !byId.getGlIp().isEmpty()){ + for (Object o : JSONArray.parseArray(byId.getGlIp())) { Acomma acomma = new Acomma(); - acomma.setKey(x); + JSONObject jsonObject = JSONObject.parseObject(o.toString()); + acomma.setKey(jsonObject.get("key").toString()); + acomma.setIpType(jsonObject.get("ipType").toString()); + acomma.setPort(jsonObject.get("port").toString()); a2.add(acomma); - }); + } byId.setGlIpList(a2); }else { byId.setGlIpList(new ArrayList<>()); } + return byId; }