From 7233f8c157e323f97a074753a2c4bd463f960b5c Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 12 五月 2026 14:02:36 +0800
Subject: [PATCH] 新增智能电表、空调管理
---
admin/src/views/business/deviceDianbiao.vue | 39 +
server/visits/dmvisit_service/src/main/resources/application-dev.yml | 1
server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicSubscribeController.java | 67 ++
server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java | 1
server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicNotifyController.java | 72 +++
server/visits/dmvisit_service/src/main/java/com/doumee/core/device/ElectronicToolUitl.java | 1141 +++++++++++++++++++++++++++++++++++++++++++++++++
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java | 2
admin/.env.development | 4
8 files changed, 1,314 insertions(+), 13 deletions(-)
diff --git a/admin/.env.development b/admin/.env.development
index 4e50306..e5046b9 100644
--- a/admin/.env.development
+++ b/admin/.env.development
@@ -3,9 +3,9 @@
# 椤圭洰涓婁笅鏂囪矾寰�
VUE_APP_CONTEXT_PATH = './'
-#VUE_APP_API_URL = 'http://localhost:10010'
+VUE_APP_API_URL = 'http://localhost:10010'
-VUE_APP_API_URL = 'http://192.168.1.44:10010'
+#VUE_APP_API_URL = 'http://192.168.1.44:10010'
#VUE_APP_API_URL = 'https://zhcg.fnwtzx.com/gateway_interface'
diff --git a/admin/src/views/business/deviceDianbiao.vue b/admin/src/views/business/deviceDianbiao.vue
index 85a37d0..e92031b 100644
--- a/admin/src/views/business/deviceDianbiao.vue
+++ b/admin/src/views/business/deviceDianbiao.vue
@@ -11,6 +11,13 @@
<el-form-item title="璁惧鍙�" prop="doorNo">
<el-input v-model="searchForm.doorNo" placeholder="璇疯緭鍏ヨ澶囧彿" @keypress.enter.native="search"></el-input>
</el-form-item>
+ <el-form-item label="杩愯鐘舵��" prop="status">
+ <el-select v-model="searchForm.status" @keypress.enter.native="search" clearable placeholder="閫夋嫨鐘舵��">
+ <el-option label="鍚堥椄" value="0"></el-option>
+ <el-option label="寮�闂�" value="1"></el-option>
+ <el-option label="寮�闂�" value="2"></el-option>
+ </el-select>
+ </el-form-item>
<section>
<el-button type="primary" @click="search">鎼滅储</el-button>
<el-button @click="reset">閲嶇疆</el-button>
@@ -19,7 +26,8 @@
<!-- 琛ㄦ牸鍜屽垎椤� -->
<template v-slot:table-wrap>
<ul class="toolbar" v-permissions="['business:device:create', 'business:device:delete']">
- <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('鏂板缓鐢佃〃')" icon="el-icon-plus" v-permissions="['business:device:create']">鏂板缓</el-button></li>
+ <li><el-button type="primary" @click="synchronousData">鍚屾</el-button></li>
+<!-- <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('鏂板缓鐢佃〃')" icon="el-icon-plus" v-permissions="['business:device:create']">鏂板缓</el-button></li>-->
<li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:device:delete']">鍒犻櫎</el-button></li>
</ul>
<el-table
@@ -27,14 +35,11 @@
:data="tableData.list"
stripe >
<el-table-column type="selection" width="55"></el-table-column>
+ <el-table-column prop="no" label="琛ㄥ彿" min-width="100" align="center" ></el-table-column>
<el-table-column prop="name" label="鍚嶇О" fixed min-width="150" align="center"></el-table-column>
- <el-table-column prop="no" label="鐢佃〃鍦板潃鍩�" min-width="100" align="center" ></el-table-column>
- <el-table-column prop="doorNo" label="璁惧鍙�" min-width="120" align="center" show-overflow-tooltip></el-table-column>
-<!--
- <el-table-column prop="channelNo" label="寮�鍏冲簭鍙�" align="center" min-width="100"></el-table-column>
--->
+ <el-table-column prop="doorNo" label="閲囬泦鍙�" min-width="120" align="center" show-overflow-tooltip></el-table-column>
<el-table-column prop="manufature" label="鍘傚晢" align="center" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column prop="regionPathName" align="center" min-width="100" label="鎵�鍦ㄤ綅缃�"></el-table-column>
+ <el-table-column prop="regionPathName" align="center" min-width="100" label="缁戝畾鎴块棿"></el-table-column>
<el-table-column prop="ip" label="IP" min-width="150" align="center" show-overflow-tooltip ></el-table-column>
<el-table-column prop="port" label="绔彛" align="center" ></el-table-column>
<el-table-column prop="isUsed" label="鏄惁浣跨敤">
@@ -114,6 +119,7 @@
import Pagination from '@/components/common/Pagination'
import OperaDeviceDataListWindow from '@/components/business/OperaDianbiaoDataListWindow'
import OperaDeviceDianbiaoWindow from '@/components/business/OperaDeviceDianbiaoWindow'
+import { syncDevices } from '@/api/business/device'
export default {
name: 'DeviceDuanluqi',
extends: BaseTable,
@@ -197,12 +203,29 @@
},
send (row, type) {
this.visibleSend = true
- this.form = { id: row.id, name: row.name, cmdDate: null, status: type}
+ this.form = { id: row.id, name: row.name, cmdDate: null, status: type }
},
sendClose () {
this.visibleSend = false
this.isWorkSending = false
this.form = { id: '', name: '', status: '', cmdDate: '' }
+ },
+ synchronousData () {
+ this.$dialog.actionConfirm('鎿嶄綔纭鎻愰啋', '鎮ㄧ‘璁ゅ悓姝ュ叏閮ㄤ俊鎭悧锛�')
+ .then(() => {
+ this.isWorking.delete = true
+ syncDevices({ type: 6 })
+ .then(res => {
+ this.$tip.apiSuccess(res || '鍚屾鎴愬姛')
+ this.search()
+ })
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ .finally(() => {
+ this.isWorking.delete = false
+ })
+ }) .catch(() => {})
}
}
}
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicNotifyController.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicNotifyController.java
new file mode 100644
index 0000000..68fe16b
--- /dev/null
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicNotifyController.java
@@ -0,0 +1,72 @@
+package com.doumee.device;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.util.*;
+
+@RestController
+@RequestMapping("/electronic")
+public class ElectronicNotifyController {
+
+ @RequestMapping("/notify")
+ public String notify(String response_content, String timestamp, String sign) {
+ System.out.println("timestamp: " + timestamp);
+ System.out.println("response_content: " + response_content);
+ System.out.println("sign: " + sign);
+ // 楠岀
+ if(!checkSign(response_content, timestamp, sign)) {
+ System.out.println("sign check failed");
+ return "sign check failed";
+ }
+ System.out.println("sign check success");
+ List<Map<String, Object>> responseContent= new ArrayList<>();
+ JSONArray contentArray = JSON.parseArray(response_content);
+ for(int i = 0; i < contentArray.size(); ++i) {
+ HashMap<String, Object> contentMap = new HashMap<>();
+ JSONObject contentObject = contentArray.getJSONObject(i);
+ Set<String> keySet = contentObject.keySet();
+ for(String key: keySet) {
+ contentMap.put(key, contentObject.getObject(key, Object.class));
+ }
+ responseContent.add(contentMap);
+ }
+ System.out.println("鎺ユ敹寮傛閫氱煡鏁版嵁锛�" + responseContent);
+ return "SUCCESS";
+ }
+
+ private boolean checkSign(String response_content, String timestamp, String sign) {
+ // 闅忔満瀛楃涓� 鍚庡彴鑾峰彇
+ String nonce = "XOfX547SeCIlhufeeBBwgZIN";
+ String buf = response_content + timestamp + nonce;
+ String encode = getMD5(buf);
+ return encode.equals(sign);
+ }
+ // md5鍔犲瘑
+ private String getMD5(String password) {
+ MessageDigest md5 = null;
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ byte[] byteArray = password.getBytes(StandardCharsets.UTF_8);
+
+ byte[] md5Bytes = md5.digest(byteArray);
+ StringBuilder hexValue = new StringBuilder();
+ for (byte md5Byte : md5Bytes) {
+ int val = ((int) md5Byte) & 0xff;
+ if (val < 16) {
+ hexValue.append("0");
+ }
+
+ hexValue.append(Integer.toHexString(val));
+ }
+ return hexValue.toString();
+ }
+}
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicSubscribeController.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicSubscribeController.java
new file mode 100644
index 0000000..e8728cb
--- /dev/null
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicSubscribeController.java
@@ -0,0 +1,67 @@
+package com.doumee.device;
+
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+
+@RestController
+@RequestMapping("/electronic")
+public class ElectronicSubscribeController {
+
+ @RequestMapping("/subscribe")
+ public String subscribe(@RequestBody(required=false) String body,
+ @RequestHeader(value="sign", required=false) String sign) {
+ if(body==null) {
+ body = "";
+ }
+ if(!checkSign(body, sign)) {
+ return "sign check failed";
+ }
+
+ if("".equals(body)) {
+ System.out.println("鎺ユ敹鍒版湇鍔″櫒璺緞娴嬭瘯璇锋眰");
+ } else {
+ System.out.println("鎺ユ敹鍒拌闃呮秷鎭�");
+ System.out.println(body);
+ //-----------鍔犲叆涓氬姟閫昏緫-----------
+ //--------------------------------
+ }
+
+ return "SUCCESS";
+ }
+
+ private boolean checkSign(String response_content, String sign) {
+ // 闅忔満瀛楃涓� 鍚庡彴鑾峰彇
+ String token = "7O2wtcxNCvtSL7MtIOLs";
+ String buf = response_content + token;
+ String encode = getMD5(buf);
+ return encode.equalsIgnoreCase(sign);
+ }
+
+ // md5鍔犲瘑
+ private String getMD5(String password) {
+ MessageDigest md5 = null;
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ byte[] byteArray = password.getBytes(StandardCharsets.UTF_8);
+
+ byte[] md5Bytes = md5.digest(byteArray);
+ StringBuilder hexValue = new StringBuilder();
+ for (byte md5Byte : md5Bytes) {
+ int val = ((int) md5Byte) & 0xff;
+ if (val < 16) {
+ hexValue.append("0");
+ }
+
+ hexValue.append(Integer.toHexString(val));
+ }
+ return hexValue.toString();
+ }
+}
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
index d94a198..94495a0 100644
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
@@ -111,7 +111,6 @@
HKService.cancelEventSub(param);//鍏堝彇娑�
// HKService.eventSub(param);//鏈堝彴宸ヤ綔鐘舵�佷簨浠�
-
param.setEventDest(path+"/platform/carstatus");
param.setEventTypes(new Integer[]{HKConstants.EventTypes.PLATFORM_CAR_STATUS.getKey()});
HKService.cancelEventSub(param);//鍏堝彇娑�
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/core/device/ElectronicToolUitl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/core/device/ElectronicToolUitl.java
new file mode 100644
index 0000000..c2db600
--- /dev/null
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/core/device/ElectronicToolUitl.java
@@ -0,0 +1,1141 @@
+package com.doumee.core.device;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.util.*;
+
+public class ElectronicToolUitl {
+
+ // 鎺堟潈鐮� 鐧诲綍 鍚庡彴鑾峰彇锛� 鑱旂郴浣犵殑鐢叉柟鎴栬�呮槸閿�鍞�
+ private static String auth_code = "1f29d378fc6792d5d2b735877993ffb7";
+ // 闅忔満瀛楃涓� 鍚庡彴鑾峰彇
+ private static String nonce = "lvyOY7fcun719WkxF8ToVYatStgt";
+ // 娴嬭瘯鐢ㄩ噰闆嗗櫒鍙� 璇蜂娇鐢ㄧ湡瀹炶澶囬噰闆嗗櫒鍙�
+ private static String debug_collector = "19020618114";
+ // 娴嬭瘯鐢ㄧ數琛ㄥ彿 璇蜂娇鐢ㄧ湡瀹炶澶囬噰闆嗗櫒鍙�
+ private static String debug_meter = "000066660942";
+ // 寮傛閫氱煡鍦板潃锛堟湇鍔″鏋滈儴缃插湪鍐呯綉锛屽湪鍏綉鏃犳硶鐩存帴璁块棶鍒帮紝闇�瑕佸湪璺敱鍣ㄤ笂閰嶇疆绔彛鏄犲皠锛屾垨鑰呴厤缃唴缃戠┛閫忓伐鍏锋潵瀹炵幇璁块棶锛� 姝ゅ浠呬负娴嬭瘯 绀轰緥
+ private static String notify_url = "http://115.221.15.8:8055/notify";
+ private static String api_url = "http://api1.tqdianbiao.com";
+ private static String api2_url = "http://api2.tqdianbiao.com";
+
+
+ public static void main(String[] args) {
+// 娉ㄦ剰 濡傞渶浣跨敤鍏呭�煎姛鑳� 鍙厛浜嗚В [鍙傛暟缁存姢妯″紡](http://doc-api.tqdianbiao.com/doc/backend/data_sync_mode.html)
+// 娉ㄦ剰 鏈�2涓郴缁� 鎺堟潈鐮佺瓑鍙傛暟 鍚勮嚜鐙珛 鎺ュ彛鍩熷悕鍒嗗埆涓� https://iot.tqdianbiao.com/ http://api1.tqdianbiao.com
+
+// -------- 绯荤粺缁存姢鍏抽敭鍙傛暟妯″紡 鎺ュ彛-------------
+// 閲囬泦鍣ㄦ坊鍔�();
+// 閲囬泦鍣ㄥ垹闄�();
+// 鏌ヨN涓噰闆嗗櫒();
+// 鏌ヨ鍏ㄩ儴閲囬泦鍣�();
+//
+// 鐢佃兘琛ㄦ坊鍔�();
+// 鐢佃兘琛ㄥ垹闄�();
+// 鐢佃兘琛ㄦ。妗堟煡璇�();
+//
+// 姘磋〃娣诲姞();
+// 姘磋〃鍒犻櫎();
+// 姘磋〃妗f鏌ヨ();
+
+// 鎿嶄綔鐘舵�佹煡璇�();
+// 鍙栨秷鎿嶄綔();
+
+
+// ------------ 鎺ュ叆鏂圭淮鎶ゅ叧閿弬鏁版ā寮� 鏁版嵁鎺ュ彛-------------
+// 鎶勭數琛ㄦ暟鎹�();
+// 璁剧疆鐢佃〃鍙傛暟();
+// 鐢佃〃鎷夐椄();
+// 鐢佃〃鍚堥椄();
+// 鐢佃〃娓呴浂_鍚屾妯″紡();
+// 鐢佃〃娓呴浂_闈炲悓姝ユā寮�();
+// 鐢佃〃寮�鎴穇鍚屾妯″紡();
+// 鐢佃〃寮�鎴穇闈炲悓姝ユā寮�();
+// 鐢佃〃鍏呭�糭鍚屾妯″紡();
+// 鐢佃〃鍏呭�糭闈炲悓姝ユā寮�();
+
+// 鎶勬按琛ㄦ暟鎹�();
+// 姘磋〃鍏抽榾();
+// 姘磋〃寮�闃�();
+// 姘磋〃娓呴浂();
+// Mbus姘磋〃鍏呭�糭鍚屾妯″紡();
+// Mbus姘磋〃鍏呭�糭闈炲悓姝ユā寮�();
+// Lora姘磋〃鍏呭�糭鍚屾妯″紡();
+// Lora姘磋〃鍏呭�糭闈炲悓姝ユā寮�();
+
+ Lora鏅�氶浠樿垂姘磋〃璁剧疆姘翠环();
+ Lora闃舵棰勪粯璐规按琛ㄨ缃按浠�();
+
+// 绗竴濂楁暟鎹帴鍙�--------------
+// 鏌ヨ鍘嗗彶鏁版嵁鎺ュ彛();
+// 鏌ヨ璁惧鍒楄〃鍜屽綋鍓嶇姸鎬�();
+// 鏌ヨ閲囬泦鍣ㄥ垪琛ㄥ拰褰撳墠鐘舵��();
+// 鏌ヨ浠锋牸妗f();
+// 鏌ヨ鐢ㄦ埛妗f();
+// 鏌ヨ鍙傛暟妗f();
+// 鏌ヨ鐢佃〃褰撳墠鐘舵�佹暟鎹�();
+// 鏌ヨ姘磋〃褰撳墠鐘舵�佹暟鎹�();
+
+ }
+
+ /**
+ * 鏌ヨ璁惧鍒楄〃鍜屽綋鍓嶇姸鎬�
+ */
+ private static void queryDeviceList() {
+ // 鏌ヨ璁惧鍒楄〃鍜屽綋鍓嶇姸鎬�
+ String url = api_url+"/Api/Meter"; // "https://iot.tqdianbiao.com/Api/Meter"
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+
+ url = url + "?" + urlParams;
+
+ String resp = HttpClientGet(url);
+
+ simpleRequestPrint(url, resp);
+ }
+
+ /**
+ * 鏌ヨ閲囬泦鍣ㄥ垪琛ㄥ拰褰撳墠鐘舵��
+ */
+ private static void queryCollectorList() {
+ // 鏌ヨ閲囬泦鍣ㄥ垪琛ㄥ拰褰撳墠鐘舵��
+ String url = api_url+"/Api/Collector";
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+
+ url = url + "?" + urlParams;
+
+ String resp = HttpClientGet(url);
+
+ simpleRequestPrint(url, resp);
+ }
+
+ /**
+ * 鏌ヨ浠锋牸妗f
+ */
+ private static void queryPrice() {
+ // 鏌ヨ浠锋牸妗f
+ String url = api_url+"/Api/Price";
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+ url = url + "?" + urlParams;
+ String resp = HttpClientGet(url);
+ simpleRequestPrint(url, resp);
+ }
+
+ /**
+ * 鏌ヨ鐢ㄦ埛妗f
+ */
+ private static void queryUser() {
+ // 鏌ヨ鐢ㄦ埛妗f
+ String url = api_url+"/Api/User";
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+ url = url + "?" + urlParams;
+ String resp = HttpClientGet(url);
+ simpleRequestPrint(url, resp);
+ }
+
+ /**
+ * 鏌ヨ鍙傛暟妗f
+ */
+ private static void queryParam() {
+ // 鏌ヨ鍙傛暟妗f
+ String url = api_url+"/Api/Param";
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+
+ url = url + "?" + urlParams;
+
+ String resp = HttpClientGet(url);
+
+ simpleRequestPrint(url, resp);
+ }
+
+ /**
+ * 鏌ヨ鐢佃〃褰撳墠鐘舵�佹暟鎹�
+ */
+ private static void queryEleMeterState() {
+ // 鏌ヨ鐢佃〃褰撳墠鐘舵�佹暟鎹�
+ String url = api_url+"/Api/EleMeterState";
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+
+ url = url + "?" + urlParams;
+
+ String resp = HttpClientGet(url);
+
+ simpleRequestPrint(url, resp);
+ }
+
+ /**
+ * 鏌ヨ姘磋〃褰撳墠鐘舵�佹暟鎹�
+ */
+ private static void queryWaterMeterState() {
+ // 鏌ヨ姘磋〃褰撳墠鐘舵�佹暟鎹�
+ String url = api_url+"/Api/WaterMeterState";
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+ url = url + "?" + urlParams;
+ String resp = HttpClientGet(url);
+ simpleRequestPrint(url, resp);
+ }
+
+ /**
+ * 鏌ヨ鍘嗗彶鏁版嵁鎺ュ彛
+ */
+ private static void queryDataRequest() {
+ // 鏌ヨ鍘嗗彶鏁版嵁鎺ュ彛
+ String url = api_url+"/Api/DataRequest";
+ Map<String, Object> params = new HashMap<>();
+ params.put("auth", auth_code);
+ params.put("type", "json");
+ params.put("functionids", "3,4,5");
+ params.put("start_time", "2020-01-01 00:00:00");
+ params.put("end_time", "2020-06-01 00:00:00");
+ params.put("offset", 0);
+ params.put("limit", 100);
+
+ // Map<String, Object> 杞垚url鍙傛暟
+ String urlParams = getUrlParams(params);
+ url = url + "?" + urlParams;
+ String resp = HttpClientGet(url);
+ simpleRequestPrint(url, resp);
+
+ }
+
+ private static void simpleRequestPrint(String url, String resp) {
+ String name=Thread.currentThread().getStackTrace()[2].getMethodName();
+ System.out.println(name);
+
+ System.out.println("璇锋眰鍙傛暟锛�" + url);
+ System.out.println("杩斿洖鏁版嵁锛�" + resp);
+ }
+
+ private static String HttpClientGet(String url) {
+ try {
+ CloseableHttpClient client = HttpClients.createDefault();
+ HttpGet httpGet = new HttpGet(url);
+ CloseableHttpResponse Response = client.execute(httpGet);
+ HttpEntity entity = Response.getEntity();
+ String resp = EntityUtils.toString(entity, "UTF-8");
+ Response.close();
+ return resp;
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ return "";
+ }
+ }
+
+ private static String getUrlParams(Map<String, Object> map) {
+ if (map == null || map.size() == 0) {
+ return "";
+ }
+ List<String> list = new ArrayList<>();
+ map.forEach((key, value)->{
+ try {
+ list.add(key + "=" + URLEncoder.encode(value.toString(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ });
+ return String.join("&", list);
+ }
+
+ /**
+ * 鐢佃〃寮�鎴穇鍚屾妯″紡
+ */
+ private static void openAcount() {
+ String url = api2_url+"/Api_v2/ele_security/open_acount";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄥ紑鎴凤紝鍚屾妯″紡锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+ }
+
+ /**
+ * 鐢佃〃寮�鎴穇闈炲悓姝ユā寮�
+ */
+ private static void 鐢佃〃寮�鎴穇闈炲悓姝ユā寮�() {
+ String url = api2_url+"/Api_v2/ele_security/open_acount";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄥ紑鎴凤紝闈炲悓姝ユā寮忥級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+ params.put("account_id", "123456");
+ params.put("count", "1");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鐢佃〃鍏呭�糭鍚屾妯″紡() {
+ String url = api2_url+"/Api_v2/ele_security/recharge";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄥ厖鍊硷紝鍚屾妯″紡锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鐢佃〃鍏呭�糭闈炲悓姝ユā寮�() {
+ String url = api2_url+"/Api_v2/ele_security/recharge";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄥ厖鍊硷紝闈炲悓姝ユā寮忥級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+ params.put("account_id", "123456");
+ params.put("count", "2");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+ }
+
+ private static void Lora鏅�氶浠樿垂姘磋〃璁剧疆姘翠环() {
+ String url = api2_url+"/Api_v2/water_write/price";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛圠ora鏅�氶浠樿垂姘磋〃璁剧疆姘翠环锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("p1", "1");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "10000000031");
+ item.put("address", "20040900000003");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void Lora闃舵棰勪粯璐规按琛ㄨ缃按浠�() {
+ String url = api2_url+"/Api_v2/water_write/price";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛圠ora闃舵棰勪粯璐规按琛ㄨ缃按浠凤級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("p1", "1");
+ params.put("p2", "2");
+ params.put("p3", "3");
+ params.put("p4", "40");
+ params.put("p5", "50");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "10000000031");
+ item.put("address", "20040900000003");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void Lora姘磋〃鍏呭�糭鍚屾妯″紡() {
+ String url = api2_url+"/Api_v2/water_security/recharge";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛圠ora姘磋〃鍏呭�硷紝鍚屾妯″紡锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "10000000031");
+ item.put("address", "20040900000003");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void Lora姘磋〃鍏呭�糭闈炲悓姝ユā寮�() {
+ String url = api2_url+"/Api_v2/water_security/recharge";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛圠ora姘磋〃鍏呭�硷紝闈炲悓姝ユā寮忥級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+ params.put("count", "2");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "10000000031");
+ item.put("address", "20040900000003");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void Mbus姘磋〃鍏呭�糭鍚屾妯″紡() {
+ String url = api2_url+"/Api_v2/water_security/recharge";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛圡bus姘磋〃鍏呭�硷紝鍚屾妯″紡锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "88020206100");
+ item.put("address", "C1E81000007859");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void Mbus姘磋〃鍏呭�糭闈炲悓姝ユā寮�() {
+ String url = api2_url+"/Api_v2/water_security/recharge";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛圡bus姘磋〃鍏呭�硷紝闈炲悓姝ユā寮忥級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("money", "100");
+ params.put("price", "5");
+ params.put("count", "2");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "88020206100");
+ item.put("address", "C1E81000007859");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 姘磋〃娓呴浂() {
+ String url = api2_url+"/Api_v2/water_security/reset";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟按琛ㄦ竻闆讹級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "88020206100");
+ item.put("address", "C1E81000007859");
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鐢佃〃娓呴浂_闈炲悓姝ユā寮�() {
+ String url = api2_url+"/Api_v2/ele_security/reset";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄦ竻闆讹紝闈炲悓姝ユā寮忥級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("account_id", "123456");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("params", params);
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鐢佃〃娓呴浂_鍚屾妯″紡() {
+ String url = api2_url+"/Api_v2/ele_security/reset";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄦ竻闆讹紝鍚屾妯″紡锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鐢佃〃鎷夐椄() {
+ String url = api2_url+"/Api_v2/ele_control";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄦ媺闂革級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("type", 10);
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鐢佃〃鍚堥椄() {
+ String url = api2_url+"/Api_v2/ele_control";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堢數琛ㄥ悎闂革級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("type", 11);
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 姘磋〃鍏抽榾() {
+ String url = api2_url+"/Api_v2/water_control";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟按琛ㄥ叧闃�锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "88020206100");
+ item.put("address", "C1E81000007859");
+ item.put("type", 53);
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 姘磋〃寮�闃�() {
+ String url = api2_url+"/Api_v2/water_control";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟按琛ㄥ紑闃�锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "88020206100");
+ item.put("address", "C1E81000007859");
+ item.put("type", 43);
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 璁剧疆鐢佃〃鍙傛暟() {
+ String url = api2_url+"/Api_v2/ele_write";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堜竴绾ф姤璀﹀�硷級
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
+ params.put("p1", "300");
+
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("type", 24);
+ item.put("params", params);
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鎶勭數琛ㄦ暟鎹�() {
+ String url = api2_url+"/Api_v2/ele_read";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟妱鐢佃〃鏁版嵁锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ item.put("type", 3);
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static void 鎶勬按琛ㄦ暟鎹�() {
+ String url = api2_url+"/Api_v2/water_read";
+
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟妱姘磋〃鏁版嵁锛�
+ List<Map<String, Object>> req = new ArrayList<>();
+ Map<String, Object> item = new HashMap<>();
+ item.put("opr_id", generateOperateId());
+ item.put("time_out", 0);
+ item.put("must_online", true);
+ item.put("retry_times", 1);
+ item.put("cid", "88020206100");
+ item.put("address", "C1E81000007859");
+ item.put("type", 42);
+ req.add(item);
+
+ String request_content = JSON.toJSONString(req);
+ testApiAsync(url, request_content);
+
+ }
+
+ private static String generateOperateId() {
+ return UUID.randomUUID().toString().replaceAll("-", "");
+ }
+
+ private static void 鐢佃兘琛ㄦ。妗堟煡璇�()
+ {
+ String url = api2_url+"/Api_v2/ele_meter/query";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟煡璇㈡寚瀹氱殑閲囬泦鍣ㄤ笅鐨勭數鑳借〃淇℃伅锛�
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "12345678901"); // 鏌ヨ鍏朵粬鍖哄煙鐨勯噰闆嗗櫒涓嬬殑鐢佃兘琛�(鏈壘鍒伴噰闆嗗櫒)
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "29020618114"); // 鏌ヨ涓嶅瓨鍦ㄧ殑閲囬泦鍣ㄤ笅鐨勭數鑳借〃(鏈壘鍒伴噰闆嗗櫒)
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "19020618114"); // 鏌ヨ鏈尯鍩熷凡缁忔坊鍔犵殑閲囬泦鍣ㄤ笅鐨勭數鑳借〃(寰楀埌姝g‘缁撴灉锛�"address":["000066660942"])
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "1902061811411"); // 鏌ヨ涓嶅悎娉曠殑閲囬泦鍣ㄤ笅鐨勭數鑳借〃(鍙敮鎸�11/12浣嶉噰闆嗗櫒鍙�)
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+
+ private static void 鐢佃兘琛ㄥ垹闄�()
+ {
+ String url = api2_url+"/Api_v2/ele_meter/delete";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(鍒犻櫎鎸囧畾鐨勭數鑳借〃淇℃伅)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "19020618114");
+ item.put("address", "0000666609"); // 涓嶅悎娉曠殑琛ㄥ彿
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "1902061811"); // 涓嶅悎娉曠殑閲囬泦鍣ㄥ彿
+ item.put("address", "000066660942");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "12345678901"); // 闈炴湰鍖哄煙閲囬泦鍣ㄥ彿
+ item.put("address", "000066660942");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "11335577990");
+ item.put("address", "000066660942"); // 涓嶅瓨鍦ㄧ殑閲囬泦鍣ㄥ彿
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+ private static void 鐢佃兘琛ㄦ坊鍔�()
+ {
+ String url = api2_url+"/Api_v2/ele_meter/add";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(娣诲姞鎸囧畾鐨勭數鑳借〃淇℃伅)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "19020618114");
+ item.put("address", "0000666609"); // 涓嶅悎娉曠殑琛ㄥ彿
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "1902061811"); // 涓嶅悎娉曠殑閲囬泦鍣ㄥ彿
+ item.put("address", "000066660942");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "12345678901"); // 闈炴湰鍖哄煙閲囬泦鍣ㄥ彿
+ item.put("address", "000066660942");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "11335577990");
+ item.put("address", "000066660942"); // 涓嶅瓨鍦ㄧ殑閲囬泦鍣ㄥ彿
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+ private static void 姘磋〃妗f鏌ヨ()
+ {
+ String url = api2_url+"/Api_v2/water_meter/query";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟煡璇㈡寚瀹氱殑閲囬泦鍣ㄤ笅鐨勬按琛ㄤ俊鎭級
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "19020618114");
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+
+ private static void 姘磋〃鍒犻櫎()
+ {
+ String url = api2_url+"/Api_v2/water_meter/delete";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(鍒犻櫎鎸囧畾鐨勬按琛ㄤ俊鎭�)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+ private static void 姘磋〃娣诲姞()
+ {
+ String url = api2_url+"/Api_v2/water_meter/add";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(娣诲姞鎸囧畾鐨勬按琛ㄤ俊鎭�)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "19020618114");
+ item.put("address", "000066660942");
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+ private static void 鎿嶄綔鐘舵�佹煡璇�()
+ {
+ String url = api2_url+"/Api_v2/request/status";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(鎿嶄綔鐘舵�佹煡璇�)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("opr_id", "123456");
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+ private static void 鍙栨秷鎿嶄綔()
+ {
+ String url = api2_url+"/Api_v2/request/cancel";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(鍙栨秷鎿嶄綔)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("opr_id", "123456");
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+
+ private static void 閲囬泦鍣ㄥ垹闄�()
+ {
+ String url = api2_url+"/Api_v2/collector/delete";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(鍒犻櫎鎸囧畾鐨勯噰闆嗗櫒淇℃伅)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "12345678901"); // 鍒犻櫎鍏朵粬鍖哄煙鐨勯噰闆嗗櫒
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "29020618114"); // 鍒犻櫎涓嶅瓨鍦ㄧ殑閲囬泦鍣�
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "19020618114"); // 鍒犻櫎鏈尯鍩熷凡缁忔坊鍔犵殑閲囬泦鍣�
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "1902061811411"); // 鍒犻櫎涓嶅悎娉曠殑閲囬泦鍣�
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+ private static void 閲囬泦鍣ㄦ坊鍔�()
+ {
+ String url = api2_url+"/Api_v2/collector/add";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(娣诲姞鎸囧畾鐨勯噰闆嗗櫒淇℃伅)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "12345678901"); // 閲囬泦鍣ㄥ彿琚叾浠栧尯鍩熺敤鎴锋坊鍔犺繃鐨�
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "19020618114"); // 澶氭璋冪敤鍧囦細杩斿洖娣诲姞鎴愬姛
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+ private static void 鏌ヨ鍏ㄩ儴閲囬泦鍣�()
+ {
+ String url = api2_url+"/Api_v2/collector/query";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁锛堟煡璇㈡墍鏈夐噰闆嗗櫒淇℃伅锛�
+ String request_content = "[]";
+
+ testApi(url, request_content);
+ }
+ private static void 鏌ヨN涓噰闆嗗櫒()
+ {
+ String url = api2_url+"/Api_v2/collector/query";
+ // 璇锋眰鍐呭锛岃皟鐢ㄦ帴鍙f墍闇�瑕佺殑鏁版嵁(鏌ヨ鎸囧畾鐨勯噰闆嗗櫒淇℃伅)
+ List<Map<String, String>> req = new ArrayList<>();
+ Map<String, String> item = new HashMap<>();
+ item.put("cid", "100000000101");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "10000000101");
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "1000000101"); // 閲囬泦鍣ㄥ彿涓嶇鍚堣鑼�
+ req.add(item);
+ item = new HashMap<>();
+ item.put("cid", "50000000101"); // 涓嶅瓨鍦ㄧ殑閲囬泦鍣�
+ req.add(item);
+ String request_content = JSON.toJSONString(req);
+
+ testApi(url, request_content);
+ }
+
+ private static void testApi(String url, String request_content)
+ {
+ String name=Thread.currentThread().getStackTrace()[2].getMethodName();
+ System.out.println(name);
+
+ String response = request(url, request_content);
+ printResponse(response);
+ }
+
+ private static void testApiAsync(String url, String request_content)
+ {
+ String name=Thread.currentThread().getStackTrace()[2].getMethodName();
+ System.out.println(name);
+
+ String response = requestAsync(url, request_content);
+ printResponse(response);
+ }
+
+ // 鎵撳嵃鍝嶅簲鍐呭
+ private static void printResponse(String response) {
+ JSONObject jsonObject = JSON.parseObject(response);
+
+ String status = jsonObject.getString("status");
+ if(!"SUCCESS".equals(status)) {
+ System.out.println(jsonObject.getString("error_msg"));
+ } else {
+ String response_content = jsonObject.getString("response_content");
+ System.out.println("response_content: " + response_content);
+ JSONArray contentArray = JSON.parseArray(response_content);
+ int index = 1;
+ System.out.println("杩斿洖缁撴灉锛�");
+ for(int i = 0; i < contentArray.size(); ++i) {
+ System.out.println("[" + index++ + "]");
+ JSONObject contentObject = contentArray.getJSONObject(i);
+ Set<String> keySet = contentObject.keySet();
+ for(String key: keySet) {
+ System.out.println(key + ": " + contentObject.get(key));
+ }
+
+ }
+ }
+ }
+
+ // 璇锋眰鎺ュ彛
+ private static String request(String url, String request_content){
+ // 鏃堕棿鎴�
+ String timestamp = String.valueOf(new Date().getTime()/1000);
+
+ // 鐢ㄤ簬绛惧悕鐨勫唴瀹�
+ Map<String, String> data = new HashMap<>();
+ data.put("timestamp", timestamp);
+ data.put("auth_code", auth_code);
+ data.put("request_content", request_content);
+
+ // 鑾峰彇绛惧悕
+ String sign = getSign(data);
+
+ data.put("sign", sign);
+
+ try {
+ return sendHttpRequest(url, data);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ // 璇锋眰鎺ュ彛
+ private static String requestAsync(String url, String request_content){
+ // 鏃堕棿鎴�
+ String timestamp = String.valueOf(new Date().getTime()/1000);
+
+ // 鐢ㄤ簬绛惧悕鐨勫唴瀹�
+ Map<String, String> data = new HashMap<>();
+ data.put("timestamp", timestamp);
+ data.put("auth_code", auth_code);
+ data.put("request_content", request_content);
+ data.put("notify_url", notify_url);
+
+ // 鑾峰彇绛惧悕
+ String sign = getSign(data);
+
+ data.put("sign", sign);
+
+ try {
+ return sendHttpRequest(url, data);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ // 鐢熸垚绛惧悕瀛楃涓�
+ private static String getSign(Map<String, String> data)
+ {
+ // 鑾峰彇鍏抽敭瀛楀垪琛�
+ List<String> keys = new ArrayList<>(data.keySet());
+ // 鍏抽敭瀛楀垪琛ㄦ帓搴�
+ keys.sort(Comparator.naturalOrder());
+ StringBuilder sb = new StringBuilder();
+ for (String key : keys)
+ {
+ // 鍙栧悇涓瓧娈靛唴瀹规嫾鎺ュ瓧绗︿覆
+ sb.append(data.get(key));
+ }
+ // 鍔犱笂鍙屾柟绾﹀畾闅忔満瀛楃涓�
+ String txt = sb.toString() + nonce;
+
+ // 璁$畻鍝堝笇鍊�
+ return getMD5(txt);
+ }
+
+ // md5鍔犲瘑
+ private static String getMD5(String password) {
+ MessageDigest md5 = null;
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ byte[] byteArray = password.getBytes(StandardCharsets.UTF_8);
+
+ byte[] md5Bytes = md5.digest(byteArray);
+ StringBuilder hexValue = new StringBuilder();
+ for (byte md5Byte : md5Bytes) {
+ int val = ((int) md5Byte) & 0xff;
+ if (val < 16) {
+ hexValue.append("0");
+ }
+
+ hexValue.append(Integer.toHexString(val));
+ }
+ return hexValue.toString();
+ }
+
+ // 鍙戦�乭ttp璇锋眰
+ private static String sendHttpRequest(String url, Map<String, String> bodyMap) throws Exception {
+ System.out.println("璇锋眰鍦板潃锛�" + url);
+ System.out.println("鍙戦�佸弬鏁帮細" + bodyMap.toString());
+ HttpClient client = HttpClientBuilder.create().build();
+ HttpPost postRequest = new HttpPost(url);
+
+ List<NameValuePair> nvps = new ArrayList<>();
+
+ for(String key : bodyMap.keySet()) {
+ nvps.add(new BasicNameValuePair(key,bodyMap.get(key)));
+ }
+ postRequest.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
+
+
+ int retry = 3;
+ HttpResponse execute = null;
+ while(retry-- > 0) {
+ try {
+ execute = client.execute(postRequest);
+ break;
+ } catch (Exception e) {
+ Thread.sleep(5000);
+ }
+ }
+ if(execute == null) {
+ throw new Exception("鎺ュ彛璇锋眰澶辫触");
+ }
+ String resp = EntityUtils.toString(execute.getEntity(), "UTF-8");
+ System.out.println("鎺ュ彛杩斿洖锛�" + resp);
+ return resp;
+ }
+
+}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
index 9dcdaa7..bcfc7f8 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
@@ -114,7 +114,7 @@
@ExcelColumn(name="绔彛")
private String port;
- @ApiModelProperty(value = "鍑哄叆绫诲瀷")
+ @ApiModelProperty(value = "鍑哄叆绫诲瀷 浠樿垂绫诲瀷锛�0棰勪粯璐癸級 ")
@ExcelColumn(name="鍑哄叆绫诲瀷")
private String inoutType;
diff --git a/server/visits/dmvisit_service/src/main/resources/application-dev.yml b/server/visits/dmvisit_service/src/main/resources/application-dev.yml
index 57baaf0..06a764e 100644
--- a/server/visits/dmvisit_service/src/main/resources/application-dev.yml
+++ b/server/visits/dmvisit_service/src/main/resources/application-dev.yml
@@ -33,7 +33,6 @@
visitor-data-origin: 0 #璁垮鏁版嵁 0鑷缓 2浠ユ捣搴蜂负涓� 1鍗庢櫉ERP绯荤粺
need-deal-img: true #鏄惁闇�瑕佸鐞嗗浘鐗囨暟鎹�
-
########################鍘嬬缉鍖呮枃浠朵綅缃� ########################
zip_file_path: d://
# Swagger閰嶇疆
--
Gitblit v1.9.3