@@ -133,7 +133,7 @@ public class AnalysisEvalDataViewManage { | |||
QueryWrapper<T> query = Wrappers.query(); | |||
query.select("count(1) as `count`, region_id as regionId"); | |||
query.in("region_id", regionIds); | |||
query.eq("danger_level", dangerLevel); | |||
query.eq(Objects.nonNull(dangerLevel),"danger_level", dangerLevel); | |||
query.groupBy("region_id"); | |||
return query; | |||
} | |||
@@ -10,6 +10,8 @@ import java.util.concurrent.TimeUnit; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
import java.util.stream.Collectors; | |||
import com.ningdatech.carapi.homepage.entity.model.NdDataAccessGps; | |||
import com.ningdatech.carapi.homepage.service.IDataAccessGpsService; | |||
import org.springframework.aop.framework.AopContext; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.data.redis.core.RedisTemplate; | |||
@@ -95,7 +97,7 @@ public class PositionMonitorManage { | |||
private final RedisTemplate redisTemplate; | |||
private final OperatorsCacheHelper operatorsCacheHelper; | |||
private final StringRedisTemplate stringRedisTemplate; | |||
private final IDataAccessGpsService dataAccessGpsService; | |||
public List<ResTrajectoryDataVO> trajectoryDatalist(ReqTrajectoryDataPO po) { | |||
@@ -275,28 +277,22 @@ public class PositionMonitorManage { | |||
} | |||
VehicleNumPO vehicleNumPO = homepageService.vehicleNum(param); | |||
Integer vehiclesTotalCount = vehicleNumPO.getTotalNum(); | |||
Integer vehiclesOnlineCount = vehicleNumPO.getTotalOnlineNum(); | |||
Integer vehiclesOfflineCount = vehicleNumPO.getTotalOfflineNum(); | |||
Integer vehiclesOnlineCount = 0; | |||
Integer vehiclesOfflineCount = 0; | |||
StopWatch stopWatch = new StopWatch(); | |||
stopWatch.start(); | |||
List<OnlineNumCnt> cntList = homepageService.getOnlineNumCnt(vehicleBaseInfos); | |||
AtomicInteger cnt = new AtomicInteger(0); | |||
for (OnlineNumCnt onlineNumCnt : cntList) { | |||
Integer onlineNum = onlineNumCnt.getCnt(); | |||
cnt.addAndGet(onlineNum); | |||
} | |||
Long cnt = vehicleBaseInfos.stream().filter(o -> Objects.nonNull(o) && | |||
Objects.nonNull(o.getStatus()) && o.getStatus() == 1).count(); | |||
stopWatch.stop(); | |||
log.info("共耗时 {}s", stopWatch.getTotalTimeSeconds()); | |||
log.info("缓存中车辆在线数为:" + cnt); | |||
vehiclesOnlineCount = cnt.get(); | |||
vehiclesOfflineCount = vehiclesTotalCount - cnt.get(); | |||
Integer todayVehiclesAccumulatedOnlineCount = homepageService.searchAccumulativeOnlineNum(param); | |||
vehiclesOnlineCount = cnt.intValue(); | |||
vehiclesOfflineCount = vehiclesTotalCount - vehiclesOnlineCount; | |||
resRealTimeMonitorStatisticsVO.setVehiclesTotalCount(vehiclesTotalCount); | |||
resRealTimeMonitorStatisticsVO.setVehiclesOnlineCount(vehiclesOnlineCount); | |||
resRealTimeMonitorStatisticsVO.setVehiclesOfflineCount(vehiclesOfflineCount); | |||
resRealTimeMonitorStatisticsVO.setTodayVehiclesAccumulatedOnlineCount(todayVehiclesAccumulatedOnlineCount); | |||
resRealTimeMonitorStatisticsVO.setTodayVehiclesAccumulatedOnlineCount(vehiclesOnlineCount); | |||
return resRealTimeMonitorStatisticsVO; | |||
} | |||
@@ -310,81 +306,26 @@ public class PositionMonitorManage { | |||
} | |||
public List<ResRealTimeMonitorVehicleGisListVO> realTimeMonitorVehicleGisList(ReqRealTimeMonitorPO po) { | |||
return Collections.emptyList(); | |||
// if (CollUtil.isEmpty(po.getCompanyIdList())) { | |||
// return Collections.emptyList(); | |||
// } | |||
// // 按照登录用户,如果是运营商账号登录,删选出该运营商关联的车辆信息 | |||
// UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); | |||
// Long roleId = userDetail.getRoleId(); | |||
// List<VehicleCompanyPO> carPlates = Lists.newArrayList(); | |||
// // 如果登录用户是运营商,只过滤出运营商下的车辆 | |||
// if (UserRoleTypeEnum.OPERATOR_ROLE_ID.getId().equals(roleId)) { | |||
// carPlates = vehicleBaseInfoService.getCarPlatesByCompanyIds(po.getCompanyIdList()); | |||
// String companyName = userDetail.getCompanyName(); | |||
// // 暂时控制运营商名称和运营商所在企业名称相同 | |||
// OperatorQueryDTO operatorQueryDTO = operatorsCacheHelper.getByName(companyName); | |||
// // 获取运营商id | |||
// Long operatorId = operatorQueryDTO.getId(); | |||
// carPlates = carPlates.stream() | |||
// .filter(v -> operatorId.equals(v.getOperatorId())) | |||
// .collect(Collectors.toList()); | |||
// } | |||
// // 如果登录用户是企业信息员,过滤出使用企业和所属企业为该企业的车辆 | |||
// else if (UserRoleTypeEnum.COMPANY_INFO_OFFICER_ROLE_ID.getId().equals(roleId)) { | |||
// Long companyId = userDetail.getCompanyId(); | |||
// carPlates = vehicleBaseInfoService.getCarPlatesByUseCompanyId(companyId); | |||
// }else{ | |||
// carPlates = vehicleBaseInfoService.getCarPlatesByCompanyIds(po.getCompanyIdList()); | |||
// } | |||
// log.info("request real carPlates 【{}】:", JSON.toJSONString(carPlates)); | |||
// if (CollUtil.isEmpty(carPlates)) { | |||
// return Collections.emptyList(); | |||
// } | |||
// Map<String, Object> map = Maps.newConcurrentMap(); | |||
// map.put(PositionContant.FIELD_CAR_PLATE, carPlates.stream().map(VehicleCompanyPO::getCarPlate).collect(Collectors.joining(","))); | |||
// map.put(PositionContant.HOST_FEILD, HOST); | |||
// JSONObject response = restTemplate.getForObject(PositionContant.REAL_GPS_URL, JSONObject.class, map); | |||
// log.info("request real gps 【{}】:", JSON.toJSONString(response)); | |||
// if (Objects.isNull(response)) { | |||
// throw new BizException(ExceptionCode.BAD_REQUEST.getCode(), "实时数据请求失败 网络异常"); | |||
// } | |||
// Integer statusCode = response.getInteger("status_code"); | |||
// if (0 != statusCode) { | |||
// throw new BizException(ExceptionCode.BAD_REQUEST.getCode(), response.getString("message")); | |||
// } | |||
// JSONArray resultJsonArray = response.getJSONArray("result"); | |||
// if (Objects.isNull(resultJsonArray) || resultJsonArray.size() == 0) { | |||
// return Collections.emptyList(); | |||
// } | |||
// | |||
// Map<String, VehicleCompanyPO> carMap = carPlates.stream() | |||
// .filter(w -> Objects.nonNull(w) && Objects.nonNull(w.getCarPlate())) | |||
// .filter(CodeUtil.distinctByKey(VehicleCompanyPO::getCarPlate)).collect(Collectors.toMap(VehicleCompanyPO::getCarPlate, v -> v)); | |||
// List<ResRealTimeMonitorVehicleGisListVO> res = resultJsonArray.stream().map(o -> { | |||
// JSONObject j = JSON.parseObject(JSON.toJSONString(o)); | |||
// String carPlate = j.getString(PositionContant.FIELD_CAR_PLATE); | |||
// VehicleCompanyPO vehicleCompany = carMap.get(carPlate); | |||
// ResRealTimeMonitorVehicleGisListVO vo = new ResRealTimeMonitorVehicleGisListVO(); | |||
// vo.setCarLongitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.LONGITUDE,BigDecimal.valueOf(0L))))); | |||
// vo.setCarLatitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.LATITUDE,BigDecimal.valueOf(0L))))); | |||
// vo.setCarAltitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.ALTITUDE,BigDecimal.valueOf(0L))))); | |||
// vo.setCarDirection(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.DIRECTION,BigDecimal.valueOf(0L))))); | |||
// vo.setCarPlate(carPlate); | |||
// vo.setPlateColor(j.getString(PositionContant.PLATE_COLOR)); | |||
// vo.setCompanyId(vehicleCompany.getCompanyId()); | |||
// vo.setCompanyName(vehicleCompany.getCompanyName()); | |||
// vo.setCarVelocity(BigDecimal.valueOf(Double.valueOf(String.valueOf(j.getOrDefault(PositionContant.CAR_VELOCITY,BigDecimal.valueOf(0L)))))); | |||
// vo.setUpdateTime((j.getString(PositionContant.UPDATE_TIME))); | |||
// vo.setSelfNo(vehicleCompany.getSelfNo()); | |||
// vo.setStatus(j.getInteger(PositionContant.ONLINE_STATUS)); | |||
// vo.setMoving(vehicleCompany.getMoving()); | |||
// vo.setVehicleType(vehicleCompany.getVehicleType()); | |||
// vo.setVehicleTypeName(vehicleCompany.getVechileTypeName()); | |||
// vo.setLimitSpeed(VehicleLimitSpeedEnum.getLimitSpeedByCode(vehicleCompany.getVehicleType())); | |||
// return vo; | |||
// }).collect(Collectors.toList()); | |||
// return res; | |||
List<NdDataAccessGps> data = dataAccessGpsService.list(); | |||
if(CollUtil.isEmpty(data)){ | |||
return Collections.emptyList(); | |||
} | |||
List<String> plates = data.stream().map(NdDataAccessGps::getCarPlate).collect(Collectors.toList()); | |||
Map<String, NdVehicleBaseInfo> map = vehicleBaseInfoService.listByCarNo(plates); | |||
return data.stream().map(d -> { | |||
ResRealTimeMonitorVehicleGisListVO vo = BeanUtil.copyProperties(d,ResRealTimeMonitorVehicleGisListVO.class); | |||
if(map.containsKey(d.getCarPlate())){ | |||
NdVehicleBaseInfo car = map.get(d.getCarPlate()); | |||
vo.setVehicleType(car.getVehicleType()); | |||
vo.setCompanyId(car.getCompanyId()); | |||
vo.setCompanyName(car.getUseCompanyName()); | |||
vo.setMoving(1); | |||
vo.setPlateColor(car.getPlateColor()); | |||
vo.setSelfNo(car.getSelfNo()); | |||
// vo.setLimitSpeed(); | |||
} | |||
return vo; | |||
}).collect(Collectors.toList()); | |||
} | |||
public List<ResRealTimeMonitorVehicleGisListVO> realTimeMonitorVehicleGisList(DataScreenParam param) { | |||
@@ -1,12 +1,15 @@ | |||
package com.ningdatech.carapi.car.position.model.vo; | |||
import com.ningdatech.carapi.common.constant.VehicleTypeEnum; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import org.apache.commons.lang3.StringUtils; | |||
import java.math.BigDecimal; | |||
import java.math.RoundingMode; | |||
import java.util.Objects; | |||
import java.util.Optional; | |||
/** | |||
* @author liuxinxin | |||
@@ -100,4 +103,13 @@ public class ResRealTimeMonitorVehicleGisListVO { | |||
} | |||
return this.carDirection; | |||
} | |||
public String getVehicleTypeName(){ | |||
if(Objects.nonNull(this.vehicleType)){ | |||
Optional.ofNullable(VehicleTypeEnum.getDescByCode(vehicleType)).ifPresent(v -> | |||
this.vehicleTypeName = v); | |||
return this.vehicleTypeName; | |||
} | |||
return StringUtils.EMPTY; | |||
} | |||
} |
@@ -0,0 +1,102 @@ | |||
package com.ningdatech.carapi.homepage.entity.model; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.ningdatech.cache.model.cache.CacheHashKey; | |||
import com.ningdatech.cache.model.cache.CacheKeyBuilder; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Component; | |||
import javax.validation.constraints.Size; | |||
import java.io.Serializable; | |||
import java.math.BigDecimal; | |||
import java.time.LocalDateTime; | |||
/** | |||
* @author CMM | |||
* @since 2023/07/06 10:47 | |||
*/ | |||
@Component | |||
@Slf4j | |||
@Data | |||
@RequiredArgsConstructor | |||
@TableName("nd_data_access_gps_2024_04_03") | |||
@ApiModel(value = "NdDataAccessGps", description = "车辆GPS") | |||
public class NdDataAccessGps implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty("ID") | |||
@TableId(value = "record_id", type = IdType.AUTO) | |||
private Long recordId; | |||
@ApiModelProperty("车牌号") | |||
@TableField(value = "car_plate") | |||
private String carPlate; | |||
@ApiModelProperty("颜色") | |||
@TableField(value = "plate_color") | |||
private String plateColor; | |||
@ApiModelProperty("坐标") | |||
@TableField(value = "car_longitude") | |||
private BigDecimal carLongitude; | |||
@ApiModelProperty("坐标") | |||
@TableField(value = "car_latitude") | |||
private BigDecimal carLatitude; | |||
@ApiModelProperty("坐标") | |||
@TableField(value = "car_altitude") | |||
private BigDecimal carAltitude; | |||
@ApiModelProperty("坐标") | |||
@TableField(value = "car_velocity") | |||
private BigDecimal carVelocity; | |||
@ApiModelProperty("坐标") | |||
@TableField(value = "car_direction") | |||
private BigDecimal carDirection; | |||
@ApiModelProperty("时间") | |||
@TableField(value = "update_time") | |||
private LocalDateTime updateTime; | |||
@ApiModelProperty("名") | |||
@TableField(value = "operator_name") | |||
private String operatorName; | |||
@ApiModelProperty("操作ID") | |||
@TableField(value = "operator_id") | |||
private String operatorId; | |||
@TableField(value = "alarm_flag") | |||
private Long alarmFlag; | |||
@ApiModelProperty("状态") | |||
@TableField(value = "status") | |||
private Long status; | |||
@ApiModelProperty("看板那啥") | |||
@TableField(value = "dashboard_mileage") | |||
private Long dashboardMileage; | |||
@ApiModelProperty("看板速度") | |||
@TableField(value = "dashboard_speed") | |||
private Long dashboardSpeed; | |||
@TableField(value = "abnormal_causes") | |||
private Integer abnormalCauses; | |||
@ApiModelProperty("时间") | |||
@TableField(value = "create_time") | |||
private LocalDateTime createTime; | |||
} |
@@ -221,25 +221,19 @@ public class HomepageManage { | |||
VehicleNumPO vehicleNumPo = homepageService.vehicleNum(param); | |||
Integer vehicleNum = vehicleNumPo.getTotalNum(); | |||
Integer onlineVehicleNum = vehicleNumPo.getTotalOnlineNum(); | |||
Integer offlineVehicleNum = vehicleNumPo.getTotalOfflineNum(); | |||
Integer onlineVehicleNum = 0; | |||
Integer offlineVehicleNum = 0; | |||
StopWatch stopWatch = new StopWatch(); | |||
stopWatch.start(); | |||
AtomicInteger cnt = new AtomicInteger(0); | |||
if (CollUtil.isNotEmpty(vehicleBaseInfos)) { | |||
List<OnlineNumCnt> cntList = homepageService.getOnlineNumCnt(vehicleBaseInfos); | |||
for (OnlineNumCnt onlineNumCnt : cntList) { | |||
Integer onlineNum = onlineNumCnt.getCnt(); | |||
cnt.addAndGet(onlineNum); | |||
} | |||
} | |||
Long cnt = vehicleBaseInfos.stream().filter(o -> Objects.nonNull(o) && | |||
Objects.nonNull(o.getStatus()) && o.getStatus() == 1).count(); | |||
stopWatch.stop(); | |||
log.info("共耗时 {}s", stopWatch.getTotalTimeSeconds()); | |||
log.info("缓存中车辆在线数为:" + cnt); | |||
onlineVehicleNum = cnt.get(); | |||
offlineVehicleNum = vehicleNum - cnt.get(); | |||
Integer accumulativeOnlineNumber = homepageService.searchAccumulativeOnlineNum(param); | |||
onlineVehicleNum = cnt.intValue(); | |||
offlineVehicleNum = vehicleNum - onlineVehicleNum; | |||
Integer accumulativeOnlineNumber = onlineVehicleNum; | |||
log.info("车辆总数为:" + vehicleNum); | |||
log.info("车辆在线数为:" + onlineVehicleNum); | |||
log.info("车辆离线数为:" + offlineVehicleNum); | |||
@@ -0,0 +1,8 @@ | |||
package com.ningdatech.carapi.homepage.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.ningdatech.carapi.homepage.entity.model.NdDataAccessGps; | |||
public interface DataAccessGpsMapper extends BaseMapper<NdDataAccessGps> { | |||
} |
@@ -0,0 +1,12 @@ | |||
package com.ningdatech.carapi.homepage.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.ningdatech.carapi.homepage.entity.model.NdDataAccessGps; | |||
/** | |||
* @author ZPF | |||
* @since 2024/09/20 15:55 | |||
*/ | |||
public interface IDataAccessGpsService extends IService<NdDataAccessGps> { | |||
} |
@@ -0,0 +1,54 @@ | |||
package com.ningdatech.carapi.homepage.service.impl; | |||
import cn.hutool.core.collection.ListUtil; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.ningdatech.carapi.car.datascreen.model.dto.DataScreenParam; | |||
import com.ningdatech.carapi.car.vehicle.mapper.VehicleBaseInfoJoinMapper; | |||
import com.ningdatech.carapi.car.vehicle.mapper.VehicleBaseInfoMapper; | |||
import com.ningdatech.carapi.car.vehicle.model.NdVehicleBaseInfo; | |||
import com.ningdatech.carapi.car.vehicle.model.NdVehicleBaseInfoJoin; | |||
import com.ningdatech.carapi.common.aop.BuildChildrenRegionEntity; | |||
import com.ningdatech.carapi.datascope.aop.XmlDataScope; | |||
import com.ningdatech.carapi.homepage.constant.HomepageConstant; | |||
import com.ningdatech.carapi.homepage.entity.dto.HomepageAbnormalBehaviorPageParamDTO; | |||
import com.ningdatech.carapi.homepage.entity.model.NdDataAccessGps; | |||
import com.ningdatech.carapi.homepage.entity.model.OnlineNumCnt; | |||
import com.ningdatech.carapi.homepage.entity.po.DriverAbnormalBehaviorNumPO; | |||
import com.ningdatech.carapi.homepage.entity.po.VehicleNumPO; | |||
import com.ningdatech.carapi.homepage.mapper.DataAccessGpsMapper; | |||
import com.ningdatech.carapi.homepage.mapper.HomepageMapper; | |||
import com.ningdatech.carapi.homepage.service.IDataAccessGpsService; | |||
import com.ningdatech.carapi.homepage.service.IHomepageService; | |||
import com.ningdatech.carapi.scheduler.mapper.VehicleOnlineStatusDayMapper; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.data.redis.core.StringRedisTemplate; | |||
import org.springframework.stereotype.Service; | |||
import java.time.Duration; | |||
import java.time.Instant; | |||
import java.time.LocalDateTime; | |||
import java.time.ZoneId; | |||
import java.util.*; | |||
import java.util.concurrent.CountDownLatch; | |||
import java.util.concurrent.ExecutorService; | |||
import java.util.concurrent.Executors; | |||
import java.util.concurrent.TimeUnit; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
import java.util.function.Consumer; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @author zpf | |||
* @description | |||
* @since 2024/09/20 17:10 | |||
*/ | |||
@Service | |||
@Slf4j | |||
@RequiredArgsConstructor | |||
public class DataAccessGpsServiceImpl extends ServiceImpl<DataAccessGpsMapper, NdDataAccessGps> implements IDataAccessGpsService { | |||
} |
@@ -142,5 +142,4 @@ public class HomepageServiceImpl implements IHomepageService { | |||
} | |||
return cntList; | |||
} | |||
} |