提交修改设备更新时关联组态更新
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.xinda.system.controller;
|
||||
package com.xinda.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -435,6 +435,14 @@ public class DeviceController extends BaseController
|
||||
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);
|
||||
|
||||
@@ -275,7 +275,7 @@ public class ScadaController extends BaseController
|
||||
@ApiOperation("获取绑定设备物模型列表")
|
||||
@PreAuthorize("@ss.hasPermi('scada:center:query')")
|
||||
@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<>();
|
||||
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);
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
@@ -374,6 +375,22 @@ public class ScadaController extends BaseController
|
||||
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文件
|
||||
* @param file 文件
|
||||
|
||||
@@ -121,4 +121,5 @@ public interface ScadaMapper
|
||||
|
||||
|
||||
Long selectDeptIdBySn(@Param("serialNumber") String serialNumber);
|
||||
|
||||
}
|
||||
|
||||
@@ -126,4 +126,6 @@ public interface IScadaService
|
||||
List<ScadaVO> listScadaVO(Scada scadaQuery);
|
||||
|
||||
AjaxResult importJson(MultipartFile file, String guid) throws IOException;
|
||||
|
||||
int updateScadaDept(Scada scada);
|
||||
}
|
||||
|
||||
@@ -238,6 +238,12 @@ public class ScadaServiceImpl implements IScadaService
|
||||
return scadaMapper.updateScada(scada);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int updateScadaDept(Scada scada) {
|
||||
return scadaMapper.updateScada(scada);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除组态中心
|
||||
*
|
||||
|
||||
@@ -339,10 +339,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectDeptIdBySn" resultType="java.lang.Long">
|
||||
<select id="selectDeptIdBySn" parameterType="String" resultType="java.lang.Long">
|
||||
select agencies_id
|
||||
from iot_device
|
||||
where serial_number = #{serial_number}
|
||||
where serial_number = #{serialNumber}
|
||||
and del_flag = '0'
|
||||
</select>
|
||||
|
||||
|
||||
@@ -105,15 +105,15 @@ public class AuthService {
|
||||
log.warn("=>设备端认证失败");
|
||||
throw new ServiceException("设备端认证失败:" + response.getBody());
|
||||
}
|
||||
}else if (clientId.startsWith("8")) {
|
||||
// 设备端认证
|
||||
ResponseEntity response = toolService.clientAuthNoClient(clientId, username, password);
|
||||
if (response.getStatusCodeValue() == HttpStatus.OK.value()) {
|
||||
return true;
|
||||
} else {
|
||||
log.warn("=>设备端认证失败");
|
||||
throw new ServiceException("设备端认证失败:" + response.getBody());
|
||||
}
|
||||
// }else if (clientId.startsWith("8")) {
|
||||
// // 设备端认证
|
||||
// ResponseEntity response = toolService.clientAuthNoClient(clientId, username, password);
|
||||
// if (response.getStatusCodeValue() == HttpStatus.OK.value()) {
|
||||
// return true;
|
||||
// } else {
|
||||
// log.warn("=>设备端认证失败");
|
||||
// throw new ServiceException("设备端认证失败:" + response.getBody());
|
||||
// }
|
||||
} else {
|
||||
Product product = productService.selectProductByProductId(147L);
|
||||
if (!username.equals(product.getMqttAccount()) && !password.equals(product.getMqttPassword())) {
|
||||
|
||||
@@ -1304,9 +1304,11 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
}
|
||||
// 设备下不能有场景联动
|
||||
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("删除失败,请先删除对应设备下的场景联动");
|
||||
}
|
||||
|
||||
|
||||
// 查绑定用户被分享用户配置的场景,需要把场景删掉
|
||||
DeviceUser deviceUser = deviceUserMapper.selectDeviceUserByDeviceId(deviceId);
|
||||
List<Long> userIdSceneList = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user