public VoucherInfo generateTextFile(VoucherInfo info11)throws Exception
{
VoucherInfo info=new VoucherInfo();
log.info("VoucherDAO : generateTextFile enter method");
String message="";
Connection con=null;
ResultSet rs=null,rs1=null;
PreparedStatement pst=null,pst1=null;
String accountno="";
DecimalFormat df1 = new DecimalFormat("000000.00");
DecimalFormat df2 = new DecimalFormat("############.00");
DecimalFormat df3 = new DecimalFormat("000000000000.00");
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = new Date();
String sysdate=dateFormat.format(date);
try{
String str="";
String withoutstr="";
String totalstr="";
StringBuffer displayString=new StringBuffer();
String displaytext="";
int kk=0;
// String newLine = String.format("%n");
// String text = "First line" + newLine + "Second line";
String sline=SystemUtils.LINE_SEPARATOR;
double totAmt=0.0;
BufferedWriter output = null;
String line_separator = "\r\n";
FileWriter file=null;
con=DBUtility.getMultipleConnection(info11.getDepartment());
pst = con.prepareStatement(getQueries("reportQuery1"));
pst.setString(1, info11.getKeyNo()); //reportDtQuery
pst.executeQuery();
rs=pst.executeQuery();
while(rs.next())
{
info = new VoucherInfo();
accountno=StringUtility.checknull(rs.getString("accountno"));
info.setEmpbankaccountno(rs.getString("empbankaccountno"));
info.setPartyType(StringUtility.checknull(rs.getString("partytype")));
log.info("rs.getString(accountno) : "+rs.getString("accountno"));
}
if(rs!=null)
rs.close();
if(pst!=null)
pst.close();
String dtQuery="";
if(!info.getPartyType().equals("N"))
dtQuery=getQueries("reportDtQuery1");
if(info.getPartyType().equals("N"))
dtQuery=getQueries("retiremedicalQuery");
pst = con.prepareStatement(dtQuery);
pst.setString(1, info11.getKeyNo()); //reportDtQuery
pst.executeQuery();
rs1=pst.executeQuery();
String fName="";
log.info("info11.getKeyNo()"+info11.getKeyNo());
String empaccountno="";
while(rs1.next()) {
empaccountno="";
/*info.setAmount(df2.format(rs1.getDouble("debit")));*/
if(accountno.equals("")) {
file=new FileWriter(info11.getPath()+"\\ALL.txt");
fName="ALL.txt";
}
else
if(accountno.equals("11084236539")) {
//SBI
if(!info.getPartyType().equals("M") && !info.getPartyType().equals("N"))
empaccountno=StringUtility.checknull(info.getEmpbankaccountno());
if(info.getPartyType().equals("M") ||info.getPartyType().equals("N"))
empaccountno=StringUtility.checknull(rs1.getString("EMPACCOUNTNO"));
info.setTextFormat(""+StringUtility.checknull(empaccountno)+"`"+StringUtility.checknull(rs1.getString("ifsccode"))+"`"+sysdate+"``"+(rs1.getDouble("amount"))+"``"+info11.getDepartment()+"_PAYMENT");
displaytext=info.getTextFormat();
displaytext+=line_separator;
str+=displaytext;
if(!info.getPartyType().equals("N"))
info.setAmount(rs1.getString("debit"));
if(info.getPartyType().equals("N"))
info.setAmount(rs1.getString("amount"));
file =new FileWriter(info11.getPath()+"\\SBI.txt");
fName="SBI.txt";
}
else if(accountno.equals("91103150000018")) {
log.info("i getTextFormat nfo :------------------------"+accountno);
// Syndicate Bank
if(!info.getPartyType().equals("M")&& !info.getPartyType().equals("N"))
empaccountno=StringUtility.checknull(info.getEmpbankaccountno());
if(info.getPartyType().equals("M") || info.getPartyType().equals("N"))
empaccountno=StringUtility.checknull(rs1.getString("EMPACCOUNTNO"));
info.setTextFormat("CH "+StringUtility.checknull(empaccountno)+" C 000000"+(rs1.getDouble("amount"))+" "+StringUtility.checknull(rs1.getString("ifsccode"))+" "+info11.getDepartment()+"_PAYMENT ");
displaytext=info.getTextFormat();
displaytext+=line_separator;
str+=displaytext;
if(!info.getPartyType().equals("N"))
info.setAmount(rs1.getString("debit"));
if(info.getPartyType().equals("N"))
info.setAmount(rs1.getString("amount"));
log.info("i getTextFormat nfo :------------------------"+info.getTextFormat());
file =new FileWriter(info11.getPath()+"\\SYNDICATEBANK.txt");
fName="SYNDICATEBANK.txt";
}
if(!info.getPartyType().equals("N"))
totAmt+=(rs1.getDouble("debit")-rs1.getDouble("credit"));
if(info.getPartyType().equals("N"))
totAmt+=rs1.getDouble("amount");
}
if(accountno.equals("91103150000018")) {
displaytext="CH 91103150000018 D "+df3.format(totAmt)+" 00000000 "+info11.getDepartment()+"_AMOUNT ";
displaytext+=line_separator;
totalstr+=displaytext;
if(!info.getPartyType().equals("M") && !info.getPartyType().equals("N"))
{
withoutstr="CH "+StringUtility.checknull(empaccountno)+" C 000000"+df3.format(totAmt)+" 00000000 "+info11.getDepartment()+"_PAYMENT ";
withoutstr+=line_separator;
}
}
else if(accountno.equals("11084236539")) {
displaytext="11084236539`10648`"+sysdate+"`"+df2.format(totAmt)+"``"+info11.getDepartment()+"_AMOUNT`";
displaytext+=line_separator;
totalstr+=displaytext;
if(!info.getPartyType().equals("M") && !info.getPartyType().equals("N"))
{
withoutstr=""+StringUtility.checknull(empaccountno)+"`00000`"+sysdate+"``"+df2.format(totAmt)+"``"+info11.getDepartment()+"_PAYMENT";
withoutstr+=line_separator;
}
}
displayString.append(totalstr);
if(info.getPartyType().equals("M") || info.getPartyType().equals("N"))
displayString.append(str);
if(!info.getPartyType().equals("M") && !info.getPartyType().equals("N"))
displayString.append(withoutstr);
file.write(displayString.toString());
file.close();
info.setPath(info11.getPath()+"\\"+fName);
/* if(textFormat.equals("1")) {
if(bankId.equals("2")) {
//log.info("Syndicate bank");
info.setTextSynb("CH "+rs.getString("BACNO")+" C 000000"+df1.format(rs.getDouble("NETAMOUNT"))+" 00000000 SALARY AMOUNT ");
}
if(bankId.equals("1")) {
//30141222500`00000`29/05/2012``14185.00`SALARAY`SALARY PAYMENTS`
//log.info("SBI");
info.setTextSynb(""+rs.getString("BACNO")+"`00000`"+sysdate+"``"+df2.format(rs.getDouble("NETAMOUNT"))+"`SALARAY`SALARY PAYMENTS`");
}
}
*/
message="Release Date Updated Successfully";
}
catch(Exception e)
{
e.printStackTrace();
}
finally {
try {
if(rs1!=null)
rs1.close();
if(pst1!=null)
pst1.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
//ending
log.info("the message is..."+message);
return info;
}
No comments:
Post a Comment