| | |
| | | |
| | | return; |
| | | } |
| | | String strStep0SQLNDD_rt="truncate table ndd.typhoon_rt"; |
| | | // String strStep0SQLNDD_rt="truncate table ndd.typhoon_rt"; |
| | | |
| | | logger.info("begin nddxml to postsql"); |
| | | logger.info("getftpfile..."); |
| | |
| | | t1= t1.substring(t1.length()-2); |
| | | String insertDBSQL=" insert into ndd.nddcanton_history (project_id,department_id,county_id,district_id,neighbor_id,affectcustomers,affectcustomersever"+ |
| | | ",yy,mm,dd,tt,ts_ser) values "; |
| | | String strStep1SQLNDD_rt="insert into ndd.typhoon_rt(dts,county_id,district_id,neighbor_id,c0,c1)"; |
| | | // String strStep1SQLNDD_rt="insert into ndd.typhoon_rt(dts,county_id,district_id,neighbor_id,c0,c1)"; |
| | | |
| | | |
| | | sqlExec(postsql,strStep0SQLNDD_rt,new String[]{}); |
| | | // sqlExec(postsql,strStep0SQLNDD_rt,new String[]{}); |
| | | |
| | | for(int j=0;j<arraySQLVals.size();j++) |
| | | { |
| | |
| | | yy+mm+dd+"."+t0+t1 |
| | | ) , |
| | | new String[]{}); |
| | | sqlExec(postsql,strStep1SQLNDD_rt+ |
| | | /* sqlExec(postsql,strStep1SQLNDD_rt+ |
| | | String.format(" values('%s',%s )", |
| | | yy+mm+dd+"."+t0+t1,arraySQLValsForTyphoon.get(j) |
| | | ),new String[]{} |
| | | ); |
| | | );*/ |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | private void doJob3(Connection postsql, String[] info) throws SQLException |
| | | { |
| | | // double switch (if db = enable -->work) |
| | | //Here is check |
| | | Date dtnow = new Date(); |
| | | //get all file |
| | | //dept, count,dist,nei ,y,m,d,t,custom |
| | | // HashMap<String> |
| | | String typhoonName=""; |
| | | String typhoonID=""; |
| | | String department=""; |
| | | String county=""; |
| | | String district=""; |
| | | String neighbor=""; |
| | | String affectCustomers=""; |
| | | String affectCustomersEver=""; |
| | | String[] tmpArray; |
| | | String sTemp; |
| | | List<String> arraySQLVals= new ArrayList<String>(); |
| | | List<String> arraySQLValsForTyphoon= new ArrayList<String>(); |
| | | boolean bActiveCheckDBSchedule=true; |
| | | |
| | | |
| | | if(!jobOnLine(postsql, "nddcanton")&& bActiveCheckDBSchedule) |
| | | { |
| | | |
| | | return; |
| | | } |
| | | String strStep0SQLNDD_rt="truncate table ndd.typhoon_rt"; |
| | | |
| | | logger.info("begin nddroad to postsql"); |
| | | logger.info("getftpfile..."); |
| | | String[] xmls= getNDDStrings(info, "*NDSExt.xml") ; |
| | | |
| | | |
| | | logger.info(String.format("total %d file(s)",xmls.length)); |
| | | for(int iRow=0;iRow<xmls.length;iRow++) |
| | | { |
| | | arraySQLVals.clear(); |
| | | arraySQLValsForTyphoon.clear(); |
| | | tmpArray= xmls[iRow].split("\n"); |
| | | for(int iLine=0;iLine<tmpArray.length;iLine++) |
| | | { |
| | | sTemp= findValue(tmpArray[iLine],"typhoonName"); |
| | | if(sTemp.length()>0) |
| | | { |
| | | typhoonName= sTemp; |
| | | typhoonID= getTyphoonIDByName(postsql,typhoonName); |
| | | // |
| | | sTemp= findValue(tmpArray[iLine],"Department id"); |
| | | department=sTemp; |
| | | } |
| | | |
| | | sTemp= findValue(tmpArray[iLine],"county ufid"); |
| | | if(sTemp.length()>0) |
| | | { |
| | | county=sTemp; |
| | | } |
| | | sTemp= findValue(tmpArray[iLine],"district ufid"); |
| | | if(sTemp.length()>0) |
| | | { |
| | | district=sTemp; |
| | | } |
| | | sTemp= findValue(tmpArray[iLine],"neighbor ufid"); |
| | | if(sTemp.length()>0) |
| | | { |
| | | neighbor=sTemp; |
| | | sTemp= findValue(tmpArray[iLine],"affectCustomers"); |
| | | if(sTemp.length()>0) |
| | | { |
| | | affectCustomers=sTemp; |
| | | } |
| | | else |
| | | { |
| | | affectCustomers="0"; |
| | | } |
| | | |
| | | sTemp= findValue(tmpArray[iLine],"affectCustomersEver"); |
| | | if(sTemp.length()>0) |
| | | { |
| | | affectCustomersEver=sTemp; |
| | | } |
| | | else |
| | | { |
| | | affectCustomersEver="0"; |
| | | } |
| | | arraySQLVals.add(String.format("(%s,%s,%s,%s,%s,%s,%s",typhoonID,department,county,district,neighbor,affectCustomers,affectCustomersEver)); |
| | | arraySQLValsForTyphoon.add(String.format("%s,%s,%s,%s,%s",county,district,neighbor,affectCustomers,affectCustomersEver)); |
| | | // insert into nddcanton_history (project_id,department_id,county_id,district_id,neighbor_id,affectcustomers,affectcustomersever |
| | | //yy,mm,dd,tt |
| | | } |
| | | |
| | | } |
| | | //!! |
| | | String yy="0000"+String.valueOf( dtnow.getYear()+1900); |
| | | String mm="00"+String.valueOf( dtnow.getMonth()+1); |
| | | String dd="00"+String.valueOf( dtnow.getDate()); |
| | | String t0="00"+ String.valueOf( dtnow.getHours()); |
| | | String t1="00"+ String.valueOf( dtnow.getMinutes()); |
| | | yy= yy.substring(yy.length()-4); |
| | | mm= mm.substring(mm.length()-2); |
| | | dd= dd.substring(dd.length()-2); |
| | | t0= t0.substring(t0.length()-2); |
| | | t1= t1.substring(t1.length()-2); |
| | | String insertDBSQL=" insert into ndd.nddcanton_history (project_id,department_id,county_id,district_id,neighbor_id,affectcustomers,affectcustomersever"+ |
| | | ",yy,mm,dd,tt,ts_ser) values "; |
| | | String strStep1SQLNDD_rt="insert into ndd.typhoon_rt(dts,county_id,district_id,neighbor_id,c0,c1)"; |
| | | |
| | | |
| | | sqlExec(postsql,strStep0SQLNDD_rt,new String[]{}); |
| | | |
| | | for(int j=0;j<arraySQLVals.size();j++) |
| | | { |
| | | |
| | | sqlExec(postsql,insertDBSQL + arraySQLVals.get(j)+ |
| | | String.format(",%s,%s,%s,'%s%s',%s)", |
| | | yy,mm,dd,t0,t1, |
| | | yy+mm+dd+"."+t0+t1 |
| | | ) , |
| | | new String[]{}); |
| | | sqlExec(postsql,strStep1SQLNDD_rt+ |
| | | String.format(" values('%s',%s )", |
| | | yy+mm+dd+"."+t0+t1,arraySQLValsForTyphoon.get(j) |
| | | ),new String[]{} |
| | | ); |
| | | } |
| | | |
| | | |
| | | String strSQLUpdateCurr="update ndd.currdata set yy='%s',mm='%s',dd='%s',tt='%s%s' where sr=1"; |
| | | sqlExec(postsql, |
| | | String.format(strSQLUpdateCurr, |
| | | yy,mm,dd,t0,t1 |
| | | ) , |
| | | new String[]{}); |
| | | logger.info(String.format("next xml")); |
| | | } |
| | | logger.info(String.format("done")); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /* |
| | | private void doJob(Connection postsql,Connection orcl) throws SQLException |