SFR : Correction

This commit is contained in:
Michael RICOIS 2013-10-02 09:58:37 +00:00
parent dc092c5884
commit 6382fb4a52

View File

@ -1,8 +1,8 @@
<?php <?php
/* /*
* Crontab * Crontab
* 0 20 * * 1-6 scores php /home/scores/batch/scripts/clients/SfrIndicateur.php --load --cron >> /home/scores/log/SfrIndicateur.log * 30 19 * * 1-6 scores php /home/scores/batch/scripts/clients/SfrIndicateur.php --cron --load >> /home/scores/log/SfrIndicateur.log
* 0 1 * * 1-6 scores php /home/scores/batch/scripts/clients/SfrIndicateur.php --evaluate --cron >> /home/scores/log/SfrIndicateur.log * 30 22 * * 1-6 scores php /home/scores/batch/scripts/clients/SfrIndicateur.php --evaluate >> /home/scores/log/SfrIndicateur.log
*/ */
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_WARNING); error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_WARNING);
//error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE); //error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);
@ -34,7 +34,7 @@ try {
//Options //Options
array( array(
'help|?' => "Displays usage information.", 'help|?' => "Displays usage information.",
'load=s' => "Preload file in database and check SIREN", 'load-s' => "Preload file in database and check SIREN",
'evaluate-s' => "Lauch evaluation (specify the Seq Number to regen)", 'evaluate-s' => "Lauch evaluation (specify the Seq Number to regen)",
'manual-s' => "Provide manualy the file path to get result and debug values", 'manual-s' => "Provide manualy the file path to get result and debug values",
'debug' => "Debug", 'debug' => "Debug",
@ -207,12 +207,12 @@ if ( $opts->cron ) {
$diff = $dateNow->sub(12, Zend_Date::HOUR); $diff = $dateNow->sub(12, Zend_Date::HOUR);
$dateIn2 = $diff->toString('yyyy-MM-dd HH:mm:ss'); $dateIn2 = $diff->toString('yyyy-MM-dd HH:mm:ss');
//client, name, typeDepot, dateDepot, fileDepot, nblignes, dateInsert, dateExecute //client, name, depotType, depotDate, depotFile, nbLines, dateInsert, dateExecute
$fluxinM = new Application_Model_Sdv1FluxFileIn(); $fluxinM = new Application_Model_Sdv1FluxFileIn();
$sql = $fluxinM->select() $sql = $fluxinM->select()
->where('client=?',$client) ->where('client=?',$client)
->where('name=?', $prestation) ->where('name=?', $prestation)
->where('typeDepot=?',$typeDepot) ->where('depotType=?',$typeDepot)
->where('dateExecute=?','0000-00-00 00:00:00') ->where('dateExecute=?','0000-00-00 00:00:00')
->where("dateInsert BETWEEN '".$dateIn2."' AND '".$dateIn1."' ") ->where("dateInsert BETWEEN '".$dateIn2."' AND '".$dateIn1."' ")
->order('dateInsert DESC'); ->order('dateInsert DESC');
@ -220,17 +220,17 @@ if ( $opts->cron ) {
$pitems = $fluxinM->fetchAll($sql); $pitems = $fluxinM->fetchAll($sql);
if ( $pitems->count()==0 ) { if ( $pitems->count()==0 ) {
//@todo : Aucun traitement à réaliser echo date('Y-m-d H:i:s')." : Aucun traitement à réaliser.".PHP_EOL;
exit; exit;
} }
foreach ($pitems as $p) { foreach ($pitems as $p) {
$filepath = $pathIn . DIRECTORY_SEPARATOR . $p->fileDepot; $filepath = $pathIn . DIRECTORY_SEPARATOR . $p->depotFile;
break; break;
} }
if ( !file_exists($filepath) ) { if ( !file_exists($filepath) ) {
echo "Fichier inexistant ! ".PHP_EOL; echo date('Y-m-d H:i:s')." : Fichier inexistant ! ".PHP_EOL;
exit; exit;
} }
@ -274,7 +274,7 @@ if ( $opts->evaluate ) {
else { else {
try { try {
$db->setFetchMode(Zend_Db::FETCH_OBJ); $db->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $db->fetchRow('SELECT NumSeq, dateInsert FROM jo.sfr_data ORDER BY NumSeq DESC LIMIT 0,1'); $result = $db->fetchRow('SELECT NumSeq, dateInsert FROM jo.sfr_data ORDER BY id DESC LIMIT 0,1');
} catch(Zend_Db_Adapter_Exception $e) { } catch(Zend_Db_Adapter_Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
@ -285,8 +285,8 @@ if ( $opts->evaluate ) {
$dateInsert = new Zend_Date($result->dateInsert, 'yyyy-MM-dd HH:mm:ss'); $dateInsert = new Zend_Date($result->dateInsert, 'yyyy-MM-dd HH:mm:ss');
$diff = $dateNow->sub($dateInsert); $diff = $dateNow->sub($dateInsert);
$measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::HOUR); $measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::HOUR);
if ( $measure->getValue()>12 ) { if ( $measure->getValue()>20 ) {
echo "Aucun traitement à réaliser (Dernière date : ".$dateInsert->toString('yyyy-MM-dd HH:mm:ss').").".PHP_EOL; echo date('Y-m-d H:i:s')." : Aucun traitement à réaliser (Dernière date : ".$dateInsert->toString('yyyy-MM-dd HH:mm:ss').").".PHP_EOL;
exit; exit;
} }
} }
@ -340,11 +340,12 @@ if ( $opts->evaluate ) {
foreach ($result as $item) { foreach ($result as $item) {
$row++; $row++;
echo "Ligne $row : "; echo date('Y-m-d H:i:s')." : Ligne $row : ";
//Score non calculé //Score non calculé
if ( $item->indiScore20 === null ) { if ( $item->indiScore20 === null ) {
echo "Non calculé";
$sfrDataM->update(array('error' => 2020), "siren='".$item->siren."' AND NumSeq='".$seq."'"); $sfrDataM->update(array('error' => 2020), "siren='".$item->siren."' AND NumSeq='".$seq."'");
} }
@ -379,7 +380,7 @@ if ( $opts->evaluate ) {
$values = array_merge($values, $valuesDebug); $values = array_merge($values, $valuesDebug);
} }
echo " Siren=".$item->siren.", ID=".$values['idVOR'].", commentaire=".$values['commentaire']; echo "Siren=".$item->siren.", ID=".$values['idVOR'].", commentaire=".$values['commentaire'];
//Ecrire fichier RETOUR //Ecrire fichier RETOUR
$line = array(); $line = array();
@ -393,7 +394,7 @@ if ( $opts->evaluate ) {
fputcsv($fp, $line, $fileOkOptionsOut['delimiter'], $fileOkOptionsOut['enclosure']); fputcsv($fp, $line, $fileOkOptionsOut['delimiter'], $fileOkOptionsOut['enclosure']);
} else { } else {
echo "- Pas de calcul"; echo "Pas de calcul";
$sfrDataM->update(array('error' => 2020), "siren='".$item->siren."' AND NumSeq='".$seq."'"); $sfrDataM->update(array('error' => 2020), "siren='".$item->siren."' AND NumSeq='".$seq."'");
} }