/**
 * output package name
 */
package com.kingdee.eas.custom.gggl.client;

import java.awt.Frame;
import java.awt.event.*;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.swing.event.TreeSelectionEvent;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.ui.face.UIRuleUtil;
import com.kingdee.bos.ctrl.data.engine.rows.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTDataRequestManager;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.kdf.table.event.KDTDataRequestEvent;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.base.permission.client.longtime.ILongTimeTask;
import com.kingdee.eas.base.permission.client.longtime.LongTimeDialog;
import com.kingdee.eas.basedata.org.FullOrgUnitFactory;
import com.kingdee.eas.basedata.org.FullOrgUnitInfo;
import com.kingdee.eas.basedata.org.OrgStructureInfo;
import com.kingdee.eas.custom.gggl.ZtSignContractReportFacadeFactory;
import com.kingdee.eas.framework.*;
import com.kingdee.eas.framework.report.ICommRptBase;
import com.kingdee.eas.framework.report.client.CommRptBaseConditionUI;
import com.kingdee.eas.framework.report.util.RptParams;
import com.kingdee.eas.framework.report.util.RptRowSet;
import com.kingdee.eas.framework.report.util.RptTableHeader;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.MsgBox;
import com.kingdee.eas.xr.helper.DateXRHelper;

/**
 * output class name
 */
public class ZtSignContractReport extends AbstractZtSignContractReport
{
	private static final Logger logger = CoreUIObject.getLogger(ZtSignContractReport.class);
	private boolean isOnLoad = false;
	private boolean isQuery = false;
	/**
	 * output class constructor
	 */
	public ZtSignContractReport() throws Exception
	{
		super();
		kDTable1.checkParsed();
		kDTable1.getDataRequestManager().addDataRequestListener(this);
		kDTable1.getDataRequestManager().setDataRequestMode(KDTDataRequestManager.REAL_MODE);
		enableExportExcel(kDTable1);
	}

