|
@@ -134,6 +134,7 @@ public class ApiService {
|
|
|
|
|
|
public List<TbBusinessCar> searchPartCar(String carNo) {
|
|
|
List<TbBusinessCar> list = tbBusinessCarService.searchPartCar(carNo);
|
|
|
+
|
|
|
list = list.stream().filter(tbBusinessCar -> {
|
|
|
String businessId = tbBusinessCar.getBusinessId();
|
|
|
if (StrUtil.isEmpty(businessId)) {
|
|
@@ -142,9 +143,16 @@ public class ApiService {
|
|
|
TbBusiness tbBusiness = tbBusinessService.getById(businessId);
|
|
|
return tbBusiness.getAdminConfirmInput() == 1;
|
|
|
}).collect(Collectors.toList());
|
|
|
+ List<TbBusinessCar> otherBusinessCarList = tbBusinessCarService.searchOtherBusinessCar(carNo);
|
|
|
+ otherBusinessCarList= otherBusinessCarList.stream().filter(tbBusinessCar -> {
|
|
|
+ String businessCarId = tbBusinessCar.getId();
|
|
|
+ List<TbBusiness> businesses = tbBusinessService.findOtherBusinessByCarId(businessCarId);
|
|
|
+ return !businesses.isEmpty();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
List<TbBusinessCar> cars = tbBusinessCarService.findTheNoBusinessCar(carNo);
|
|
|
//过滤掉不用缴费的车
|
|
|
list.addAll(cars);
|
|
|
+ list.addAll(otherBusinessCarList);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
@@ -273,26 +281,31 @@ public class ApiService {
|
|
|
|
|
|
public void addCarDisinfect(OtherBusinessBO otherBusinessBO) {
|
|
|
String carNo = otherBusinessBO.getCarNo().trim().toUpperCase();
|
|
|
- TbBusinessCar db = tbBusinessCarService.findInAndHasBusinessCar(carNo);
|
|
|
- if (db != null) {
|
|
|
- throw new BusinessException(carNo + "有未完成作业");
|
|
|
- }
|
|
|
- db = tbBusinessCarService.findInAndNoBusinessCar(carNo);
|
|
|
+ TbBusinessCar db = tbBusinessCarService.findNotOutCar(carNo);
|
|
|
+ String customerId = otherBusinessBO.getCustomerId();
|
|
|
if (db == null) {
|
|
|
- db = new TbBusinessCar();
|
|
|
- db.setPay(0).setTimeUpdate(new Date());
|
|
|
+ db = tbBusinessCarService.findNotInCar(carNo);
|
|
|
+ if (db == null) {
|
|
|
+ TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
- TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
- db.setCarNo(carNo).setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
|
|
|
+
|
|
|
TbBusiness tbBusiness = new TbBusiness();
|
|
|
- String customerId = otherBusinessBO.getCustomerId();
|
|
|
- db.setCustomerId(customerId);
|
|
|
+ tbBusiness.setBusinessCarId(db.getId());
|
|
|
TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
|
- if (tbCostomer!=null){
|
|
|
+ if (tbCostomer != null) {
|
|
|
tbBusiness.setCustomerId(customerId).setCustomerName(tbCostomer.getName());
|
|
|
}
|
|
|
- db.setCarSize(otherBusinessBO.getCarSize());
|
|
|
List<TbItem> tbItems = otherBusinessBO.getItems();
|
|
|
+ if (tbItems.isEmpty()) {
|
|
|
+ throw new BusinessException("请选择明细");
|
|
|
+ }
|
|
|
BigDecimal price = new BigDecimal("0");
|
|
|
List<TbBusinessItem> itemList = new ArrayList<>();
|
|
|
String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
|
|
@@ -300,11 +313,11 @@ public class ApiService {
|
|
|
for (TbItem tbItem : tbItems) {
|
|
|
TbBusinessItem item = new TbBusinessItem();
|
|
|
int num = tbItem.getNum();
|
|
|
- RelationTypeItem relationTypeItem= relationTypeItemService.findByTypeIdAndItemId(otherBusinessBO.getItemTypeId(),tbItem.getId());
|
|
|
+ RelationTypeItem relationTypeItem = relationTypeItemService.findByTypeIdAndItemId(otherBusinessBO.getItemTypeId(), tbItem.getId());
|
|
|
BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
|
|
|
item.setNo(no + "0" + index).setPayTypeName(tbItem.getPayTypeName()).setPayType(tbItem.getPayType())
|
|
|
- .setBusinessType(tbItem.getBusinessType()).setTaxRate(NumberUtil.div(tbItem.getTaxRate().doubleValue(),100D,2));
|
|
|
- item.setItemCode(tbItem.getItemCode()).setNum("1").setNum(num + "").setItemId(tbItem.getId()).setItemCode(tbItem.getItemCode())
|
|
|
+ .setBusinessType(tbItem.getBusinessType()).setTaxRate(NumberUtil.div(tbItem.getTaxRate().doubleValue(), 100D, 2));
|
|
|
+ item.setItemCode(tbItem.getItemCode()).setNum(num + "").setItemId(tbItem.getId()).setItemCode(tbItem.getItemCode())
|
|
|
.setItemName(tbItem.getItemName()).setItemPrice(tbItem.getPrice()).setRemark(tbItem.getRemark())
|
|
|
.setItemTypeId(otherBusinessBO.getItemTypeId()).setItemTypeName(relationTypeItem.getTypeName())
|
|
|
.setUnit(tbItem.getUnit()).setTotal(itemTotalPrice).setCreateTime(new Date());
|
|
@@ -313,6 +326,7 @@ public class ApiService {
|
|
|
index++;
|
|
|
}
|
|
|
tbBusiness.setCardSize(otherBusinessBO.getCarSize()).setNetWeight(otherBusinessBO.getCarWeight())
|
|
|
+ .setOperator(otherBusinessBO.getOperator()).setOperateTime(otherBusinessBO.getOperateTime())
|
|
|
.setNo(no).setGoodsName(otherBusinessBO.getCarType()).setItemTypeId(otherBusinessBO.getItemTypeId())
|
|
|
.setCreateTime(new Date()).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
|
|
|
.setItemPrice(price).setTotalMoney(price);
|
|
@@ -323,9 +337,6 @@ public class ApiService {
|
|
|
tbBusiness.setCardNo(carNo);
|
|
|
}
|
|
|
tbBusinessService.save(tbBusiness);
|
|
|
- db.setBusinessId(tbBusiness.getId())
|
|
|
- .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
- tbBusinessCarService.save(db);
|
|
|
itemList.forEach(tbBusinessItem -> tbBusinessItem.setBusinessId(tbBusiness.getId()));
|
|
|
tbBusinessItemService.saveBatch(itemList);
|
|
|
}
|
|
@@ -338,17 +349,63 @@ public class ApiService {
|
|
|
throw new BusinessException("数据不存在");
|
|
|
}
|
|
|
List<TbItem> tbItems = JSONUtil.toList(itemJson, TbItem.class);
|
|
|
- tbItems.forEach(tbItem -> {
|
|
|
-
|
|
|
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
public void editOtherBusiness(OtherBusinessBO otherBusinessBO) {
|
|
|
+ List<TbItem> tbItems = otherBusinessBO.getItems();
|
|
|
+ if (tbItems.isEmpty()) {
|
|
|
+ throw new BusinessException("请选择明细");
|
|
|
+ }
|
|
|
String businessId = otherBusinessBO.getId();
|
|
|
+ String carNo = otherBusinessBO.getCarNo();
|
|
|
+ String customerId = otherBusinessBO.getCustomerId();
|
|
|
tbBusinessItemService.removeByBusinessId(businessId);
|
|
|
- tbBusinessCarService.removeByBusinessId(businessId);
|
|
|
- this.addCarDisinfect(otherBusinessBO);
|
|
|
+ TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
|
+ TbBusiness tbBusiness = tbBusinessService.getById(businessId);
|
|
|
+ tbBusiness.setOperateTime(otherBusinessBO.getOperateTime())
|
|
|
+ .setOperator(otherBusinessBO.getOperator())
|
|
|
+ .setCardSize(otherBusinessBO.getCarSize())
|
|
|
+ .setCustomerId(customerId).setNetWeight(otherBusinessBO.getCarWeight())
|
|
|
+ .setGoodsName(otherBusinessBO.getCarType())
|
|
|
+ .setCustomerName(tbCostomer.getName());
|
|
|
+ String prefix = carNo.substring(0, 1);
|
|
|
+ if (CAR_LIST.contains(prefix)) {
|
|
|
+ tbBusiness.setChinaCarNo(carNo);
|
|
|
+ } else {
|
|
|
+ tbBusiness.setCardNo(carNo);
|
|
|
+ }
|
|
|
+ String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
|
|
|
+ TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(tbBusiness.getBusinessCarId());
|
|
|
+ tbBusinessCar.setCarSize(otherBusinessBO.getCarSize()).setCustomerId(otherBusinessBO.getCustomerId()).setCarNo(carNo)
|
|
|
+ .setTimeUpdate(new Date());
|
|
|
+ int index = 1;
|
|
|
+ BigDecimal price = new BigDecimal("0");
|
|
|
+ List<TbBusinessItem> itemList = new ArrayList<>();
|
|
|
+ for (TbItem tbItem : tbItems) {
|
|
|
+ TbBusinessItem item = new TbBusinessItem();
|
|
|
+ int num = tbItem.getNum();
|
|
|
+ RelationTypeItem relationTypeItem = relationTypeItemService.findByTypeIdAndItemId(otherBusinessBO.getItemTypeId(), tbItem.getId());
|
|
|
+ BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
|
|
|
+ item.setNo(no + "0" + index).setPayTypeName(tbItem.getPayTypeName())
|
|
|
+ .setPayType(tbItem.getPayType())
|
|
|
+ .setBusinessType(tbItem.getBusinessType())
|
|
|
+ .setTaxRate(NumberUtil.div(tbItem.getTaxRate().doubleValue(), 100D, 2))
|
|
|
+ .setItemCode(tbItem.getItemCode()).setNum(num + "")
|
|
|
+ .setItemId(tbItem.getId()).setItemCode(tbItem.getItemCode())
|
|
|
+ .setItemName(tbItem.getItemName()).setItemPrice(tbItem.getPrice())
|
|
|
+ .setRemark(tbItem.getRemark())
|
|
|
+ .setItemTypeId(otherBusinessBO.getItemTypeId())
|
|
|
+ .setItemTypeName(relationTypeItem.getTypeName()).setBusinessId(otherBusinessBO.getId())
|
|
|
+ .setUnit(tbItem.getUnit()).setTotal(itemTotalPrice).setCreateTime(new Date());
|
|
|
+ price = price.add(itemTotalPrice);
|
|
|
+ itemList.add(item);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ tbBusinessItemService.saveBatch(itemList);
|
|
|
+ tbBusinessService.updateById(tbBusiness);
|
|
|
+ tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|