123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package com.gzlh.device.face.task;
- import cn.hutool.core.thread.ThreadUtil;
- import cn.hutool.core.util.StrUtil;
- import cn.hutool.extra.spring.SpringUtil;
- import cn.hutool.http.HttpUtil;
- import cn.hutool.json.JSONObject;
- import cn.hutool.json.JSONUtil;
- import com.gzlh.bus.EventBus;
- import com.gzlh.bus.EventDataManager;
- import com.gzlh.bus.SysConfig;
- import com.gzlh.cache.CacheManager;
- import com.gzlh.cache.PassCacheManager;
- import com.gzlh.config.ModuleEnum;
- import com.gzlh.config.SystemObject;
- import com.gzlh.config.dto.ChannelSetting;
- import com.gzlh.config.properties.ExternalProperties;
- import com.gzlh.device.led.utils.LedOptions;
- import com.gzlh.device.plc.event.PLCEvent;
- import com.gzlh.entity.ReqBO;
- import com.gzlh.utils.DeviceCache;
- import lombok.extern.slf4j.Slf4j;
- @Slf4j
- public class SubmitFaceToLimitServerThread implements Runnable {
- @Override
- public void run() {
- ReqBO reqBO = EventDataManager.getCacheData();
- int channelType = SysConfig.channelSetting.getChannelType();
- //非人行通道,需要有车牌
- if (channelType != 3) {
- if (reqBO == null || StrUtil.isEmpty(reqBO.getCarNo())) {
- return;
- }
- }
- ExternalProperties externalProperties = SpringUtil.getBean(ExternalProperties.class);
- String uploadFaceGateUrl = externalProperties.getFaceOpenGatePath();
- JSONObject params = new JSONObject();
- ReqBO.Face face = reqBO.getFace();
- boolean pass = face.isPass();
- params.set("employeeNo", face.getEmployeeNo())
- .set("ip", face.getIp())
- .set("time", face.getTime())
- .set("carNo", reqBO.getCarNo())
- .set("pass", pass)
- .set("channelCode", reqBO.getChannelCode());
- String resp = HttpUtil.createPost(uploadFaceGateUrl).body(params.toJSONString(0)).execute().body();
- log.info("上报开门事件:{},{},{}", uploadFaceGateUrl, params.toJSONString(0), resp);
- //非行人通道
- if (channelType != 3) {
- LedOptions options = new LedOptions().setLine("03").setShowType("00");
- if (pass) {
- //行政通道---直接抬杆
- if (channelType == 1) {
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
- .sendMsg("请通行", options);
- EventBus eventBus = SpringUtil.getBean(EventBus.class);
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.RAILING_RISE);
- PassCacheManager.carPass = null;
- PassCacheManager.customerPass = null;
- PassCacheManager.facePass = null;
- return;
- }
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
- .sendMsg("请等待核验", options);
- EventBus eventBus = SpringUtil.getBean(EventBus.class);
- int count = 0;
- String serverUrl = SysConfig.channelSetting.getTwinService();
- while (count < 15) {
- String response = HttpUtil.get(serverUrl);
- JSONObject result = JSONUtil.parseObj(response);
- Boolean re = result.getBool("data");
- if (re == null) {
- count++;
- ThreadUtil.sleep(1000);
- continue;
- }
- if (re) {
- PassCacheManager.carPass = null;
- PassCacheManager.customerPass = null;
- PassCacheManager.facePass = null;
- //抬杆
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.RAILING_RISE);
- } else {
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
- .sendMsg("核验失败,请退出通道", options);
- DeviceCache.setInterrupt(true);
- break;
- }
- }
- } else {
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
- .sendMsg("核验失败,请退出通道", options);
- DeviceCache.setInterrupt(true);
- }
- }
- }
- }
|