public void actionPrintPreview_actionPerformed(ActionEvent e)
throws Exception
{
checkSelected();
ArrayList idList = super.getSelectedIdValues();
if ((idList == null) || (idList.size() == 0) || (getTDFileName() == null))
return;
BOSQueryDelegate data = new PaymentAdvicePrintDataProvider(idList);
KDNoteHelper appHlp = new KDNoteHelper();
appHlp.printPreview(getTDFileName(), data, SwingUtilities.getWindowAncestor(this));
}
public class PaymentAdvicePrintDataProvider
implements ICrossPrintDataProvider
{
private static Logger logger = Logger.getLogger(PaymentAdvicePrintDataProvider.class);
public static final String[] col = { "id", "startdate", "enddate", "appdate", "appamount", "actamount", "contractname", "roomname", "projectname", "customer", "moneyname", "balance", "tarea", "arrearageday" };
public static final String[] col1 = { "comment" };
private Set ids = null;
private boolean ishasNext = true;
public PaymentAdvicePrintDataProvider(List id)
{
this.ids = new HashSet(id);
}
public boolean hasNext()
{
if (this.ishasNext) {
this.ishasNext = false;
return true;
}
return false;
}
private List getCC()
{
FDCSQLBuilder zfsqlBuilder = new FDCSQLBuilder();
zfsqlBuilder.appendSql(" select tenancyBill.fid as billID,tenancyCustomerEntry.ffdccustomerid as customerID ,fdccustomer.fname_l2 as customer ").appendSql(" from T_TEN_TenancyCustomerEntry tenancyCustomerEntry ").appendSql(" join T_TEN_TenancyBill tenancyBill on tenancyBill.fid = tenancyCustomerEntry.ftenancybillid ").appendSql(" left join T_SHE_FDCCustomer fdccustomer on fdccustomer.fid = tenancyCustomerEntry.ffdccustomerid ").appendSql(" left join T_SHE_SellProject SellProject on tenancyBill.FSellProjectID =SellProject.Fid ");
IRowSet zfrs = null;
try {
zfrs = zfsqlBuilder.executeQuery();
} catch (BOSException e) {
ExceptionHandler.handle(e.getMessage(), e);
}
List ccList = new ArrayList();
try {
Map cc = null;
if (zfrs != null)
while (zfrs.next()) {
cc = new HashMap();
String billId = zfrs.getString("billId");
String customername = zfrs.getString("customer");
cc.put("billId", billId);
cc.put("customername", customername);
ccList.add(cc);
}
}
catch (SQLException e) {
logger.debug(e);
}
return ccList;
}
public IRowSet execute(BOSQueryDataSource ds)
{
IRowSet iRowSet = null;
DynamicRowSet row = null;
try
{
if ("MAINBILL".equals(ds.getID().toUpperCase()))
{
row = new DynamicRowSet(col.length);
for (int i = 0; i < col.length; i++) {
ColInfo ci = new ColInfo();
ci.colType = 12;
ci.columnName = col[i];
ci.nullable = 1;
row.setColInfo(i + 1, ci);
}
iRowSet = PaymentAdvicePrintFacadeFactory.getRemoteInstance().getPrintData(this.ids);
while (iRowSet.next()) {
String contractname = iRowSet.getString("contractname");
String roomname = "";
if (iRowSet.getString("contractname") != null) {
if (iRowSet.getString("contractname").equals(iRowSet.getString("roomname")))
roomname = "";
else
roomname = iRowSet.getString("roomname");
}
else {
roomname = iRowSet.getString("roomname");
}
String projectname = iRowSet.getString("projectname");
String customer = "";
Map cc = null;
String contractid = iRowSet.getString("contractid");
int i = 0;
List ccList = getCC();
for (Iterator iter = ccList.iterator(); iter.hasNext(); ) {
cc = (HashMap)iter.next();
if ((cc.containsKey("billId")) && (cc.get("billId") != null)) {
String billId = cc.get("billId").toString();
if (billId.equals(contractid)) {
if (i == 0) {
customer = customer + cc.get("customername").toString();
i = 1;
} else {
customer = customer + "," + cc.get("customername").toString();
}
}
}
}
String moneyname = iRowSet.getString("moneyname");
java.sql.Date startdate = null;
if (iRowSet.getDate("startdate") != null) {
startdate = iRowSet.getDate("startdate");
}
java.sql.Date enddate = null;
if (iRowSet.getDate("startdate") != null) {
enddate = iRowSet.getDate("enddate");
}
java.sql.Date appdate = iRowSet.getDate("appdate");
Integer arrearageDay = getArrearageDay(appdate);
BigDecimal appamount = FDCHelper.divide(iRowSet.getBigDecimal("appamount"), new BigDecimal("1"));
BigDecimal actamount1 = null;
if (iRowSet.getBigDecimal("actamount") == null)
actamount1 = new BigDecimal("0");
else {
actamount1 = iRowSet.getBigDecimal("actamount");
}
BigDecimal tamount = null;
if (iRowSet.getBigDecimal("tamount") == null)
tamount = new BigDecimal("0");
else {
tamount = iRowSet.getBigDecimal("tamount");
}
BigDecimal ramount = null;
if (iRowSet.getBigDecimal("ramount") == null)
ramount = new BigDecimal("0");
else {
ramount = iRowSet.getBigDecimal("ramount");
}
BigDecimal aamount = null;
if (iRowSet.getBigDecimal("aamount") == null)
aamount = new BigDecimal("0");
else {
aamount = iRowSet.getBigDecimal("aamount");
}
BigDecimal tarea = null;
if (iRowSet.getBigDecimal("tarea") != null) {
if (iRowSet.getBigDecimal("tarea").compareTo(new BigDecimal("-1")) != 0)
tarea = iRowSet.getBigDecimal("tarea");
else
tarea = new BigDecimal("0");
}
else {
tarea = new BigDecimal("0");
}
tarea = FDCHelper.divide(tarea, new BigDecimal("1"));
BigDecimal actamount = actamount1.subtract(tamount).subtract(ramount).subtract(aamount);
actamount = FDCHelper.divide(actamount, new BigDecimal("1"));
BigDecimal balance = FDCHelper.subtract(appamount, actamount);
String id = iRowSet.getString("id");
row.moveToInsertRow();
row.updateString("contractname", contractname);
row.updateString("roomname", roomname);
row.updateString("projectname", projectname);
row.updateString("customer", customer);
row.updateString("moneyname", moneyname);
row.updateString("startdate", startdate == null ? "" : startdate.toString());
row.updateString("enddate", enddate == null ? "" : enddate.toString());
row.updateDate("appdate", appdate);
row.updateBigDecimal("tarea", tarea);
if (actamount == null) {
actamount = FDCHelper.ZERO;
}
if (appamount == null) {
appamount = FDCHelper.ZERO;
}
row.updateBigDecimal("appamount", appamount);
row.updateBigDecimal("actamount", actamount);
row.updateBigDecimal("balance", balance);
row.updateInt("arrearageday", arrearageDay.intValue());
row.updateString("id", id);
row.insertRow();
}
}
}
catch (BOSException e)
{
e.printStackTrace();
}
catch (SQLException e) {
e.printStackTrace();
}
return row;
}
public Integer getArrearageDay(java.sql.Date appdate)
{
java.util.Date now = DateHelper.getDayBegin();
int i = DateHelper.getDiffDays(DateHelper.getDayBegin(appdate), now) - 1;
return new Integer(i);
}
}
自定义套打元数据
最新推荐文章于 2023-10-31 19:47:25 发布