LD 5 лет назад
Родитель
Сommit
e509fd6639

+ 0 - 1
app/Http/Controllers/Controller.php

@@ -27,5 +27,4 @@ class Controller extends BaseController
         $this->log($method,'apiError',$description);
         return ['success'=>'false','fail_info'=>$description];
     }
-
 }

+ 326 - 1124
app/Http/Controllers/api/thirdPart/flux/StoreController.php

@@ -1,1168 +1,370 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\flux;
+namespace App\Http\Controllers;
 
-use App\Http\Controllers\Controller;
+use App\Depository;
+use App\Owner;
+use App\Services\LogService;
 use App\Store;
+use App\StoreItems;
+use App\Warehouse;
 use App\WMSReflectReceive;
-use App\WMSReflectReceiveSku;
 use Carbon\Carbon;
-use Illuminate\Support\Facades\Auth;
+use Illuminate\Contracts\Foundation\Application;
+use Illuminate\Contracts\View\Factory;
+use Illuminate\Http\RedirectResponse;
+use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+use Illuminate\Routing\Redirector;
 use Illuminate\Support\Facades\DB;
-use Zttp\Zttp;
+use Illuminate\Support\Facades\Gate;
+use Illuminate\Support\Facades\Validator;
+use Illuminate\View\View;
+use App\Http\Controllers\Api\thirdPart\flux\StoreController as FStoreController;
 
 class StoreController extends Controller
 {
-
-
     /**
-     * 入库回传给WMS
-     * @param Store $store
-     * @return bool
+     * Display a listing of the resource.
+     *
+     * @return Application|Factory|Response|View
      */
-    public function accomplishToWMS(Store $store, array $inputs)
+    public function index()
     {
-        $METHOD = __METHOD__;
-        $FUNCTION = __FUNCTION__;
-        Controller::logS(__METHOD__, __FUNCTION__, '快递入库进入WMS接口:' . $store['asn_code']);
-        $wmsReceiveds = WMSReflectReceive::query()->where('ASNNO', $store['asn_code'])->get();
-        if ($wmsReceiveds->isEmpty()) {
-            (new Controller())->log(__METHOD__, 'error_' . __FUNCTION__, '没有本地WMS入库单');
-            return false;
-        }
-        $success = true;
-        $wmsReceiveds->each(function ($wmsReceived) use (&$store, &$amountsItem, &$success, &$inputs, $METHOD, $FUNCTION) {
-
-            $wmsSkus = $wmsReceived->skus()->get();
-            $orderNumberCode = $wmsReceived['ASNREFERENCE1'] ?? $store['order_number'];
-            $amountsSku = (function () use ($wmsSkus) {
-                $result = [];
-                $wmsSkus->each(function ($sku) use (&$result) {
-                    $result[$sku['id']] = $sku['EXPECTEDQTY_EACH'];
-                });
-                return $result;
-            })();
-            $skuStrList = [];
-            $customerCode = $store->owner()->first()['code'];
-            $wmsSkus->each(function (WMSReflectReceiveSku $sku) use (&$skuList, &$amountsItem, &$amountsSku, &$skuStrList, $wmsReceived, $customerCode, &$inputs) {
-                $STATUS = 'ZP';
-                if (isset($inputs['quality']) && $inputs['quality']
-                    && $inputs['quality'] != '正品') {
-                    $STATUS = 'CC';
-                }
-                $repositoryCode = $sku['LOTATT05'];
-                if (isset($inputs['depository_code']) && $inputs['depository_code']) {
-                    $repositoryCode = $inputs['depository_code'];
-                }
-                $skuStr = "
-                        {
-                            \"ORDERNUMBERCODE\": \"{$wmsReceived['ASNNO']}\",
-                            \"ASNLINENO\": \"{$sku['ASNLINENO']}\",
-                            \"SKUCODE\": \"{$sku['SKU']}\",
-                            \"QUANTITY\": \"{$sku['EXPECTEDQTY_EACH']}\",
-                            \"LOTATT04\": \"{$sku['LOTATT04']}\",
-                            \"LOTATT05\": \"{$repositoryCode}\",
-                            \"STATUS\": \"{$STATUS}\",
-                            \"USERDEFINE1\": \"{$inputs['follow_code']}\",
-                            \"USERDEFINE2\": \"\",
-                            \"USERDEFINE3\": \"\",
-                            \"UNIQUE_CODE_LIST\": [" .
-                    "]
-                        }
-                    ";
-                $skuStrList[] = $skuStr;
-            });
-            $skuStrList = implode(',', $skuStrList);
-            $json = "
-                {
-                    \"request\": [
-                        {
-                            \"ORDERNUMBERCODE\": \"{$wmsReceived['ASNNO']}\",
-                            \"CUSTOMERID\": \"{$wmsReceived['CUSTOMERID']}\",
-                            \"ASNTYPE\": \"{$wmsReceived['ASNTYPE']}\",
-                            \"ASNREFERENCE1\": \"{$wmsReceived['ASNREFERENCE1']}\",
-                            \"ADDWHO\": \"WCS\",
-                            \"USERDEFINE1\": \"\",
-                            \"USERDEFINE2\": \"\",
-                            \"USERDEFINE3\": \"\",
-                            \"SKU_LIST\": [{$skuStrList}]
-                        }
-                    ]
-                }
-        ";
-
-            $sendingJson = json_decode($json, true);
-            $url = url(config('api.flux.receive.new'));
-//            (new Controller())->log($METHOD,$FUNCTION,$store['asn_code'].'||' .json_encode($sendingJson));
-            Controller::logS(__METHOD__, __FUNCTION__, '快递入库请求WMS接口开始:' . $store['asn_code']);
-            $response = Zttp::post($url, $sendingJson);
-            Controller::logS(__METHOD__, __FUNCTION__, '快递入库请求WMS接口结束:' . $store['asn_code'] . '||' . $response->body());
-            $noIssues = true;
-            $json = $response->json();
-            if (!$json || !isset($json['Response']) || !$json['Response']['return']['returnFlag'] == '1') {
-                $noIssues = false;
-            }
-            if ($json && isset($json['Response'])) {
-                if ($json['Response']['return']['returnFlag'] == '2') {
-                    (new Controller())->log($METHOD, 'error_' . $FUNCTION, $store['asn_code'] . '||' . $response->body());
-                    return true;
-                }
-//                if(isset($json['Response']['return']['returnDesc'])&&strpos($json['Response']['return']['returnDesc'],'唯一约束')!==false){
-//                    (new Controller())->log($METHOD,'error_'.$FUNCTION,$response->body());
-//                    return true;
-//                }
-                if (isset($json['Response']['return']['errordescr']) && strpos($json['Response']['return']['errordescr'], '已完成') !== false) {
-                    (new Controller())->log($METHOD, 'error_' . $FUNCTION, $store['asn_code'] . '||' . $response->body());
-                    return true;
-                }
-            }
-            if ($noIssues && $json['Response']['return']['returnFlag'] == '1') {
-                $wmsReceived['is_uploaded'] = 1;
-                $wmsReceived->save();
-                (new Controller())->log($METHOD, 'success_' . $FUNCTION, $store['asn_code'] . '||' . $response->body());
-                return true;
-            } else {
-                $success = false;
-                (new Controller())->log($METHOD, 'error_' . $FUNCTION, $store['asn_code'] . '||' . $response->body());
-            }
-        });
-
-        return $success;
+        if(!Gate::allows('入库管理-快速入库-查询')){ return redirect(url('/'));  }
+        $stores=Store::orderBy('id','DESC')->paginate(50);
+        return view('store.fast.index',['stores'=>$stores]);
     }
 
