| | |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | public TbFjEntity insertData(List<MediaFileEntity> mediaFile, LotInfo lotInfo) throws IOException { |
| | | TbFjEntity tbFj = new TbFjEntity(); |
| | | public int insertData(List<MediaFileEntity> mediaFile, LotInfo lotInfo) throws IOException { |
| | | int count = 0; |
| | | List<TbFjEntity> list = new ArrayList<>(); |
| | | TbFjEntity tbFj; |
| | | for (int i = 0; i < mediaFile.size(); i++) { |
| | | MediaFileEntity file = mediaFile.get(i); |
| | | tbFj = dbConvertToEntity(file, lotInfo); |
| | | try { |
| | | mapper.insert(tbFj); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | list.add(tbFj); |
| | | mapper.insert(tbFj); |
| | | count++; |
| | | } |
| | | return tbFj; |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | |
| | | JSONObject shootPosition = jsonObject.getJSONObject("shootPosition"); |
| | | Double lat = shootPosition.getDouble("lat"); |
| | | Double lng = shootPosition.getDouble("lng"); |
| | | int psjd = 0; |
| | | String fjhxz = "0"; |
| | | int pshgj = 0; |
| | | String jym = "0"; |
| | | String psry = "0"; |
| | | String zsdm = "0"; |
| | | String dklx = "0"; |
| | | String xzqdm = "0"; |
| | | Long pssj = mediaFile.getCreateTime(); |
| | | String bsm= UUID.randomUUID().toString(); |
| | | String fjmc= mediaFile.getFileName(); |
| | | String bsm = UUID.randomUUID().toString(); |
| | | String fjmc = mediaFile.getFileName(); |
| | | String key = mediaFile.getObjectKey(); |
| | | String head = "http://dev.jxpskj.com:9000/cloud-bucket"; |
| | | String url = head + key; |
| | | byte[] FJ = downloadFileAsBytes(url); |
| | | TbFjEntity.TbFjEntityBuilder builder = TbFjEntity.builder(); |
| | | if (lotInfo != null){ |
| | | builder.bsm(bsm) |
| | | .dkbsm(lotInfo.getDkbh()) |
| | | .xzqdm(lotInfo.getXzqdm()) |
| | | .dklx(lotInfo.getDklx()) |
| | | .xdgd(relativeAltitude) |
| | | .jdgd(absoluteAltitude) |
| | | .Latitude(lat) |
| | | .longitude(lng) |
| | | .fj(FJ) |
| | | .fjmc(fjmc) |
| | | .fjlx(1) |
| | | .psfyj(gimbalYawDegree) |
| | | .pssj(String.valueOf(pssj)) |
| | | .build();} |
| | | else { |
| | | if (lotInfo != null) { |
| | | builder.bsm(bsm) |
| | | .dkbsm(lotInfo.getDkbh()) |
| | | .xzqdm(xzqdm) |
| | | .dklx(dklx) |
| | | .xdgd(relativeAltitude) |
| | | .jdgd(absoluteAltitude) |
| | | .Latitude(lat) |
| | | .longitude(lng) |
| | | .fj(FJ) |
| | | .fjmc(fjmc) |
| | | .fjlx(1) |
| | | .psfyj(gimbalYawDegree) |
| | | .pssj(String.valueOf(pssj)) |
| | | .psjd(psjd) |
| | | .fjhxz(fjhxz) |
| | | .pshgj(pshgj) |
| | | .zsdm(zsdm) |
| | | .psry(psry) |
| | | .jym(jym) |
| | | .build(); |
| | | } else { |
| | | throw new IllegalArgumentException("未匹配到相关地块"); |
| | | } |
| | | return builder.build(); |