diff --git a/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.bin b/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.bin index 9b11a2a3..090f72e5 100644 Binary files a/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.bin and b/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.bin differ diff --git a/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.lock b/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.lock index 2db9d72a..5ca23b84 100644 Binary files a/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.lock and b/API_SERVER/satellite/.gradle/8.1.1/executionHistory/executionHistory.lock differ diff --git a/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.bin b/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.bin index 734fedde..3a915f34 100644 Binary files a/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.bin and b/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.bin differ diff --git a/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.lock b/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.lock index 946a5554..f0bfd2bb 100644 Binary files a/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.lock and b/API_SERVER/satellite/.gradle/8.1.1/fileHashes/fileHashes.lock differ diff --git a/API_SERVER/satellite/.gradle/8.1.1/fileHashes/resourceHashesCache.bin b/API_SERVER/satellite/.gradle/8.1.1/fileHashes/resourceHashesCache.bin index 23d0a338..fc3f3516 100644 Binary files a/API_SERVER/satellite/.gradle/8.1.1/fileHashes/resourceHashesCache.bin and b/API_SERVER/satellite/.gradle/8.1.1/fileHashes/resourceHashesCache.bin differ diff --git a/API_SERVER/satellite/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/API_SERVER/satellite/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 7c10ee82..9d426e94 100644 Binary files a/API_SERVER/satellite/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/API_SERVER/satellite/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/API_SERVER/satellite/.gradle/file-system.probe b/API_SERVER/satellite/.gradle/file-system.probe index 7162ebdb..c18fcba1 100644 Binary files a/API_SERVER/satellite/.gradle/file-system.probe and b/API_SERVER/satellite/.gradle/file-system.probe differ diff --git a/API_SERVER/satellite/.idea/.gitignore b/API_SERVER/satellite/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/API_SERVER/satellite/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/API_SERVER/satellite/.idea/compiler.xml b/API_SERVER/satellite/.idea/compiler.xml new file mode 100644 index 00000000..14e0f3cc --- /dev/null +++ b/API_SERVER/satellite/.idea/compiler.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/API_SERVER/satellite/.idea/dbnavigator.xml b/API_SERVER/satellite/.idea/dbnavigator.xml new file mode 100644 index 00000000..352209ac --- /dev/null +++ b/API_SERVER/satellite/.idea/dbnavigator.xml @@ -0,0 +1,420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/API_SERVER/satellite/.idea/gradle.xml b/API_SERVER/satellite/.idea/gradle.xml new file mode 100644 index 00000000..ba1ec5c7 --- /dev/null +++ b/API_SERVER/satellite/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/API_SERVER/satellite/.idea/jarRepositories.xml b/API_SERVER/satellite/.idea/jarRepositories.xml new file mode 100644 index 00000000..fdc392fe --- /dev/null +++ b/API_SERVER/satellite/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/API_SERVER/satellite/.idea/misc.xml b/API_SERVER/satellite/.idea/misc.xml new file mode 100644 index 00000000..5d982561 --- /dev/null +++ b/API_SERVER/satellite/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/API_SERVER/satellite/.idea/vcs.xml b/API_SERVER/satellite/.idea/vcs.xml new file mode 100644 index 00000000..b2bdec2d --- /dev/null +++ b/API_SERVER/satellite/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/controller/TleDataController.class b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/controller/TleDataController.class index 250a4b79..e5eb89e2 100644 Binary files a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/controller/TleDataController.class and b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/controller/TleDataController.class differ diff --git a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/dto/UpdateTleDataDto.class b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/dto/UpdateTleDataDto.class index 653e9c2e..73d270ce 100644 Binary files a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/dto/UpdateTleDataDto.class and b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/dto/UpdateTleDataDto.class differ diff --git a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/repository/TleDataRepository.class b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/repository/TleDataRepository.class index bbb44c79..4de190aa 100644 Binary files a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/repository/TleDataRepository.class and b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/repository/TleDataRepository.class differ diff --git a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/service/TleDataService.class b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/service/TleDataService.class index 9f1b03e9..733ec473 100644 Binary files a/API_SERVER/satellite/build/classes/java/main/com/example/satellite/service/TleDataService.class and b/API_SERVER/satellite/build/classes/java/main/com/example/satellite/service/TleDataService.class differ diff --git a/API_SERVER/satellite/build/resources/main/application.yml b/API_SERVER/satellite/build/resources/main/application.yml new file mode 100644 index 00000000..f2dee3f8 --- /dev/null +++ b/API_SERVER/satellite/build/resources/main/application.yml @@ -0,0 +1,41 @@ +tle: + api-key: FZVfJwO7l89rRRJg67NE56mG0iat9wPEztjLkXJd + +server: +# address: localhost + address: 0.0.0.0 + port: 8080 + +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://14.52.137.81:3306/team_ed_user3?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC +# username: satellite +# password: Abcd123! + username: team_ed + password: team_ed!@#123 + jpa: + database: mysql + show-sql: true + hibernate: + ddl-auto: update + properties: + hibernate: + show_sql: true + format_sql: true +jwt: + issuer: cro7710@gmail.com + secret_key: satellite-project + +#app: +# datasource2: +# driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://localhost:3306/root?useSSL=false&serverTimezone=UTC +# username: satellite +# password: Abcd123! + +#logging: +# level: +# org: +# springframework: +# security: DEBUG \ No newline at end of file diff --git a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleData.class.uniqueId1 b/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleData.class.uniqueId1 deleted file mode 100644 index 0624e1c5..00000000 Binary files a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleData.class.uniqueId1 and /dev/null differ diff --git a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataController.class.uniqueId2 b/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataController.class.uniqueId0 similarity index 82% rename from API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataController.class.uniqueId2 rename to API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataController.class.uniqueId0 index 250a4b79..091fced1 100644 Binary files a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataController.class.uniqueId2 and b/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataController.class.uniqueId0 differ diff --git a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataRepository.class.uniqueId0 b/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataRepository.class.uniqueId0 deleted file mode 100644 index bbb44c79..00000000 Binary files a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataRepository.class.uniqueId0 and /dev/null differ diff --git a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataService.class.uniqueId1 b/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataService.class.uniqueId1 new file mode 100644 index 00000000..4a0a4f21 Binary files /dev/null and b/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataService.class.uniqueId1 differ diff --git a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataService.class.uniqueId3 b/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataService.class.uniqueId3 deleted file mode 100644 index 9f1b03e9..00000000 Binary files a/API_SERVER/satellite/build/tmp/compileJava/compileTransaction/stash-dir/TleDataService.class.uniqueId3 and /dev/null differ diff --git a/API_SERVER/satellite/build/tmp/compileJava/previous-compilation-data.bin b/API_SERVER/satellite/build/tmp/compileJava/previous-compilation-data.bin index 64af77ad..c67c04f8 100644 Binary files a/API_SERVER/satellite/build/tmp/compileJava/previous-compilation-data.bin and b/API_SERVER/satellite/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/API_SERVER/satellite/out/production/resources/application.yml b/API_SERVER/satellite/out/production/resources/application.yml new file mode 100644 index 00000000..f2dee3f8 --- /dev/null +++ b/API_SERVER/satellite/out/production/resources/application.yml @@ -0,0 +1,41 @@ +tle: + api-key: FZVfJwO7l89rRRJg67NE56mG0iat9wPEztjLkXJd + +server: +# address: localhost + address: 0.0.0.0 + port: 8080 + +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://14.52.137.81:3306/team_ed_user3?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC +# username: satellite +# password: Abcd123! + username: team_ed + password: team_ed!@#123 + jpa: + database: mysql + show-sql: true + hibernate: + ddl-auto: update + properties: + hibernate: + show_sql: true + format_sql: true +jwt: + issuer: cro7710@gmail.com + secret_key: satellite-project + +#app: +# datasource2: +# driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://localhost:3306/root?useSSL=false&serverTimezone=UTC +# username: satellite +# password: Abcd123! + +#logging: +# level: +# org: +# springframework: +# security: DEBUG \ No newline at end of file diff --git a/API_SERVER/satellite/src/main/java/com/example/satellite/controller/TleDataController.java b/API_SERVER/satellite/src/main/java/com/example/satellite/controller/TleDataController.java index 260e1ca0..288eadae 100644 --- a/API_SERVER/satellite/src/main/java/com/example/satellite/controller/TleDataController.java +++ b/API_SERVER/satellite/src/main/java/com/example/satellite/controller/TleDataController.java @@ -74,8 +74,8 @@ public List getTleDataBySatelliteId(@RequestParam String satelliteId) { } @PutMapping("/{satelliteId}") - public TleData updateTleData(@PathVariable int id, @RequestBody UpdateTleDataDto tleData) { - return service.updateTleData(id, tleData); + public TleData updateTleData(@PathVariable String satelliteId, @RequestBody UpdateTleDataDto tleData) { + return service.updateTleData(satelliteId, tleData); } } \ No newline at end of file diff --git a/API_SERVER/satellite/src/main/java/com/example/satellite/dto/UpdateTleDataDto.java b/API_SERVER/satellite/src/main/java/com/example/satellite/dto/UpdateTleDataDto.java index da5a7568..5f00f5fd 100644 --- a/API_SERVER/satellite/src/main/java/com/example/satellite/dto/UpdateTleDataDto.java +++ b/API_SERVER/satellite/src/main/java/com/example/satellite/dto/UpdateTleDataDto.java @@ -6,8 +6,5 @@ @Getter @Setter public class UpdateTleDataDto { // tle_data 수정할때 쓸 dto - private String satelliteNumber; private String name; - private String classification; - private String firstLaunch; } diff --git a/API_SERVER/satellite/src/main/java/com/example/satellite/repository/TleDataRepository.java b/API_SERVER/satellite/src/main/java/com/example/satellite/repository/TleDataRepository.java index 3386fccd..78184f8b 100644 --- a/API_SERVER/satellite/src/main/java/com/example/satellite/repository/TleDataRepository.java +++ b/API_SERVER/satellite/src/main/java/com/example/satellite/repository/TleDataRepository.java @@ -23,4 +23,6 @@ public interface TleDataRepository extends JpaRepository { List findByNameContaining(String satelliteName); Optional findBySatelliteId(String satelliteId); + + Optional findById(Integer id); } diff --git a/API_SERVER/satellite/src/main/java/com/example/satellite/service/TleDataService.java b/API_SERVER/satellite/src/main/java/com/example/satellite/service/TleDataService.java index 212cabda..cb7defdc 100644 --- a/API_SERVER/satellite/src/main/java/com/example/satellite/service/TleDataService.java +++ b/API_SERVER/satellite/src/main/java/com/example/satellite/service/TleDataService.java @@ -17,6 +17,7 @@ import java.util.Optional; import java.util.stream.Collectors; + @Service public class TleDataService { @@ -73,19 +74,15 @@ public List getSearchedTleData(String satelliteName) { return repository.findByNameContaining(satelliteName); } - public TleData updateTleData(int id, UpdateTleDataDto updateTleDataDto) { - if(repository.existsById((long) id)){ - TleData tleData = repository.findById((long) id).get(); - tleData.setSatelliteNumber(updateTleDataDto.getSatelliteNumber()); - tleData.setName(updateTleDataDto.getName()); - tleData.setClassification(updateTleDataDto.getClassification()); - tleData.setFirstLaunch(updateTleDataDto.getFirstLaunch()); - return repository.save(tleData); - } else { - throw new ResponseStatusException(HttpStatus.NOT_FOUND, "TleData not found"); - } + + public TleData updateTleData(String id, UpdateTleDataDto updateTleDataDto) { + TleData tleData = repository.findBySatelliteId(id) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "TleData not found")); + tleData.setName(updateTleDataDto.getName()); + return repository.save(tleData); } + public List getSearchedTleDataBySatelliteId(String satelliteId) { Optional optionalTleData = repository.findBySatelliteId(satelliteId); return optionalTleData.map(Collections::singletonList).orElse(Collections.emptyList()); diff --git a/API_SERVER/satellite/src/main/resources/application.yml b/API_SERVER/satellite/src/main/resources/application.yml new file mode 100644 index 00000000..f2dee3f8 --- /dev/null +++ b/API_SERVER/satellite/src/main/resources/application.yml @@ -0,0 +1,41 @@ +tle: + api-key: FZVfJwO7l89rRRJg67NE56mG0iat9wPEztjLkXJd + +server: +# address: localhost + address: 0.0.0.0 + port: 8080 + +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://14.52.137.81:3306/team_ed_user3?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC +# username: satellite +# password: Abcd123! + username: team_ed + password: team_ed!@#123 + jpa: + database: mysql + show-sql: true + hibernate: + ddl-auto: update + properties: + hibernate: + show_sql: true + format_sql: true +jwt: + issuer: cro7710@gmail.com + secret_key: satellite-project + +#app: +# datasource2: +# driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://localhost:3306/root?useSSL=false&serverTimezone=UTC +# username: satellite +# password: Abcd123! + +#logging: +# level: +# org: +# springframework: +# security: DEBUG \ No newline at end of file diff --git a/apps/data_collectors/nasa_data.js b/apps/data_collectors/nasa_data.js index d2bcd95e..09130f31 100644 --- a/apps/data_collectors/nasa_data.js +++ b/apps/data_collectors/nasa_data.js @@ -33,15 +33,19 @@ async function sleep(ms) { } function saveTLEInfo(updatedCount, newCount, totalCount, fetchTime) { - const queryInsertInfo = "INSERT INTO tle_data_info (updated_count, new_count, total_count, fetch_time) VALUES (?, ?, ?, ?)"; - - connection.query(queryInsertInfo, [updatedCount, newCount, totalCount, fetchTime], (error, results) => { - if (error) { - console.error("Error saving TLE info:", error); - } else { - //console.log("TLE info saved successfully."); + const queryInsertInfo = + "INSERT INTO tle_data_info (updated_count, new_count, total_count, fetch_time) VALUES (?, ?, ?, ?)"; + connection.query( + queryInsertInfo, + [updatedCount, newCount, totalCount, fetchTime], + (error, results) => { + if (error) { + console.error("Error saving TLE info:", error); + } else { + //console.log("TLE info saved successfully."); + } } - }); + ); } async function getTotalCount() { @@ -81,6 +85,116 @@ function calculateSatellitePosition(line1, line2, date) { }; } +function updateInfoBasedOnName(name) { + if (name.startsWith('BEIDOU')) { + return '중국'; + } else if (name.startsWith('COSMOS')) { + return '러시아'; + } else if (name.startsWith('EUTELSAT')) { + return 'Eutelsat'; + } else if (name.startsWith('FALCON')) { + return 'SpaceX'; + } else if (name.startsWith('FENGYUN')) { + return '중국'; + } else if (name.startsWith('GALAXY')) { + return 'Intelsat'; + } else if (name.startsWith('INTELSAT')) { + return 'Intelsat'; + } else if (name.startsWith('GAOFEN')) { + return '중국'; + } else if (name.startsWith('GLOBALSTAR')) { + return 'Globalstar'; + } else if (name.startsWith('GONETS')) { + return '러시아'; + } else if (name.startsWith('GORIZONT')) { + return '러시아'; + } else if (name.startsWith('GOES')) { + return '미국'; + } else if (name.startsWith('GPS BIIA')) { + return '미국'; + } else if (name.startsWith('GPS BIIF')) { + return '미국'; + } else if (name.startsWith('GPS BIII')) { + return '미국'; + } else if (name.startsWith('GPS BIIIR')) { + return '미국'; + } else if (name.startsWith('GPS BIIIRM')) { + return '미국'; + } else if (name.startsWith('GSAT')) { + return '인도'; + } else if (name.startsWith('IRIDIUM')) { + return 'Iridium communication system'; + } else if (name.startsWith('LEMUR')) { + return 'Spire Global'; + } else if (name.startsWith('MOLNIYA')) { + return '러시아'; + } else if (name.startsWith('RADUGA')) { + return '러시아'; + } else if (name.startsWith('NUSAT')) { + return '아르헨티나'; + } else if (name.startsWith('ONEWEB')) { + return 'ONEWEB'; + } else if (name.startsWith('ORBCOMM')) { + return 'ORBCOMM'; + } else if (name.startsWith('SHIJIAN')) { + return '중국'; + } else if (name.startsWith('SHIYAN')) { + return '중국'; + } else if (name.startsWith('SPACEBEE')) { + return 'Swarm Technologies'; + } else if (name.startsWith('STARLINK')) { + return 'SpaceX'; + } else if (name.startsWith('APRIZESAT')) { + return '미국, 영국'; + } else if (name.startsWith('ASTROCAST')) { + return 'Astrocast SA'; + } else if (name.startsWith('CHINASAT')) { + return '중국'; + } else if (name.startsWith('CZ')) { + return '중국'; + } else if (name.startsWith('ECHOSTAR')) { + return 'EchoStar Satellite Services'; + } else if (name.startsWith('YAOGAN')) { + return '중국'; + } else if (name.startsWith('ISS')) { + return '국제우주정거장'; + } else if (name.startsWith('YUNHAI')) { + return '중국'; + } else if (name.startsWith('NOAA')) { + return '미국'; + } else if (name.startsWith('USA')) { + return '미국'; + } else if (name.startsWith('WGS')) { + return '미국'; + } else if (name.startsWith('UNKNOWN')) { + return '비식별위성'; + } else if (name.startsWith('GALILEO')) { + return '유럽'; + } else if (name.startsWith('ROBUSTA')) { + return '프랑스'; + } else if (name.startsWith('INMARSAT')) { + return 'Inmarsat'; + } else if (name.startsWith('JILIN')) { + return '중국'; + } else if (name.startsWith('KANOPUS')) { + return '러시아'; + } else if (name.startsWith('KEPLER')) { + return 'NASA'; + } else if (name.startsWith('KOREASAT')) { + return '대한민국'; + } else if (name.startsWith('KSF')) { + return '대한민국'; + } else if (name.startsWith('O3B')) { + return 'O3B Networks'; + } else if (name.startsWith('SAUDI')) { + return '사우디 아라비아'; + } else if (name.startsWith('SKYSAT')) { + return 'Planets Labs'; + } + + return null; +} + function processTLEData(tleData, fetchTime) { const extractedTLEData = []; @@ -117,6 +231,7 @@ function processTLEData(tleData, fetchTime) { const satellitePosition = calculateSatellitePosition(line1, line2, new Date(tle.date)); const latitude = satellitePosition.latitude; const longitude = satellitePosition.longitude; + const info = updateInfoBasedOnName(tle.name); extractedTLEData.push({ satellite_id: tle.satelliteId, @@ -129,6 +244,8 @@ function processTLEData(tleData, fetchTime) { fetch_timestamp: fetchTime, latitude: latitude, longitude: longitude, + info: info, + isNew: true, }); } else { console.error("Line data is not available for this TLE."); @@ -154,7 +271,10 @@ function saveTLEData(tleData, fetchTime) { const latitude = tle.latitude; const longitude = tle.longitude; const first_launch = line1Fields.firstLaunch; + const isNew = tle.isNew ? 1 : 0; + const info = tle.info; + //console.log(`Satellite Name: ${name}, Info: ${info}`); const changed_time = new Date() .toISOString() .slice(0, 19) @@ -193,12 +313,14 @@ function saveTLEData(tleData, fetchTime) { fetch_timestamp: fetchTime, latitude: latitude, longitude: longitude, + info: info, + isNew: isNew, }, (error, results) => { if (error) { console.error("Error saving TLE data:", error); } else { - //console.log("TLE data saved successfully for:", name); + //console.log("TLE data saved successfully for :",name); } } ); @@ -232,12 +354,13 @@ function saveTLEData(tleData, fetchTime) { changed_time, latitude, longitude, + isNew, ], (error, results) => { if (error) { console.error("Error saving TLE data to tle_data_log:", error); } else { - //console.log("TLE data saved to tle_data_log successfully for:",name); + //console.log("TLE data saved to tle_data_log successfully for:", name); } } ); @@ -267,28 +390,23 @@ function saveTLEData(tleData, fetchTime) { fetch_timestamp: fetchTime, latitude: latitude, longitude: longitude, + info: info, }; const hasChanges = JSON.stringify(existingData) !== JSON.stringify(newData); - if (hasChanges) { - connection.query( - queryUpdate, - [{ ...newData }, satellite_id], - (error, results) => { + if (hasChanges) { + connection.query(queryUpdate, [{ ...newData }, satellite_id], (error, results) => { if (error) { console.error("Error updating TLE data:", error); } else { - //console.log("TLE data updated successfully for:", name); + //console.log("TLE data saved successfully:", name); } - } - ); - - // tle_data_log 테이블 - connection.query( - queryInsertLog, - [ + }); + + // tle_data_log 테이블 + connection.query(queryInsertLog, [ satellite_id, name, date, @@ -314,6 +432,7 @@ function saveTLEData(tleData, fetchTime) { changed_time, latitude, longitude, + isNew ? 1 : 0, ], (error, results) => { if (error) { @@ -361,14 +480,13 @@ async function fetchTLE() { const extractedTLEData = processTLEData(tleData.member, formattedFetchTime); const updatedCount = extractedTLEData.length; - const newCount = extractedTLEData.filter(entry => entry.isNew).length; + const newCount = extractedTLEData.filter(tle => tle.isNew === 1).length; totalUpdatedCount += updatedCount; totalNewCount += newCount; if (extractedTLEData.length > 0) { await saveTLEData(extractedTLEData, formattedFetchTime); - } else { console.error("Processed TLE data is empty or invalid."); } @@ -379,17 +497,19 @@ async function fetchTLE() { if (pageCounter === 100) { console.log(`Wait...`); - await sleep(15 * 60 * 1000); // 100페이지마다 15분 대기 + await sleep(10 * 60 * 1000); // 100페이지마다 10분 대기 pageCounter = 0; } } - const totalCount = await getTotalCount(); + const totalCount = await getTotalCount(); saveTLEInfo(totalUpdatedCount, totalNewCount, totalCount, formattedFetchTime); } catch (error) { console.error("Error fetching or saving TLE data:", error); - console.log("Retrying in 1 hour..."); + + const totalCount = await getTotalCount(); + saveTLEInfo(totalUpdatedCount, totalNewCount, totalCount, formattedFetchTime);; if (connection && !connection._closed) { connection.end(); @@ -397,31 +517,22 @@ async function fetchTLE() { await sleep(60 * 60 * 1000); - connection = mysql.createConnection(mysqlConfig); - connection.connect((error) => { - if (error) { - console.error("Error connecting to the database:", error); - } else { - console.log("Reconnected to the MySQL database."); - fetchTLE(); - } - }); + fetchTLE(); } } + async function run() { while (true) { totalUpdatedCount = 0; + totalNewCount = 0; console.log("Fetching TLE data from API..."); try { await fetchTLE(); - const totalCount = await getTotalCount(); - const fetchTime = new Date().toISOString().slice(0, 19).replace("T", " "); - saveTLEInfo(totalUpdatedCount, totalNewCount, totalCount, fetchTime); } catch (error) { console.error("Error occurred:", error); } - await sleep(120 * 60 * 1000); // 120분마다 갱신 + await sleep(150 * 60 * 1000); // 150분마다 갱신 } }