车辆管理
This commit is contained in:
@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.dromara.common.core.constant.HttpStatus;
|
import org.dromara.common.core.constant.HttpStatus;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.excel.core.DefaultExcelListener;
|
import org.dromara.common.excel.core.DefaultExcelListener;
|
||||||
import org.dromara.common.excel.utils.ExcelUtil;
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
@ -39,6 +40,7 @@ import java.math.RoundingMode;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,21 +259,30 @@ public class PgsProgressCategoryController extends BaseController {
|
|||||||
List<PgsProgressCategoryVo> list = sheetListener.getExcelResult().getList();
|
List<PgsProgressCategoryVo> list = sheetListener.getExcelResult().getList();
|
||||||
List<PgsProgressCategoryVo> newList = list.stream().filter(vo -> vo.getId() == null).toList();
|
List<PgsProgressCategoryVo> newList = list.stream().filter(vo -> vo.getId() == null).toList();
|
||||||
List<PgsProgressCategoryVo> oldList = list.stream().filter(vo -> vo.getId() != null).toList();
|
List<PgsProgressCategoryVo> oldList = list.stream().filter(vo -> vo.getId() != null).toList();
|
||||||
// 将当前sheet的数据添加到总数据中
|
Set<Long> ids = oldList.stream().map(PgsProgressCategoryVo::getId).collect(Collectors.toSet());
|
||||||
allData.addAll(oldList);
|
List<PgsProgressCategory> categoryList = pgsProgressCategoryService.listByIds(ids);
|
||||||
if (CollUtil.isNotEmpty(newList)) {
|
// 筛选出关联设计图的数据
|
||||||
if (CollUtil.isNotEmpty(oldList)) {
|
List<PgsProgressCategoryVo> oldListVo = oldList.stream().filter(vo -> {
|
||||||
PgsProgressCategoryVo first = oldList.getFirst();
|
PgsProgressCategory category = categoryList.stream().filter(c -> c.getId().equals(vo.getId())).findFirst().orElse(null);
|
||||||
PgsProgressCategory category = pgsProgressCategoryService.getById(first.getId());
|
if (category == null) {
|
||||||
newList.forEach(vo -> {
|
return true;
|
||||||
vo.setParentId(category.getParentId());
|
|
||||||
vo.setProjectId(category.getProjectId());
|
|
||||||
vo.setMatrixId(category.getMatrixId());
|
|
||||||
vo.setAncestors(category.getAncestors());
|
|
||||||
vo.setRelevancyStructure(category.getRelevancyStructure());
|
|
||||||
});
|
|
||||||
allData.addAll(newList);
|
|
||||||
}
|
}
|
||||||
|
String workType = category.getWorkType();
|
||||||
|
return StringUtils.isBlank(workType);
|
||||||
|
}).toList();
|
||||||
|
// 将当前sheet的数据添加到总数据中
|
||||||
|
allData.addAll(oldListVo);
|
||||||
|
if (CollUtil.isNotEmpty(newList) && CollUtil.isNotEmpty(oldList)) {
|
||||||
|
PgsProgressCategoryVo first = oldList.getFirst();
|
||||||
|
PgsProgressCategory category = pgsProgressCategoryService.getById(first.getId());
|
||||||
|
newList.forEach(vo -> {
|
||||||
|
vo.setParentId(category.getParentId());
|
||||||
|
vo.setProjectId(category.getProjectId());
|
||||||
|
vo.setMatrixId(category.getMatrixId());
|
||||||
|
vo.setAncestors(category.getAncestors());
|
||||||
|
vo.setRelevancyStructure(category.getRelevancyStructure());
|
||||||
|
});
|
||||||
|
allData.addAll(newList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,7 @@ import org.dromara.common.log.enums.BusinessType;
|
|||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.common.web.core.BaseController;
|
import org.dromara.common.web.core.BaseController;
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyCreateReq;
|
import org.dromara.vehicle.domain.dto.vehicleapply.*;
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyQueryReq;
|
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyReviewReq;
|
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyUpdateReq;
|
|
||||||
import org.dromara.vehicle.domain.vo.VehVehicleApplyVo;
|
import org.dromara.vehicle.domain.vo.VehVehicleApplyVo;
|
||||||
import org.dromara.vehicle.service.IVehVehicleApplyService;
|
import org.dromara.vehicle.service.IVehVehicleApplyService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -98,9 +95,31 @@ public class VehVehicleApplyController extends BaseController {
|
|||||||
@SaCheckPermission("vehicle:vehicleApply:edit")
|
@SaCheckPermission("vehicle:vehicleApply:edit")
|
||||||
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PutMapping("/vehicleOwnerReview")
|
@PutMapping("/driverReview")
|
||||||
public R<Void> vehicleOwnerReview(@Validated @RequestBody VehVehicleApplyReviewReq req) {
|
public R<Void> driverReview(@Validated @RequestBody VehVehicleApplyReviewReq req) {
|
||||||
return toAjax(vehVehicleApplyService.vehicleOwnerReview(req));
|
return toAjax(vehVehicleApplyService.driverReview(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乘客确认上车状态
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("vehicle:vehicleApply:edit")
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/changeStatus")
|
||||||
|
public R<Void> changeStatus(@Validated @RequestBody VehVehicleApplyChangeStatusReq req) {
|
||||||
|
return toAjax(vehVehicleApplyService.changeStatus(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乘客取消申请
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("vehicle:vehicleApply:edit")
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/cancel")
|
||||||
|
public R<Void> cancel(@Validated @RequestBody VehVehicleApplyCancelReq req) {
|
||||||
|
return toAjax(vehVehicleApplyService.cancelApply(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,115 @@
|
|||||||
|
package org.dromara.vehicle.controller.app;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.log.annotation.Log;
|
||||||
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.vehicle.domain.dto.vehicleapply.*;
|
||||||
|
import org.dromara.vehicle.domain.vo.VehVehicleApplyVo;
|
||||||
|
import org.dromara.vehicle.service.IVehVehicleApplyService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乘车申请 app 接口
|
||||||
|
*
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-10-28 10:16
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/vehicle/vehicleApply")
|
||||||
|
public class VehVehicleApplyAppController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IVehVehicleApplyService vehicleApplyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询乘车申请列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<VehVehicleApplyVo> list(VehVehicleApplyQueryReq req, PageQuery pageQuery) {
|
||||||
|
return vehicleApplyService.queryPageList(req, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取乘车申请详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<VehVehicleApplyVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long id) {
|
||||||
|
return R.ok(vehicleApplyService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增乘车申请
|
||||||
|
*/
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated @RequestBody VehVehicleApplyCreateReq req) {
|
||||||
|
return toAjax(vehicleApplyService.insertByBo(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改乘车申请
|
||||||
|
*/
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated @RequestBody VehVehicleApplyUpdateReq req) {
|
||||||
|
return toAjax(vehicleApplyService.updateByBo(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车主审核
|
||||||
|
*/
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/driverReview")
|
||||||
|
public R<Void> driverReview(@Validated @RequestBody VehVehicleApplyReviewReq req) {
|
||||||
|
return toAjax(vehicleApplyService.driverReview(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乘客确认上车状态
|
||||||
|
*/
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/changeStatus")
|
||||||
|
public R<Void> changeStatus(@Validated @RequestBody VehVehicleApplyChangeStatusReq req) {
|
||||||
|
return toAjax(vehicleApplyService.changeStatus(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乘客取消申请
|
||||||
|
*/
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/cancel")
|
||||||
|
public R<Void> cancel(@Validated @RequestBody VehVehicleApplyCancelReq req) {
|
||||||
|
return toAjax(vehicleApplyService.cancelApply(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除乘车申请
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@Log(title = "乘车申请", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] ids) {
|
||||||
|
return toAjax(vehicleApplyService.deleteWithValidByIds(List.of(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
package org.dromara.vehicle.controller.app;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.log.annotation.Log;
|
||||||
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.vehicle.domain.dto.vehicletrip.VehVehicleTripCancelReq;
|
||||||
|
import org.dromara.vehicle.domain.dto.vehicletrip.VehVehicleTripCreateReq;
|
||||||
|
import org.dromara.vehicle.domain.dto.vehicletrip.VehVehicleTripQueryReq;
|
||||||
|
import org.dromara.vehicle.domain.dto.vehicletrip.VehVehicleTripUpdateReq;
|
||||||
|
import org.dromara.vehicle.domain.vo.VehVehicleTripVo;
|
||||||
|
import org.dromara.vehicle.service.IVehVehicleTripService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆出行记录 app 接口
|
||||||
|
*
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-10-28 10:19
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/vehicle/vehicleTrip")
|
||||||
|
public class VehVehicleTripAppController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IVehVehicleTripService vehicleTripService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆出行记录列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<VehVehicleTripVo> list(VehVehicleTripQueryReq req, PageQuery pageQuery) {
|
||||||
|
return vehicleTripService.queryPageList(req, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆出行记录详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<VehVehicleTripVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long id) {
|
||||||
|
return R.ok(vehicleTripService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆出行记录
|
||||||
|
*/
|
||||||
|
@Log(title = "车辆出行记录", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated @RequestBody VehVehicleTripCreateReq req) {
|
||||||
|
return toAjax(vehicleTripService.insertByBo(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆出行记录
|
||||||
|
*/
|
||||||
|
@Log(title = "车辆出行记录", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated @RequestBody VehVehicleTripUpdateReq req) {
|
||||||
|
return toAjax(vehicleTripService.updateByBo(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消车辆出行记录
|
||||||
|
*/
|
||||||
|
@Log(title = "车辆出行记录", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping("/cancel")
|
||||||
|
public R<Void> cancel(@Validated @RequestBody VehVehicleTripCancelReq req) {
|
||||||
|
return toAjax(vehicleTripService.cancel(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除车辆出行记录
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@Log(title = "车辆出行记录", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] ids) {
|
||||||
|
return toAjax(vehicleTripService.deleteWithValidByIds(List.of(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package org.dromara.vehicle.domain.dto.vehicleapply;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-10-28 09:22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class VehVehicleApplyCancelReq implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -3178638460132028254L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "主键不能为空")
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package org.dromara.vehicle.domain.dto.vehicleapply;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-10-28 09:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class VehVehicleApplyChangeStatusReq implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -7509344474542508076L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "主键不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乘车状态
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "乘车状态不能为空")
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
@ -22,16 +22,6 @@ public class VehVehicleApplyUpdateReq implements Serializable {
|
|||||||
@NotNull(message = "主键不能为空")
|
@NotNull(message = "主键不能为空")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
|
||||||
* 项目ID
|
|
||||||
*/
|
|
||||||
private Long projectId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联行程ID
|
|
||||||
*/
|
|
||||||
private Long tripId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 申请人数
|
* 申请人数
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.vehicle.domain.VehVehicleApply;
|
import org.dromara.vehicle.domain.VehVehicleApply;
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyCreateReq;
|
import org.dromara.vehicle.domain.dto.vehicleapply.*;
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyQueryReq;
|
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyReviewReq;
|
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyUpdateReq;
|
|
||||||
import org.dromara.vehicle.domain.vo.VehVehicleApplyVo;
|
import org.dromara.vehicle.domain.vo.VehVehicleApplyVo;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -68,7 +65,23 @@ public interface IVehVehicleApplyService extends IService<VehVehicleApply> {
|
|||||||
* @param req 审核信息
|
* @param req 审核信息
|
||||||
* @return 是否审核成功
|
* @return 是否审核成功
|
||||||
*/
|
*/
|
||||||
Boolean vehicleOwnerReview(VehVehicleApplyReviewReq req);
|
Boolean driverReview(VehVehicleApplyReviewReq req);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改乘车状态
|
||||||
|
*
|
||||||
|
* @param req 修改乘车状态信息
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
Boolean changeStatus(VehVehicleApplyChangeStatusReq req);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消申请
|
||||||
|
*
|
||||||
|
* @param req 取消申请信息
|
||||||
|
* @return 是否取消成功
|
||||||
|
*/
|
||||||
|
Boolean cancelApply(VehVehicleApplyCancelReq req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除乘车申请信息
|
* 校验并批量删除乘车申请信息
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.vehicle.service.impl;
|
package org.dromara.vehicle.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.PhoneUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -11,13 +12,12 @@ import org.dromara.common.core.exception.ServiceException;
|
|||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.vehicle.domain.VehVehicleApply;
|
import org.dromara.vehicle.domain.VehVehicleApply;
|
||||||
import org.dromara.vehicle.domain.VehVehicleTrip;
|
import org.dromara.vehicle.domain.VehVehicleTrip;
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyCreateReq;
|
import org.dromara.vehicle.domain.dto.vehicleapply.*;
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyQueryReq;
|
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyReviewReq;
|
|
||||||
import org.dromara.vehicle.domain.dto.vehicleapply.VehVehicleApplyUpdateReq;
|
|
||||||
import org.dromara.vehicle.domain.enums.VehApplyStatusEnum;
|
import org.dromara.vehicle.domain.enums.VehApplyStatusEnum;
|
||||||
|
import org.dromara.vehicle.domain.enums.VehTripStatusEnum;
|
||||||
import org.dromara.vehicle.domain.vo.VehVehicleApplyVo;
|
import org.dromara.vehicle.domain.vo.VehVehicleApplyVo;
|
||||||
import org.dromara.vehicle.mapper.VehVehicleApplyMapper;
|
import org.dromara.vehicle.mapper.VehVehicleApplyMapper;
|
||||||
import org.dromara.vehicle.service.IVehVehicleApplyService;
|
import org.dromara.vehicle.service.IVehVehicleApplyService;
|
||||||
@ -157,7 +157,7 @@ public class VehVehicleApplyServiceImpl extends ServiceImpl<VehVehicleApplyMappe
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean vehicleOwnerReview(VehVehicleApplyReviewReq req) {
|
public Boolean driverReview(VehVehicleApplyReviewReq req) {
|
||||||
Long id = req.getId();
|
Long id = req.getId();
|
||||||
String status = req.getStatus();
|
String status = req.getStatus();
|
||||||
// 获取数据
|
// 获取数据
|
||||||
@ -178,6 +178,10 @@ public class VehVehicleApplyServiceImpl extends ServiceImpl<VehVehicleApplyMappe
|
|||||||
if (vehicleTrip == null) {
|
if (vehicleTrip == null) {
|
||||||
throw new ServiceException("行程不存在", HttpStatus.NOT_FOUND);
|
throw new ServiceException("行程不存在", HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
// 判断是否有审核权限
|
||||||
|
if (!Objects.equals(vehicleTrip.getCreateBy(), LoginHelper.getUserId())) {
|
||||||
|
throw new ServiceException("没有审核权限", HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
if (Objects.equals(status, VehApplyStatusEnum.CONFIRMED.getValue())) {
|
if (Objects.equals(status, VehApplyStatusEnum.CONFIRMED.getValue())) {
|
||||||
// 修改行程信息
|
// 修改行程信息
|
||||||
int left = vehicleTrip.getLeftSeat() - apply.getPeopleNum();
|
int left = vehicleTrip.getLeftSeat() - apply.getPeopleNum();
|
||||||
@ -209,11 +213,138 @@ public class VehVehicleApplyServiceImpl extends ServiceImpl<VehVehicleApplyMappe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改乘车状态
|
||||||
|
*
|
||||||
|
* @param req 修改乘车状态信息
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean changeStatus(VehVehicleApplyChangeStatusReq req) {
|
||||||
|
Long id = req.getId();
|
||||||
|
String status = req.getStatus();
|
||||||
|
// 获取数据
|
||||||
|
VehVehicleApply apply = this.getById(id);
|
||||||
|
if (apply == null) {
|
||||||
|
throw new ServiceException("数据不存在", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
// 判断是否为申请人
|
||||||
|
if (!Objects.equals(apply.getCreateBy(), LoginHelper.getUserId())) {
|
||||||
|
throw new ServiceException("您没有权限修改该申请", HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
String applyStatus = apply.getStatus();
|
||||||
|
// 状态校验
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.CANCELED.getValue())) {
|
||||||
|
throw new ServiceException("该申请已取消,无法修改", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.APPLYING.getValue())) {
|
||||||
|
throw new ServiceException("该申请正在审核中,无法修改", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.REJECTED.getValue())) {
|
||||||
|
throw new ServiceException("该申请已被拒绝,无法修改", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.ARRIVED.getValue())
|
||||||
|
&& !Objects.equals(status, VehApplyStatusEnum.ALREADY.getValue())) {
|
||||||
|
throw new ServiceException("请先确认上车后再确认到达目的地", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
apply.setStatus(status);
|
||||||
|
boolean updateApply = this.updateById(apply);
|
||||||
|
if (!updateApply) {
|
||||||
|
throw new ServiceException("行程信息更新失败", HttpStatus.ERROR);
|
||||||
|
}
|
||||||
|
// 如果状态为已到达,则修改行程信息
|
||||||
|
if (Objects.equals(status, VehApplyStatusEnum.ALREADY.getValue())) {
|
||||||
|
VehVehicleTrip vehicleTrip = vehicleTripService.getById(apply.getTripId());
|
||||||
|
if (vehicleTrip == null) {
|
||||||
|
throw new ServiceException("行程不存在", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
if (!Objects.equals(vehicleTrip.getTripStatus(), VehTripStatusEnum.COMPLETED.getValue())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Integer leftSeat = vehicleTrip.getLeftSeat();
|
||||||
|
vehicleTrip.setLeftSeat(leftSeat + apply.getPeopleNum());
|
||||||
|
boolean updateTrip = vehicleTripService.updateById(vehicleTrip);
|
||||||
|
if (!updateTrip) {
|
||||||
|
throw new ServiceException("行程信息更新失败", HttpStatus.ERROR);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消申请
|
||||||
|
*
|
||||||
|
* @param req 取消申请信息
|
||||||
|
* @return 是否取消成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean cancelApply(VehVehicleApplyCancelReq req) {
|
||||||
|
Long id = req.getId();
|
||||||
|
VehVehicleApply apply = this.getById(id);
|
||||||
|
if (apply == null) {
|
||||||
|
throw new ServiceException("数据不存在", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
// 判断是否为申请人
|
||||||
|
if (!Objects.equals(apply.getCreateBy(), LoginHelper.getUserId())) {
|
||||||
|
throw new ServiceException("您没有权限取消该申请", HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
String applyStatus = apply.getStatus();
|
||||||
|
// 状态校验
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.CANCELED.getValue())) {
|
||||||
|
throw new ServiceException("该申请已取消,无需取消", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.ARRIVED.getValue())) {
|
||||||
|
throw new ServiceException("该申请已到达目的地,无法取消", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
// 获取行程信息
|
||||||
|
VehVehicleTrip vehicleTrip = vehicleTripService.getById(apply.getTripId());
|
||||||
|
if (vehicleTrip == null) {
|
||||||
|
throw new ServiceException("行程不存在", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
// 需要通知司机的状态
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.CONFIRMED.getValue())
|
||||||
|
|| Objects.equals(applyStatus, VehApplyStatusEnum.ALREADY.getValue())
|
||||||
|
|| Objects.equals(applyStatus, VehApplyStatusEnum.APPLYING.getValue())) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
Long createBy = vehicleTrip.getCreateBy();
|
||||||
|
String title = "有乘客取消预约,请及时查看!";
|
||||||
|
try {
|
||||||
|
chatServerHandler.sendSystemMessageToUser(createBy, title, "4");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("异步发送系统消息失败,用户ID: {}, 消息: {}", createBy, title, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 如果已确认,减少乘车人数
|
||||||
|
if (Objects.equals(applyStatus, VehApplyStatusEnum.CONFIRMED.getValue())
|
||||||
|
|| Objects.equals(applyStatus, VehApplyStatusEnum.ALREADY.getValue())) {
|
||||||
|
Integer leftSeat = vehicleTrip.getLeftSeat();
|
||||||
|
vehicleTrip.setLeftSeat(leftSeat + apply.getPeopleNum());
|
||||||
|
boolean updateTrip = vehicleTripService.updateById(vehicleTrip);
|
||||||
|
if (!updateTrip) {
|
||||||
|
throw new ServiceException("行程信息更新失败", HttpStatus.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply.setStatus(VehApplyStatusEnum.CANCELED.getValue());
|
||||||
|
boolean updateApply = this.updateById(apply);
|
||||||
|
if (!updateApply) {
|
||||||
|
throw new ServiceException("行程信息更新失败", HttpStatus.ERROR);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
private void validEntityBeforeSave(VehVehicleApply entity) {
|
private void validEntityBeforeSave(VehVehicleApply entity) {
|
||||||
//TODO 做一些数据校验,如唯一约束
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
String passengerPhone = entity.getPassengerPhone();
|
||||||
|
if (!PhoneUtil.isPhone(passengerPhone)) {
|
||||||
|
throw new ServiceException("手机号码格式不正确", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +357,18 @@ public class VehVehicleApplyServiceImpl extends ServiceImpl<VehVehicleApplyMappe
|
|||||||
@Override
|
@Override
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
List<VehVehicleApply> applyList = this.listByIds(ids);
|
||||||
|
for (VehVehicleApply apply : applyList) {
|
||||||
|
// 判断是否能删除
|
||||||
|
if (apply.getStatus().equals(VehApplyStatusEnum.CONFIRMED.getValue())
|
||||||
|
|| apply.getStatus().equals(VehApplyStatusEnum.ALREADY.getValue())) {
|
||||||
|
throw new ServiceException("该申请已确认,无法删除", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
// 判断是否为申请人
|
||||||
|
if (!Objects.equals(apply.getCreateBy(), LoginHelper.getUserId())) {
|
||||||
|
throw new ServiceException("您没有权限删除该申请", HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import org.dromara.common.core.constant.HttpStatus;
|
|||||||
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
|
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
|
||||||
import org.dromara.common.core.domain.event.ProcessEvent;
|
import org.dromara.common.core.domain.event.ProcessEvent;
|
||||||
import org.dromara.common.core.domain.event.ProcessTaskEvent;
|
import org.dromara.common.core.domain.event.ProcessTaskEvent;
|
||||||
|
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.utils.ObjectUtils;
|
import org.dromara.common.core.utils.ObjectUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
@ -142,16 +143,27 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
// 判断车辆是否被占用
|
// 判断车辆是否被占用
|
||||||
Long vehicleId = trip.getVehicleId();
|
Long vehicleId = trip.getVehicleId();
|
||||||
if (vehicleId != null) {
|
if (vehicleId != null) {
|
||||||
// 获取车辆信息
|
synchronized (vehicleId.toString()) {
|
||||||
VehVehicleInfo vehicle = vehicleInfoService.getById(vehicleId);
|
// 获取车辆信息
|
||||||
if (vehicle == null) {
|
VehVehicleInfo vehicle = vehicleInfoService.getById(vehicleId);
|
||||||
throw new ServiceException("车辆不存在", HttpStatus.NOT_FOUND);
|
if (vehicle == null) {
|
||||||
}
|
throw new ServiceException("车辆不存在", HttpStatus.NOT_FOUND);
|
||||||
if (!vehicle.getVehicleStatus().equals(VehVehicleInfoStatusEnum.AVAILABLE.getValue())) {
|
}
|
||||||
throw new ServiceException("车辆已被占用", HttpStatus.BAD_REQUEST);
|
if (!vehicle.getVehicleStatus().equals(VehVehicleInfoStatusEnum.AVAILABLE.getValue())) {
|
||||||
|
throw new ServiceException("车辆已被占用", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
// 修改车辆状态
|
||||||
|
vehicle.setVehicleStatus(VehVehicleInfoStatusEnum.IN_USE.getValue());
|
||||||
|
boolean update = vehicleInfoService.updateById(vehicle);
|
||||||
|
if (!update) {
|
||||||
|
throw new ServiceException("修改车辆状态失败");
|
||||||
|
}
|
||||||
|
trip.setPlateNumber(vehicle.getPlateNumber());
|
||||||
|
return this.save(trip);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return this.save(trip);
|
||||||
}
|
}
|
||||||
return this.save(trip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,7 +244,22 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更新数据
|
// 更新数据
|
||||||
return this.updateById(trip);
|
boolean update = this.updateById(trip);
|
||||||
|
if (!update) {
|
||||||
|
throw new ServiceException("修改车辆出行记录失败");
|
||||||
|
}
|
||||||
|
// 释放车辆
|
||||||
|
if (trip.getVehicleId() != null) {
|
||||||
|
VehVehicleInfo vehicle = vehicleInfoService.getById(trip.getVehicleId());
|
||||||
|
if (vehicle != null) {
|
||||||
|
vehicle.setVehicleStatus(VehVehicleInfoStatusEnum.AVAILABLE.getValue());
|
||||||
|
boolean updateVehicle = vehicleInfoService.updateById(vehicle);
|
||||||
|
if (!updateVehicle) {
|
||||||
|
throw new ServiceException("修改车辆状态失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,6 +341,16 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
}
|
}
|
||||||
vehicleTrip.setReviewStatus(processEvent.getStatus());
|
vehicleTrip.setReviewStatus(processEvent.getStatus());
|
||||||
this.updateById(vehicleTrip);
|
this.updateById(vehicleTrip);
|
||||||
|
if (processEvent.getStatus().equals(BusinessStatusEnum.FINISH.getStatus())
|
||||||
|
|| processEvent.getStatus().equals(BusinessStatusEnum.TERMINATION.getStatus())
|
||||||
|
|| processEvent.getStatus().equals(BusinessStatusEnum.INVALID.getStatus())
|
||||||
|
|| processEvent.getStatus().equals(BusinessStatusEnum.CANCEL.getStatus())) {
|
||||||
|
// 获取车辆申请列表
|
||||||
|
VehVehicleInfo vehicleInfo = new VehVehicleInfo();
|
||||||
|
vehicleInfo.setId(vehicleTrip.getVehicleId());
|
||||||
|
vehicleInfo.setVehicleStatus(VehVehicleInfoStatusEnum.AVAILABLE.getValue());
|
||||||
|
vehicleInfoService.updateById(vehicleInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user