| | |
| | | import javax.xml.crypto.Data; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | return count; |
| | | } |
| | | |
| | | public void insertOneData(MediaFileEntity mediaFile, LotInfo lotInfo) throws Exception { |
| | | public void insertOneData(MediaFileEntity mediaFile, LotInfo lotInfo) throws Exception { |
| | | TbFjEntity tbFj = dbConvertToEntity(mediaFile, lotInfo); |
| | | tbFjMapper.insert(tbFj); |
| | | if (tbFj.getFjysgd()==3000){ |
| | | tbFjMapper.insert(tbFj); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | Double absoluteAltitude = jsonObject.getDouble("absoluteAltitude"); |
| | | Double relativeAltitude = jsonObject.getDouble("relativeAltitude"); |
| | | Double gimbalYawDegree = jsonObject.getDouble("gimbalYawDegree"); |
| | | Long sj =jsonObject.getLong("createdTime"); |
| | | Long sj = jsonObject.getLong("createdTime"); |
| | | JSONObject shootPosition = jsonObject.getJSONObject("shootPosition"); |
| | | Double lat = shootPosition.getDouble("lat"); |
| | | Double lng = shootPosition.getDouble("lng"); |
| | |
| | | String zsdm = "23C8CCC61E3042FBA6A658F319337B1A"; |
| | | String dklx = "0"; |
| | | int fjlx = 1; |
| | | String pstz="Y"; |
| | | String pssj=convertTimestampToDateTime(sj); |
| | | String pstz = "Y"; |
| | | String pssj = convertTimestampToDateTime(sj); |
| | | String bsm = UUID.randomUUID().toString(); |
| | | String fjmc = mediaFile.getFileName(); |
| | | String key = mediaFile.getObjectKey(); |
| | |
| | | //对应图片和视频文件进行不同处理 |
| | | boolean endsWith = key.endsWith(".mp4"); |
| | | if (!endsWith) { |
| | | file1 = WaterMarkUtil.addWatermark(file, patchesConfigPojo.getUnzip(), sj, lat, lng,gimbalYawDegree); |
| | | file1 = WaterMarkUtil.addWatermark(file, patchesConfigPojo.getUnzip(), sj, lat, lng, gimbalYawDegree); |
| | | FJ = fileToByteArray(file1); |
| | | } else { |
| | | file1 = VideoZipUtil.compressVideo(file, 800000, 128000, 1280, 720); |
| | | FJ = fileToByteArray(file1); |
| | | } |
| | | String sm3 = Sm3Util.calculateSM3Hash(fjhxz+","+pssj+","+lng+","+lat+","+gimbalYawDegree+","+psjd+","+pshgj+","+psry+","+zsdm); |
| | | String sm3 = Sm3Util.calculateSM3Hash(fjhxz + "," + pssj + "," + lng + "," + lat + "," + gimbalYawDegree + "," + psjd + "," + pshgj + "," + psry + "," + zsdm); |
| | | |
| | | byte[] hash = sm3.getBytes(); // 注意:使用SM3或其他哈希算法来计算数据的哈希值 |
| | | // 加载私钥 |
| | |
| | | .dkbsm(lotInfo.getBsm()) |
| | | .xzqdm(lotInfo.getXzqdm()) |
| | | .dklx(dklx) |
| | | .xdgd(relativeAltitude) |
| | | .jdgd(absoluteAltitude) |
| | | .Latitude(lat) |
| | | .longitude(lng) |
| | | .xdgd(truncateToTwoDecimalPlaces(relativeAltitude)) |
| | | .jdgd(truncateToTwoDecimalPlaces(absoluteAltitude)) |
| | | .Latitude(truncateToSevenDecimalPlaces(lat)) |
| | | .longitude(truncateToSevenDecimalPlaces(lng)) |
| | | .fj(FJ) |
| | | .fjmc(fjmc) |
| | | .fjlx(fjlx) |
| | |
| | | fis.close(); |
| | | return data; |
| | | } |
| | | |
| | | public static String convertTimestampToDateTime(long timestamp) { |
| | | // 将时间戳转换为 Instant 对象 |
| | | Instant instant = Instant.ofEpochMilli(timestamp); |
| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | return dateTime.format(formatter); |
| | | } |
| | | } |
| | | |
| | | public static Double truncateToTwoDecimalPlaces(Double value) { |
| | | if (value == null) { |
| | | return null; // 处理null值情况 |
| | | } |
| | | BigDecimal bd = new BigDecimal(value).setScale(2, RoundingMode.DOWN); |
| | | return bd.doubleValue(); |
| | | } |
| | | public static Double truncateToSevenDecimalPlaces(Double value) { |
| | | if (value == null) { |
| | | return null; // 处理null值情况 |
| | | } |
| | | BigDecimal bd = new BigDecimal(value).setScale(7, RoundingMode.DOWN); |
| | | return bd.doubleValue(); |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(truncateToSevenDecimalPlaces(152.00666565)); |
| | | System.out.println(truncateToTwoDecimalPlaces(12.006)); |
| | | } |
| | | } |