<?php


namespace App\Http\Controllers\api\thirdPart\haiq;




use App\Http\Requests\ForeignHaiRobotic_processedRequest;
use App\Services\ForeignHaiRoboticsService;
use App\Services\LogService;

class PickStationController
{

    /** @var ForeignHaiRoboticsService $service */
    private $service;
    public function __construct(){
        $this->service=app('ForeignHaiRoboticsService');
    }

    public function processed(ForeignHaiRobotic_processedRequest $request): array
    {
        LogService::log('海柔请求','processed1',
            json_encode($request->all()));
        $failed=
            ($processedResult=
                $this->service->markBinProcessed(
                    $request->input('workStation'),
                    $request->input('binCode'),
                    $request->input('success'),
                    $request->input('created_at'),
                    $request->input('exception'),
                    $request->input('is_in_plan')
                ))!==true;

        $result = ["code" => 200, "data" => json_encode($request->all())];
        if($failed){
            $result["code"] = 400;
            $result["errMsg"] = $processedResult;
        }
        LogService::log('海柔请求','processed2',
            json_encode($result));
        return $result;
    }

}
