示例#1
0
文件: helpers.php 项目: hunglmtb/eb
 public static function checkValidateTable($dcTable, $occur_date, $facility_id)
 {
     $lockTable = AuditValidateTable::where(['TABLE_NAME' => $dcTable, 'FACILITY_ID' => $facility_id])->whereDate('DATE_FROM', '<=', $occur_date)->whereDate('DATE_TO', '>=', $occur_date)->first();
     return $lockTable != null && $lockTable != false;
 }
示例#2
0
 public function validateData(Request $request)
 {
     $data = $request->all();
     $table_names = explode(',', $data['TABLE_NAMES']);
     $current_username = '';
     if (auth()->user() != null) {
         $current_username = auth()->user()->username;
     }
     $obj['DATE_FROM'] = \Helper::parseDate($data['DATE_FROM']);
     $obj['DATE_TO'] = \Helper::parseDate($data['DATE_TO']);
     $obj['USER_ID'] = $current_username;
     $obj['FACILITY_ID'] = $data['FACILITY_ID'];
     foreach ($table_names as $table) {
         $condition = array('TABLE_NAME' => $table, 'FACILITY_ID' => $data['FACILITY_ID']);
         $obj['TABLE_NAME'] = $table;
         //\DB::enableQueryLog();
         AuditValidateTable::updateOrCreate($condition, $obj);
         //\Log::info(\DB::getQueryLog());
     }
     $objType_id = $data['OBJECTTYPE'];
     $facility_id = $data['FACILITY_ID'];
     $group_id = $data['GROUP_ID'];
     $result = array();
     $intMapTable = IntMapTable::getTableName();
     $auditValidateTable = AuditValidateTable::getTableName();
     if ($group_id != 0) {
         $datatablegroup = DataTableGroup::where(['ID' => $group_id])->select('TABLES')->first();
         $group = $datatablegroup->TABLES;
         $group = str_replace("\r", "", $group);
         $group = str_replace(" ", "", $group);
         $group = str_replace("\t", "", $group);
         $group = "," . str_replace("\n", ",", $group) . ",";
     } else {
         $group = '';
     }
     // 		\DB::enableQueryLog();
     $loadValidateData = DB::table($intMapTable . ' AS a')->leftjoin($auditValidateTable . ' AS b', function ($join) use($facility_id) {
         $join->on('a.TABLE_NAME', '=', 'b.TABLE_NAME')->where('b.FACILITY_ID', '=', $facility_id);
     })->where(function ($q) use($objType_id) {
         if ($objType_id != 0) {
             $q->where(['a.OBJECT_TYPE' => $objType_id]);
         }
     })->select(['b.ID AS T_ID', 'a.ID', 'a.TABLE_NAME', 'a.FRIENDLY_NAME', 'b.DATE_FROM', 'b.DATE_TO'])->get();
     // 		\Log::info(\DB::getQueryLog());
     foreach ($loadValidateData as $v) {
         if ($group) {
             if (strpos($group, ",{$v->TABLE_NAME},") === false) {
                 continue;
             }
         }
         $v->T_ID = $v->T_ID ? "checked" : "";
         array_push($result, $v);
     }
     return response()->json(array('result' => $result));
 }