| 12
 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
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 
 | /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package ChargFamille;
 
/*****les imports******/
/**
 *
 * @author Administrateur
 */
public class NewClass {
  private ConnOracle conn;
  private ConnMysql conmysql;
 
  final BlockingQueue<String> queuee= new ArrayBlockingQueue<String>(1000000);
  SitBean sit;
  StatBean statu;
  FamBean fam;
  ArrayList listfam=null;
  /***************************
   bloc de connexion 
  ********************* */
 
 
  public Runnable charge = new Runnable() {
  @Override
  synchronized public void run() {
  //public RecupFam()throws SQLException{
        ArrayList listfam=null;
        String requete;
        PreparedStatement ps = null;
        ResultSet rs = null;
        Date maj;
        String imma;
        int i=0;
            try{
           java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());
           int year=sqlDate.getYear();
           year=year-2;
           sqlDate.setYear(year);
 
           requete="SELECT distinct(IMM_V_NUM_IMM)"
           +" FROM   D_ASS_OPER"
           +" WHERE  TEV_C_EVOP    LIKE '21%' "
           +"AND    TPR_C_PREST   IN ('AE','AM','AN','AR','AA') "
           +" AND    ASO_D_EMISS >=? and rownum<100000";
            ps=conn.getConnexion().prepareStatement(requete);
            ps.setDate(1, sqlDate);
            rs=ps.executeQuery();
 
            while(rs.next()){
 
                 imma=rs.getString("IMM_V_NUM_IMM");
 
                 GetFamille(imma);
 
            }   }
        catch (Exception exx){
             System.err.println("[RecupFam-DatMaj] - [Erreur] - Erreur  de la requete!");
             System.err.println("[RecupFam-DatMaj] - [Message] - " + exx.getMessage());}
 
        try{
        queuee.put("END_QUEUE");}
        catch (Exception exe){}
         try {
            ps.close();
         } catch (Exception exx) {}
           try {
            rs.close();
        } catch (Exception ex) {}
 
  }};
 
  public  void GetFamille(String imma) throws SQLException{
        String requete;
        PreparedStatement ps = null;
        ResultSet rs = null;
        Date maj;
        String prenom;
        String datnaiss;
        requete ="select IND_IND_V_NUM_INDIVIDU_1,NIT_NIT_C_NAT_INT,IND_L_PRENOM ,IND_D_NAISSANCE from d_immat  immat ,d_ind  ind , d_relation rel "
 
	+" where immat.IMM_V_NUM_IMM 	= 1|| substr(?,2,8) and rel.IND_IND_V_NUM_INDIVIDU  = immat.IND_IND_V_NUM_INDIVIDU"
	+" and IND_IND_V_NUM_INDIVIDU_1    = ind.IND_V_NUM_INDIVIDU"
	+" and  NIT_NIT_C_NAT_INT = 13"
	+" and nvl(RFA_C_ETAT,'0') = 0"
	+" order by IND_D_NAISSANCE";
        ps=conn.getConnexion().prepareStatement(requete);
 
        ps.setString(1, imma);
        rs=ps.executeQuery();//}
 
       while(rs.next())
        {
 
       sit= AppelSit(rs.getString("IND_IND_V_NUM_INDIVIDU_1"),imma);
        //System.out.println(rs.getString("IND_IND_V_NUM_INDIVIDU_1")+"IND_IND_V_NUM_INDIVIDU_1");
       statu=AppelStat(rs.getString("IND_IND_V_NUM_INDIVIDU_1"));
 
        datnaiss=String.format("%1$td"+"/"+"%1$tm"+"/"+"%1$tY", rs.getDate("IND_D_NAISSANCE"));
        prenom=rs.getString("IND_L_PRENOM");
        String datsite =sit.getDatsit();
        String site ="SIT"+sit.getSit();
        String datstate=statu.getDatstat();
        String statue ="STAT"+statu.getStat();
 
        datsite=(datsite.substring(6, 8)+"/"+datsite.substring(4, 6)+"/"+datsite.substring(0, 4));
        datstate=(datstate.substring(6, 8)+"/"+datstate.substring(4, 6)+"/"+datstate.substring(0, 4));
 
        queuee.put(imma+"-"+prenom+"-"+datnaiss+"-"+site+"-"+datsite+"-"+statue+"-"+datstate);
 
 
 
        }
 
        }
 
 
 
         catch (Exception exx) {
            System.err.println("[ChargFamille-GetFamille] - [Erreur] - Erreur  de la requete!");
             System.err.println("[ChargFamille-GetFamille] - [Message] - " + exx.getMessage());
        }
 
 
 
        finally{
            try {
            ps.close();
         } catch (Exception exx) {}
           try {
            rs.close();
        } catch (Exception ex) {}
        }
       // return listfam;
  }//};
  public SitBean AppelSit(String ind,String imma) throws SQLException{
        String requete;
        PreparedStatement ps = null;
        CallableStatement cs = null;
        ResultSet rs = null;
        Date maj;
        java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());
        try{
         requete="call appel_situation_individu(?,?,?,?,?)";
        cs=conn.getConnexion().prepareCall(requete);
        cs.setString(1, ind);
        cs.setDate(2,sqlDate);
 
        cs.setString(3, "1"+imma.substring(1,9));
        cs.registerOutParameter(4, java.sql.Types.NUMERIC);
        cs.registerOutParameter(5, java.sql.Types.VARCHAR);
        cs.execute();
        Integer dernsit=cs.getInt(4);
        String datsit=cs.getString(5);
        sit=new SitBean(dernsit,datsit);}
        catch (Exception exx) {
            System.err.println("[ChargFamille-AppelStat] - [Erreur] - Erreur  de la requete!");
             System.err.println("[ChargFamille-AppelStat] - [Message] - " + exx.getMessage());
        }
        finally{
        try {
            cs.close();
         } catch (Exception exx) {}}
      return sit;
    }
  public StatBean AppelStat(String ind) throws SQLException{
      String requete;
        PreparedStatement ps = null;
        CallableStatement cs = null;
        ResultSet rs = null;
        try{
        requete="call appel_statut_individu(?,?,?)";
        cs=conn.getConnexion().prepareCall(requete);
        cs.setString(1, ind);
        cs.registerOutParameter(2, java.sql.Types.NUMERIC);
        cs.registerOutParameter(3, java.sql.Types.VARCHAR);
        cs.execute();
        Integer stat=cs.getInt(2);
        String datstat=cs.getString(3);
        statu= new StatBean(stat,datstat);}
        catch (Exception exx) {
            System.err.println("[ChargFamille-AppelStat] - [Erreur] - Erreur  de la requete!");
             System.err.println("[ChargFamille-AppelStat] - [Message] - " + exx.getMessage());
        }
        finally{
         try {
            cs.close();
         } catch (Exception exx) {}}
 
      return statu;
  }
     // public void InsertFamille(String imma,String prenom,String site,String datsite,String datstate,String statue,String datnaiss ) throws SQLException{
  public Runnable ecriture = new Runnable() {
   @Override
  synchronized public void run() {
       PreparedStatement ps = null;
       ResultSet rs = null;
 
       try{
 
        while(true)
           {
 
              String t=queuee.take();
 
              if(t!="END_QUEUE")
               {
                   String[] tab=t.split("-");
 
       String requete="INSERT INTO ts_famille VALUES (?, ?, ?, ?, ?, ?, ?)";
       ps=conmysql.getConnexion().prepareStatement(requete);
 
 
 
 
       for(int j=0;j<tab.length;j++){
 
       switch(j+1)
       {
       case 1 : ps.setString(1,tab[0]);
       case 2 : ps.setString(2, tab[1]);
           case 3:
               ps.setString(3, tab[2]);
           case 4:
               ps.setString(4, tab[3]);
           case 5:
               ps.setString(5, tab[4]);
       case 6
               :ps.setString(6,tab[5]);
       case 7:ps.setString(7,tab[6]);
 
       }}ps.executeUpdate();}
 else{break;}}
       }
 
      catch (Exception exx) {
             System.err.println("[ChargFamille-InsertFamille1111] - [Erreur] - Erreur  de la requete!");
             System.err.println("[ChargFamille-InsertFamille] - [Message] - " + exx.getMessage());
        }
         try {
            ps.close();
         } catch (Exception exx) {}
           try {
            rs.close();
        } catch (Exception ex) {}
   }};
 
  } |