소스 검색

入库预约-逾期收货
缓存架入库-分离出库
即时账单-数据错误修复

Zhouzhendong 4 년 전
부모
커밋
dbc1832c5f

+ 5 - 0
app/DeliveryAppointment.php

@@ -46,6 +46,7 @@ class DeliveryAppointment extends Model
         1 => "取消",
         2 => "完成",
         3 => "已逾期",
+        4 => "逾期收货",
     ];
     //类型标记
     const TYPE = [
@@ -59,6 +60,10 @@ class DeliveryAppointment extends Model
     {   //车辆
         return $this->hasMany(DeliveryAppointmentCar::class,"delivery_appointment_id","id");
     }
+    public function car()
+    {   //单车辆
+        return $this->belongsTo(DeliveryAppointmentCar::class,"id","delivery_appointment_id");
+    }
     public function details()
     {   //明细
         return $this->hasMany(DeliveryAppointmentDetail::class);

+ 4 - 3
app/Http/Controllers/DeliveryAppointmentController.php

@@ -566,12 +566,13 @@ html;
         $this->gate("入库管理-入库预约-预约管理-卸货完成");
         if (!request("id"))$this->error("非法参数");
         /** @var DeliveryAppointmentCar|\stdClass $car */
-        $car = DeliveryAppointmentCar::query()->where("status",1)->find(request("id"));
+        $car = DeliveryAppointmentCar::query()->with("deliveryAppointment")->where("status",1)->find(request("id"));
         if (!$car || !$car->deliveryAppointment)$this->error("单据不存在");
+        if ($car->deliveryAppointment->appointment_date!=date('Y-m-d'))$this->error("禁止越天逾期操作");
         $car->update(["status"=>2]);
-        app("DeliveryAppointmentService")->checkFull($car->delivery_appointment_id);
+        $status = app("DeliveryAppointmentService")->checkFull($car->delivery_appointment_id);
         event(new DeliveryAppointmentEvent($car));
-        $this->success();
+        $this->success($status);
     }
 
     /**

+ 4 - 21
app/Http/Controllers/StorageController.php

@@ -116,34 +116,17 @@ class StorageController extends Controller
         $boxes = request("boxes");
         //清理任务
         $data = '';
-        $station = Station::query()->select("id")->whereIn("code",$boxes);
-        $occupy = Storage::query()->with("station:id,code")->whereIn("station_id",$station)->where("status",1)->get();
+        $occupy = Storage::query()->with("station:id,code")->whereIn("station_id",Station::query()->select("id")->whereIn("code",$boxes))->where("status",1)->get();
         foreach ($occupy as $item){
             unset($boxes[array_search($item->station->code,$boxes)]);
             $data .= '“'.$item->station->code.'”,';
         }
         if ($occupy->count()>0){
-            $data .= "存在任务待处理,无法释放";
+            $data .= "存在任务待处理,无法调取";
             $boxes = array_values($boxes);
-            $station = Station::query()->select("id")->whereIn("code",$boxes);
         }
-        //清除海柔信息,标记料箱为出库
-        DB::connection("mysql_haiRobotics")->table("ks_bin")->whereIn("ks_bin_space_code",$boxes)
-            ->where("status",1)->update([
-                "ks_bin_space_code" => null,"ks_bin_space_id"=>null,"orig_ks_bin_space_code"=>null,"orig_ks_bin_space_id"=>null,
-                "status"=>4,
-            ]);
-        $task = StationTask::query()->select("id")->where("status","!=",'完成')->whereIn("station_id",$station);
-        StationTaskMaterialBox::query()->where("status","!=",'完成')->whereIn("station_task_id",$task)->update([
-            "status" => "完成"
-        ]);
-        StationTask::query()->where("status","!=",'完成')->whereIn("station_id",$station)->update([
-            "status" => "完成"
-        ]);
-        Storage::query()->whereIn("station_id",$station)->update([
-            "status" => 1,
-            "station_id" => null,
-        ]);
+        //清理原有任务
+        app("StorageService")->clearTask($boxes);//TODO 改为机器人防置时触发 但需要阿君修改任务参数为指定格口而非整个缓存架
         //重新调取料箱
         $result = app("ForeignHaiRoboticsService")->paddingCacheShelf(Station::query()->whereIn("code",$boxes)->get());
         if ($result===null)$this->error("任务下发错误,检查日志");

+ 3 - 7
app/Http/Controllers/TestController.php

@@ -143,13 +143,9 @@ class TestController extends Controller
 
     public function test1()
     {
-        ini_set('max_execution_time',-1);
-        foreach (Order::query()->where("wms_edittime",">=","2021-06-01 00:00:00")
-                     ->whereNotIn("id",OwnerFeeDetail::query()->select("outer_id")
-                         ->where("created_at",">=",'2021-06-01 00:00:00')
-                         ->where("outer_table_name","orders"))->get() as $order){
-            dispatch(new OrderCreateInstantBill($order));
-        }
+        $order = Order::query()->find(3330884);
+        $a = new OrderService();
+        $a->createInstantBill($order);
     }
 
     public function test2()

+ 8 - 1
app/Services/DeliveryAppointmentService.php

@@ -8,6 +8,7 @@ use App\Services\common\QueryService;
 use App\Traits\ServiceAppAop;
 use App\DeliveryAppointment;
 use App\Warehouse;
+use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\Auth;
 use phpDocumentor\Reflection\Types\Integer;
@@ -163,6 +164,7 @@ class DeliveryAppointmentService
      * 验证预约单完整性修改状态
      *
      * @param integer $id
+     * @return int
      */
     public function checkFull($id)
     {
@@ -171,7 +173,12 @@ class DeliveryAppointmentService
             /** @var Builder $query */
             $query->whereNull("delivery_time")->where("status","!=",2);
         }])->find($id);
