雷达新增和删除

detached
王宇航 2024-01-25 10:24:14 +08:00
parent c403a9622f
commit f1af214b75
4 changed files with 19 additions and 3 deletions

View File

@ -43,6 +43,7 @@ import java.sql.Statement;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
/**
*
@ -183,6 +184,7 @@ public class RadarStatusController implements InitializingBean {
try {
Socket socket = new Socket(radar.getRadarIp(), 23);
SocketModel socketModel = new SocketModel();
socketModel.setId(radar.getId());
socketModel.setRadarLocation(radar.getRadarLocation());
socketModel.setSocket(socket);
socketModel.setRadarIp(radar.getRadarIp());
@ -193,6 +195,17 @@ public class RadarStatusController implements InitializingBean {
}
}
public static void addRadar(List<SysRadar> radarList) {
List<Long> idList = allRadar.stream().map(SocketModel::getId).collect(Collectors.toList());
List<SysRadar> filterList = radarList.stream().filter(item -> !idList.contains(item.getId())).collect(Collectors.toList());
buildAllRadar(filterList);
}
public static void delRadar(Long id) {
allRadar.removeIf(item -> item.getId().equals(id));
}
private void asyncReadRadar(SocketModel socketModel) {
CompletableFuture.runAsync(()->{
try {

View File

@ -73,7 +73,8 @@ public class SysRadarController extends BaseController {
public AjaxResult addSave(@Validated SysRadar radar) {
radar.setCreateBy(getLoginName());
int result = radarService.insertRadar(radar);
RadarStatusController.buildAllRadar(radarService.selectRadarList(new SysRadar()));
List<SysRadar> sysRadars = radarService.selectRadarList(new SysRadar());
RadarStatusController.addRadar(sysRadars);
return toAjax(result);
}
@ -106,7 +107,7 @@ public class SysRadarController extends BaseController {
@ResponseBody
public AjaxResult remove(String ids) {
int result = radarService.deleteRadarByIds(ids);
RadarStatusController.buildAllRadar(radarService.selectRadarList(new SysRadar()));
RadarStatusController.delRadar(Long.valueOf(ids));
return toAjax(result);
}

View File

@ -6,6 +6,8 @@ import java.net.Socket;
@Data
public class SocketModel {
private Long id;
private String radarIp;
private String radarLocation;

View File

@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sort != null and sort != 0">
AND r.sort = #{sort}
</if>
order by id asc
order by id desc
</select>
<insert id="insertRadar">