|
@@ -12,6 +12,8 @@ import com.pj.project.tb_business.TbBusiness;
|
|
|
import com.pj.project.tb_business.TbBusinessService;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItem;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItemService;
|
|
|
+import com.pj.project.tb_fee_details.TbFeeDetails;
|
|
|
+import com.pj.project.tb_fee_details.TbFeeDetailsService;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -42,6 +44,9 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
private TbBusinessService tbBusinessService;
|
|
|
@Resource
|
|
|
PartConfig partConfig;
|
|
|
+ @Resource
|
|
|
+ @Lazy
|
|
|
+ TbFeeDetailsService tbFeeDetailsService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -86,13 +91,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
|
|
|
|
|
|
public List<TbBusinessCar> searchPartCar(String carNo) {
|
|
|
-// QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
|
|
|
-// ew.like("car_no", carNo);
|
|
|
-// ew.orderByDesc("id");
|
|
|
-// List<TbBusinessCar> list = this.list(ew);
|
|
|
-// list = list.stream().filter(tbBusinessCar -> tbBusinessCar.getPay()==0).collect(
|
|
|
-// Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TbBusinessCar::getCarNo))), ArrayList::new));
|
|
|
-// return list;
|
|
|
return tbBusinessCarMapper.searchPartCar(carNo.toUpperCase());
|
|
|
}
|
|
|
|
|
@@ -205,4 +203,54 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
|
|
|
List<TbBusinessCar> list = this.list(ew);
|
|
|
return list.isEmpty() ? null : list.get(0);
|
|
|
}
|
|
|
+
|
|
|
+ public void addCarRecord(TbBusinessCar t) throws Exception {
|
|
|
+ String carNo = t.getCarNo().toUpperCase();
|
|
|
+ TbBusinessCar db = this.check(carNo);
|
|
|
+ if (db != null) {
|
|
|
+ throw new Exception("该车有未完成业务");
|
|
|
+ }
|
|
|
+ t.setPay(0);
|
|
|
+ this.save(t);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateCarRecord(TbBusinessCar t) throws Exception {
|
|
|
+ if(StrUtil.isEmpty(t.getBusinessId())) {
|
|
|
+ t.setBusinessId(null);
|
|
|
+ }
|
|
|
+ if(StrUtil.isEmpty(t.getCustomerId())) {
|
|
|
+ t.setCustomerId(null);
|
|
|
+ }
|
|
|
+ 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 businessCar = this.findByBusinessIdAndCarNo(businessId, carNo);
|
|
|
+ if (businessCar != null && !StrUtil.equals(t.getId(), businessCar.getId())) {
|
|
|
+ throw new Exception("车辆已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ this.updateById(t);
|
|
|
+ TbBusiness tbBusiness = tbBusinessService.getById(t.getBusinessId());
|
|
|
+ if(tbBusiness != null) {
|
|
|
+ if (!CAR_LIST.contains(carNo.substring(0,1))) {
|
|
|
+ tbBusiness.setCardNo(carNo);
|
|
|
+ } else {
|
|
|
+ List<TbBusinessCar> cars = this.findByBusinessId(t.getBusinessId());
|
|
|
+ String chiaCarNo = cars.stream().filter(obj -> CAR_LIST.contains(obj.getCarNo().substring(0,1))).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
|
|
|
+ tbBusiness.setChinaCarNo(chiaCarNo);
|
|
|
+ }
|
|
|
+ tbBusinessService.updateById(tbBusiness);
|
|
|
+
|
|
|
+ List<TbFeeDetails> feeDetailsLIst = tbFeeDetailsService.getByBusinessIdAndCarNo(businessId, oldCarNo);
|
|
|
+ feeDetailsLIst.forEach(fee -> fee.setCarNo(carNo));
|
|
|
+ tbFeeDetailsService.updateBatchById(feeDetailsLIst);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|