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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
while((line = buff.readLine()) != null){
String entete = line.substring(0,5);
if(entete.equals("RFF10")){
tag = 1;
ref = "";
ref = line.substring(8,line.length());
if(ref.trim().length()<= 6){//recuperation du n° de cde minos
while(ref.trim().length()<9){
ref = '0'+ref;
}
st = BaseDonnees.connexionAS400().prepareStatement("select vm010p10.nucmdc,vm010p10.clil,vm010p10.nuliv,vm007p10.rsclt,un100p10.livpoidst,un100p10.livinstr1,un100p10.dtcreenr,un100p10.indcde from vm010p10, vm007p10, un100p10 " +
"where vm007p10.cli = vm010p10.clil " +
"and un100p10.blnum = vm010p10.nuliv " +
"and vm010p10.cste='CRP' and vm010p10.nucmdc='"+ref+"' and vm010p10.nuliv<>''");
rs = st.executeQuery();
while (rs.next()){
int j = rs.getRow();
if(j == 1){
if(rs.getString("rsclt").trim()!= ""){//raison sociale du client
cli = rs.getString("rsclt").trim();
System.out.println("cli: "+cli);
}else{
cli = "incon";
}
if(rs.getString("livpoidst").trim() != ""){//poids envoi
pds = rs.getString("livpoidst").trim().substring(0, 4);
pds = "0"+pds;
System.out.println("pds: "+pds);
}else{
pds = "0";
}
if(rs.getString("livinstr1").trim() != ""){
col = rs.getString("livinstr1").trim().substring(0, 2);//nb colis
pal = rs.getString("livinstr1").trim().substring(6, 8);//nb palettes
cp = col +"C"+"/"+pal+"P";
System.out.println("cp: "+cp);
}
if(rs.getString("clil").trim() != ""){//code client minos
clil = rs.getString("clil").trim();
System.out.println("clicode: "+clil);
}
if(rs.getString("dtcreenr").trim() != ""){//date d'enregistrement
aenv = rs.getString("dtcreenr").trim().substring(0, 4);
menv = rs.getString("dtcreenr").trim().substring(4, 6);
jenv = rs.getString("dtcreenr").trim().substring(6, rs.getString("dtcreenr").trim().length());
System.out.println("date: "+aenv+"/"+menv+"/"+jenv);
}else{
aenv = "00";
menv = "00";
jenv = "00";
}
if(rs.getString("indcde").trim() != ""){
ind = rs.getString("indcde").trim();
System.out.println("ind:"+ind);
}else{
ind = "000";
}
refc = "inconnu";
}
}
}
if(ref.trim().length() > 9){//recup n° de bl dans la ligne si pas de n° de cde
k = line.substring(26, 29);
if(k.equals("KAF")){
ref = "incon";
refc = line.substring(29, 37);
clil = "incon";
cli = "incon";
}
if((k.equals("KMS")) || (k.equals("KSX"))){
bl = line.substring(29, 37);
while(bl.length() < 9){
bl = "0"+bl;
}
st1 = BaseDonnees.connexionAS400().prepareStatement("select vm010p10.nucmdc,vm010p10.clil,vm010p10.nuliv,vm007p10.rsclt,un100p10.livpoidst,un100p10.livinstr1,un100p10.dtcreenr,un100p10.indcde from vm010p10, vm007p10, un100p10 " +
"where vm007p10.cli = vm010p10.clil " +
"and un100p10.blnum = vm010p10.nuliv " +
"and vm010p10.cste='CRP' and vm010p10.nuliv='"+bl+"'");
rs1 = st1.executeQuery();
while (rs.next()){
int j = rs.getRow();
if(j == 1){
if(rs1.getString("rsclt").trim()!= ""){//raison sociale du client
cli = rs1.getString("rsclt").trim();
}else{
cli = "incon";
}
if(rs1.getString("livpoidst").trim() != ""){//poids envoi
pds = rs1.getString("livpoidst").trim().substring(0, 4);
pds = "0"+pds;
}else{
pds = "0";
}
if(rs1.getString("livinstr1").trim() != ""){
col = rs1.getString("livinstr1").trim().substring(0, 2);//nb colis
pal = rs1.getString("livinstr1").trim().substring(6, 8);//nb palettes
cp = col +"C"+"/"+pal+"P";
}
if(rs1.getString("clil").trim() != ""){//code client minos
clil = rs1.getString("clil").trim();
}
if(rs1.getString("nucmdc").trim() != ""){
ref = rs1.getString("nucmdc").trim();
}else{
ref= "incon";
}
if(rs1.getString("dtcreenr").trim() != ""){//date d'enregistrement
aenv = rs1.getString("dtcreenr").trim().substring(0, 4);
menv = rs1.getString("dtcreenr").trim().substring(4, 6);
jenv = rs1.getString("dtcreenr").trim().substring(6, rs1.getString("dtcreenr").trim().length());
}else{
aenv = "00";
menv = "00";
jenv = "00";
}
if(rs1.getString("indcde").trim() != ""){
ind = rs1.getString("indcde").trim();
}else{
ind = "000";
}
if(rs1.getString("nucmdc").trim() != ""){
ref = rs1.getString("nucmdc").trim();
}else{
ref = "incon";
}
}
}
}
}
}
if(entete.equals("RSJ20")){//suivi d'expedition
tag = 2;
sit = line.substring(8, 11);
st1 = BaseDonnees.connexionPostgres().prepareStatement("select libelle from codsit where code='"+sit+"'");
rs1 = st1.executeQuery();
while(rs1.next()){
sit = rs1.getString("libelle").trim();//libelle situation
System.out.println("sit: "+sit);
}
just = line.substring(11, 14);
st1 = BaseDonnees.connexionPostgres().prepareStatement("select libelle from codjust where code='"+just+"'");
rs1 = st1.executeQuery();
while(rs1.next()){
just = rs1.getString("libelle").trim();//libelle justification
System.out.println("just: "+just);
}
}
if(entete.equals("DTM30")){//date operation chez transporteur
dtm = line.substring(5, 8);
if(dtm.equals("DSJ")){
tag = 3;
dtm1 = "20"+line.substring(8, 14);
h = line.substring(14, line.length());
System.out.println("date et heure: "+dtm1+" "+h);
}
}
if(entete.equals("TXT30")){//marquage colis et n° de recepisse
txt = line.substring(5, 8);
if(txt.equals("RCO")){
tag = 4;
pci = line.substring(29, line.length());
System.out.println("marquage: "+pci);
}
if(txt.equals("DEL")){//ligne de commentaire
tag = 5;
del = line.substring(8, line.length());
System.out.println("com;: "+del);
}
}
if(tag == 5){
InsertBase insert = new InsertBase();
System.out.println(transp+" "+pci+" "+clil+" "+cli+" "+ref+" "+ind+" "+refc+" "+sit+" "+just+" "+dtm1+" "+h+" "+del+" "+cp+" "+pds+" "+aenv+" "+menv+" "+jenv);
insert.insertB(transp, pci, clil, cli, ref, ind, refc, sit, just, dtm1, h, del, cp, pds, aenv, menv, jenv);
}
}
}finally{
buff.close();
} |
Partager