diff --git a/ssjygl-xsx-common/pom.xml b/ssjygl-xsx-common/pom.xml
index 972d0af..56f7459 100644
--- a/ssjygl-xsx-common/pom.xml
+++ b/ssjygl-xsx-common/pom.xml
@@ -133,6 +133,12 @@
3.4.0
+
+ com.aliyun
+ aliyun-java-sdk-core
+ 4.5.3
+
+
\ No newline at end of file
diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/common/aliyun/sms/SendBatchSms.java b/ssjygl-xsx-common/src/main/java/com/cowr/common/aliyun/sms/SendBatchSms.java
new file mode 100644
index 0000000..427c05a
--- /dev/null
+++ b/ssjygl-xsx-common/src/main/java/com/cowr/common/aliyun/sms/SendBatchSms.java
@@ -0,0 +1,36 @@
+package com.cowr.common.aliyun.sms;
+
+import com.aliyuncs.CommonRequest;
+import com.aliyuncs.CommonResponse;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+
+public class SendBatchSms {
+ public static void main(String[] args) {
+ DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4GBjCx9Hjxg9LtaTLD43", "xsf8w9KUArVGiXIMcM94d0iIqL7q5O");
+ IAcsClient client = new DefaultAcsClient(profile);
+
+ CommonRequest request = new CommonRequest();
+ request.setSysMethod(MethodType.POST);
+ request.setSysDomain("dysmsapi.aliyuncs.com");
+ request.setSysVersion("2017-05-25");
+ request.setSysAction("SendBatchSms");
+ request.putQueryParameter("RegionId", "cn-hangzhou");
+ request.putQueryParameter("PhoneNumberJson", "[\"13627293906\"]");
+ request.putQueryParameter("SignNameJson", "[\"智慧砂石\"]");
+ request.putQueryParameter("TemplateCode", "SMS_66850327");
+ request.putQueryParameter("TemplateParamJson", "[{\"time\":\"test time\", \"code\":\"test code\"}]");
+ try {
+ CommonResponse response = client.getCommonResponse(request);
+ System.out.println(response.getData());
+ } catch (ServerException e) {
+ e.printStackTrace();
+ } catch (ClientException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LED.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LED.java
index 60b04be..fea30a7 100644
--- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LED.java
+++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LED.java
@@ -1,7 +1,9 @@
package com.cowr.local.ssjygl.devicectrl.device;
import com.jfinal.log.Log;
+import org.apache.poi.util.HexDump;
+import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
@@ -80,15 +82,15 @@ public class LED extends Device {
InputStream in = socket.getInputStream();
byte[] buf = new byte[in.available()];
in.read(buf);
-// BufferedInputStream bis = new BufferedInputStream(socket.getInputStream());
-// byte[] y = new byte[128];
-// int read = bis.read(y);
-// while (!(read > 0)) {
-// read = bis.read(y);
-// }
-// byte[] z = new byte[read];
-// System.arraycopy(y, 0, z, 0, read);
-// System.out.println(HexDump.toHex(z));
+ BufferedInputStream bis = new BufferedInputStream(socket.getInputStream());
+ byte[] y = new byte[128];
+ int read = bis.read(y);
+ while (!(read > 0)) {
+ read = bis.read(y);
+ }
+ byte[] z = new byte[read];
+ System.arraycopy(y, 0, z, 0, read);
+ System.out.println(HexDump.toHex(z));
socket.close();
} finally {
lock.unlock();
@@ -199,13 +201,9 @@ public class LED extends Device {
public static void main(String[] args) {
try {
- LED led = new LED("", "192.168.0.197", 5005);
+ LED led = new LED("", "192.168.30.201", 5005);
led.screen("12345678", "等待车辆", "%s\\n %s \\n%s");
- Thread.sleep(3000);
-
- led.screen("987654321", "等待车辆", "%s\\n %s \\n%s");
-
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LEDThread.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LEDThread.java
index b99793b..4ea6e39 100644
--- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LEDThread.java
+++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/LEDThread.java
@@ -9,6 +9,7 @@ import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.Charset;
+import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.locks.ReentrantLock;
@@ -59,8 +60,13 @@ public class LEDThread extends Device implements Runnable {
@Override
public void run() {
+ DateFormat df = new SimpleDateFormat("mm:ss");
+
+
while (this.running){
try {
+ setWeightInfo("鄂A7D1P1", df.format(new Date()));
+
screen();
Thread.sleep(1000);
@@ -136,6 +142,8 @@ public class LEDThread extends Device implements Runnable {
// socket.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
+
+ reconn();
} finally {
lock.unlock();
}
@@ -245,9 +253,34 @@ public class LEDThread extends Device implements Runnable {
socket = null;
}
+ public boolean reconn(){
+ try {
+ log.debug("销毁LED连接");
+ if (socket != null) {
+ socket.close();
+ }
+
+ socket = null;
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+
+ try {
+ socket = new Socket();
+ socket.setSoTimeout(1000);
+ socket.connect(new InetSocketAddress(getIp(), getPort()), 3000);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ } finally {
+ lock.unlock();
+ }
+
+ return isConnected();
+ }
+
public static void main(String[] args) {
try {
- LEDThread led = new LEDThread("", "192.168.1.16", 5005);
+ LEDThread led = new LEDThread("", "192.168.30.201", 5005);
Thread thread = new Thread(led);
thread.setDaemon(true);
thread.start();
@@ -255,11 +288,11 @@ public class LEDThread extends Device implements Runnable {
System.out.println("LED 启动");
- Thread.sleep(10000);
+ Thread.sleep(10000000);
led.running = false;
- Thread.sleep(10000);
+ Thread.sleep(100000);
} catch (Exception e) {
e.printStackTrace();
}