| | |
| | | /** 航线数据 */ |
| | | private byte[] routeData; |
| | | |
| | | /** 行点总数 */ |
| | | private Integer pointCount; |
| | | |
| | | } |
| | |
| | | KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName()); |
| | | ardRouteInfo.setPath(kmzResult.getPath()); |
| | | ardRouteInfo.setReadOnly("0"); |
| | | ardRouteInfo.setPointCount(getPointCount(ardRouteInfo)); |
| | | ardRouteInfoMapper.insertArdRouteInfo(ardRouteInfo); |
| | | return kmzResult.getPath(); |
| | | } |
| | |
| | | } |
| | | ardRouteInfo.setPath(kmzResult.getPath()); |
| | | } |
| | | ardRouteInfo.setPointCount(getPointCount(ardRouteInfo)); |
| | | return ardRouteInfoMapper.updateArdRouteInfo(ardRouteInfo); |
| | | } |
| | | |
| | | private Integer getPointCount(ArdRouteInfo ardRouteInfo) { |
| | | if (ardRouteInfo.getUavRouteReq().getRoutePointList() != null) { |
| | | return ardRouteInfo.getUavRouteReq().getRoutePointList().size(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * 批量删除航线(kmz) |
| | | * |
| | |
| | | |
| | | String kml = XML_HEADER + xStream.toXML(kmlInfo); |
| | | String wpml = XML_HEADER + xStream.toXML(wpmlInfo); |
| | | |
| | | KmzResultVo result = new KmzResultVo(); |
| | | try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | ZipOutputStream zipOutputStream = new ZipOutputStream(baos)) { |
| | | zipOutputStream.setLevel(0); |
| | | |
| | | // 判断本地生成kmz文件 |
| | | if (isLocal) { |
| | | try (FileOutputStream fileOutputStream = new FileOutputStream(localFilePath + fileName + ".kmz"); |
| | | ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream)) { |
| | | zipOutputStream.setLevel(0); // 0 表示不压缩,存储方式 |
| | | // 创建 wpmz 目录中的 template.kml 文件条目 |
| | | buildZipFile("wpmz/template.kml", zipOutputStream, kml); |
| | | // 创建 wpmz 目录中的 waylines.wpml 文件条目 |
| | | buildZipFile("wpmz/waylines.wpml", zipOutputStream, wpml); |
| | | |
| | | // 创建KMZ文件内容 |
| | | buildZipFile("wpmz/template.kml", zipOutputStream, kml); |
| | | buildZipFile("wpmz/waylines.wpml", zipOutputStream, wpml); |
| | | zipOutputStream.finish(); |
| | | zipOutputStream.flush(); |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | result.setPath(localFilePath + fileName + ".kmz"); |
| | | // 创建MultipartFile对象 |
| | | MultipartFile multipartFile = new MockMultipartFile( |
| | | fileName + ".kmz", |
| | | fileName + ".kmz", |
| | | "application/vnd.google-earth.kmz", |
| | | new ByteArrayInputStream(baos.toByteArray()) |
| | | ); |
| | | String kmzFilePath = ossService.upload(kmzPath,multipartFile); |
| | | result.setPath(kmzFilePath); |
| | | return result; |
| | | }else { |
| | | try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | ZipOutputStream zipOutputStream = new ZipOutputStream(baos)) { |
| | | zipOutputStream.setLevel(0); |
| | | |
| | | // 创建 wpmz 目录中的 template.kml 文件条目 |
| | | buildZipFile("wpmz/template.kml", zipOutputStream, kml); |
| | | |
| | | // 创建 wpmz 目录中的 waylines.wpml 文件条目 |
| | | buildZipFile("wpmz/waylines.wpml", zipOutputStream, wpml); |
| | | |
| | | zipOutputStream.finish(); |
| | | zipOutputStream.flush(); |
| | | |
| | | // 获取文件大小 |
| | | Double fileSize = (double) baos.size(); // 字节数 |
| | | |
| | | // 创建MultipartFile对象 |
| | | MultipartFile multipartFile = new MockMultipartFile( |
| | | fileName + ".kmz", |
| | | fileName + ".kmz", |
| | | "application/vnd.google-earth.kmz", |
| | | new ByteArrayInputStream(baos.toByteArray()) |
| | | ); |
| | | String kmzFilePath = ossService.upload(kmzPath,multipartFile); |
| | | result.setPath(kmzFilePath); |
| | | return result; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("KMZ文件生成或上传失败", e); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("KMZ文件生成或上传失败", e); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public class ToolUtils { |
| | | |
| | | public static Boolean isLocal = false; |
| | | |
| | | public static String localFilePath = "KmzFile/kmz/"; |
| | | |
| | | public static String kmzPath = "kmz"; |
| | | |
| | | /** |
| | |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="pointCount" column="point_count" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectArdRouteInfoVo"> |
| | |
| | | create_by, |
| | | create_time, |
| | | update_by, |
| | | update_time |
| | | update_time, |
| | | point_count |
| | | from ard_route_info |
| | | </sql> |
| | | |
| | |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateBy != null">update_by,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="pointCount != null">point_count,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id},</if> |
| | |
| | | <if test="createTime != null">#{createTime},</if> |
| | | <if test="updateBy != null">#{updateBy},</if> |
| | | <if test="updateTime != null">#{updateTime},</if> |
| | | <if test="pointCount != null">#{pointCount},</if> |
| | | </trim> |
| | | </insert> |
| | | |
| | |
| | | <if test="createTime != null">create_time = #{createTime},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | | <if test="pointCount != null">point_count = #{pointCount},</if> |
| | | </trim> |
| | | where id = #{id} |
| | | </update> |
| | |
| | | </delete> |
| | | |
| | | <select id="selectArdRouteInfoByGroupId" parameterType="String" resultMap="ArdRouteInfoResult"> |
| | | select id,name,path,group_id,type,aircraft,payload,read_only,create_by,create_time,update_by,update_time from ard_route_info |
| | | select id,name,path,group_id,type,aircraft,payload,read_only,create_by,create_time,update_by,update_time,point_count from ard_route_info |
| | | <where> |
| | | <if test="groupId != null "> and group_id = #{groupId}</if> |
| | | </where> |