识别数据功能提交
This commit is contained in:
parent
358dc92794
commit
19ff90cf77
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.bonus.web.controller.data;
|
||||||
|
|
||||||
|
import com.bonus.common.annotation.RequiresPermissions;
|
||||||
|
import com.bonus.common.annotation.SysLog;
|
||||||
|
import com.bonus.common.core.controller.BaseController;
|
||||||
|
import com.bonus.common.core.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.page.TableDataInfo;
|
||||||
|
import com.bonus.common.domain.data.dto.ParamsDto;
|
||||||
|
import com.bonus.common.domain.data.vo.DeviceIdentificationDataVo;
|
||||||
|
import com.bonus.common.enums.OperaType;
|
||||||
|
import com.bonus.web.service.data.DeviceIdentificationService;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DeviceIdentificationController
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2025-12-23-16:31
|
||||||
|
* @version:1.0
|
||||||
|
* @description:设备识别-web层
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/data/deviceIdentification")
|
||||||
|
public class DeviceIdentificationController extends BaseController {
|
||||||
|
|
||||||
|
@Resource(name = "DeviceIdentificationService")
|
||||||
|
private DeviceIdentificationService deviceIdentificationService;
|
||||||
|
|
||||||
|
@ApiOperation(notes = "查询识别图片",value = "查询识别图片")
|
||||||
|
@RequiresPermissions("data:deviceIdentification:list")
|
||||||
|
@GetMapping("/getDeviceIdentificationList")
|
||||||
|
@SysLog(title = "设备管理", businessType = OperaType.QUERY, logType = 1, module = "设备管理->识别图片", details = "查询识别图片")
|
||||||
|
public TableDataInfo getDeviceIdentificationList(ParamsDto dto) {
|
||||||
|
startPage();
|
||||||
|
List<DeviceIdentificationDataVo> list = deviceIdentificationService.getDeviceIdentificationList(dto);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(notes = "查询识别数据",value = "查询识别数据")
|
||||||
|
@RequiresPermissions("data:deviceIdentification:list")
|
||||||
|
@GetMapping("/getDeviceIdentificationByDataList")
|
||||||
|
@SysLog(title = "设备管理", businessType = OperaType.QUERY, logType = 1, module = "设备管理->识别图片", details = "查询识别数据")
|
||||||
|
public TableDataInfo getDeviceIdentificationByDataList(ParamsDto dto) {
|
||||||
|
startPage();
|
||||||
|
List<DeviceIdentificationDataVo> list = deviceIdentificationService.getDeviceIdentificationList(dto);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(notes = "查询识别数据(车流量)",value = "查询识别数据(车流量)")
|
||||||
|
@RequiresPermissions("data:deviceIdentification:list")
|
||||||
|
@GetMapping("/getDeviceIdentificationByDataDetail")
|
||||||
|
public AjaxResult getDeviceIdentificationByDataDetail(ParamsDto dto) {
|
||||||
|
return deviceIdentificationService.getDeviceIdentificationByDataDetail(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,9 +3,15 @@ package com.bonus.web.service.data;
|
||||||
import com.bonus.common.domain.data.dto.ParamsDto;
|
import com.bonus.common.domain.data.dto.ParamsDto;
|
||||||
import com.bonus.common.domain.data.vo.AlarmVo;
|
import com.bonus.common.domain.data.vo.AlarmVo;
|
||||||
import com.bonus.data.service.DlAlarmService;
|
import com.bonus.data.service.DlAlarmService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,6 +21,7 @@ import java.util.List;
|
||||||
* @version:1.0
|
* @version:1.0
|
||||||
* @description:
|
* @description:
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service(value = "AlarmService")
|
@Service(value = "AlarmService")
|
||||||
public class AlarmService {
|
public class AlarmService {
|
||||||
|
|
||||||
|
|
@ -29,6 +36,24 @@ public class AlarmService {
|
||||||
* @date 2025/12/23 15:44
|
* @date 2025/12/23 15:44
|
||||||
*/
|
*/
|
||||||
public List<AlarmVo> getAlarmList(ParamsDto dto) {
|
public List<AlarmVo> getAlarmList(ParamsDto dto) {
|
||||||
return dlAlarmService.getAlarmList(dto);
|
try {
|
||||||
|
if (dto.getStartTime() == null || dto.getEndTime() == null) {
|
||||||
|
// 获取今天的日期
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
// 设置开始时间为 00:00:00
|
||||||
|
LocalDateTime startOfDay = now.with(LocalTime.MIN);
|
||||||
|
// 设置结束时间为 23:59:59 (也可以使用 LocalTime.MAX)
|
||||||
|
LocalDateTime endOfDay = now.with(LocalTime.MAX);
|
||||||
|
// 转换为 Date 赋值给 dto (如果你的字段类型是 Date)
|
||||||
|
ZoneId zone = ZoneId.systemDefault();
|
||||||
|
dto.setStartTime(Date.from(startOfDay.atZone(zone).toInstant()));
|
||||||
|
dto.setEndTime(Date.from(endOfDay.atZone(zone).toInstant()));
|
||||||
|
}
|
||||||
|
List<AlarmVo> alarmList = dlAlarmService.getAlarmList(dto);
|
||||||
|
return alarmList != null ? alarmList : Collections.emptyList();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
package com.bonus.web.service.data;
|
||||||
|
|
||||||
|
import com.bonus.common.core.domain.AjaxResult;
|
||||||
|
import com.bonus.common.domain.data.dto.ParamsDto;
|
||||||
|
import com.bonus.common.domain.data.vo.DeviceIdentificationDataCountVo;
|
||||||
|
import com.bonus.common.domain.data.vo.DeviceIdentificationDataVo;
|
||||||
|
import com.bonus.data.service.DIDeviceIdentificationService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DeviceIdentificationService
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2025-12-23-16:32
|
||||||
|
* @version:1.0
|
||||||
|
* @description:设备识别-业务层
|
||||||
|
*/
|
||||||
|
@Service(value = "DeviceIdentificationService")
|
||||||
|
@Slf4j
|
||||||
|
public class DeviceIdentificationService {
|
||||||
|
|
||||||
|
@Resource(name = "DIDeviceIdentificationService")
|
||||||
|
private DIDeviceIdentificationService deviceIdentificationService;
|
||||||
|
|
||||||
|
public List<DeviceIdentificationDataVo> getDeviceIdentificationList(ParamsDto dto) {
|
||||||
|
try {
|
||||||
|
if (dto.getStartTime() == null || dto.getEndTime() == null) {
|
||||||
|
// 获取今天的日期
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
// 设置开始时间为 00:00:00
|
||||||
|
LocalDateTime startOfDay = now.with(LocalTime.MIN);
|
||||||
|
// 设置结束时间为 23:59:59 (也可以使用 LocalTime.MAX)
|
||||||
|
LocalDateTime endOfDay = now.with(LocalTime.MAX);
|
||||||
|
// 转换为 Date 赋值给 dto (如果你的字段类型是 Date)
|
||||||
|
ZoneId zone = ZoneId.systemDefault();
|
||||||
|
dto.setStartTime(Date.from(startOfDay.atZone(zone).toInstant()));
|
||||||
|
dto.setEndTime(Date.from(endOfDay.atZone(zone).toInstant()));
|
||||||
|
}
|
||||||
|
List<DeviceIdentificationDataVo> result = deviceIdentificationService.getDeviceIdentificationList(dto);
|
||||||
|
// 处理图片-待实现
|
||||||
|
return result != null ? result : Collections.emptyList();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询识别数据
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return AjaxResult
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2025/12/23 17:38
|
||||||
|
*/
|
||||||
|
public AjaxResult getDeviceIdentificationByDataDetail(ParamsDto dto) {
|
||||||
|
DeviceIdentificationDataCountVo vo = null;
|
||||||
|
try {
|
||||||
|
List<DeviceIdentificationDataVo> result = deviceIdentificationService.getDeviceIdentificationList(dto);
|
||||||
|
vo = calculateStatistics(result, dto.getStartTime(), dto.getEndTime());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
vo = new DeviceIdentificationDataCountVo();
|
||||||
|
}
|
||||||
|
return AjaxResult.success(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceIdentificationDataCountVo calculateStatistics(List<DeviceIdentificationDataVo> result, Date startTime, Date endTime) {
|
||||||
|
DeviceIdentificationDataCountVo countVo = new DeviceIdentificationDataCountVo();
|
||||||
|
|
||||||
|
// 1. 计算小时数(不足1小时按1小时算)
|
||||||
|
long durationMillis = Math.abs(endTime.getTime() - startTime.getTime());
|
||||||
|
double hours = Math.ceil(durationMillis / (1000.0 * 60 * 60));
|
||||||
|
if (hours <= 0) hours = 1.0;
|
||||||
|
|
||||||
|
// 2. 分类统计数量
|
||||||
|
// 假设 carType: "1" 是油车,"2" 是电车
|
||||||
|
long totalCount = result.size();
|
||||||
|
long petrolCount = result.stream()
|
||||||
|
.filter(item -> "1".equals(item.getCarType()))
|
||||||
|
.count();
|
||||||
|
long electricCount = result.stream()
|
||||||
|
.filter(item -> "2".equals(item.getCarType()))
|
||||||
|
.count();
|
||||||
|
|
||||||
|
// 3. 赋值数量
|
||||||
|
countVo.setTotalCarNum(totalCount);
|
||||||
|
countVo.setPetrolVehiclesNum(petrolCount);
|
||||||
|
countVo.setNewEnergyNum(electricCount);
|
||||||
|
|
||||||
|
// 4. 计算并赋值车流量 (PCU = 数量 / 小时)
|
||||||
|
// 使用 BigDecimal 或 保留小数处理以防精度丢失
|
||||||
|
countVo.setTotalPCU(round(totalCount / hours));
|
||||||
|
countVo.setPetrolVehiclesPCU(round(petrolCount / hours));
|
||||||
|
countVo.setNewEnergyPCU(round(electricCount / hours));
|
||||||
|
return countVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 辅助方法:保留两位小数
|
||||||
|
*/
|
||||||
|
private double round(double value) {
|
||||||
|
return BigDecimal.valueOf(value).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,6 +16,9 @@ import java.util.Date;
|
||||||
@Data
|
@Data
|
||||||
public class ParamsDto {
|
public class ParamsDto {
|
||||||
|
|
||||||
|
/**车辆类型 1.油车 2.新能源*/
|
||||||
|
private String carType;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.bonus.common.domain.data.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DeviceIdentificationDataCountVo
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2025-12-23-17:38
|
||||||
|
* @version:1.0
|
||||||
|
* @description:识别数据统计
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceIdentificationDataCountVo {
|
||||||
|
|
||||||
|
/**车辆总数(辆)*/
|
||||||
|
private long totalCarNum;
|
||||||
|
|
||||||
|
/**油车数量(辆)*/
|
||||||
|
private long petrolVehiclesNum;
|
||||||
|
|
||||||
|
/**新能源数量(辆)*/
|
||||||
|
private long newEnergyNum;
|
||||||
|
|
||||||
|
/**总车流量(PCU/h)*/
|
||||||
|
private double totalPCU;
|
||||||
|
|
||||||
|
/**油车车流量(PCU/h)*/
|
||||||
|
private double petrolVehiclesPCU;
|
||||||
|
|
||||||
|
/**新能源车流量(PCU/h)*/
|
||||||
|
private double newEnergyPCU;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.bonus.common.domain.data.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DeviceIdentificationDataVo
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2025-12-23-16:30
|
||||||
|
* @version:1.0
|
||||||
|
* @description:设备识别数据
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceIdentificationDataVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 识别数据id
|
||||||
|
*/
|
||||||
|
private Long identificationDataId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统id
|
||||||
|
*/
|
||||||
|
private Long systemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 识别地点
|
||||||
|
*/
|
||||||
|
private String identificationLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 识别时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date identificationTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车牌颜色 1.蓝色 2.绿色
|
||||||
|
*/
|
||||||
|
private String carColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆类型 1.油车 2.电车
|
||||||
|
*/
|
||||||
|
private String carType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
* */
|
||||||
|
private String filePath;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.bonus.data.mapper;
|
||||||
|
|
||||||
|
import com.bonus.common.domain.data.dto.ParamsDto;
|
||||||
|
import com.bonus.common.domain.data.vo.DeviceIdentificationDataVo;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DIDeviceIdentificationMapper
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2025-12-23-16:35
|
||||||
|
* @version:1.0
|
||||||
|
* @description:设备识别-数据层
|
||||||
|
*/
|
||||||
|
@Repository(value = "DIDeviceIdentificationMapper")
|
||||||
|
public interface DIDeviceIdentificationMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询识别图片
|
||||||
|
* @param dto
|
||||||
|
* @return List<DeviceIdentificationDataVo>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2025/12/23 16:42
|
||||||
|
*/
|
||||||
|
List<DeviceIdentificationDataVo> getDeviceIdentificationList(ParamsDto dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.bonus.data.service;
|
||||||
|
|
||||||
|
import com.bonus.common.domain.data.dto.ParamsDto;
|
||||||
|
import com.bonus.common.domain.data.vo.AlarmVo;
|
||||||
|
import com.bonus.common.domain.data.vo.DeviceIdentificationDataVo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DIDeviceIdentification
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2025-12-23-16:34
|
||||||
|
* @version:1.0
|
||||||
|
* @description:设备识别-业务层
|
||||||
|
*/
|
||||||
|
@Service(value = "DIDeviceIdentificationService")
|
||||||
|
public interface DIDeviceIdentificationService {
|
||||||
|
/**
|
||||||
|
* 查询识别图片
|
||||||
|
* @param dto
|
||||||
|
* @return List<AlarmVo>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2025/12/23 16:38
|
||||||
|
*/
|
||||||
|
List<DeviceIdentificationDataVo> getDeviceIdentificationList(ParamsDto dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.bonus.data.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.common.domain.data.dto.ParamsDto;
|
||||||
|
import com.bonus.common.domain.data.vo.AlarmVo;
|
||||||
|
import com.bonus.common.domain.data.vo.DeviceIdentificationDataVo;
|
||||||
|
import com.bonus.data.mapper.DIDeviceIdentificationMapper;
|
||||||
|
import com.bonus.data.service.DIDeviceIdentificationService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DDeviceIdentificationServiceImpl
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2025-12-23-16:35
|
||||||
|
* @version:1.0
|
||||||
|
* @description:设备识别-业务逻辑层
|
||||||
|
*/
|
||||||
|
@Service(value = "DIDeviceIdentificationService")
|
||||||
|
public class DDeviceIdentificationServiceImpl implements DIDeviceIdentificationService {
|
||||||
|
|
||||||
|
@Resource(name = "DIDeviceIdentificationMapper")
|
||||||
|
private DIDeviceIdentificationMapper diDeviceIdentificationMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceIdentificationDataVo> getDeviceIdentificationList(ParamsDto dto) {
|
||||||
|
return diDeviceIdentificationMapper.getDeviceIdentificationList(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bonus.data.mapper.DIDeviceIdentificationMapper">
|
||||||
|
|
||||||
|
<!--查询识别图片-->
|
||||||
|
<select id="getDeviceIdentificationList" resultType="com.bonus.common.domain.data.vo.DeviceIdentificationDataVo">
|
||||||
|
SELECT
|
||||||
|
tdid.identification_location AS identificationLocation,
|
||||||
|
tdid.identification_time AS identificationTime,
|
||||||
|
tdid.car_color AS carColor,
|
||||||
|
tdid.car_type AS carType,
|
||||||
|
srf.file_path AS filePath
|
||||||
|
FROM tb_device_identification_data tdid
|
||||||
|
LEFT JOIN sys_resource_file srf
|
||||||
|
ON srf.business_id = tdid.identification_data_id
|
||||||
|
AND srf.source_table = 'tb_device_identification_data'
|
||||||
|
<where>
|
||||||
|
<if test="startTime != null">
|
||||||
|
AND tdid.identification_time >= #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null">
|
||||||
|
AND tdid.identification_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="carType != null and carType != ''">
|
||||||
|
AND tdid.car_type = #{carType}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY tdid.identification_time DESC
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue