|
|
@@ -10,7 +10,8 @@ use App\Order;
|
|
|
use App\OrderBin;
|
|
|
use App\OrderCommodity;
|
|
|
use App\Owner;
|
|
|
-use App\Services\OrderService;
|
|
|
+//use App\Services\OrderService;
|
|
|
+use App\Services\CommodityService;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
@@ -19,11 +20,11 @@ use Zttp\Zttp;
|
|
|
class SortingController extends Controller
|
|
|
{
|
|
|
|
|
|
- /** @var OrderService orderService */
|
|
|
- private $orderService;
|
|
|
- public function __construct(){
|
|
|
- $this->orderService=app('OrderService');
|
|
|
- }
|
|
|
+// /** @var OrderService orderService */
|
|
|
+// private $orderService;
|
|
|
+// public function __construct(){
|
|
|
+// $this->orderService=app('OrderService');
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 新增被通知的波次列表(一个以上的波次),并且保存在本地数据库,供get波次使用
|
|
|
@@ -44,12 +45,14 @@ class SortingController extends Controller
|
|
|
$requestBatches = $requestArr['request']?? '';
|
|
|
foreach ($requestBatches as $requestBatch){
|
|
|
$requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
|
|
|
- $batch=new Batch([
|
|
|
- 'code' => $requestBatch['waveno'],
|
|
|
- 'wms_type' => $requestBatch['batch_type']??'',
|
|
|
- 'wms_status' => $requestBatch['docstatus']??'',
|
|
|
- 'status' => '未处理',
|
|
|
- 'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
|
|
|
+ $batch=Batch::query()->firstOrCreate(['code' => $requestBatch['waveno']]);
|
|
|
+ if(!$batch)$batch=new Batch();
|
|
|
+ $batch->fill([
|
|
|
+ 'code' => $requestBatch['waveno'],
|
|
|
+ 'wms_type' => $requestBatch['batch_type']??'',
|
|
|
+ 'wms_status' => $requestBatch['docstatus']??'',
|
|
|
+ 'status' => '未处理',
|
|
|
+ 'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
|
|
|
]);
|
|
|
$batch->save();
|
|
|
$oracleAlloactions=OracleActAllocationDetails::query()->where('waveno',$requestBatch['waveno'])->get();
|
|
|
@@ -57,7 +60,6 @@ class SortingController extends Controller
|
|
|
$owner=Owner::query()->where('code',$requestOrder['customerid'])->first();
|
|
|
$order=Order::query()->where('code',$requestOrder['docno'])->first();
|
|
|
if(!$order){
|
|
|
- $this->orderService->
|
|
|
$order=new Order([
|
|
|
'batch_id' => $batch['id'],
|
|
|
'code' => $requestOrder['docno'],
|
|
|
@@ -80,7 +82,9 @@ class SortingController extends Controller
|
|
|
$orderCommodity=OrderCommodity::query()
|
|
|
->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
|
|
|
if(!$orderCommodity){
|
|
|
- $commodity=Commodity::newCommodityBy_BarcodeOwnerIdNameSku($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['descr_c'],$requestBarcode['sku']);
|
|
|
+ /** @var CommodityService $commodityService */
|
|
|
+ $commodityService=app('CommodityService');
|
|
|
+ $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
|
|
|
$orderCommodity = new OrderCommodity([
|
|
|
'order_id' => $order['id'],
|
|
|
'commodity_id' => $commodity['id'],
|
|
|
@@ -103,7 +107,7 @@ class SortingController extends Controller
|
|
|
{
|
|
|
return Validator::make($data, [
|
|
|
'request' => ['required', 'array', 'min:1'],
|
|
|
- 'request.*.waveno' => ['required', 'string', 'max:191','unique:batches,code'],
|
|
|
+ 'request.*.waveno' => ['required', 'string', 'max:191'],
|
|
|
'request.*.taskprocess' => ['nullable', 'string', 'max:191'],
|
|
|
'request.*.edittime' => ['nullable', 'string', 'max:191'],
|
|
|
'request.*.batch_type' => ['nullable', 'string', 'max:191'],
|