|
@@ -15,6 +15,8 @@ import com.pj.project.tb_business_car.TbBusinessCar;
|
|
|
import com.pj.project.tb_business_car.TbBusinessCarService;
|
|
import com.pj.project.tb_business_car.TbBusinessCarService;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItem;
|
|
import com.pj.project.tb_business_item.TbBusinessItem;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItemService;
|
|
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.utils.cache.RedisUtil;
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -22,6 +24,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import javax.xml.crypto.Data;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -40,6 +43,8 @@ public class OpenService {
|
|
|
@Resource
|
|
@Resource
|
|
|
@Lazy
|
|
@Lazy
|
|
|
private TbBusinessItemService tbBusinessItemService;
|
|
private TbBusinessItemService tbBusinessItemService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private TbCarService tbCarService;
|
|
|
|
|
|
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
|
|
|
|
|
@@ -47,55 +52,65 @@ public class OpenService {
|
|
|
public ResultJson checkCarNumber(CheckCarNumberBO checkCarNumberBO) {
|
|
public ResultJson checkCarNumber(CheckCarNumberBO checkCarNumberBO) {
|
|
|
String carNo = checkCarNumberBO.getCarNumber();
|
|
String carNo = checkCarNumberBO.getCarNumber();
|
|
|
int inOrOut = checkCarNumberBO.getInOrOut();
|
|
int inOrOut = checkCarNumberBO.getInOrOut();
|
|
|
|
|
+ String image = checkCarNumberBO.getImageData();
|
|
|
if (inOrOut == 1) {
|
|
if (inOrOut == 1) {
|
|
|
- handlerIn(carNo, checkCarNumberBO.getChannelName());
|
|
|
|
|
|
|
+ handlerIn(carNo, checkCarNumberBO.getChannelName(), image);
|
|
|
return ResultJson.success();
|
|
return ResultJson.success();
|
|
|
}
|
|
}
|
|
|
- return handlerOut(carNo, checkCarNumberBO.getChannelName());
|
|
|
|
|
|
|
+ return handlerOut(carNo, checkCarNumberBO.getChannelName(), image);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void handlerIn(String carNo, String channel) {
|
|
|
|
|
|
|
+ private void handlerIn(String carNo, String channel, String image) {
|
|
|
carNo = carNo.toUpperCase();
|
|
carNo = carNo.toUpperCase();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
|
if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)) {
|
|
if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)) {
|
|
|
tbBusinessCar = new TbBusinessCar();
|
|
tbBusinessCar = new TbBusinessCar();
|
|
|
- tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(3D).setIsLock(0)
|
|
|
|
|
|
|
+ tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(3D).setIsLock(0).setInImage(image)
|
|
|
.setInChannel(channel).setRealInTime(now).setBasePartMoney(new BigDecimal("0"));
|
|
.setInChannel(channel).setRealInTime(now).setBasePartMoney(new BigDecimal("0"));
|
|
|
tbBusinessCarService.save(tbBusinessCar);
|
|
tbBusinessCarService.save(tbBusinessCar);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- tbBusinessCar.setRealInTime(now).setInChannel(channel);
|
|
|
|
|
|
|
+ tbBusinessCar.setRealInTime(now).setInChannel(channel).setInImage(image);
|
|
|
tbBusinessCarService.saveOrUpdate(tbBusinessCar);
|
|
tbBusinessCarService.saveOrUpdate(tbBusinessCar);
|
|
|
if (!CAR_LIST.contains(carNo)) {
|
|
if (!CAR_LIST.contains(carNo)) {
|
|
|
TbBusiness tbBusiness = tbBusinessService.getById(tbBusinessCar.getBusinessId());
|
|
TbBusiness tbBusiness = tbBusinessService.getById(tbBusinessCar.getBusinessId());
|
|
|
- tbBusiness.setRealInTime(now).setInChannel(channel);
|
|
|
|
|
- tbBusinessService.updateById(tbBusiness);
|
|
|
|
|
|
|
+ if (tbBusiness != null) {
|
|
|
|
|
+ tbBusiness.setRealInTime(now).setInChannel(channel);
|
|
|
|
|
+ tbBusinessService.updateById(tbBusiness);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ checkFree(carNo, 1, now);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private ResultJson handlerOut(String carNo, String channel) {
|
|
|
|
|
|
|
+ private ResultJson handlerOut(String carNo, String channel, String image) {
|
|
|
carNo = carNo.toUpperCase();
|
|
carNo = carNo.toUpperCase();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findNotOutCar(carNo);
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findNotOutCar(carNo);
|
|
|
if (tbBusinessCar == null) {
|
|
if (tbBusinessCar == null) {
|
|
|
return ResultJson.error("未查询到入场记录");
|
|
return ResultJson.error("未查询到入场记录");
|
|
|
}
|
|
}
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ if (checkFree(carNo, 2, now)) {
|
|
|
|
|
+ tbBusinessCar.setRealOutTime(now).setOutImage(image);
|
|
|
|
|
+ tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
|
|
+ return ResultJson.success();
|
|
|
|
|
+ }
|
|
|
if (tbBusinessCar.getIsLock() == 1) {
|
|
if (tbBusinessCar.getIsLock() == 1) {
|
|
|
return ResultJson.error("车辆已锁定");
|
|
return ResultJson.error("车辆已锁定");
|
|
|
}
|
|
}
|
|
|
- Date now = new Date();
|
|
|
|
|
|
|
+
|
|
|
String businessId = tbBusinessCar.getBusinessId();
|
|
String businessId = tbBusinessCar.getBusinessId();
|
|
|
- BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now,StrUtil.isNotEmpty(businessId));
|
|
|
|
|
|
|
+ BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now, StrUtil.isNotEmpty(businessId));
|
|
|
double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
|
|
double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
|
|
|
if (dif > 0) {
|
|
if (dif > 0) {
|
|
|
- tbBusinessCar.setPay(0);
|
|
|
|
|
|
|
+ tbBusinessCar.setPay(0).setOutImage(image);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
RedisUtil.set(channel, carNo);
|
|
RedisUtil.set(channel, carNo);
|
|
|
return ResultJson.error("请缴停车费" + dif + "元");
|
|
return ResultJson.error("请缴停车费" + dif + "元");
|
|
|
}
|
|
}
|
|
|
if (StrUtil.isEmpty(businessId)) {
|
|
if (StrUtil.isEmpty(businessId)) {
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel);
|
|
|
|
|
|
|
+ tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setOutImage(image);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
return ResultJson.success();
|
|
return ResultJson.success();
|
|
|
}
|
|
}
|
|
@@ -116,10 +131,23 @@ public class OpenService {
|
|
|
if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType()) && !business.getItemPrice().equals(itemPayPrice)) {
|
|
if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType()) && !business.getItemPrice().equals(itemPayPrice)) {
|
|
|
return ResultJson.error("请缴纳业务费用");
|
|
return ResultJson.error("请缴纳业务费用");
|
|
|
}
|
|
}
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel);
|
|
|
|
|
|
|
+ tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setOutImage(image);
|
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
return ResultJson.success();
|
|
return ResultJson.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private boolean checkFree(String carNo, int inOrOut, Date now) {
|
|
|
|
|
+ TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
|
|
+ if (tbCar != null) {
|
|
|
|
|
+ if (inOrOut == 1) {
|
|
|
|
|
+ tbCar.setLastInTime(now);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ tbCar.setLastOutTime(now);
|
|
|
|
|
+ }
|
|
|
|
|
+ tbCarService.updateById(tbCar);
|
|
|
|
|
+ }
|
|
|
|
|
+ return tbCar != null && TbCar.CarTypeEnum.BUSINESS_CAR.getType().equals(tbCar.getCarType());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|