|
|
@@ -16,6 +16,7 @@ use App\DeliveryAppointment;
|
|
|
use App\DeliveryAppointmentDetail;
|
|
|
use App\Events\BroadcastToStation;
|
|
|
use App\Events\SendEmailEvent;
|
|
|
+use App\Exceptions\ErrorException;
|
|
|
use App\Exceptions\Exception;
|
|
|
use App\Feature;
|
|
|
use App\Http\Controllers\api\thirdPart\haiq\PickStationController;
|
|
|
@@ -85,17 +86,24 @@ use App\Services\OrderTrackingService;
|
|
|
use App\Services\OwnerLogisticFeeDetailService;
|
|
|
use App\Services\OwnerLogisticFeeReportService;
|
|
|
use App\Services\RejectedBillService;
|
|
|
+use App\Services\StationRuleBatchService;
|
|
|
+use App\Services\StationTaskBatchService;
|
|
|
+use App\Services\StationTaskCommodityService;
|
|
|
+use App\Services\StationTaskMaterialBoxService;
|
|
|
+use App\Services\StationTaskService;
|
|
|
use App\Services\StorageService;
|
|
|
use App\Services\StoreItemService;
|
|
|
use App\Services\StoreService;
|
|
|
use App\Services\SupplierService;
|
|
|
use App\Station;
|
|
|
use App\StationTask;
|
|
|
+use App\StationTaskChildren;
|
|
|
use App\StationTaskCommodity;
|
|
|
use App\StationTaskMaterialBox;
|
|
|
use App\Store;
|
|
|
use App\StationTaskBatch;
|
|
|
use App\StoreItem;
|
|
|
+use App\Traits\ModelLogChanging;
|
|
|
use App\Unit;
|
|
|
use App\User;
|
|
|
use App\UserDetail;
|
|
|
@@ -147,17 +155,68 @@ class TestController extends Controller
|
|
|
{
|
|
|
return call_user_func([$this, $method], $request);
|
|
|
}
|
|
|
- public function test()
|
|
|
+ public function test1()
|
|
|
{
|
|
|
- $arr = [];
|
|
|
- foreach (Waybill::query()->get() as $a){
|
|
|
- $arr[] = $a;
|
|
|
- }
|
|
|
- $us = \Illuminate\Database\Eloquent\Collection::make(collect($arr));
|
|
|
+ $batches = Batch::query()->where("code",\request("code"))->get();
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $ids = [];
|
|
|
+ foreach ($batches as $b){
|
|
|
+ $ids[] = $b->id;
|
|
|
+ }
|
|
|
+ if (!$ids)dd("错误");
|
|
|
+ $tasks = StationTaskBatch::query()->whereIn("batch_id",$ids)->get();
|
|
|
+ foreach ($tasks as $task){
|
|
|
+ StationTaskMaterialBox::query()->where("station_task_batch_id",$task->id)->delete();
|
|
|
+ StationTask::query()->where("id",$task->station_task_id)->delete();
|
|
|
+ StationTaskChildren::query()->where("station_task_id",$task->station_task_id)->delete();
|
|
|
+ StationTaskCommodity::query()->where("station_task_id",$task->station_task_id)->delete();
|
|
|
+ StationTaskMaterialBox::query()->where("station_task_id",$task->station_task_id)->delete();
|
|
|
+ $task->delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ $stationTaskService = new StationTaskService();
|
|
|
+ $stationTaskBatchService = new StationTaskBatchService();
|
|
|
+ $stationTaskMaterialBoxService = new StationTaskMaterialBoxService();
|
|
|
+ $stationTaskCommodityService = new StationTaskCommodityService();
|
|
|
+
|
|
|
+
|
|
|
+ $batches = collect($batches);
|
|
|
|
|
|
- $us->load("owner");
|
|
|
- dd($us);
|
|
|
+ $stationRuleBatchService = new StationRuleBatchService();
|
|
|
+ $batches_shouldProcess = collect($batches); //按规则过滤需要的波次
|
|
|
|
|
|
+ app('LogService')->log('海柔','assignTasks3',json_encode($batches_shouldProcess));
|
|
|
+ DB::transaction(function ()use($batches,&$batches_shouldProcess,&$stationTasks){
|
|
|
+ $stationTaskService = new StationTaskService();
|
|
|
+ $stationTaskBatchService = new StationTaskBatchService();
|
|
|
+ $stationTaskMaterialBoxService = new StationTaskMaterialBoxService();
|
|
|
+ $stationTaskCommodityService = new StationTaskCommodityService();
|
|
|
+ $stationTasks = $stationTaskService->create($batches_shouldProcess->count()); //生成总任务
|
|
|
+ $stationTaskBatchService->createByBatches($batches_shouldProcess,$stationTasks); //注册波次任务
|
|
|
+ $stationTaskMaterialBoxService->createByBatches($batches_shouldProcess,$stationTasks); //注册料箱任务
|
|
|
+ $stationTaskCommodityService->createByBatches($batches_shouldProcess,$stationTasks); //注册商品任务
|
|
|
+ });
|
|
|
+ DB::commit();
|
|
|
+ dd("OK");
|
|
|
+ }catch (\Exception $e){
|
|
|
+ DB::rollBack();
|
|
|
+ dd($e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function test()
|
|
|
+ {
|
|
|
+ $stationTaskBatchService = new StationTaskBatchService();
|
|
|
+ $batch = Batch::query()->where("code",\request("code"))->first();
|
|
|
+ $batchTask=StationTaskBatch::query()->where("batch_id",$batch->id)->first();
|
|
|
+ $batchesFailed=$stationTaskBatchService->runMany(collect([$batchTask]));//执行波次任务
|
|
|
+ if($batchesFailed && $batchesFailed->isNotEmpty()){
|
|
|
+ return [
|
|
|
+ 'success'=>false,
|
|
|
+ 'errorMsg'=>'有部分失败波次:'.$batchesFailed->toJson()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return ['success'=>true];
|
|
|
}
|
|
|
function tailCustom($filepath, $lines = 1, $adaptive = true) {
|
|
|
// Open file
|