while ((linha=in.readLine()) != null) {
// ordem dos campos: cod_lit;Janeiro de 2006 at� Fevereiro de 2007;
String[] campos = linha.split(";");
if(campos != null) {
TempBean tempBean = new TempBean();
// Janeiro/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("1"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[1]));
listTempBean.add(tempBean);
}
// Fevereiro/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("2"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[2]));
listTempBean.add(tempBean);
}
// Mar�o/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("3"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[3]));
listTempBean.add(tempBean);
}
// Abril/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("4"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[4]));
listTempBean.add(tempBean);
}
// Maio/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("5"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[5]));
listTempBean.add(tempBean);
}
// Junho/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("6"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[6]));
listTempBean.add(tempBean);
}
// Julho/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("7"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[7]));
listTempBean.add(tempBean);
}
// Agosto/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("8"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[8]));
listTempBean.add(tempBean);
}
// Setembro/2006
if(!codCidadeManfrinopolis.equals(campos[0])) {
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("9"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[9]));
listTempBean.add(tempBean);
}
// Outubro/2006
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("10"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[10]));
listTempBean.add(tempBean);
// Novembro/2006
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("11"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[11]));
listTempBean.add(tempBean);
// Dezembro/2006
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("12"));
tempBean.setAno(Integer.valueOf("2006"));
tempBean.setQtde(Double.valueOf(campos[12]));
listTempBean.add(tempBean);
// Janeiro/2007
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("1"));
tempBean.setAno(Integer.valueOf("2007"));
tempBean.setQtde(Double.valueOf(campos[13]));
listTempBean.add(tempBean);
// Fevereiro/2007
tempBean = new TempBean();
tempBean.setCodLit(Long.valueOf(campos[0]));
tempBean.setMes(Integer.valueOf("2"));
tempBean.setAno(Integer.valueOf("2007"));
tempBean.setQtde(Double.valueOf(campos[14]));
listTempBean.add(tempBean);
}
registrosLidos++;
}
System.out.println("registrosLidos: " + registrosLidos);
System.out.println("Iniciando transacao...");
tx = session.beginTransaction();
Dao dao = new Dao();
AcompRealFisicoDao arfDao = new AcompRealFisicoDao(null);
Iterator it = listTempBean.iterator();
while(it.hasNext()) {
TempBean bean = (TempBean)it.next();
LocalItemLit lit = (LocalItemLit)dao.buscar(LocalItemLit.class, bean.getCodLit());
AcompRealFisicoArf arf = arfDao.buscarPorIettir(Long.valueOf(bean.getMes()), Long.valueOf(bean.getAno()), Long.valueOf("1187"));
if(lit == null || arf == null) {
throw new Exception("lit == null || arf == null");
}
AcompRealFisicoLocalArfl arfl = new AcompRealFisicoLocalArfl();
arfl.setLocalItemLit(lit);
arfl.setAcompRealFisicoArf(arf);
arfl.setQuantidadeArfl(bean.getQtde());
session.save(arfl);
}
//int i = Integer.parseInt("asdasd.as;;");