Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. procedure TForm2.Button4Click(Sender: TObject);
  2.  
  3. var
  4.  JSON: TJSONObject;
  5.   JSON1: TJSONArray;
  6.   track: string;
  7.   track1: string;
  8.   track2: TJSONArray;
  9.   result1:string;
  10.   temp: string;
  11.   km_count, str_time, departure_from, temp1, temp2: string;
  12.   i, j, count2, grid_counter, mass_counter: integer;
  13.   count1 : double;
  14.   arr_flag: array [0..100] of string;
  15.   myDate : TDateTime;
  16.   checker: string;
  17.   arr_stop: array [0..100] of string;
  18.   counter3: integer;
  19.   counter2: integer;
  20.   counter1: integer;
  21.   qwe: string;
  22.  
  23.     begin
  24. Chromium1.Browser.MainFrame.ExecuteJavaScript('delete_track()','about:blank', 0);
  25.  
  26.  counter := 0;
  27.  counter1 := 0;
  28.  counter2 := 0;
  29.  counter3 := 0;
  30.  o := 0;
  31.  p := 0;
  32.  l := 0;
  33.  dynRESTreq.Params.AddItem('svc', 'report/exec_report', TRESTRequestParameterKind.pkGETorPOST);
  34.   dynRESTreq.Params.AddItem('params', '{"reportResourceId":14464460,"reportTemplateId":2,"reportTemplate":null,"reportObjectId":14453179,"reportObjectSecId":0,"interval":{"flags":16777216,"from":1481500800,"to":1486021378}}', TRESTRequestParameterKind.pkGETorPOST);
  35.   dynRESTreq.Params.AddItem('sid', result ,TRESTRequestParameterKind.pkGETorPOST);
  36.   dynRESTreq.Execute;
  37.  
  38.  str_report := dynRESTresp.Content;
  39.  
  40.   Json := TJSONObject.ParseJSONValue(str_report) as TJSONObject;
  41.   if not Assigned(JSON) then  raise Exception.Create('Файл не содержит JSON-данные');
  42.   dynRESTreq.Params.AddItem('svc', 'report/select_result_rows', TRESTRequestParameterKind.pkGETorPOST);
  43.   dynRESTreq.Params.AddItem('params', '{"tableIndex":0,"config":{"type":"range","data":{"from":0,"to":100,"level":0}}}', TRESTRequestParameterKind.pkGETorPOST);
  44.   dynRESTreq.Params.AddItem('sid', result ,TRESTRequestParameterKind.pkGETorPOST);
  45.   dynRESTreq.Execute;
  46.    str_report := '';
  47.   str_report := dynRESTresp.Content;
  48.  
  49.  
  50.  
  51.   Json1 := TJSONObject.ParseJSONValue(str_report) as TJSONArray;
  52.   if not Assigned(JSON1) then  raise Exception.Create('Файл не содержит JSON-данные');
  53.   for i := 0 to Json1.Size-1 do begin
  54.  
  55.  
  56.   track2 := ((Json1.Get(i) as TJSONObject).Get('c').JsonValue as TJSONArray);
  57.  
  58. if (ContainsText(track2.ToString, 'y') and ContainsText(track2.ToString, 'x')) then begin
  59.  
  60.   checker := ((track2.Get(2) as TJSONObject).Get('t').JsonValue.Value);//Место
  61.     if (ContainsText(checker, 'значение датчика')) then  begin
  62.     arr_flag[counter] := ((track2.Get(2) as TJSONObject).Get('t').JsonValue.Value);
  63.     arr_flag[counter+1] := ((track2.Get(2) as TJSONObject).Get('y').JsonValue.Value);
  64.     arr_flag[counter+2] := ((track2.Get(2) as TJSONObject).Get('x').JsonValue.Value);
  65.     counter := counter+3;
  66.     end;
  67.  
  68.  
  69.  
  70.   end;
  71.  
  72.   end;
  73.  
  74.  
  75.  
  76.  
  77.  
  78. for j := 0 to (counter div 3) - 1 do begin
  79.       if (ContainsText(arr_flag[counter1], 'значение датчика')) then begin
  80.  
  81.   if (StrToFloat(copy(arr_flag[counter1], pos( 'лось с ', arr_flag[counter1])+7, pos('т на', arr_flag[counter1]) - pos( 'лось с ', arr_flag[counter1])-8)) > StrToFloat(copy(arr_flag[counter1], pos( 'т на ', arr_flag[counter1])+5, arr_flag[counter1].Length-2 - pos( 'т на ', arr_flag[counter1])-5))) then
  82.    begin
  83.   Chromium1.Browser.MainFrame.ExecuteJavaScript('flagDrowFinish(' + '"' + arr_flag[counter1] + '"' + ',' + arr_flag[counter1+1] +',' + arr_flag[counter1+2] +',' + IntToStr(j+1) +')','about:blank', 0);
  84.   counter1 := counter1 + 3;
  85.  
  86.    end
  87.    else begin
  88.  
  89.   Chromium1.Browser.MainFrame.ExecuteJavaScript('flagDrowStart(' + '"' + arr_flag[counter1] + '"' + ',' + arr_flag[counter1+1] +',' + arr_flag[counter1+2] +',' + IntToStr(j+1) +')','about:blank', 0);
  90.   counter1 := counter1 + 3;
  91.  
  92.  
  93.     end;
  94.     end else
  95.     begin
  96.  
  97. //     showmessage(copy(arr_flag[counter1], pos(',', arr_flag[counter1]), pos(' т,', arr_flag[counter1])-3));
  98. //     showmessage(copy(arr_flag[counter1], pos(' т,', arr_flag[counter1])+3, (arr_flag[counter1].Length-2 - pos(' т,', arr_flag[counter1])+3)));
  99.   if (copy(arr_flag[counter1], pos(',', arr_flag[counter1]), pos(' т,', arr_flag[counter1])-3) > copy(arr_flag[counter1], pos(' т,', arr_flag[counter1])+3, arr_flag[counter1].Length-2 - pos(' т,', arr_flag[counter1])+3)) then begin
  100.      Chromium1.Browser.MainFrame.ExecuteJavaScript('flagDrowFinish(' + '"' + arr_flag[counter1] + '"' + ',' + arr_flag[counter1+1] +',' + arr_flag[counter1+2] +',' + IntToStr(j+1) +')','about:blank', 0);
  101.   counter1 := counter1 + 3;
  102.   end else
  103.   begin
  104.      Chromium1.Browser.MainFrame.ExecuteJavaScript('flagDrowStart(' + '"' + arr_flag[counter1] + '"' + ',' + arr_flag[counter1+1] +',' + arr_flag[counter1+2] +',' + IntToStr(j+1) +')','about:blank', 0);
  105.   counter1 := counter1 + 3;
  106.   end;
  107.  
  108.  
  109.  
  110.     end;
  111. end;
  112.  
  113. Chromium1.Browser.MainFrame.ExecuteJavaScript('update_renderer()','about:blank', 0);
  114.  
  115. Chromium1.Browser.MainFrame.ExecuteJavaScript('show_track1(1481500800, 1486021378, 2, "C70F0F", 14643030, 52.135509491, 23.6187381744, 50.5740890503, 22.2671527863, 0x0000)','about:blank', 0);
  116.  
  117. Chromium1.Browser.MainFrame.ExecuteJavaScript('update_renderer()','about:blank', 0);
  118.  
  119.   dynRESTreq.Params.AddItem('svc', 'report/exec_report', TRESTRequestParameterKind.pkGETorPOST);  //отчет с остановками
  120.   dynRESTreq.Params.AddItem('params', '{"reportResourceId":14464460,"reportTemplateId":13,"reportTemplate":null,"reportObjectId":14643030,"reportObjectSecId":0,"interval":{"flags":16777216,"from":1483995600,"to":1485776769}}', TRESTRequestParameterKind.pkGETorPOST);
  121.   dynRESTreq.Params.AddItem('sid', result ,TRESTRequestParameterKind.pkGETorPOST);
  122.   dynRESTreq.Execute;
  123.  
  124.  
  125.     dynRESTreq.Params.AddItem('svc', 'report/select_result_rows', TRESTRequestParameterKind.pkGETorPOST);
  126.   dynRESTreq.Params.AddItem('params', '{"tableIndex":0,"config":{"type":"range","data":{"from":0,"to":100,"level":0}}}', TRESTRequestParameterKind.pkGETorPOST);
  127.   dynRESTreq.Params.AddItem('sid', result ,TRESTRequestParameterKind.pkGETorPOST);
  128.   dynRESTreq.Execute;
  129.    str_report := '';
  130.    str_report := dynRESTresp.Content;
  131.  
  132.  
  133.  
  134.  
  135.   Json1 := TJSONObject.ParseJSONValue(str_report) as TJSONArray;
  136.   if not Assigned(JSON1) then  raise Exception.Create('Файл не содержит JSON-данные');
  137.   for i := 0 to Json1.Size-1 do begin
  138.   track2 := ((Json1.Get(i) as TJSONObject).Get('c').JsonValue as TJSONArray);
  139.  
  140.   arr_stop[counter2] := (track2.Get(0).value);//время
  141.   arr_stop[counter2+1] := ((track2.Get(1) as TJSONObject).Get('y').JsonValue.Value);//Y
  142.   arr_stop[counter2+2] := ((track2.Get(1) as TJSONObject).Get('x').JsonValue.Value);//X
  143.   counter2 := counter2 + 3;
  144.  
  145.  
  146. end;
  147.  
  148.  
  149.   dynRESTreq.Params.AddItem('svc', 'report/exec_report', TRESTRequestParameterKind.pkGETorPOST);  //отчет со стоянками
  150.   dynRESTreq.Params.AddItem('params', '{"reportResourceId":14464460,"reportTemplateId":13,"reportTemplate":null,"reportObjectId":14643030,"reportObjectSecId":0,"interval":{"flags":16777216,"from":1483995600,"to":1485776769}}', TRESTRequestParameterKind.pkGETorPOST);
  151.   dynRESTreq.Params.AddItem('sid', result ,TRESTRequestParameterKind.pkGETorPOST);
  152.   dynRESTreq.Execute;
  153.  
  154.     dynRESTreq.Params.AddItem('svc', 'report/select_result_rows', TRESTRequestParameterKind.pkGETorPOST);
  155.   dynRESTreq.Params.AddItem('params', '{"tableIndex":1,"config":{"type":"range","data":{"from":0,"to":100,"level":0}}}', TRESTRequestParameterKind.pkGETorPOST);
  156.   dynRESTreq.Params.AddItem('sid', result ,TRESTRequestParameterKind.pkGETorPOST);
  157.   dynRESTreq.Execute;
  158.    str_report := '';
  159.  
  160.    str_report := dynRESTresp.Content;
  161.  
  162.   Json1 := TJSONObject.ParseJSONValue(str_report) as TJSONArray;
  163.   if not Assigned(JSON1) then  raise Exception.Create('Файл не содержит JSON-данные');
  164.   for i := 0 to Json1.Size-1 do begin
  165.   track2 := ((Json1.Get(i) as TJSONObject).Get('c').JsonValue as TJSONArray);
  166.  
  167.   arr_stop[counter2] := (track2.Get(0).value);//время
  168.   arr_stop[counter2+1] := ((track2.Get(1) as TJSONObject).Get('y').JsonValue.Value);//Y
  169.   arr_stop[counter2+2] := ((track2.Get(1) as TJSONObject).Get('x').JsonValue.Value);//X
  170.   counter2 := counter2 + 3;
  171.  
  172.  
  173. end;
  174.  
  175.   for j := 0 to (counter2 div 3) - 1 do begin
  176.  
  177.     if(StrToInt(copy(arr_stop[counter3], 1, pos(':', arr_stop[counter3])-1)) < 9) then begin
  178.     Chromium1.Browser.MainFrame.ExecuteJavaScript('stop1Drow(' + '"' + arr_stop[counter3] + '"' + ',' + arr_stop[counter3+1] +',' + arr_stop[counter3+2] +',' + IntToStr(o+1) +')','about:blank', 0);
  179.     o := o + 1;
  180.     end
  181.     else if (StrToInt(copy(arr_stop[counter3], 1, pos(':', arr_stop[counter3])-1)) > 9) and (StrToInt(copy(arr_stop[counter3], 1, pos(':', arr_stop[counter3])-1)) < 24) then begin
  182.     Chromium1.Browser.MainFrame.ExecuteJavaScript('stop2Drow(' + '"' + arr_stop[counter3] + '"' + ',' + arr_stop[counter3+1] +',' + arr_stop[counter3+2] +',' + IntToStr(p+1) +')','about:blank', 0);
  183.     p := p + 1;
  184.     end
  185.     else if (StrToInt(copy(arr_stop[counter3], 1, pos(':', arr_stop[counter3])-1)) > 24) then begin
  186.     Chromium1.Browser.MainFrame.ExecuteJavaScript('stop3Drow(' + '"' + arr_stop[counter3] + '"' + ',' + arr_stop[counter3+1] +',' + arr_stop[counter3+2] +',' + IntToStr(l+1) +')','about:blank', 0);
  187.     l := l + 1;
  188.     end;
  189.     counter3 := counter3 + 3;
  190.  
  191.   end;
  192.  
  193.  
  194.  
  195.  
  196. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement