|
@@ -6,9 +6,11 @@ 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.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.pj.api.open.ResultJson;
|
|
|
import com.pj.api.open.bo.CheckCarNumberBO;
|
|
|
+import com.pj.api.open.bo.InRecordBO;
|
|
|
import com.pj.constants.UserTypeEnum;
|
|
|
import com.pj.current.config.SystemObject;
|
|
|
import com.pj.current.task.TaskService;
|
|
@@ -22,6 +24,8 @@ 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.project.tb_car_no_color.TbCarNoColor;
|
|
|
+import com.pj.project.tb_car_no_color.TbCarNoColorService;
|
|
|
import com.pj.project4sp.uploadfile.UploadConfig;
|
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
@@ -37,6 +41,8 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -58,6 +64,8 @@ public class OpenService {
|
|
|
|
|
|
@Resource
|
|
|
TaskService taskService;
|
|
|
+ @Resource
|
|
|
+ TbCarNoColorService tbCarNoColorService;
|
|
|
|
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
|
|
|
@@ -79,15 +87,17 @@ public class OpenService {
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
Date now = new Date();
|
|
|
TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
- if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)) {
|
|
|
+ if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)||tbBusinessCar.getPay()==1) {
|
|
|
tbBusinessCar = new TbBusinessCar();
|
|
|
- tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(0D).setIsLock(0).setCarCompany(tbCar!=null?tbCar.getCustomerName():"临时")
|
|
|
- .setInChannel(channel).setRealInTime(now).setBasePartMoney(new BigDecimal("0"));
|
|
|
+ tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(0D).setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时")
|
|
|
+ .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);
|
|
|
return;
|
|
|
}
|
|
|
- tbBusinessCar.setRealInTime(now).setInChannel(channel).setCarCompany(tbCar!=null?tbCar.getCustomerName():"临时");
|
|
|
+ tbBusinessCar.setRealInTime(now).setInChannel(channel).setTimeUpdate(now)
|
|
|
+ .setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
|
|
|
tbBusinessCarService.saveOrUpdate(tbBusinessCar);
|
|
|
CoverBase64ToUrl(image, tbBusinessCar.getId(), 1);
|
|
|
if (!CAR_LIST.contains(carNo)) {
|
|
@@ -101,19 +111,34 @@ public class OpenService {
|
|
|
}
|
|
|
|
|
|
private void CoverBase64ToUrl(String base64image, String carId, int inOrOut) {
|
|
|
+ if (StrUtil.isEmpty(base64image)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
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);
|
|
|
+ TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
if (tbBusinessCar == null) {
|
|
|
return ResultJson.error("未查询到入场记录");
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
+ if (StrUtil.isNotEmpty(tbBusinessCar.getColor())) {
|
|
|
+ List<TbCarNoColor> freeList = tbCarNoColorService.getFreeColor();
|
|
|
+ List<String> colorList = freeList.stream().map(f -> f.getCarNoColor().substring(0, 1)).collect(Collectors.toList());
|
|
|
+ String color = tbBusinessCar.getColor().substring(0, 1);
|
|
|
+ if (colorList.contains(color)) {
|
|
|
+ tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
|
|
|
+ tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+ CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
+ return ResultJson.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (checkFree(carNo, 2, now)) {
|
|
|
- tbBusinessCar.setRealOutTime(now);
|
|
|
+ tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
return ResultJson.success();
|
|
@@ -122,19 +147,22 @@ public class OpenService {
|
|
|
return ResultJson.error("车辆已锁定");
|
|
|
}
|
|
|
String businessId = tbBusinessCar.getBusinessId();
|
|
|
- BigDecimal price =new BigDecimal("0");
|
|
|
- if (CAR_LIST.contains(carNo.substring(0,1))){
|
|
|
- price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now);
|
|
|
+ BigDecimal price = new BigDecimal("0");
|
|
|
+ if (CAR_LIST.contains(carNo.substring(0, 1))) {
|
|
|
+ Date inTime=tbBusinessCar.getRealInTime();
|
|
|
+ if (tbBusinessCar.getPay()==1){
|
|
|
+ inTime=tbBusinessCar.getPayTime();
|
|
|
+ }
|
|
|
+ price = tbBusinessService.calculationPartMoney(inTime, now);
|
|
|
}
|
|
|
- double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
|
|
|
+// double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
|
|
|
+ double dif = price.doubleValue();
|
|
|
if (dif > 0) {
|
|
|
- tbBusinessCar.setPay(0);
|
|
|
- tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
RedisUtil.set(channel, carNo);
|
|
|
return ResultJson.error("请缴停车费" + dif + "元");
|
|
|
}
|
|
|
if (StrUtil.isEmpty(businessId)) {
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel);
|
|
|
+ tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
return ResultJson.success();
|
|
@@ -156,7 +184,7 @@ public class OpenService {
|
|
|
if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType()) && !business.getItemPrice().equals(itemPayPrice)) {
|
|
|
return ResultJson.error("请缴纳业务费用");
|
|
|
}
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel);
|
|
|
+ tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
|
|
|
return ResultJson.success();
|
|
@@ -176,4 +204,17 @@ public class OpenService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void handlerInRecord(InRecordBO inRecordBO) {
|
|
|
+ String carNo = inRecordBO.getCarNumber().trim().toUpperCase();
|
|
|
+ // 入场==>取车牌颜色
|
|
|
+ List<TbBusinessCar> cars = tbBusinessCarService.findByCarNo(carNo);
|
|
|
+ cars.stream().filter(obj -> StrUtil.isEmpty(obj.getColor()))
|
|
|
+ .forEach(tbBusinessCar -> {
|
|
|
+ tbBusinessCar.setColor(inRecordBO.getCarColor());
|
|
|
+ tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+ });
|
|
|
+ if (cars.isEmpty()) {
|
|
|
+ //handlerIn(carNo, inRecordBO.getChannelName(), null);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|