|
@@ -129,14 +129,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
return getOne(ew);
|
|
|
}
|
|
|
|
|
|
- public TbBusinessCar findInAndHasBusinessCar(String carNo) {
|
|
|
- QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
|
- ew.eq("car_no", carNo.toUpperCase())
|
|
|
- .isNotNull("real_in_time")
|
|
|
- .isNotNull("business_id")
|
|
|
- .isNull("real_out_time");
|
|
|
- return getOne(ew);
|
|
|
- }
|
|
|
|
|
|
public List<TbBusinessCar> findInAndNoBusinessCar() {
|
|
|
QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
@@ -165,8 +157,10 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
|
|
|
public TbBusinessCar findNotInCar(String carNo) {
|
|
|
QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
|
- ew.eq("car_no", carNo.toUpperCase()).isNull("real_in_time");
|
|
|
- return this.getOne(ew);
|
|
|
+ ew.eq("car_no", carNo.toUpperCase())
|
|
|
+ .isNull("real_in_time").orderByDesc("id");
|
|
|
+ List<TbBusinessCar> list = list(ew);
|
|
|
+ return list.isEmpty() ? null : list.get(0);
|
|
|
}
|
|
|
|
|
|
public TbBusinessCar findNotOutCar(String carNo) {
|
|
@@ -176,7 +170,7 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
.isNotNull("real_in_time");
|
|
|
List<TbBusinessCar> list = list(ew);
|
|
|
if (list.size() > 1) {
|
|
|
- throw new BusinessException("该车有多个未出场记录");
|
|
|
+ throw new BusinessException("该车" + carNo + "有多个未出场记录");
|
|
|
}
|
|
|
return getOne(ew);
|
|
|
}
|
|
@@ -235,13 +229,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
this.updateById(car);
|
|
|
}
|
|
|
|
|
|
- public TbBusinessCar findInBuNoOutAndNotPay(String carNo) {
|
|
|
- QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
|
- ew.eq("car_no", carNo.toUpperCase())
|
|
|
- .isNull("real_out_time")
|
|
|
- .isNotNull("real_in_time").eq("pay", "0");
|
|
|
- return getOne(ew);
|
|
|
- }
|
|
|
|
|
|
public AjaxJson deleteCar(String id) {
|
|
|
TbBusinessCar db = this.getById(id);
|
|
@@ -253,12 +240,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
return AjaxJson.getSuccess();
|
|
|
}
|
|
|
|
|
|
- public TbBusinessCar checkCar(String carNo) {
|
|
|
- QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
|
- ew.eq("car_no", carNo);
|
|
|
- ew.eq("pay", 0);
|
|
|
- return this.getOne(ew);
|
|
|
- }
|
|
|
|
|
|
public TbBusinessCar findTheLastRecord(String carNo) {
|
|
|
QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
@@ -280,20 +261,25 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
}
|
|
|
|
|
|
public void updateCarRecord(TbBusinessCar t) throws Exception {
|
|
|
- if (StrUtil.isEmpty(t.getBusinessId())) {
|
|
|
- t.setBusinessId(null);
|
|
|
- }
|
|
|
- if (StrUtil.isEmpty(t.getCustomerId())) {
|
|
|
- t.setCustomerId(null);
|
|
|
+ TbBusinessCar db = this.getById(t.getId());
|
|
|
+ if (StrUtil.equals(db.getCarNo().toUpperCase().trim(), t.getCarNo().toUpperCase().trim())) {
|
|
|
+ db.setRealInTime(t.getRealInTime()).setColor(t.getColor())
|
|
|
+ .setRealOutTime(t.getRealOutTime()).setInImage(t.getInImage())
|
|
|
+ .setOutImage(t.getOutImage())
|
|
|
+ .setCarSize(t.getCarSize())
|
|
|
+ .setDriverName(t.getDriverName())
|
|
|
+ .setDriverPhone(t.getDriverPhone()).setTimeUpdate(new Date());
|
|
|
+ this.updateById(db);
|
|
|
+ return;
|
|
|
}
|
|
|
String carNo = t.getCarNo().toUpperCase();
|
|
|
TbBusinessCar old = this.getById(t.getId());
|
|
|
String oldCarNo = old.getCarNo();
|
|
|
- TbBusinessCar db = this.check(carNo);
|
|
|
- String businessId = t.getBusinessId();
|
|
|
- if (db != null && !StrUtil.equals(t.getId(), db.getId())) {
|
|
|
- throw new Exception("该车有未完成业务");
|
|
|
+ TbBusinessCar notOutCar = findNotOutCar(carNo);
|
|
|
+ if (notOutCar != null && !notOutCar.getId().equals(t.getId())) {
|
|
|
+ throw new Exception("该车" + carNo + "已进场但未出场");
|
|
|
}
|
|
|
+ String businessId = t.getBusinessId();
|
|
|
TbBusinessCar businessCar = this.findByBusinessIdAndCarNo(businessId, carNo);
|
|
|
if (businessCar != null && !StrUtil.equals(t.getId(), businessCar.getId())) {
|
|
|
throw new Exception("车辆已存在");
|
|
@@ -403,10 +389,25 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
}
|
|
|
|
|
|
public List<TbBusinessCar> findNotOutCarLike(String carNo) {
|
|
|
+ if (StrUtil.isEmpty(carNo) || StrUtil.length(carNo) < 3) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
|
ew.select("car_no,car_size");
|
|
|
- ew.like("car_no", carNo.toUpperCase());
|
|
|
- List<TbBusinessCar>list=list(ew);
|
|
|
+ ew.like("car_no", carNo.trim().toUpperCase());
|
|
|
+ ew.isNull("real_out_time")
|
|
|
+ .isNotNull("real_in_time");
|
|
|
+ List<TbBusinessCar> list = list(ew);
|
|
|
return list.stream().distinct().collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
+ public TbBusinessCar searchOtherBusinessCarNotOut(String carNo) {
|
|
|
+ QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
|
+ ew.isNull("real_out_time")
|
|
|
+ .isNull("business_id")
|
|
|
+ .eq("car_no", carNo.trim().toUpperCase())
|
|
|
+ .orderByDesc("time_update");
|
|
|
+ List<TbBusinessCar> list = list(ew);
|
|
|
+ return list.isEmpty() ? null : list.get(0);
|
|
|
+ }
|
|
|
}
|