提交修改设备更新时关联组态更新

This commit is contained in:
LEED
2025-07-13 17:05:39 +08:00
parent ac40c5e5ec
commit 4c1521bda0
9 changed files with 50 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
package com.xinda.system.controller; package com.xinda.web.controller.system;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;

View File

@@ -435,6 +435,14 @@ public class DeviceController extends BaseController
device.setGuid(uuid.toString()); device.setGuid(uuid.toString());
} }
} }
}else{
Scada scada = scadaService.selectScadaByGuid(device.getGuid());
if(scada!=null){
scada.setTenantId(device.getTenantId());
scada.setTenantName(device.getTenantName());
scada.setDeptId(device.getAgenciesId());
scadaService.updateScadaDept(scada);
}
} }
return deviceService.updateDevice(device); return deviceService.updateDevice(device);

View File

@@ -275,7 +275,7 @@ public class ScadaController extends BaseController
@ApiOperation("获取绑定设备物模型列表") @ApiOperation("获取绑定设备物模型列表")
@PreAuthorize("@ss.hasPermi('scada:center:query')") @PreAuthorize("@ss.hasPermi('scada:center:query')")
@GetMapping("/listDeviceThingsModel") @GetMapping("/listDeviceThingsModel")
public TableDataInfo getBindDatalist(Integer pageNum, Integer pageSize, String scadaGuid, String serialNumber) public TableDataInfo getBindDatalist(Integer pageNum, Integer pageSize, String scadaGuid, String serialNumber,String deviceName,String identifier)
{ {
List<DeviceRealDataVO> list= new ArrayList<>(); List<DeviceRealDataVO> list= new ArrayList<>();
if(StringUtils.isEmpty(scadaGuid)){ if(StringUtils.isEmpty(scadaGuid)){
@@ -365,6 +365,7 @@ public class ScadaController extends BaseController
} }
} }
} }
list = filterDevices(list,deviceName,identifier);
List resultList = ScadaCollectionUtils.startPage(list, pageNum, pageSize); List resultList = ScadaCollectionUtils.startPage(list, pageNum, pageSize);
TableDataInfo rspData = new TableDataInfo(); TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS); rspData.setCode(HttpStatus.SUCCESS);
@@ -374,6 +375,22 @@ public class ScadaController extends BaseController
return rspData; return rspData;
} }
public List<DeviceRealDataVO> filterDevices(List<DeviceRealDataVO> list, String deviceName, String identifier) {
return list.stream()
.filter(device -> {
// 过滤条件deviceName 非空且匹配(忽略大小写)
boolean nameMatch = deviceName == null || deviceName.isEmpty() ||
device.getDeviceName().equalsIgnoreCase(deviceName);
// 过滤条件identifier 非空且匹配(忽略大小写)
boolean idMatch = identifier == null || identifier.isEmpty() ||
device.getIdentifier().equalsIgnoreCase(identifier);
return nameMatch && idMatch;
})
.collect(Collectors.toList());
}
/** /**
* 导入json文件 * 导入json文件
* @param file 文件 * @param file 文件

View File

@@ -121,4 +121,5 @@ public interface ScadaMapper
Long selectDeptIdBySn(@Param("serialNumber") String serialNumber); Long selectDeptIdBySn(@Param("serialNumber") String serialNumber);
} }

View File

@@ -126,4 +126,6 @@ public interface IScadaService
List<ScadaVO> listScadaVO(Scada scadaQuery); List<ScadaVO> listScadaVO(Scada scadaQuery);
AjaxResult importJson(MultipartFile file, String guid) throws IOException; AjaxResult importJson(MultipartFile file, String guid) throws IOException;
int updateScadaDept(Scada scada);
} }

View File

@@ -238,6 +238,12 @@ public class ScadaServiceImpl implements IScadaService
return scadaMapper.updateScada(scada); return scadaMapper.updateScada(scada);
} }
@Override
public int updateScadaDept(Scada scada) {
return scadaMapper.updateScada(scada);
}
/** /**
* 批量删除组态中心 * 批量删除组态中心
* *

View File

@@ -339,10 +339,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and del_flag = '0' and del_flag = '0'
</select> </select>
<select id="selectDeptIdBySn" resultType="java.lang.Long"> <select id="selectDeptIdBySn" parameterType="String" resultType="java.lang.Long">
select agencies_id select agencies_id
from iot_device from iot_device
where serial_number = #{serial_number} where serial_number = #{serialNumber}
and del_flag = '0' and del_flag = '0'
</select> </select>

View File

@@ -105,15 +105,15 @@ public class AuthService {
log.warn("=>设备端认证失败"); log.warn("=>设备端认证失败");
throw new ServiceException("设备端认证失败:" + response.getBody()); throw new ServiceException("设备端认证失败:" + response.getBody());
} }
}else if (clientId.startsWith("8")) { // }else if (clientId.startsWith("8")) {
// 设备端认证 // // 设备端认证
ResponseEntity response = toolService.clientAuthNoClient(clientId, username, password); // ResponseEntity response = toolService.clientAuthNoClient(clientId, username, password);
if (response.getStatusCodeValue() == HttpStatus.OK.value()) { // if (response.getStatusCodeValue() == HttpStatus.OK.value()) {
return true; // return true;
} else { // } else {
log.warn("=>设备端认证失败"); // log.warn("=>设备端认证失败");
throw new ServiceException("设备端认证失败:" + response.getBody()); // throw new ServiceException("设备端认证失败:" + response.getBody());
} // }
} else { } else {
Product product = productService.selectProductByProductId(147L); Product product = productService.selectProductByProductId(147L);
if (!username.equals(product.getMqttAccount()) && !password.equals(product.getMqttPassword())) { if (!username.equals(product.getMqttAccount()) && !password.equals(product.getMqttPassword())) {

View File

@@ -1304,9 +1304,11 @@ public class DeviceServiceImpl implements IDeviceService {
} }
// 设备下不能有场景联动 // 设备下不能有场景联动
List<SceneDeviceBindVO> sceneDeviceBindVOList = sceneDeviceMapper.listSceneDeviceBind(device.getSerialNumber()); List<SceneDeviceBindVO> sceneDeviceBindVOList = sceneDeviceMapper.listSceneDeviceBind(device.getSerialNumber());
if (null != sceneDeviceBindVOList.stream().filter(s -> s.getUserId().equals(sceneUserId)).findAny().orElse(null)) { if (null != sceneDeviceBindVOList.stream().filter(s -> null != s.getUserId() && sceneUserId.equals(s.getUserId())).findAny().orElse(null)) {
return AjaxResult.error("删除失败,请先删除对应设备下的场景联动"); return AjaxResult.error("删除失败,请先删除对应设备下的场景联动");
} }
// 查绑定用户被分享用户配置的场景,需要把场景删掉 // 查绑定用户被分享用户配置的场景,需要把场景删掉
DeviceUser deviceUser = deviceUserMapper.selectDeviceUserByDeviceId(deviceId); DeviceUser deviceUser = deviceUserMapper.selectDeviceUserByDeviceId(deviceId);
List<Long> userIdSceneList = new ArrayList<>(); List<Long> userIdSceneList = new ArrayList<>();