当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper::parseDate方法代码示例

本文整理汇总了PHP中Helper::parseDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::parseDate方法的具体用法?PHP Helper::parseDate怎么用?PHP Helper::parseDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Helper的用法示例。


在下文中一共展示了Helper::parseDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     //     	\DB::enableQueryLog();
     $dataSet = $mdl::whereDate("{$dcTable}.BEGIN_DATE", '>=', $occur_date)->whereDate("{$dcTable}.BEGIN_DATE", '<=', $date_end)->select("{$dcTable}.ID as {$dcTable}", "{$dcTable}.ID as DT_RowId", "{$dcTable}.*")->get();
     //  		\Log::info(\DB::getQueryLog());
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:11,代码来源:ContractDataController.php

示例2: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $storage_id = $postData['Storage'];
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $pdCargo = PdCargo::getTableName();
     $dataSet = $mdl::join($pdCargo, "{$dcTable}.CARGO_ID", '=', "{$pdCargo}.ID")->whereDate("{$dcTable}.DATE_UNLOAD", '>=', $occur_date)->whereDate("{$dcTable}.DATE_UNLOAD", '<=', $date_end)->where("{$pdCargo}.STORAGE_ID", '=', $storage_id)->select("{$dcTable}.ID as {$dcTable}", "{$dcTable}.ID as DT_RowId", "{$dcTable}.*")->get();
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:11,代码来源:CargoUnloadController.php

示例3: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $object_id = $postData['EnergyUnit'];
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $euWheres = ['EU_ID' => $object_id];
     //     	\DB::enableQueryLog();
     $dataSet = $mdl::where($euWheres)->whereBetween('EFFECTIVE_DATE', [$occur_date, $date_end])->select("ID as DT_RowId", "{$dcTable}.*")->orderBy('EFFECTIVE_DATE')->get();
     //  		\Log::info(\DB::getQueryLog());
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:13,代码来源:EuTestController.php

示例4: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $storage_id = $postData['Storage'];
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $pdVoyage = PdVoyage::getTableName();
     //     	\DB::enableQueryLog();
     $dataSet = $mdl::join($pdVoyage, "{$dcTable}.VOYAGE_ID", '=', "{$pdVoyage}.ID")->whereDate("{$pdVoyage}.SCHEDULE_DATE", '>=', $occur_date)->whereDate("{$pdVoyage}.SCHEDULE_DATE", '<=', $date_end)->where("{$pdVoyage}.STORAGE_ID", '=', $storage_id)->select("{$dcTable}.ID as {$dcTable}", "{$dcTable}.ID as DT_RowId", "{$dcTable}.*")->get();
     //     					\Log::info(\DB::getQueryLog());
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:13,代码来源:VoyageController.php

