|
|
@@ -2,25 +2,19 @@ package com.yunfeiyun.agmp.iots.device.serviceImp;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
-import com.yunfeiyun.agmp.common.utils.JSONUtils;
|
|
|
-import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
|
|
|
import com.yunfeiyun.agmp.iot.common.constant.devicetype.ServiceNameConst;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.*;
|
|
|
import com.yunfeiyun.agmp.iot.common.model.cmd.CmdModel;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
-
|
|
|
import com.yunfeiyun.agmp.iots.core.http.ZjsfXycbHttpClient;
|
|
|
import com.yunfeiyun.agmp.iots.core.manager.HttpManager;
|
|
|
import com.yunfeiyun.agmp.iots.device.common.HttpDeviceAbstractImpl;
|
|
|
import com.yunfeiyun.agmp.iots.device.service.ZjsfXycbDevice;
|
|
|
import com.yunfeiyun.agmp.iots.service.*;
|
|
|
import com.yunfeiyun.agmp.iots.service.impl.IotDeviceAddressService;
|
|
|
-import com.yunfeiyun.agmp.iots.service.impl.IotPestRecogService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -58,22 +52,11 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
private IIotPestService iIotPestService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IotPestRecogService iotPestRecogService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private IIotXyImageService iIotXyImageService;
|
|
|
|
|
|
@Resource
|
|
|
private HttpManager httpManager;
|
|
|
|
|
|
- private String imgBaseUrl = "https://bigdata-image.oss-cn-hangzhou.aliyuncs.com";
|
|
|
-
|
|
|
- @Value("${runMode.modeName:dev}")
|
|
|
- private String modeName;
|
|
|
-
|
|
|
- /** 线上环境 */
|
|
|
- private final String onlineEnv = "nanpi";
|
|
|
-
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -126,45 +109,11 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
for(JSONObject device : dataList){
|
|
|
String deviceMac = device.getString("DeviceMac");
|
|
|
JSONArray photoList = device.getJSONArray("PhotoList");
|
|
|
- if(!Objects.equals(modeName, onlineEnv) && (photoList == null || photoList.isEmpty())){
|
|
|
- photoList = new JSONArray();
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("path", "Basics/xyv3/861551051653129/2023/9/20/192.168.100.100_01_20230920154158615_ALARM_INPUT.jpg");
|
|
|
- jsonObject.put("createTime", DateUtils.dateTimeNow());
|
|
|
-
|
|
|
- photoList.add(jsonObject);
|
|
|
- }
|
|
|
deviceImageMap.put(deviceMac, photoList);
|
|
|
}
|
|
|
return deviceImageMap;
|
|
|
}
|
|
|
|
|
|
- public void syncPestCount(Map<IotDevice, JSONObject> pestCountMap){
|
|
|
- for(Map.Entry<IotDevice, JSONObject> entry : pestCountMap.entrySet()) {
|
|
|
- JSONObject jsonObject = entry.getValue();
|
|
|
- IotDevice iotDevice = entry.getKey();
|
|
|
- Integer pestCount = jsonObject.getInteger("ct");
|
|
|
- String devBid = iotDevice.getDevBid();
|
|
|
- IotXyinfo iotXyinfo = new IotXyinfo();
|
|
|
- iotXyinfo.setDevBid(devBid);
|
|
|
-
|
|
|
- try {
|
|
|
- IotXyinfo oldIotXyinfo = iIotXyinfoService.selectIotXyinfoList(iotXyinfo).get(0);
|
|
|
- IotPest iotPest = iIotPestService.selectIotPestByBid(oldIotXyinfo.getPestBusid());
|
|
|
- if (iotPest == null) {
|
|
|
- log.info("未设置诱芯,无法统计虫情数据");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.info("未设置诱芯,无法统计虫情数据");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public void syncImageInfo(Map<IotDevice, JSONArray> imgInfoMap){
|
|
|
List<JSONObject> jsonObjectList = iIotXyImageService.selectImageAlreadyExistsList(imgInfoMap);
|
|
|
Set<String> imgSet = new HashSet<>();
|
|
|
@@ -186,7 +135,7 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
IotXycbimg iotXycbimg = new IotXycbimg();
|
|
|
iotXycbimg.setDevBid(devBid);
|
|
|
iotXycbimg.setXycbimgBid(iotXycbimg.getUUId());
|
|
|
- iotXycbimg.setXycbimgAddr(imgBaseUrl + "/" + path);
|
|
|
+ iotXycbimg.setXycbimgAddr(path);
|
|
|
iotXycbimg.setXycbimgCreatedDate(createTime);
|
|
|
iotXycbimg.setXycbimgModifieddate(createTime);
|
|
|
iotXycbimg.setXycbimgDelstatus("0");
|
|
|
@@ -195,7 +144,7 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(iotXycbimgList.size() > 0) {
|
|
|
+ if(!iotXycbimgList.isEmpty()) {
|
|
|
iIotXyImageService.batchInsert(iotXycbimgList);
|
|
|
}
|
|
|
}
|
|
|
@@ -240,7 +189,6 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
String lat = deviceInfo.getString("gpsLat");
|
|
|
|
|
|
String version = deviceInfo.getString("otaVersion");
|
|
|
- String pestName = deviceInfo.getString("bugName");
|
|
|
String totalBugCount = deviceInfo.getString("bugCount");
|
|
|
|
|
|
// 工作状态
|
|
|
@@ -286,8 +234,6 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
|
|
|
}
|
|
|
|
|
|
- bugCountInt = bugCountInt + 1;
|
|
|
-
|
|
|
IotDevice iotDevice = new IotDevice();
|
|
|
iotDevice.setDevBid(oldIotDevice.getDevBid());
|
|
|
iotDevice.setDevVersion(version);
|
|
|
@@ -315,15 +261,11 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
extConf.put("cs", chargeStatus);
|
|
|
extConf.put("win", windDirection);
|
|
|
extConf.put("win_speed", windSpeed);
|
|
|
- extConf.put("ct", String.valueOf(bugCountInt));
|
|
|
+ extConf.put("infr_ct", String.valueOf(bugCountInt));
|
|
|
extConf.put("totalCt", totalBugCount);
|
|
|
extConf.put("uptime", updatedDate);
|
|
|
|
|
|
- String devConfig = JSONUtils.toJSONString(extConf);
|
|
|
- // 创建或更新设备配置信息
|
|
|
- if (StringUtils.isNotEmpty(devConfig)) {
|
|
|
- iIotDeviceconfigService.createOrUpdateDevConfig(oldIotDevice, devConfig, iotDevice.getDevUpdateddate());
|
|
|
- }
|
|
|
+ // 不支持控制 没有配置文件
|
|
|
|
|
|
// 保存 设备最新数据 到redis
|
|
|
iIotDevicelasteddataService.createOrUpdateDeviceLastedData(
|
|
|
@@ -333,9 +275,6 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
insertDataMap.put(oldIotDevice, new ArrayList<>());
|
|
|
}
|
|
|
insertDataMap.get(oldIotDevice).add(extConf);
|
|
|
- if(bugCountInt > 0){
|
|
|
- pestCountMap.put(iotDevice, extConf);
|
|
|
- }
|
|
|
|
|
|
if(deviceImageMap.containsKey(devCode)){
|
|
|
JSONArray imgList = deviceImageMap.get(devCode);
|
|
|
@@ -343,21 +282,14 @@ public class ZjsfXycbDeviceImpl extends HttpDeviceAbstractImpl implements ZjsfXy
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(updateIotDeviceList.size() > 0){
|
|
|
+ if(!updateIotDeviceList.isEmpty()){
|
|
|
iotDeviceService.updateIotDeviceBatch(updateIotDeviceList);
|
|
|
}
|
|
|
- for(Map.Entry<IotDevice, List<JSONObject>> entry : insertDataMap.entrySet()) {
|
|
|
- List<JSONObject> insertDeviceDatalist = entry.getValue();
|
|
|
- IotDevice iotDevice = entry.getKey();
|
|
|
- // 批量插入设备数据到mongodb
|
|
|
- if (insertDeviceDatalist.size() > 0) {
|
|
|
- // 批量插入设备数据到mongodb
|
|
|
- iIotZjsfXycbdataService.batchInsertData(iotDevice, insertDeviceDatalist);
|
|
|
- }
|
|
|
- }
|
|
|
- if(pestCountMap.size() > 0){
|
|
|
- syncPestCount(pestCountMap);
|
|
|
+
|
|
|
+ if(!insertDataMap.isEmpty()){
|
|
|
+ iIotZjsfXycbdataService.batchInsertData(insertDataMap);
|
|
|
}
|
|
|
+
|
|
|
if(imgInfoMap.size() > 0){
|
|
|
syncImageInfo(imgInfoMap);
|
|
|
}
|