摄像头拍摄逻辑,车辆管理
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
package org.dromara.test;
|
package org.dromara.test;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.materials.domain.MatMaterialIssue;
|
import org.dromara.materials.domain.MatMaterialIssue;
|
||||||
@ -17,6 +16,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,12 +49,15 @@ public class MaterialsTest {
|
|||||||
List<MatMaterials> materials = materialsService.lambdaQuery()
|
List<MatMaterials> materials = materialsService.lambdaQuery()
|
||||||
.eq(MatMaterials::getProjectId, PROJECT_ID)
|
.eq(MatMaterials::getProjectId, PROJECT_ID)
|
||||||
.list();
|
.list();
|
||||||
|
Set<Long> materialIds = materials.stream().map(MatMaterials::getId).collect(Collectors.toSet());
|
||||||
|
List<MatMaterialsInventory> inventoryList = materialsInventoryService.lambdaQuery()
|
||||||
|
.in(MatMaterialsInventory::getMaterialsId, materialIds)
|
||||||
|
.eq(MatMaterialsInventory::getOutPut, MatMaterialsInventoryOutPutEnum.OUT.getValue())
|
||||||
|
.list();
|
||||||
Map<String, List<MatMaterials>> map = materials.stream()
|
Map<String, List<MatMaterials>> map = materials.stream()
|
||||||
.collect(Collectors.groupingBy(MatMaterials::getFormCode));
|
.collect(Collectors.groupingBy(MatMaterials::getFormCode));
|
||||||
for (Map.Entry<String, List<MatMaterials>> entry : map.entrySet()) {
|
|
||||||
String key = entry.getKey();
|
|
||||||
List<MatMaterials> value = entry.getValue();
|
|
||||||
}
|
|
||||||
for (MatMaterials material : materials) {
|
for (MatMaterials material : materials) {
|
||||||
String formCode = material.getFormCode();
|
String formCode = material.getFormCode();
|
||||||
// 查看入库数据
|
// 查看入库数据
|
||||||
@ -62,13 +65,13 @@ public class MaterialsTest {
|
|||||||
.eq(MatMaterialReceive::getFormCode, formCode)
|
.eq(MatMaterialReceive::getFormCode, formCode)
|
||||||
.one();
|
.one();
|
||||||
// 查看出库数据
|
// 查看出库数据
|
||||||
List<MatMaterialsInventory> inventoryList = materialsInventoryService.lambdaQuery()
|
/* List<MatMaterialsInventory> inventoryList = materialsInventoryService.lambdaQuery()
|
||||||
.eq(MatMaterialsInventory::getMaterialsId, material.getId())
|
.eq(MatMaterialsInventory::getMaterialsId, material.getId())
|
||||||
.eq(MatMaterialsInventory::getOutPut, MatMaterialsInventoryOutPutEnum.OUT.getValue())
|
.eq(MatMaterialsInventory::getOutPut, MatMaterialsInventoryOutPutEnum.OUT.getValue())
|
||||||
.list();
|
.list();
|
||||||
if (CollUtil.isEmpty(inventoryList)) {
|
if (CollUtil.isEmpty(inventoryList)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}*/
|
||||||
// 创建领料出库数据
|
// 创建领料出库数据
|
||||||
List<MatMaterialIssue> issueList = inventoryList.stream().map(inventory -> {
|
List<MatMaterialIssue> issueList = inventoryList.stream().map(inventory -> {
|
||||||
MatMaterialIssue issue = new MatMaterialIssue();
|
MatMaterialIssue issue = new MatMaterialIssue();
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.job.cycle;
|
package org.dromara.job.cycle;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.manager.ys7manager.Ys7Manager;
|
import org.dromara.manager.ys7manager.Ys7Manager;
|
||||||
@ -10,6 +11,8 @@ import org.dromara.other.domain.enums.OthDeviceStatusEnum;
|
|||||||
import org.dromara.other.service.IOthDevicePresetService;
|
import org.dromara.other.service.IOthDevicePresetService;
|
||||||
import org.dromara.other.service.IOthYs7DeviceImgService;
|
import org.dromara.other.service.IOthYs7DeviceImgService;
|
||||||
import org.dromara.other.service.IOthYs7DeviceService;
|
import org.dromara.other.service.IOthYs7DeviceService;
|
||||||
|
import org.dromara.safety.domain.HseViolationLevel;
|
||||||
|
import org.dromara.safety.service.IHseViolationLevelService;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -40,6 +43,9 @@ public class IncSyncYs7DeviceCapturePicData {
|
|||||||
@Resource
|
@Resource
|
||||||
private IOthYs7DeviceImgService ys7DeviceImgService;
|
private IOthYs7DeviceImgService ys7DeviceImgService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IHseViolationLevelService violationLevelService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private Ys7Manager ys7Manager;
|
private Ys7Manager ys7Manager;
|
||||||
|
|
||||||
@ -49,11 +55,21 @@ public class IncSyncYs7DeviceCapturePicData {
|
|||||||
@Scheduled(cron = "0 */10 7-19 * * ?")
|
@Scheduled(cron = "0 */10 7-19 * * ?")
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("执行萤石设备抓拍图片");
|
log.info("执行萤石设备抓拍图片");
|
||||||
|
// 获取所有项目的等级信息
|
||||||
|
List<HseViolationLevel> allLevel = violationLevelService.lambdaQuery()
|
||||||
|
.select(HseViolationLevel::getId, HseViolationLevel::getProjectId)
|
||||||
|
.list();
|
||||||
|
Set<Long> projectIds = allLevel.stream().map(HseViolationLevel::getProjectId).collect(Collectors.toSet());
|
||||||
// 查询所有在线的摄像头设备,仅获取必要字段
|
// 查询所有在线的摄像头设备,仅获取必要字段
|
||||||
List<OthYs7Device> deviceList = ys7DeviceService.lambdaQuery()
|
List<OthYs7Device> deviceList = ys7DeviceService.lambdaQuery()
|
||||||
.select(OthYs7Device::getId, OthYs7Device::getDeviceSerial, OthYs7Device::getDeviceName)
|
.select(OthYs7Device::getId, OthYs7Device::getDeviceSerial, OthYs7Device::getDeviceName)
|
||||||
|
.in(OthYs7Device::getProjectId, projectIds) // 仅获取设置了安全等级项目的摄像头
|
||||||
.eq(OthYs7Device::getStatus, OthDeviceStatusEnum.ONLINE.getValue())
|
.eq(OthYs7Device::getStatus, OthDeviceStatusEnum.ONLINE.getValue())
|
||||||
.list();
|
.list();
|
||||||
|
if (CollUtil.isEmpty(deviceList)) {
|
||||||
|
log.info("没有可拍摄的摄像头设备");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 提取设备序列号用于后续查询预置位
|
// 提取设备序列号用于后续查询预置位
|
||||||
List<String> deviceSerialList = deviceList.stream()
|
List<String> deviceSerialList = deviceList.stream()
|
||||||
.map(OthYs7Device::getDeviceSerial).toList();
|
.map(OthYs7Device::getDeviceSerial).toList();
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package org.dromara.manager.recognizermanager.enums;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +49,15 @@ public enum RecognizerTypeEnum {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RecognizerTypeEnum fromCode(String code) {
|
||||||
|
for (RecognizerTypeEnum type : RecognizerTypeEnum.values()) {
|
||||||
|
if (type.getCode().equals(code)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将多个 RecognizerTypeEnum 拼接为接口识别参数字符串(","分隔)
|
* 将多个 RecognizerTypeEnum 拼接为接口识别参数字符串(","分隔)
|
||||||
*/
|
*/
|
||||||
@ -60,4 +70,18 @@ public enum RecognizerTypeEnum {
|
|||||||
.collect(Collectors.joining(","));
|
.collect(Collectors.joining(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将多个 code 转换为 RecognizerTypeEnum
|
||||||
|
*
|
||||||
|
* @param codes code列表
|
||||||
|
* @return RecognizerTypeEnum列表
|
||||||
|
*/
|
||||||
|
public static List<RecognizerTypeEnum> listFromCodes(List<String> codes) {
|
||||||
|
return codes.stream()
|
||||||
|
.map(RecognizerTypeEnum::fromCode)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,6 +68,11 @@ public class MatMaterialIssue extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String issueUnit;
|
private String issueUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领料单位id
|
||||||
|
*/
|
||||||
|
private Long issueUnitId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领用人
|
* 领用人
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -270,7 +270,9 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
|
|||||||
inventory.setOutPutTime(new Date());
|
inventory.setOutPutTime(new Date());
|
||||||
inventory.setResidue(item.getRemainingQuantity().longValue());
|
inventory.setResidue(item.getRemainingQuantity().longValue());
|
||||||
inventory.setOperator(nickname);
|
inventory.setOperator(nickname);
|
||||||
|
inventory.setOperatorId(LoginHelper.getUserId());
|
||||||
inventory.setRecipient(materialIssue.getIssueUnit());
|
inventory.setRecipient(materialIssue.getIssueUnit());
|
||||||
|
inventory.setRecipientId(materialIssue.getIssueUnitId());
|
||||||
inventory.setShipper(materialIssue.getShipper());
|
inventory.setShipper(materialIssue.getShipper());
|
||||||
inventory.setMaterialsId(item.getMaterialsId());
|
inventory.setMaterialsId(item.getMaterialsId());
|
||||||
inventory.setProjectId(materialIssue.getProjectId());
|
inventory.setProjectId(materialIssue.getProjectId());
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class WebSocketConfig {
|
public class WebSocketConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public ServerEndpointExporter serverEndpointExporter() {
|
public ServerEndpointExporter serverEndpointExporter() {
|
||||||
|
|||||||
@ -31,9 +31,11 @@ import org.dromara.other.domain.vo.ys7deviceimg.OthYs7DeviceImgVo;
|
|||||||
import org.dromara.other.mapper.OthYs7DeviceImgMapper;
|
import org.dromara.other.mapper.OthYs7DeviceImgMapper;
|
||||||
import org.dromara.other.service.IOthYs7DeviceImgService;
|
import org.dromara.other.service.IOthYs7DeviceImgService;
|
||||||
import org.dromara.other.service.IOthYs7DeviceService;
|
import org.dromara.other.service.IOthYs7DeviceService;
|
||||||
|
import org.dromara.safety.domain.HseViolationLevel;
|
||||||
import org.dromara.safety.domain.dto.recognizerecord.HseRecognizeRecordCreateDto;
|
import org.dromara.safety.domain.dto.recognizerecord.HseRecognizeRecordCreateDto;
|
||||||
import org.dromara.safety.domain.enums.HseRecordCategoryEnum;
|
import org.dromara.safety.domain.enums.HseRecordCategoryEnum;
|
||||||
import org.dromara.safety.service.IHseRecognizeRecordService;
|
import org.dromara.safety.service.IHseRecognizeRecordService;
|
||||||
|
import org.dromara.safety.service.IHseViolationLevelService;
|
||||||
import org.dromara.system.domain.vo.SysOssUploadVo;
|
import org.dromara.system.domain.vo.SysOssUploadVo;
|
||||||
import org.dromara.system.service.ISysOssService;
|
import org.dromara.system.service.ISysOssService;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@ -45,6 +47,7 @@ import java.time.LocalDate;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 萤石摄像头图片Service业务层处理
|
* 萤石摄像头图片Service业务层处理
|
||||||
@ -66,6 +69,9 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl<OthYs7DeviceImgMappe
|
|||||||
@Resource
|
@Resource
|
||||||
private IHseRecognizeRecordService recognizeRecordService;
|
private IHseRecognizeRecordService recognizeRecordService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IHseViolationLevelService violationLevelService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IOthYs7DeviceService ys7DeviceService;
|
private IOthYs7DeviceService ys7DeviceService;
|
||||||
|
|
||||||
@ -206,6 +212,33 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl<OthYs7DeviceImgMappe
|
|||||||
public void saveCapturePic(List<OthYs7DeviceImgCreateByCapture> imgList) {
|
public void saveCapturePic(List<OthYs7DeviceImgCreateByCapture> imgList) {
|
||||||
List<OthYs7DeviceImg> saveList = new ArrayList<>();
|
List<OthYs7DeviceImg> saveList = new ArrayList<>();
|
||||||
List<HseRecognizeRecordCreateDto> recordList = new ArrayList<>();
|
List<HseRecognizeRecordCreateDto> recordList = new ArrayList<>();
|
||||||
|
// 获取项目id
|
||||||
|
Set<Long> projectIds = imgList.stream().map(OthYs7DeviceImgCreateByCapture::getProjectId).collect(Collectors.toSet());
|
||||||
|
// 获取安全等级设置
|
||||||
|
List<HseViolationLevel> levelList = violationLevelService.lambdaQuery()
|
||||||
|
.in(HseViolationLevel::getProjectId, projectIds)
|
||||||
|
.list();
|
||||||
|
if (CollUtil.isEmpty(levelList)) {
|
||||||
|
log.error("未设置安全等级");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<Long, List<RecognizerTypeEnum>> level = new HashMap<>();
|
||||||
|
Map<Long, List<HseViolationLevel>> levelMap = levelList.stream()
|
||||||
|
.collect(Collectors.groupingBy(HseViolationLevel::getProjectId));
|
||||||
|
for (Map.Entry<Long, List<HseViolationLevel>> entry : levelMap.entrySet()) {
|
||||||
|
List<RecognizerTypeEnum> recognizerTypeEnums = entry.getValue().stream().map(l -> {
|
||||||
|
List<String> levels = StringUtils.splitList(l.getViolationType());
|
||||||
|
return RecognizerTypeEnum.listFromCodes(levels);
|
||||||
|
}).filter(CollUtil::isNotEmpty)
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
level.put(entry.getKey(), recognizerTypeEnums);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(level)) {
|
||||||
|
log.error("未设置安全等级");
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (OthYs7DeviceImgCreateByCapture img : imgList) {
|
for (OthYs7DeviceImgCreateByCapture img : imgList) {
|
||||||
OthYs7DeviceImg othYs7DeviceImg = new OthYs7DeviceImg();
|
OthYs7DeviceImg othYs7DeviceImg = new OthYs7DeviceImg();
|
||||||
String url = img.getUrl();
|
String url = img.getUrl();
|
||||||
@ -220,17 +253,11 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl<OthYs7DeviceImgMappe
|
|||||||
othYs7DeviceImg.setDeviceName(img.getDeviceName());
|
othYs7DeviceImg.setDeviceName(img.getDeviceName());
|
||||||
othYs7DeviceImg.setUrl(ossUrl);
|
othYs7DeviceImg.setUrl(ossUrl);
|
||||||
// 将抓取的图片进行识别
|
// 将抓取的图片进行识别
|
||||||
// List<RecognizerTypeEnum> recTypes = List.of(RecognizerTypeEnum.NO_EQUIPMENT,
|
List<RecognizerTypeEnum> recTypes = level.get(img.getProjectId());
|
||||||
// RecognizerTypeEnum.NO_HELMET,
|
if (CollUtil.isEmpty(recTypes)) {
|
||||||
// RecognizerTypeEnum.NO_EQUIPMENT,
|
log.error("未设置安全等级");
|
||||||
// RecognizerTypeEnum.NO_VEST,
|
continue;
|
||||||
// RecognizerTypeEnum.SMOKE,
|
}
|
||||||
// RecognizerTypeEnum.FIRE);
|
|
||||||
List<RecognizerTypeEnum> recTypes = List.of(
|
|
||||||
RecognizerTypeEnum.COLUMN,
|
|
||||||
RecognizerTypeEnum.PANEL,
|
|
||||||
RecognizerTypeEnum.BRACKET,
|
|
||||||
RecognizerTypeEnum.HOLE);
|
|
||||||
RecognizeVo recognizeVo = null;
|
RecognizeVo recognizeVo = null;
|
||||||
try {
|
try {
|
||||||
recognizeVo = recognizerManager.recognize(ossUrl, recTypes);
|
recognizeVo = recognizerManager.recognize(ossUrl, recTypes);
|
||||||
|
|||||||
@ -0,0 +1,85 @@
|
|||||||
|
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.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
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.bo.VehVehicleInfoBo;
|
||||||
|
import org.dromara.vehicle.domain.vo.VehVehicleInfoVo;
|
||||||
|
import org.dromara.vehicle.service.IVehVehicleInfoService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-10-30 11:51
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/vehicle/vehicleInfo")
|
||||||
|
public class VehVehicleInfoAppController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IVehVehicleInfoService vehicleInfoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆信息列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<VehVehicleInfoVo> list(VehVehicleInfoBo bo, PageQuery pageQuery) {
|
||||||
|
return vehicleInfoService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆信息详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<VehVehicleInfoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long id) {
|
||||||
|
return R.ok(vehicleInfoService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆信息
|
||||||
|
*/
|
||||||
|
@Log(title = "车辆信息", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody VehVehicleInfoBo bo) {
|
||||||
|
return toAjax(vehicleInfoService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆信息
|
||||||
|
*/
|
||||||
|
@Log(title = "车辆信息", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody VehVehicleInfoBo bo) {
|
||||||
|
return toAjax(vehicleInfoService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除车辆信息
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@Log(title = "车辆信息", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] ids) {
|
||||||
|
return toAjax(vehicleInfoService.deleteWithValidByIds(List.of(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -46,7 +46,7 @@ public class VehVehicleTripAppController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/myList")
|
@GetMapping("/myList")
|
||||||
public R<List<VehVehicleTripMyVo>> queryMyList(VehVehicleTripMyQueryReq req) {
|
public R<List<VehVehicleTripMyVo>> queryMyList(VehVehicleTripMyQueryReq req) {
|
||||||
return R.ok(vehicleTripService.queryMyList(req));
|
return R.ok(vehicleTripService.queryMyAppList(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -61,22 +61,22 @@ public class VehVehicleApply extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 出发地经度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
private String startLat;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
private String startLng;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 乘车状态
|
* 乘车状态
|
||||||
|
|||||||
@ -65,22 +65,22 @@ public class VehVehicleTrip extends BaseEntity {
|
|||||||
private String endPlace;
|
private String endPlace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地经度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
private String startLat;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
private String startLng;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
private String endLat;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
private String endLng;
|
private String endLng;
|
||||||
|
|
||||||
|
|||||||
@ -54,24 +54,24 @@ public class VehVehicleApplyCreateReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 出发地经度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
private String startLat;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
private String startLng;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "目的地经度不能为空")
|
@NotBlank(message = "目的地经度不能为空")
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "目的地纬度不能为空")
|
@NotBlank(message = "目的地纬度不能为空")
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
|
|||||||
@ -45,22 +45,22 @@ public class VehVehicleApplyUpdateReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 出发地经度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
private String startLat;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
private String startLng;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
|
|||||||
@ -59,25 +59,25 @@ public class VehVehicleTripCreateReq implements Serializable {
|
|||||||
* 出发地经度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "出发地经度不能为空")
|
@NotBlank(message = "出发地经度不能为空")
|
||||||
private String startLat;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "出发地纬度不能为空")
|
@NotBlank(message = "出发地纬度不能为空")
|
||||||
private String startLng;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "目的地经度不能为空")
|
@NotBlank(message = "目的地经度不能为空")
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "目的地纬度不能为空")
|
@NotBlank(message = "目的地纬度不能为空")
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划出发时间
|
* 计划出发时间
|
||||||
|
|||||||
@ -17,7 +17,9 @@ public class VehVehicleTripMyQueryReq implements Serializable {
|
|||||||
private static final long serialVersionUID = 4251601419123102085L;
|
private static final long serialVersionUID = 4251601419123102085L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询类型(1待出行 2预约中 3已完成)
|
* 查询类型
|
||||||
|
* web(1待出行 2预约中 3已完成)
|
||||||
|
* app(0待出行 1进行中 2预约中 3已完成)
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "查询类型不能为空")
|
@NotBlank(message = "查询类型不能为空")
|
||||||
private String type;
|
private String type;
|
||||||
|
|||||||
@ -29,12 +29,12 @@ public class VehVehicleTripQueryReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划出发时间
|
* 计划出发时间
|
||||||
|
|||||||
@ -61,22 +61,22 @@ public class VehVehicleTripUpdateReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 出发地经度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
private String startLat;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
private String startLng;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划出发时间
|
* 计划出发时间
|
||||||
|
|||||||
@ -75,25 +75,25 @@ public class VehVehicleApplyVo implements Serializable {
|
|||||||
* 出发地经度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "出发地经度")
|
@ExcelProperty(value = "出发地经度")
|
||||||
private String startLat;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "出发地纬度")
|
@ExcelProperty(value = "出发地纬度")
|
||||||
private String startLng;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "目的地经度")
|
@ExcelProperty(value = "目的地经度")
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "目的地纬度")
|
@ExcelProperty(value = "目的地纬度")
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 乘车状态
|
* 乘车状态
|
||||||
|
|||||||
@ -81,25 +81,25 @@ public class VehVehicleTripVo implements Serializable {
|
|||||||
* 出发地经度
|
* 出发地经度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "出发地经度")
|
@ExcelProperty(value = "出发地经度")
|
||||||
private String startLat;
|
private String startLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出发地纬度
|
* 出发地纬度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "出发地纬度")
|
@ExcelProperty(value = "出发地纬度")
|
||||||
private String startLng;
|
private String startLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地经度
|
* 目的地经度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "目的地经度")
|
@ExcelProperty(value = "目的地经度")
|
||||||
private String endLat;
|
private String endLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目的地纬度
|
* 目的地纬度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "目的地纬度")
|
@ExcelProperty(value = "目的地纬度")
|
||||||
private String endLng;
|
private String endLat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划出发时间
|
* 计划出发时间
|
||||||
@ -155,6 +155,11 @@ public class VehVehicleTripVo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String distanceScore;
|
private String distanceScore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private String time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间评分
|
* 时间评分
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -44,6 +44,14 @@ public interface IVehVehicleTripService extends IService<VehVehicleTrip> {
|
|||||||
*/
|
*/
|
||||||
List<VehVehicleTripMyVo> queryMyList(VehVehicleTripMyQueryReq req);
|
List<VehVehicleTripMyVo> queryMyList(VehVehicleTripMyQueryReq req);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前用户车辆出行记录列表
|
||||||
|
*
|
||||||
|
* @param req 列表查询条件
|
||||||
|
* @return 当前用户车辆出行记录列表
|
||||||
|
*/
|
||||||
|
List<VehVehicleTripMyVo> queryMyAppList(VehVehicleTripMyQueryReq req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询符合条件的车辆出行记录列表
|
* 查询符合条件的车辆出行记录列表
|
||||||
*
|
*
|
||||||
|
|||||||
@ -14,6 +14,7 @@ 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.enums.BusinessStatusEnum;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.utils.DateUtils;
|
||||||
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;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
@ -96,6 +97,16 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
&& ObjectUtils.isNotNull(req.getStartTime()) && ObjectUtils.isNotNull(req.getPeopleNum())
|
&& ObjectUtils.isNotNull(req.getStartTime()) && ObjectUtils.isNotNull(req.getPeopleNum())
|
||||||
&& req.getPeopleNum() >= 1) {
|
&& req.getPeopleNum() >= 1) {
|
||||||
result = baseMapper.selectVehicleTripPage(pageQuery.build(), req);
|
result = baseMapper.selectVehicleTripPage(pageQuery.build(), req);
|
||||||
|
result.getRecords().forEach(trip -> {
|
||||||
|
Date startTime = trip.getStartTime();
|
||||||
|
Date date = DateUtils.toDate(req.getStartTime());
|
||||||
|
// 判断日期
|
||||||
|
if (date.after(startTime)) {
|
||||||
|
DateUtils.getTimeDifference(startTime, date);
|
||||||
|
} else {
|
||||||
|
DateUtils.getTimeDifference(date, startTime);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
result = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(req));
|
result = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(req));
|
||||||
}
|
}
|
||||||
@ -115,8 +126,6 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
throw new ServiceException("请先登录", HttpStatus.UNAUTHORIZED);
|
throw new ServiceException("请先登录", HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
// 查询数据
|
|
||||||
List<VehVehicleTrip> tripList = new ArrayList<>();
|
|
||||||
// --- 一、查询当前用户创建的行程 ---
|
// --- 一、查询当前用户创建的行程 ---
|
||||||
List<VehVehicleTrip> createdTrips = this.lambdaQuery()
|
List<VehVehicleTrip> createdTrips = this.lambdaQuery()
|
||||||
.eq(VehVehicleTrip::getCreateBy, userId)
|
.eq(VehVehicleTrip::getCreateBy, userId)
|
||||||
@ -125,10 +134,6 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
.ne("2".equals(type), VehVehicleTrip::getReviewStatus, BusinessStatusEnum.FINISH.getStatus())
|
.ne("2".equals(type), VehVehicleTrip::getReviewStatus, BusinessStatusEnum.FINISH.getStatus())
|
||||||
.eq("3".equals(type), VehVehicleTrip::getTripStatus, VehTripStatusEnum.COMPLETED.getValue())
|
.eq("3".equals(type), VehVehicleTrip::getTripStatus, VehTripStatusEnum.COMPLETED.getValue())
|
||||||
.list();
|
.list();
|
||||||
// 收集行程id
|
|
||||||
Set<Long> tripIds = createdTrips.stream()
|
|
||||||
.map(VehVehicleTrip::getId)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
// --- 二、查询当前用户作为乘客的申请 ---
|
// --- 二、查询当前用户作为乘客的申请 ---
|
||||||
List<VehVehicleApply> userApplies = vehicleApplyService.lambdaQuery()
|
List<VehVehicleApply> userApplies = vehicleApplyService.lambdaQuery()
|
||||||
.eq(VehVehicleApply::getCreateBy, userId)
|
.eq(VehVehicleApply::getCreateBy, userId)
|
||||||
@ -136,57 +141,42 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
.notIn("2".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.ARRIVED.getValue(), VehApplyStatusEnum.ALREADY.getValue())
|
.notIn("2".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.ARRIVED.getValue(), VehApplyStatusEnum.ALREADY.getValue())
|
||||||
.eq("3".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.ARRIVED.getValue())
|
.eq("3".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.ARRIVED.getValue())
|
||||||
.list();
|
.list();
|
||||||
List<VehVehicleApply> applyList = new ArrayList<>(userApplies);
|
|
||||||
// 收集申请对应的行程id
|
|
||||||
tripIds.addAll(userApplies.stream()
|
|
||||||
.map(VehVehicleApply::getTripId)
|
|
||||||
.collect(Collectors.toSet()));
|
|
||||||
// 收集申请id
|
|
||||||
Set<Long> applyIds = userApplies.stream()
|
|
||||||
.map(VehVehicleApply::getId)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
// --- 三、查询这些行程Id对应的行程(合并创建的与乘坐的) ---
|
|
||||||
if (CollUtil.isNotEmpty(tripIds)) {
|
|
||||||
List<VehVehicleTrip> trips = this.lambdaQuery()
|
|
||||||
.in(VehVehicleTrip::getId, tripIds)
|
|
||||||
.list();
|
|
||||||
tripList.addAll(trips);
|
|
||||||
}
|
|
||||||
// --- 四、查询这些行程对应的有效申请 ---
|
|
||||||
if (CollUtil.isNotEmpty(tripIds)) {
|
|
||||||
List<VehVehicleApply> applies = vehicleApplyService.lambdaQuery()
|
|
||||||
.in(VehVehicleApply::getTripId, tripIds)
|
|
||||||
.notIn(CollUtil.isNotEmpty(applyIds), VehVehicleApply::getId, applyIds)
|
|
||||||
.ne(VehVehicleApply::getStatus, VehApplyStatusEnum.CANCELED.getValue())
|
|
||||||
.list();
|
|
||||||
applyList.addAll(applies);
|
|
||||||
}
|
|
||||||
// 整合数据
|
// 整合数据
|
||||||
List<VehVehicleTripMyVo> result = new ArrayList<>();
|
return buildTripMyVoList(createdTrips, userApplies, userId);
|
||||||
if (CollUtil.isEmpty(tripList)) {
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
List<VehVehicleTripMyVo> tripMyVos = new ArrayList<>(tripList.stream().map(trip -> {
|
|
||||||
VehVehicleTripMyVo tripMyVo = new VehVehicleTripMyVo();
|
/**
|
||||||
BeanUtils.copyProperties(trip, tripMyVo);
|
* 查询当前用户车辆出行记录列表
|
||||||
List<VehVehicleApply> list = applyList.stream()
|
*
|
||||||
.filter(apply -> apply.getTripId().equals(trip.getId()))
|
* @param req 列表查询条件
|
||||||
.toList();
|
* @return 当前用户车辆出行记录列表
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
*/
|
||||||
// 封装数据
|
@Override
|
||||||
List<VehVehicleApplyVo> applyVoList = list.stream().map(apply -> {
|
public List<VehVehicleTripMyVo> queryMyAppList(VehVehicleTripMyQueryReq req) {
|
||||||
VehVehicleApplyVo applyVo = new VehVehicleApplyVo();
|
String type = req.getType();
|
||||||
BeanUtils.copyProperties(apply, applyVo);
|
Long userId = LoginHelper.getUserId();
|
||||||
return applyVo;
|
if (userId == null) {
|
||||||
}).toList();
|
throw new ServiceException("请先登录", HttpStatus.UNAUTHORIZED);
|
||||||
tripMyVo.setApplyList(applyVoList);
|
|
||||||
}
|
}
|
||||||
tripMyVo.setIsVehicleOwner(trip.getCreateBy().equals(userId) ? 1 : 0);
|
// --- 一、查询当前用户创建的行程 ---
|
||||||
return tripMyVo;
|
List<VehVehicleTrip> createdTrips = this.lambdaQuery()
|
||||||
}).toList());
|
.eq(VehVehicleTrip::getCreateBy, userId)
|
||||||
// 根据出行时间排序
|
.eq("0".equals(type) || "2".equals(type), VehVehicleTrip::getTripStatus, VehTripStatusEnum.READY_DEPART.getValue())
|
||||||
tripMyVos.sort(Comparator.comparing(VehVehicleTripMyVo::getStartTime));
|
.eq("0".equals(type), VehVehicleTrip::getReviewStatus, BusinessStatusEnum.FINISH.getStatus())
|
||||||
return tripMyVos;
|
.eq("1".equals(type), VehVehicleTrip::getTripStatus, VehTripStatusEnum.UNDERWAY.getValue())
|
||||||
|
.ne("2".equals(type), VehVehicleTrip::getReviewStatus, BusinessStatusEnum.FINISH.getStatus())
|
||||||
|
.eq("3".equals(type), VehVehicleTrip::getTripStatus, VehTripStatusEnum.COMPLETED.getValue())
|
||||||
|
.list();
|
||||||
|
// --- 二、查询当前用户作为乘客的申请 ---
|
||||||
|
List<VehVehicleApply> userApplies = vehicleApplyService.lambdaQuery()
|
||||||
|
.eq(VehVehicleApply::getCreateBy, userId)
|
||||||
|
.eq("0".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.CONFIRMED.getValue())
|
||||||
|
.eq("1".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.ALREADY.getValue())
|
||||||
|
.notIn("2".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.ARRIVED.getValue(), VehApplyStatusEnum.ALREADY.getValue())
|
||||||
|
.eq("3".equals(type), VehVehicleApply::getStatus, VehApplyStatusEnum.ARRIVED.getValue())
|
||||||
|
.list();
|
||||||
|
// 整合数据
|
||||||
|
return buildTripMyVoList(createdTrips, userApplies, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -475,6 +465,77 @@ public class VehVehicleTripServiceImpl extends ServiceImpl<VehVehicleTripMapper,
|
|||||||
return this.removeBatchByIds(ids);
|
return this.removeBatchByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建用户行程及其对应申请的展示列表
|
||||||
|
*
|
||||||
|
* @param createdTrips 用户创建的行程列表
|
||||||
|
* @param userApplies 用户申请列表
|
||||||
|
* @param userId 当前用户ID
|
||||||
|
* @return 组装后的 VehVehicleTripMyVo 列表
|
||||||
|
*/
|
||||||
|
private List<VehVehicleTripMyVo> buildTripMyVoList(List<VehVehicleTrip> createdTrips,
|
||||||
|
List<VehVehicleApply> userApplies,
|
||||||
|
Long userId) {
|
||||||
|
// 收集行程id
|
||||||
|
Set<Long> tripIds = createdTrips.stream()
|
||||||
|
.map(VehVehicleTrip::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
List<VehVehicleApply> applyList = new ArrayList<>(userApplies);
|
||||||
|
// 收集申请对应的行程id
|
||||||
|
tripIds.addAll(userApplies.stream()
|
||||||
|
.map(VehVehicleApply::getTripId)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
// 收集申请id
|
||||||
|
Set<Long> applyIds = userApplies.stream()
|
||||||
|
.map(VehVehicleApply::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
// --- 三、查询这些行程Id对应的行程(合并创建的与乘坐的) ---
|
||||||
|
List<VehVehicleTrip> tripList = new ArrayList<>();
|
||||||
|
if (CollUtil.isNotEmpty(tripIds)) {
|
||||||
|
List<VehVehicleTrip> trips = this.lambdaQuery()
|
||||||
|
.in(VehVehicleTrip::getId, tripIds)
|
||||||
|
.list();
|
||||||
|
tripList.addAll(trips);
|
||||||
|
}
|
||||||
|
// --- 四、查询这些行程对应的有效申请 ---
|
||||||
|
if (CollUtil.isNotEmpty(tripIds)) {
|
||||||
|
List<VehVehicleApply> applies = vehicleApplyService.lambdaQuery()
|
||||||
|
.in(VehVehicleApply::getTripId, tripIds)
|
||||||
|
.notIn(CollUtil.isNotEmpty(applyIds), VehVehicleApply::getId, applyIds)
|
||||||
|
.ne(VehVehicleApply::getStatus, VehApplyStatusEnum.CANCELED.getValue())
|
||||||
|
.list();
|
||||||
|
applyList.addAll(applies);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(tripList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return tripList.stream().map(trip -> {
|
||||||
|
VehVehicleTripMyVo tripMyVo = new VehVehicleTripMyVo();
|
||||||
|
BeanUtils.copyProperties(trip, tripMyVo);
|
||||||
|
|
||||||
|
// 找出对应申请
|
||||||
|
List<VehVehicleApply> relatedApplies = applyList.stream()
|
||||||
|
.filter(apply -> apply.getTripId().equals(trip.getId()))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(relatedApplies)) {
|
||||||
|
List<VehVehicleApplyVo> applyVoList = relatedApplies.stream().map(apply -> {
|
||||||
|
VehVehicleApplyVo applyVo = new VehVehicleApplyVo();
|
||||||
|
BeanUtils.copyProperties(apply, applyVo);
|
||||||
|
return applyVo;
|
||||||
|
}).toList();
|
||||||
|
tripMyVo.setApplyList(applyVoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否为行程发起人
|
||||||
|
tripMyVo.setIsVehicleOwner(trip.getCreateBy().equals(userId) ? 1 : 0);
|
||||||
|
|
||||||
|
return tripMyVo;
|
||||||
|
}).sorted(Comparator.comparing(VehVehicleTripMyVo::getStartTime))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
|
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
|
||||||
* 正常使用只需#processEvent.flowCode=='leave1'
|
* 正常使用只需#processEvent.flowCode=='leave1'
|
||||||
|
|||||||
@ -14,10 +14,10 @@
|
|||||||
trip_reason,
|
trip_reason,
|
||||||
start_place,
|
start_place,
|
||||||
end_place,
|
end_place,
|
||||||
start_lat,
|
|
||||||
start_lng,
|
start_lng,
|
||||||
end_lat,
|
start_lat,
|
||||||
end_lng,
|
end_lng,
|
||||||
|
end_lat,
|
||||||
start_time,
|
start_time,
|
||||||
end_time,
|
end_time,
|
||||||
people_num,
|
people_num,
|
||||||
@ -51,7 +51,7 @@
|
|||||||
-- 3. 时间评分(0-100)
|
-- 3. 时间评分(0-100)
|
||||||
ROUND(
|
ROUND(
|
||||||
GREATEST(0, LEAST(100,
|
GREATEST(0, LEAST(100,
|
||||||
100 - ABS(TIMESTAMPDIFF(MINUTE, start_time, #{req.startTime})) / (60 / 100)
|
100 - ABS(TIMESTAMPDIFF(MINUTE, start_time, #{req.startTime})) / (120 / 100)
|
||||||
)), 2
|
)), 2
|
||||||
) AS time_score,
|
) AS time_score,
|
||||||
|
|
||||||
@ -73,7 +73,7 @@
|
|||||||
)) * 0.5)
|
)) * 0.5)
|
||||||
+
|
+
|
||||||
(GREATEST(0, LEAST(100,
|
(GREATEST(0, LEAST(100,
|
||||||
100 - ABS(TIMESTAMPDIFF(MINUTE, start_time, #{req.startTime})) / (60 / 100)
|
100 - ABS(TIMESTAMPDIFF(MINUTE, start_time, #{req.startTime})) / (120 / 100)
|
||||||
)) * 0.2)
|
)) * 0.2)
|
||||||
+
|
+
|
||||||
(CASE
|
(CASE
|
||||||
|
|||||||
Reference in New Issue
Block a user