示例5: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $dataSet = null;
     $codeDeferGroupType = CodeDeferGroupType::getTableName();
     $where = ['FACILITY_ID' => $facility_id];
     $dataSet = $mdl::leftJoin($codeDeferGroupType, "{$dcTable}.DEFER_GROUP_TYPE", '=', "{$codeDeferGroupType}.ID")->where($where)->whereDate("{$dcTable}.BEGIN_TIME", '>=', $occur_date)->whereDate("{$dcTable}.END_TIME", '<=', $date_end)->select("{$dcTable}.ID as {$dcTable}", "{$codeDeferGroupType}.CODE as DEFER_GROUP_CODE", "{$dcTable}.ID as DT_RowId", "{$dcTable}.ID", "{$dcTable}.*")->get();
     $bunde = ['FACILITY_ID' => $facility_id];
     $extraDataSet = $this->getExtraDataSet($dataSet, $bunde);
     return ['dataSet' => $dataSet, 'extraDataSet' => $extraDataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:14,代码来源:DefermentController.php

示例6: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $object_id = $postData['Tank'];
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $tank = Tank::getTableName();
     $wheres = ['TANK_ID' => $object_id];
     //     	\DB::enableQueryLog();
     $dataSet = $mdl::join($tank, "{$dcTable}.TANK_ID", '=', "{$tank}.ID")->where($wheres)->whereBetween('OCCUR_DATE', [$occur_date, $date_end])->select("{$dcTable}.ID as {$dcTable}", "{$dcTable}.TANK_ID as OBJ_ID", "{$tank}.PRODUCT as FLOW_PHASE", "{$dcTable}.ID as DT_RowId", "{$dcTable}.OCCUR_DATE as T_OCCUR_DATE", "{$dcTable}.*")->orderBy("{$dcTable}.OCCUR_DATE")->orderBy("{$dcTable}.LOADING_TIME")->orderBy("{$dcTable}.TICKET_NO")->get();
     //  		\Log::info(\DB::getQueryLog());
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:14,代码来源:TicketController.php

示例7: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $accountId = $postData['PdLiftingAccount'];
     $date_end = array_key_exists('date_end', $postData) ? $postData['date_end'] : null;
     if ($date_end) {
         $date_end = \Helper::parseDate($date_end);
     }
     //     	\DB::enableQueryLog();
     //     	$sSQL="SELECT a.ID, $fields FROM PD_LIFTING_ACCOUNT_MTH_DATA a WHERE LIFTING_ACCOUNT_ID = $accountId order by BALANCE_MONTH";
     //  	\Log::info(\DB::getQueryLog());
     $pdLiftingAccountMthData = PdLiftingAccountMthData::getTableName();
     $query = PdLiftingAccountMthData::where("LIFTING_ACCOUNT_ID", $accountId)->select("{$pdLiftingAccountMthData}.*", "{$pdLiftingAccountMthData}.ID as {$pdLiftingAccountMthData}", "{$pdLiftingAccountMthData}.ID as DT_RowId")->orderBy("BALANCE_MONTH");
     $dataSet = $query->get();
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:15,代码来源:LiftMonthlyController.php

示例8: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $storage_id = $postData['Storage'];
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $pdCargo = PdCargo::getTableName();
     //     	\DB::enableQueryLog();
     $dataSet = $mdl::join($pdCargo, function ($query) use($pdCargo, $storage_id, $dcTable) {
         $query->on("{$dcTable}.CARGO_ID", '=', "{$pdCargo}.ID")->where("{$pdCargo}.STORAGE_ID", '=', $storage_id);
     })->whereDate("{$dcTable}.REQUEST_DATE", '<=', $date_end)->whereDate("{$dcTable}.REQUEST_DATE", '>=', $occur_date)->select("{$dcTable}.ID as {$dcTable}", "{$dcTable}.ID as DT_RowId", "{$dcTable}.*")->orderBy("{$dcTable}")->get();
     //  		\Log::info(\DB::getQueryLog());
     $extraDataSet = $this->getExtraDataSet($dataSet);
     return ['dataSet' => $dataSet, 'extraDataSet' => $extraDataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:16,代码来源:CargoNominationController.php

示例9: getDataSet

 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);
     }
     $storageId = $postData['Storage'];
     $pd_voyage = PdVoyage::getTableName();
     $pd_cargo = PdCargo::getTableName();
     $pd_voyage_detail = PdVoyageDetail::getTableName();
     $column = array();
     $ObjColumn = $properties['properties'];
     foreach ($ObjColumn as $p) {
         array_push($column, "{$pd_voyage}.{$p->data}");
     }
     array_push($column, "{$pd_voyage_detail}.ID AS DT_RowId");
     array_push($column, "{$pd_voyage}.ID AS VOYAGE_ID");
     array_push($column, "{$pd_voyage_detail}.PARCEL_NO as MASTER_NAME");
     $dataSet = PdVoyage::join($pd_cargo, "{$pd_voyage}.CARGO_ID", '=', "{$pd_cargo}.ID")->join($pd_voyage_detail, "{$pd_voyage_detail}.VOYAGE_ID", '=', "{$pd_voyage}.ID")->where(["{$pd_cargo}.STORAGE_ID" => $storageId])->whereDate('SCHEDULE_DATE', '>=', $occur_date)->whereDate('SCHEDULE_DATE', '<=', $date_end)->orderBy("DT_RowId")->get($column);
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:21,代码来源:CargoDocumentsController.php

