SubmitCarToLimitServerThread.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.gzlh.bus;
  2. import cn.hutool.core.date.DateUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import cn.hutool.extra.spring.SpringUtil;
  5. import cn.hutool.http.HttpUtil;
  6. import cn.hutool.json.JSONObject;
  7. import cn.hutool.json.JSONUtil;
  8. import com.gzlh.cache.PassCacheManager;
  9. import com.gzlh.config.SystemObject;
  10. import com.gzlh.config.properties.ExternalProperties;
  11. import com.gzlh.device.led.utils.LedOptions;
  12. import com.gzlh.entity.CarCaptureBO;
  13. import com.gzlh.entity.ReqBO;
  14. import com.gzlh.utils.DeviceCache;
  15. import lombok.extern.slf4j.Slf4j;
  16. @Slf4j
  17. public class SubmitCarToLimitServerThread implements Runnable {
  18. @Override
  19. public void run() {
  20. ExternalProperties externalProperties = SpringUtil.getBean(ExternalProperties.class);
  21. ReqBO reqBO = EventDataManager.getCacheData();
  22. if (reqBO == null || StrUtil.isEmpty(reqBO.getCarNo())) {
  23. log.error("Request empty");
  24. return;
  25. }
  26. CarCaptureBO carCaptureBO = new CarCaptureBO();
  27. carCaptureBO.setChannelCode(reqBO.getChannelCode()).setCarNo(reqBO.getCarNo())
  28. .setCarImage(reqBO.getCarImg())
  29. .setIdentifyTime(DateUtil.now());
  30. String body = JSONUtil.toJsonStr(carCaptureBO);
  31. log.info("submitCarToLimitServerThread: {}", body);
  32. String resp = HttpUtil.createPost(externalProperties.getSubCarValidatePath())
  33. .body(body).execute().body();
  34. log.info("submitCarToLimitServerThread resp: {},{}",externalProperties.getSubCarValidatePath() ,resp);
  35. JSONObject result = JSONUtil.parseObj(resp);
  36. Integer code = result.getInt("code");
  37. LedOptions options = new LedOptions().setLine("03").setShowType("00");
  38. if (code != 200) {
  39. SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
  40. .sendMsg(result.getStr("msg"), options);
  41. PassCacheManager.carPass = false;
  42. DeviceCache.setInterrupt(true);
  43. } else {
  44. SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
  45. .sendMsg("请进行人脸核验", options);
  46. PassCacheManager.carPass = true;
  47. }
  48. }
  49. }