/**
* output package name
*/
package com.kingdee.eas.guiliumuye.duckbreeding.client;
import java.awt.event.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import com.kingdee.eas.hr.perf.client.FilterUIUtil;
import org.apache.log4j.Logger;
import com.kingdee.eas.base.commonquery.client.CustomerParams;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.basedata.org.AdminOrgUnitFactory;
import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
import com.kingdee.eas.basedata.org.CompanyOrgUnitInfo;
import com.kingdee.eas.basedata.org.CtrlUnitInfo;
import com.kingdee.eas.basedata.org.IAdminOrgUnit;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.fm.common.client.FMClientHelper;
import com.kingdee.eas.framework.*;
/**
* output class name
*/
public class SpeciasingleQueryPanel2UIEditUI extends AbstractSpeciasingleQueryPanel2UIEditUI
{
private static final Logger logger = CoreUIObject.getLogger(SpeciasingleQueryPanel2UIEditUI.class);
/**
* output class constructor
*/
public SpeciasingleQueryPanel2UIEditUI() throws Exception
{
super();
}
//给面板 公司 日期设置值
public void initValue() throws ParseException, BOSException, EASBizException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//获取当前月第一天:
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
String first = format.format(c.getTime());
Date start = new SimpleDateFormat("yyyy-MM-dd").parse(first);
//获取当前月最后一天
Calendar ca = Calendar.getInstance();
ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
String last = format.format(ca.getTime());
Date end = new SimpleDateFormat("yyyy-MM-dd").parse(last);
this.kDDatePicker1.setValue(start);
this.kDDatePicker2.setValue(end);
//给当前公司赋值当前登录公司 com.kingdee.eas.basedata.org.app.AdminOrgUnitQuery
//com.kingdee.eas.basedata.org.app.CompanyOrgUnitQuery
//AdminOrgUnitInfo currentAdminUnit = SysContext.getSysContext().getCurrentAdminUnit();
// CompanyOrgUnitInfo currentFIUnit = SysContext.getSysContext().getCurrentFIUnit();
CompanyOrgUnitInfo currentCompany = (CompanyOrgUnitInfo) SysContext.getSysContext().getCurrentCompany();
// this.prmtAPPCompany.setValue(SysContext.getSysContext().getCurrentAdminUnit());
//this.prmtAPPCompany.setValue(SysContext.getSysContext().getCurrentFIUnit());
}
@Override
public void onLoad() throws Exception {
// TODO Auto-generated method stub
//Map listen = FMClientHelper.removeComponentListeners(this);
//FMClientHelper.addComponentListeners(this, listen);
super.onLoad();
initValue();
}
public void loadFields() {
try {
//Map listen = FMClientHelper.removeComponentListeners(this);
super.loadFields();
//FMClientHelper.addComponentListeners(this, listen);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clear() {
// TODO Auto-generated method stub
super.clear();
}
@Override
public boolean isPrepareInit() {
// TODO Auto-generated method stub
return true;
}
@Override
public CustomerParams getCustomerParams() {
// TODO Auto-generated method stub
// return super.getCustomerParams();
return FilterUIUtil.saveAllData(this);
}
@Override
public void setCustomerParams(CustomerParams cp) {
// TODO Auto-generated method stub
// super.setCustomerParams(cp);
FilterUIUtil.retriveAllData(cp, this);
}
@Override
public boolean verify() {
// TODO Auto-generated method stub
return super.verify();
}
public FilterInfo getFilter(){
return super.getFilterInfo();
}
protected void prmtAPPCompany_dataChanged(com.kingdee.bos.ctrl.swing.event.DataChangeEvent e){
Object[] F7cols = (Object[]) e.getNewValue();
if (null!= F7cols) {
//得到 f7 多选 AdminOrgUnitInfo
StringBuilder f7id = new StringBuilder();
StringBuilder f7Name = new StringBuilder();
for (int i = 0; i < F7cols.length; i++) {
CompanyOrgUnitInfo info = (CompanyOrgUnitInfo) F7cols[i];
String idString = info.getId().toString();
f7id.append(idString).append(";");
f7Name.append(info.getNumber()).append("-").append(info.getName()).append(";");
// operationTypeid.append(idString).append(";");
// operationTypeName.append(info.getNumber()).append("-").append(info.getName()).append(";");
}
//得到选到的复制在id框中
this.kDTextField1.setText(f7id.toString());
}
}
public FilterInfo getFilterInfo()
{
FilterInfo filter = new FilterInfo();
StringBuilder sbBuilder = new StringBuilder();
String adminOrgids = this.kDTextField1.getText();
//业务日期 结束
int j=0;
String maskString ="";
if(null!=adminOrgids){
String[] adminOrgidss = adminOrgids.split(";");
int length = adminOrgidss.length;
for (int i = 0; i < adminOrgidss.length; i++) {
String orgid = adminOrgidss[i];
filter.getFilterItems().add(new FilterItemInfo("CU.id",orgid, CompareType.EQUALS));
sbBuilder.append("#").append(i).append(" ").append("or ");
j=i;
}
j=j+1;
maskString = sbBuilder.toString();
maskString = maskString.substring(0, maskString.length() - 3);
}
//业务日期 开始
StringBuffer maskStringbuffer = new StringBuffer(maskString);
maskStringbuffer.insert(0, " (");//前面追加( 实现 (cu.id='213123' or cu.id='8787878');
maskStringbuffer.append(" )");//
SimpleDateFormat dtFormat = new SimpleDateFormat("yyyy-MM-dd");
if (this.kDDatePicker1.getValue() != null) {
filter.getFilterItems().add(new FilterItemInfo("bizDate", dtFormat.format(this.kDDatePicker1.getValue()), CompareType.GREATER_EQUALS));
maskStringbuffer.append("and ").append("#").append(j).append(" ");
}
//业务日期结束
if (this.kDDatePicker2.getValue() != null) {
filter.getFilterItems().add(new FilterItemInfo("bizDate", dtFormat.format(this.kDDatePicker2.getValue()), CompareType.LESS_EQUALS));
maskStringbuffer.append("and ").append("#").append(j+1).append(" ");
}
filter.setMaskString(maskStringbuffer.toString());
return filter;
}
/**
* output storeFields method
*/
public void storeFields()
{
super.storeFields();
}
}