Skip to content

Commit

Permalink
Merge branch 'main' into Frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
KyuTae98 authored Dec 11, 2023
2 parents 646035c + 607c622 commit b61c2a7
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 55 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
git pull origin main
cd ${{ secrets.PWD }}/BackendJS/BackendTS
npm install
pm2 restart Traffic
pm2 reload Traffic --time
- if: github.event.pull_request.merged == true && github.head_ref == 'Frontend'
uses: appleboy/ssh-action@master
with:
Expand All @@ -34,9 +34,5 @@ jobs:
cd ${{ secrets.PWD }}
git pull origin main
cd ${{ secrets.PWD }}/Backend/Frontend/creative
pm2 stop Traffic
npm install
npm run build
cd ${{ secrets.PWD }}/BackendJS/BackendTS
npm install
pm2 restart Traffic
npm run build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import styled from "styled-components";

import {moveSubway} from "./signUtil.tsx"
import BusTimer from "../bus-component/buslist/BusTimer.tsx"

import useBusTimer from "../../hook/useBusTImer.tsx";

const StyledSignInfoList = styled.ul`
Expand Down Expand Up @@ -32,8 +31,6 @@ const StyledSingBusTimer = styled.div`


const SignDetailInfoList = ({info}:any) => {

console.log(info)
if(info.trafficType===2){//버스
return (
<StyledSignInfoList>
Expand Down
2 changes: 1 addition & 1 deletion Backend/Frontend/creative/src/page/BusPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
flex-direction: column;
align-items: center;
justify-content: start;
height: 100vh;
height: 85vh;
}
2 changes: 1 addition & 1 deletion Backend/Frontend/creative/src/page/SignPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
flex-direction: column;
align-items: center;
justify-content: start;
height: 100vh;
height: 85vh;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
flex-direction: column;
align-items: center;
justify-content: start;
height: 100vh;
height: 85vh;
}
90 changes: 80 additions & 10 deletions BackendJS/BackendTS/routes/navigation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand All @@ -14,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
const express_1 = __importDefault(require("express"));
const request_1 = __importDefault(require("request"));
const serviceKey_json_1 = __importDefault(require("../KEY/serviceKey.json"));
const db = __importStar(require("../db"));
const router = express_1.default.Router();
const velocity = 46.8;
function deg2rad(deg) {
Expand Down Expand Up @@ -427,23 +451,35 @@ router.get('/:startX/:startY/:endX/:endY/:type', (req, res) => __awaiter(void 0,
const NavigationList = JSON.parse(body).result;
//console.log(error);
//console.log(response);
//275 -> 10분
//10분 ->
//버스 환승 ->
//
//1. 도보 시간, 2. 환승 개수, 3. 총 이동 시간
NavigationList.path.sort((a, b) => {
if (a.info.totalWalk === b.info.totalWalk) {
if (a.info.busTransitCount + a.info.subwayTransitCount === b.info.busTransitCount + b.info.subwayTransitCount) {
return a.info.totalTime - b.info.totalTime;
//가중치 계산
const weight_A = a.info.totalWalk / 300 * 30 + a.info.totalTime + a.info.busTransitCount * 10 + a.info.subwayTransitCount * 5;
const weight_B = b.info.totalWalk / 300 * 30 + b.info.totalTime + b.info.busTransitCount * 10 + b.info.subwayTransitCount * 5;
if (weight_A === weight_B) {
if (a.info.totalWalkTime === b.info.totalWalkTime) {
if (a.info.busTransitCount + a.info.subwayTransitCount === b.info.busTransitCount + b.info.busTransitCount) {
return a.info.totalTime - b.info.totalTime;
}
else {
return a.info.busTransitCount + a.info.subwayTransitCount - b.info.busTransitCount + b.info.busTransitCount;
}
}
else {
return a.info.busTransitCount + a.info.subwayTransitCount - b.info.busTransitCount + b.info.subwayTransitCount;
return a.info.totalWalkTime - b.info.totalWalkTime;
}
}
else {
return a.info.totalWalk - b.info.totalWalk;
return weight_A - weight_B;
}
});
//상위 5개 경로만 반환
NavigationList.path = NavigationList.path.slice(0, 5);
NavigationList.path.forEach(element => {
NavigationList.path.forEach((element) => __awaiter(this, void 0, void 0, function* () {
//일반인 기준 이동시간 저장
const t = element.info.totalWalkTime;
//도보 이동 시간 계산
Expand All @@ -459,7 +495,7 @@ router.get('/:startX/:startY/:endX/:endY/:type', (req, res) => __awaiter(void 0,
delete element.info.checkIntervalTime;
delete element.info.checkIntervalTimeOverYn;
//subPath 정리
element.subPath.forEach(element => {
yield element.subPath.forEach((element) => __awaiter(this, void 0, void 0, function* () {
//도보인 경우
if (element.trafficType === 3) {
//교통약자 평균 이동속도에 맞게 이동시간 조정
Expand All @@ -485,10 +521,44 @@ router.get('/:startX/:startY/:endX/:endY/:type', (req, res) => __awaiter(void 0,
//지하철인 경우
else if (element.trafficType === 1) {
delete element.lane[0].subwayCityCode;
if (element.lane[0].name === "수도권 분당선(급행)") {
element.lane[0].subwayCode = 10;
}
else if (element.lane[0].name === "수도권 신분당선") {
element.lane[0].subwayCode = 11;
}
const getSationInfo = (name, subwayCode) => new Promise((res, rej) => {
const SQL = "Select * from subcode_1 where STIN_NM LIKE ? and LN_CD = ?;";
const connection = db.return_connection();
connection.query(SQL, ['%' + name + '%', subwayCode], function (err, results, fields) {
if (err) {
console.log(err);
return rej(err);
}
else {
return res({
stCd: results[0].STIN_CD,
lnCd: results[0].LN_CD,
railCd: results[0].RAIL_OPR_ISTT_CD,
stNm: results[0].STIN_NM
});
}
});
});
const startInfo = yield getSationInfo(element.passStopList.stations[0].stationName, element.lane[0].subwayCode);
const endInfo = yield getSationInfo(element.passStopList.stations[element.passStopList.stations.length - 1].stationName, element.lane[0].subwayCode);
element.passStopList.stations[0].stNm = startInfo.stNm;
element.passStopList.stations[0].stCd = startInfo.stCd;
element.passStopList.stations[0].lnCd = startInfo.lnCd;
element.passStopList.stations[0].railCd = startInfo.railCd;
element.passStopList.stations[element.passStopList.stations.length - 1].stNm = endInfo.stNm;
element.passStopList.stations[element.passStopList.stations.length - 1].stCd = endInfo.stCd;
element.passStopList.stations[element.passStopList.stations.length - 1].lnCd = endInfo.lnCd;
element.passStopList.stations[element.passStopList.stations.length - 1].railCd = endInfo.railCd;
}
});
});
return res.status(200).json(NavigationList.path);
}));
}));
return setTimeout(() => res.status(200).json(NavigationList.path), 1000);
});
});
}
Expand Down
63 changes: 48 additions & 15 deletions BackendJS/BackendTS/routes/subwaydata.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,53 @@ function getSubwayStationName(stNm, callback) {
const connection = db.return_connection();
let SQL = "Select * FROM subcode_1 a, 도우미번호 b WHERE (a.stin_nm = b.역명 and a.ln_cd = b.운영노선명) and a.STIN_NM like ?; ";
let nameList = [];
connection.query(SQL, ["%" + stNm + "%"], function (err, results, fields) {
if (err) {
console.log(err);
}
for (let i = 0; i < results.length; i++) {
nameList.push({
railCd: results[i].RAIL_OPR_ISTT_CD,
lnCd: results[i].LN_CD,
lnNm: results[i].LN_CD,
stCd: results[i].STIN_CD,
stNm: results[i].STIN_NM,
const getGPS = (STIN_NM, STIN_CD, LN_CD, RAIL_OPR_ISTT_CD) => new Promise((req, rej) => {
const url = 'https://openapi.kric.go.kr/openapi/convenientInfo/stationInfo';
let queryParams = '?' + encodeURI('serviceKey');
queryParams += '=' + serviceKey_json_1.default.subwayRailKey;
queryParams += '&' + encodeURI('format') + '=' + encodeURI('json');
queryParams += '&' + encodeURI('railOprIsttCd');
queryParams += '=' + encodeURI(RAIL_OPR_ISTT_CD);
queryParams += '&' + encodeURI('lnCd');
queryParams += '=' + encodeURI(LN_CD);
queryParams += '&' + encodeURI('stinCd');
queryParams += '=' + encodeURI(STIN_CD);
queryParams += '&' + encodeURI('stinNm');
queryParams += '=' + encodeURI(STIN_NM);
(0, request_1.default)({
url: url + queryParams,
method: 'GET'
}, function (error, response, body) {
const stationinfo = JSON.parse(body).body[0];
//NULL error
if (stationinfo === undefined) {
return callback(null);
}
req({
tmX: stationinfo.stinLocLon,
tmY: stationinfo.stinLocLat,
});
}
callback(nameList);
});
});
connection.query(SQL, ["%" + stNm + "%"], function (err, results, fields) {
return __awaiter(this, void 0, void 0, function* () {
if (err) {
console.log(err);
}
for (let i = 0; i < results.length; i++) {
const tm = yield getGPS(results[0].STIN_NM, results[0].STIN_CD, results[0].LN_CD, results[0].RAIL_OPR_ISTT_CD);
nameList.push({
railCd: results[i].RAIL_OPR_ISTT_CD,
lnCd: results[i].LN_CD,
lnNm: results[i].LN_CD,
stCd: results[i].STIN_CD,
stNm: results[i].STIN_NM,
tmX: tm.tmX,
tmY: tm.tmY
});
}
callback(nameList);
});
});
}
catch (e) {
Expand All @@ -69,7 +102,7 @@ function getSubwayStationName(stNm, callback) {
function getSubwayStationInfo(stCd, stNm, callback) {
try {
const connection = db.return_connection();
let sql = "Select * FROM subcode_1 a, 도우미번호 b WHERE (a.stin_nm = b.역명 and a.ln_cd = b.운영노선명) and a.stin_cd = ? and a.stin_nm = ?";
let sql = "Select RAIL_OPR_ISTT_CD, LN_CD, STIN_CD, STIN_NM, `교통약자도우미 전화번호` as wNum, en_name, f_code FROM subcode_1 a, 도우미번호 b WHERE (a.stin_nm = b.역명 and a.ln_cd = b.운영노선명) and a.stin_cd = ? and a.stin_nm = ?";
connection.query(sql, [stCd, stNm], function (err, results, fields) {
if (err) {
console.log(err);
Expand Down Expand Up @@ -107,7 +140,7 @@ function getSubwayStationInfo(stCd, stNm, callback) {
roadNm: stationinfo.roadNmAdr,
tmX: stationinfo.stinLocLon,
tmY: stationinfo.stinLocLat,
wNum: results[0].wnum,
wNum: results[0].wNum,
eName: results[0].en_name,
fCode: results[0].f_code
});
Expand Down
2 changes: 1 addition & 1 deletion BackendJS/BackendTS/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const httpsOptions = {
cert: fs_1.default.readFileSync('./KEY/rootca.crt')
};
let corsOptions = {
origin: ['http://localhost:3000/#/', 'http://localhost:3000', 'http://localhost:3005', 'http://34.168.80.42:3000', 'http://172.30.1.35:5000', 'http://localhost:5000', 'http://localhost:80', 'http://localhost:80/#/', 'https://www.easy-taza.site'],
origin: ['http://localhost:3000/#/', 'http://localhost:3000', 'http://localhost:3005', 'http://34.168.80.42:3000', 'http://172.30.1.35:5000', 'http://localhost:5000', 'http://localhost:80', 'http://localhost:80/#/', 'https://www.easy-taza.site', 'https://.easy-taza.site'],
credentials: true
};
app.use((0, cors_1.default)(corsOptions));
Expand Down
Loading

0 comments on commit b61c2a7

Please sign in to comment.