|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.storeroom.modules.device.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.storeroom.exception.BaseException; |
|
|
|
import com.storeroom.modules.device.domain.*; |
|
|
|
import com.storeroom.modules.device.repository.*; |
|
|
@ -8,10 +9,14 @@ import com.storeroom.modules.device.service.dto.DeviceInfoDto; |
|
|
|
import com.storeroom.modules.device.service.dto.DeviceTypeDto; |
|
|
|
import com.storeroom.modules.device.service.mapstruct.DeviceInfoMapper; |
|
|
|
import com.storeroom.modules.device.service.mapstruct.DeviceTypeMapper; |
|
|
|
import com.storeroom.modules.storeroom3d.service.AlarmInfoService; |
|
|
|
import com.storeroom.modules.storeroom3d.service.ThirdApiService; |
|
|
|
import com.storeroom.modules.storeroom3d.service.impl.AlarmInfoServiceImpl; |
|
|
|
import com.storeroom.modules.storeroom3d.service.impl.ThirdApiServiceImpl; |
|
|
|
import com.storeroom.utils.*; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.apache.http.HttpResponse; |
|
|
|
import org.apache.http.util.EntityUtils; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -27,7 +32,8 @@ import java.util.stream.Collectors; |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DeviceImpl implements DeviceService { |
|
|
|
|
|
|
|
|
|
|
|
private final AlarmInfoService alarmInfoService; |
|
|
|
private final ThirdApiService thirdApiService; |
|
|
|
private final DeviceInfoRepository deviceInfoRepository; |
|
|
|
private final DeviceInfoMapper deviceInfoMapper; |
|
|
|
private final OperatingStateRepository operatingStateRepository; |
|
|
@ -55,7 +61,8 @@ public class DeviceImpl implements DeviceService { |
|
|
|
item.setDeviceState(0); |
|
|
|
}); |
|
|
|
} |
|
|
|
return PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
Map<String,Object> map = PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
return this.transformationDeviceState(map); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -71,7 +78,8 @@ public class DeviceImpl implements DeviceService { |
|
|
|
item.setDeviceState(0); |
|
|
|
}); |
|
|
|
} |
|
|
|
return PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
Map<String,Object> map = PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
return this.transformationDeviceState(map); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -88,7 +96,8 @@ public class DeviceImpl implements DeviceService { |
|
|
|
item.setDeviceState(0); |
|
|
|
}); |
|
|
|
} |
|
|
|
return PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
Map<String,Object> map = PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
return this.transformationDeviceState(map); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -104,7 +113,8 @@ public class DeviceImpl implements DeviceService { |
|
|
|
item.setDeviceState(0); |
|
|
|
}); |
|
|
|
} |
|
|
|
return PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
Map<String,Object> map = PageUtil.toPage(page.map(deviceInfoMapper::toDto)); |
|
|
|
return this.transformationDeviceState(map); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -562,5 +572,48 @@ public class DeviceImpl implements DeviceService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public Map<String,Object> transformationDeviceState(Map<String,Object> map){ |
|
|
|
String url = alarmInfoService.getAddressUrl(); |
|
|
|
String token = thirdApiService.getToken(url); |
|
|
|
List<DeviceInfoDto> list = (List<DeviceInfoDto>) map.get("content"); |
|
|
|
List<DeviceInfoDto> newList = new ArrayList<>(); |
|
|
|
for(DeviceInfoDto deviceInfo:list){ |
|
|
|
String deviceInfoTypeId = deviceInfo.getDeviceTypeId().getId(); |
|
|
|
//密集架 |
|
|
|
if("DD656054BE3D1DF1E2F1FC".equals(deviceInfo.getDeviceTypeId())){ |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("StoreCode", deviceInfo.getStoreroomCode() == null?"12345678":deviceInfo.getStoreroomCode()); |
|
|
|
json.put("QuNo",deviceInfo.getAreaNo()); |
|
|
|
try { |
|
|
|
String url1 = "http://" + deviceInfo.getDeviceIp() + ":" + deviceInfo.getDevicePort(); |
|
|
|
HashMap<String, String> llmap = new HashMap<>(); |
|
|
|
llmap.put("Content-type", "application/json"); |
|
|
|
HttpResponse response = HttpUtils.doPost(url1, "/IntelligentCabinetAPIServer/ReportStatus", |
|
|
|
"POST", llmap, null, json.toJSONString()); |
|
|
|
String retust = EntityUtils.toString(response.getEntity()); |
|
|
|
deviceInfo.setDeviceState(1); |
|
|
|
}catch (Exception e){ |
|
|
|
deviceInfo.setDeviceState(2); |
|
|
|
} |
|
|
|
//通道门 摄像头 |
|
|
|
}else if("65D1886B0F864291766421".equals(deviceInfoTypeId) || "7305DE3D273B0CAC079538".equals(deviceInfoTypeId)){ |
|
|
|
deviceInfo.setDeviceState(1); |
|
|
|
//空调 恒湿机 漏水传感器 温湿度感应器 空气质量检测设备 |
|
|
|
}else if("7882487E0C15304A3758AF".equals(deviceInfoTypeId) || "250AE644EC43E4EC954A81".equals(deviceInfoTypeId) || |
|
|
|
"C09A1946216E496BB3FA88".equals(deviceInfoTypeId) || "89284777EFADA87FA342A7".equals(deviceInfoTypeId) || |
|
|
|
"E58C8D7C896BCB9A408A78".equals(deviceInfoTypeId)){ |
|
|
|
if (!StringUtils.isEmpty(token)) { |
|
|
|
deviceInfo.setDeviceState(1); |
|
|
|
}else{ |
|
|
|
deviceInfo.setDeviceState(0); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
deviceInfo.setDeviceState(0); |
|
|
|
} |
|
|
|
newList.add(deviceInfo); |
|
|
|
} |
|
|
|
map.put("content",newList); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
} |