修改关联ip

duhanyu
杜函宇 1 week ago
parent 0bc33eb045
commit 1f03c113ee

@ -2,6 +2,8 @@ package com.ruoyi.tc.controller;
import cn.hutool.core.bean.BeanUtil; 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.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -27,9 +29,10 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.util.ArrayList;
import java.time.ZoneId; import java.util.Arrays;
import java.util.*; import java.util.List;
import java.util.Objects;
/** /**
* (AssetCurrent) * (AssetCurrent)
@ -164,16 +167,12 @@ public class AssetCurrentController extends BaseController {
}); });
} }
assetCurrent.setGlym(a.toString()); assetCurrent.setGlym(a.toString());
StringBuilder b = new StringBuilder();
if (assetCurrent.getGlIpList() != null) { if (assetCurrent.getGlIpList() != null) {
assetCurrent.getGlIpList().forEach(x -> { assetCurrent.setGlIp(assetCurrent.getGlIpList().toString());
if (!Objects.equals(x.getKey(), "") && x.getKey() != null) { } else {
b.append(x.getKey()); assetCurrent.setGlIp("");
b.append(",");
}
});
} }
assetCurrent.setGlIp(b.toString()); // assetCurrent.setGlIp(b.toString());
assetCurrentService.save(assetCurrent); assetCurrentService.save(assetCurrent);
//新增新监管业务形态 //新增新监管业务形态
if (assetCurrent.getXjgywxt() != null) { if (assetCurrent.getXjgywxt() != null) {
@ -389,16 +388,20 @@ public class AssetCurrentController extends BaseController {
byId.setGlymList(new ArrayList<>()); byId.setGlymList(new ArrayList<>());
} }
List<Acomma> a2 = new ArrayList<>(); List<Acomma> a2 = new ArrayList<>();
if (byId.getGlIp() != null) { if(byId.getGlIp()!=null&& !byId.getGlIp().isEmpty()){
Arrays.asList(byId.getGlIp().split(",")).forEach(x -> { for (Object o : JSONArray.parseArray(byId.getGlIp())) {
Acomma acomma = new Acomma(); 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); a2.add(acomma);
}); }
byId.setGlIpList(a2); byId.setGlIpList(a2);
} else { }else {
byId.setGlIpList(new ArrayList<>()); byId.setGlIpList(new ArrayList<>());
} }
return success(byId); return success(byId);
} }
@ -535,16 +538,18 @@ public class AssetCurrentController extends BaseController {
}); });
} }
assetCurrent.setGlym(a.toString()); assetCurrent.setGlym(a.toString());
StringBuilder b = new StringBuilder();
if (assetCurrent.getGlIpList() != null) { if (assetCurrent.getGlIpList() != null) {
assetCurrent.getGlIpList().forEach(x -> { // assetCurrent.getGlIpList().forEach(x -> {
if (!Objects.equals(x.getKey(), "") && x.getKey() != null) { // if (!Objects.equals(x.getKey(), "") && x.getKey() != null) {
b.append(x.getKey()); // b.append(x.getKey());
b.append(","); // b.append(",");
} // }
}); // });
assetCurrent.setGlIp(assetCurrent.getGlIpList().toString());
} else {
assetCurrent.setGlIp("");
} }
assetCurrent.setGlIp(b.toString());
if (!assetCurrent.getXtzt().equals("7")) { if (!assetCurrent.getXtzt().equals("7")) {
assetCurrent.setBtgyy(null); assetCurrent.setBtgyy(null);
} }

@ -82,57 +82,57 @@ public class WithoutController extends BaseController {
return AjaxResult.success(unitService.selectAllUnit(req)); return AjaxResult.success(unitService.selectAllUnit(req));
} }
/** // /**
* // * 根据查询条件查询所有单位列表
* // *
* @return // * @return 单位
*/ // */
@ApiOperation(value = "获取所有单位列表213", response = Unit.class) // @ApiOperation(value = "获取所有单位列表213", response = Unit.class)
@GetMapping("/test") // @GetMapping("/test")
public void test() { // public void test() {
sendSms("123", "17638176947", "120ErrorMes"); // sendSms("123", "17638176947", "120ErrorMes");
} // }
//
/** // /**
* // * 发送短信
* // *
* @param content // * @param content 短信内容
* @param tel 使, // * @param tel 手机号多个使用,拼接
* @param errorMes rediskey // * @param errorMes 异常通知的类别 即redis的key
*/ // */
public void sendSms(String content, String tel, String errorMes) { // public void sendSms(String content, String tel, String errorMes) {
if (errorMes != null) { // if (errorMes != null) {
Integer minutes = redisCache.getCacheObject(errorMes); // Integer minutes = redisCache.getCacheObject(errorMes);
if (minutes == null) { // if (minutes == null) {
redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES); // redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES);
return; // return;
} // }
if (minutes < 10) { // if (minutes < 10) {
long expireTime = redisCache.getExpire(errorMes); // long expireTime = redisCache.getExpire(errorMes);
if (expireTime == -1 || expireTime == -2) { // if (expireTime == -1 || expireTime == -2) {
redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES); // redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES);
} else { // } else {
redisCache.setCacheObject(errorMes, minutes + 1, (int) expireTime, TimeUnit.SECONDS); // redisCache.setCacheObject(errorMes, minutes + 1, (int) expireTime, TimeUnit.SECONDS);
} // }
return; // return;
} // }
} // }
// 限制每种tel每天只能发一次短信 // // 限制每种tel每天只能发一次短信
Map<String, Object> dataKey = redisCache.getCacheMap("dataKey"); // Map<String, Object> dataKey = redisCache.getCacheMap("dataKey");
if (CollectionUtil.isNotEmpty(dataKey)) { // if (CollectionUtil.isNotEmpty(dataKey)) {
String sendDateStr = (String) dataKey.get(content); // String sendDateStr = (String) dataKey.get(content);
LocalDate sendDate = LocalDate.parse(sendDateStr); // LocalDate sendDate = LocalDate.parse(sendDateStr);
if (LocalDate.now().equals(sendDate)) { // if (LocalDate.now().equals(sendDate)) {
return; // return;
} else { // } else {
dataKey.put(content, LocalDate.now()); // dataKey.put(content, LocalDate.now());
redisCache.setCacheMap("dataKey", dataKey); // redisCache.setCacheMap("dataKey", dataKey);
} // }
} else { // } else {
Map<String, Object> map = new HashMap<>(); // Map<String, Object> map = new HashMap<>();
map.put(content, LocalDate.now()); // map.put(content, LocalDate.now());
redisCache.setCacheMap("dataKey", map); // redisCache.setCacheMap("dataKey", map);
} // }
System.err.println("已经发送短信"); // System.err.println("已经发送短信");
} // }
} }

