Procházet zdrojové kódy

新增 编辑要素接口

zhaiyifei před 8 měsíci
rodič
revize
b272d7d6c1

+ 16 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/controller/IotDeviceSfController.java

@@ -333,6 +333,22 @@ public class IotDeviceSfController extends BaseController {
         int status = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
         return toAjax(status);
     }
+
+    /**
+     * 获取润浩全局灌区参数
+     * @param
+     * @return
+     */
+    @GetMapping("/rh/group/param/global/{devBid}")
+    public AjaxResult getGroupParamByGlobal(@PathVariable String devBid){
+        ValidateUtil.validateDevBid(devBid);
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(devBid);
+        iotDeviceBaseFunReqVo.setMethodName("getGroupParamByGlobal");
+        iotDeviceBaseFunReqVo.setParam(devBid);
+        JSONObject jsonObject = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+        return AjaxResult.success(jsonObject);
+    }
 //
 //    /**
 //     * 下发水肥机指令

+ 11 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/IIotSfCommService.java

@@ -379,4 +379,15 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
         return iotSfElementfactorService.updateIotSfElementfactor(iotSfElementfactor);
     }
 
+    /**
+     * 获取灌区参数
+     *
+     * @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
+     * @param reqVo
+     */
+    public JSONObject getGroupParamByGlobal (String devBid) {
+        // 由具体子类实现
+        return null;
+    }
+
 }

+ 45 - 3
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/impl/IotRunHaoSfServiceImpl.java

@@ -544,9 +544,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
                 throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "名称不能为空");
             }
 
-            if(!sfTypeSet.contains(sfType)){
-                sfTypeSet.add(sfType);
-            }
+            sfTypeSet.add(sfType);
 
             IotSfElementfactor elementfactor = makeIotSfElementfactor(element, createDate);
 
@@ -713,4 +711,48 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
         reqVo.setIotDevice(iotDevice);
         return sendConfigCmd(reqVo);
     }
+
+
+    /**
+     * 获取灌区参数
+     *
+     * @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
+     * @param reqVo
+     */
+    public JSONObject getGroupParamByGlobal (String devBid) {
+        JSONObject groupParamJson = new JSONObject();
+        Map<String, String> params = new HashMap<>();
+        params.put("devBid", devBid);
+        IotRunHaoSfdata iotRunHaoSfdata = (IotRunHaoSfdata) mongoService.findOne(IotRunHaoSfdata.class, params, "sfdataCreatedDate", "desc");
+        if(iotRunHaoSfdata == null || iotRunHaoSfdata.getSfdataContent() == null){
+            return null;
+        }
+
+        IotSfElementfactorListReqVo reqVo = new IotSfElementfactorListReqVo();
+        reqVo.setDevBid(devBid);
+        reqVo.setSfType(EnumSfElementType.SUCTION.getCode());
+        List<IotSfElementfactor> sfElementfactorList = iotSfElementfactorService.selectIotSfElementfactorList(reqVo);
+        Set<String> suctionSet = new HashSet<>();
+        if(sfElementfactorList != null && !sfElementfactorList.isEmpty()){
+            for(IotSfElementfactor vo : sfElementfactorList){
+                suctionSet.add(vo.getSfCode());
+            }
+        }
+
+        Map<String, String> groupParamMap = new HashMap<>();
+        groupParamMap.put("Num-ggsj", "0");
+        groupParamMap.put("Num-fqsj", "0");
+        for(String sfCode : suctionSet){
+            String key = sfCode.replace("Btn-fs", "");
+            groupParamMap.put("Btn-fxz" + key, "0");
+            groupParamMap.put("Num-fsj" + key, "0");
+        }
+
+        JSONObject sfdataContent = iotRunHaoSfdata.getSfdataContent();
+        for(String key: groupParamMap.keySet()){
+            String value = RunHaoSfElementUtil.getDataValue(key, sfdataContent);
+            groupParamJson.put(key, value);
+        }
+        return groupParamJson;
+    }
 }