|
@@ -3,10 +3,15 @@ package com.pj.api.open.service;
|
|
|
import cn.hutool.cache.CacheUtil;
|
|
|
import cn.hutool.cache.impl.TimedCache;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.img.ImgUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.pj.api.open.ResultJson;
|
|
|
import com.pj.api.open.bo.CheckCarNumberBO;
|
|
|
import com.pj.constants.UserTypeEnum;
|
|
|
+import com.pj.current.config.SystemObject;
|
|
|
+import com.pj.current.task.TaskService;
|
|
|
import com.pj.project.tb_business.BusinessMessageManager;
|
|
|
import com.pj.project.tb_business.TbBusiness;
|
|
|
import com.pj.project.tb_business.TbBusinessService;
|
|
@@ -17,15 +22,20 @@ import com.pj.project.tb_business_item.TbBusinessItem;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItemService;
|
|
|
import com.pj.project.tb_car.TbCar;
|
|
|
import com.pj.project.tb_car.TbCarService;
|
|
|
+import com.pj.project4sp.uploadfile.UploadConfig;
|
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import sun.misc.BASE64Decoder;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.xml.crypto.Data;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -46,6 +56,9 @@ public class OpenService {
|
|
|
@Resource
|
|
|
private TbCarService tbCarService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TaskService taskService;
|
|
|
+
|
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
|
|
|
|
|
|
@@ -65,16 +78,18 @@ public class OpenService {
|
|
|
carNo = carNo.toUpperCase();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
Date now = new Date();
|
|
|
- checkFree(carNo, 1, now);
|
|
|
+ TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)) {
|
|
|
tbBusinessCar = new TbBusinessCar();
|
|
|
- tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(3D).setIsLock(0).setInImage(image)
|
|
|
+ tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(3D).setIsLock(0).setCarCompany(tbCar!=null?tbCar.getCustomerName():"临时")
|
|
|
.setInChannel(channel).setRealInTime(now).setBasePartMoney(new BigDecimal("0"));
|
|
|
tbBusinessCarService.save(tbBusinessCar);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), 1);
|
|
|
return;
|
|
|
}
|
|
|
- tbBusinessCar.setRealInTime(now).setInChannel(channel).setInImage(image);
|
|
|
+ tbBusinessCar.setRealInTime(now).setInChannel(channel).setCarCompany(tbCar!=null?tbCar.getCustomerName():"临时");
|
|
|
tbBusinessCarService.saveOrUpdate(tbBusinessCar);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), 1);
|
|
|
if (!CAR_LIST.contains(carNo)) {
|
|
|
TbBusiness tbBusiness = tbBusinessService.getById(tbBusinessCar.getBusinessId());
|
|
|
if (tbBusiness != null) {
|
|
@@ -85,6 +100,11 @@ public class OpenService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void CoverBase64ToUrl(String base64image, String carId, int inOrOut) {
|
|
|
+ taskService.addTask(new CoverBase64ToImageTask("=======" + carId + "", 2000, carId, base64image, inOrOut));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private ResultJson handlerOut(String carNo, String channel, String image) {
|
|
|
carNo = carNo.toUpperCase();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findNotOutCar(carNo);
|
|
@@ -93,26 +113,30 @@ public class OpenService {
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
if (checkFree(carNo, 2, now)) {
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutImage(image);
|
|
|
+ tbBusinessCar.setRealOutTime(now);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
if (tbBusinessCar.getIsLock() == 1) {
|
|
|
return ResultJson.error("车辆已锁定");
|
|
|
}
|
|
|
-
|
|
|
String businessId = tbBusinessCar.getBusinessId();
|
|
|
- BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now, StrUtil.isNotEmpty(businessId));
|
|
|
+ BigDecimal price =new BigDecimal("0");
|
|
|
+ if (CAR_LIST.contains(carNo.substring(0,1))){
|
|
|
+ price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now);
|
|
|
+ }
|
|
|
double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
|
|
|
if (dif > 0) {
|
|
|
- tbBusinessCar.setPay(0).setOutImage(image);
|
|
|
+ tbBusinessCar.setPay(0);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
RedisUtil.set(channel, carNo);
|
|
|
return ResultJson.error("请缴停车费" + dif + "元");
|
|
|
}
|
|
|
if (StrUtil.isEmpty(businessId)) {
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setOutImage(image);
|
|
|
+ tbBusinessCar.setRealOutTime(now).setOutChannel(channel);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
TbBusiness business = tbBusinessService.getById(businessId);
|
|
@@ -132,8 +156,9 @@ public class OpenService {
|
|
|
if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType()) && !business.getItemPrice().equals(itemPayPrice)) {
|
|
|
return ResultJson.error("请缴纳业务费用");
|
|
|
}
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setOutImage(image);
|
|
|
+ tbBusinessCar.setRealOutTime(now).setOutChannel(channel);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
|