package com.sinosoft.lis.report.fin;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.f1j.swing.JBook;
import com.sinosoft.lis.db.LPrtTempleteDB;
import com.sinosoft.lis.finfee.PathTest;
import com.sinosoft.lis.finfee.PrintTest;
import com.sinosoft.lis.fininterface.FinPubFun;
import com.sinosoft.lis.pubfun.GlobalInput;
import com.sinosoft.lis.pubfun.PubFun;
import com.sinosoft.lis.report.PubReportInterface;
import com.sinosoft.print.show.VtsPrint;
import com.sinosoft.print.show.pdf.PdfJxlPrint;
import com.sinosoft.utility.CError;
import com.sinosoft.utility.CErrors;
import com.sinosoft.utility.ExeSQL;
import com.sinosoft.utility.ListTable;
import com.sinosoft.utility.SSRS;
import com.sinosoft.utility.TextTag;
import com.sinosoft.utility.TransferData;
import com.sinosoft.utility.VData;
import com.sinosoft.utility.XmlExportNew;
/*Auto Collection Summary/
public class Report_fin_6002 implements PubReportInterface {
public CErrors mErrors = new CErrors();
private VData mResult = new VData();
private TransferData mTransferData = new TransferData();
private String mTempleteID = "";
private XmlExportNew mXmlExport = new XmlExportNew();
private XmlExportNew NmXmlExport = new XmlExportNew();
private LPrtTempleteDB mLPrtTempleteDB = new LPrtTempleteDB();
private String currentdate =PubFun.getCurrentDate();
private String Date ="";
public Report_fin_6002() {
}
public boolean submitData(VData cInputData, String cOperate) {
if (!getInputData(cInputData)) {
return false;
}
mResult.clear();
if (!dealData()) {
return false;
}
// if (!dealXmlExport()) {
// return false;
// }
return true;
}
private boolean getInputData(VData cInputData) {
mTransferData = (TransferData) cInputData.getObjectByObjectName(
"TransferData", 0);
Date = (String) mTransferData.getValueByName("ReportDate");
System.out.println("Date------>>>>>>>"+Date);
mTempleteID = (String) mTransferData.getValueByName("TempleteID");
mLPrtTempleteDB.setTempleteID(mTempleteID);
if (mTempleteID != null && "".equals(mTempleteID)) {
this.mErrors.addOneError("获取模板数据时候出错!");
return false;
}
if (!mLPrtTempleteDB.getInfo()) {
this.mErrors.addOneError("获取模板数据时候出错!");
return false;
}
return true;
}
public VData getResult() {
return this.mResult;
}
private String getParaValue(String aParaName) {
String tReturn = (String) mTransferData.getValueByName(aParaName);
return tReturn;
}
private boolean dealData() {
System.out.println("自动收费总和报表6002");
String tOutputType = mLPrtTempleteDB.getOutputType();
String tTempleteName = mLPrtTempleteDB.getTempleteName();
String Firstday="";
String LastDay="";
Firstday = FinPubFun.getMonthFirstNatureDate(Date,Date); //获取第一个自然日
LastDay = FinPubFun.getMonthLastNatureDate(Date,Date); //获取最后一个自然日
System.out.println("------------------------------------------------");
System.out.println("LastDay"+LastDay);
System.out.println("Date"+Date);
System.out.println("------------------------------------------------");
mXmlExport.createDocument("006002", "zh", "0");
TextTag texttag = new TextTag();
texttag.add("ReportDate", Date);
texttag.add("ProcessDate", PubFun.getCurrentDate());
System.out.println("---------------------------------日报开始---------------------------------------------");
String sql="SELECT "
+ "a.MerchantID,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney),"
// + “b.paymode ,”
+ "b.acccode "
+ “FROM iftransactiondetail a,LJUnallocatedAccount b "
//String sql=“SELECT a.MerchantID,count(1),b.paycurrency,sum(b.dealmoney) FROM iftransactiondetail a,LJUnallocatedAccount b "
+ " WHERE a.transactiondetailid = b.otherno "
+ " AND b.othertype = ‘1’ AND a.tempfeeno = b.tempfeeno "
+ " AND a.TransactionSource = ‘CC’ "
+ " AND (a.transactionmode = ‘5’ OR a.transactionmode = ‘8’)”
+ " AND a.filetype = ‘0’ "
+ " AND a.othertype = ‘1’ "
+ " AND a.makedate = DATE’”+ Date + “’”
+ " group by "
+ “a.MerchantID,”
+ “paycurrency1,”
// + “b.paymode,”
+ “b.acccode”;
doListTable(sql,“RowInfo1”);
//原来:Bank Account,TotalNo,Currency,Total Amount
//现在:Bank Account,Total No,Currency,Total Amount
//DDA
String sql2="SELECT "
+ "b.acccode ,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney) "
+ "FROM iftransactiondetail a,LJUnallocatedAccount b "
+" WHERE a.transactiondetailid = b.otherno "
+" AND b.othertype = '1' AND a.tempfeeno = b.tempfeeno "
+" AND a.TransactionSource = 'FPS' "
+" AND a.transactionmode = '11'"
+" AND a.filetype = '0' "
+" AND a.othertype = '1' "
+" AND a.makedate = DATE'" + Date + "'"
+ " group by "
+ "paycurrency1,"
+ "b.acccode";
doListTable(sql2,"RowInfo2");
if (texttag.size() > 0) {
mXmlExport.addTextTag(texttag); // 将texttag填充到xmlexport中
}
this.mResult.add(mXmlExport);
FinReportPubFun deal=new FinReportPubFun();
if(!deal.dealXmlExport(mResult, Date, "FIN006002")){
this.mErrors.addOneError("报表生成失败!");
return false;
}
this.mResult.clear();
System.out.println("---------------------------------日报结束---------------------------------------------");
//原来:MerchantCode,Total No.,Currency,Total Amount
//现在:MerchantCode,Total No.,Currency,Total Amount,Type,Bank Account
//CCDDA
if(Date.equalsIgnoreCase(LastDay)) {
System.out.println("---------------------------------月报---------------------------------------------");
mXmlExport.createDocument("006002", "zh", "0");
String sql12="SELECT "
+ "a.MerchantID,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney),"
// + “b.paymode ,”
+ “b.acccode "
+ “FROM iftransactiondetail a,LJUnallocatedAccount b "
//String sql=“SELECT a.MerchantID,count(1),b.paycurrency,sum(b.dealmoney) FROM iftransactiondetail a,LJUnallocatedAccount b "
+ " WHERE a.transactiondetailid = b.otherno "
+ " AND b.othertype = ‘1’ AND a.tempfeeno = b.tempfeeno "
+ " AND a.TransactionSource = ‘CC’ "
//+ " AND a.transactionmode = ‘5’ "
+ " AND (a.transactionmode = ‘5’ OR a.transactionmode = ‘8’)”
+ " AND a.filetype = ‘0’ "
+ " AND a.othertype = ‘1’ "
//+ " AND a.makedate = DATE’”+ Date + “’”
+ " AND a.makedate between DATE’”+ Firstday + “’ and DATE’”+ LastDay + “’”
+ " group by "
+ “a.MerchantID,”
+ “paycurrency1,”
// + “b.paymode,”
+ “b.acccode”;
doListTable(sql12,“RowInfo1”);
String sql22="SELECT "
+ "b.acccode ,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney) "
+ "FROM iftransactiondetail a,LJUnallocatedAccount b "
+" WHERE a.transactiondetailid = b.otherno "
+" AND b.othertype = '1' AND a.tempfeeno = b.tempfeeno "
+" AND a.TransactionSource = 'FPS' "
+" AND a.transactionmode = '11'"
+" AND a.filetype = '0' "
+" AND a.othertype = '1' "
//+" AND a.makedate = DATE'" + Date + "'"
+ " AND a.makedate between DATE'"+ Firstday + "' and DATE'"+ LastDay + "'"
+ " group by "
+ "paycurrency1,"
+ "b.acccode";
doListTable(sql22,"RowInfo2");
if (texttag.size() > 0) {
mXmlExport.addTextTag(texttag); // 将texttag填充到xmlexport中
}
this.mResult.add(mXmlExport);
FinReportPubFun deal2=new FinReportPubFun();
if(!deal2.dealXmlExport(mResult, Date, "FIN006002")){
this.mErrors.addOneError("报表生成失败!");
return false;
}
this.mResult.clear();
System.out.println("---------------------------------月报---------------------------------------------");
}// end 月报结束
return true;
}
private void doListTable(String sql,String listName){
ListTable tlistTable = new ListTable();
tlistTable.setName(listName);// 循环体名称
SSRS cS = new SSRS();
cS=new ExeSQL().execSQL(sql);
String strArr[] = null;
strArr = new String[cS.getMaxCol()];
for (int a = 1; a <= cS.getMaxRow(); a++) {
/** 将所得到得符合条件得记录逐条加入到strArr中相应得位置中 */
for (int b = 1; b <= cS.getMaxCol(); b++) {
strArr[b - 1] = cS.GetText(a, b);
}
tlistTable.add(strArr);
strArr = new String[cS.getMaxCol()];
}
mXmlExport.addListTable(tlistTable, strArr);
}
private String getBankAccNo1(String aStr) {
if (aStr.length() != 14) {
return aStr;
} else {
StringBuffer DecString = new StringBuffer(aStr);
DecString = DecString.insert(3, "-").insert(7, "-").insert(9, "-")
.insert(16, "-");
return DecString.toString();
}
}
删减:
package com.juan;
/*Auto Collection Summary/
public class Report_fin_6002 {
private void dealData() {
String sql="SELECT "
+ "a.MerchantID,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney),"
// + "b.paymode ,"
+ "b.acccode "
+ "FROM iftransactiondetail a,LJUnallocatedAccount b "
//String sql="SELECT a.MerchantID,count(1),b.paycurrency,sum(b.dealmoney) FROM iftransactiondetail a,LJUnallocatedAccount b "
+ " WHERE a.transactiondetailid = b.otherno "
+ " AND b.othertype = '1' AND a.tempfeeno = b.tempfeeno "
+ " AND a.TransactionSource = 'CC' "
+ " AND (a.transactionmode = '5' OR a.transactionmode = '8')"
+ " AND a.filetype = '0' "
+ " AND a.othertype = '1' "
+ " AND a.makedate = DATE'"+ Date + "'"
+ " group by "
+ "a.MerchantID,"
+ "paycurrency1,"
// + "b.paymode,"
+ "b.acccode";
//原来:Bank Account,TotalNo,Currency,Total Amount
//现在:Bank Account,Total No,Currency,Total Amount
//DDA
String sql2="SELECT "
+ "b.acccode ,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney) "
+ "FROM iftransactiondetail a,LJUnallocatedAccount b "
+" WHERE a.transactiondetailid = b.otherno "
+" AND b.othertype = '1' AND a.tempfeeno = b.tempfeeno "
+" AND a.TransactionSource = 'FPS' "
+" AND a.transactionmode = '11'"
+" AND a.filetype = '0' "
+" AND a.othertype = '1' "
+" AND a.makedate = DATE'" + Date + "'"
+ " group by "
+ "paycurrency1,"
+ "b.acccode";
String sql3="SELECT "
+ "a.MerchantID,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney),"
// + "b.paymode ,"
+ "b.acccode "
+ "FROM iftransactiondetail a,LJUnallocatedAccount b "
//String sql="SELECT a.MerchantID,count(1),b.paycurrency,sum(b.dealmoney) FROM iftransactiondetail a,LJUnallocatedAccount b "
+ " WHERE a.transactiondetailid = b.otherno "
+ " AND b.othertype = '1' AND a.tempfeeno = b.tempfeeno "
+ " AND a.TransactionSource = 'CC' "
//+ " AND a.transactionmode = '5' "
+ " AND (a.transactionmode = '5' OR a.transactionmode = '8')"
+ " AND a.filetype = '0' "
+ " AND a.othertype = '1' "
//+ " AND a.makedate = DATE'"+ Date + "'"
+ " AND a.makedate between DATE'"+ Firstday + "' and DATE'"+ LastDay + "'"
+ " group by "
+ "a.MerchantID,"
+ "paycurrency1,"
// + "b.paymode,"
+ "b.acccode";
String sql4="SELECT "
+ "b.acccode ,"
+ "count(1),"
+ "(case b.paycurrency when '13' then 'HKD' when '14' then 'USD' else 'CNY' end) as paycurrency1,"
+ "sum(b.dealmoney) "
+ "FROM iftransactiondetail a,LJUnallocatedAccount b "
+" WHERE a.transactiondetailid = b.otherno "
+" AND b.othertype = '1' AND a.tempfeeno = b.tempfeeno "
+" AND a.TransactionSource = 'FPS' "
+" AND a.transactionmode = '11'"
+" AND a.filetype = '0' "
+" AND a.othertype = '1' "
//+" AND a.makedate = DATE'" + Date + "'"
+ " AND a.makedate between DATE'"+ Firstday + "' and DATE'"+ LastDay + "'"
+ " group by "
+ "paycurrency1,"
+ "b.acccode";
System.out.println(sql+"\n\n\n\n");
System.out.println(sql2+"\n\n\n\n");
System.out.println(sql3+"\n\n\n\n");
System.out.println(sql4+"\n\n\n\n");
}
private static String Firstday,LastDay,Date;
public static void main(String[] args) {
Firstday="2019-11-1";
LastDay="2019-11-30";
Date="2019-11-30";
new Report_fin_6002().dealData();
}
}
需复制对象:
结果: