create FMS service with test
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Models\CMMS_Form;
|
||||
use App\Models\CMMS_Forms_histories;
|
||||
use App\Models\CMMS_Province;
|
||||
use App\Models\CmmsDemo;
|
||||
use App\Services\FMSService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -18,7 +19,7 @@ use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CMMSController extends Controller
|
||||
{
|
||||
public function getVehicleActivity(Request $request)
|
||||
public function getVehicleActivity(Request $request, FMSService $FMSService)
|
||||
{
|
||||
|
||||
if (!$request->machineCode || !$request->startDT || !$request->endDT || !$request->minStopDuration) {
|
||||
@@ -26,22 +27,8 @@ class CMMSController extends Controller
|
||||
'message' => 'error'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$r = $request->machineCode;
|
||||
$s = $request->startDT;
|
||||
$e = $request->endDT;
|
||||
$d = $request->minStopDuration;
|
||||
$url = 'http://fms.141.ir/api/RMS/GetVehicleActivity?';
|
||||
$query = "username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}&minStopDuration={$d}";
|
||||
$full_url = $url . $query;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $full_url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
||||
"username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}&minStopDuration={$d}");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
$server_output = $FMSService->getVehicleActivity($request);
|
||||
|
||||
$d = json_decode($server_output, true);
|
||||
|
||||
@@ -58,7 +45,7 @@ class CMMSController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function getVehicleLastPoints(Request $request)
|
||||
public function getVehicleLastPoints(Request $request, FMSService $FMSService)
|
||||
{
|
||||
|
||||
if (!$request->machineCode) {
|
||||
@@ -66,19 +53,8 @@ class CMMSController extends Controller
|
||||
'message' => 'error'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$r = $request->machineCode;
|
||||
$url = 'http://fms.141.ir/api/RMS/GetVehicleLastPoints?';
|
||||
$query = "username=RMS&password=XSW@1qaz&machineCodes={$r}";
|
||||
$full_url = $url . $query;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $full_url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
||||
"username=RMS&password=XSW@1qaz&machineCode={$r}");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
$server_output = $FMSService->getVehicleLastPoints($request);
|
||||
|
||||
$d = json_decode($server_output, true);
|
||||
return $d;
|
||||
@@ -95,7 +71,7 @@ class CMMSController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function getVehicleActivitySummary(Request $request)
|
||||
public function getVehicleActivitySummary(Request $request, FMSService $FMSService)
|
||||
{
|
||||
|
||||
if (!$request->machineCode || !$request->startDT || !$request->endDT) {
|
||||
@@ -103,21 +79,8 @@ class CMMSController extends Controller
|
||||
'message' => 'error'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$r = $request->machineCode;
|
||||
$s = $request->startDT;
|
||||
$e = $request->endDT;
|
||||
$url = 'http://fms.141.ir/api/RMS/GetVehicleActivitySummary?';
|
||||
$query = "username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}";
|
||||
$full_url = $url . $query;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $full_url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
||||
"username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
$server_output = $FMSService->getVehicleActivitySummary($request);
|
||||
|
||||
$d = json_decode($server_output, true);
|
||||
|
||||
@@ -135,17 +98,9 @@ class CMMSController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function getVehicleData(Request $request)
|
||||
{
|
||||
$r = $request->machine;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL,"http://fms.141.ir/api/RMS/GetVehicleLastPoints?username=RMS&password=XSW@1qaz&machineCodes={$r}");
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
||||
"username=RMS&password=XSW@1qaz&machineCodes={$r}");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
public function getVehicleData(Request $request, FMSService $FMSService)
|
||||
{
|
||||
$server_output = $FMSService->getVehicleData($request);
|
||||
|
||||
$d = json_decode($server_output);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user