Esempio n. 1
0
 public function getDetailData($id, $postData, $properties)
 {
     $pdShipPortInformation = PdShipPortInformation::getTableName();
     $pdTransportShipDetail = PdTransportShipDetail::getTableName();
     $dataSet = PdShipPortInformation::join($pdTransportShipDetail, function ($query) use($id, $pdShipPortInformation, $pdTransportShipDetail) {
         $query->on("{$pdShipPortInformation}.VOYAGE_ID", '=', "{$pdTransportShipDetail}.VOYAGE_ID");
         $query->on("{$pdShipPortInformation}.PARCEL_NO", '=', "{$pdTransportShipDetail}.PARCEL_NO");
         $query->where("{$pdTransportShipDetail}.ID", '=', $id);
     })->select("{$pdShipPortInformation}.*", "{$pdShipPortInformation}.ID as DT_RowId", "{$pdShipPortInformation}.ID as {$pdShipPortInformation}")->get();
     return $dataSet;
 }
Esempio n. 2
0
 public function gentransport(Request $request)
 {
     $postData = $request->all();
     $voyage_id = $postData['VOYAGE_ID'];
     $pdVoyageDetail = PdVoyageDetail::getTableName();
     $pdVoyage = PdVoyage::getTableName();
     $pdTransitCarrier = PdTransitCarrier::getTableName();
     $dataSet = PdVoyageDetail::join($pdVoyage, "{$pdVoyageDetail}.VOYAGE_ID", '=', "{$pdVoyage}.ID")->join($pdTransitCarrier, "{$pdVoyage}.CARRIER_ID", '=', "{$pdTransitCarrier}.ID")->where("{$pdVoyage}.ID", '=', $voyage_id)->orderBy("{$pdVoyageDetail}.ID")->select("{$pdVoyage}.CODE as VOYAGE_CODE", "{$pdVoyage}.NAME as VOYAGE_NAME", "{$pdVoyage}.QUANTITY_TYPE as VOYAGE_QTY_TYPE", "{$pdTransitCarrier}.TRANSIT_TYPE", "{$pdVoyageDetail}.*")->get();
     try {
         $resultTransaction = \DB::transaction(function () use($dataSet, $voyage_id) {
             $attributes = ['VOYAGE_ID' => $voyage_id];
             foreach ($dataSet as $ro) {
                 $attributes['PARCEL_NO'] = $ro->PARCEL_NO;
                 switch ($ro->TRANSIT_TYPE) {
                     case 3:
                         $pdTransportShipDetail = PdTransportShipDetail::where($attributes)->first();
                         if (!$pdTransportShipDetail) {
                             $values = ['VOYAGE_ID' => $voyage_id];
                             $values['CODE'] = "SH_{$ro->VOYAGE_CODE}" . "_{$ro->PARCEL_NO}";
                             $values['NAME'] = "SH_{$ro->VOYAGE_NAME}" . "_{$ro->PARCEL_NO}";
                             $values['CARGO_ID'] = $ro->CARGO_ID;
                             $values['PARCEL_NO'] = $ro->PARCEL_NO;
                             $values['RECEIPT_QTY'] = $ro->LOAD_QTY;
                             $values['QTY_TYPE'] = $ro->VOYAGE_QTY_TYPE;
                             $values['QTY_UOM'] = $ro->LOAD_UOM;
                             $pdTransportShipDetail = PdTransportShipDetail::insert($values);
                             $pdShipPortInformation = PdShipPortInformation::insert($attributes);
                         }
                         break;
                     case 4:
                         $pdTransportPipelineDetail = PdTransportPipelineDetail::where($attributes)->first();
                         if (!$pdTransportPipelineDetail) {
                             $values = ['VOYAGE_ID' => $voyage_id];
                             $values['CODE'] = "PP_{$ro->VOYAGE_CODE}" . "_{$ro->PARCEL_NO}";
                             $values['NAME'] = "PP_{$ro->VOYAGE_NAME}" . "_{$ro->PARCEL_NO}";
                             $values['CARGO_ID'] = $ro->CARGO_ID;
                             $values['PARCEL_NO'] = $ro->PARCEL_NO;
                             $values['QUANTITY'] = $ro->LOAD_QTY;
                             $values['QUANTITY_UOM'] = $ro->LOAD_UOM;
                             $pdTransportPipelineDetail = PdTransportPipelineDetail::insert($values);
                         }
                         break;
                     default:
                         $pdTransportGroundDetail = PdTransportGroundDetail::where($attributes)->first();
                         if (!$pdTransportGroundDetail) {
                             $values = ['VOYAGE_ID' => $voyage_id];
                             $values['CODE'] = "GR_{$ro->VOYAGE_CODE}" . "_{$ro->PARCEL_NO}";
                             $values['NAME'] = "GR_{$ro->VOYAGE_NAME}" . "_{$ro->PARCEL_NO}";
                             $values['CARGO_ID'] = $ro->CARGO_ID;
                             $values['PARCEL_NO'] = $ro->PARCEL_NO;
                             $values['QUANTITY'] = $ro->LOAD_QTY;
                             $values['QUANTITY_UOM'] = $ro->LOAD_UOM;
                             $pdTransportGroundDetail = PdTransportGroundDetail::insert($values);
                         }
                         break;
                 }
             }
         });
     } catch (\Exception $e) {
         return response()->json('error when insert data');
     }
     return response()->json('success');
 }