|
|
@@ -7,7 +7,7 @@ import com.yunfeiyun.agmp.common.exception.BizException;
|
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.*;
|
|
|
-import com.yunfeiyun.agmp.iot.common.util.dev.QxzTypeUtil;
|
|
|
+import com.yunfeiyun.agmp.iot.common.util.dev.DevTypeUtil;
|
|
|
import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceBaseFunReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
|
|
|
@@ -115,43 +115,82 @@ public class IotWarnindicatorServiceImpl implements IIotWarnindicatorService {
|
|
|
|
|
|
@Override
|
|
|
public List<IotWarnindicator> query(IotDevice iotDevice) {
|
|
|
- if (StringUtils.isEmpty(iotDevice.getDevtypeBid())) {
|
|
|
+ String devTypeBid = iotDevice.getDevtypeBid();
|
|
|
+ String devBid = iotDevice.getDevBid();
|
|
|
+ if (StringUtils.isEmpty(devTypeBid)) {
|
|
|
throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备类型不能为空");
|
|
|
}
|
|
|
+ if (StringUtils.isEmpty(devBid)) {
|
|
|
+ throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备标识不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
List<IotWarnindicator> result = new ArrayList<>();
|
|
|
// 暂时只支持针对设备的告警要素查询
|
|
|
- if (StringUtils.isNotEmpty(iotDevice.getDevBid())) {
|
|
|
- result = warnindicatorDevQuery(iotDevice);
|
|
|
+ if(DevTypeUtil.isQxSq(devTypeBid)){
|
|
|
+ result = warnindicatorDevQueryByQxSq(iotDevice);
|
|
|
+ }else if(DevTypeUtil.isYfRecogCbd(devTypeBid)){
|
|
|
+ result = warnindicatorDevQueryByCbd(iotDevice);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询气象墒情告警要素列表
|
|
|
+ * @param iotDevice
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<IotWarnindicator> warnindicatorDevQuery(IotDevice iotDevice){
|
|
|
+ public List<IotWarnindicator> warnindicatorDevQueryByQxSq(IotDevice iotDevice){
|
|
|
// 暂不支持根据类型查询要素
|
|
|
// 查询当前设备是否存在预设要素
|
|
|
List<IotWarnindicator> result = new ArrayList<>();
|
|
|
- if (isFactorDevice(iotDevice.getDevtypeBid())) {
|
|
|
- IotDeviceDataListReqVo iotDeviceDataListReqVo = new IotDeviceDataListReqVo();
|
|
|
- BeanUtils.copyProperties(iotDevice,iotDeviceDataListReqVo);
|
|
|
- IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
|
|
|
- iotDeviceBaseFunReqVo.setDevBid(iotDevice.getDevBid());
|
|
|
- iotDeviceBaseFunReqVo.setMethodName("warnDataLatest");
|
|
|
- iotDeviceBaseFunReqVo.setParam(iotDeviceDataListReqVo);
|
|
|
- IotDevicelasteddata iotDevicelasteddata = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
|
|
|
- if(null == iotDevicelasteddata){
|
|
|
- return result;
|
|
|
- }
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(iotDevicelasteddata.getDevldContent());
|
|
|
- // 直接返回设备上报的数据
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- JSONObject dataItem = jsonArray.getJSONObject(i);
|
|
|
- IotWarnindicator iotWarnindicator = new IotWarnindicator();
|
|
|
- iotWarnindicator.setWiAddress(dataItem.getString("address"));
|
|
|
- iotWarnindicator.setWiCode(dataItem.getString("factorCode"));
|
|
|
- iotWarnindicator.setWiName(dataItem.getString("factorName"));
|
|
|
- iotWarnindicator.setWiUnit(dataItem.getString("factorUnit"));
|
|
|
- result.add(iotWarnindicator);
|
|
|
- }
|
|
|
+ IotDeviceDataListReqVo iotDeviceDataListReqVo = new IotDeviceDataListReqVo();
|
|
|
+ BeanUtils.copyProperties(iotDevice,iotDeviceDataListReqVo);
|
|
|
+ IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
|
|
|
+ iotDeviceBaseFunReqVo.setDevBid(iotDevice.getDevBid());
|
|
|
+ iotDeviceBaseFunReqVo.setMethodName("warnDataLatest");
|
|
|
+ iotDeviceBaseFunReqVo.setParam(iotDeviceDataListReqVo);
|
|
|
+ IotDevicelasteddata iotDevicelasteddata = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
|
|
|
+ if(null == iotDevicelasteddata){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(iotDevicelasteddata.getDevldContent());
|
|
|
+ // 直接返回设备上报的数据
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject dataItem = jsonArray.getJSONObject(i);
|
|
|
+ IotWarnindicator iotWarnindicator = new IotWarnindicator();
|
|
|
+ iotWarnindicator.setWiAddress(dataItem.getString("address"));
|
|
|
+ iotWarnindicator.setWiCode(dataItem.getString("factorCode"));
|
|
|
+ iotWarnindicator.setWiName(dataItem.getString("factorName"));
|
|
|
+ iotWarnindicator.setWiUnit(dataItem.getString("factorUnit"));
|
|
|
+ result.add(iotWarnindicator);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询测报灯告警要素列表
|
|
|
+ *
|
|
|
+ * @param iotDevice
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<IotWarnindicator> warnindicatorDevQueryByCbd(IotDevice iotDevice) {
|
|
|
+
|
|
|
+ List<String[]> factorList = new ArrayList<>();
|
|
|
+ factorList.add(new String[]{"pestType", "害虫种类", "类", "0"});
|
|
|
+ factorList.add(new String[]{"pestNum", "害虫数量", "头", "0"});
|
|
|
+ factorList.add(new String[]{"pestDetail", "指定害虫", "头", "1"});
|
|
|
+
|
|
|
+ List<IotWarnindicator> result = new ArrayList<>();
|
|
|
+ for(String[] factor : factorList){
|
|
|
+ IotWarnindicator iotWarnindicator = new IotWarnindicator();
|
|
|
+ iotWarnindicator.setWiAddress(factor[0]);
|
|
|
+ iotWarnindicator.setWiCode(factor[0]);
|
|
|
+ iotWarnindicator.setWiName(factor[1]);
|
|
|
+ iotWarnindicator.setWiUnit(factor[2]);
|
|
|
+ iotWarnindicator.setWiOptiontype(factor[3]);
|
|
|
+ result.add(iotWarnindicator);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
@@ -171,18 +210,6 @@ public class IotWarnindicatorServiceImpl implements IIotWarnindicatorService {
|
|
|
return iotWarndataitemList.stream().collect(Collectors.toMap(IotWarndataitem::getWdCode, item -> item));
|
|
|
}
|
|
|
|
|
|
- private boolean isFactorDevice(String devTypeBid) {
|
|
|
- List<String> devTypeList = new ArrayList<>();
|
|
|
- devTypeList.addAll(Arrays.asList(QxzTypeUtil.getAllQxzTypes()));
|
|
|
- devTypeList.addAll(Arrays.asList(QxzTypeUtil.getAllSqzTypes()));
|
|
|
-
|
|
|
- Set<String> devTypeSet = new HashSet<>(devTypeList);
|
|
|
- if(devTypeSet.contains(devTypeBid)){
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 查询虫情列表
|