SFR : Correction
This commit is contained in:
parent
dc092c5884
commit
6382fb4a52
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* Crontab
|
||||
* 0 20 * * 1-6 scores php /home/scores/batch/scripts/clients/SfrIndicateur.php --load --cron >> /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 19 * * 1-6 scores php /home/scores/batch/scripts/clients/SfrIndicateur.php --cron --load >> /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);
|
||||
@ -34,7 +34,7 @@ try {
|
||||
//Options
|
||||
array(
|
||||
'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)",
|
||||
'manual-s' => "Provide manualy the file path to get result and debug values",
|
||||
'debug' => "Debug",
|
||||
@ -207,12 +207,12 @@ if ( $opts->cron ) {
|
||||
$diff = $dateNow->sub(12, Zend_Date::HOUR);
|
||||
$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();
|
||||
$sql = $fluxinM->select()
|
||||
->where('client=?',$client)
|
||||
->where('name=?', $prestation)
|
||||
->where('typeDepot=?',$typeDepot)
|
||||
->where('depotType=?',$typeDepot)
|
||||
->where('dateExecute=?','0000-00-00 00:00:00')
|
||||
->where("dateInsert BETWEEN '".$dateIn2."' AND '".$dateIn1."' ")
|
||||
->order('dateInsert DESC');
|
||||
@ -220,17 +220,17 @@ if ( $opts->cron ) {
|
||||
$pitems = $fluxinM->fetchAll($sql);
|
||||
|
||||
if ( $pitems->count()==0 ) {
|
||||
//@todo : Aucun traitement à réaliser
|
||||
echo date('Y-m-d H:i:s')." : Aucun traitement à réaliser.".PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($pitems as $p) {
|
||||
$filepath = $pathIn . DIRECTORY_SEPARATOR . $p->fileDepot;
|
||||
$filepath = $pathIn . DIRECTORY_SEPARATOR . $p->depotFile;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !file_exists($filepath) ) {
|
||||
echo "Fichier inexistant ! ".PHP_EOL;
|
||||
echo date('Y-m-d H:i:s')." : Fichier inexistant ! ".PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ if ( $opts->evaluate ) {
|
||||
else {
|
||||
try {
|
||||
$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) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
@ -285,8 +285,8 @@ if ( $opts->evaluate ) {
|
||||
$dateInsert = new Zend_Date($result->dateInsert, 'yyyy-MM-dd HH:mm:ss');
|
||||
$diff = $dateNow->sub($dateInsert);
|
||||
$measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::HOUR);
|
||||
if ( $measure->getValue()>12 ) {
|
||||
echo "Aucun traitement à réaliser (Dernière date : ".$dateInsert->toString('yyyy-MM-dd HH:mm:ss').").".PHP_EOL;
|
||||
if ( $measure->getValue()>20 ) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -340,11 +340,12 @@ if ( $opts->evaluate ) {
|
||||
foreach ($result as $item) {
|
||||
|
||||
$row++;
|
||||
echo "Ligne $row : ";
|
||||
echo date('Y-m-d H:i:s')." : Ligne $row : ";
|
||||
|
||||
//Score non calculé
|
||||
if ( $item->indiScore20 === null ) {
|
||||
|
||||
echo "Non calculé";
|
||||
$sfrDataM->update(array('error' => 2020), "siren='".$item->siren."' AND NumSeq='".$seq."'");
|
||||
|
||||
}
|
||||
@ -379,7 +380,7 @@ if ( $opts->evaluate ) {
|
||||
$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
|
||||
$line = array();
|
||||
@ -393,7 +394,7 @@ if ( $opts->evaluate ) {
|
||||
fputcsv($fp, $line, $fileOkOptionsOut['delimiter'], $fileOkOptionsOut['enclosure']);
|
||||
|
||||
} else {
|
||||
echo "- Pas de calcul";
|
||||
echo "Pas de calcul";
|
||||
$sfrDataM->update(array('error' => 2020), "siren='".$item->siren."' AND NumSeq='".$seq."'");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user