|
@@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -118,6 +119,9 @@ public class ReaderCardController {
|
|
|
|
|
|
// 判断是否读取成功
|
|
|
if (!json.getBoolean("Result")) {
|
|
|
+ // 重启客户端控件
|
|
|
+ restartControl();
|
|
|
+
|
|
|
String errMsg = json.getString("Error").split(",")[0];
|
|
|
return new ResponseMsg(ResponseMsg.ERROR_CODE, errMsg.substring(2, errMsg.length() - 1));
|
|
|
}
|
|
@@ -259,4 +263,44 @@ public class ReaderCardController {
|
|
|
|
|
|
return ckFlag;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重启电子口岸客户端控件
|
|
|
+ */
|
|
|
+ public static void restartControl() {
|
|
|
+ LOGGER.info("-------------------- 重启中国电子口岸客户端控件开始 --------------------");
|
|
|
+
|
|
|
+ try {
|
|
|
+ //-------------------- 关闭电子口岸客户端控件 --------------------
|
|
|
+ // 调用cmd命令,/c net必须要有
|
|
|
+ Process p = Runtime.getRuntime().exec("cmd.exe /c net stop Eport_Ikey_Service");
|
|
|
+ InputStream inputStream = p.getInputStream();
|
|
|
+ Scanner scanner = new Scanner(inputStream, "GBK");
|
|
|
+ scanner.useDelimiter("\\A");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 必须要循环
|
|
|
+ * 不然stop没有结束,马上执行start,就达不到效果了
|
|
|
+ */
|
|
|
+ while (scanner.hasNext()) {
|
|
|
+ scanner.next();
|
|
|
+ }
|
|
|
+ scanner.close();
|
|
|
+
|
|
|
+ //-------------------- 启动电子口岸客户端控件 --------------------
|
|
|
+ p = Runtime.getRuntime().exec("cmd.exe /c net start Eport_Ikey_Service");
|
|
|
+ inputStream = p.getInputStream();
|
|
|
+ scanner = new Scanner(inputStream, "GBK");
|
|
|
+ scanner.useDelimiter("\\A");
|
|
|
+ while (scanner.hasNext()) {
|
|
|
+ scanner.next();
|
|
|
+ }
|
|
|
+ scanner.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.info("---------- 重启中国电子口岸客户端控件异常 ----------");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ LOGGER.info("-------------------- 重启中国电子口岸客户端控件结束 --------------------");
|
|
|
+ }
|
|
|
}
|