コード例 #1
0
ファイル: VoyageController.php プロジェクト: hunglmtb/eb
 public function genBLMR(Request $request)
 {
     $postData = $request->all();
     $pid = $postData['id'];
     $shipCargoBlmr = $this->getShipCargoBlmr($pid);
     $xid = $shipCargoBlmr ? $shipCargoBlmr->ID : 0;
     $results = \DB::transaction(function () use($xid, $pid) {
         $mdl = $this->modelName;
         $transportType = $mdl::getTableName();
         $shipCargoBlmr = ShipCargoBlmr::getTableName();
         if ($xid > 0) {
             // 			    			\DB::enableQueryLog();
             $values = $this->getUpdateFields($shipCargoBlmr, $transportType);
             ShipCargoBlmr::join($transportType, "{$transportType}.ID", '=', "{$shipCargoBlmr}.PARENT_ID")->where("{$shipCargoBlmr}.ID", $xid)->update($values);
             // 			   \Log::info(\DB::getQueryLog());
             return 'Success(only update exist rows)';
         } else {
             $pdVoyage = PdVoyage::getTableName();
             $storage = Storage::getTableName();
             $values = $this->getInsertFields($pid, $pdVoyage, $storage, $transportType);
             $mdl::join($pdVoyage, "{$pdVoyage}.ID", '=', "{$transportType}.VOYAGE_ID")->join($storage, "{$storage}.ID", '=', "{$pdVoyage}.STORAGE_ID")->where("{$transportType}.ID", $pid)->select($values)->chunk(10, function ($rows) {
                 ShipCargoBlmr::insert($rows->toArray());
             });
             return 'Success!';
         }
     });
     return response()->json($results);
 }
コード例 #2
0
ファイル: TableDataController.php プロジェクト: hunglmtb/eb
 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $date_end = array_key_exists('date_end', $postData) ? $postData['date_end'] : null;
     if ($date_end) {
         $date_end = \Helper::parseDate($date_end);
     }
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $storage = Storage::getTableName();
     $pdCargoNomination = PdCargoNomination::getTableName();
     //     	\DB::enableQueryLog();
     $query = $mdl::join($storage, "{$dcTable}.STORAGE_ID", '=', "{$storage}.ID")->leftJoin($pdCargoNomination, "{$pdCargoNomination}.CARGO_ID", '=', "{$dcTable}.ID")->where(["{$storage}.FACILITY_ID" => $facility_id])->select("{$dcTable}.ID as {$dcTable}", "{$dcTable}.ID as DT_RowId", "{$pdCargoNomination}.ID as IS_NOMINATED", "{$dcTable}.*");
     //   		    			->orderBy('EFFECTIVE_DATE')
     //   		    			->get();
     if ($date_end) {
         $query->whereDate("{$dcTable}.REQUEST_DATE", '<=', $date_end);
     }
     if ($occur_date) {
         $query->whereDate("{$dcTable}.REQUEST_DATE", '>=', $occur_date);
     }
     $dataSet = $query->get();
     //  		\Log::info(\DB::getQueryLog());
     return ['dataSet' => $dataSet];
 }
コード例 #3
0
ファイル: QualityController.php プロジェクト: hunglmtb/eb
 public function getExtraDatasetBy($objectType, $facility_id)
 {
     $srcTypeData = null;
     if ($objectType == "PARCEL") {
         $storage = Storage::getTableName();
         $pdVoyageDetail = PdVoyageDetail::getTableName();
         $pdVoyage = PdVoyage::getTableName();
         $srcTypeData = PdVoyage::join($storage, function ($query) use($storage, $facility_id, $pdVoyage) {
             $query->on("{$pdVoyage}.STORAGE_ID", '=', "{$storage}.ID")->where("{$storage}.FACILITY_ID", '=', $facility_id);
         })->join($pdVoyageDetail, "{$pdVoyage}.ID", '=', "{$pdVoyageDetail}.VOYAGE_ID")->select("{$pdVoyageDetail}.ID", "{$pdVoyageDetail}.ID as CODE", "{$pdVoyage}.NAME as NAME", "{$pdVoyage}.ID as value", "{$pdVoyage}.NAME as text", "{$pdVoyageDetail}.PARCEL_NO as PARCEL_NO")->orderBy("{$pdVoyage}.ID")->orderBy("{$pdVoyageDetail}.PARCEL_NO")->get();
     } else {
         if ($objectType == "RESERVOIR") {
             $srcTypeData = \DB::table($objectType)->get(['ID', 'CODE', 'NAME', 'ID as value', 'NAME as text']);
         } else {
             if ($objectType) {
                 $srcTypeData = \DB::table($objectType)->where("FACILITY_ID", $facility_id)->get(['ID', 'CODE', 'NAME', 'ID as value', 'NAME as text']);
             }
         }
     }
     return $srcTypeData;
 }