|
@@ -5,6 +5,8 @@
|
|
*/
|
|
*/
|
|
package com.hboxs.control.admin;
|
|
package com.hboxs.control.admin;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.gexin.fastjson.JSON;
|
|
import com.hboxs.ViewObject.CommonParamVo;
|
|
import com.hboxs.ViewObject.CommonParamVo;
|
|
import com.hboxs.common.Filter;
|
|
import com.hboxs.common.Filter;
|
|
import com.hboxs.common.JsonMessage;
|
|
import com.hboxs.common.JsonMessage;
|
|
@@ -88,6 +90,13 @@ public class EquipmentController extends BaseController {
|
|
}
|
|
}
|
|
model.addAttribute("rulesCkche", lis);
|
|
model.addAttribute("rulesCkche", lis);
|
|
}
|
|
}
|
|
|
|
+ }else{
|
|
|
|
+ model.addAttribute("rules", null);
|
|
|
|
+ List<String> lis = new ArrayList<>();
|
|
|
|
+ for(int i = 0;i<10;i++){
|
|
|
|
+ lis.add("a");
|
|
|
|
+ }
|
|
|
|
+ model.addAttribute("rulesCkche", lis);
|
|
}
|
|
}
|
|
if(equipment.getRule()==null){
|
|
if(equipment.getRule()==null){
|
|
List<String> lis = new ArrayList<>();
|
|
List<String> lis = new ArrayList<>();
|
|
@@ -335,7 +344,23 @@ public class EquipmentController extends BaseController {
|
|
String rule = commonParamVo.getVal();
|
|
String rule = commonParamVo.getVal();
|
|
Long id = Long.valueOf(commonParamVo.getId());
|
|
Long id = Long.valueOf(commonParamVo.getId());
|
|
Equipment equipment = equipmentService.find(id);
|
|
Equipment equipment = equipmentService.find(id);
|
|
- equipment.setRule(rule);
|
|
|
|
|
|
+ if(rule!=null&&rule.length()>=6){
|
|
|
|
+ String[] res = rule.split(",");
|
|
|
|
+ StringBuffer rules = new StringBuffer();
|
|
|
|
+ for(int i=0;i<res.length;i++){
|
|
|
|
+ if(res[i]!=null&&!res[i].equals("")){
|
|
|
|
+ if(res[i].length()>6){
|
|
|
|
+ rules.append(res[i]+",");
|
|
|
|
+ }else {
|
|
|
|
+ rules.append(res[i]+":59,");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ equipment.setRule(rules.toString().substring(0,rules.toString().length()-1));
|
|
|
|
+ }
|
|
|
|
+ if(rule!=null&&!rule.equals("")&&rule.length()<6){
|
|
|
|
+ equipment.setRule(rule+":59");
|
|
|
|
+ }
|
|
equipmentService.update(equipment);
|
|
equipmentService.update(equipment);
|
|
PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("updateRule", rule).toString());
|
|
PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("updateRule", rule).toString());
|
|
return SUCCESS_MESSAGE;
|
|
return SUCCESS_MESSAGE;
|
|
@@ -402,8 +427,28 @@ public class EquipmentController extends BaseController {
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public Message updateCommonParam(@RequestBody CommonParamVo commonParamVo) {
|
|
public Message updateCommonParam(@RequestBody CommonParamVo commonParamVo) {
|
|
String gtClientId = commonParamVo.getId();
|
|
String gtClientId = commonParamVo.getId();
|
|
-
|
|
|
|
|
|
+ String clientId = commonParamVo.getClientId();
|
|
|
|
+ String name = commonParamVo.getName();
|
|
|
|
+ String code = commonParamVo.getCode();
|
|
PushUtils.push(gtClientId, "", "", PushUtils.buildJson("Param", commonParamVo.getName() + ":" + commonParamVo.getVal()).toString());
|
|
PushUtils.push(gtClientId, "", "", PushUtils.buildJson("Param", commonParamVo.getName() + ":" + commonParamVo.getVal()).toString());
|
|
|
|
+ Equipment equipment = equipmentService.findByClientId(clientId);
|
|
|
|
+ List<CommonParamVo> commonParamVos = null;
|
|
|
|
+ String commonParameters = equipment.getCommonParameters();
|
|
|
|
+ String advancedParameters = equipment.getAdvancedParameters();
|
|
|
|
+ if (code.equals("0")) {
|
|
|
|
+ commonParamVos = JSON.parseArray(commonParameters, CommonParamVo.class);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ commonParamVos = JSON.parseArray(advancedParameters, CommonParamVo.class);
|
|
|
|
+ for (CommonParamVo commonParam : commonParamVos) {
|
|
|
|
+ if (commonParam.getName().equals(name)) {
|
|
|
|
+ commonParam.setVal(commonParamVo.getVal());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String param = JSONArray.toJSONString(commonParamVos);
|
|
|
|
+ equipment.setAdvancedParameters(param);
|
|
|
|
+ equipmentService.update(equipment);
|
|
|
|
+ }
|
|
|
|
|
|
return SUCCESS_MESSAGE;
|
|
return SUCCESS_MESSAGE;
|
|
}
|
|
}
|