Procházet zdrojové kódy

批量插入飞行数据

tags/v1.3.1
chengwang před 1 rokem
rodič
revize
019f5acdf4
3 změnil soubory, kde provedl 83 přidání a 5 odebrání
  1. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/FlightDataHlMapper.java
  2. +3
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/data/FlyDataService.java
  3. +77
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/FlightDataHlMapper.xml

+ 3
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/FlightDataHlMapper.java Zobrazit soubor

@@ -3,6 +3,7 @@ package com.tuoheng.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.entity.FlightDataHl;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@@ -14,4 +15,6 @@ public interface FlightDataHlMapper extends BaseMapper<FlightDataHl> {

List<FlightDataHl> selectListByInspectionId(String id);

int addBatch(@Param("list") List<FlightDataHl> records);

}

+ 3
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/data/FlyDataService.java Zobrazit soubor

@@ -14,6 +14,7 @@ import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.response.TZHLAirportFlightDataResponse;
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService;
import com.tuoheng.admin.tzhl.service.airport.TZHLGetAirportListService;
import com.tuoheng.common.core.utils.CommonUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.RedisUtils;
import com.tuoheng.common.core.utils.StringUtils;
@@ -82,16 +83,13 @@ public class FlyDataService {
}
flightDataHl.setCreateUser(inspection.getCreateUser());

int count = flightDataHlMapper.insert(flightDataHl);

if(count<=0){
log.info("输入插入失败,responseData:{}",responseData);
throw new SecurityException("飞行数据插入失败");
}
flightDataHls.add(flightDataHl);
log.info("结束飞行数据保存入库, flightDataHls:{}",flightDataHls);

}
CommonUtils.batchOperate((x) -> flightDataHlMapper.addBatch(x),flightDataHls,1000);

//将最新的一条数据存入缓存,并设置过期时间
log.info("开始存入最新一条数据于缓存中");
if(CollectionUtil.isNotEmpty(flightDataHls) && flightDataHls.size()>0){

+ 77
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/FlightDataHlMapper.xml Zobrazit soubor

@@ -90,4 +90,81 @@ gimbal_roll, zoom_ratio, focal_length, video_stream_source, create_user, create_
order by create_time asc
</select>


<!-- 批量新增问题图片 -->
<insert id="addBatch" parameterType="com.tuoheng.admin.entity.FlightDataHl">
insert into th_flight_data_hl (id, tenant_id, inspection_id, record_id, attach_r_d, uav_id, uav_no, time, alt, lng, lat, spd, ht,
head, pit, roll, bat, vol, fuel, act, mode, flight_mode, arm, air, absp, temp, tc, velocity_z, remaining_flight_time,
module_signal, satellite, deptId, app_connected, ground_connected, control_device, rc_control_position, gps, ultrasonic_height,
altitude_fused, lat_lon_altitude, home_location, duration, battery1_capacity_percent, battery1_voltage, battery1_temperature,
battery1_heat_state, battery2_capacity_percent, battery2_voltage, battery2_temperature, battery2_heat_state, gimbal_pitch, gimbal_yaw,
gimbal_roll, zoom_ratio, focal_length, video_stream_source, create_user, create_time, update_user, update_time, mark)
values
<foreach collection="list" item="item" separator=",">
(
#{item.id,jdbcType=BIGINT},
#{item.tenantId,jdbcType=VARCHAR},
#{item.inspectionId,jdbcType=INTEGER},
#{item.recordId,jdbcType=BIGINT},
#{item.attachRD,jdbcType=BIGINT},
#{item.uavId,jdbcType=BIGINT},
#{item.uavNo,jdbcType=BIGINT},
#{item.time,jdbcType=BIGINT},
#{item.alt,jdbcType=VARCHAR},
#{item.lng,jdbcType=VARCHAR},
#{item.lat,jdbcType=VARCHAR},
#{item.spd,jdbcType=VARCHAR},
#{item.ht,jdbcType=VARCHAR},
#{item.head,jdbcType=VARCHAR},
#{item.pit,jdbcType=VARCHAR},
#{item.roll,jdbcType=VARCHAR},
#{item.bat,jdbcType=VARCHAR},
#{item.vol,jdbcType=VARCHAR},
#{item.fuel,jdbcType=VARCHAR},
#{item.act,jdbcType=BIGINT},
#{item.mode,jdbcType=BIGINT},
#{item.flightMode,jdbcType=VARCHAR},
#{item.arm,jdbcType=VARCHAR},
#{item.air,jdbcType=VARCHAR},
#{item.absp,jdbcType=VARCHAR},
#{item.temp,jdbcType=VARCHAR},
#{item.tc,jdbcType=VARCHAR},
#{item.velocityZ,jdbcType=VARCHAR},
#{item.remainingFlightTime,jdbcType=VARCHAR},
#{item.moduleSignal,jdbcType=VARCHAR},
#{item.satellite,jdbcType=VARCHAR},
#{item.deptId,jdbcType=BIGINT},
#{item.appConnected,jdbcType=VARCHAR},
#{item.groundConnected,jdbcType=VARCHAR},
#{item.controlDevice,jdbcType=VARCHAR},
#{item.rcControlPosition,jdbcType=VARCHAR},
#{item.gps,jdbcType=VARCHAR},
#{item.ultrasonicHeight,jdbcType=VARCHAR},
#{item.altitudeFused,jdbcType=VARCHAR},
#{item.latLonAltitude,jdbcType=VARCHAR},
#{item.homeLocation,jdbcType=VARCHAR},
#{item.duration,jdbcType=VARCHAR},
#{item.battery1CapacityPercent,jdbcType=VARCHAR},
#{item.battery1Voltage,jdbcType=VARCHAR},
#{item.battery1Temperature,jdbcType=VARCHAR},
#{item.battery1HeatState,jdbcType=VARCHAR},
#{item.battery2CapacityPercent,jdbcType=VARCHAR},
#{item.battery2Voltage,jdbcType=VARCHAR},
#{item.battery2Temperature,jdbcType=VARCHAR},
#{item.battery2HeatState,jdbcType=VARCHAR},
#{item.gimbalPitch,jdbcType=VARCHAR},
#{item.gimbalYaw,jdbcType=VARCHAR},
#{item.gimbalRoll,jdbcType=VARCHAR},
#{item.zoomRatio,jdbcType=VARCHAR},
#{item.focalLength,jdbcType=VARCHAR},
#{item.videoStreamSource,jdbcType=VARCHAR},
#{item.createUser,jdbcType=VARCHAR},
#{item.createTime,jdbcType=DATE},
#{item.updateUser,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=DATE},
#{item.mark,jdbcType=TINYINT}
)
</foreach>
</insert>

</mapper>

Načítá se…
Zrušit
Uložit