Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sql.query("SELECT * FROM Users WHERE token like ?",json.token,function (err,res) {
- if(!err){
- if(res.length>0){
- var hospitals;
- sql.query("SELECT * FROM " +
- " HospitalDepartaments WHERE title" +
- " like ?",json.title,function (err,res) {
- if(!err){
- var workload = [res.length];
- for(var i=0;i<res.length;i++){
- workload[i] = ((res[i].online/res[i].doctors)-1)*(-1);
- workload[i]= workload[i].toFixed(2);
- }
- //SERVER 3-matrix
- sql.query("SELECT * FROM Hospitals",function (err,res) {
- var arr=[workload.length];
- var mas = [0,0,0,0,0];
- for(var z=0;z<workload.length;z++){
- arr[z]=[workload.length];
- for(var i=0;i<workload.length-1;i++){
- arr[z][i] = [3];
- if(z!=i){
- arr[z][i][0]= res[i+1].lat - res[i].lat;
- arr[z][i][1]= res[i+1].lnt - res[i].lnt;
- arr[z][i][2]= workload[i+1] - workload[i];
- if(i>0 && i<workload.length-1){
- if(arr[z][i-1][0] < arr[z][i][0]){
- mas[z]++;
- }
- if(arr[z][i-1][1]<arr[z][i][1]){
- mas[z]++;
- }
- if(arr[z][i-1][2]<arr[z][i][2]){
- mas[z]++;
- }
- }
- }
- }
- }
- var index =0;
- for(var i=0;i<mas.length;i++){
- if(mas[index] < mas[i]){
- index = i;
- }
- }
- result.end(JSON.stringify({
- lat : res[index].lat,
- lnt : res[index].lnt,
- title: res[index].title
- }));
- });
- }
- })
- }
- }
- })
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement