|
@@ -4,6 +4,8 @@ import net.sf.json.JSONArray;
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
import org.apache.commons.codec.binary.Base64;
|
|
import org.apache.commons.codec.binary.Base64;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
|
+import org.jeecg.modules.system.entity.SysDictItem;
|
|
|
|
+import org.jeecg.modules.system.service.ISysDictItemService;
|
|
import org.jeecg.modules.webaccess.dto.WaLogDTO;
|
|
import org.jeecg.modules.webaccess.dto.WaLogDTO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpEntity;
|
|
import org.springframework.http.HttpEntity;
|
|
@@ -24,8 +26,32 @@ public class WebAccessService {
|
|
@Autowired
|
|
@Autowired
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
-// @Autowired
|
|
|
|
-// private ISysConfigService configService;
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysDictItemService sysDictItemService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取webaccess的API信息
|
|
|
|
+ * @param itemtext(group:组合API,single:单独某个信息,login:登录信息)
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String getDictItemDesc(String itemtext, String type) {
|
|
|
|
+ SysDictItem uriIictItem = sysDictItemService.selectItemsByDictcodeAndItemtext("webaccess", "webaccess地址");
|
|
|
|
+ SysDictItem projIictItem = sysDictItemService.selectItemsByDictcodeAndItemtext("webaccess", "webaccess工程名");
|
|
|
|
+ SysDictItem dictItem = sysDictItemService.selectItemsByDictcodeAndItemtext("webaccess", itemtext);
|
|
|
|
+
|
|
|
|
+ if ("group".equals(type)) {
|
|
|
|
+ return uriIictItem.getDescription() + "/" + dictItem.getDescription() + "/" + projIictItem.getDescription();
|
|
|
|
+ }
|
|
|
|
+ else if ("single".equals(type)) {
|
|
|
|
+ return dictItem.getDescription();
|
|
|
|
+ }
|
|
|
|
+ else if ("login".equals(type)) {
|
|
|
|
+ return uriIictItem.getDescription() + "/" + dictItem.getDescription();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 登录
|
|
* 登录
|
|
@@ -33,9 +59,7 @@ public class WebAccessService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject login() {
|
|
public JSONObject login() {
|
|
- String paramValues = "";
|
|
|
|
-// String url = configService.selectConfigByKey("ems.webaccess.login");;
|
|
|
|
- String url = "";
|
|
|
|
|
|
+ String url = getDictItemDesc("登录地址", "login");
|
|
JSONObject result = httpRequest(url, null);
|
|
JSONObject result = httpRequest(url, null);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -46,8 +70,7 @@ public class WebAccessService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject tagList() {
|
|
public JSONObject tagList() {
|
|
-// String getTagValueUrl = configService.selectConfigByKey("ems.webaccess.GetTagList");
|
|
|
|
- String getTagValueUrl = "";
|
|
|
|
|
|
+ String getTagValueUrl = getDictItemDesc("取得所有测点列表", "group");
|
|
JSONObject result = httpRequest(getTagValueUrl, null);
|
|
JSONObject result = httpRequest(getTagValueUrl, null);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
@@ -61,8 +84,7 @@ public class WebAccessService {
|
|
*/
|
|
*/
|
|
public String getTagNameValues(JSONObject jsonObject) {
|
|
public String getTagNameValues(JSONObject jsonObject) {
|
|
String paramValues = "";
|
|
String paramValues = "";
|
|
-// String getTagValueUrl = configService.selectConfigByKey("ems.webaccess.GetTagValue");
|
|
|
|
- String getTagValueUrl = "";
|
|
|
|
|
|
+ String getTagValueUrl = getDictItemDesc("取得测点的量测值", "group");
|
|
JSONObject result = httpRequest(getTagValueUrl, jsonObject);
|
|
JSONObject result = httpRequest(getTagValueUrl, jsonObject);
|
|
JSONArray jsonArray = result.getJSONArray("Values");
|
|
JSONArray jsonArray = result.getJSONArray("Values");
|
|
|
|
|
|
@@ -96,10 +118,8 @@ public class WebAccessService {
|
|
JSONObject itemInfor = JSONObject.fromObject(item);
|
|
JSONObject itemInfor = JSONObject.fromObject(item);
|
|
map.put(itemInfor.getString("Name"), itemInfor.getDouble("Value"));
|
|
map.put(itemInfor.getString("Name"), itemInfor.getDouble("Value"));
|
|
}
|
|
}
|
|
-// String getTagValueUrl = configService.selectConfigByKey("ems.webaccess.GetTagValue");
|
|
|
|
-// String setTagValueUrl = configService.selectConfigByKey("ems.webaccess.SetTagValue");
|
|
|
|
- String getTagValueUrl = "";
|
|
|
|
- String setTagValueUrl = "";
|
|
|
|
|
|
+ String getTagValueUrl = getDictItemDesc("取得测点的量测值", "group");
|
|
|
|
+ String setTagValueUrl = getDictItemDesc("更改测点的量测值", "group");
|
|
|
|
|
|
JSONObject result = httpRequest(setTagValueUrl, jsonObject);
|
|
JSONObject result = httpRequest(setTagValueUrl, jsonObject);
|
|
Thread.sleep(500);
|
|
Thread.sleep(500);
|
|
@@ -153,10 +173,8 @@ public class WebAccessService {
|
|
JSONObject itemInfor = JSONObject.fromObject(item);
|
|
JSONObject itemInfor = JSONObject.fromObject(item);
|
|
map.put(itemInfor.getString("Name"), itemInfor.getString("Value"));
|
|
map.put(itemInfor.getString("Name"), itemInfor.getString("Value"));
|
|
}
|
|
}
|
|
-// String getTagValueTextUrl = configService.selectConfigByKey("ems.webaccess.GetTagValueText");
|
|
|
|
-// String setTagValueTextUrl = configService.selectConfigByKey("ems.webaccess.SetTagValueText");
|
|
|
|
- String getTagValueTextUrl = "";
|
|
|
|
- String setTagValueTextUrl = "";
|
|
|
|
|
|
+ String getTagValueTextUrl = getDictItemDesc("取得文字测点的量测值", "group");
|
|
|
|
+ String setTagValueTextUrl = getDictItemDesc("更改文字测点的量测值", "group");
|
|
|
|
|
|
JSONObject result = httpRequest(setTagValueTextUrl, jsonObject);
|
|
JSONObject result = httpRequest(setTagValueTextUrl, jsonObject);
|
|
|
|
|
|
@@ -197,8 +215,7 @@ public class WebAccessService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private JSONObject httpRequest(String url, JSONObject jsonObject) {
|
|
private JSONObject httpRequest(String url, JSONObject jsonObject) {
|
|
-// String plainCreds = configService.selectConfigByKey("ems.webaccess.AccountPwd");
|
|
|
|
- String plainCreds = "";
|
|
|
|
|
|
+ String plainCreds = getDictItemDesc("登录信息", "single");
|
|
byte[] plainCredsBytes = plainCreds.getBytes();
|
|
byte[] plainCredsBytes = plainCreds.getBytes();
|
|
byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
|
|
byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
|
|
String base64Creds = new String(base64CredsBytes);
|
|
String base64Creds = new String(base64CredsBytes);
|