|
|
@@ -110,32 +110,6 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取灌区和电磁阀的绑定关系数据
|
|
|
- */
|
|
|
- private Map<String, List<String>> getGroupValveMap(JSONObject dataJson){
|
|
|
- Map<String, List<String>> groupValveMap = new HashMap<>();
|
|
|
- for (String key : dataJson.keySet()) {
|
|
|
- if(!key.startsWith("Btn-fx")){
|
|
|
- continue;
|
|
|
- }
|
|
|
- String groupIndexString = dataJson.getString(key);
|
|
|
- int groupIndex = 0;
|
|
|
- try{
|
|
|
- groupIndex = (int) Math.round(Double.parseDouble(groupIndexString));
|
|
|
- String groupKey = "Btn-qx" + String.format("%02d", groupIndex);
|
|
|
- if(!groupValveMap.containsKey(groupKey)){
|
|
|
- List<String> valveList = new ArrayList<>();
|
|
|
- groupValveMap.put(groupKey, valveList);
|
|
|
- }
|
|
|
- String suffix = key.split("Btn-fx")[1];
|
|
|
- String valveKey = "Btn-fa" + Integer.valueOf(suffix);
|
|
|
- groupValveMap.get(groupKey).add(valveKey);
|
|
|
- }catch (Exception e){}
|
|
|
- }
|
|
|
- return groupValveMap;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 获取未配置的灌区元素列表
|
|
|
*
|
|
|
* @param reqVo 请求参数,包含设备标识(devBid)等筛选条件
|
|
|
@@ -474,4 +448,55 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
}
|
|
|
return status;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除元素
|
|
|
+ *
|
|
|
+ * @param reqVo 请求对象,包含了要删除的元素信息
|
|
|
+ * @return 返回删除结果,返回值为0表示删除成功,非0表示删除失败
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int elementDelete(IotSfElementfactor reqVo) {
|
|
|
+ String sfBid = reqVo.getSfBid();
|
|
|
+ String sfType = reqVo.getSfType();
|
|
|
+ String devBid = reqVo.getDevBid();
|
|
|
+ String sfCode = reqVo.getSfCode();
|
|
|
+ IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
+
|
|
|
+ int status = iotSfElementfactorService.deleteIotSfElementfactorBySfBid(sfBid);
|
|
|
+ Map<String, String> payload = new HashMap<>();
|
|
|
+ if(Objects.equals(sfType, EnumSfElementType.GROUP.getCode())){
|
|
|
+ IotSfElementfactorListReqVo selectReqVo = new IotSfElementfactorListReqVo();
|
|
|
+ selectReqVo.setDevBid(devBid);
|
|
|
+ List<IotSfElementfactorAlreadyListResVo> resVoList = iotSfElementfactorService.getGroupAlreadyElementList(selectReqVo);
|
|
|
+ IotSfElementfactorAlreadyListResVo alreadyResVo = resVoList.get(0);
|
|
|
+ List<IotSfElementfactorAlreadyListResVo> childrenList = alreadyResVo.getChildrenList();
|
|
|
+
|
|
|
+ if(childrenList != null && !childrenList.isEmpty()){
|
|
|
+ for(IotSfElementfactorAlreadyListResVo child : childrenList){
|
|
|
+ String childSfCode = child.getSfCode();
|
|
|
+ int valveIndex = Integer.parseInt(childSfCode.replace("Btn-fa", ""));
|
|
|
+ String key = "Btn-fx" + String.format("%02d", valveIndex);
|
|
|
+ payload.put(key, "0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if(Objects.equals(sfType, EnumSfElementType.SOLENOID_VALVE.getCode())){
|
|
|
+ int valveIndex = Integer.parseInt(sfCode.replace("Btn-fa", ""));
|
|
|
+ String key = "Btn-fx" + String.format("%02d", valveIndex);
|
|
|
+ payload.put(key, "0");
|
|
|
+ }
|
|
|
+ if(!payload.isEmpty()){
|
|
|
+ IotSfConfigCmdReqVo configCmdReqVo = new IotSfConfigCmdReqVo();
|
|
|
+ configCmdReqVo.setDevBid(devBid);
|
|
|
+ configCmdReqVo.setCmd(CmdDef.RunHaoSfCmdDef.CMD_CONFIG);
|
|
|
+ configCmdReqVo.setIotDevice(findDevice);
|
|
|
+ configCmdReqVo.setData(JSONObject.from(payload));
|
|
|
+
|
|
|
+ sendConfigCmd(configCmdReqVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return status;
|
|
|
+ }
|
|
|
}
|