git 2 years ago
parent
commit
61bc657798
1 changed files with 44 additions and 88 deletions
  1. 44 88
      Home/Lib/Action/CronAction.class.php

+ 44 - 88
Home/Lib/Action/CronAction.class.php

@@ -7,96 +7,52 @@ class CronAction extends Action {
 
 
  
-	public  function searchFile2Ftp(  ){
-		$dir = C('FTP_LOCAL_DIR');
-		$targetDir = C('FTP_SERVER_DIR');
-		$config = C('FTP_CONFIG');
-		while (true) {
-			$res = scanTargetFile($dir, 'md5');
-			$files = explode(';', $res);
-			array_pop($files);
-			if(empty($files)){
-				sleep(1);
-			}
-			foreach ($files as $v) {
-				$path_parts = pathinfo($v);
-				//$start = time();
-				//判断是否需要压缩,之前压缩过但没上传成功,需要重新上传
-				$zip_file = $path_parts['dirname'].'/' . $path_parts['filename'] . '.zip';
-				if(file_exists($zip_file)){
-					$zip = $zip_file;
-				}else{
-					$zip = $this->zip($path_parts['filename'], $path_parts['dirname']);
-				}
-				if ($zip) {//压缩完成
-					if(filesize($zip) <= 0){
-						@unlink($zip);
-						continue;
-					}
-					//echo '压缩用时:'.(time()-$start).PHP_EOL;
-					$tagetDat = $targetDir . '/' . $path_parts['filename'] . '.zip';
-					//echo $tagetDat . PHP_EOL;
-					//删除本地dat文件
-					@unlink($path_parts['dirname'] . '/' . $path_parts['filename'] . '.dat');
-					$datRes = Zmcoding\FtpFile::getInstance($config)->up_file($zip, $tagetDat);
-					echo "datRes:".$datRes.PHP_EOL;
-					if ($datRes) {
-						$md5Res = Zmcoding\FtpFile::getInstance($config)->up_file($v,  $targetDir . '/' . $path_parts['basename']); //md5文件
-						if ($md5Res) {
-							debug_log('upload_info', json_encode($targetDir . '/' . $path_parts['basename'], JSON_UNESCAPED_UNICODE));
-						}
-						debug_log('upload_info', json_encode($tagetDat, JSON_UNESCAPED_UNICODE));
-					}
-				}
-			}
-			// sleep(3);
+	public  function deleteWdRecords(  ){
+		$config = C('ORACLE_CONFIG');
+		
+		$host= $config['host'];
+		$port=  $config['port'];
+		$instance_name= $config['instance_name'];
+		$username= $config['username'];
+		$password=  $config['password'];
+		
+		/*
+		$host= '192.168.100.23';
+		$port=   '1521';
+		$instance_name= 'helowin';
+		$username=  'DSSC3';
+		$password=  'Rliandssc3';
+		*/
+		$conn = oci_connect($username, $password, $host.':'.$port.'/'. $instance_name,'AL32UTF8');
+		if (!$conn) {
+		   $e = oci_error();
+		   trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
 		}
-	}
-	
- 
-	public  function zip( $name, $path ){
-		//压缩
-		if (!file_exists($path)) {
-			return false;
-		}
-		$current_dir = opendir($path);
-		$needzip = '';//需要压缩的文件
-		while (($file = readdir($current_dir)) !== false) {
-			$sub_dir = $path . DIRECTORY_SEPARATOR . $file;
-			if ($file == '.' || $file == '..') {
-				continue;
-			}
-			if (is_file($sub_dir)) {    //如果是.dat文件,进行赋值
-				$pathinfo = pathinfo($file);
-				// var_dump($pathinfo);
-				if ($pathinfo['extension'] == 'dat' && $pathinfo['filename'] == $name) {
-					$needzip = $file;
-				}
-			}
-		}
-		if ($needzip == '') {
-			return false;
-		}
-		// var_dump($files);exit;
-		$zip_filename = $path . '/' . $name . '.zip';
-		@unlink($zip_filename);
-		if (!file_exists($zip_filename)) {
-			touch($zip_filename);
-			$zip = new \ZipArchive();
-			$ret = $zip->open($zip_filename, \ZipArchive::OVERWRITE);
-			if ($ret !== true) {
-				return false;
-			} else {
-				// if (!empty($files)) {
-				// foreach ($files as $file) {
-				$zip->addFile($path . '/' . $needzip, $needzip);
-				// @unlink($path . '/' . $name . '.dat');
-				// }
-				// }
-				$zip->close();
-			}
+		$min_id=0;
+		$max_id=0;
+		$query_sql='select ID from DSSC2.W_DW_RF_RECORD   where rownum = 1   order by ID Asc ';
+		$stid = oci_parse($conn, $query_sql);
+		oci_define_by_name($stid, 'ID', $min_id);
+		oci_execute($stid);
+		oci_fetch($stid);
+		
+		$max_id=0;
+		$query_sql='select ID from DSSC2.W_DW_RF_RECORD   where rownum = 1   order by ID Desc ';
+		$stid = oci_parse($conn, $query_sql);
+		oci_define_by_name($stid, 'ID', $max_id);
+		oci_execute($stid);
+		oci_fetch($stid);
+		
+		$delete_id=$max_id-800000000;
+		
+		while($min_id<=$delete_id){
+			$del_sql='DELETE FROM DSSC2.W_DW_RF_RECORD WHERE ID = 6468026663';
+			$stid = oci_parse($conn, $del_sql);
+		   $r = oci_execute($stid);
+			$min_id++;
+		
 		}
-		return $zip_filename;
+		
 	}