|
|
@@ -10,10 +10,12 @@ import com.yunfeiyun.agmp.iot.common.constant.devicetype.ServiceNameConst;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotRunHaoSfdata;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor;
|
|
|
+import com.yunfeiyun.agmp.iot.common.enums.EnumSfElementType;
|
|
|
import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
import com.yunfeiyun.agmp.iot.common.util.dev.RunHaoSfElementUtil;
|
|
|
import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorAlreadyListResVo;
|
|
|
+import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorInfoVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.sf.service.IIotSfCommService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
@@ -41,6 +43,16 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
@Autowired
|
|
|
private MongoService mongoService;
|
|
|
|
|
|
+ private String getDataValue(JSONObject dataJson, String key){
|
|
|
+ String v = dataJson.getString(key);
|
|
|
+ if("true".equals(v)){
|
|
|
+ v = "1";
|
|
|
+ }else if("false".equals(v)){
|
|
|
+ v = "0";
|
|
|
+ }
|
|
|
+ return v;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取泵类未处理的元素列表
|
|
|
* 该接口用于根据请求参数获取未处理的元素列表,并返回相关数据。
|
|
|
@@ -258,4 +270,89 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
rspData.setTotal(resultList.size());
|
|
|
return rspData;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取水肥机状态信息
|
|
|
+ *
|
|
|
+ * @param reqVo 请求对象,包含设备标识等信息
|
|
|
+ * @return TableDataInfo 包含响应码、消息、数据和总数
|
|
|
+ * @throws IotBizException 抛出业务异常,包含错误码和错误信息
|
|
|
+ */
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo getStatus(String devBid) {
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
+ rspData.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
+ rspData.setMsg(ErrorCode.SUCCESS.getMessage());
|
|
|
+ rspData.setData(new ArrayList<>());
|
|
|
+ rspData.setTotal(0);
|
|
|
+
|
|
|
+ IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
+ if (findDevice == null) {
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, String> params = new HashMap<>();
|
|
|
+ params.put("devBid", devBid);
|
|
|
+
|
|
|
+ IotRunHaoSfdata iotRunHaoSfdata = (IotRunHaoSfdata) mongoService.findOne(IotRunHaoSfdata.class, params, "sfdataCreatedDate", "desc");
|
|
|
+ if (iotRunHaoSfdata == null) {
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+ IotSfElementfactorListReqVo reqVo = new IotSfElementfactorListReqVo();
|
|
|
+ reqVo.setDevBid(devBid);
|
|
|
+ List<IotSfElementfactor> resVoList = iotSfElementfactorService.selectIotSfElementfactorList(reqVo);
|
|
|
+
|
|
|
+ if (resVoList == null || resVoList.isEmpty()){
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+ JSONObject dataJson = iotRunHaoSfdata.getSfdataContent();
|
|
|
+ Map<String, IotSfElementfactorInfoVo> eleMap = new LinkedHashMap<>();
|
|
|
+ for (IotSfElementfactor elementfactor : resVoList) {
|
|
|
+ String sfBid = elementfactor.getSfBid();
|
|
|
+ String sfParentBid = elementfactor.getSfParentBid();
|
|
|
+ String sfCode = elementfactor.getSfCode();
|
|
|
+ String value = getDataValue(dataJson, sfCode);
|
|
|
+
|
|
|
+ IotSfElementfactorInfoVo infoVo = new IotSfElementfactorInfoVo();
|
|
|
+ BeanUtils.copyProperties(elementfactor, infoVo);
|
|
|
+ infoVo.setValue(value);
|
|
|
+
|
|
|
+ IotSfElementfactorInfoVo parentInfo = eleMap.get(sfParentBid);
|
|
|
+ if(parentInfo == null){
|
|
|
+ infoVo.setChildrenList(new ArrayList<>());
|
|
|
+ eleMap.put(sfBid, infoVo);
|
|
|
+ }else{
|
|
|
+ parentInfo.getChildrenList().add(infoVo);
|
|
|
+ if(Objects.equals(infoVo.getSfType(), EnumSfElementType.SUCTION.getCode())){
|
|
|
+ List<IotSfElementfactor> lsliList = RunHaoSfElementUtil.getLsLlFactor(sfCode);
|
|
|
+ for(IotSfElementfactor lsli : lsliList){
|
|
|
+ IotSfElementfactorInfoVo lsliVo = new IotSfElementfactorInfoVo();
|
|
|
+ BeanUtils.copyProperties(lsli, lsliVo);
|
|
|
+ String lv = getDataValue(dataJson, lsli.getSfCode());
|
|
|
+ lsliVo.setValue(lv);
|
|
|
+ parentInfo.getChildrenList().add(lsliVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<IotSfElementfactorInfoVo> resultList = new ArrayList<>(eleMap.values());
|
|
|
+ for(String key : dataJson.keySet()){
|
|
|
+ IotSfElementfactor elementFactor = RunHaoSfElementUtil.getSensorElementFactor(key);
|
|
|
+ if(elementFactor == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String value = dataJson.getString(key);
|
|
|
+ IotSfElementfactorInfoVo infoVo = new IotSfElementfactorInfoVo();
|
|
|
+ BeanUtils.copyProperties(elementFactor, infoVo);
|
|
|
+ infoVo.setValue(value);
|
|
|
+ resultList.add(infoVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ rspData.setData(resultList);
|
|
|
+ rspData.setTotal(resultList.size());
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
}
|