|
|
@@ -4,6 +4,7 @@
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
|
+use App\Components\ErrorPush;
|
|
|
use App\Exceptions\ErrorException;
|
|
|
use App\Exceptions\Exception;
|
|
|
use App\Jobs\CacheShelfTaskJob;
|
|
|
@@ -21,7 +22,7 @@ use App\Traits\ServiceAppAop;
|
|
|
|
|
|
class ForeignHaiRoboticsService
|
|
|
{
|
|
|
- use ServiceAppAop;
|
|
|
+ use ServiceAppAop,ErrorPush;
|
|
|
|
|
|
/** @var $stationTaskMaterialBoxService StationTaskMaterialBoxService */
|
|
|
private $stationTaskMaterialBoxService;
|
|
|
@@ -334,58 +335,51 @@ class ForeignHaiRoboticsService
|
|
|
return $controlSuccess;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 任务变更时的动作
|
|
|
+ *
|
|
|
+ * @param $stationTaskMaterialBox_id
|
|
|
+ * @param $updateEventType
|
|
|
+ * @param $status
|
|
|
+ * @param $binCode
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
public function taskUpdate(
|
|
|
-// $groupCode,
|
|
|
$stationTaskMaterialBox_id, //实际对应传入的字段 taskCode, 这里用料箱任务号做taskCode
|
|
|
$updateEventType, //0:task_begin(取货)1:task_end(放货)
|
|
|
$status, //0:任务成功1:任务失败
|
|
|
$binCode
|
|
|
):bool{
|
|
|
- LogService::log('海柔请求','taskUpdateIn',
|
|
|
- json_encode([
|
|
|
- $stationTaskMaterialBox_id,
|
|
|
- $updateEventType,
|
|
|
- $status,
|
|
|
- $binCode
|
|
|
- ]));
|
|
|
$this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
|
|
|
- try{
|
|
|
- if(($failed
|
|
|
- =$status)==1){
|
|
|
- throw new ErrorException('海柔任务失败');
|
|
|
- }
|
|
|
- if($料箱不匹配=
|
|
|
- !$stationTaskMaterialBox
|
|
|
- =(function()use($stationTaskMaterialBox_id,$binCode){
|
|
|
- $stationTaskMaterialBox=StationTaskMaterialBox::query()->find($id=$stationTaskMaterialBox_id);
|
|
|
- if($stationTaskMaterialBox['materialBox']['code']==$binCode)return $stationTaskMaterialBox;
|
|
|
- return null;
|
|
|
- })()){
|
|
|
- throw new ErrorException('发回的料箱和任务号(ID)不匹配:$stationTaskMaterialBox_id:'
|
|
|
- .$stationTaskMaterialBox_id.' $binCode:'.$binCode. ' '.
|
|
|
- StationTaskMaterialBox::query()
|
|
|
- ->where('id', $id=$stationTaskMaterialBox_id)
|
|
|
- ->get()
|
|
|
- ->toJson());
|
|
|
+ if ($status==1){ //海柔失败
|
|
|
+ $this->push(__METHOD__."->".__LINE__,"海柔任务异常",json_encode(request()->input()));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //获取下达任务
|
|
|
+ /** @var StationTaskMaterialBox|\stdClass $stationTaskMaterialBox */
|
|
|
+ $stationTaskMaterialBox = $stationTaskMaterialBox_id ? StationTaskMaterialBox::query()->with("materialBox:id,code")
|
|
|
+ ->find($stationTaskMaterialBox_id) : null;
|
|
|
+ if (!$stationTaskMaterialBox || !$stationTaskMaterialBox->materialBox){
|
|
|
+ $this->push(__METHOD__."->".__LINE__,"海柔任务不存在",json_encode(request()->input()));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ($stationTaskMaterialBox->materialBox->code != $binCode){
|
|
|
+ $this->push(__METHOD__."->".__LINE__,"海柔任务料箱号不匹配",json_encode(request()->input()));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ switch ($updateEventType){
|
|
|
+ case 0://已取出
|
|
|
+ $this->stationTaskMaterialBoxService->markHasTaken($stationTaskMaterialBox);
|
|
|
+ break;
|
|
|
+ case 1://已放置
|
|
|
+ $this->stationTaskMaterialBoxService->markHasPut($stationTaskMaterialBox);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new \Exception("任务进行状态错误,未捕获");
|
|
|
}
|
|
|
- if(($标记已放置=
|
|
|
- function()use($updateEventType,$stationTaskMaterialBox){
|
|
|
- if(($isPut
|
|
|
- =$updateEventType)==1){
|
|
|
- $this->stationTaskMaterialBoxService->markHasPut($stationTaskMaterialBox);
|
|
|
- return true;
|
|
|
- }return false;
|
|
|
- })())
|
|
|
- return true;
|
|
|
- ($标记已取出=
|
|
|
- function()use($updateEventType,$stationTaskMaterialBox){
|
|
|
- if(($isGet
|
|
|
- =$updateEventType)==0){
|
|
|
- $this->stationTaskMaterialBoxService->markHasTaken($stationTaskMaterialBox);
|
|
|
- }
|
|
|
- })();
|
|
|
- }catch (\Exception $e){
|
|
|
- $this->excepted($stationTaskMaterialBox_id, $binCode, $e->getMessage());
|
|
|
+ }catch (\Exception $err){
|
|
|
+ $this->push(__METHOD__."->".__LINE__,"海柔任务通知失败",json_encode(request()->input())." | ".$err->getMessage());
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|