1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#!/SOFT/perl5/bin/perl
use 5.008005;
use strict;
use warnings;
use lib "$ENV{STKROOT}/batch/";
use Infra;
use POSIX qw(strftime);
use DB;
#Déclaration des variables et tableaux
my %mapping;
my %reverse_mapping;
my $chemin;
my $fichier;
my @fichiers;
my $dossier;
my $nomfichier;
my $nomcaisse;
my $caisse;
my @time_stats;
my $mtime;
my $datep;
my $heurep;
my $save = "$ENV{SUMMITSPOOLDIR}/indicateur_convention.txt"; # sauvegarde dans un fichier csv
my $tmp;
my $year;
my $month;
my $day;
printf "Lecture et chargement du fichier des caisses...";
open IN, "<$ENV{STKROOT}/batch/rep_mapping_caisse.ini";
while (<IN>) {
if (m/^([a-z]+):(.*)$/) {
$mapping{$1}=$2;
}
}
close IN;
%reverse_mapping = reverse %mapping;
printf "OK\n";
open (FH, ">$save") || die $!;
foreach $caisse (values %reverse_mapping) {
#Récupération PLUPD SUMMIT & CHOPE_G & CHOPE_5J INFOCENTRE
@fichiers = (
"$ENV{INTRANET_BASEDIR}/$caisse/Commun/REPORTING/SUMMIT/$ENV{PAR_J_YYYY}$ENV{PAR_J_MM}$ENV{PAR_J_DD}/"
."$ENV{PAR_J_YYYY}$ENV{PAR_J_MM}$ENV{PAR_J_DD}"."_SUMMIT"."_$mapping{$caisse}"."_PLUPD"
."_3112".($ENV{PAR_J_YY}-1<10?'0':'').($ENV{PAR_J_YY}-1)."_$ENV{BAT_JM1_DD}$ENV{BAT_JM1_MM}$ENV{BAT_JM1_YY}".".txt",
"$ENV{INTRANET_BASEDIR}/$caisse/Commun/REPORTING/INFOCENTRE/$ENV{PAR_J_YYYY}$ENV{PAR_J_MM}$ENV{PAR_J_DD}/CHOPE_5J.XLS",
"$ENV{INTRANET_BASEDIR}/$caisse/Commun/REPORTING/INFOCENTRE/$ENV{PAR_J_YYYY}$ENV{PAR_J_MM}$ENV{PAR_J_DD}/CHOPE_G.XLS"
);
foreach $fichier (@fichiers){
$tmp=$fichier;
print "$tmp\n";
if (-e $fichier){ #si le fichier existe récupération des infos du fichier
# if ($tmp =~ m#([^/]+)/Commun/REPORTING/SUMMIT/([0-9]{8,8})/(.*)$#){
if ($tmp =~ m#([^/]+)/Commun/REPORTING/SUMMIT/([0-9]{8,8})/[0-9]{8,8}_SUMMIT_[A-Z]+_(PLUPD)_[0-9_]+.txt$#){
}
elsif ($tmp =~ m#([^/]+)/Commun/REPORTING/INFOCENTRE/([0-9]{8,8})/(CHOPE_5J).XLS$#){
}
elsif ($tmp =~ m#([^/]+)/Commun/REPORTING/INFOCENTRE/([0-9]{8,8})/(CHOPE_G).XLS$#){
}
else {
print "aucun fichier trouvé: anomalie!";
exit ;
}
$year=substr($2, 0,4);
$month=substr($2, 4,2);
$day=substr($2, 6,2);
$dossier= $day.$month.$year;
print "$dossier\n";
$nomcaisse= $mapping{$1};
print " $nomcaisse\n";
$nomfichier=$3;
print " $nomfichier\n";
@time_stats = stat($fichier); #On récupère date et heure
$mtime = $time_stats[9];
$datep = strftime( "%d/%m/%Y" ,localtime($mtime)); #date JJ/MM/YYYY
$heurep = strftime( "%H:%M:%S",localtime($mtime)); #heure HH:MM:SS
printf FH "%s;%s;%s;%s;%s;\n",$dossier, $nomcaisse, $nomfichier, $datep, $heurep
}
}
}
close (FH);
END {
exit filter ;
} |
Partager