|
|
@@ -719,41 +719,46 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
* @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
|
|
|
* @param reqVo
|
|
|
*/
|
|
|
- public JSONObject getGroupParamByGlobal (String devBid) {
|
|
|
- JSONObject groupParamJson = new JSONObject();
|
|
|
+ public List<IotSfGroupParamResVo> getGroupParamByGlobal (String devBid) {
|
|
|
+ List<IotSfGroupParamResVo> groupParamResVoList = new ArrayList<>();
|
|
|
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;
|
|
|
+ return groupParamResVoList;
|
|
|
}
|
|
|
+ Map<String, String> groupParamMap = new LinkedHashMap<>();
|
|
|
+ groupParamMap.put("Btn-dsdl", "施肥模式");
|
|
|
+ groupParamMap.put("Num-ggsj", "灌溉时间");
|
|
|
+ groupParamMap.put("Num-fqsj", "肥前水时间");
|
|
|
|
|
|
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());
|
|
|
+ String sfCode = vo.getSfCode();
|
|
|
+ String sfDisplayname = vo.getSfDisplayname();
|
|
|
+ String key = sfCode.replace("Btn-fs", "");
|
|
|
+ groupParamMap.put("Btn-fxz" + key, sfDisplayname + "开关");
|
|
|
+ groupParamMap.put("Num-fsj" + key, sfDisplayname);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- 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()){
|
|
|
+ for(Map.Entry<String, String> entry : groupParamMap.entrySet()){
|
|
|
+ String key = entry.getKey();
|
|
|
String value = RunHaoSfElementUtil.getDataValue(key, sfdataContent);
|
|
|
- groupParamJson.put(key, value);
|
|
|
+
|
|
|
+ IotSfGroupParamResVo resVo = new IotSfGroupParamResVo();
|
|
|
+ resVo.setSfCode(key);
|
|
|
+ resVo.setSfDisplayName(entry.getValue());
|
|
|
+ resVo.setValue(value);
|
|
|
+
|
|
|
+ groupParamResVoList.add(resVo);
|
|
|
}
|
|
|
- return groupParamJson;
|
|
|
+ return groupParamResVoList;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -836,9 +841,9 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "请先切换到自动模式");
|
|
|
}
|
|
|
|
|
|
- String dsdl = runStatusData.getString("Btn-dsdl");
|
|
|
- String lgcs = runStatusData.getString("Num-lgcs");
|
|
|
- String lgjg = runStatusData.getString("Num-lgjg");
|
|
|
+ String dsdl = data.getString("Btn-dsdl");
|
|
|
+ String lgcs = data.getString("Num-lgcs");
|
|
|
+ String lgjg = data.getString("Num-lgjg");
|
|
|
|
|
|
if(StringUtils.isEmpty(dsdl)){
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "请先设置施肥模式");
|
|
|
@@ -858,13 +863,14 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
|
|
|
JSONObject sendJson = new JSONObject();
|
|
|
for(IotSfElementfactorAlreadyListResVo elementfactor : elementfactorList){
|
|
|
+ String sfCode = elementfactor.getSfCode();
|
|
|
+ if(!data.containsKey(sfCode)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if(elementfactor.getChildrenList() == null || elementfactor.getChildrenList().isEmpty()){
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "灌区未配置阀,无法开始灌溉");
|
|
|
}
|
|
|
- String sfCode = elementfactor.getSfCode();
|
|
|
- if(data.containsKey(sfCode)){
|
|
|
- sendJson.put(sfCode, data.getString(sfCode));
|
|
|
- }
|
|
|
+ sendJson.put(sfCode, "1");
|
|
|
}
|
|
|
if(sendJson.isEmpty()){
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "请先选择灌区");
|