@ -10,6 +10,18 @@ import lombok.Data;
@Data @Data
public class Acomma { public class Acomma {
@Override
public String toString() {
return "{\"key\": \"" + key + "\", \"ipType\": \"" + ipType + "\", \"port\": " + port + "}";
}
@ApiModelProperty("key") @ApiModelProperty("key")
private String key; private String key;
@ApiModelProperty("ipType")
private String ipType;
@ApiModelProperty("port")
private String port;
} }

@ -1,5 +1,7 @@
package com.ruoyi.tc.service.impl; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.tc.entity.*; import com.ruoyi.tc.entity.*;
@ -83,17 +85,22 @@ public class AssetCurrentServiceImpl extends ServiceImpl<AssetCurrentMapper, Ass
}else { }else {
byId.setGlymList(new ArrayList<>()); byId.setGlymList(new ArrayList<>());
} }
List<Acomma> a2 = new ArrayList<>(); List<Acomma> a2 = new ArrayList<>();
if(byId.getGlIp()!=null){ if(byId.getGlIp()!=null&& !byId.getGlIp().isEmpty()){
Arrays.asList(byId.getGlIp().split(",")).forEach(x -> { for (Object o : JSONArray.parseArray(byId.getGlIp())) {
Acomma acomma = new Acomma(); 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); a2.add(acomma);
}); }
byId.setGlIpList(a2); byId.setGlIpList(a2);
}else { }else {
byId.setGlIpList(new ArrayList<>()); byId.setGlIpList(new ArrayList<>());
} }
return byId; return byId;
} }

Loading…
Cancel
Save