-    public function quickStorage($docno){
-        $db = DB::connection('oracle');
-        //判断单据有效性
-        $cus_bs_asnheader = $db->select(DB::raw("SELECT t.addwho FROM CUS_BS_ASNHEADER t WHERE t.ASNREFERENCE1 = '".$docno."'"));
-        if (!$cus_bs_asnheader) return ['success'=>false, 'data'=>'单据不存在'];
-        $addwho = $cus_bs_asnheader[0]->addwho;
-        if ($addwho == "WCS"){
-            //判断单据状态
-            $cus_bs_asnheader = $db->select(
-                DB::raw("SELECT 1 FROM CUS_BS_ASNHEADER t INNER JOIN DOC_ASN_HEADER a ON a.asnno = t.asnno WHERE t.asnreference1 = '".$docno."' AND a.asnstatus < '40'"));
-            if (!$cus_bs_asnheader) return ['success'=>false, 'data'=>"该单据已完成收货"];
-
-            $sql = "select a.warehouseid,a.asnno as docno,a1.asnlineno,a.customerid,t1.sku,a1.packid,t1.receivedqty_each,t1.lotatt01,t1.lotatt02,";
-            $sql .= " t1.lotatt04,t1.lotatt05,t1.lotatt08,t1.userdefine1 as new_traceid,a.userdefine1,a.userdefine2,a.userdefine3,a.userdefine4,a.userdefine5,t.addwho";
-            $sql .= " from doc_asn_details a1";
-            $sql .= " inner join doc_asn_header a on a.asnno = a1.asnno";
-            $sql .= " inner join cus_bs_asndetails t1 on t1.asnno = a.asnno and t1.asnlineno = a1.asnlineno";
-            $sql .= " inner join cus_bs_asnheader t on t.asnno = a1.asnno";
-            $sql .= " where t.asnreference1 = '".$docno."' and nvl(t1.rcvflag,'N') = 'N'";
-            $doc_asn_details = $db->select(DB::raw($sql));
-            $db->beginTransaction();
-            try{
-                $username=config('database.connections.oracle.username');
-                $password=config('database.connections.oracle.password');
-                $host=config('database.connections.oradcle.host');
-                $service_name=config('database.connections.oracle.service_name');
-                $conn=oci_connect($username,$password,$host.'/'.$service_name);
-                $sql_sp="begin SPASN_Receiving_Process(:IN_Warehouse, :In_Process_Action, :In_ASNNo_C, :In_ASNLineNo_C, :In_FMTraceID_C, :In_New_TraceID_C, :In_ProductStatus,".
-                    ":In_ProductStatus_Descr, :In_HoldRejectCode_C, :In_HoldRejectReason_C, :In_PONo_C, :In_CustomerID, :In_SKU, :In_ReceivedQty, :In_RejectedQty,:In_UOM, :In_PackID,".
-                    " :In_ContainerID, :In_LotAtt01_C, :In_LotAtt02_C, :In_LotAtt03_C, :In_LotAtt04_C, :In_LotAtt05_C, :In_LotAtt06_C,".
-                    ":In_LotAtt07_C, :In_LotAtt08_C, :In_LotAtt09_C, :In_LotAtt10_C, :In_LotAtt11_C, :In_LotAtt12_C,".
-                    ":In_TotalCubic, :In_TotalGrossWeight, :In_TotalNetWeight, :In_TotalPrice, :In_UserDefine1, :In_UserDefine2,:In_UserDefine3, :In_UserDefine4, :In_UserDefine5, :In_FMLocation,".
-                    ":In_TOLocation_C,:In_QC_Type_C, :In_PlanToLoc_C,:In_ReceivingTime, :In_LPN, :In_Operator, :IN_RCVModule, :IN_RCVStation, :In_Language, :In_UserID, :OUT_Return_Code); end;";
-                foreach ($doc_asn_details as $doc_asn_detail){
-                    $IN_Warehouse = $doc_asn_detail->warehouseid ?? '';
-                    $In_Process_Action = '3';
-                    $In_ASNNo_C = $doc_asn_detail->docno ?? '';
-                    $In_ASNLineNo_C = $doc_asn_detail->asnlineno ?? '';
-                    $In_FMTraceID_C = '';
-                    $In_New_TraceID_C = $doc_asn_detail->new_traceid ?? '';
-                    $In_ProductStatus = '00';
-                    $In_ProductStatus_Descr = '正常';
-                    $In_HoldRejectCode_C = 'OK';
-                    $In_HoldRejectReason_C = '正常';
-                    $In_PONo_C = '';
-                    $In_CustomerID = $doc_asn_detail->customerid ?? '';
-                    $In_SKU = $doc_asn_detail->sku ?? '';
-                    $In_ReceivedQty = $doc_asn_detail->receivedqty_each ?? '';
-                    $In_RejectedQty = '';
-                    $In_UOM = 'EA';
-                    $In_PackID = $doc_asn_detail->packid ?? '';
-                    $In_ContainerID = '';
-                    $In_LotAtt01_C = $doc_asn_detail->lotatt01 ?? '';
-                    $In_LotAtt02_C = $doc_asn_detail->lotatt02 ?? '';
-                    $In_LotAtt03_C = '';
-                    $In_LotAtt04_C = $doc_asn_detail->lotatt04 ?? '';
-                    $In_LotAtt05_C = $doc_asn_detail->lotatt05 ?? '';
-                    $In_LotAtt06_C = '';
-                    $In_LotAtt07_C = '';
-                    $In_LotAtt08_C = $doc_asn_detail->lotatt08 ?? '';
-                    $In_LotAtt09_C = '';
-                    $In_LotAtt10_C = '';
-                    $In_LotAtt11_C = '';
-                    $In_LotAtt12_C = '';
-                    $In_TotalCubic = '0.00';
-                    $In_TotalGrossWeight = '0.00';
-                    $In_TotalNetWeight = '0.00';
-                    $In_TotalPrice = '0.00';
-                    $In_UserDefine1 = $doc_asn_detail->userdefine1 ?? '';
-                    $In_UserDefine2 = $doc_asn_detail->userdefine2 ?? '';
-                    $In_UserDefine3 = $doc_asn_detail->userdefine3 ?? '';
-                    $In_UserDefine4 = $doc_asn_detail->userdefine4 ?? '';
-                    $In_UserDefine5 = $doc_asn_detail->userdefine5 ?? '';
-                    $In_FMLocation = 'STAGE'.$doc_asn_detail->warehouseid;
-                    $In_TOLocation_C = 'STAGE'.$doc_asn_detail->warehouseid;
-                    $In_QC_Type_C = 'OK';
-                    $In_PlanToLoc_C = '';
-                    $In_ReceivingTime = '';
-                    $In_LPN = '*';
-                    $In_Operator = $doc_asn_detail->addwho ?? '';
-                    $IN_RCVModule = '';
-                    $IN_RCVStation = '';
-                    $In_Language = 'cn';
-                    $In_UserID = $doc_asn_detail->addwho ?? '';
-                    $result = '';
-                    $stmt = oci_parse($conn, $sql_sp);
-                    oci_bind_by_name($stmt,':IN_Warehouse',$IN_Warehouse);
-                    oci_bind_by_name($stmt,':In_Process_Action',$In_Process_Action);
-                    oci_bind_by_name($stmt,':In_ASNNo_C',$In_ASNNo_C);
-                    oci_bind_by_name($stmt,':In_ASNLineNo_C',$In_ASNLineNo_C);
-                    oci_bind_by_name($stmt,':In_FMTraceID_C',$In_FMTraceID_C);
-                    oci_bind_by_name($stmt,':In_New_TraceID_C',$In_New_TraceID_C);
-                    oci_bind_by_name($stmt,':In_ProductStatus',$In_ProductStatus);
-                    oci_bind_by_name($stmt,':In_ProductStatus_Descr',$In_ProductStatus_Descr);
-                    oci_bind_by_name($stmt,':In_HoldRejectCode_C',$In_HoldRejectCode_C);
-                    oci_bind_by_name($stmt,':In_HoldRejectReason_C',$In_HoldRejectReason_C);
-                    oci_bind_by_name($stmt,':In_PONo_C',$In_PONo_C);
-                    oci_bind_by_name($stmt,':In_CustomerID',$In_CustomerID);
-                    oci_bind_by_name($stmt,':In_SKU',$In_SKU);
-                    oci_bind_by_name($stmt,':In_ReceivedQty',$In_ReceivedQty);
-                    oci_bind_by_name($stmt,':In_RejectedQty',$In_RejectedQty);
-                    oci_bind_by_name($stmt,':In_UOM',$In_UOM);
-                    oci_bind_by_name($stmt,':In_PackID',$In_PackID);
-                    oci_bind_by_name($stmt,':In_ContainerID',$In_ContainerID);
-                    oci_bind_by_name($stmt,':In_LotAtt01_C',$In_LotAtt01_C);
-                    oci_bind_by_name($stmt,':In_LotAtt02_C',$In_LotAtt02_C);
-                    oci_bind_by_name($stmt,':In_LotAtt03_C',$In_LotAtt03_C);
-                    oci_bind_by_name($stmt,':In_LotAtt04_C',$In_LotAtt04_C);
-                    oci_bind_by_name($stmt,':In_LotAtt05_C',$In_LotAtt05_C);
-                    oci_bind_by_name($stmt,':In_LotAtt06_C',$In_LotAtt06_C);
-                    oci_bind_by_name($stmt,':In_LotAtt07_C',$In_LotAtt07_C);
-                    oci_bind_by_name($stmt,':In_LotAtt08_C',$In_LotAtt08_C);
-                    oci_bind_by_name($stmt,':In_LotAtt09_C',$In_LotAtt09_C);
-                    oci_bind_by_name($stmt,':In_LotAtt10_C',$In_LotAtt10_C);
-                    oci_bind_by_name($stmt,':In_LotAtt11_C',$In_LotAtt11_C);
-                    oci_bind_by_name($stmt,':In_LotAtt12_C',$In_LotAtt12_C);
-                    oci_bind_by_name($stmt,':In_TotalCubic',$In_TotalCubic);
-                    oci_bind_by_name($stmt,':In_TotalGrossWeight',$In_TotalGrossWeight);
-                    oci_bind_by_name($stmt,':In_TotalNetWeight',$In_TotalNetWeight);
-                    oci_bind_by_name($stmt,':In_TotalPrice',$In_TotalPrice);
-                    oci_bind_by_name($stmt,':In_UserDefine1',$In_UserDefine1);
-                    oci_bind_by_name($stmt,':In_UserDefine2',$In_UserDefine2);
-                    oci_bind_by_name($stmt,':In_UserDefine3',$In_UserDefine3);
-                    oci_bind_by_name($stmt,':In_UserDefine4',$In_UserDefine4);
-                    oci_bind_by_name($stmt,':In_UserDefine5',$In_UserDefine5);
-                    oci_bind_by_name($stmt,':In_FMLocation',$In_FMLocation);
-                    oci_bind_by_name($stmt,':In_TOLocation_C',$In_TOLocation_C);
-                    oci_bind_by_name($stmt,':In_QC_Type_C',$In_QC_Type_C);
-                    oci_bind_by_name($stmt,':In_PlanToLoc_C',$In_PlanToLoc_C);
-                    oci_bind_by_name($stmt,':In_ReceivingTime',$In_ReceivingTime);
-                    oci_bind_by_name($stmt,':In_LPN',$In_LPN);
-                    oci_bind_by_name($stmt,':In_Operator',$In_Operator);
-                    oci_bind_by_name($stmt,':IN_RCVModule',$IN_RCVModule);
-                    oci_bind_by_name($stmt,':IN_RCVStation',$IN_RCVStation);
-                    oci_bind_by_name($stmt,':In_Language',$In_Language);
-                    oci_bind_by_name($stmt,':In_UserID',$In_UserID);
-                    oci_bind_by_name($stmt,':OUT_Return_Code',$result);
-                    oci_execute($stmt);
-                    oci_close($conn);
-                    if (substr($result,0,3) == '000'){
-                        $query = DB::raw("update cus_bs_asndetails t set t.rcvflag = 'Y' where t.asnno = ? and t.asnlineno = ?");
-                        $db->update($query,[$doc_asn_detail->docno,$doc_asn_detail->asnlineno]);
-                    }else{
-                        $query = DB::raw("update cus_bs_asndetails t set t.rcvflag = 'W' where t.asnno = ? and t.asnlineno = ?");
-                        $db->update($query,[$doc_asn_detail->docno,$doc_asn_detail->asnlineno]);
-                        $db->rollBack();
-                        return ['success'=>false, 'data'=>'收货失败','code'=>$result];
-                    }
-                }
-                $db->commit();
-                return ['success'=>true];
-            }catch (\Exception $e){
-                $db->rollBack();
-                return ['success'=>false, 'data'=>$e->getMessage()];
-            }
-        }
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return Application|Factory|Response|View
+     */
+    public function create()
+    {
+        if(!Gate::allows('入库管理-快速入库-录入')){ return redirect(url('/'));  }
+        return view('store.fast.create');
     }
 
-
-    /*$resule = $that->exe($doc_asn_detail->warehouseid,'3',$doc_asn_detail->docno,$doc_asn_detail->asnlineno,'',$doc_asn_detail->new_traceid,'00','正常','OK','正常',
-                        '',$doc_asn_detail->customerid,$doc_asn_detail->sku,$doc_asn_detail->receivedqty_each,'','EA',$doc_asn_detail->packid,'',$doc_asn_detail->lotatt01,$doc_asn_detail->lotatt02,
-                        '',$doc_asn_detail->lotatt04,$doc_asn_detail->lotatt05,'','',$doc_asn_detail->lotatt08,'','','','',
-                        '0.00','0.00','0.00','0.00',$doc_asn_detail->userdefine1,$doc_asn_detail->userdefine2,$doc_asn_detail->userdefine3,$doc_asn_detail->userdefine4,$doc_asn_detail->userdefine5,'STAGE'.$doc_asn_detail->warehouseid,
-                    'STAGE'.$doc_asn_detail->warehouseid,'OK','','','*',$doc_asn_detail->addwho,'','','cn',$doc_asn_detail->addwho,'');*/
-    /** $In_Process_Action为来源渠道,快速入库调用固定值 为 '3' */
-    private function exe($IN_Warehouse, $In_Process_Action, $In_ASNNo_C, $In_ASNLineNo_C, $In_FMTraceID_C, $In_New_TraceID_C, $In_ProductStatus,
-        $In_ProductStatus_Descr, $In_HoldRejectCode_C, $In_HoldRejectReason_C, $In_PONo_C, $In_CustomerID, $In_SKU, $In_ReceivedQty, $In_RejectedQty,
-        $In_UOM, $In_PackID, $In_ContainerID, $In_LotAtt01_C, $In_LotAtt02_C, $In_LotAtt03_C, $In_LotAtt04_C, $In_LotAtt05_C, $In_LotAtt06_C,
-        $In_LotAtt07_C, $In_LotAtt08_C, $In_LotAtt09_C, $In_LotAtt10_C, $In_LotAtt11_C, $In_LotAtt12_C,
-        $In_TotalCubic, $In_TotalGrossWeight, $In_TotalNetWeight, $In_TotalPrice, $In_UserDefine1, $In_UserDefine2,
-        $In_UserDefine3, $In_UserDefine4, $In_UserDefine5, $In_FMLocation, $In_TOLocation_C, $In_QC_Type_C, $In_PlanToLoc_C,
-        $In_ReceivingTime, $In_LPN, $In_Operator, $IN_RCVModule, $IN_RCVStation, $In_Language, $In_UserID, $OUT_Return_Code)
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param Request $request
+     * @return RedirectResponse|Response|Redirector
+     */
+    public function store(Request $request)
     {
-        /*$r_NO_COMMIT $R_CurrentTime $OUT_Return_Code $R_ReceivingTime $r_LPN $r_UDF2_AD $r_UDF2_IN
-        $R_Qty_PlanPutaway $R_QCTaskID $R_HOLD_FLAG $R_PA_TaskID $R_PA_Flag $R_QC_Sequence $R_PA_Sequence
-        $R_Reserve_Flag $R_QtyMVOut $r_TotalGrossWeight $r_TotalCubic r_TotalNetWeight r_TotalPrice In_LotAtt01
-        In_LotAtt02 In_LotAtt03 In_LotAtt04 In_LotAtt05 In_LotAtt06 In_LotAtt07 In_LotAtt08 In_LotAtt09 In_LotAtt10
-        In_LotAtt11 In_LotAtt12 In_HoldRejectCode In_HoldRejectReason
-        */
-        /** IS */
-        $r_OutboundLifeDays = 0;
-        $r_InboundLifeDays = 0;
-
-        if ($OUT_Return_Code == "NO_COMMIT" || $OUT_Return_Code == "*_*"){
-            $r_NO_COMMIT = 'N';
-        }else{
-            $r_NO_COMMIT = 'Y';
-        }
-        //初始化
-        $R_CurrentTime = Carbon::now();
-        $OUT_Return_Code ='000';
-        if (!$In_ReceivingTime){
-            $R_ReceivingTime = Carbon::now();
-        }else{
-            $R_ReceivingTime = $In_ReceivingTime;
-        }
-        //else R_ReceivingTime:=To_Date( IN_ReceivingTime,'YYYY/MM/DD hh24:mi:ss'); --2008-11-25 15:53:33
-
-        if ($In_LPN && $In_LPN != "*"){
-            $r_LPN = $In_LPN;
-        }else $r_LPN = "*";
-
-        $bascode = DB::select(DB::raw("SELECT udf2 FROM BAS_CODES WHERE codeid ='TRN_TYP' AND code='AD'"));
-        $r_UDF2_AD = $bascode[0]->udf2 ?? 'N';
-
-        $bascode = DB::select(DB::raw("SELECT udf2 FROM BAS_CODES WHERE codeid ='TRN_TYP' AND code='IN'"));
-        $r_UDF2_IN = $bascode[0]->udf2 ?? 'N';
-
-        $R_Qty_PlanPutaway = 0;
-        $R_QCTaskID = '*';
-        $R_HOLD_FLAG = 'N';
-        $R_PA_TaskID = '*';
-        $R_PA_Flag = 'N';
-        $R_QC_Sequence = 0;
-        $R_PA_Sequence = 0;
-        $R_Reserve_Flag = 'N';
-        $R_QtyMVOut  =  0;
-
-        $r_TotalGrossWeight = $In_TotalGrossWeight;
-        $r_TotalCubic = $In_TotalCubic;
-        $r_TotalNetWeight = $In_TotalNetWeight ?? 0;
-        $r_TotalPrice = $In_TotalPrice;
-
-        $In_LotAtt01 = $In_LotAtt01_C;
-        $In_LotAtt02 = $In_LotAtt02_C;
-        $In_LotAtt03 = $In_LotAtt03_C;
-        $In_LotAtt04 = $In_LotAtt04_C;
-        $In_LotAtt05 = $In_LotAtt05_C;
-        $In_LotAtt06 = $In_LotAtt06_C;
-        $In_LotAtt07 = $In_LotAtt07_C;
-        $In_LotAtt08 = $In_LotAtt08_C;
-        $In_LotAtt09 = $In_LotAtt09_C;
-        $In_LotAtt10 = $In_LotAtt10_C;
-        $In_LotAtt11 = $In_LotAtt11_C;
-        $In_LotAtt12 = $In_LotAtt12_C;
-
-        $In_HoldRejectCode = $In_HoldRejectCode_C;
-        $In_HoldRejectReason = $In_HoldRejectReason_C;
-
-        $In_TOLocation = $In_TOLocation_C;
-        $In_New_TraceID = $In_New_TraceID_C ?? '*';
-        $In_QC_Type = $In_QC_Type_C;
-        $In_FMTraceID = $In_FMTraceID_C;
-        $In_ASNNo = $In_ASNNo_C;
-        $In_ASNLineNo = $In_ASNLineNo_C;
-        $In_PONo = $In_PONo_C;
-        $In_PlanToLoc = $In_PlanToLoc_C;
-
-        $r_nrow = 0;
-
-        $OUT_Return_Code = '*_*';
-        //此处调用必然返回000,所以直接忽视判断进入下层逻辑
-        $OUT_Return_Code = $this->SPUDF_ProcessA($IN_Warehouse,'RCV_BEFORE',$In_ASNNo,$In_ASNLineNo,$In_ReceivedQty,$In_Language,$In_UserID,$OUT_Return_Code);
-
-        //TODO 盲收逻辑 SPASN_Receiving_Process:536行 $In_Process_Action = 2
-
-        //如果订单已经关闭或者取消,则报错
-        $doc_asn_header = DB::connection('oracle')->select(DB::raw("Select 1  from DOC_ASN_Header where ASNNO='".$In_ASNNo."' and (ASNStatus='90' or ASNStatus='99')"));
-        if ($doc_asn_header) return '201';
-
-        //收货数量必须大于0
-        if ($In_ReceivedQty <= 0 && ((!$In_ProductStatus) || $In_ProductStatus == '00')) return '204';
-
-        //批次属性自动复制 系统配置是否允许超量收货
-        $customer = DB::connection('oracle')->select(DB::raw("SELECT OverReceiving,OverRCVPercentage,ASN_LNK_PO,AsnRef1ToLot4,AsnRef2ToLot5,AsnRef3ToLot6,AsnRef4ToLot7,AsnRef5ToLot8 FROM Bas_Customer WHERE CustomerID='".$In_CustomerID."' AND Customer_Type = 'OW'"));
-        if (!$customer) return '888BAS_Customer,OPEN';
-
-        $R_OverReceiving = $customer[0]->overreceiving ?? 'N';
-        $R_OverRCVPercentage_Customer = $customer[0]->overrcvpercentage ?? 0;
-        $r_ASN_LNK_PO = $customer[0]->asn_lnk_po ?? 'Y';
-        $R_AsnRef1ToLot4 = $customer[0]->asnref1tolot4;
-        $R_AsnRef2ToLot5 = $customer[0]->asnref2tolot5;
-        $R_AsnRef3ToLot6 = $customer[0]->asnref3tolot6;
-        $R_AsnRef4ToLot7 = $customer[0]->asnref4tolot7;
-        $R_AsnRef5ToLot8 = $customer[0]->asnref5tolot8;
-
-        $DOC_ASN_Header = DB::connection('oracle')->select(DB::raw("SELECT ASNReference1,ASNReference2,ASNReference3,ASNReference4,ASNReference5,ExpectedArriveTime1,ExpectedArriveTime2,QCStatus,ASNType,WarehouseID,ReleaseStatus,Priority FROM DOC_ASN_Header WHERE ASNNO='".$In_ASNNo."'"));
-        if (!$DOC_ASN_Header) return '888DOC_ASN_Header,OPEN';
-
-        $r_ASNReference1 = $DOC_ASN_Header[0]->asnreference1;
-        $r_ASNReference2 = $DOC_ASN_Header[0]->asnreference2;
-        $r_ASNReference3 = $DOC_ASN_Header[0]->asnreference3;
-        $r_ASNReference4 = $DOC_ASN_Header[0]->asnreference4;
-        $r_ASNReference5 = $DOC_ASN_Header[0]->asnreference5;
-        $r_ExpectedArriveTime1 = $DOC_ASN_Header[0]->expectedarrivetime1 ?? "2000-01-01 00:00:00";
-        $r_ExpectedArriveTime2 = $DOC_ASN_Header[0]->expectedarrivetime2 ?? "2099-12-31 00:00:00";
-        $r_QCStatus = $DOC_ASN_Header[0]->qcstatus;
-        $r_ASNType = $DOC_ASN_Header[0]->asntype;
-        $r_WarehouseID = $DOC_ASN_Header[0]->warehouseid;
-        $R_ReleaseStatus = $DOC_ASN_Header[0]->releasestatus;
-        $r_Priority = $DOC_ASN_Header[0]->priority ?? '3';
-
-        if ($R_AsnRef1ToLot4 == 'Y' && ($r_ASNReference1 && $r_ASNReference1 != "*") && ((!$In_LotAtt04) || $In_LotAtt04=='*')){
-            $In_LotAtt04 = $r_ASNReference1;
-        }
-        if ($R_AsnRef2ToLot5 == 'Y' && ($r_ASNReference2 && $r_ASNReference2 != "*") && ((!$In_LotAtt05) || $In_LotAtt05=='*')){
-            $In_LotAtt05 = $r_ASNReference2;
-        }
-        if ($R_AsnRef3ToLot6 == 'Y' && ($r_ASNReference3 && $r_ASNReference3 != "*") && ((!$In_LotAtt06) || $In_LotAtt06=='*')){
-            $In_LotAtt06 = $r_ASNReference3;
-        }
-        if ($R_AsnRef4ToLot7 == 'Y' && ($r_ASNReference4 && $r_ASNReference4 != "*") && ((!$In_LotAtt07) || $In_LotAtt07=='*')){
-            $In_LotAtt07 = $r_ASNReference4;
-        }
-        if ($R_AsnRef5ToLot8 == 'Y' && ($r_ASNReference5 && $r_ASNReference5 != "*") && ((!$In_LotAtt08) || $In_LotAtt08=='*')){
-            $In_LotAtt08 = $r_ASNReference5;
-        }
-
-        if ($In_LotAtt01 == 'YYYY-MM-DD') $In_LotAtt01 = null;
-        if ($In_LotAtt02 == 'YYYY-MM-DD') $In_LotAtt02 = null;
-        if ($In_LotAtt03 == 'YYYY-MM-DD') $In_LotAtt03 = null;
-
-        // TODO SPASN_Receiving_Process:643行 IN_ProductStatus固定值00 跳过
-
-        //生产日期、入库日期、失效日期的逻辑校验
-        if (($In_LotAtt01 && $In_LotAtt02 && Carbon::parse($In_LotAtt01)->gte(Carbon::parse($In_LotAtt02))) || ($In_LotAtt01 && Carbon::parse($In_LotAtt01)->gt(Carbon::parse($R_CurrentTime)))){
-            return "260";
-        }
-        $r_ASN_MDT_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'ASN_MDT_CHK');
-
-        //入库生产日期不能小于在库库存生产日期
-        if ($r_ASN_MDT_CHK == 'Y' && trim($In_LotAtt01)){
-            $data = DB::connection('oracle')->select(DB::raw("SELECT 1 c FROM INV_LOT_LOC_ID a,INV_LOT_ATT b, bas_location c WHERE a.CUSTOMERID='".$In_CustomerID.
-                "' AND a.sku='".$In_SKU."' AND a.LotNum=b.LotNum AND a.LocationID=c.LocationID AND c.LocationUsage<>'ST' AND b.LotAtt01>'".$In_LotAtt01."'"));
-            if ($data) return '266INV_LOT_LOC_ID';
-        }
-
-        //批次属性必输校验
-        $BAS_lotID = DB::connection('oracle')->select(DB::raw("SELECT LotAtt01_Flag,LotAtt02_Flag,LotAtt03_Flag,LotAtt04_Flag,LotAtt05_Flag,LotAtt06_Flag,".
-            "LotAtt07_Flag,LotAtt08_Flag,LotAtt09_Flag,LotAtt10_Flag,LotAtt11_Flag,LotAtt12_Flag,OverRCVPercentage,a.LotID,PackID,".
-            "GrossWeight,Cube,CopyPackIDToLotAtt12,AllowReceiving,A.SKU_Group1 FROM Bas_SKU a, BAS_lotID b WHERE a.CustomerID='".$In_CustomerID."' AND a.sku='".$In_SKU."' AND a.LotID=b.LotID"));
-        if (!$BAS_lotID)return "888From Bas_SKU*BAS_lotID,OPEN";
-        $r_LotAtt01_Flag = $BAS_lotID[0]->lotatt01_flag;
-        $r_LotAtt02_Flag = $BAS_lotID[0]->lotatt02_flag;
-        $r_LotAtt03_Flag = $BAS_lotID[0]->lotatt03_flag;
-        $r_LotAtt04_Flag = $BAS_lotID[0]->lotatt04_flag;
-        $r_LotAtt05_Flag = $BAS_lotID[0]->lotatt05_flag;
-        $r_LotAtt06_Flag = $BAS_lotID[0]->lotatt06_flag;
-        $r_LotAtt07_Flag = $BAS_lotID[0]->lotatt07_flag;
-        $r_LotAtt08_Flag = $BAS_lotID[0]->lotatt08_flag;
-        $r_LotAtt09_Flag = $BAS_lotID[0]->lotatt09_flag;
-        $r_LotAtt10_Flag = $BAS_lotID[0]->lotatt10_flag;
-        $r_LotAtt11_Flag = $BAS_lotID[0]->lotatt11_flag;
-        $r_LotAtt12_Flag = $BAS_lotID[0]->lotatt12_flag;
-        $r_OverRCVPercentage_SKU = $BAS_lotID[0]->overrcvpercentage ?? 0;
-        $r_SKU_LOTID = $BAS_lotID[0]->lotid;
-        $r_SKU_PackID = $BAS_lotID[0]->packid;
-        $r_SKU_GrossWeight = $BAS_lotID[0]->grossweight;
-        $r_SKU_Cube = $BAS_lotID[0]->cube;
-        $r_CopyPackIDToLotAtt12 = $BAS_lotID[0]->copypackidtolotatt12;
-        $r_AllowReceiving = $BAS_lotID[0]->allowreceiving;
-        $r_SKU_Group1 = $BAS_lotID[0]->sku_group1;
-        //是否被设置禁止入库
-        if ($r_AllowReceiving == 'N') return "117";
-        if (($r_LotAtt01_Flag == '3' && !$In_LotAtt01) ||
-            ($r_LotAtt02_Flag == "3" && !$In_LotAtt02) ||
-            ($r_LotAtt03_Flag == "3" && !$In_LotAtt03) ||
-            ($r_LotAtt04_Flag == "3" && !$In_LotAtt04) ||
-            ($r_LotAtt05_Flag == "3" && !$In_LotAtt05) ||
-            ($r_LotAtt06_Flag == "3" && !$In_LotAtt06) ||
-            ($r_LotAtt07_Flag == "3" && !$In_LotAtt07) ||
-            ($r_LotAtt08_Flag == "3" && !$In_LotAtt08) ||
-            ($r_LotAtt09_Flag == "3" && !$In_LotAtt09) ||
-            ($r_LotAtt10_Flag == "3" && !$In_LotAtt10) ||
-            ($r_LotAtt11_Flag == "3" && !$In_LotAtt11) ||
-            ($r_LotAtt12_Flag == "3" && !$In_LotAtt12))return "221".$In_ASNLineNo_C;
-        if ($r_LotAtt01_Flag == '1' && $In_LotAtt01) $In_LotAtt01 = null;
-        if ($r_LotAtt02_Flag == '1' && $In_LotAtt02) $In_LotAtt02 = null;
-        if ($r_LotAtt03_Flag == '1' && $In_LotAtt03) $In_LotAtt03 = null;
-        if ($r_LotAtt04_Flag == '1' && $In_LotAtt04) $In_LotAtt04 = null;
-        if ($r_LotAtt05_Flag == '1' && $In_LotAtt05) $In_LotAtt05 = null;
-        if ($r_LotAtt06_Flag == '1' && $In_LotAtt06) $In_LotAtt06 = null;
-        if ($r_LotAtt07_Flag == '1' && $In_LotAtt07) $In_LotAtt07 = null;
-        if ($r_LotAtt08_Flag == '1' && $In_LotAtt08) $In_LotAtt08 = null;
-        if ($r_LotAtt09_Flag == '1' && $In_LotAtt09) $In_LotAtt09 = null;
-        if ($r_LotAtt10_Flag == '1' && $In_LotAtt10) $In_LotAtt10 = null;
-        //if ($r_LotAtt11_Flag == '1' && $In_LotAtt11) $In_LotAtt11 = null;
-        if ($r_LotAtt12_Flag == '1' && $In_LotAtt12) $In_LotAtt12 = null;
-
-        $R_LOT_12_PKG = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'LOT_#12_PKG');
-        // 批次属性12被设置为跟踪包装数量,不允许输入非数字字符'
-        if ($R_LOT_12_PKG == 'Y' && !is_numeric($In_LotAtt12)) return "232";
-
-        if ($r_OverRCVPercentage_SKU != 0) $r_OverRCVPercentage = $r_OverRCVPercentage_SKU;
-        else $r_OverRCVPercentage = $R_OverRCVPercentage_Customer;
-
-        // TODO 药品相关逻辑 SPASN_Receiving_Process:817行 药品有效期 证书有效期 经营许可证有效期校验提示
-
-        //基础设置是否维护完全校验
-        $R_BAS_PAC_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_PAC_CHK');
-        $R_BAS_LOT_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_LOT_CHK');
-        $R_BAS_GWT_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_GWT_CHK');
-        $R_BAS_CUB_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'BAS_CUB_CHK');
-        if ($R_BAS_PAC_CHK == 'Y' && !$r_SKU_PackID)return '110'.$In_SKU;
-        if ($R_BAS_LOT_CHK == 'Y' && !$r_SKU_LOTID)return '111';
-        if ($R_BAS_GWT_CHK == 'Y' && $r_SKU_GrossWeight == 0)return '112';
-        if ($R_BAS_CUB_CHK == 'Y' && $r_SKU_Cube == 0)return '113';
-
-        //订单释放状态校验
-        if($R_ReleaseStatus == 'N') return '226';
-
-        /*参数准备 */
-        //必须输入价格
-        $R_UNT_PRI_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'UNT_PRI_CTL');
-        //收货后打印上架标签
-        $R_PRT_PTA_LBL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PRT_PTA_LBL');
-        //ASN收货自动产生跟踪号
-        $r_ASN_GEN_TID = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'ASN_GEN_TID');
-        //收货后将收货结果更新ASN明细
-        $r_ASN_RCV_UPD = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'ASN_RCV_UPD');
-        //完全收货后自动关闭ASN
-        $r_RCV_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_CTL');
-        //超过产品有效期控制天数是否拒收
-        $r_EXP_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'EXP_CTL');
-        //码盘后才能收货
-        $r_PLT_RCV = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PLT_RCV');
-        //跨区域货物是否允许收到一个托盘上
-        $r_RCV_CRS_ARA = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_CRS_ARA');
-        //收货时必须指定跟踪号
-        $r_RCV_TID_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_TID_CTL');
-        //超额收货
-        $R_OverReceiving = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'OVR_RCV');
-        //收货时间必须在预期到货时间范围内
-        $r_RCV_TIM_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_TIM_CTL');
-        //同一跟踪号不允许在收货区重复收货
-        $r_RCV_MIX_TID = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_MIX_TID');
-        //只有上架确认后才能关闭ASN
-        $r_PTA_CLS_CHK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PTA_CLS_CHK');
-        //收货数量拆分寻找目标库位
-        $r_RCV_BRK_TSK = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_BRK_TSK');
-        //扫描收货时记录箱码和序列号
-        $r_SN_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'SN#_CTL','0');
-        //质检后才能收货
-        $r_QC_RCV_CTL = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'QC_RCV_CTL');
-        //目标库位为拆零拣货位拆箱时作废箱码
-        $r_PCK_LOS_SN = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'PCK_LOS_SN');
-        //服装行业插件开关
-        $r_IND_TEX = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'IND_TEX');
-
-        if ($In_Process_Action != '2'){
-            $DOC_ASN_DETAiLS = DB::connection('oracle')->select(DB::raw("SELECT ExpectedQty_Each,ReceivedQty_Each,POLineNO,PONO,OverRCVPercentage,ContainerID,QCStatus FROM DOC_ASN_DETAiLS WHERE ASNNO='".$In_ASNNo."' AND ASNLineNo='".$In_ASNLineNo."' FOR UPDATE"));
-            if (!$DOC_ASN_DETAiLS)return '104'.$In_ASNNo.":".$In_ASNLineNo;
-            $r_ExpectedQty_Each_ASN = $DOC_ASN_DETAiLS[0]->expectedqty_each;
-            $r_ReceivedQty_Each_ASN = $DOC_ASN_DETAiLS[0]->receivedqty_each;
-            $r_POLineNO = $DOC_ASN_DETAiLS[0]->polineno;
-            $r_PONO = $DOC_ASN_DETAiLS[0]->pono;
-            $R_OverRCVPercentage_ASN = $DOC_ASN_DETAiLS[0]->overrcvpercentage;
-            $r_ASNContainerID = $DOC_ASN_DETAiLS[0]->containerid ?? '';
-            $r_QCStatus = $DOC_ASN_DETAiLS[0]->qcstatus ?? '';
-        }
-
-        //目标库位属性
-        if ($In_TOLocation == '*' || !trim($In_TOLocation))$In_TOLocation = $In_FMLocation;
-
-        $BAS_Location = DB::connection('oracle')->select(DB::raw("SELECT LocationUsage,LoseID_Flag,Mix_Flag,Mix_LotFlag,LocationAttribute,SKUCount FROM BAS_Location WHERE LocationID='".$In_TOLocation."'"));
-        if (!$BAS_Location)return '104'.$In_TOLocation;
-        $R_LocationUsage = $BAS_Location[0]->locationusage;
-        $R_LoseID_Flag = $BAS_Location[0]->loseid_flag ?? 'N';
-        $R_Mix_Flag = $BAS_Location[0]->mix_flag ?? 'Y';
-        $R_Mix_LotFlag = $BAS_Location[0]->mix_lotflag ?? 'Y';
-        $r_LocationAttribute = $BAS_Location[0]->locationattribute;
-        $r_SKUCount = $BAS_Location[0]->skucount;
-
-        if($r_QC_RCV_CTL == 'Y' && $r_QCStatus != '20')return '272';
-
-        //如果ASN中ContainerID有值,并且收货SP没有传递跟踪号,则以ContainerID作为跟踪号
-        if ($r_ASNContainerID && (!$In_New_TraceID || $In_New_TraceID == '*'))$In_New_TraceID = $r_ASNContainerID;
-
-        $IN_New_TraceID_OLD = $In_New_TraceID;
-
-        if ($r_RCV_TID_CTL == 'Y' && (!$In_New_TraceID || $In_New_TraceID=='*'))return '270';
-        //必须维护单价后才能收货
-        if ($R_UNT_PRI_CTL == 'Y'){
-            if (!$In_TotalPrice || $In_TotalPrice <= 0)return '050';
-        }
-
-        if($r_RCV_TIM_CTL == 'Y' && ($R_CurrentTime->lt(Carbon::parse($r_ExpectedArriveTime1)) || $R_CurrentTime->gt($r_ExpectedArriveTime2)))return '271';
-
-        // 同一跟踪号不允许混收产品
-        if (strtoupper($In_FMLocation) == 'SCANSTATION')$r_RCV_MIX_SKU = 'Y';
-        else $r_RCV_MIX_SKU=$this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_MIX_SKU', 'Y');
-
-        $r_RCV_MIX_GR1 = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'RCV_MIX_GR1', 'Y','C');
-
-        //跟踪号的校验处理
-        if ($In_New_TraceID != '*' && trim($In_New_TraceID)){
-            if ($R_LoseID_Flag == 'N'){
-                if ($r_RCV_MIX_TID == 'N'){ //跟踪号是否可以多次收货
-                    $INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.LOCATIONID = b.LOCATIONID WHERE b.WAREHOUSEID = '".
-                        $IN_Warehouse."' AND  TraceID='".$In_New_TraceID."' AND qty>0"));
-                    if ($INV_LOT_LOC_ID) return '218跟踪号重复错误ID='.$In_New_TraceID;
-                }else{
-                    if ($r_RCV_MIX_SKU == 'N'){
-                        $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.locationid = b.LocationID WHERE b.WarehouseID = '".
-                        $IN_Warehouse."' AND TraceID = '".$In_New_TraceID."' AND sku <> '".$In_SKU."' AND qty>0"));
-                        if ($TABLE_INV_LOT_LOC_ID) return '273';
-                    }elseif ($r_RCV_MIX_GR1 == 'N'){
-                        $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b ON a.locationid = b.LocationID INNER JOIN Bas_Sku C ON A.CUSTOMERID = C.CUSTOMERID AND A.SKU = C.SKU WHERE b.WarehouseID = '".
-                            $IN_Warehouse."' AND TraceID='".$In_New_TraceID."' AND C.SKU_GROUP1 <> '".$r_SKU_Group1."' AND qty>0"));
-                        if ($TABLE_INV_LOT_LOC_ID)return '273';
-                    }
-                    //ID是否重复
-                    $TABLE_INV_LOT_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM INV_LOT_LOC_ID a INNER JOIN view_MultiWarehouse b on a.locationid = b.LocationID where b.WarehouseID ='".
-                        $IN_Warehouse."' AND a.LocationID<>'".$In_TOLocation."' AND a.TraceID='".$In_New_TraceID."' AND a.QTY>0"));
-                    if ($TABLE_INV_LOT_LOC_ID)return '218'.$In_New_TraceID;
-                }
-            }else $In_New_TraceID = '*';
-        }
-
-        //r_QtyOnHold:=0
-        if (!trim($In_HoldRejectCode)) $In_HoldRejectCode = 'OK'; //TODO 1098行
-
-        //ID合法性校验 禁止收货到封存库位
-        if (in_array($r_LocationAttribute,["HD","FI"]))return '228';
-
-        //混放产品校验
-        if (($R_Mix_Flag == 'N' || $r_SKUCount > 0) && $R_LocationUsage != 'ST'){
-            $TABLE_inv_lot_LOC_ID = DB::connection('oracle')->select(DB::raw("SELECT COUNT(distinct SKU) c FROM inv_lot_LOC_ID WHERE LocationID='".$In_TOLocation."' AND sku <> '".$In_SKU.
-                "' AND Qty > 0"));
-            if ($TABLE_inv_lot_LOC_ID){
-                if ($TABLE_inv_lot_LOC_ID[0]->c >= 1 && $R_Mix_Flag == 'N')return '205'.rtrim($In_TOLocation);
-                elseif ($R_Mix_Flag == 'Y' && $r_SKUCount > 0 && $TABLE_inv_lot_LOC_ID[0]->c >= $r_SKUCount) return '367'.$r_SKUCount;
-            }
-        }
-
-        //码盘后才能收货
-        if (!rtrim($In_FMTraceID))$In_FMTraceID = '*';
-        if ($r_PLT_RCV == 'Y' && $In_FMTraceID == '*')return '217';
-        if ($In_FMTraceID != '*'){
-            //无论是ASn收货还是码盘收货, 交易里的FMUOM/QTY/Packid都取收货的数据
-            $TABLE_DOC_Trace_Details = DB::connection('oracle')->select(DB::raw("SELECT PlanToLoc, UOM, LineStatus, Reserve_Flag,Lotnum, ExpectedQty_Each - ReceivedQty_Each from DOC_Trace_Details ".
-            "WHERE TraceID=In_FMTraceID  AND ASNNO='".$In_ASNNo."' AND ASNLineNO='".$In_ASNLineNo."'"));
-            if (!$TABLE_DOC_Trace_Details) return '104'.$In_ASNNo.":".$In_ASNLineNo;
-            $r_PlanToLoc_Trace = $TABLE_DOC_Trace_Details[0]->plantoloc;
-            $r_TraceUOM = $TABLE_DOC_Trace_Details[0]->uom;
-            $r_LineStatus_Trace = $TABLE_DOC_Trace_Details[0]->linestatus;
-            $R_Reserve_Flag = $TABLE_DOC_Trace_Details[0]->reserve_flag;
-            $r_Lotnum_Trace = $TABLE_DOC_Trace_Details[0]->lotnum;
-            $r_CancelQty_Trace = $TABLE_DOC_Trace_Details[0]->expectedqty_each - $TABLE_DOC_Trace_Details[0]->receivedqty_each;
-
-            if ($R_Reserve_Flag == 'Y' && $R_LocationUsage != 'ST'){
-                $OUT_Return_Code = '*_*';
-                $OUT_Return_Code = $this->spasn_reserve_cancel($IN_Warehouse, 'TRACEID', $In_ASNNo, $In_ASNLineNo, $In_FMTraceID, $In_Language, $In_UserID, $OUT_Return_Code);
-                if (substr($OUT_Return_Code,1,3) != '000'){
-                    DB::rollBack();
-                    return $OUT_Return_Code;
-                }
-            }
-        }else{
-            //没有码盘
-            $r_FMUOM = $In_UOM;
-            $r_FMPackID = $In_PackID;
-            $r_FMQty_Each = '';
-            $r_FMQty = $In_ReceivedQty;
-        }
-
-        //收货时使用的包装数量转换
-        $TABLE_bas_Package = DB::connection('oracle')->select(DB::raw("SELECT QTY1,QTY2,QTY3,QTY4,QTY5,IN_Label1,IN_Label3,IN_Label4 FROM bas_Package where PackID='".$In_PackID."'"));
-        if (!$TABLE_bas_Package)return '104'.$In_PackID;
-        $r_QTY1_P = $TABLE_bas_Package[0]->qty1;
-        $r_QTY2_P = $TABLE_bas_Package[0]->qty2;
-        $r_QTY3_P = $TABLE_bas_Package[0]->qty3;
-        $r_QTY4_P = $TABLE_bas_Package[0]->qty4;
-        $r_QTY5_P = $TABLE_bas_Package[0]->qty5;
-        $r_IN_Label1 = $TABLE_bas_Package[0]->in_label1;
-        $r_IN_Label3 = $TABLE_bas_Package[0]->in_label3;
-        $r_IN_Label4 = $TABLE_bas_Package[0]->in_label4;
+        if(!Gate::allows('入库管理-快速入库-录入')){ return redirect(url('/'));  }
+        $this->validator($request);
+        if ($request->test)$result = $this->quickStorage($request->input('asn_code'),$request->input('quality') == '正品' ? 'ZP' : 'CC',$request->input('depository_code'));
+        else $result = $this->quickStorage_temp($request->input('asn_code'),$request->input('quality'),$request->input('depository_code'));
+        $response = redirect('store/fast/create');
+        if ($result['success'])return redirect('store/fast/create')->with('successTip',$result['data']);
+        return $response->with('successError',$result['data']);
+    }
 
