| | |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.account.XpOperationsRole; |
| | | import com.xiaopeng.api.model.maintenance.XpChargingRecord; |
| | | import com.xiaopeng.api.model.maintenance.XpTask; |
| | | import com.xiaopeng.api.model.maintenance.XpTaskRule; |
| | | import com.xiaopeng.api.model.maintenance.XpTaskRuleRole; |
| | |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.api.vo.maintenance.TaskScheduleConstants; |
| | | import com.xiaopeng.maintenance.mapper.XpChargingRecordMapper; |
| | | import com.xiaopeng.maintenance.mapper.XpTaskMapper; |
| | | import com.xiaopeng.maintenance.mapper.XpTaskRuleMapper; |
| | | import com.xiaopeng.maintenance.mapper.XpTaskRuleRoleMapper; |
| | |
| | | |
| | | @Autowired |
| | | private XpTaskMapper taskMapper; |
| | | |
| | | @Autowired |
| | | private XpChargingRecordMapper chargingRecordMapper; |
| | | |
| | | @Autowired |
| | | private XpVehicleClient xpVehicleClient; |
| | |
| | | } |
| | | |
| | | int createdCount = 0; |
| | | int skippedCount = 0; |
| | | int skippedUnfinishedTaskCount = 0; |
| | | int skippedUnfinishedChargingRecordCount = 0; |
| | | int skippedNoAssigneeCount = 0; |
| | | for (VehiclePosition position : lowBatteryPositions) { |
| | | if (position == null || !StringUtils.hasLength(position.getVin())) { |
| | |
| | | |
| | | // 避免重复创建:若存在未完成的充电任务则跳过 |
| | | if (hasUnfinishedTask(vehicle.getId(), TaskScheduleConstants.TASK_TYPE_CHARGING)) { |
| | | skippedCount++; |
| | | skippedUnfinishedTaskCount++; |
| | | continue; |
| | | } |
| | | |
| | | // 若车辆最新一条充电记录未完成,则不再创建新的充电任务 |
| | | if (hasUnfinishedLatestChargingRecord(vehicle.getId())) { |
| | | skippedUnfinishedChargingRecordCount++; |
| | | continue; |
| | | } |
| | | |
| | |
| | | createdCount++; |
| | | } |
| | | |
| | | log.info("========== {}执行完成,阈值={},命中={},创建任务数={},跳过(已存在未完成任务)={},跳过(无可分配处理人)={} ==========", |
| | | TASK_NAME, threshold, lowBatteryPositions.size(), createdCount, skippedCount, skippedNoAssigneeCount); |
| | | log.info("========== {}执行完成,阈值={},命中={},创建任务数={},跳过(已存在未完成任务)={},跳过(最新充电记录未完成)={},跳过(无可分配处理人)={} ==========", |
| | | TASK_NAME, threshold, lowBatteryPositions.size(), createdCount, skippedUnfinishedTaskCount, |
| | | skippedUnfinishedChargingRecordCount, skippedNoAssigneeCount); |
| | | } |
| | | |
| | | private XpTaskRule getTaskRule() { |
| | |
| | | return existingTask != null; |
| | | } |
| | | |
| | | /** |
| | | * 检查车辆最新一条充电记录是否未完成 |
| | | */ |
| | | private boolean hasUnfinishedLatestChargingRecord(Long vehicleId) { |
| | | XpChargingRecord latestChargingRecord = chargingRecordMapper.selectOne( |
| | | new LambdaQueryWrapper<XpChargingRecord>() |
| | | .eq(XpChargingRecord::getVehicleId, vehicleId) |
| | | .orderByDesc(XpChargingRecord::getCreateTime) |
| | | .last("limit 1") |
| | | ); |
| | | return latestChargingRecord != null |
| | | && (latestChargingRecord.getEndTime() == null |
| | | || latestChargingRecord.getEndRemainingBattery() == null); |
| | | } |
| | | |
| | | private List<Long> resolveHandleUserIds(Long vehicleId, Set<Long> roleOperationUserIds, |
| | | Map<Long, Long> vehicleIdToFleetIdCache, |
| | | Map<Long, Set<Long>> fleetIdToOperationUserIdsCache) { |