|
@@ -283,31 +283,47 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
}
|
|
}
|
|
|
JSONObject dataJson = iotRunHaoSfdata.getSfdataContent();
|
|
JSONObject dataJson = iotRunHaoSfdata.getSfdataContent();
|
|
|
Map<String, IotSfElementfactorInfoVo> eleMap = new LinkedHashMap<>();
|
|
Map<String, IotSfElementfactorInfoVo> eleMap = new LinkedHashMap<>();
|
|
|
|
|
+ Map<String, IotSfElementfactor> tempMap = new LinkedHashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (IotSfElementfactor elementfactor : resVoList) {
|
|
|
|
|
+ String sfBid = elementfactor.getSfBid();
|
|
|
|
|
+ tempMap.put(sfBid, elementfactor);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
for (IotSfElementfactor elementfactor : resVoList) {
|
|
for (IotSfElementfactor elementfactor : resVoList) {
|
|
|
String sfBid = elementfactor.getSfBid();
|
|
String sfBid = elementfactor.getSfBid();
|
|
|
- String sfParentBid = elementfactor.getSfParentBid();
|
|
|
|
|
String sfCode = elementfactor.getSfCode();
|
|
String sfCode = elementfactor.getSfCode();
|
|
|
|
|
+ String sfParentBid = elementfactor.getSfParentBid();
|
|
|
String value = getDataValue(dataJson, sfCode);
|
|
String value = getDataValue(dataJson, sfCode);
|
|
|
|
|
|
|
|
- IotSfElementfactorInfoVo infoVo = new IotSfElementfactorInfoVo();
|
|
|
|
|
- BeanUtils.copyProperties(elementfactor, infoVo);
|
|
|
|
|
- infoVo.setValue(value);
|
|
|
|
|
|
|
+ IotSfElementfactorInfoVo eleResVo = new IotSfElementfactorInfoVo();
|
|
|
|
|
+ BeanUtils.copyProperties(elementfactor, eleResVo);
|
|
|
|
|
+ eleResVo.setValue(value);
|
|
|
|
|
|
|
|
- IotSfElementfactorInfoVo parentInfo = eleMap.get(sfParentBid);
|
|
|
|
|
- if(parentInfo == null){
|
|
|
|
|
- infoVo.setChildrenList(new ArrayList<>());
|
|
|
|
|
- eleMap.put(sfBid, infoVo);
|
|
|
|
|
|
|
+ // 表示是一级元素,直接添加
|
|
|
|
|
+ if(StringUtils.isEmpty(sfParentBid) && !eleMap.containsKey(sfBid)){
|
|
|
|
|
+ eleResVo.setChildrenList(new ArrayList<>());
|
|
|
|
|
+ eleMap.put(sfBid, eleResVo);
|
|
|
}else{
|
|
}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);
|
|
|
|
|
|
|
+ // 表示不是一级元素,需要判断父元素是否已经存在
|
|
|
|
|
+ IotSfElementfactorInfoVo parentInfo = eleMap.get(sfParentBid);
|
|
|
|
|
+ // 如果父类已经添加,直接添加到父类的childrenList中
|
|
|
|
|
+ if(parentInfo != null){
|
|
|
|
|
+ parentInfo.getChildrenList().add(eleResVo);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 如果父类没有添加,需要先添加父类,再添加当前元素
|
|
|
|
|
+ IotSfElementfactor parentElement = tempMap.get(sfParentBid);
|
|
|
|
|
+ // 如果父类不存在,直接跳过
|
|
|
|
|
+ if(parentElement == null){
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ IotSfElementfactorInfoVo parentReq = new IotSfElementfactorInfoVo();
|
|
|
|
|
+ BeanUtils.copyProperties(parentElement, parentReq);
|
|
|
|
|
+ parentReq.setChildrenList(new ArrayList<>());
|
|
|
|
|
+ parentReq.setValue(getDataValue(dataJson, parentReq.getSfCode()));
|
|
|
|
|
+
|
|
|
|
|
+ parentReq.getChildrenList().add(eleResVo);
|
|
|
|
|
+ eleMap.put(sfParentBid, parentReq);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -744,6 +760,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
sfTypeMap.put(runMode, null);
|
|
sfTypeMap.put(runMode, null);
|
|
|
|
|
|
|
|
Map<EnumSfElementType, Integer> sfTypeValueMap = new HashMap<>();
|
|
Map<EnumSfElementType, Integer> sfTypeValueMap = new HashMap<>();
|
|
|
|
|
+ Map<String, IotSfElementfactorInfoVo> elementfactorInfoVoMap = new HashMap<>();
|
|
|
IotSfElementfactorAlreadyListResVo groupResVo = null;
|
|
IotSfElementfactorAlreadyListResVo groupResVo = null;
|
|
|
|
|
|
|
|
for(IotSfElementfactorInfoVo element : resultList){
|
|
for(IotSfElementfactorInfoVo element : resultList){
|
|
@@ -776,11 +793,13 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
|
|
|
|
|
sfTypeValueMap.put(childType, sfTypeValueMap.getOrDefault(childType, 0) + Integer.parseInt(child.getValue()));
|
|
sfTypeValueMap.put(childType, sfTypeValueMap.getOrDefault(childType, 0) + Integer.parseInt(child.getValue()));
|
|
|
sfTypeMap.put(child.getSfCode(), childType);
|
|
sfTypeMap.put(child.getSfCode(), childType);
|
|
|
|
|
+ elementfactorInfoVoMap.put(child.getSfCode(), child);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if(typeSet.contains(elementType)){
|
|
if(typeSet.contains(elementType)){
|
|
|
sfTypeValueMap.put(elementType, sfTypeValueMap.getOrDefault(elementType, 0) + Integer.parseInt(element.getValue()));
|
|
sfTypeValueMap.put(elementType, sfTypeValueMap.getOrDefault(elementType, 0) + Integer.parseInt(element.getValue()));
|
|
|
sfTypeMap.put(element.getSfCode(), elementType);
|
|
sfTypeMap.put(element.getSfCode(), elementType);
|
|
|
|
|
+ elementfactorInfoVoMap.put(element.getSfCode(), element);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -824,7 +843,17 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"请先关闭水源泵");
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"请先关闭水源泵");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if(elementfactorInfoVoMap.containsKey(key)){
|
|
|
|
|
+ IotSfElementfactorInfoVo elementfactorInfoVo = elementfactorInfoVoMap.get(key);
|
|
|
|
|
+ String oprecdName = elementfactorInfoVo.getSfDisplayname();
|
|
|
|
|
+ String oprecdContent = "关闭";
|
|
|
|
|
+ String oprecdStatus = "0";
|
|
|
|
|
+ if(Objects.equals(v, "1")){
|
|
|
|
|
+ oprecdContent = "打开";
|
|
|
|
|
+ oprecdStatus = "1";
|
|
|
|
|
+ }
|
|
|
|
|
+ iotSfIrrigationOprecordService.createIotSfIrrigationOprecord(devBid, oprecdName, oprecdContent, oprecdStatus);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//
|
|
//
|
|
@@ -1076,6 +1105,8 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
String sfdataBid = runStatusData.getString("sfdataBid");
|
|
String sfdataBid = runStatusData.getString("sfdataBid");
|
|
|
iotSfIrrigationRecordService.createIotSfIrrigationRecordList(groupList, EnumIrrigationRecord.MODE_AUTO.getCode(), sfdataBid);
|
|
iotSfIrrigationRecordService.createIotSfIrrigationRecordList(groupList, EnumIrrigationRecord.MODE_AUTO.getCode(), sfdataBid);
|
|
|
|
|
|
|
|
|
|
+ iotSfIrrigationOprecordService.createIotSfIrrigationOprecord(devBid, "自动灌溉", "启动", "1");
|
|
|
|
|
+
|
|
|
IotSfConfigCmdReqVo cmdReqVo = new IotSfConfigCmdReqVo();
|
|
IotSfConfigCmdReqVo cmdReqVo = new IotSfConfigCmdReqVo();
|
|
|
cmdReqVo.setDevBid(devBid);
|
|
cmdReqVo.setDevBid(devBid);
|
|
|
cmdReqVo.setCmd(CmdDef.RunHaoSfCmdDef.CMD_CONFIG);
|
|
cmdReqVo.setCmd(CmdDef.RunHaoSfCmdDef.CMD_CONFIG);
|