|  | @@ -45,6 +45,7 @@ import com.pj.project4sp.role4permission.SpRolePermissionService;
 | 
	
		
			
				|  |  |  import com.pj.utils.so.SoMap;
 | 
	
		
			
				|  |  |  import org.aspectj.weaver.loadtime.Aj;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.scheduling.annotation.Async;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.pj.utils.sg.*;
 | 
	
	
		
			
				|  | @@ -99,7 +100,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 | 
	
		
			
				|  |  |       * 增
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public AjaxJson addOrUpdate(TbBusiness t) {
 | 
	
		
			
				|  |  | -        if (checkCarNo(t.getCardNo()) != null) {
 | 
	
		
			
				|  |  | +        if (checkCarNo(t.getCardNo()) != null&&StrUtil.isEmpty(t.getId())) {
 | 
	
		
			
				|  |  |              return AjaxJson.getError("该车辆【" + t.getCardNo() + "】有未完成业务");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -142,12 +143,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 | 
	
		
			
				|  |  |          this.saveOrUpdate(t);
 | 
	
		
			
				|  |  |          tbBusinessItemService.saveBatch(items);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //增加一条放行记录
 | 
	
		
			
				|  |  | -//        TbPassRecord record = new TbPassRecord();
 | 
	
		
			
				|  |  | -//        record.setBusinessId(t.getId()).setCustomerId(t.getCustomerId())
 | 
	
		
			
				|  |  | -//                .setCardNo(t.getCardNo()).setCustomerName(t.getCustomerName())
 | 
	
		
			
				|  |  | -//                .setStatus(1).setUpdateTime(new Date());
 | 
	
		
			
				|  |  | -//        tbPassRecordService.saveOrUpdate(record);
 | 
	
		
			
				|  |  | +        //增加或修改一条境外车未入场记录
 | 
	
		
			
				|  |  | +        tbPassRecordService.addOrUpdate(t.getId(), t.getCustomerId(), t.getCustomerName(),
 | 
	
		
			
				|  |  | +                t.getCardNo(), 1, null, null, t.getCountryName());
 | 
	
		
			
				|  |  | +        //增加或修改一条中国车未入场记录
 | 
	
		
			
				|  |  | +        tbPassRecordService.addOrUpdate(t.getId(), t.getCustomerId(), t.getCustomerName(),
 | 
	
		
			
				|  |  | +                t.getChinaCarNo(), 1, null, null, "中国车");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return AjaxJson.getSuccess();
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -250,10 +251,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 | 
	
		
			
				|  |  |          tbBusiness.setRealInTime(new Date()).setInChannel(inChannel);
 | 
	
		
			
				|  |  |          this.updateById(tbBusiness);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //更新放行记录
 | 
	
		
			
				|  |  | -        TbPassRecord record = tbPassRecordService.getByBusinessId(tbBusiness.getId());
 | 
	
		
			
				|  |  | -        record.setStatus(2).setInTime(tbBusiness.getRealInTime()).setUpdateTime(new Date());
 | 
	
		
			
				|  |  | -        tbPassRecordService.saveOrUpdate(record);
 | 
	
		
			
				|  |  | +        //更新境外车入场记录
 | 
	
		
			
				|  |  | +        tbPassRecordService.addOrUpdate(tbBusiness.getId(), tbBusiness.getCustomerId(), tbBusiness.getCustomerName(),
 | 
	
		
			
				|  |  | +                tbBusiness.getCardNo(), 2, tbBusiness.getRealInTime(), null, tbBusiness.getCountryName());
 | 
	
		
			
				|  |  | +        //更新中国车入场记录
 | 
	
		
			
				|  |  | +        tbPassRecordService.addOrUpdate(tbBusiness.getId(), tbBusiness.getCustomerId(), tbBusiness.getCustomerName(),
 | 
	
		
			
				|  |  | +                tbBusiness.getChinaCarNo(), 2, tbBusiness.getChinaCarInTime(), null, "中国车");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void adminOut(String id, Date outDayTime, String outChannel, String carType) {
 | 
	
	
		
			
				|  | @@ -262,13 +265,17 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 | 
	
		
			
				|  |  |          calculationPartMoney(carType, tbBusiness);
 | 
	
		
			
				|  |  |          this.updateById(tbBusiness);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //更新放行记录
 | 
	
		
			
				|  |  | -        TbPassRecord record = tbPassRecordService.getByBusinessId(tbBusiness.getId());
 | 
	
		
			
				|  |  | -        record.setStatus(3).setOutTime(tbBusiness.getOutDayTime()).setUpdateTime(new Date());
 | 
	
		
			
				|  |  | -        tbPassRecordService.saveOrUpdate(record);
 | 
	
		
			
				|  |  | +        //更新境外车出场记录
 | 
	
		
			
				|  |  | +        tbPassRecordService.addOrUpdate(tbBusiness.getId(), tbBusiness.getCustomerId(), tbBusiness.getCustomerName(),
 | 
	
		
			
				|  |  | +                tbBusiness.getCardNo(), 3,
 | 
	
		
			
				|  |  | +                tbBusiness.getRealInTime(), tbBusiness.getOutDayTime(), tbBusiness.getCountryName());
 | 
	
		
			
				|  |  | +        //更新中国车出场记录
 | 
	
		
			
				|  |  | +        tbPassRecordService.addOrUpdate(tbBusiness.getId(), tbBusiness.getCustomerId(), tbBusiness.getCustomerName(),
 | 
	
		
			
				|  |  | +                tbBusiness.getChinaCarNo(), 3,
 | 
	
		
			
				|  |  | +                tbBusiness.getChinaCarInTime(), tbBusiness.getChinaCarOutTime(), "中国车");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    @Async
 | 
	
		
			
				|  |  |      public void calculationPartMoney(String itemType, TbBusiness tbBusiness) {
 | 
	
		
			
				|  |  |          Date iTime = tbBusiness.getRealInTime();
 | 
	
		
			
				|  |  |          Date oTime = tbBusiness.getOutDayTime();
 | 
	
	
		
			
				|  | @@ -286,44 +293,15 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 | 
	
		
			
				|  |  |          if (carSize < partConfig.getFreeCarLength() || minutes <= partConfig.getFreeMinutes()) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        String businessId = tbBusiness.getId();
 | 
	
		
			
				|  |  | -//        TbBusinessItem businessItem = tbBusinessItemService.findByBusinessIdAndTypeName(businessId, itemType);
 | 
	
		
			
				|  |  | -//        if (businessItem == null) {
 | 
	
		
			
				|  |  | -//            businessItem = new TbBusinessItem();
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -        LocalTime zero = LocalTime.of(0, 0, 0);
 | 
	
		
			
				|  |  |          long days = ChronoUnit.DAYS.between(inDayTime.toLocalDate(), outDayTime.toLocalDate());
 | 
	
		
			
				|  |  | +        long hour = ChronoUnit.HOURS.between(inDayTime, outDayTime);
 | 
	
		
			
				|  |  |          BigDecimal basePrice = partConfig.getBasePrice();
 | 
	
		
			
				|  |  |          BigDecimal extraPrice = partConfig.getExtraPrice();
 | 
	
		
			
				|  |  | -        BigDecimal price = basePrice;
 | 
	
		
			
				|  |  | -        LocalTime outTime = outDayTime.toLocalTime();
 | 
	
		
			
				|  |  | -        LocalTime nigthEnd = LocalTime.parse(partConfig.getNightEnd(), DateTimeFormatter.ofPattern("HH:mm:ss"));
 | 
	
		
			
				|  |  | -        if (days >= 1) {
 | 
	
		
			
				|  |  | -            price = basePrice.add(basePrice.multiply(new BigDecimal(days - 1)));
 | 
	
		
			
				|  |  | -            if (outTime.isAfter(nigthEnd)){
 | 
	
		
			
				|  |  | -                price = basePrice.add(basePrice.multiply(new BigDecimal(days)));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (outTime.isAfter(zero)&&outTime.isBefore(nigthEnd)){
 | 
	
		
			
				|  |  | -                price=price.add(extraPrice);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        long hour = ChronoUnit.HOURS.between(zero, outTime);
 | 
	
		
			
				|  |  | -        if (days == 0) {
 | 
	
		
			
				|  |  | -            hour = ChronoUnit.HOURS.between(inDayTime, outDayTime);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        String num = days + "天" + hour + "小时";
 | 
	
		
			
				|  |  | -        if (hour == 0) {
 | 
	
		
			
				|  |  | -            num = minutes + "分钟";
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -//        businessItem.setTotal(price).setUnit("天").setItemTypeName(itemType).setItemPrice(partConfig.getBasePrice())
 | 
	
		
			
				|  |  | -//                .setBusinessId(businessId).setItemName("停车费").setNum(num);
 | 
	
		
			
				|  |  | -//        tbBusinessItemService.saveOrUpdate(businessItem);
 | 
	
		
			
				|  |  | +        BigDecimal price = basePrice.add(basePrice.multiply(new BigDecimal(hour/24))).add(new BigDecimal(days).multiply(extraPrice));
 | 
	
		
			
				|  |  |          if (itemType.contains("中国")) {
 | 
	
		
			
				|  |  |              tbBusiness.setChinaPartMoney(price).setChinaCarPartTime(minutes);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              tbBusiness.setPartMoney(price).setPartTime(minutes);
 | 
	
		
			
				|  |  | -            ;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          tbBusiness.setTotalMoney(tbBusiness.getItemPrice().add(tbBusiness.getChinaPartMoney()).add(tbBusiness.getPartMoney()));
 | 
	
		
			
				|  |  |      }
 |