|
@@ -8,6 +8,7 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.log.StaticLog;
|
|
|
import com.pj.api.open.ResultJson;
|
|
|
import com.pj.api.open.bo.CheckCarNumberBO;
|
|
|
import com.pj.api.open.bo.InRecordBO;
|
|
@@ -92,6 +93,10 @@ public class OpenService {
|
|
|
|
|
|
private void handlerIn(String carNo, String channel, String image) {
|
|
|
carNo = carNo.toUpperCase();
|
|
|
+ if (StrUtil.isNotEmpty(image)) {
|
|
|
+ StaticLog.error("缓存入场图片:{}",carNo);
|
|
|
+ IMAGE_CACHE.put(carNo, image);
|
|
|
+ }
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
Date now = new Date();
|
|
|
TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
@@ -105,13 +110,13 @@ public class OpenService {
|
|
|
.setInChannel(channel).setRealInTime(now).setBasePartMoney(new BigDecimal("0")).setTimeUpdate(now)
|
|
|
.setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
tbBusinessCarService.save(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), 1);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo,1);
|
|
|
return;
|
|
|
}
|
|
|
tbBusinessCar.setRealInTime(now).setInChannel(channel).setTimeUpdate(now)
|
|
|
.setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
|
|
|
tbBusinessCarService.saveOrUpdate(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), 1);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo,1);
|
|
|
if (!CAR_LIST.contains(carNo)) {
|
|
|
TbBusiness tbBusiness = tbBusinessService.getById(tbBusinessCar.getBusinessId());
|
|
|
if (tbBusiness != null) {
|
|
@@ -122,13 +127,21 @@ public class OpenService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void CoverBase64ToUrl(String base64image, String carId, int inOrOut) {
|
|
|
+ private void CoverBase64ToUrl(String base64image, String carId,String carNo, int inOrOut) {
|
|
|
+ String cacheBase64 = IMAGE_CACHE.get(carNo);
|
|
|
+ if (StrUtil.isEmpty(base64image)) {
|
|
|
+ base64image = cacheBase64;
|
|
|
+ }
|
|
|
if (StrUtil.isEmpty(base64image)) {
|
|
|
+ log.error("无出场图片:{}", carNo);
|
|
|
return;
|
|
|
}
|
|
|
taskService.addTask(new CoverBase64ToImageTask("=======" + carId + "", 2000, carId, base64image, inOrOut));
|
|
|
-
|
|
|
+ IMAGE_CACHE.remove(carNo);
|
|
|
}
|
|
|
+
|
|
|
+ final TimedCache<String, String> IMAGE_CACHE = CacheUtil.newTimedCache(30 * 60 * 1000);
|
|
|
+
|
|
|
private ResultJson handlerOut(String carNo, String channel, String image) {
|
|
|
carNo = carNo.toUpperCase();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
@@ -136,6 +149,10 @@ public class OpenService {
|
|
|
log.error("请求返回【未查询到入场记录】:{}", carNo);
|
|
|
return ResultJson.error("未查询到入场记录");
|
|
|
}
|
|
|
+ if (StrUtil.isNotEmpty(image)) {
|
|
|
+ StaticLog.error("缓存离场图片,{}",carNo);
|
|
|
+ IMAGE_CACHE.put(carNo, image);
|
|
|
+ }
|
|
|
Date now = new Date();
|
|
|
Integer businessType = tbBusinessCar.getBusinessType();
|
|
|
//判断是否蓝色车牌===免停车费
|
|
@@ -146,7 +163,7 @@ public class OpenService {
|
|
|
if (colorList.contains(color)) {
|
|
|
tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(),carNo, 2);
|
|
|
RedisUtil.del(channel);
|
|
|
log.error("请求返回【放行】:{}", carNo);
|
|
|
return ResultJson.success();
|
|
@@ -156,7 +173,7 @@ public class OpenService {
|
|
|
if (checkFree(carNo, 2, now)) {
|
|
|
tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo,2);
|
|
|
RedisUtil.del(channel);
|
|
|
log.error("请求返回【放行】:{}", carNo);
|
|
|
return ResultJson.success();
|
|
@@ -186,7 +203,7 @@ public class OpenService {
|
|
|
if (TbBusiness.BusinessType.NO_BUSINESS.getCode().equals(businessType)) {
|
|
|
tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(),carNo, 2);
|
|
|
RedisUtil.del(channel);
|
|
|
log.error("请求返回【放行】:{}", carNo);
|
|
|
return ResultJson.success();
|
|
@@ -209,7 +226,7 @@ public class OpenService {
|
|
|
}
|
|
|
tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo,2);
|
|
|
RedisUtil.del(channel);
|
|
|
return ResultJson.success();
|
|
|
}
|