|
@@ -6,6 +6,7 @@ import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.ruoyi.demo.config.MtStarProperties;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -14,6 +15,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Component
|
|
|
+@Slf4j
|
|
|
public class MtStarUtil {
|
|
|
@Autowired
|
|
|
MtStarProperties mtStarProperties;
|
|
@@ -36,15 +38,20 @@ public class MtStarUtil {
|
|
|
map.put("startIndex", 0);
|
|
|
map.put("queryCount", 1);
|
|
|
map.put("select_name", equipmentCode);
|
|
|
- String post = HttpUtil.post(mtStarProperties.getUrl() + "dev_get_devs_cmarks", map);
|
|
|
- JSONObject obj = JSONUtil.parseObj(post);
|
|
|
- if (obj.get("retCode",Integer.class) == 0){
|
|
|
- List<String> list = obj.getBeanList("cMarkList", String.class);
|
|
|
- if (list != null && !list.isEmpty()){
|
|
|
- JSONObject entries = JSONUtil.parseObj(list.get(0));
|
|
|
- return entries.get("cMark", String.class);
|
|
|
- }
|
|
|
+ try {
|
|
|
+ String post = HttpUtil.post(mtStarProperties.getUrl() + "dev_get_devs_cmarks", map);
|
|
|
+ JSONObject obj = JSONUtil.parseObj(post);
|
|
|
+ if (obj.get("retCode",Integer.class) == 0){
|
|
|
+ List<String> list = obj.getBeanList("cMarkList", String.class);
|
|
|
+ if (list != null && !list.isEmpty()){
|
|
|
+ JSONObject entries = JSONUtil.parseObj(list.get(0));
|
|
|
+ return entries.get("cMark", String.class);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return "error";
|
|
|
}
|
|
|
return "error";
|
|
|
}
|
|
@@ -66,10 +73,15 @@ public class MtStarUtil {
|
|
|
sCmd.put("subcmd", "ctrl_lcd_onoff_ontime");
|
|
|
map.put("params", sCmd.toString());
|
|
|
map.put("retry", 0);
|
|
|
- String post = HttpUtil.post(mtStarProperties.getUrl() + "sendClientParams", map);
|
|
|
- JSONObject obj = JSONUtil.parseObj(post);
|
|
|
- if (0 == obj.get("retCode", Integer.class))
|
|
|
- return "success";
|
|
|
+ try {
|
|
|
+ String post = HttpUtil.post(mtStarProperties.getUrl() + "sendClientParams", map);
|
|
|
+ JSONObject obj = JSONUtil.parseObj(post);
|
|
|
+ if (0 == obj.get("retCode", Integer.class))
|
|
|
+ return "success";
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return "error";
|
|
|
+ }
|
|
|
return "error";
|
|
|
}
|
|
|
|