|
@@ -4,18 +4,23 @@ import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
import com.gzlh.config.dto.SerialSetting;
|
|
import com.gzlh.config.dto.SerialSetting;
|
|
import com.gzlh.device.capture.factory.CaptureFactory;
|
|
import com.gzlh.device.capture.factory.CaptureFactory;
|
|
import com.gzlh.device.capture.properties.CapturePropertiesConfig;
|
|
import com.gzlh.device.capture.properties.CapturePropertiesConfig;
|
|
import com.gzlh.config.ModuleEnum;
|
|
import com.gzlh.config.ModuleEnum;
|
|
import com.gzlh.config.SystemObject;
|
|
import com.gzlh.config.SystemObject;
|
|
-import com.gzlh.config.dto.EventDTO;
|
|
|
|
|
|
+import com.gzlh.device.car.factory.CarFactory;
|
|
import com.gzlh.device.infrared.config.RedPropertiesConfig;
|
|
import com.gzlh.device.infrared.config.RedPropertiesConfig;
|
|
import com.gzlh.device.infrared.factory.RedFactory;
|
|
import com.gzlh.device.infrared.factory.RedFactory;
|
|
import com.gzlh.device.led.factory.LedFactory;
|
|
import com.gzlh.device.led.factory.LedFactory;
|
|
|
|
+import com.gzlh.device.plc.event.PLCEvent;
|
|
import com.gzlh.device.plc.handler.PLCHadnler;
|
|
import com.gzlh.device.plc.handler.PLCHadnler;
|
|
import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
|
|
import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
|
|
import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
|
|
import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
|
|
|
|
+import com.gzlh.utils.DeviceCache;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -38,6 +43,7 @@ public class EventThread implements Runnable{
|
|
LedFactory ledFactory= SystemObject.ledFactory;
|
|
LedFactory ledFactory= SystemObject.ledFactory;
|
|
RedFactory redFactory=SystemObject.redFactory;
|
|
RedFactory redFactory=SystemObject.redFactory;
|
|
WeighbridgeFactory weighbridgeFactory=SystemObject.weighbridgeFactory;
|
|
WeighbridgeFactory weighbridgeFactory=SystemObject.weighbridgeFactory;
|
|
|
|
+ CarFactory carFactory= SystemObject.carFactory;
|
|
WeighbridgePropertiesConfig weighbridgePropertiesConfig=SystemObject.weighbridgePropertiesConfig;
|
|
WeighbridgePropertiesConfig weighbridgePropertiesConfig=SystemObject.weighbridgePropertiesConfig;
|
|
RedPropertiesConfig redPropertiesConfig=SystemObject.redPropertiesConfig;
|
|
RedPropertiesConfig redPropertiesConfig=SystemObject.redPropertiesConfig;
|
|
PLCHadnler plcHadnler= SpringUtil.getBean(PLCHadnler.class);
|
|
PLCHadnler plcHadnler= SpringUtil.getBean(PLCHadnler.class);
|
|
@@ -66,7 +72,10 @@ public class EventThread implements Runnable{
|
|
}else if (StrUtil.equals(module, ModuleEnum.PLC_MODULE.getModuleEn())) {
|
|
}else if (StrUtil.equals(module, ModuleEnum.PLC_MODULE.getModuleEn())) {
|
|
//动作属于plc
|
|
//动作属于plc
|
|
plcHadnler.handlerAction(command);
|
|
plcHadnler.handlerAction(command);
|
|
- } else if (StrUtil.equals(module, ModuleEnum.CENTER_MODULE.getModuleEn())) {
|
|
|
|
|
|
+ }else if (StrUtil.equals(module, ModuleEnum.CAR_MODULE.getModuleEn())) {
|
|
|
|
+ //动作属于电子车牌
|
|
|
|
+ carFactory.handler(serialSetting.getCar().getBrand()).handlerAction(command);
|
|
|
|
+ } else if (StrUtil.equals(module, ModuleEnum.CENTER_MODULE.getModuleEn())) {
|
|
//动作属于中心总线
|
|
//动作属于中心总线
|
|
handlerAction(command);
|
|
handlerAction(command);
|
|
}
|
|
}
|
|
@@ -85,6 +94,8 @@ public class EventThread implements Runnable{
|
|
if (StrUtil.contains(action, CenterActionCommand.SLEEP_COMMAND)) {
|
|
if (StrUtil.contains(action, CenterActionCommand.SLEEP_COMMAND)) {
|
|
//休眠
|
|
//休眠
|
|
handlerSleep(action);
|
|
handlerSleep(action);
|
|
|
|
+ }else if (StrUtil.contains(action, CenterActionCommand.SUBMIT)){
|
|
|
|
+ handlerSubmit();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -100,6 +111,51 @@ public class EventThread implements Runnable{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 提交数据
|
|
|
|
+ *
|
|
|
|
+ * @param
|
|
|
|
+ */
|
|
|
|
+ private void handlerSubmit() {
|
|
|
|
+ String address = SystemObject.applicationConfig.getServerUrl();
|
|
|
|
+ String api="/open/submit";
|
|
|
|
+ HttpResponse response = request(address+api, JSONUtil.toJsonStr(EventDataManager.getCacheData()));
|
|
|
|
+ EventBus eventBus= SpringUtil.getBean(EventBus.class);
|
|
|
|
+ if (response!=null&&response.getStatus()==200){
|
|
|
|
+ eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn()+"."+ PLCEvent.RAILING_RISE);
|
|
|
|
+ }else {
|
|
|
|
+ eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn()+"."+ PLCEvent.CHECK_FAILED);
|
|
|
|
+ }
|
|
|
|
+// 重置记录的设备触发时间
|
|
|
|
+ DeviceCache.resetTimeMap();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public HttpResponse request(String url,String json) {
|
|
|
|
+
|
|
|
|
+ HttpResponse res = null;
|
|
|
|
+// url = "http://192.168.1.8:9191/open/submit";
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+ System.out.println(startTime);
|
|
|
|
+
|
|
|
|
+ String body = json;
|
|
|
|
+ try {
|
|
|
|
+// System.out.printf("请求地址:%s, 请求体:%s ", url,body);
|
|
|
|
+
|
|
|
|
+ res = HttpRequest.post(url)
|
|
|
|
+ .header("Content-Type", "application/json;character=utf-8;")
|
|
|
|
+ .body(body)
|
|
|
|
+ .execute();
|
|
|
|
+ String bodyResult = res.body();
|
|
|
|
+// System.out.printf("ReqStatus:%s,返回结果:{%s} ",res.getStatus(), bodyResult);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void run(){
|
|
public void run(){
|
|
handlerEvent(eventName);
|
|
handlerEvent(eventName);
|