|
|
@@ -30,85 +30,85 @@ class SortingController extends Controller
|
|
|
*/
|
|
|
public function newBatch(Request $request)
|
|
|
{
|
|
|
-/* $requestArr=$request->all();
|
|
|
+// $requestArr=$request->all();
|
|
|
app('LogService')->log(__METHOD__, 'issued_' . __FUNCTION__, json_encode($request->all()));
|
|
|
- !$requestArr?$requestArr=json_decode($request->getContent(),true):false;
|
|
|
- $errors=$this->newBatchValidator($requestArr)->errors();
|
|
|
- if(count($errors)>0){
|
|
|
- app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, 'fields wrong, see Errors report please.'.'|'.json_encode($request->all()).'|'.json_encode($errors));
|
|
|
- return response()->json(['Response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001',
|
|
|
- 'returnDesc'=>':Failure','resultInfo'=>'','errors'=>$errors]]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
|
|
|
- }
|
|
|
- $requestBatches = $requestArr['request']?? '';
|
|
|
-
|
|
|
- foreach ($requestBatches as $requestBatch){
|
|
|
- $requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
|
|
|
- $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();
|
|
|
- foreach($requestBatch['order_list'] as $requestOrder){
|
|
|
- $owner=Owner::query()->where('code',$requestOrder['customerid'])->first();
|
|
|
- $order=app("OrderService")->first(['code'=>$requestOrder['docno']]);
|
|
|
- if(!$order){
|
|
|
- $order=app("OrderService")->createOrder([
|
|
|
- 'batch_id' => $batch['id'],
|
|
|
- 'code' => $requestOrder['docno'],
|
|
|
- 'owner_id' => $owner['id'],
|
|
|
- 'wms_status' => $requestOrder['docstatus']??'波次下发',
|
|
|
- 'status' => '未处理',
|
|
|
- ]);
|
|
|
- app('LogService')->log(__METHOD__,__FUNCTION__,'创建 Order'.json_encode($order));
|
|
|
- }else{
|
|
|
- $order['batch_id']= $batch['id'] ;
|
|
|
- $order['owner_id']=$order['owner_id']??$owner['owner_id'];
|
|
|
- $order['wms_status']=$order['wms_status']??$requestOrder['docstatus']??'波次下发';
|
|
|
- $order['status']=$order['status']??'未处理';
|
|
|
- }
|
|
|
- $order->save();
|
|
|
- OrderBin::query()->firstOrCreate([
|
|
|
- 'order_id' => $order['id'],
|
|
|
- 'number' => $requestOrder['reservedfield01'],
|
|
|
- ]);
|
|
|
- foreach($requestOrder['barcode_list'] as $requestBarcode){
|
|
|
- $orderCommodity=OrderCommodity::query()
|
|
|
- ->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
|
|
|
- if(!$orderCommodity){
|
|
|
- /** @var CommodityService $commodityService */
|
|
|
- /*$commodityService=app('CommodityService');
|
|
|
- $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
|
|
|
- $orderCommodity=OrderCommodity::query()->firstOrCreate(['order_id'=>$order['id'],'commodity_id'=>$commodity['id']]);
|
|
|
- if(!$orderCommodity){
|
|
|
- $orderCommodity = new OrderCommodity([
|
|
|
- 'order_id' => $order['id'],
|
|
|
- 'commodity_id' => $commodity['id'],
|
|
|
- 'amount' => $requestBarcode['fmqty_each']??0,
|
|
|
- 'wms_ptltaskid' => $requestBarcode['ptltaskid'],
|
|
|
- ]);
|
|
|
- }else{
|
|
|
- $orderCommodity['order_id']=$order['id'];
|
|
|
- $orderCommodity['commodity_id']=$commodity['id'];
|
|
|
- $orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
|
|
|
- $orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid']??0;
|
|
|
- }
|
|
|
- $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
|
|
|
- if($allocation)
|
|
|
- $orderCommodity['location'] = $allocation['location'];
|
|
|
- $orderCommodity->save();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
- return response()->json(['Response'=>['return'=>['returnFlag'=>'1','returnCode'=>'0000',
|
|
|
- 'returnDesc'=>'消息处理成功:Success','resultInfo'=>'']]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
|
|
|
+// !$requestArr?$requestArr=json_decode($request->getContent(),true):false;
|
|
|
+// $errors=$this->newBatchValidator($requestArr)->errors();
|
|
|
+// if(count($errors)>0){
|
|
|
+// app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, 'fields wrong, see Errors report please.'.'|'.json_encode($request->all()).'|'.json_encode($errors));
|
|
|
+// return response()->json(['Response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001',
|
|
|
+// 'returnDesc'=>':Failure','resultInfo'=>'','errors'=>$errors]]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
|
|
|
+// }
|
|
|
+// $requestBatches = $requestArr['request']?? '';
|
|
|
+//
|
|
|
+// foreach ($requestBatches as $requestBatch){
|
|
|
+// $requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
|
|
|
+// $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();
|
|
|
+// foreach($requestBatch['order_list'] as $requestOrder){
|
|
|
+// $owner=Owner::query()->where('code',$requestOrder['customerid'])->first();
|
|
|
+// $order=app("OrderService")->first(['code'=>$requestOrder['docno']]);
|
|
|
+// if(!$order){
|
|
|
+// $order=app("OrderService")->createOrder([
|
|
|
+// 'batch_id' => $batch['id'],
|
|
|
+// 'code' => $requestOrder['docno'],
|
|
|
+// 'owner_id' => $owner['id'],
|
|
|
+// 'wms_status' => $requestOrder['docstatus']??'波次下发',
|
|
|
+// 'status' => '未处理',
|
|
|
+// ]);
|
|
|
+// app('LogService')->log(__METHOD__,__FUNCTION__,'创建 Order'.json_encode($order));
|
|
|
+// }else{
|
|
|
+// $order['batch_id']= $batch['id'] ;
|
|
|
+// $order['owner_id']=$order['owner_id']??$owner['owner_id'];
|
|
|
+// $order['wms_status']=$order['wms_status']??$requestOrder['docstatus']??'波次下发';
|
|
|
+// $order['status']=$order['status']??'未处理';
|
|
|
+// }
|
|
|
+// $order->save();
|
|
|
+// OrderBin::query()->firstOrCreate([
|
|
|
+// 'order_id' => $order['id'],
|
|
|
+// 'number' => $requestOrder['reservedfield01'],
|
|
|
+// ]);
|
|
|
+// foreach($requestOrder['barcode_list'] as $requestBarcode){
|
|
|
+// $orderCommodity=OrderCommodity::query()
|
|
|
+// ->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
|
|
|
+// if(!$orderCommodity){
|
|
|
+// /** @var CommodityService $commodityService */
|
|
|
+// $commodityService=app('CommodityService');
|
|
|
+// $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
|
|
|
+// $orderCommodity=OrderCommodity::query()->firstOrCreate(['order_id'=>$order['id'],'commodity_id'=>$commodity['id']]);
|
|
|
+// if(!$orderCommodity){
|
|
|
+// $orderCommodity = new OrderCommodity([
|
|
|
+// 'order_id' => $order['id'],
|
|
|
+// 'commodity_id' => $commodity['id'],
|
|
|
+// 'amount' => $requestBarcode['fmqty_each']??0,
|
|
|
+// 'wms_ptltaskid' => $requestBarcode['ptltaskid'],
|
|
|
+// ]);
|
|
|
+// }else{
|
|
|
+// $orderCommodity['order_id']=$order['id'];
|
|
|
+// $orderCommodity['commodity_id']=$commodity['id'];
|
|
|
+// $orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
|
|
|
+// $orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid']??0;
|
|
|
+// }
|
|
|
+// $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
|
|
|
+// if($allocation)
|
|
|
+// $orderCommodity['location'] = $allocation['location'];
|
|
|
+// $orderCommodity->save();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return response()->json(['Response'=>['return'=>['returnFlag'=>'1','returnCode'=>'0000',
|
|
|
+// 'returnDesc'=>'消息处理成功:Success','resultInfo'=>'']]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
|
|
|
protected function newBatchValidator(array $data)
|