-        if ($r_CopyPackIDToLotAtt12 == 'Y')$In_LotAtt12 = $r_QTY3_P;
-        if ($R_LOT_12_PKG == 'Y' && $In_UOM == 'CS')$R_UOMQty_Read = $In_LotAtt12;
-        else{
-            switch ($In_UOM){
-                case 'EA':
-                    $R_UOMQty_Read = $r_QTY1_P;
-                    break;
-                case 'IP':
-                    $R_UOMQty_Read = $r_QTY2_P;
-                    break;
-                case 'CS':
-                    $R_UOMQty_Read = $r_QTY3_P;
-                    break;
-                case 'PL':
-                    $R_UOMQty_Read = $r_QTY4_P;
-                    break;
-                case 'OT':
-                    $R_UOMQty_Read = $r_QTY5_P;
-                    break;
-            }
+    public function quickStorage_temp($asn,$quality,$depository_code){
+        $WMSReflectReceive=WMSReflectReceive::with('skus')->where('ASNNO',$asn)->first();
+        if (!$WMSReflectReceive)return ['success'=>false, 'data'=>"ASN编号不存在!"];
+        $warehouse=Warehouse::query()->where('code',$WMSReflectReceive->WAREHOUSEID)->first();
+        if (!$warehouse&&$WMSReflectReceive->WAREHOUSEID){
+            $warehouse=new Warehouse([
+                'name'=>$WMSReflectReceive->WAREHOUSEID,
+                'code'=>$WMSReflectReceive->WAREHOUSEID
+            ]);
+            $warehouse->save();
         }
-        $r_FMQty_Each = ($r_FMQty ?? 0) * ($R_UOMQty_Read ?? 0);
-        $r_ReceivedQty_Each = $In_ReceivedQty * ($R_UOMQty_Read ?? 0);
-
-        if (!$r_TotalCubic) $r_TotalCubic = ($r_SKU_Cube ?? 0) * $r_ReceivedQty_Each;
-
-        if ($In_Process_Action != 2){
-            if ($R_OverRCVPercentage_ASN ?? false)$r_OverRCVPercentage = $R_OverRCVPercentage_ASN;
-            //质检控制
-            if ($r_QC_RCV_CTL == 'C'){ //校验合格数
-                $TABLE_ACT_QC_Transaction = DB::connection('oracle')->select(DB::raw("SELECT SUM(QCQty_PASS) pass FROM ACT_QC_Transaction a INNER JOIN DOC_QC_Header b ON A.QCNo = b.QcNo WHERE B.ASNNo = '".$In_ASNNo."' AND A.AsnLineNo = '".$In_ASNLineNo."' AND B.QCStatus < '90'"));
-                if ($TABLE_ACT_QC_Transaction)$r_QCQTY_Pass = $TABLE_ACT_QC_Transaction[0]->pass;
-                if ((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) > ($r_QCQTY_Pass ?? 0)) return '225';
-            }else{
-                $TABLE_doc_QC_Details = DB::connection('oracle')->select(DB::raw("SELECT C.UDF1 from doc_QC_Details a INNER JOIN doc_QC_Header b ON a.QcNo = b.QcNo INNER JOIN BAS_Codes C ON a.QCResult = C.Code and codeid = 'QC_RST' WHERE B.ASNNo = '".$In_ASNNo."' and A.AsnLineNo = '".$In_ASNLineNo."' and B.QCStatus < '90' and rownum = 1"));
-                if ($TABLE_doc_QC_Details) $r_UDF1 = $TABLE_doc_QC_Details[0]->udf1;
-                if ($r_UDF1 ?? false){
-                    if ($r_UDF1 == 'NOPASS')return '229'; //拒收,原因:质检不合格'
-                    if ($r_UDF1 == 'CONTROL'){
-                        $TABLE_ACT_QC_Transaction = DB::connection('oracle')->select(DB::raw("Select SUM(QcQty_Reject) QcQty_Reject from ACT_QC_Transaction a inner join DOC_QC_Header b ON A.QCNo = b.QcNo Where B.ASNNo = '".$In_ASNNo."' and A.AsnLineNo = '".$In_ASNLineNo."' and B.QCStatus <> '90'"));
-                        if ($TABLE_ACT_QC_Transaction) $r_QCQTY_Reject = $TABLE_ACT_QC_Transaction[0]->qcqty_reject;
-                        if (($r_ReceivedQty_Each_ASN ?? 0 + $r_ReceivedQty_Each) > ($r_ExpectedQty_Each_ASN ?? 0 - ($r_QCQTY_Reject ?? 0)))return '225'; //超出质检合格数
-                    }
-                }
-            }
+        $owner=Owner::query()->where('code',$WMSReflectReceive->CUSTOMERID)->first();
+        if (!$owner&&$WMSReflectReceive->CUSTOMERID){
+            $owner=new Owner([
+                'name'=>$WMSReflectReceive->CUSTOMERID,
+                'code'=>$WMSReflectReceive->CUSTOMERID
+            ]);
+            $owner->save();
         }
-
-        //超量收货校验
-        if ($R_OverReceiving != 'Y' && ($r_ExpectedQty_Each_ASN ?? false) && ($In_Process_Action != 2)){
-            if ((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) > $r_ExpectedQty_Each_ASN)return '215';
-            if (($r_PONO ?? false) && $r_PONO != '*' && ($r_POLineNO ?? false)){
-                $TABLE_DOC_PO_DETAiLS = DB::connection('oracle')->select(DB::raw("SELECT OrderedQty_Each, ReceivedQty_Each From DOC_PO_DETAiLS where PONO='".$r_PONO."' AND POLineNo='".$r_POLineNO."'"));
-                if ($TABLE_DOC_PO_DETAiLS){
-                    $r_OrderedQty_PO = $TABLE_DOC_PO_DETAiLS[0]->orderedqty_each;
-                    $r_ReceivedQty_Each_PO = $TABLE_DOC_PO_DETAiLS[0]->receivedqty_each;
-                }
-                if ((($r_ReceivedQty_Each_PO ?? 0) + $r_ReceivedQty_Each > ($r_OrderedQty_PO ?? 0)))return '215'.$In_CustomerID.",PONo=".$r_PONO;
-            }
-        }
-
-        if ($R_OverReceiving == 'Y' && $r_OverRCVPercentage && ($r_ExpectedQty_Each_ASN ?? false) && $In_Process_Action != 2){//有百分比限制
-            $r_OVR_RCV_BY = $this->GETSYS_configuration($IN_Warehouse, $In_CustomerID, $r_ASNType, 'OVR_RCV_BY','BOTH');
-            if (in_array($r_OVR_RCV_BY,["ASN","BOTH"])){
-                if (((($r_ReceivedQty_Each_ASN ?? 0) + $r_ReceivedQty_Each) / $r_ExpectedQty_Each_ASN) > (1+$r_OverRCVPercentage))return '215'.$In_CustomerID;
-            }elseif (in_array($r_OVR_RCV_BY,["PO","BOTH"])){
-                if (($r_PONO ?? false) && $r_PONO!='*' && ($r_POLineNO ?? false)){
-                    $TABLE_DOC_PO_DETAiLS = DB::connection('oracle')->select(DB::raw("Select OrderedQty_Each, ReceivedQty_Each From DOC_PO_DETAiLS where PONO=r_PONO AND POLineNo=r_POLineNo"));
-                    if ($TABLE_DOC_PO_DETAiLS){
-                        $r_OrderedQty_PO = $TABLE_DOC_PO_DETAiLS[0]->orderedqty_each;
-                        $r_ReceivedQty_Each_PO = $TABLE_DOC_PO_DETAiLS[0]->receivedqty_each;
+        $store=Store::query()->where('asn_code',$WMSReflectReceive->ASNNO)->first();
+        if(!$store){
+            $store=new Store([
+                'asn_code'=>$WMSReflectReceive->ASNNO,
+                'warehouse_id'=>$warehouse->id,
+                'owner_id'=>$owner->id,
+                'stored_method'=>'快速入库',
+                'status'=>'未入库',
+                'remark'=>$WMSReflectReceive->NOTES,
+            ]);
+            $store->save();
+
+            $customDepository=(function()use($depository_code){
+                $customDepository=Depository::query()->where('code',$depository_code)->first();
+                if($depository_code){
+                    if (!$customDepository){
+                        $depository=new Depository([
+                            'name'=>$depository_code,
+                            'code'=>$depository_code
+                        ]);
+                        $depository->save();
                     }
-                    if (((($r_ReceivedQty_Each_PO ?? 0) + $r_ReceivedQty_Each) / ($r_OrderedQty_PO ?? 0)) > (1+$r_OverRCVPercentage)) return '215'.$In_CustomerID.',PONo='.$r_PONO;
                 }
-            }
-        }
-
-        if ($In_ASNNo == '*') $r_DocType = '*';
-        else $r_DocType = 'ASN';
-
-        //RF收货产生新的ID [In_New_TraceID],自动打印上架标签
-        if ($In_New_TraceID == '*' && ($R_PRT_PTA_LBL == 'Y' || $r_ASN_GEN_TID == 'Y')){
-            if ($R_LoseID_Flag != 'Y'){
-               // $OUT_Return_Code = $this->spcom_getidsequence(); //1331 此SP调用 恒定返回000 无意义调用
-                $OUT_Return_Code = '000';
-            }
-        }
-        //判断目标库位是否冻结 @LocationHold
-        $TABLE_ACT_InventoryHold = DB::connection('oracle')->select(DB::raw("Select count(1) c From ACT_InventoryHold Where HoldBy='2' and HoldFlag='Y' and LocationID='".$In_TOLocation."'"));
-        if ($TABLE_ACT_InventoryHold)$r_nrow = $TABLE_ACT_InventoryHold[0]->c;
-        if ($r_nrow >= 1) $r_LocationHold = 'Y';
-        $r_LogicalFMSequence = null;
-        $r_LogicalToSequence = null;
-        $TABLE_BAS_Location = DB::connection('oracle')->select(DB::raw("select LogicalSequence From BAS_Location Where LocationID= '".$In_PlanToLoc."'"));
-        if (!$TABLE_BAS_Location) $r_LogicalToSequence = 0;
-        else $r_LogicalToSequence = $TABLE_BAS_Location[0]->logicalsequence;
-        $TABLE_BAS_Location = DB::connection('oracle')->select(DB::raw("select LogicalSequence From BAS_Location Where LocationID='".$In_TOLocation."'"));
-        if (!$TABLE_BAS_Location) $r_LogicalFMSequence = 0;
-        else $r_LogicalFMSequence = $TABLE_BAS_Location[0]->logicalsequence;
-        $r_MaxPATaskID_Sequence = 0;
-        $r_MaxQCTaskID_Sequence = 0;
-
-        // <<Loop1>>
-        //批号处理
-        if ($In_Process_Action != '2'){
-            $r_nrow = 1;
-            $query = DB::raw("SELECT LotNum from INV_LOT_ATT where CustomerID='".$In_CustomerID."' and SKU=in_SKU".
-                " and nvl(LotAtt01,'*')=nvl(rtrim('".$In_LotAtt01."'),'*') and nvl(LotAtt02,'*')=nvl(rtrim('".$In_LotAtt02."'),'*') and nvl(LotAtt03,'*')=nvl(rtrim('".$In_LotAtt03."'),'*')".
-                " and nvl(LotAtt04,'*')=nvl(rtrim('".$In_LotAtt04."'),'*') and nvl(LotAtt05,'*')=nvl(rtrim('".$In_LotAtt05."'),'*') and nvl(LotAtt06,'*')=nvl(rtrim('".$In_LotAtt06."'),'*')".
-                " and nvl(LotAtt07,'*')=nvl(rtrim('".$In_LotAtt07."'),'*') and nvl(LotAtt08,'*')=nvl(rtrim('".$In_LotAtt08."'),'*') and nvl(LotAtt09,'*')=nvl(rtrim('".$In_LotAtt09."'),'*')".
-                " and nvl(LotAtt10,'*')=nvl(rtrim('".$In_LotAtt10."'),'*') and nvl(LotAtt11,'*')=nvl(rtrim('".$In_LotAtt11."'),'*') and nvl(LotAtt12,'*')=nvl(rtrim('".$In_LotAtt12."'),'*') and rownum=1");
-            $data = DB::connection('oracle')->select($query);
-            if (!$data) $r_nrow = 0;
-            else $r_Return_LotNum = $data[0]->lotnum;
-
-            //产生新的批号
-            if($r_nrow <= 0){
-                //SP: SPCOM_GetIDSequence(IN_Warehouse,IN_Language,'LOTNumber',r_Return_LotNum,OUT_Return_Code);
-                $r_Return_LotNum = '0';
-                $OUT_Return_Code = '000';
-
-                //TODO CREATE INV_LOT_ATT
-                DB::connection('oracle')->insert(DB::raw("INSERT INTO INV_LOT_ATT (CustomerID,SKU,LotNum,LotAtt01,LotAtt02,LotAtt03,LotAtt04,LotAtt05,LotAtt06,LotAtt07,LotAtt08,LotAtt09,LotAtt10,LotAtt11,LotAtt12,AddTime,AddWho,EditTime,EditWho,ReceivingTime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"),
-                    [$In_CustomerID,$In_SKU,$r_Return_LotNum,rtrim($In_LotAtt01),rtrim($In_LotAtt02),rtrim($In_LotAtt03),rtrim($In_LotAtt04),rtrim($In_LotAtt05),rtrim($In_LotAtt06)
-                        ,rtrim($In_LotAtt07),rtrim($In_LotAtt08),rtrim($In_LotAtt09),rtrim($In_LotAtt10),rtrim($In_LotAtt11),rtrim($In_LotAtt12)
-                        ,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString()]);
-            }
-            //预约库存的数量处理
-            $r_Lotnum_Trace = $r_Lotnum_Trace ?? '';
-            $r_PlanToLoc_Trace = $r_PlanToLoc_Trace ?? '';
-            $r_Return_LotNum = $r_Return_LotNum ?? '';
-
-            if ($R_Reserve_Flag == 'Y' && $R_LocationUsage == 'ST' && ($r_Lotnum_Trace ?? '') != $r_Return_LotNum){ //有预约,并且是收到ST库位,批次发生变化
-                //TODO UPDATE
-                DB::connection('oracle')->update(DB::raw('UPDATE INV_LOT_LOC_ID SET QTYPA = QTYPA - ? WHERE lotnum = ? and LocationID = ? and traceid = ?'),
-                    [(int)($r_CancelQty_Trace ?? 0),$r_Lotnum_Trace,$r_PlanToLoc_Trace,$In_FMTraceID]);
-                //TODO DELETE
-                DB::connection('oracle')->delete(DB::raw('DELETE FROM INV_LOT_LOC_ID where lotnum = ? and LocationID = ? and traceid = ? and QTYPA = 0 and qty = 0 and qtyMvin = 0'),
-                    [$r_Lotnum_Trace,$r_PlanToLoc_Trace,$In_FMTraceID]);
+                return $customDepository;
+            })();
 
-                DB::connection('oracle')->select(DB::raw('Select * from INV_LOT_LOC_ID Where LotNum=? and LocationID=? and TraceID=? for update'),[
-                    $r_Return_LotNum, $r_PlanToLoc_Trace, $In_FMTraceID
-                ]);
-                $TABLE_inv_lot_loc_id = DB::connection('oracle')->select(DB::raw(' select count(*) c from inv_lot_loc_id where lotnum = ? and LocationID = ? and traceid = ?'),[
-                    $r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID
-                ]);
-                if ($TABLE_inv_lot_loc_id[0]->c > 0){
-                    //TODO UPDATE
-                    DB::connection('oracle')->update(DB::raw('update inv_lot_loc_id set QTYPA = QTYPA + ? where lotnum = ? and LocationID = ? and traceid = ?'),[
-                        (int)$r_ReceivedQty_Each,$r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID
-                    ]);
-                }else{
-                    //TODO CREATE INV_LOT_LOC_ID
-                    DB::connection('oracle')->insert(DB::raw('Insert Into INV_LOT_LOC_ID (LotNum, LocationID, TraceID, CustomerID, SKU, Qty, QtyAllocated, QtyRPIn, QtyRPOut, QtyMVIN, QtyMVOut, QtyOnHold, OnHoldLocker,GrossWeight, NetWeight, Cubic, Price, AddTime, AddWho, EditTime, EditWho, LPN, QTYPA) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'),[
-                        $r_Return_LotNum,$r_PlanToLoc_Trace,$In_FMTraceID,$In_CustomerID,$In_SKU,0,0,0,0,0,
-                        0,0,0,0,0,0,0,$R_CurrentTime->toDateTimeString(),$In_UserID,$R_CurrentTime->toDateTimeString(),
-                        $In_UserID,null,$r_ReceivedQty_Each
-                    ]);
-                }
-            }
-            //混放批次校验
-            if ($R_Mix_LotFlag == 'N' && $R_LocationUsage != 'ST'){
-                $TABLE_inv_lot_LOC_ID = DB::connection('oracle')->selectOne(DB::raw('select count(distinct LotNUM) c from inv_lot_LOC_ID where LocationID=? and LotNum<>? and Qty>0 and CustomerID=? and SKU=?'),[
-                    $In_TOLocation,$r_Return_LotNum,$In_CustomerID,$In_SKU
-                ]);
-                if ($TABLE_inv_lot_LOC_ID->c >= 1){
-                    DB::rollBack();
-                    return '206'.rtrim($In_TOLocation);
-                }
-            }
-            //货架生命周期,失效日期,自动冻结
-            $r_Flag = '0';
-            if (trim($In_LotAtt02)){
-                if ((strtotime($In_LotAtt02) ? true : false)){
-                    $r_nrow = 1;
-                    $TABLE_BAS_SKU = DB::connection('oracle')->selectOne(DB::raw("SELECT c.OutboundLifeDays,c.InboundLifeDays from BAS_SKU c where c.CustomerID=? and c.SKU=? and c.ShelfLifeFlag='Y' and c.ShelfLifeType='E'"),[
-                        $In_CustomerID,$In_SKU
+            if ($WMSReflectReceive->skus){
+                foreach ($WMSReflectReceive->skus as $sku){
+                    $depository=(function()use($sku,$customDepository){
+                        if($customDepository)return $customDepository;
+                        $depository=Depository::query()->where('code',$sku->LOTATT05)->first();
+                        if (!$depository){
+                            if (!$sku->LOTATT05)return $depository;
+                            $depository=new Depository([
+                                'name'=>$sku->LOTATT05,
+                                'code'=>$sku->LOTATT05
+                            ]);
+                            $depository->save();
+                        }
+                        return $depository;
+                    })();
+                    $storeItem=new StoreItems([
+                        'store_id'=>$store->id,
+                        'asn_line_code'=>$sku->ASNLINENO,
+                        'name'=>$sku->SKUDESCRC,
+                        'sku'=>$sku->SKU,
+                        'barcode'=>$sku->ALTERNATE_SKU1,
+                        'quality'=>$quality,
+                        'status'=>'未入库',
                     ]);
-                    if (!$TABLE_BAS_SKU)$r_nrow=0;
-                    else {
-                        $r_OutboundLifeDays = $TABLE_BAS_SKU->outboundlifedays;
-                        $r_InboundLifeDays = $TABLE_BAS_SKU->inboundlifedays;
-                    }
-                }
-                if ($r_nrow > 0)$r_Flag = '1';
-                else $r_Flag = '0';
-                if ($r_nrow > 0 && (($r_OutboundLifeDays > 0 && (Carbon::parse($In_LotAtt02)->diffInDays($R_CurrentTime) <= $r_OutboundLifeDays)) ||
-                        ($r_InboundLifeDays > 0 && (Carbon::parse($In_LotAtt02)->diffInDays($R_CurrentTime) <= $r_InboundLifeDays)))){
-                    if ($r_EXP_CTL == 'Y')return '222'; //过期 拒收
-                    if ($r_EXP_CTL != 'N')$r_Hold_EP = 'Y';
-                }
-            }
-            //货架生命周期,生产日期,自动冻结
-            if ($In_LotAtt01 && !(strtotime($In_LotAtt01) ? true : false) && (!$r_Flag || $r_Flag = '0')){
-                $r_nrow = 1;
-                $TABLE_BAS_SKU = DB::connection('oracle')->selectOne(DB::raw('select c.OutboundLifeDays,c.InboundLifeDays from BAS_SKU c where c.CustomerID=? and c.SKU=? and c.ShelfLifeFlag=? and c.ShelfLifeType=?') ,[
-                    $In_CustomerID,$In_SKU,'Y','M'
-                ]);
-                if (!$TABLE_BAS_SKU)$r_nrow = 0;
-                else {
-                    $r_OutboundLifeDays = $TABLE_BAS_SKU->outboundlifedays;
-                    $r_InboundLifeDays = $TABLE_BAS_SKU->inboundlifedays;
-                }
-                if ($r_nrow > 0 && (($r_OutboundLifeDays > 0 && ($R_CurrentTime->diffInDays(Carbon::parse($In_LotAtt01)) > $r_OutboundLifeDays))  ||
-                        ($r_InboundLifeDays > 0 && ($R_CurrentTime->diffInDays(Carbon::parse($In_LotAtt01)) > $r_InboundLifeDays)))){
-                    if ($r_EXP_CTL == 'Y')return '222'; //有效期受控 拒收
-                    if ($r_EXP_CTL != 'N') $r_Hold_EP ='Y';
-                }
-            }
-            if (trim($In_ContainerID)){
-                DB::connection('oracle')->update(DB::raw('Update DOC_ASN_SerialNo Set LotNum=?,edittime=?,editwho=? Where LocationID=? and TraceID=? and LotNum=?'),[
-                    $r_Return_LotNum,$R_CurrentTime,$In_UserID,$In_TOLocation,$In_New_TraceID,$In_ContainerID
-                ]);
-            }
-        }
-        //计算上架库位 1543-1716 INSERT UPDATE
-
-        //QTYPA 写入INV_LOT_LOC_ID 1719-1752 INSERT UPDATE
-
-        //更新库存MVOut数量 1754-1810 SP:SPASN_Putaway_Calculation INSERT DELETE
-
-        //上架库位处理 QTYPA 写入INV_LOT_LOC_ID 1854-1918 UPDATE
-
-        // 1920-1989 UPDATE
-
-        //任务处理 1992-2105 INSERT
-            //--指定上架任务时此表为空 TMP_Putaway_task
-            //混托盘任务处理
-
-        //拆分上架任务后,需要分别写入收货交易,不然取消收货会导致QTYPA负数错误 库存交易处理 2107-2294   INSERT
-            //产生交易记录 INSERT
-            //更新冻结数 SP:SPINV_Hold_Update
-            //只有质检后才能上架
-            //根据收货交易产生质检明细
-            //获取数据精度
-
-        //2298-2378 UPDATE INSERT SP
-
-        //更新码盘明细 2403-2460 UPDATE
-            //码盘收货
-
-        //更新ASN明细和ASN Header 2462-2617 SP UPDATE
-            //判断拒收是否超量r_RejectedQty_Each_ASN
-            //拒收数量应该< 预期数量-已收数量-已拒数量-本次收货数量,否则报错“拒收数量超量错误”
-        if ($In_ASNNo != '*'){
-            $query = DB::raw('Select PackID,UOM,ExpectedQty,ExpectedQty_Each,RejectedQty,RejectedQty_Each,ReceivedQty,ReceivedQty_Each,POLineNO,PONO From DOC_ASN_Details Where ASNNO=? and ASNLineNO=? for update');
-            $TABLE_DOC_ASN_Details = DB::connection('oracle')->selectOne($query,[$In_ASNNo,$In_ASNLineNo]);
-            if (!$TABLE_DOC_ASN_Details) return '803'.$In_ASNNo;
-            $r_PackID_ASN = $TABLE_DOC_ASN_Details->packid;
-            $r_UOM_ASN = $TABLE_DOC_ASN_Details->uom;
-            $r_ExpectedQty_ASN = $TABLE_DOC_ASN_Details->expectedqty;
-            $r_ExpectedQty_Each_ASN = $TABLE_DOC_ASN_Details->expectedqty_each;
-            $r_RejectedQty_ASN = $TABLE_DOC_ASN_Details->rejectedqty;
-            $r_RejectedQty_Each_ASN = $TABLE_DOC_ASN_Details->rejectedqty_each;
-            $r_ReceivedQty_ASN = $TABLE_DOC_ASN_Details->receivedqty;
-            $r_ReceivedQty_Each_ASN = $TABLE_DOC_ASN_Details->receivedqty_each;
-            $r_POLineNO = $TABLE_DOC_ASN_Details->polineno;
-            $In_PONo = $TABLE_DOC_ASN_Details->pono;
-            //拒收超量
-            if ($R_OverReceiving != 'Y' && (int)$In_RejectedQty > ((int)$r_ExpectedQty_Each_ASN - (int)$r_RejectedQty_Each_ASN - (int)$r_ReceivedQty_Each_ASN - (int)$r_ReceivedQty_Each_ASN))return '220';
-            $r_ReceivedQty_Each_ASN = $r_ReceivedQty_Each + $r_ReceivedQty_Each_ASN;
-            switch ($r_UOM_ASN){
-                case "EA":
-                    $r_UOMQty_ASN = $r_QTY1_P;
-                    break;
-                case "IP":
-                    $r_UOMQty_ASN = $r_QTY2_P;
-                    break;
-                case "CS":
-                    $r_UOMQty_ASN = $r_QTY3_P;
-                    break;
-                case "PL":
-                    $r_UOMQty_ASN = $r_QTY4_P;
-                    break;
-                case "OT":
-                    $r_UOMQty_ASN = $r_QTY5_P;
-                    break;
-                default:
-                    $r_UOMQty_ASN = 0;
-                    break;
-            }
-            if ($r_UOMQty_ASN <= 0)return '103'.rtrim($r_PackID_ASN);
-            if ($r_ReceivedQty_Each_ASN >= $r_ExpectedQty_Each_ASN)$r_LineStatus = '40';
-            else $r_LineStatus = '30';
-            if ($r_ASN_RCV_UPD == 'Y'){
-                $query = DB::raw("Update DOC_ASN_Details Set LineStatus=? ,ReceivedQty= (ReceivedQty_Each+?)/ ?,ReceivedQty_Each=ReceivedQty_Each+?,ReceivedTime=? ,".
-                    "RejectedQty=(RejectedQty_Each + (?))/?,RejectedQty_Each=RejectedQty_Each + (?),Reserve_Flag='Y',HoldRejectCode=?,HoldRejectReason=?,EditTime=? , EditWho=?,".
-                    "LotAtt01=?,LotAtt02=?,LotAtt04=?,LotAtt05=?,LotAtt06=?,LotAtt07=?,LotAtt08=?,LotAtt09=?,LotAtt10=?,LotAtt11=?,LotAtt12=?,Operator= ? Where ASNNO=? and ASNLineNO=?");
-                DB::connection('oracle')->update($query,[$r_LineStatus,(int)$r_ReceivedQty_Each,(int)$r_UOMQty_ASN,(int)$r_ReceivedQty_Each,$R_ReceivingTime->toDateTimeString(),
-                    (int)$In_RejectedQty,(int)$r_UOMQty_ASN,(int)$In_RejectedQty,$In_HoldRejectCode,
-                    $In_HoldRejectReason,$R_CurrentTime->toDateTimeString(),$In_UserID,
-                    $In_LotAtt01,$In_LotAtt02,$In_LotAtt04,$In_LotAtt05,$In_LotAtt06,$In_LotAtt07,$In_LotAtt08,$In_LotAtt09,$In_LotAtt10,$In_LotAtt11,$In_LotAtt12,$In_Operator,$In_ASNNo,$In_ASNLineNo]);
-            }else{
-                $query = DB::raw('Update DOC_ASN_Details Set LineStatus=? ,ReceivedQty= (ReceivedQty_Each+?)/ ?,ReceivedQty_Each=ReceivedQty_Each+?'.
-                    ",ReceivedTime=?,RejectedQty=(RejectedQty_Each + (? ))/?,RejectedQty_Each=RejectedQty_Each + (?),Reserve_Flag='Y',HoldRejectCode=?".
-                    ",HoldRejectReason=?,EditTime=? , EditWho=?,Operator= ? Where ASNNO=? and ASNLineNO=?");
-                DB::connection('oracle')->update($query,[$r_LineStatus,(int)$r_ReceivedQty_Each,(int)$r_UOMQty_ASN,(int)$r_ReceivedQty_Each,
-                    $R_ReceivingTime->toDateTimeString(),(int)$In_RejectedQty,(int)$r_UOMQty_ASN,(int)$In_RejectedQty,$In_HoldRejectCode,
-                    $In_HoldRejectReason,$R_CurrentTime->toDateTimeString(),$In_UserID,$In_Operator,$In_ASNNo,$In_ASNLineNo]);
-            }
-            if ($r_LineStatus == '40'){
-                $count = DB::connection('oracle')->selectOne(DB::raw("Select Count(1) c from DOC_ASN_Details Where ASNNO=? and ASNLineNO<>? and LineStatus < '40'"),[$In_ASNNo,$In_ASNLineNo]);
-                $r_nrow = $count->c;
-                if ($r_nrow > 0) $r_LineStatus = '30';
-            }
-            $query = DB::raw("Update DOC_ASN_Header Set ASNStatus=?,Reserve_Flag='Y',LastReceivingTime=?,EditTime=? , EditWho=? Where ASNNO=?");
-            DB::connection('oracle')->update($query,[$r_LineStatus,$R_ReceivingTime->toDateTimeString(),$R_CurrentTime->toDateTimeString(),$In_UserID, $In_ASNNo]);
-
-            if ($r_RCV_CTL == 'Y' && $r_LineStatus == '40'){
-                $r_nrow = 0;
-                if ($r_PTA_CLS_CHK == 'Y'){
-                    $count = DB::connection('oracle')->selectOne(DB::raw("select count(1) c from TSK_Tasklists Where DocNo=? and TaskProcess='00' And DocType='ASN'"),[$In_ASNNo]);
-                    $r_nrow = $count->c;
-                }
-                if ($r_nrow == 0){
-                    $r_LineStatus = '99';
-                    //断点回滚,关闭ASN如果失败回滚该次操作而不是将上方全部操作回滚
-                    DB::transaction(function (){
-                        //2595-2614 关闭ASN 调用SP SPASN_Close_Process 该SP抛错时不影响全局回滚
-                    });
+                    if ($depository)$storeItem->depository_id=$depository->id;
+                    $storeItem->save();
                 }
             }
         }
-
-        //更新PO信息 2620-2697 UPDATE
-
-        //删除TMP_Putaway_Task(上架任务临时表) 2808 DELETE
-        //DB::connection('oracle')->delete(DB::raw('delete from TMP_Putaway_Task where TMPID=?'),[$r_TMPID]);
-
-        //修改UDF_A的调用方式 SP 2812-2828
-
-        //清除0库存 2831-2834 SP
-
-        //结束返回与异常判断
-        return $OUT_Return_Code;
-    }
-
-    /** 对于快速入库 $IN_Parameter1 = 'RCV_AFTER' |  'RCV_BEFORE'
-     * 目前该SP只存在 RCV_AFTER(校验近期产品) 且已被注释
-     */
-    private function SPUDF_ProcessA($IN_Warehouse, $IN_Parameter1, $IN_Parameter2, $IN_Parameter3, $IN_Parameter4, $IN_Language, $IN_UserID, $OUT_Return_Code){
-        $r_CurrentTime = Carbon::now();
-
-        //TODO 状态为 分配之前 走此逻辑,本快速入库不存在分配之前 不会走此逻辑 保留一下
-        if ($IN_Parameter1='ALLOCATION_BEFORE'){
-            $doc_order_header = DB::connection('oracle')->select(DB::raw("SELECT t.Carrierid,t.soreference5 FROM DOC_ORDER_HEADER t WHERE  ORDERNO='".$IN_Parameter2."'"));
-            $r_Carrierid = $doc_order_header[0]->carrierid;
-            $r_soreference5 = $doc_order_header[0]->soreference5;
-            if (in_array($r_Carrierid,['ZTO','YUNDA','POSTB','YTO','STO','EMS','SF']) && !$r_soreference5){
-                $OUT_Return_Code = '999面单号未获取!';
-                DB::rollBack();
-                return $OUT_Return_Code;
+        /** @var Store $store */
+        $store=Store::with('storeItems')->where('asn_code',$asn)->first();
+        $storeApi=new FStoreController();
+        $result=$storeApi->accomplishToWMS($store,[
+            'quality'=>$quality,
+            'depository_code'=>$depository_code,
+            'follow_code'=>$store['id'],
+        ]);
+        if ($result){
+            $store->status='已入库';
+            $store->save();
+            if ($store->storeItems){
+                $store->storeItems->each(function ($storeItem)use($quality){
+                    $storeItem->status='已入库';
+                    $storeItem->quality=$quality;
+                    $storeItem->save();
+                });
             }
+            return ['success'=>true, 'data'=>"成功!"];
         }
-        //TODO 状态为 导入后的逻辑:SPUDF_ProcessA 77行起 此处忽略 IN_Parameter1='SO_IMPORT_AFTER'
-
-        //TODO 装箱完成前,做一些数据处理:SPUDF_ProcessA 125行起 此处忽略 IN_Parameter1='PACKING_BEFORE'
-
-        //TODO 装箱完成后,做一些数据处理:SPUDF_ProcessA 132行起 此处忽略 IN_Parameter1='PACKING_AFTER'
-
-        //TODO 打印标记:SPUDF_ProcessA 281行起 此处忽略 IN_Parameter1='PRINT'
-
-        //TODO 发货前校验是否全部复核:SPUDF_ProcessA 553行起 此处忽略 IN_Parameter1='SHIP_BEFORE'
-
-        //TODO 转移时校验库位是否允许混放批次:SPUDF_ProcessA 594行起 此处忽略 IN_Parameter1='TRAPPROVE_BEFORE'
-
-        //TODO 分配之后,如果是单品单件订单,更新deliveryno:SPUDF_ProcessA 658行起 此处忽略 IN_Parameter1='ALLOCATION_AFTER'
-
-        //TODO 上架前,校验此货主是否必须有拣货位,如果无拣货位,则拦截   by mxl 20191205:SPUDF_ProcessA 675行起 此处忽略 IN_Parameter1='PA_BEFORE'
-
-        //TODO ASN关闭后  针对JIANSHANG货主,订单关闭后将数据写入临时表CUS_ADJ_H  by mxl 20191217:SPUDF_ProcessA 700行起 此处忽略 IN_Parameter1='ASNCLOSE_AFTER'
-
-        //TODO SO关闭后 针对JIANSHANG货主,订单关闭后将数据写入临时表CUS_ADJ_H  by mxl 20191217:SPUDF_ProcessA 734行起 此处忽略 IN_Parameter1='SHIP_AFTER'
-
-        $OUT_Return_Code = '000';
-        return $OUT_Return_Code;
+        return ['success'=>false, 'data'=>"失败!请检查错误日志"];
     }
 
-    private function GETSYS_configuration($IN_WarehouseID, $IN_CustomerID, $IN_OrderType, $IN_ConfigID, $IN_DefaultValue = 'N', $IN_ValueType = 'C')
+    public function quickStorage($asnno,$quality,$depository_code)
     {
-        if ($IN_ValueType == 'C'){
-            $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='".($IN_OrderType ?? '*')."' AND CONFIG_ID='".$IN_ConfigID."'"));
-            if (!$sys_configuration){
-                $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
-                if (!$sys_configuration){
-                    $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
-                    if (!$sys_configuration){
-                        $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_STRING FROM sys_configuration WHERE WarehouseID='*' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
-                        if (!$sys_configuration) return $IN_DefaultValue;
-                    }
-                }
+        $db = DB::connection('oracle');
+        $query = DB::raw("SELECT * FROM DOC_ASN_HEADER WHERE ASNNO = ?");
+        $asn = $db->selectOne($query,[$asnno]);
+        if (!$asn) return ['success'=>false, 'data'=>"单据号不存在"];
+        if ($asn->asnstatus != '00')return ['success'=>false, 'data'=>'单据号状态非创建订单'];
+        if (array_search($asn->customerid,array_values(config('stores.owners'))) === false)return ['success'=>false, 'data'=>"不允许该货主快速入库"];
+        if (array_search($asn->asntype,array_values(config('stores.types'))) === false)return ['success'=>false, 'data'=>"该单据类型不允许被入库"];
+        $query = DB::raw("SELECT b.ALTERNATE_SKU1,h.WAREHOUSEID,h.asnno,d.ASNLINENO,d.SKUDESCRC,h.CUSTOMERID,d.SKU,d.PACKID,d.RECEIVEDQTY_EACH,d.EXPECTEDQTY_EACH,d.LOTATT01,d.LOTATT02,d.lotatt04,".
+            "d.lotatt05,d.lotatt08,d.USERDEFINE1,d.USERDEFINE2,d.USERDEFINE3,d.USERDEFINE4,d.USERDEFINE5,d.RECEIVINGLOCATION FROM DOC_ASN_DETAILS d ".
+            " LEFT JOIN BAS_SKU b ON d.CUSTOMERID = b.CUSTOMERID AND d.SKU = b.SKU INNER JOIN DOC_ASN_HEADER h ON d.ASNNO = h.ASNNO WHERE h.ASNNO = ?");
+        $details = $db->select($query,[$asnno]);
+
+        $username = config('database.connections.oracle.username');
+        $password = config('database.connections.oracle.password');
+        $host = config('database.connections.oracle.host');
+        $service_name = config('database.connections.oracle.service_name');
+        $conn = oci_connect($username, $password, $host . '/' . $service_name,"utf8");
+        $sql_sp = "begin SPASN_Receiving_Process(:IN_Warehouse, :In_Process_Action, :In_ASNNo_C, :In_ASNLineNo_C, :In_FMTraceID_C, :In_New_TraceID_C, :In_ProductStatus," .
+            ":In_ProductStatus_Descr, :In_HoldRejectCode_C, :In_HoldRejectReason_C, :In_PONo_C, :In_CustomerID, :In_SKU, :In_ReceivedQty, :In_RejectedQty,:In_UOM, :In_PackID," .
+            " :In_ContainerID, :In_LotAtt01_C, :In_LotAtt02_C, :In_LotAtt03_C, :In_LotAtt04_C, :In_LotAtt05_C, :In_LotAtt06_C," .
+            ":In_LotAtt07_C, :In_LotAtt08_C, :In_LotAtt09_C, :In_LotAtt10_C, :In_LotAtt11_C, :In_LotAtt12_C," .
+            ":In_TotalCubic, :In_TotalGrossWeight, :In_TotalNetWeight, :In_TotalPrice, :In_UserDefine1, :In_UserDefine2,:In_UserDefine3, :In_UserDefine4, :In_UserDefine5, :In_FMLocation," .
+            ":In_TOLocation_C,:In_QC_Type_C, :In_PlanToLoc_C,:In_ReceivingTime, :In_LPN, :In_Operator, :IN_RCVModule, :IN_RCVStation, :In_Language, :In_UserID, :OUT_Return_Code); end;";
+        $items = [];
+        $toDay = Carbon::now()->toDateTimeString();
+        $depositories = [];
+        foreach ($details as $detail) {
+            $result = $this->executeSP($detail,$asnno,$depository_code,$db,$quality,$conn,$sql_sp);
+            if (substr($result, 0, 3) != '000') {
+                oci_close($conn);
+                LogService::log(__METHOD__,"快速入库-FLUX收货失败","ASNNO:".$asnno.";ERROR:".$result);
+                return ['success' => false, 'data' => $detail->asnlineno.'收货失败,错误代码:'.$result];
             }
-            return trim($sys_configuration[0]->value_string);
-        }
-        $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='".($IN_OrderType ?? '*')."' AND CONFIG_ID='".$IN_ConfigID."'"));
-        if (!$sys_configuration){
-            $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='".($IN_CustomerID ?? '*')."' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
-            if (!$sys_configuration){
-                $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='".($IN_WarehouseID ?? '*')."' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
-                if (!$sys_configuration){
-                    $sys_configuration = DB::connection('oracle')->select(DB::raw("SELECT VALUE_INT FROM sys_configuration WHERE WarehouseID='*' AND CustomerID='*' AND OrderType='*' AND CONFIG_ID='".$IN_ConfigID."'"));
-                    if (!$sys_configuration) return $IN_DefaultValue;
-                }
+            if (!isset($depositories[$detail->lotatt05])){
+                $depository = app('depositoryService')->firstOrCreate(["code"=>$detail->lotatt05],["code"=>$detail->lotatt05,"name"=>$detail->lotatt05]);
+                $depositories[$detail->lotatt05] = $depository->id;
             }
+            $items[] = [
+                "asn_line_code" => $detail->asnlineno,
+                "name" => $detail->skudescrc,
+                "sku" => $detail->sku,
+                "barcode" => $detail->alternate_sku1,
+                "depository_id" => $depositories[$detail->lotatt05],
+                "amount" => $detail->expectedqty_each,
+                "quality" => $quality == 'ZP' ? '正品' : '残次',
+                "status" => "已入库",
+                "created_at" => $toDay
+            ];
+        }
+        oci_close($conn);
+        $warehouse = app('warehouseService')->firstOrCreate(["code"=>$asn->warehouseid],["code"=>$asn->warehouseid,"name"=>$asn->warehouseid]);
+        $owner = app('ownerService')->firstOrCreate(['code'=>$asn->customerid],['code'=>$asn->customerid,"name"=>$asn->customerid]);
+        $store = app('storeService')->create([
+            'asn_code'=>$asnno,
+            'warehouse_id'=>$warehouse->id,
+            'owner_id'=>$owner->id,
+            'stored_method'=>'快速入库',
+            'status'=>'已入库',
+            'remark'=>$asn->notes,
+        ]);
+        LogService::log(__METHOD__,"快速入库",json_encode($store));
+        foreach ($items as $item){
+            $item["store_id"] = $store->id;
         }
-        return trim($sys_configuration[0]->value_string);
+        app('storeItemService')->insert($items);
+        return ['success'=>true,"data"=>"已成功将“".$asnno."”入库"];
     }
 
-    /** 码盘调用SP,大概率不会被使用,内部 为游标,UPDATE操作 */
-    private function spasn_reserve_cancel($in_warehouse, $in_by, $in_asnno, $in_asnlineno, $in_traceid, $in_language, $in_userid, $out_return_code){
-        $query = DB::raw('Select TraceID,ASNLineNO,CustomerID,SKU,PackID,UOM,LotNUM,PlanToLoc,ExpectedQty,ExpectedQty_Each,TotalGrossWeight,TotalCubic from DOC_Trace_DETAILS '.
-            "Where (ASNNO='".$in_asnno."' and ReceivedQty_Each=0 and trim(PlanToLoc) is not null and trim(PlanToLoc)<>'*' and Reserve_Flag='Y' and '".$in_by."'='ASNNO') OR".
-            " (ASNNO='".$in_asnno."' and ASNLineNO='".$in_asnlineno."' and ReceivedQty_Each=0 and trim(PlanToLoc) is not null and trim(PlanToLoc)<>'*' and Reserve_Flag='Y' and upper('".$in_by."')=upper('ASNLineNO')) OR".
-            " (ASNNO='".$in_asnno."' and TraceID='".$in_traceid."' and ASNLineNO='".$in_asnlineno."' and ReceivedQty_Each=0 and trim(PlanToLoc) is not null and trim(PlanToLoc)<>'*' and Reserve_Flag='Y' and upper('".$in_by."')=upper('TraceID'))");
-
-        if ($out_return_code == 'NO_COMMIT')$r_no_commit = 'N';
-        else $r_no_commit = 'Y';
-        $sp_sql_r = "''".$in_by."'',''".$in_asnno."'',''".$in_asnlineno."'',''".$in_traceid."'',''".$in_language."'',''".$in_userid."''";
-        $R_CurrentTime = Carbon::now();
-
-        if ($in_by != 'ASNNO' && strtoupper($in_by) != 'ASNLINENO' && strtoupper($in_by) != 'TRACEID')return '887SPASN_Reserve_Cancel';
-
-        $ccur_asns = DB::connection('oracle')->select($query);
-        foreach ($ccur_asns as $crow_asn){
-            $sp_sql_r = 'Fetch cCur_ASN';
-            $TABLE_DOC_Trace_Details = DB::connection('oracle')->select(DB::raw("SELECT 1 c from DOC_Trace_Details Where ASNNO='".$in_asnno."' and  TraceID='".$crow_asn->traceid."'"));
-            if ($TABLE_DOC_Trace_Details && $TABLE_DOC_Trace_Details[0]->c == 1){
-                // TODO UPDATE
-                $rowcount = DB::connection('oracle')->update(DB::raw("UPDATE INV_LOT_LOC_ID SET QTYPA=(QTYPA-".$crow_asn->expectedqty_each."),EditTime=TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss'),EditWho='".$in_userid.
-                    "' WHERE LotNum='".$crow_asn->lotnum."' and LocationID='".$crow_asn->plantoloc."' and TraceID='".$crow_asn->traceid."'"));
-                if ($rowcount == 0) return 'INV_LOT_LOC_ID,UPDATE';
-                // TODO UPDATE
-                DB::connection('oracle')->update(DB::raw("UPDATE DOC_Trace_Details set PlanToLoc='' ,Reserve_Flag='N',EditTime= TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss'), EditWho='".$in_userid.
-                    "' where ASNNO='".$in_asnno."' and ASNLineNO='".$crow_asn->asnlineno."' and TraceID='".$crow_asn->traceid."'"));
-                $TABLE_DOC_Trace_Details = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM DOC_Trace_Details WHERE ASNNO='".$in_asnno."' and ASNLineNO='".$crow_asn->asnlineno."' and trim(PlanToLoc) is not null and  trim(PlanToLoc)<>'*'"));
-                if (!$TABLE_DOC_Trace_Details){
-                    //TODO UPDATE
-                    DB::connection('oracle')->update(DB::raw("Update DOC_ASN_Details set Reserve_Flag='N'  ,EditTime=TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss') , EditWho='".$in_userid."' where ASNNO='".$in_asnno."' and ASNLineNO='".$crow_asn->asnlineno."'"));
-                }
-            }
-            //TODO COMMIT
-            if ($r_no_commit == 'Y')DB::commit();
+    private function executeSP($detail, $asnno, $depository_code, $db, $quality, $conn, $sql_sp){
+        $IN_Warehouse = $detail->warehouseid ?? '';
+        $In_Process_Action = '3';
+        $In_ASNNo_C = $detail->asnno ?? '';
+        $In_ASNLineNo_C = $detail->asnlineno ?? '';
+        $In_FMTraceID_C = '';
+        $In_New_TraceID_C = '';
+        $In_ProductStatus = '00';
+        $In_ProductStatus_Descr = '正常';
+        $In_HoldRejectCode_C = 'OK';
+        $In_HoldRejectReason_C = '正常';
+        $In_PONo_C = '';
+        $In_CustomerID = $detail->customerid ?? '';
+        $In_SKU = $detail->sku ?? '';
+        $In_ReceivedQty = (string)((int)$detail->expectedqty_each - (int)$detail->receivedqty_each) ?? '';
+        $In_RejectedQty = '';
+        $In_UOM = 'EA';
+        $In_PackID = $detail->packid ?? '';
+        $In_ContainerID = '';
+        $In_LotAtt01_C = $detail->lotatt01 ?? '';
+        $In_LotAtt02_C = $detail->lotatt02 ?? '';
+        $In_LotAtt03_C = '';
+        $In_LotAtt04_C = $detail->lotatt04 ?? '';
+        $In_LotAtt05_C = $detail->lotatt05 ?? '';
+        $In_LotAtt06_C = '';
+        $In_LotAtt07_C = '';
+        $In_LotAtt08_C = $detail->lotatt08 ?? '';
+        $In_LotAtt09_C = '';
+        $In_LotAtt10_C = '';
+        $In_LotAtt11_C = '';
+        $In_LotAtt12_C = '';
+        $In_TotalCubic = '0.00';
+        $In_TotalGrossWeight = '0.00';
+        $In_TotalNetWeight = '0.00';
+        $In_TotalPrice = '0.00';
+        $In_UserDefine1 = $detail->userdefine1 ?? '';
+        $In_UserDefine2 = $detail->userdefine2 ?? '';
+        $In_UserDefine3 = $detail->userdefine3 ?? '';
+        $In_UserDefine4 = $detail->userdefine4 ?? '';
+        $In_UserDefine5 = $detail->userdefine5 ?? '';
+        $In_FMLocation = 'STAGE' . $detail->warehouseid;
+        $In_TOLocation_C = 'STAGE' . $detail->warehouseid;
+        $In_QC_Type_C = 'OK';
+        $In_PlanToLoc_C = '';
+        $In_ReceivingTime = '';
+        $In_LPN = '*';
+        $In_Operator = 'WCS';
+        $IN_RCVModule = '';
+        $IN_RCVStation = '';
+        $In_Language = 'cn';
+        $In_UserID = 'WCS';
+        $result = '';
+        if ($depository_code && (strtoupper($depository_code) != strtoupper($detail->receivinglocation))){
+            $query = DB::raw("UPDATE DOC_ASN_DETAILS SET RECEIVINGLOCATION = ?  WHERE ASNNO = ? AND ASNLINENO = ?");
+            $db->update($query,[$depository_code,$detail->asnno,$detail->asnlineno]);
+            $db->commit();
+            LogService::log(__METHOD__,"快速入库-修改FULX属性仓","ASNNO:".$asnno.";原仓:".$detail->receivinglocation.";修改为:".$depository_code);
         }
-
-        $TABLE_DOC_ASN_Details = DB::connection('oracle')->select(DB::raw("SELECT 1 FROM DOC_ASN_Details Where ASNNO='".$in_asnno."' and  Reserve_Flag='Y'"));
-        if (!$TABLE_DOC_ASN_Details){
-            $sp_sql_r = 'Update DOC_ASN_Header';
-            //TODO UPDATE
-            DB::connection('oracle')->update(DB::raw("Update DOC_ASN_Header set Reserve_Flag='N' ,EditTime=TO_DATE('".$R_CurrentTime->toDateTimeString()."','yyyy-mm-dd hh24:mi:ss') , EditWho='".$in_userid."' where ASNNO='".$in_asnno."'"));
+        if ($quality && ($quality != $detail->lotatt08)){
+            $query = DB::raw("UPDATE DOC_ASN_DETAILS SET LOTATT08 = ?  WHERE ASNNO = ? AND ASNLINENO = ?");
+            $db->update($query,[$quality,$detail->asnno,$detail->asnlineno]);
+            $db->commit();
+            LogService::log(__METHOD__,"快速入库-修改FULX质量状态","ASNNO:".$asnno.";原质量:".$detail->lotatt08.";修改为:".$quality);
+            $In_LotAtt08_C = $quality;
         }
-        //TODO COMMIT
-        if ($r_no_commit == 'Y')DB::commit();
-
-        return '000';
+        $stmt = oci_parse($conn, $sql_sp);
+        oci_bind_by_name($stmt, ':IN_Warehouse', $IN_Warehouse);
+        oci_bind_by_name($stmt, ':In_Process_Action', $In_Process_Action);
+        oci_bind_by_name($stmt, ':In_ASNNo_C', $In_ASNNo_C);
+        oci_bind_by_name($stmt, ':In_ASNLineNo_C', $In_ASNLineNo_C);
+        oci_bind_by_name($stmt, ':In_FMTraceID_C', $In_FMTraceID_C);
+        oci_bind_by_name($stmt, ':In_New_TraceID_C', $In_New_TraceID_C);
+        oci_bind_by_name($stmt, ':In_ProductStatus', $In_ProductStatus);
+        oci_bind_by_name($stmt, ':In_ProductStatus_Descr', $In_ProductStatus_Descr);
+        oci_bind_by_name($stmt, ':In_HoldRejectCode_C', $In_HoldRejectCode_C);
+        oci_bind_by_name($stmt, ':In_HoldRejectReason_C', $In_HoldRejectReason_C);
+        oci_bind_by_name($stmt, ':In_PONo_C', $In_PONo_C);
+        oci_bind_by_name($stmt, ':In_CustomerID', $In_CustomerID);
+        oci_bind_by_name($stmt, ':In_SKU', $In_SKU);
+        oci_bind_by_name($stmt, ':In_ReceivedQty', $In_ReceivedQty);
+        oci_bind_by_name($stmt, ':In_RejectedQty', $In_RejectedQty);
+        oci_bind_by_name($stmt, ':In_UOM', $In_UOM);
+        oci_bind_by_name($stmt, ':In_PackID', $In_PackID);
+        oci_bind_by_name($stmt, ':In_ContainerID', $In_ContainerID);
+        oci_bind_by_name($stmt, ':In_LotAtt01_C', $In_LotAtt01_C);
+        oci_bind_by_name($stmt, ':In_LotAtt02_C', $In_LotAtt02_C);
+        oci_bind_by_name($stmt, ':In_LotAtt03_C', $In_LotAtt03_C);
+        oci_bind_by_name($stmt, ':In_LotAtt04_C', $In_LotAtt04_C);
+        oci_bind_by_name($stmt, ':In_LotAtt05_C', $In_LotAtt05_C);
+        oci_bind_by_name($stmt, ':In_LotAtt06_C', $In_LotAtt06_C);
+        oci_bind_by_name($stmt, ':In_LotAtt07_C', $In_LotAtt07_C);
+        oci_bind_by_name($stmt, ':In_LotAtt08_C', $In_LotAtt08_C);
+        oci_bind_by_name($stmt, ':In_LotAtt09_C', $In_LotAtt09_C);
+        oci_bind_by_name($stmt, ':In_LotAtt10_C', $In_LotAtt10_C);
+        oci_bind_by_name($stmt, ':In_LotAtt11_C', $In_LotAtt11_C);
+        oci_bind_by_name($stmt, ':In_LotAtt12_C', $In_LotAtt12_C);
+        oci_bind_by_name($stmt, ':In_TotalCubic', $In_TotalCubic);
+        oci_bind_by_name($stmt, ':In_TotalGrossWeight', $In_TotalGrossWeight);
+        oci_bind_by_name($stmt, ':In_TotalNetWeight', $In_TotalNetWeight);
+        oci_bind_by_name($stmt, ':In_TotalPrice', $In_TotalPrice);
+        oci_bind_by_name($stmt, ':In_UserDefine1', $In_UserDefine1);
+        oci_bind_by_name($stmt, ':In_UserDefine2', $In_UserDefine2);
+        oci_bind_by_name($stmt, ':In_UserDefine3', $In_UserDefine3);
+        oci_bind_by_name($stmt, ':In_UserDefine4', $In_UserDefine4);
+        oci_bind_by_name($stmt, ':In_UserDefine5', $In_UserDefine5);
+        oci_bind_by_name($stmt, ':In_FMLocation', $In_FMLocation);
+        oci_bind_by_name($stmt, ':In_TOLocation_C', $In_TOLocation_C);
+        oci_bind_by_name($stmt, ':In_QC_Type_C', $In_QC_Type_C);
+        oci_bind_by_name($stmt, ':In_PlanToLoc_C', $In_PlanToLoc_C);
+        oci_bind_by_name($stmt, ':In_ReceivingTime', $In_ReceivingTime);
+        oci_bind_by_name($stmt, ':In_LPN', $In_LPN);
+        oci_bind_by_name($stmt, ':In_Operator', $In_Operator);
+        oci_bind_by_name($stmt, ':IN_RCVModule', $IN_RCVModule);
+        oci_bind_by_name($stmt, ':IN_RCVStation', $IN_RCVStation);
+        oci_bind_by_name($stmt, ':In_Language', $In_Language);
+        oci_bind_by_name($stmt, ':In_UserID', $In_UserID);
+        oci_bind_by_name($stmt, ':OUT_Return_Code', $result,300);
+        oci_execute($stmt);
+        return $result;
     }
 
-    //获取数据表的ID(PO, ASN, SO...) $in_sequence_name_c = TraceID  LOTNumber  TEMPID    Traceid  TransactionID  TaskID QCNO  TransactionID
-    private function spcom_getidsequence($in_warehouse, $in_language, $in_sequence_name_c, $out_returnno, $out_return_code){
-        $out_return_code = '000';
-        $out_returnno = '0';
-        $in_sequence_name = $in_sequence_name_c;
-        $r_id_sequence = -1;
-        $r_length = 0;
-        //TODO $IN_Parameter1 = 'IDSEQUENCE' 单多包裹逻辑校验 应该调用SPUDF_ProcessA 但其中单多部分逻辑已被注释 恒定返回000 此处同理恒定返回000 不会下行执行其他逻辑
-        return;
-        //DB::connection('oracle')->select(DB::raw("Select ID_Sequence,Max_ID_Sequence,Length,PreFix,to_CHar(EditTime,'YYMMDD') ,Date_Format  ,Date_max From SYS_IDSequence where IDName=upper('".$IN_Sequence_Name."') and WareHouseID = upper('".$in_warehouse."') For Update;"));
-        //return [$out_returnno,$out_return_code];
+
+    public function validator(Request $request){
+        $validator=Validator::make($request->input(),[
+            'asn_code'=>['required'],
+            'quality'=>['required'],
+            'depository_code'=>['nullable','string'],
+        ],[
+            'required'=>':attribute 为必填项',
+            'unique'=>':attribute 已存在',
+        ],[
+            'asn_code'=>'ASN编号',
+            'quality'=>'货物类型'
+        ])->validate();
+        return $validator;
     }
 }