| | |
| | | import com.dji.sample.territory.dao.ITbFjMapper; |
| | | import com.dji.sample.territory.model.entity.TbFjEntity; |
| | | import com.dji.sample.territory.service.ITbFJService; |
| | | import com.dji.sample.territory.utils.HashUtil; |
| | | import com.dji.sample.territory.utils.Sm3Util; |
| | | import com.dji.sample.territory.utils.VideoZipUtil; |
| | | import com.dji.sample.territory.utils.WaterMarkUtil; |
| | | import com.dji.sample.territory.utils.*; |
| | | import org.bouncycastle.crypto.params.ECPrivateKeyParameters; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | String numberPart = focal.replaceAll("[^\\d]", ""); |
| | | int psjj = Integer.parseInt(numberPart); |
| | | json.getString("GimbalYawDegree"); |
| | | String fjhxz = HashUtil.SM3Hash(file); |
| | | BufferedImage image = ImageIO.read(file); |
| | | int width = image.getWidth(); |
| | | int height = image.getHeight(); |
| | | String fjhxz = null; |
| | | //对应图片和视频文件进行不同处理 |
| | | boolean endsWith = key.endsWith(".mp4"); |
| | | if (!endsWith) { |
| | | file1 = WaterMarkUtil.addWatermark(file, sj, lat, lng, gimbalYawDegree); |
| | | fjhxz = String.valueOf(SM3HashExample.HaXi(new File(file1.toURI()))); |
| | | FJ = fileToByteArray(file1); |
| | | } else { |
| | | file1 = VideoZipUtil.compressVideo(file, 800000, 128000, 1280, 720); |
| | | FJ = fileToByteArray(file1); |
| | | } |
| | | String hxz = HashUtil.calculateHash((fjhxz + "," + pssj + "," + lng + "," + lat + "," + gimbalYawDegree + "," + psjd + "," + pshgj + "," + psry + "," + zsdm).getBytes()); |
| | | byte[] hash = hxz.getBytes(); // 注意:使用SM3或其他哈希算法来计算数据的哈希值 |
| | | // 加载私钥 |
| | | ECPrivateKeyParameters sm2PrivateKey = getSM2PrivateKey(); |
| | | // 使用SM2私钥对哈希值进行签名 |
| | | String signatureHex = signWithSM2(hash, sm2PrivateKey); |
| | | String jym=SM2SignExamples.jym(hxz); |
| | | TbFjEntity.TbFjEntityBuilder builder = TbFjEntity.builder(); |
| | | if (lotInfo != null) { |
| | | builder.bsm(bsm) |
| | |
| | | .pshgj(pshgj) |
| | | .zsdm(zsdm) |
| | | .psry(psry) |
| | | .jym(signatureHex) |
| | | .jym(jym) |
| | | .url(url) |
| | | .pstz(pstz) |
| | | .fjyskd(width) |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(truncateToSevenDecimalPlaces(152.00666565)); |
| | | System.out.println(truncateToTwoDecimalPlaces(12.006)); |
| | | String s= String.valueOf(SM3HashExample.HaXi(new File("src/main/resources/FJ_10.jpeg"))); |
| | | System.out.println(s); |
| | | } |
| | | } |