修改关联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 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<Acomma> 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);
}

@ -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 rediskey
*/
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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> map = new HashMap<>();
// map.put(content, LocalDate.now());
// redisCache.setCacheMap("dataKey", map);
// }
// System.err.println("已经发送短信");
// }
}

@ -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;
}

@ -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<AssetCurrentMapper, Ass
}else {
byId.setGlymList(new ArrayList<>());
}
List<Acomma> 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;
}

Loading…
Cancel
Save