1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package com.gzlh.bus;
- import cn.hutool.core.date.DateUtil;
- 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.cache.PassCacheManager;
- import com.gzlh.config.SystemObject;
- import com.gzlh.config.properties.ExternalProperties;
- import com.gzlh.device.led.utils.LedOptions;
- import com.gzlh.entity.CarCaptureBO;
- import com.gzlh.entity.ReqBO;
- import com.gzlh.utils.DeviceCache;
- import lombok.extern.slf4j.Slf4j;
- @Slf4j
- public class SubmitCarToLimitServerThread implements Runnable {
- @Override
- public void run() {
- ExternalProperties externalProperties = SpringUtil.getBean(ExternalProperties.class);
- ReqBO reqBO = EventDataManager.getCacheData();
- if (reqBO == null || StrUtil.isEmpty(reqBO.getCarNo())) {
- log.error("Request empty");
- return;
- }
- CarCaptureBO carCaptureBO = new CarCaptureBO();
- carCaptureBO.setChannelCode(reqBO.getChannelCode()).setCarNo(reqBO.getCarNo())
- .setCarImage(reqBO.getCarImg())
- .setIdentifyTime(DateUtil.now());
- String body = JSONUtil.toJsonStr(carCaptureBO);
- log.info("submitCarToLimitServerThread: {}", body);
- String resp = HttpUtil.createPost(externalProperties.getSubCarValidatePath())
- .body(body).execute().body();
- log.info("submitCarToLimitServerThread resp: {},{}",externalProperties.getSubCarValidatePath() ,resp);
- JSONObject result = JSONUtil.parseObj(resp);
- Integer code = result.getInt("code");
- LedOptions options = new LedOptions().setLine("03").setShowType("00");
- if (code != 200) {
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
- .sendMsg(result.getStr("msg"), options);
- PassCacheManager.carPass = false;
- DeviceCache.setInterrupt(true);
- } else {
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
- .sendMsg("请进行人脸核验", options);
- PassCacheManager.carPass = true;
- }
- }
- }
|