示例10: getDataSet

 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];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:24,代码来源:TableDataController.php

示例11: getDataSet

 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $auditTrail = AuditTrail::getTableName();
     $codeAuditReason = CodeAuditReason::getTableName();
     $beginDate = $occur_date;
     if ($postData['IntObjectType'] > 0) {
         $objectName = IntObjectType::where("ID", $postData['IntObjectType'])->select("CODE")->first();
         $objectName = $objectName ? $objectName->CODE : "";
         $objectType = strtoupper(str_replace(' ', '_', $objectName)) . '_%';
     } else {
         $objectType = '%';
     }
     //     	$result = array();
     // 		\DB::enableQueryLog();
     $dataSet = AuditTrail::leftjoin($codeAuditReason, "{$auditTrail}.REASON", '=', "{$codeAuditReason}.ID")->where(["{$auditTrail}.FACILITY_ID" => $facility_id])->whereDate("{$auditTrail}.WHEN", '>=', $occur_date)->whereDate("{$auditTrail}.WHEN", '<=', $date_end)->where('TABLE_NAME', 'like', $objectType)->select(['ACTION', 'WHO', 'WHEN', 'TABLE_NAME', 'COLUMN_NAME', 'RECORD_ID', 'OBJECT_DESC', 'OLD_VALUE', 'NEW_VALUE', "{$codeAuditReason}.NAME AS REASON"])->get();
     // 		\Log::info(\DB::getQueryLog());
     /* 
         	foreach ($loadAudittrail as $v){
         		$v->WHEN = date('m-d-Y', strtotime($v->WHEN));
         		array_push($result, $v);
         	}
         	
         	return response ()->json ( array (
         			'result' => $result
         	) ); */
     /* $dataSet = $mdl::whereDate("$dcTable.BEGIN_DATE",'>=',$occur_date)
     			->whereDate("$dcTable.BEGIN_DATE",'<=',$date_end)
       	->select(
       			"$dcTable.ID as $dcTable",
       			"$dcTable.ID as DT_RowId",
       			"$dcTable.*") 
       			->get(); */
     return ['dataSet' => $dataSet];
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:36,代码来源:AuditController.php