-        if ($delivery->cars_count == 0)$delivery->update(["status"=>2]);
+        if ($delivery->cars_count != 0)return 0;
+        $status = 2;
+        if (Carbon::parse($delivery->appointment_date." ".explode("-",DeliveryAppointment::PERIOD[$delivery->date_period])[1].":00:00")->lt(Carbon::parse($delivery->car->delivery_time)))
+            $status = 4;
+        $delivery->update(["status"=>$status]);
+        return $status;
     }
 
     /**

+ 3 - 2
app/Services/OwnerPriceOperationService.php

@@ -312,7 +312,7 @@ class OwnerPriceOperationService
      */
     public function matching($matchObject, $columnMapping, $ownerId, $type = '出库', $typeMark = null)
     {
-        $units = app("UnitService")->getUnitMapping(["件","箱","m³","T","kg"]); //获取单位映射集
+        $units = app("UnitService")->getUnitMapping(["件","单","箱","m³","T","kg"]); //获取单位映射集
         $rules = $this->getOwnerPriceOperation($ownerId,$type,$typeMark);//货主下的全部规则
         if (!$rules)return -2;  //规则不存在跳出
 
@@ -446,7 +446,8 @@ class OwnerPriceOperationService
             if ($rule->strategy=='起步'){
                 $startNumber = $rule->amount;
                 $money = 0;
-                if ($unitName && $startNumber && $unitName != $units[$rule->unit_id])return -3; //校验单位是否一致
+                if ($unitName && $startNumber && $rule->unit_id && $unitName != $units[$rule->unit_id])return -3; //校验单位是否一致
+
                 if ($startNumber){
                     $money = $rule->unit_price;
                     $matchObject=$this->settingCount($matchObject,$columnMapping[8],$startNumber);

+ 29 - 0
app/Services/StorageService.php

@@ -487,4 +487,33 @@ sql;
             return false;
         }
     }
+
+    /**
+     * 清除任务
+     *
+     * @param array $stationCodes
+     */
+    public function clearTask(array $stationCodes)
+    {
+        //清除海柔信息,标记料箱为出库
+        DB::connection("mysql_haiRobotics")->table("ks_bin")->whereIn("ks_bin_space_code",$stationCodes)
+            ->where("status",1)->update([
+                "ks_bin_space_code" => null,"ks_bin_space_id"=>null,"orig_ks_bin_space_code"=>null,"orig_ks_bin_space_id"=>null,
+                "status"=>4,
+            ]);
+        //WAS任务清除
+        $station = Station::query()->select("id")->whereIn("code",$stationCodes);
+        $task = StationTask::query()->select("id")->where("status","!=",'完成')->whereIn("station_id",$station);
+        StationTaskMaterialBox::query()->where("status","!=",'完成')->whereIn("station_task_id",$task)->update([
+            "status" => "完成"
+        ]);
+        StationTask::query()->where("status","!=",'完成')->whereIn("station_id",$station)->update([
+            "status" => "完成"
+        ]);
+        Storage::query()->whereIn("station_id",$station)->update([
+            "status" => 1,
+            "station_id" => null,
+        ]);
+        return true;
+    }
 }

+ 1 - 1
resources/views/customer/project/create.blade.php

@@ -886,7 +886,7 @@
                         return;
                     }
                     let unit = null;
-                    for (let i=1;i<this.model.operation.items.length;i++){
+                    for (let i=0;i<this.model.operation.items.length;i++){
                         if (this.model.operation.items[i].amount){
                             if(!unit)unit = this.model.operation.items[i].unit_id;
                             else if(unit !== this.model.operation.items[i].unit_id){

+ 1 - 1
resources/views/store/deliveryAppointment/list.blade.php

@@ -318,7 +318,7 @@
                             if (this.list[i].cars.every(car=>{
                                 if (car.status!=2)return false;
                                 return true
-                            }))this.list[i].status = 2;
+                            }))this.list[i].status = res;
                             return "成功确认";
                         })
                     })