安防门状态改成实时数据
This commit is contained in:
parent
87d2232fcd
commit
d0d7f46fc8
@ -18,6 +18,8 @@ import com.fastbee.iot.haiwei.service.HaiWeiService;
|
||||
import com.fastbee.iot.mapper.DeviceMapper;
|
||||
import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||
import com.fastbee.iot.model.haiwei.CmdHaiWeiVo;
|
||||
import com.fastbee.iot.model.haiwei.HaiWeiDeviceInfoVo;
|
||||
import com.fastbee.iot.model.haiwei.HaiWeiPropertyVo;
|
||||
import com.fastbee.iot.model.haiwei.dto.CmdHaiWeiDto;
|
||||
import com.fastbee.iot.service.IDeviceLogService;
|
||||
import com.fastbee.iot.service.IDeviceService;
|
||||
@ -178,20 +180,36 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService {
|
||||
if (StringUtils.isNotEmpty(anfangIds)) {
|
||||
Device anfangDevice = iDeviceService.selectDeviceByDeviceId(Long.parseLong(anfangIds));
|
||||
//获取当前安防告警状态
|
||||
|
||||
CommonResult<HaiWeiDeviceInfoVo> cache = haiWeiService.getCache(anfangDevice.getDeviceId());
|
||||
HaiWeiDeviceInfoVo checkedData = cache.getCheckedData();
|
||||
List<HaiWeiPropertyVo> propertyList = checkedData.getPropertyList();
|
||||
for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) {
|
||||
if (haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_open")) {
|
||||
// HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
// put("upType", 0);
|
||||
// put("identifier", "xiangmen");
|
||||
// put("unit", "");
|
||||
// put("value", haiWeiPropertyVo.getValue());
|
||||
// put("name", haiWeiPropertyVo.getNameCn());
|
||||
// }};
|
||||
anfangInfoVo.setDoorStatus(Integer.parseInt(haiWeiPropertyVo.getValue().toString()));
|
||||
}
|
||||
}
|
||||
UploadedPhotos uploadedPhotos = new UploadedPhotos();
|
||||
uploadedPhotos.setSn(anfangDevice.getSerialNumber());
|
||||
List<UploadedPhotos> uploadedPhotos1 = uploadedPhotosService.selectUploadedPhotosList(uploadedPhotos);
|
||||
int doorStatus = 0;//0=正常,1=箱门振动,2=箱门打开
|
||||
if (uploadedPhotos1.size() > 0) {
|
||||
UploadedPhotos temp = uploadedPhotos1.get(0);
|
||||
if (new Date().getTime() - temp.getUploadTime().getTime() < 36000000) {
|
||||
if (temp.getShakeState().equals("1")) {
|
||||
doorStatus = 1;
|
||||
}
|
||||
if (temp.getDoorState().equals("1")) {
|
||||
doorStatus = 2;
|
||||
}
|
||||
}
|
||||
// if (new Date().getTime() - temp.getUploadTime().getTime() < 36000000) {
|
||||
// if (temp.getShakeState().equals("1")) {
|
||||
// doorStatus = 1;
|
||||
// }
|
||||
// if (temp.getDoorState().equals("1")) {
|
||||
// doorStatus = 2;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (uploadedPhotos1.size() > 5) {
|
||||
uploadedPhotos1 = uploadedPhotos1.subList(0, 5);
|
||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fastbee.common.core.domain.CommonResult;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
import com.fastbee.common.model.vo.TreeItemVo;
|
||||
import com.fastbee.common.model.vo.iot.GisDeviceListVo;
|
||||
@ -18,8 +19,11 @@ import com.fastbee.iot.domain.Device;
|
||||
import com.fastbee.iot.domain.DeviceLog;
|
||||
import com.fastbee.iot.domain.Product;
|
||||
import com.fastbee.iot.domain.ThingsModel;
|
||||
import com.fastbee.iot.haiwei.service.HaiWeiService;
|
||||
import com.fastbee.iot.mapper.DeviceMapper;
|
||||
import com.fastbee.iot.mapper.ProductMapper;
|
||||
import com.fastbee.iot.model.haiwei.HaiWeiDeviceInfoVo;
|
||||
import com.fastbee.iot.model.haiwei.HaiWeiPropertyVo;
|
||||
import com.fastbee.iot.service.*;
|
||||
import com.fastbee.waterele.domain.MaWatereleRecord;
|
||||
import com.fastbee.waterele.service.IMaWatereleRecordService;
|
||||
@ -55,6 +59,8 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
@Autowired
|
||||
private IMaWatereleRecordService watereleRecordService;
|
||||
|
||||
@Resource
|
||||
HaiWeiService haiWeiService;
|
||||
|
||||
public GisDeviceServiceImpl(@Qualifier("deviceMapper") DeviceMapper deviceMapper, @Qualifier("productMapper") ProductMapper productMapper) {
|
||||
this.deviceMapper = deviceMapper;
|
||||
@ -156,15 +162,15 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
if (hashMap.size() > 1) {
|
||||
List<DeviceLog> deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs1 != null) {
|
||||
if(deviceLogs1.size() > 0){
|
||||
if (deviceLogs1.size() > 0) {
|
||||
if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) {
|
||||
if(deviceLogs1.size() > 1){
|
||||
if (deviceLogs1.size() > 1) {
|
||||
if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap.put("upType", 1);
|
||||
} else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap.put("upType", -1);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
hashMap.put("upType", 0);
|
||||
}
|
||||
hashMap.put("value", deviceLogs1.get(0).getLogValue());
|
||||
@ -173,7 +179,7 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
hashMap.put("upType", 0);
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
hashMap.put("value", "--");
|
||||
hashMap.put("upType", 0);
|
||||
}
|
||||
@ -202,90 +208,34 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
}
|
||||
//箱门信息
|
||||
String guimenIds = devParams.get("guimenIds").toString();
|
||||
ThingsModel thingsModel3 = new ThingsModel();
|
||||
thingsModel3.setProductId(140L);
|
||||
List<ThingsModel> guimenModels = thingsModelService.selectThingsModelList(thingsModel3);
|
||||
if (StringUtils.isNotEmpty(taiyangnengIds)) {
|
||||
Device guimenDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(guimenIds));
|
||||
List<DeviceLog> deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{
|
||||
setSerialNumber(guimenDevice.getSerialNumber());
|
||||
setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString());
|
||||
setEndTime(DateUtil.endOfDay(dateTime).toString());
|
||||
}});
|
||||
Map<String, List<DeviceLog>> guimenCollect = deviceLogs.stream().sorted(Comparator
|
||||
.comparing(DeviceLog::getCreateTime, Comparator
|
||||
.nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity()));
|
||||
for (ThingsModel thingsModel : guimenModels) {
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_open")?"xiangmen":thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
}};
|
||||
if (StringUtils.isNotEmpty(thingsModel.getSpecs())) {
|
||||
String specs = thingsModel.getSpecs();
|
||||
JSONObject parse = (JSONObject) JSON.parse(specs);
|
||||
if (parse.containsKey("unit")) {
|
||||
hashMap1.put("unit", parse.get("unit"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(guimenIds)) {
|
||||
CommonResult<HaiWeiDeviceInfoVo> cache = haiWeiService.getCache(Long.valueOf(guimenIds));
|
||||
HaiWeiDeviceInfoVo checkedData = cache.getCheckedData();
|
||||
List<HaiWeiPropertyVo> propertyList = checkedData.getPropertyList();
|
||||
for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) {
|
||||
if (haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_open")) {
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", "xiangmen");
|
||||
put("unit", "");
|
||||
put("value", haiWeiPropertyVo.getValue());
|
||||
put("name", haiWeiPropertyVo.getNameCn());
|
||||
}};
|
||||
rMap.put("xiangmen", hashMap1);
|
||||
}
|
||||
|
||||
if (hashMap1.size() > 1) {
|
||||
List<DeviceLog> deviceLogs1 = guimenCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs1 != null) {
|
||||
if(deviceLogs1.size() > 0){
|
||||
if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) {
|
||||
if(deviceLogs1.size() > 1){
|
||||
if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap1.put("upType", 1);
|
||||
} else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap1.put("upType", -1);
|
||||
}
|
||||
}else{
|
||||
hashMap1.put("upType", 0);
|
||||
}
|
||||
hashMap1.put("value", deviceLogs1.get(0).getLogValue());
|
||||
} else {
|
||||
hashMap1.put("value", "--");
|
||||
hashMap1.put("upType", 0);
|
||||
}
|
||||
|
||||
}else{
|
||||
hashMap1.put("value", "--");
|
||||
hashMap1.put("upType", 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else if (hashMap1.size() > 0) {
|
||||
List<DeviceLog> deviceLogs3 = guimenCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs3 != null) {
|
||||
hashMap1.put("value", deviceLogs3.get(0).getLogValue());
|
||||
}
|
||||
}
|
||||
rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_open")?"xiangmen":thingsModel.getIdentifier(), hashMap1);
|
||||
}
|
||||
} else {
|
||||
for (ThingsModel thingsModel : taiyangnengModels) {
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_open")?"xiangmen":thingsModel.getIdentifier());
|
||||
put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_open") ? "xiangmen" : thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
}};
|
||||
rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_open")?"xiangmen":thingsModel.getIdentifier(), hashMap1);
|
||||
rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_open") ? "xiangmen" : thingsModel.getIdentifier(), hashMap1);
|
||||
}
|
||||
}
|
||||
// HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
// put("upType", 0);
|
||||
// put("identifier", "xiangmen");
|
||||
// put("unit", "");
|
||||
// put("value", 0);//0=正常,1=箱门振动,2=箱门打开
|
||||
// put("name", "箱门状态");
|
||||
// }};
|
||||
// rMap.put("xiangmen", hashMap);
|
||||
String liuliangIds = devParams.get("liuliangIds").toString();
|
||||
ThingsModel thingsModel2 = new ThingsModel();
|
||||
thingsModel2.setProductId(139L);
|
||||
@ -303,7 +253,7 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
for (ThingsModel thingsModel : liuliangModels) {
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow")?"sumFlow":thingsModel.getIdentifier());
|
||||
put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
@ -319,15 +269,15 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
if (hashMap1.size() > 1) {
|
||||
List<DeviceLog> deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs1 != null) {
|
||||
if(deviceLogs1.size() > 0){
|
||||
if (deviceLogs1.size() > 0) {
|
||||
if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) {
|
||||
if(deviceLogs1.size() > 1){
|
||||
if (deviceLogs1.size() > 1) {
|
||||
if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap1.put("upType", 1);
|
||||
} else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap1.put("upType", -1);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
hashMap1.put("upType", 0);
|
||||
}
|
||||
hashMap1.put("value", deviceLogs1.get(0).getLogValue());
|
||||
@ -336,7 +286,7 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
hashMap1.put("upType", 0);
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
hashMap1.put("value", "--");
|
||||
hashMap1.put("upType", 0);
|
||||
}
|
||||
@ -349,18 +299,18 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
hashMap1.put("value", deviceLogs2.get(0).getLogValue());
|
||||
}
|
||||
}
|
||||
rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow")?"sumFlow":thingsModel.getIdentifier(), hashMap1);
|
||||
rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier(), hashMap1);
|
||||
}
|
||||
} else {
|
||||
for (ThingsModel thingsModel : taiyangnengModels) {
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow")?"sumFlow":thingsModel.getIdentifier());
|
||||
put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
}};
|
||||
rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow")?"sumFlow":thingsModel.getIdentifier(), hashMap1);
|
||||
rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier(), hashMap1);
|
||||
}
|
||||
}
|
||||
// HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
@ -376,8 +326,8 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
TableDataInfo tableDataInfo = watereleRecordService.selectMaWatereleRecordList(maWatereleRecord);
|
||||
List<MaWatereleRecord> deviceLogs = (List<MaWatereleRecord>) tableDataInfo.getRows();
|
||||
String sumEle = "0";
|
||||
if(deviceLogs.size() > 0){
|
||||
sumEle = NumberUtil.isNumber(deviceLogs.get(0).getSumele())?deviceLogs.get(0).getSumele():
|
||||
if (deviceLogs.size() > 0) {
|
||||
sumEle = NumberUtil.isNumber(deviceLogs.get(0).getSumele()) ? deviceLogs.get(0).getSumele() :
|
||||
"0";
|
||||
}
|
||||
String finalSumEle = sumEle;
|
||||
@ -422,9 +372,9 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
}
|
||||
DateTime dateTime = DateUtil.date(new Date());
|
||||
Map<String, Object> devParams = DevParamsUtils.getDevParams(device.getDevParams());
|
||||
if(devParams.containsKey("liuliangIds")){
|
||||
if (devParams.containsKey("liuliangIds")) {
|
||||
Device liuliangDevice = iDeviceService.selectDeviceByDeviceId(Long.parseLong(devParams.get("liuliangIds").toString()));
|
||||
if(liuliangDevice != null){
|
||||
if (liuliangDevice != null) {
|
||||
List<DeviceLog> deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{
|
||||
setSerialNumber(liuliangDevice.getSerialNumber());
|
||||
setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString());
|
||||
@ -434,10 +384,10 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
.comparing(DeviceLog::getCreateTime, Comparator
|
||||
.nullsFirst(Comparator.naturalOrder()))).collect(Collectors.groupingBy(t -> t.getIdentity()));
|
||||
List<DeviceLog> deviceLogList = liuliangCollect.get("三菱FX2N_1_sumFlow");
|
||||
if(deviceLogList != null && deviceLogList.size() > 0){
|
||||
if (deviceLogList != null && deviceLogList.size() > 0) {
|
||||
for (DeviceLog deviceLog : deviceLogList) {
|
||||
sumFlow.add(deviceLog.getLogValue());
|
||||
sumFlowTime.add(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,deviceLog.getCreateTime()));
|
||||
sumFlowTime.add(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, deviceLog.getCreateTime()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user