示例12: testformula

 public function testformula(Request $request)
 {
     $data = $request->all();
     $str = "";
     $fid = $data['fid'];
     $occur_date = $data['occur_date'];
     if (!$occur_date) {
         $result = FoVar::where(['formula_id' => $fid])->orderBy('ORDER')->select('*')->get();
         $need_occur_date = false;
         foreach ($result as $row) {
             if (strpos($row->STATIC_VALUE, '@OCCUR_DATE') !== false) {
                 $need_occur_date = true;
                 break;
             }
         }
         if ($need_occur_date) {
             $str = "need_occur_date";
             return response()->json($str);
         }
     }
     if (!$occur_date) {
         $occur_date = Carbon::now();
     } else {
         $occur_date = \Helper::parseDate($occur_date);
     }
     $param = Formula::find($fid);
     $v = \FormulaHelpers::evalFormula($param, $occur_date, true);
     //echo $v;
     return response()->json($v);
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:30,代码来源:FormulaController.php

示例13: run

 public function run(Request $request)
 {
     $postData = $request->all();
     $date_end = $postData['date_end'];
     $date_end = \Helper::parseDate($date_end);
     $object_id = $postData['EnergyUnit'];
     $phase_type = $postData['ExtensionPhaseType'];
     $value_type = $postData['ExtensionValueType'];
     $data_source = $postData['ExtensionDataSource'];
     $table = $postData['EnergyUnit'];
     $mdl = \Helper::getModelName($table);
     $cb_update_db = $postData['cb_update_db'];
     $a = $postData['a'];
     $b = $postData['b'];
     $u = $postData['u'];
     $l = $postData['l'];
     $m = $postData['m'];
     $c1 = $postData['c1'];
     $c2 = $postData['c2'];
     $date_begin = $postData['date_begin'];
     $date_begin = \Helper::parseDate($date_begin);
     $date_from = $postData['f_from_date'];
     $date_from = \Helper::parseDate($date_from);
     $date_to = $postData['f_to_date'];
     $date_to = \Helper::parseDate($date_to);
     $from_date = $date_begin;
     $mkey = "_" . date("Ymdhis_") . rand(100, 1000);
     $data = "";
     $continous = true;
     $lastT = null;
     if (array_key_exists('forecast', $postData)) {
         $txt_modify_data = $postData['forecast'];
         $ds = explode("\n", $txt_modify_data);
         foreach ($ds as $line) {
             if ($line) {
                 $ls = explode(",", $line);
                 if (count($ls) >= 2) {
                     $t = trim($ls[0]);
                     $v = trim($ls[1]);
                     $data .= ($data ? "\r\n" : "") . "{$t},{$v}";
                     if ($lastT && $t - $lastT != 1 && $continous) {
                         $continous = false;
                     }
                     $lastT = $t;
                 }
             }
         }
     } else {
         $qData = $this->getDataSet($postData, null, null, $date_begin, null);
         $dataSet = $qData['dataSet'];
         foreach ($dataSet as $row) {
             $occur_date = $row->OCCUR_DATE;
             $time = $occur_date->diffInDays($from_date);
             $value = $row->V;
             $data .= ($data ? "\r\n" : "") . "{$time},{$value}";
             if ($lastT && $time - $lastT != 1 && $continous) {
                 $continous = false;
             }
             $lastT = $time;
         }
     }
     file_put_contents("data{$mkey}.txt", $data);
     //$end = '2013-08-29';
     //$start = '2013-08-25';
     /* $d1 = strtotime($date_from) - strtotime($date_begin);
     		$d1 = floor($d1/(60*60*24));
     		$d2 = strtotime($date_to) - strtotime($date_begin);
     		$d2 = floor($d2/(60*60*24)); */
     $d1 = $date_from->timestamp - $date_begin->timestamp;
     $d1 = floor($d1 / (60 * 60 * 24));
     $d2 = $date_to->timestamp - $date_begin->timestamp;
     $d2 = floor($d2 / (60 * 60 * 24));
     $timeForecast = "";
     for ($i = $d1; $i < $d2 + 1; $i++) {
         $timeForecast .= ($timeForecast ? "\r\n" : "") . $i;
         if ($lastT && $i - $lastT != 1 && $continous) {
             $continous = false;
         }
         $lastT = $i;
     }
     $sqls = [];
     $warning = '';
     if (!$continous) {
         $warning = "Timing is not continuous";
     }
     file_put_contents("t{$mkey}.txt", $timeForecast);
     // 		echo "<b>Time forecast:</b> ".$timeForecast."<br>";
     if ($a === "0" || $a === "1") {
         $params = "{$a},{$b},0,0,0,0,0";
     } else {
         if ($c2 > 0) {
             $params = "{$a},{$b},0,0,0,{$c1},{$c2}";
         } else {
             $params = "{$a},{$b},{$l},{$u},{$m},{$c1},0";
         }
     }
     file_put_contents("prop{$mkey}.txt", $params);
     $error = [];
     $results = [];
     if (!file_exists('pdforecast.exe')) {
//.........这里部分代码省略.........
开发者ID:hunglmtb,项目名称:eb,代码行数:101,代码来源:EnergyUnitForecastController.php

示例14: run

 public function run(Request $request)
 {
     $postData = $request->all();
     $phase_type = $postData['ExtensionPhaseType'];
     $cb_update_db = $postData['cb_update_db'];
     $occur_date = $postData['date_begin'];
     $value_type = $postData['ExtensionValueType'];
     $occur_date = \Helper::parseDate($occur_date);
     $inputDataSet = $this->getInputDataSet($postData, $occur_date);
     $objdata = $inputDataSet['data'];
     $objinfo = $inputDataSet['info'];
     $mkey = "";
     // 		$mkey			=	"_".date("Ymdhis_").rand(100,1000)/* ."hung_test" */;
     $preos = "";
     $files = ['gas' => "{$preos}" . "prvap.exe", 'oil' => "{$preos}" . "prliq.exe", 'data' => "{$preos}" . "data{$mkey}.txt", 'm_ij' => "{$preos}" . "m_ij{$mkey}.txt", 'prop' => "{$preos}" . "prop{$mkey}.txt", 'error' => "{$preos}" . "error{$mkey}.txt", 'PR_single_V' => "{$preos}" . "PR_single_V{$mkey}.csv", 'PR_single_L' => "{$preos}" . "PR_single_L{$mkey}.csv"];
     $cc = count($objdata);
     if ($cc <= 0) {
         return response('empty input data', 401);
     }
     //['error'=>"empty input data"];
     $ele = array_values($objdata)[0];
     $data = "";
     $inputData = [];
     foreach ($ele as $key => $value) {
         $ss = [];
         foreach ($objdata as $source => $objValue) {
             if ($objValue[$key] !== "") {
                 $ss[] = $objValue[$key];
                 $inputData[] = $objValue[$key] . " <- [{$source}][{$key}]";
             }
         }
         if (count($ss) > 0) {
             $data .= ($data ? "\r\n" : "") . implode(",", $ss);
         }
     }
     file_put_contents($files['data'], $data);
     $error = [];
     $results = [];
     $sqls = [];
     //Gas
     $exe = $phase_type == 2 ? $files['gas'] : $files['oil'];
     if (!file_exists($exe)) {
         $error[] = "Exec {$exe} file not found";
     } else {
         if (file_exists($files['data'])) {
             set_time_limit(300);
             exec("{$exe} {$mkey}");
             if (file_exists($files['error'])) {
                 $error[] = file_get_contents($files['error'], true);
             }
             if (file_exists($files['PR_single_V'])) {
                 $fileName = $files['PR_single_V'];
                 $file = fopen($fileName, "r");
                 $lastline = "";
                 $result = [];
                 while (!feof($file)) {
                     $line = fgets($file);
                     $result[] = $line;
                     if ($line) {
                         if ($line) {
                             $lastline = $line;
                         }
                     }
                 }
                 $results[$fileName] = $result;
                 fclose($file);
                 $fileName = $files['PR_single_L'];
                 $file = fopen($fileName, "r");
                 $lastline = "";
                 $result = [];
                 while (!feof($file)) {
                     $line = fgets($file);
                     $result[] = $line;
                     if ($line) {
                         if ($line) {
                             $lastline = $line;
                         }
                     }
                 }
                 $results[$fileName] = $result;
                 fclose($file);
                 if ($lastline && $cb_update_db == 'true') {
                     $xs = explode(",", $lastline);
                     $i = 0;
                     foreach ($xs as $svol) {
                         if ($i < count($objinfo)) {
                             $src = $objinfo[$i]["src"];
                             $pre = $objinfo[$i]["pre"];
                             $table = $src . "_DATA_VALUE";
                             $field = $pre . "_DATA_{$value_type}";
                             $field = strtoupper($field);
                             $attributes = ["OCCUR_DATE" => $occur_date];
                             if ($src == "ENERGY_UNIT") {
                                 $attributes['FLOW_PHASE'] = $phase_type;
                             }
                             $attributes["{$pre}" . "_ID"] = $objinfo[$i]["obj_id"];
                             $values = $attributes;
                             $values[$field] = $svol;
                             $mdl = \Helper::getModelName($table);
                             \DB::enableQueryLog();
//.........这里部分代码省略.........
开发者ID:hunglmtb,项目名称:eb,代码行数:101,代码来源:PreosController.php

示例15: gen

 public function gen(Request $request)
 {
     try {
         $postData = $request->all();
         $result = \DB::transaction(function () use($postData) {
             $contract_id = $postData['contract_id'];
             $storage_id = $postData['PdContractQtyFormula'];
             $code1st = array_key_exists("code1st", $postData) ? $postData["code1st"] : 0;
             $year1 = array_key_exists("year1", $postData) ? $postData["year1"] : 0;
             $code2nd = array_key_exists("code2nd", $postData) ? $postData["code2nd"] : 0;
             $year = array_key_exists("year", $postData) ? $postData["year"] : 0;
             $month = array_key_exists("month", $postData) ? $postData["month"] : 0;
             $day = array_key_exists("day", $postData) ? $postData["day"] : "";
             $seq = array_key_exists("seq", $postData) ? $postData["seq"] : 0;
             $liftacc = array_key_exists("PdLiftingAccount", $postData) ? $postData["PdLiftingAccount"] : 0;
             $priority = array_key_exists("PdCodeCargoPriority", $postData) ? $postData["PdCodeCargoPriority"] : 0;
             $qtytype = array_key_exists("PdCodeCargoQtyType", $postData) ? $postData["PdCodeCargoQtyType"] : 0;
             $date1st = array_key_exists("date1st", $postData) ? $postData["date1st"] : 0;
             $avgqty = array_key_exists("avgqty", $postData) ? $postData["avgqty"] : 0;
             $uom = array_key_exists("PdCodeMeasUom", $postData) ? $postData["PdCodeMeasUom"] : 0;
             $adjtime = array_key_exists("PdCodeTimeAdj", $postData) ? $postData["PdCodeTimeAdj"] : 0;
             $tolerance = array_key_exists("PdCodeQtyAdj", $postData) ? $postData["PdCodeQtyAdj"] : 0;
             $qty = array_key_exists("qty", $postData) ? $postData["qty"] : 0;
             $n = strlen($seq);
             $num = $seq + 1 - 1;
             $count = 0;
             $x_qty = 0;
             if ($qty <= 0) {
                 return "Quantity value must be greater than zero";
             }
             if ($avgqty <= 0) {
                 return "Average quantity value must be greater than zero";
             }
             $date1st = \Helper::parseDate($date1st);
             $requestDate = $date1st;
             while (true) {
                 $x_qty += $avgqty;
                 $exit = $x_qty >= $qty;
                 $code = $code1st . $year1 . $code2nd . $year . $month . $day . str_pad($num, $n, '0', STR_PAD_LEFT);
                 PdCargo::where("CODE", $code)->delete();
                 PdCargo::insert(["CODE" => $code, "NAME" => $code, "LIFTING_ACCT" => $liftacc, "STORAGE_ID" => $storage_id, "REQUEST_DATE" => $requestDate, "REQUEST_QTY" => $avgqty, "REQUEST_UOM" => $uom, "PRIORITY" => $priority, "QUANTITY_TYPE" => $qtytype, "CONTRACT_ID" => $contract_id]);
                 $num++;
                 $requestDate = $requestDate->addMonths(6);
                 if ($exit) {
                     break;
                 }
             }
             return "Sucess";
         });
     } catch (\Exception $e) {
         $result = "could not generate cargo";
         \Log::info("\n---gen cargo--\nException wher run transation\n ");
         \Log::info($e->getMessage());
         \Log::info($e->getTraceAsString());
         // 			return response($e->getMessage(), 400);
     }
     return response()->json($result);
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:58,代码来源:ContractProgramController.php


注:本文中的Helper::parseDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。