|
@@ -0,0 +1,97 @@
|
|
|
|
|
+package com.yunfeiyun.agmp.iotm.device.sf.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
|
|
+import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
|
|
|
|
|
+import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
|
|
|
|
|
+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.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.IotSfElementfactorListReqVo;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.device.sf.service.IIotSfCommService;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotSfElementfactorService;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 润浩水肥机
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Service(value = ServiceNameConst.SERVICE_RUNHAO_SF)
|
|
|
|
|
+public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIotDeviceService iotDeviceService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIotSfElementfactorService iotSfElementfactorService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MongoService mongoService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取未处理的元素列表
|
|
|
|
|
+ * 该接口用于根据请求参数获取未处理的元素列表,并返回相关数据。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param reqVo 请求参数,包含设备标识(devBid)等信息
|
|
|
|
|
+ * @return TableDataInfo 包含未处理的元素列表的数据封装对象
|
|
|
|
|
+ * @throws IllegalArgumentException 如果devBid为空,则抛出非法参数异常
|
|
|
|
|
+ */
|
|
|
|
|
+ public TableDataInfo getUnAlreadyElementList(IotSfElementfactorListReqVo reqVo) {
|
|
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
|
|
+ rspData.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
|
|
+ rspData.setMsg(ErrorCode.SUCCESS.getMessage());
|
|
|
|
|
+ rspData.setData(new ArrayList<>());
|
|
|
|
|
+ rspData.setTotal(0);
|
|
|
|
|
+
|
|
|
|
|
+ String devBid = reqVo.getDevBid();
|
|
|
|
|
+ if (StringUtils.isEmpty(devBid)) {
|
|
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
|
|
|
|
|
+ if (findDevice == null) {
|
|
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<IotSfElementfactor> elementfactorList = iotSfElementfactorService.selectIotSfElementfactorList(reqVo);
|
|
|
|
|
+ Set<String> sfCodeSet = new java.util.HashSet<>();
|
|
|
|
|
+ for (IotSfElementfactor elementfactor : elementfactorList) {
|
|
|
|
|
+ sfCodeSet.add(elementfactor.getSfCode());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ HashMap<String, String> params = new HashMap<>();
|
|
|
|
|
+ params.put("devBid", devBid);
|
|
|
|
|
+
|
|
|
|
|
+ IotRunHaoSfdata iotRunHaoSfdata = (IotRunHaoSfdata) mongoService.findOne(IotRunHaoSfdata.class, params, "sfdataCreatedDate", "desc");
|
|
|
|
|
+ List<IotSfElementfactor> resultList = new ArrayList<>();
|
|
|
|
|
+ if (iotRunHaoSfdata != null) {
|
|
|
|
|
+ JSONObject dataJson = iotRunHaoSfdata.getSfdataContent();
|
|
|
|
|
+ for (String key : dataJson.keySet()) {
|
|
|
|
|
+ if(sfCodeSet.contains(key)){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ IotSfElementfactor elementFactor = RunHaoSfElementUtil.getSfElementfactor(key);
|
|
|
|
|
+ if(elementFactor == null){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ resultList.add(elementFactor);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ rspData.setData(resultList);
|
|
|
|
|
+ rspData.setTotal(resultList.size());
|
|
|
|
|
+ return rspData;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|