	/**
	 * output storeFields method
	 */
	public void storeFields()
	{
		super.storeFields();
	}
	@Override
	public void onLoad() throws Exception {
		// TODO Auto-generated method stub
		setShowDialogOnLoad(false);
		isOnLoad=true;
		kDTable1.getStyleAttributes().setLocked(true);

		super.onLoad();

		isOnLoad=false;
		btnQuery.setVisible(false);
		setUITitle("中庭租赁位签约情况表");
	}
	/**
	 * output actionPageSetup_actionPerformed
	 */
	public void actionPageSetup_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionPageSetup_actionPerformed(e);
	}

	/**
	 * output actionExitCurrent_actionPerformed
	 */
	public void actionExitCurrent_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionExitCurrent_actionPerformed(e);
	}

	/**
	 * output actionHelp_actionPerformed
	 */
	public void actionHelp_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionHelp_actionPerformed(e);
	}

	/**
	 * output actionAbout_actionPerformed
	 */
	public void actionAbout_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionAbout_actionPerformed(e);
	}

	/**
	 * output actionOnLoad_actionPerformed
	 */
	public void actionOnLoad_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionOnLoad_actionPerformed(e);
	}

	/**
	 * output actionSendMessage_actionPerformed
	 */
	public void actionSendMessage_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionSendMessage_actionPerformed(e);
	}

	/**
	 * output actionCalculator_actionPerformed
	 */
	public void actionCalculator_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionCalculator_actionPerformed(e);
	}

	/**
	 * output actionExport_actionPerformed
	 */
	public void actionExport_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionExport_actionPerformed(e);
	}

	/**
	 * output actionExportSelected_actionPerformed
	 */
	public void actionExportSelected_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionExportSelected_actionPerformed(e);
	}

	/**
	 * output actionRegProduct_actionPerformed
	 */
	public void actionRegProduct_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionRegProduct_actionPerformed(e);
	}

	/**
	 * output actionPersonalSite_actionPerformed
	 */
	public void actionPersonalSite_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionPersonalSite_actionPerformed(e);
	}

	/**
	 * output actionProcductVal_actionPerformed
	 */
	public void actionProcductVal_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionProcductVal_actionPerformed(e);
	}

	/**
	 * output actionExportSave_actionPerformed
	 */
	public void actionExportSave_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionExportSave_actionPerformed(e);
	}

	/**
	 * output actionExportSelectedSave_actionPerformed
	 */
	public void actionExportSelectedSave_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionExportSelectedSave_actionPerformed(e);
	}

	/**
	 * output actionKnowStore_actionPerformed
	 */
	public void actionKnowStore_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionKnowStore_actionPerformed(e);
	}

	/**
	 * output actionAnswer_actionPerformed
	 */
	public void actionAnswer_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionAnswer_actionPerformed(e);
	}

	/**
	 * output actionRemoteAssist_actionPerformed
	 */
	public void actionRemoteAssist_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionRemoteAssist_actionPerformed(e);
	}

	/**
	 * output actionPopupCopy_actionPerformed
	 */
	public void actionPopupCopy_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionPopupCopy_actionPerformed(e);
	}

	/**
	 * output actionHTMLForMail_actionPerformed
	 */
	public void actionHTMLForMail_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionHTMLForMail_actionPerformed(e);
	}

	/**
	 * output actionExcelForMail_actionPerformed
	 */
	public void actionExcelForMail_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionExcelForMail_actionPerformed(e);
	}

	/**
	 * output actionHTMLForRpt_actionPerformed
	 */
	public void actionHTMLForRpt_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionHTMLForRpt_actionPerformed(e);
	}

	/**
	 * output actionExcelForRpt_actionPerformed
	 */
	public void actionExcelForRpt_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionExcelForRpt_actionPerformed(e);
	}

	/**
	 * output actionLinkForRpt_actionPerformed
	 */
	public void actionLinkForRpt_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionLinkForRpt_actionPerformed(e);
	}

	/**
	 * output actionPopupPaste_actionPerformed
	 */
	public void actionPopupPaste_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionPopupPaste_actionPerformed(e);
	}

	/**
	 * output actionToolBarCustom_actionPerformed
	 */
	public void actionToolBarCustom_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionToolBarCustom_actionPerformed(e);
	}

	/**
	 * output actionCloudFeed_actionPerformed
	 */
	public void actionCloudFeed_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionCloudFeed_actionPerformed(e);
	}

	/**
	 * output actionCloudShare_actionPerformed
	 */
	public void actionCloudShare_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionCloudShare_actionPerformed(e);
	}

	/**
	 * output actionCloudScreen_actionPerformed
	 */
	public void actionCloudScreen_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionCloudScreen_actionPerformed(e);
	}

	/**
	 * output actionXunTongFeed_actionPerformed
	 */
	public void actionXunTongFeed_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionXunTongFeed_actionPerformed(e);
	}

	/**
	 * output actionRefresh_actionPerformed
	 */
	public void actionRefresh_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionRefresh_actionPerformed(e);
	}

	/**
	 * output actionQuery_actionPerformed
	 */
	public void actionQuery_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionQuery_actionPerformed(e);
	}

	/**
	 * output actionPrint_actionPerformed
	 */
	public void actionPrint_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionPrint_actionPerformed(e);
	}

	/**
	 * output actionPrintPreview_actionPerformed
	 */
	public void actionPrintPreview_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionPrintPreview_actionPerformed(e);
	}

	/**
	 * output actionChart_actionPerformed
	 */
	public void actionChart_actionPerformed(ActionEvent e) throws Exception
	{
		super.actionChart_actionPerformed(e);
	}

	@Override
	protected RptParams getParamsForInit() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected CommRptBaseConditionUI getQueryDialogUserPanel() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected ICommRptBase getRemoteInstance() throws BOSException {
		// TODO Auto-generated method stub
		return ZtSignContractReportFacadeFactory.getRemoteInstance();
	}

	@Override
	protected KDTable getTableForPrintSetting() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void query() {
		// TODO Auto-generated method stub
		kDTable1.removeColumns();
		kDTable1.removeRows();
	}
	protected void treeMain_valueChanged(TreeSelectionEvent e) throws Exception {

		OrgStructureInfo orgStruct =new OrgStructureInfo();
		FullOrgUnitInfo orgInfo = FullOrgUnitFactory.getRemoteInstance()
		.getFullOrgUnitInfo(new ObjectUuidPK(orgStruct.getUnit().getId()));
		params.setObject("selectedOrgInfo", orgInfo);

		query();
	}
	public void tableDataRequest(KDTDataRequestEvent arg0) {
		if(isQuery) 
			return;
		isQuery=true;

		LongTimeDialog dialog = null;

		dialog = new LongTimeDialog(new Frame());
		dialog.setLongTimeTask(new ILongTimeTask() {
			public void afterExec(Object result) throws Exception {
				RptParams pp=(RptParams)params.clone();
				RptParams rpt = getRemoteInstance().createTempTable(pp);
				RptTableHeader header = (RptTableHeader)rpt.getObject("header");
				com.kingdee.eas.framework.report.util.KDTableUtil.setHeader(header, kDTable1);
				RptRowSet rs = (RptRowSet)((RptParams)result).getObject("rowSet");
				kDTable1.setRowCount(rs.getRowCount());
				com.kingdee.eas.framework.report.util.KDTableUtil.insertRows(rs,0, kDTable1);
				kDTable1.getViewManager().setFreezeView(0, 3);
				
				loadDate();
				
//				sumCll();
			}
			public Object exec() throws Exception {
				RptParams pp=(RptParams)params.clone();
				kDTable1.setRefresh(false);
				RptParams resultRpt= getRemoteInstance().query(pp);
				return resultRpt;
			}
		});
		dialog.show();
		isQuery = false;
	}
	public void loadDate()throws Exception {
		Calendar calendar=Calendar.getInstance();
		int yeart=calendar.get(Calendar.YEAR);
		//计算当前年每个月有多少天
		int m1=DateXRHelper.getDays(yeart, 1);
		int m2=DateXRHelper.getDays(yeart, 2);
		int m3=DateXRHelper.getDays(yeart, 3);
		int m4=DateXRHelper.getDays(yeart, 4);
		int m5=DateXRHelper.getDays(yeart, 5);
		int m6=DateXRHelper.getDays(yeart, 6);
		int m7=DateXRHelper.getDays(yeart, 7);
		int m8=DateXRHelper.getDays(yeart, 8);
		int m9=DateXRHelper.getDays(yeart, 9);
		int m10=DateXRHelper.getDays(yeart, 10);
		int m11=DateXRHelper.getDays(yeart, 11);
		int m12=DateXRHelper.getDays(yeart, 12);
		
		
		//获取开始结束时间
		
		for(int i=0;i<kDTable1.getRowCount();i++){
			com.kingdee.bos.ctrl.kdf.table.IRow row=kDTable1.getRow(i);
		  if(row.getCell("ZLSTARTDATE").getValue()!=null && row.getCell("ZLENDDATE").getValue()!=null){
		   BigDecimal cyDays=UIRuleUtil.getBigDecimal(row.getCell("cydays").getValue());//差异天数
		   BigDecimal zlAmount=UIRuleUtil.getBigDecimal(row.getCell("zlAmount").getValue());//租赁金额
		   BigDecimal  price=zlAmount.divide(cyDays, 6, 4);//单价
		   String ZLSTARTDATE=row.getCell("ZLSTARTDATE").getValue().toString();
		   String ZLENDDATE=row.getCell("ZLENDDATE").getValue().toString();
			
			DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); 
			DateFormat MM = new SimpleDateFormat("MM"); 
			Date dates=format1.parse(ZLSTARTDATE);
			Date datee=format1.parse(ZLENDDATE);
			int syear=DateXRHelper.getYear(dates);
			int eyear=DateXRHelper.getYear(datee);
			int sMonth=DateXRHelper.getMonth(dates);//开始日期所在月份
			int enMonth=DateXRHelper.getMonth(datee);//结束日期所在月份
			int sdays=DateXRHelper.getDay(dates);//开始日期天数
			int eDays=DateXRHelper.getDay(datee);//结束日期天数
			String smm=MM.format(dates);
			String emm=MM.format(datee);
			
			int smdays=DateXRHelper.getDays(syear, sMonth); //开始日期年月 月份天数
			int emdays=DateXRHelper.getDays(eyear, enMonth); //结束日期年月 月份天数
			
			
			
			
			row.getCell("01").setValue(BigDecimal.ZERO);
			row.getCell("02").setValue(BigDecimal.ZERO);
			row.getCell("03").setValue(BigDecimal.ZERO);
			row.getCell("04").setValue(BigDecimal.ZERO);
			row.getCell("05").setValue(BigDecimal.ZERO);
			row.getCell("06").setValue(BigDecimal.ZERO);
			row.getCell("07").setValue(BigDecimal.ZERO);
			row.getCell("08").setValue(BigDecimal.ZERO);
			row.getCell("09").setValue(BigDecimal.ZERO);
			row.getCell("10").setValue(BigDecimal.ZERO);
			row.getCell("11").setValue(BigDecimal.ZERO);
			row.getCell("12").setValue(BigDecimal.ZERO);
			
			//当租赁开始日期年小于当前年 ，租赁结束日期年大于当前年
			if(syear<yeart&&eyear>yeart){
				row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
				row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
				row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
				row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
				row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
				row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
				row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
				row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
				row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
				row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
				row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
				row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
				
				
			}
			//当租赁开始日期年小于当前年 ，租赁结束日期年 等于当前年
			if(syear<yeart&&eyear==yeart){
				if (enMonth==1) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
				 }
					else if (enMonth==2) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					}
					else if (enMonth==3) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					}
					else if (enMonth==4) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					}
					else if (enMonth==5) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					}
					else if (enMonth==6) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
					row.getCell("06").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					}
					else if (enMonth==7) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
					row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
					row.getCell("07").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					}
					else if (enMonth==8) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
					row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
					row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
					row.getCell("08").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					}
					else if (enMonth==9) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
					row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
					row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
					row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
					row.getCell("09").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					
					}
					else if (enMonth==10) {
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
					row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
					row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
					row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
					row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
					row.getCell("10").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					
					}
					else if (enMonth==11) {	
					row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
					row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
					row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
					row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
					row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
					row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
					row.getCell("11").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					
					}
					else if (enMonth==12) {	
						row.getCell("01").setValue(price.multiply( new BigDecimal(m1)).setScale(2, 4));
						row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
						row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
						row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
						row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
						row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
						row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
						row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
						
					}
			}
			//当租赁开始日期于当前年 ，租赁结束日期年大于等于当前年
			if(syear==yeart&&eyear>yeart){
				if (sMonth==1) {
					int days=m1-sdays+1;
					row.getCell("01").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
					row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
					row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
					row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
					row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
					row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
					row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
					row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
					row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
					row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
					row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
					row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
				 }
					else if (sMonth==2) {
						int days=m2-sdays+1;
						row.getCell("02").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
						row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
						row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
						row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
						row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
						row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					}
					else if (sMonth==3) {
						int days=m3-sdays+1;
						row.getCell("03").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
						row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
						row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
						row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
						row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					}
					else if (sMonth==4) {
						int days=m4-sdays+1;
						row.getCell("04").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
						row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
						row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
						row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					}
					else if (sMonth==5) {
						int days=m5-sdays+1;
						row.getCell("05").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
						row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
						row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					}
					else if (sMonth==6) {
						int days=m6-sdays+1;
						row.getCell("06").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
						row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					}
					else if (sMonth==7) {
						int days=m7-sdays+1;
						row.getCell("07").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					}
					else if (sMonth==8) {
						int days=m8-sdays+1;
						row.getCell("08").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					}
					else if (sMonth==9) {
						int days=m9-sdays+1;
						row.getCell("09").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					
					}
					else if (sMonth==10) {
						int days=m10-sdays+1;
						row.getCell("10").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					
					}
					else if (sMonth==11) {	
						int days=m11-sdays+1;
						row.getCell("11").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						row.getCell("12").setValue(price.multiply( new BigDecimal(m12)).setScale(2, 4));
					
					}
				
					else if (sMonth==12) {	
						int days=m12-sdays+1;
						row.getCell("12").setValue(price.multiply( new BigDecimal(days)).setScale(2, 4));
						
					}
				
			}
			BigDecimal t13=UIRuleUtil.getBigDecimal(row.getCell("01").getValue()).add(UIRuleUtil.getBigDecimal(row.getCell("02").getValue()))
			.add(UIRuleUtil.getBigDecimal(row.getCell("03").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("04").getValue()))
				.add(UIRuleUtil.getBigDecimal(row.getCell("05").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("06").getValue()))
					.add(UIRuleUtil.getBigDecimal(row.getCell("07").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("08").getValue()))
						.add(UIRuleUtil.getBigDecimal(row.getCell("09").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("10").getValue()))
							.add(UIRuleUtil.getBigDecimal(row.getCell("11").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("12").getValue()));
			
			row.getCell("13").setValue(t13);
			
			//当租赁开始日期 结束日期等于当前年
			if(syear==yeart&&eyear==yeart){
				if(smm.equals(emm)){//当开始日期截至日期在同一个月份时
					row.getCell(smm).setValue(zlAmount);
				}else{
					int cym=enMonth-sMonth;
					int days1=smdays-sdays+1;
					row.getCell(smm).setValue(price.multiply( new BigDecimal(days1)).setScale(2, 4));
					row.getCell(emm).setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4));
					//当月份相减大于1时
					if(cym>1){
						int mm=sMonth;
						for(int k=1;k<=cym-1;k++){
							mm=mm+1;
							if(mm==2){
								row.getCell("02").setValue(price.multiply( new BigDecimal(m2)).setScale(2, 4));
							}
							if(mm==3){
								row.getCell("03").setValue(price.multiply( new BigDecimal(m3)).setScale(2, 4));
							}
							if(mm==4){
								row.getCell("04").setValue(price.multiply( new BigDecimal(m4)).setScale(2, 4));
							}
							if(mm==5){
								row.getCell("05").setValue(price.multiply( new BigDecimal(m5)).setScale(2, 4));
							}
							if(mm==6){
								row.getCell("06").setValue(price.multiply( new BigDecimal(m6)).setScale(2, 4));
							}
							if(mm==7){
								row.getCell("07").setValue(price.multiply( new BigDecimal(m7)).setScale(2, 4));
							}
							if(mm==8){
								row.getCell("08").setValue(price.multiply( new BigDecimal(m8)).setScale(2, 4));
							}
							if(mm==9){
								row.getCell("09").setValue(price.multiply( new BigDecimal(m9)).setScale(2, 4));
							}
							if(mm==10){
								row.getCell("10").setValue(price.multiply( new BigDecimal(m10)).setScale(2, 4));
							}
							if(mm==11){
								row.getCell("11").setValue(price.multiply( new BigDecimal(m11)).setScale(2, 4));
							}
						}
					}
				}
				row.getCell("13").setValue(zlAmount);
				 t13=UIRuleUtil.getBigDecimal(row.getCell("01").getValue()).add(UIRuleUtil.getBigDecimal(row.getCell("02").getValue()))
				.add(UIRuleUtil.getBigDecimal(row.getCell("03").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("04").getValue()))
					.add(UIRuleUtil.getBigDecimal(row.getCell("05").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("06").getValue()))
						.add(UIRuleUtil.getBigDecimal(row.getCell("07").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("08").getValue()))
							.add(UIRuleUtil.getBigDecimal(row.getCell("09").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("10").getValue()))
								.add(UIRuleUtil.getBigDecimal(row.getCell("11").getValue())).add(UIRuleUtil.getBigDecimal(row.getCell("12").getValue()));
				//当在同一年时，补差到结束月
				 if(t13.compareTo(zlAmount)!=0){
						BigDecimal cc=t13.subtract(zlAmount);
						row.getCell(emm).setValue(price.multiply( new BigDecimal(eDays)).setScale(2, 4).subtract(cc));
					}
			}
		}
	}

} 
	//总计列赋值
	public void sumCll()throws Exception{
		for(int j=0;j<kDTable1.getRowCount();j++){
			com.kingdee.bos.ctrl.kdf.table.IRow row=kDTable1.getRow(j);
			BigDecimal sumC=new BigDecimal(0);
			for(int i=1;i<13;i++){

				sumC=sumC.add(UIRuleUtil.getBigDecimal(row.getCell("null"+i).getValue()));
				row.getCell("null13").setValue(sumC);
			}
		}
	}

}