|
@ -15,7 +15,12 @@ import com.storeroom.modules.storeroom3d.service.impl.AlarmInfoServiceImpl; |
|
|
import com.storeroom.modules.storeroom3d.service.impl.ThirdApiServiceImpl; |
|
|
import com.storeroom.modules.storeroom3d.service.impl.ThirdApiServiceImpl; |
|
|
import com.storeroom.utils.*; |
|
|
import com.storeroom.utils.*; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
import org.apache.http.HttpEntity; |
|
|
import org.apache.http.HttpResponse; |
|
|
import org.apache.http.HttpResponse; |
|
|
|
|
|
import org.apache.http.client.HttpClient; |
|
|
|
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
import org.springframework.data.domain.Page; |
|
|
import org.springframework.data.domain.Page; |
|
|
import org.springframework.data.domain.Pageable; |
|
|
import org.springframework.data.domain.Pageable; |
|
@ -24,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.ObjectUtils; |
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
|
|
import java.io.InputStreamReader; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -491,6 +498,43 @@ public class DeviceImpl implements DeviceService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Integer getDeviceTypeNum(String deviceTypeId) { |
|
|
public Integer getDeviceTypeNum(String deviceTypeId) { |
|
|
|
|
|
//桌面式RFID读写器 |
|
|
|
|
|
if("E2767FEACA9CE0E3B16B89".equals(deviceTypeId)){ |
|
|
|
|
|
Integer count = 0; |
|
|
|
|
|
List<DeviceInfo> deviceInfos = deviceInfoRepository.findByDeviceTypeId(deviceTypeId); |
|
|
|
|
|
for(DeviceInfo deviceInfo:deviceInfos){ |
|
|
|
|
|
try { |
|
|
|
|
|
HttpClient client = HttpClients.createDefault(); |
|
|
|
|
|
String url2 = "http://" + deviceInfo.getDeviceIp() + ":" + deviceInfo.getDevicePort() + "/RFIDInterface.aspx?op=RFID_CheckStatus&sDevID=" + deviceInfo.getDeviceId(); |
|
|
|
|
|
HttpGet httpGet = new HttpGet(url2); |
|
|
|
|
|
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded"); |
|
|
|
|
|
//httpClient实例化 |
|
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
|
|
|
// 执行请求并获取返回 |
|
|
|
|
|
HttpResponse response = httpClient.execute(httpGet); |
|
|
|
|
|
HttpEntity entity = response.getEntity(); |
|
|
|
|
|
// 显示结果 |
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8")); |
|
|
|
|
|
String line = null; |
|
|
|
|
|
StringBuffer responseSB = new StringBuffer(); |
|
|
|
|
|
while ((line = reader.readLine()) != null) { |
|
|
|
|
|
if (line.contains("<!")) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
responseSB.append(line.trim()); |
|
|
|
|
|
} |
|
|
|
|
|
reader.close(); |
|
|
|
|
|
httpClient.close(); |
|
|
|
|
|
JSONObject jsonRF = JSONObject.parseObject(responseSB.toString()); |
|
|
|
|
|
if("0".equals(jsonRF.get("code")+"")){ |
|
|
|
|
|
count ++; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
} |
|
|
|
|
|
return count; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return deviceInfoRepository.countByDeviceTypeId(deviceTypeId); |
|
|
return deviceInfoRepository.countByDeviceTypeId(deviceTypeId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -598,6 +642,35 @@ public class DeviceImpl implements DeviceService { |
|
|
//通道门 摄像头 |
|
|
//通道门 摄像头 |
|
|
}else if("65D1886B0F864291766421".equals(deviceInfoTypeId) || "7305DE3D273B0CAC079538".equals(deviceInfoTypeId)){ |
|
|
}else if("65D1886B0F864291766421".equals(deviceInfoTypeId) || "7305DE3D273B0CAC079538".equals(deviceInfoTypeId)){ |
|
|
deviceInfo.setDeviceState(1); |
|
|
deviceInfo.setDeviceState(1); |
|
|
|
|
|
//桌面式RFID读写器 |
|
|
|
|
|
}else if("E2767FEACA9CE0E3B16B89".equals(deviceInfoTypeId)){ |
|
|
|
|
|
try { |
|
|
|
|
|
HttpClient client = HttpClients.createDefault(); |
|
|
|
|
|
String url2 = "http://" + deviceInfo.getDeviceIp() + ":" + deviceInfo.getDevicePort() + "/RFIDInterface.aspx?op=RFID_CheckStatus&sDevID=" + deviceInfo.getDeviceId(); |
|
|
|
|
|
HttpGet httpGet = new HttpGet(url2); |
|
|
|
|
|
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded"); |
|
|
|
|
|
//httpClient实例化 |
|
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
|
|
|
// 执行请求并获取返回 |
|
|
|
|
|
HttpResponse response = httpClient.execute(httpGet); |
|
|
|
|
|
HttpEntity entity = response.getEntity(); |
|
|
|
|
|
// 显示结果 |
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8")); |
|
|
|
|
|
String line = null; |
|
|
|
|
|
StringBuffer responseSB = new StringBuffer(); |
|
|
|
|
|
while ((line = reader.readLine()) != null) { |
|
|
|
|
|
if (line.contains("<!")) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
responseSB.append(line.trim()); |
|
|
|
|
|
} |
|
|
|
|
|
reader.close(); |
|
|
|
|
|
httpClient.close(); |
|
|
|
|
|
JSONObject jsonRF = JSONObject.parseObject(responseSB.toString()); |
|
|
|
|
|
deviceInfo.setDeviceState("0".equals(jsonRF.get("code")+"")?1:2); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
deviceInfo.setDeviceState(2); |
|
|
|
|
|
} |
|
|
//空调 恒湿机 漏水传感器 温湿度感应器 空气质量检测设备 |
|
|
//空调 恒湿机 漏水传感器 温湿度感应器 空气质量检测设备 |
|
|
}else if("7882487E0C15304A3758AF".equals(deviceInfoTypeId) || "250AE644EC43E4EC954A81".equals(deviceInfoTypeId) || |
|
|
}else if("7882487E0C15304A3758AF".equals(deviceInfoTypeId) || "250AE644EC43E4EC954A81".equals(deviceInfoTypeId) || |
|
|
"C09A1946216E496BB3FA88".equals(deviceInfoTypeId) || "89284777EFADA87FA342A7".equals(deviceInfoTypeId) || |
|
|
"C09A1946216E496BB3FA88".equals(deviceInfoTypeId) || "89284777EFADA87FA342A7".equals(deviceInfoTypeId) || |
|
@ -605,10 +678,10 @@ public class DeviceImpl implements DeviceService { |
|
|
if (!StringUtils.isEmpty(token)) { |
|
|
if (!StringUtils.isEmpty(token)) { |
|
|
deviceInfo.setDeviceState(1); |
|
|
deviceInfo.setDeviceState(1); |
|
|
}else{ |
|
|
}else{ |
|
|
deviceInfo.setDeviceState(0); |
|
|
|
|
|
|
|
|
deviceInfo.setDeviceState(2); |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
}else{ |
|
|
deviceInfo.setDeviceState(0); |
|
|
|
|
|
|
|
|
deviceInfo.setDeviceState(2); |
|
|
} |
|
|
} |
|
|
newList.add(deviceInfo); |
|
|
newList.add(deviceInfo); |
|
|
} |
|
|
} |
|
|