|
@@ -27,6 +27,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_business_sort.TbBusinessSort;
|
|
|
|
|
+import com.pj.project.tb_business_sort.TbBusinessSortService;
|
|
|
import com.pj.project.tb_car.TbCar;
|
|
import com.pj.project.tb_car.TbCar;
|
|
|
import com.pj.project.tb_car.TbCarService;
|
|
import com.pj.project.tb_car.TbCarService;
|
|
|
import com.pj.project.tb_costomer.TbCostomer;
|
|
import com.pj.project.tb_costomer.TbCostomer;
|
|
@@ -58,6 +60,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -109,6 +112,9 @@ public class ApiService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private TbItemTypeService tbItemTypeService;
|
|
private TbItemTypeService tbItemTypeService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private TbBusinessSortService tbBusinessSortService;
|
|
|
|
|
+
|
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
|
|
|
|
|
|
|
|
|
|
@@ -307,27 +313,23 @@ public class ApiService {
|
|
|
throw new BusinessException("请选择明细");
|
|
throw new BusinessException("请选择明细");
|
|
|
}
|
|
}
|
|
|
String carNo = otherBusinessBO.getCarNo().trim().toUpperCase();
|
|
String carNo = otherBusinessBO.getCarNo().trim().toUpperCase();
|
|
|
- for (TbItem tbItem1 : tbItems) {
|
|
|
|
|
- List<TbBusinessCar> tbBusinessCarList = tbBusinessCarService.findTodayRecord(carNo, tbItem1.getId());
|
|
|
|
|
- if (!tbBusinessCarList.isEmpty()) {
|
|
|
|
|
- throw new BusinessException("该车当天已有相同业务");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ checkOtherBusiness(otherBusinessBO, tbItems, carNo);
|
|
|
TbBusinessCar db = tbBusinessCarService.findNotOutCar(carNo);
|
|
TbBusinessCar db = tbBusinessCarService.findNotOutCar(carNo);
|
|
|
String customerId = otherBusinessBO.getCustomerId();
|
|
String customerId = otherBusinessBO.getCustomerId();
|
|
|
TbItemType tbItemType = tbItemTypeService.getById(otherBusinessBO.getItemTypeId());
|
|
TbItemType tbItemType = tbItemTypeService.getById(otherBusinessBO.getItemTypeId());
|
|
|
|
|
+ TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
if (db == null) {
|
|
if (db == null) {
|
|
|
db = tbBusinessCarService.findNotInCar(carNo);
|
|
db = tbBusinessCarService.findNotInCar(carNo);
|
|
|
if (db == null) {
|
|
if (db == null) {
|
|
|
- TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
|
|
db = new TbBusinessCar();
|
|
db = new TbBusinessCar();
|
|
|
- db.setPay(0).setCarNo(carNo).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
|
|
|
|
|
- .setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
|
|
|
|
|
- db.setCarSize(otherBusinessBO.getCarSize()).setTimeUpdate(new Date()).setCustomerId(customerId)
|
|
|
|
|
- .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
|
|
- tbBusinessCarService.save(db);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ db.setPay(0).setCarNo(carNo).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
|
|
|
|
|
+ .setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
|
|
|
|
|
+ .setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
|
|
|
|
|
+ db.setCarSize(otherBusinessBO.getCarSize()).setTimeUpdate(new Date()).setCustomerId(customerId)
|
|
|
|
|
+ .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
|
|
+ tbBusinessCarService.saveOrUpdate(db);
|
|
|
TbBusiness tbBusiness = new TbBusiness();
|
|
TbBusiness tbBusiness = new TbBusiness();
|
|
|
tbBusiness.setBusinessCarId(db.getId()).setPayStep(tbItemType.getPayStep());
|
|
tbBusiness.setBusinessCarId(db.getId()).setPayStep(tbItemType.getPayStep());
|
|
|
TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
@@ -388,9 +390,10 @@ public class ApiService {
|
|
|
}
|
|
}
|
|
|
TbItemType tbItemType = tbItemTypeService.getById(otherBusinessBO.getItemTypeId());
|
|
TbItemType tbItemType = tbItemTypeService.getById(otherBusinessBO.getItemTypeId());
|
|
|
String businessId = otherBusinessBO.getId();
|
|
String businessId = otherBusinessBO.getId();
|
|
|
|
|
+ tbBusinessItemService.removeByBusinessId(businessId);
|
|
|
String carNo = otherBusinessBO.getCarNo();
|
|
String carNo = otherBusinessBO.getCarNo();
|
|
|
String customerId = otherBusinessBO.getCustomerId();
|
|
String customerId = otherBusinessBO.getCustomerId();
|
|
|
- tbBusinessItemService.removeByBusinessId(businessId);
|
|
|
|
|
|
|
+ checkOtherBusiness(otherBusinessBO, tbItems, carNo);
|
|
|
TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
|
TbBusiness tbBusiness = tbBusinessService.getById(businessId);
|
|
TbBusiness tbBusiness = tbBusinessService.getById(businessId);
|
|
|
tbBusiness.setOperateTime(otherBusinessBO.getOperateTime())
|
|
tbBusiness.setOperateTime(otherBusinessBO.getOperateTime())
|
|
@@ -440,4 +443,46 @@ public class ApiService {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void checkOtherBusiness(OtherBusinessBO otherBusinessBO, List<TbItem> tbItems, String carNo) {
|
|
|
|
|
+ SoMap soMap = SoMap.getRequestSoMap();
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ List<TbBusinessSort> sorts = tbBusinessSortService.getList(soMap);
|
|
|
|
|
+ LocalDateTime operateTime = LocalDateTime.parse(otherBusinessBO.getOperateTime(), formatter);
|
|
|
|
|
+ String today=DateUtil.today();
|
|
|
|
|
+ int i = 0;
|
|
|
|
|
+ List<String> businessTypeList = tbItems.stream().map(TbItem::getBusinessType).collect(Collectors.toList());
|
|
|
|
|
+ for (TbBusinessSort tbBusinessSort : sorts) {
|
|
|
|
|
+ if (i==0&&StrUtil.equals(tbBusinessSort.getTypeId(),otherBusinessBO.getItemTypeId())&&sorts.size()>1){
|
|
|
|
|
+ TbBusinessSort afterItem = sorts.get(i +1);
|
|
|
|
|
+ String typeId = afterItem.getTypeId();
|
|
|
|
|
+ Integer interval = afterItem.getIntervalTime();
|
|
|
|
|
+ LocalDateTime endTime = operateTime.plusMinutes(interval);
|
|
|
|
|
+ int count = tbBusinessService.checkCarBusinessType(typeId, carNo, endTime.format(formatter),1);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new BusinessException("车辆:[" + carNo + "]" + tbBusinessSort.getTypeName() + "后" + afterItem.getIntervalTime() + "分钟才可以执行" + afterItem.getTypeName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (i > 0 &&StrUtil.equals(tbBusinessSort.getTypeId(),otherBusinessBO.getItemTypeId())) {
|
|
|
|
|
+ TbBusinessSort beforeItem = sorts.get(i - 1);
|
|
|
|
|
+ String typeId = beforeItem.getTypeId();
|
|
|
|
|
+ Integer interval = tbBusinessSort.getIntervalTime();
|
|
|
|
|
+ LocalDateTime endTime = operateTime.minusMinutes(interval);
|
|
|
|
|
+ int count = tbBusinessService.checkCarBusinessType(typeId, carNo, endTime.format(formatter),0);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new BusinessException("车辆:[" + carNo + "]" + beforeItem.getTypeName() + "后" + tbBusinessSort.getIntervalTime() + "分钟才可以执行" + tbBusinessSort.getTypeName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ String typeId = otherBusinessBO.getItemTypeId();
|
|
|
|
|
+ Integer singleIntervalTime = tbBusinessSort.getSingleIntervalTime();
|
|
|
|
|
+ String timeStart = operateTime.minusHours(singleIntervalTime).format(formatter);
|
|
|
|
|
+ String businessId = otherBusinessBO.getId();
|
|
|
|
|
+ String timeEnd = operateTime.plusHours(singleIntervalTime).format(formatter);
|
|
|
|
|
+ int count = tbBusinessService.checkCarBusinessType(typeId, carNo, timeStart, timeEnd, businessId);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new BusinessException("车辆:[" + carNo + "]" + singleIntervalTime + "小时内已有相同作业");
|
|
|
|
|
+ }
|
|
|
|
|
+ i++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|