您的位置:首页 > 其它

报表添加用户自定义面板

2013-07-19 15:30 330 查看
/**
* output package name
*/
package com.kingdee.eas.fdc.schedule.client;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.ui.face.IUIWindow;
import com.kingdee.bos.ui.face.UIFactory;
import com.kingdee.bos.ui.face.WinStyle;
import com.kingdee.bos.ctrl.kdf.table.ICell;
import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.kdf.table.event.KDTMouseEvent;
import com.kingdee.bos.ctrl.kdf.util.style.StyleAttributes;
import com.kingdee.bos.ctrl.swing.KDPanel;
import com.kingdee.eas.base.commonquery.client.CommonQueryDialog;
import com.kingdee.eas.base.commonquery.client.CustomerParams;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.eas.common.client.UIContext;
import com.kingdee.eas.common.client.UIFactoryName;
import com.kingdee.eas.fdc.schedule.TaskExcuteStatisticsFactory;
import com.kingdee.eas.framework.*;
import com.kingdee.eas.framework.report.util.RptRowSet;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.EASResource;

/**
* 项目任务执行统计表 output class name
*/
public class ProjectExcuteStaticRptUI extends AbstractProjectExcuteStaticRptUI {
private static final Logger logger = CoreUIObject
.getLogger(ProjectExcuteStaticRptUI.class);

private static final long DAY = 24L * 60L * 60L * 1000L;

private CommonQueryDialog commonQueryDialog = null;
private ProjectExcuteStaticFilterUI excuteStaticFilterUI = null;
private CustomerParams params = null;
private String projectID = null;
private String taskID = null;
private String personID = null;
private String plantBeginDate = null;
private String plantEndDate = null;
private String actualBeginDate = null;
private String actualEndDate = null;
protected Map<String, Object> paramsMap = null;

public ProjectExcuteStaticRptUI() throws Exception {
super();
mainQueryPK = new MetaDataPK("com.kingdee.eas.fdc.schedule.app",
"TaskExecuteStaticRptQuery");
paramsMap = new HashMap<String, Object>();
}

public void storeFields() {
super.storeFields();
}

@Override
public void onLoad() throws Exception {
super.onLoad();
initCompent();
initAction();
}

/**
* 初始化控件
*
* @throws Exception
*/
protected void initCompent() throws Exception {
initTblMain();
}

/**
* 初始化 Action
*
* @throws Exception
*/
protected void initAction() throws Exception {
actionAddNew.setVisible(false);
actionCloudFeed.setVisible(false);
actionView.setVisible(false);
actionEdit.setVisible(false);
actionRemove.setVisible(false);
actionRefresh.setVisible(false);
actionLocate.setVisible(false);
actionAttachment.setVisible(false);
actionPageSetup.setVisible(false);
actionCancelCancel.setVisible(false);
actionCancel.setVisible(false);
actionQueryScheme.setVisible(false);
}

/**
* 初始化表格 tblMain
*/
protected void initTblMain() throws Exception {
// Color col1 = new Color(204, 232, 207);
// Color col2 = new Color(188, 224, 191);
// Color col3 = new Color(253, 233, 217);
tblMain.getHeadRow(0).setHeight(30);
StyleAttributes sab = tblMain.getHeadRow(0).getStyleAttributes();
sab.setFontSize(11);
sab.setBold(true);
// tblMain.getColumn("projectName").getStyleAttributes().setBackground(
// col1);
//tblMain.getColumn("taskName").getStyleAttributes().setBackground(col1)
// ;
tblMain.getColumn("taskName").setWidth(200);
// tblMain.getColumn("taskQuality").getStyleAttributes().setBackground(
// col1);
// tblMain.getColumn("responsibleDepartment").getStyleAttributes().
// setBackground(col1);
// tblMain.getColumn("responsiblePerson").getStyleAttributes().
// setBackground(col1);

//tblMain.getColumn("plantBeginDate").getStyleAttributes().setBackground
// (col2);
tblMain.getColumn("plantBeginDate").setWidth(110);
// tblMain.getColumn("plantCompleteDate").getStyleAttributes().
// setBackground(col2);
tblMain.getColumn("plantCompleteDate").setWidth(110);
//tblMain.getColumn("plantDulation").getStyleAttributes().setBackground(
// col2);
tblMain.getColumn("plantDulation").setWidth(80);

//tblMain.getColumn("actualBeginDate").getStyleAttributes().setBackground
// (col3);
tblMain.getColumn("actualBeginDate").setWidth(110);
// tblMain.getColumn("actualCompleteDate").getStyleAttributes().
// setBackground(col3);
tblMain.getColumn("actualCompleteDate").setWidth(110);
//tblMain.getColumn("actualDulation").getStyleAttributes().setBackground
// (col3);
tblMain.getColumn("actualDulation").setWidth(80);

// tblMain.getColumn("taskDelayDay").getStyleAttributes().setBackground(
// col2);
tblMain.getColumn("taskDelayDay").setWidth(130);
// tblMain.getColumn("status").getStyleAttributes().setBackground(col2);
tblMain.getColumn("status").setWidth(60);
tblMain.setAutoscrolls(true);
//tblMain.getColumn("taskName").getStyleAttributes().setUnderline(true);

}

protected CommonQueryDialog initCommonQueryDialog() {
if (commonQueryDialog != null) {
return commonQueryDialog;
} else {
commonQueryDialog = super.initCommonQueryDialog();
commonQueryDialog.setWidth(400);
commonQueryDialog.addUserPanel(getFilterUI());
commonQueryDialog.setShowSorter(true);
commonQueryDialog.setShowFilter(true);
return commonQueryDialog;
}
}

private ProjectExcuteStaticFilterUI getFilterUI() {
if (excuteStaticFilterUI == null) {
try {
excuteStaticFilterUI = new ProjectExcuteStaticFilterUI(this,
actionOnLoad);
// filterUI.onLoad();
} catch (Exception e) {
e.printStackTrace();
abort(e);
}
}
return excuteStaticFilterUI;
}

protected void execQuery() {
try {
this.params = this.excuteStaticFilterUI.getCustomerParams();
// String projectId = params.getCustomerParam("projectIds");
this.projectID = this.params.getCustomerParam("projectIds");
this.taskID = this.params.getCustomerParam("taskID");
this.personID = this.params.getCustomerParam("personID");
this.plantBeginDate = this.params
.getCustomerParam("plantBeginDate");
this.plantEndDate = this.params.getCustomerParam("plantEndDate");
this.actualBeginDate = this.params
.getCustomerParam("actualBeginDate");
this.actualEndDate = this.params.getCustomerParam("actualEndDate");
paramsMap.put("projectID", projectID);
paramsMap.put("taskID", taskID);
paramsMap.put("personID", personID);
paramsMap.put("plantBeginDate", plantBeginDate);
paramsMap.put("plantEndDate", plantEndDate);
paramsMap.put("actualBeginDate", actualBeginDate);
paramsMap.put("actualEndDate", actualEndDate);
EntityViewInfo viewInfo = commonQueryDialog
.getEntityViewInfoResult();
if (viewInfo != null && !"".equals(viewInfo.toString().trim())) {
String userDefineFilter = viewInfo.toString();//.replace("WHERE"
// , " ");
// String[] fileds = new
// String[]{"project.name","name","adminDept.name"
// ,"adminPerson.name","start"};
paramsMap.put("userDefineFilter", userDefineFilter);
}
showTableInfo();
} catch (EASBizException e) {
e.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}

private void showTableInfo() throws EASBizException, BOSException,
ParseException {
tblMain.removeRows();
RptRowSet rs = TaskExcuteStatisticsFactory.getRemoteInstance()
.getTaskExcuteStatistics(paramsMap);
if (rs == null) {
return;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

while (rs.next()) {
IRow row = tblMain.addRow();
row.getCell("id").setValue(rs.getString("taskId"));
row.getCell("projectName").setValue(rs.getString("projectName"));
row.getCell("taskName").setValue(rs.getString("taskName"));
row.getCell("taskQuality").setValue(rs.getString("taskQuality"));
row.getCell("responsibleDepartment").setValue(
rs.getString("responsibleDepartment"));
row.getCell("responsiblePerson").setValue(
rs.getString("responsiblePerson"));

Date plantBeginDate = null;
Date plantCompleteDate = null;

Date actualBeginDate = null;
Date actualCompleteDate = null;
Long day = null;
Long completeDay = null;
if (rs.getObject("plantBeginDate") != null
&& !"".equals(rs.getObject("plantBeginDate"))) {
plantBeginDate = dateFormat.parse(rs
.getObject("plantBeginDate").toString());
row.getCell("plantBeginDate").setValue(
dateFormat.format(plantBeginDate));
}
if (rs.getObject("plantCompleteDate") != null
&& !"".equals(rs.getObject("plantCompleteDate"))) {
plantCompleteDate = dateFormat.parse(rs.getObject(
"plantCompleteDate").toString());
row.getCell("plantCompleteDate").setValue(
dateFormat.format(plantCompleteDate));
}
if (plantCompleteDate != null && plantBeginDate != null) {
day = (plantCompleteDate.getTime() - plantBeginDate.getTime())
/ DAY;
}
if (day != null) {
row.getCell("plantDulation").setValue(day + 1);
}
if (rs.getObject("actualBeginDate") != null
&& !"".equals(rs.getObject("actualBeginDate"))) {
actualBeginDate = dateFormat.parse(rs.getObject(
"actualBeginDate").toString());
row.getCell("actualBeginDate").setValue(
dateFormat.format(actualBeginDate));
}
if (rs.getObject("actualCompleteDate") != null
&& !"".equals(rs.getObject("actualCompleteDate"))) {
actualCompleteDate = dateFormat.parse(rs.getObject(
"actualCompleteDate").toString());
row.getCell("actualCompleteDate").setValue(
dateFormat.format(actualCompleteDate));
}
if (actualBeginDate != null && actualCompleteDate != null) {
completeDay = (actualCompleteDate.getTime() - actualBeginDate
.getTime())
/ DAY;
}
if (completeDay != null) {
row.getCell("actualDulation").setValue(completeDay + 1);
}
if (completeDay != null && day != null) {
row.getCell("taskDelayDay").setValue(completeDay - day);
}
Object statusValue = row.getCell("taskDelayDay").getValue();
String status = null;
if (statusValue != null) {
Long statusLongValue = Long.parseLong(statusValue.toString());
if (statusLongValue > 0) {
status = "延误";
} else if (statusLongValue == 0) {
status = "正常";
} else if (statusLongValue < 0) {
status = "提前";
}
} else {
if (plantCompleteDate != null) {
Long curComplete = (new Date().getTime() - plantCompleteDate
.getTime())
/ DAY;
if (curComplete > 0) {
status = "延误";
}
}
}
row.getCell("status").setValue(status);
}
if (rs != null) {
tblMain.setRowCount(rs.getRowCount());
}

}

@Override
protected ICoreBase getBizInterface() throws Exception {
return null;
}

/**
* 双击 任务名称时 查看任务属性详细
*/
protected void tblMain_tableClicked(KDTMouseEvent event) throws Exception {
if (event.getType() == 0) // 点击的是表头
{
return;
}
if (event.getClickCount() == 2) {
// if (event.getColIndex() == tblMain.getColumnIndex("taskName"))
// {
ICell cell = tblMain.getCell(event.getRowIndex(), "id");
if (cell == null) {
return;
}
Object value = cell.getValue();
if (value == null) {
return;
}
String taskId = value.toString();
UIContext uiContext = new UIContext(this);
uiContext.put("ID", taskId);
getUIContext().putAll(uiContext);
IUIWindow uiWindow = null;
uiWindow = UIFactory.createUIFactory(UIFactoryName.MODEL).create(
getPropertityUIName(), uiContext, null, OprtState.VIEW,
WinStyle.SHOW_TOOLBAR);
uiWindow.show();
// }
}

// super.tblMain_tableClicked(event);
}

/**
* 初始化默认查询条件
*/
protected boolean initDefaultFilter() {
return true;
}

protected String getPropertityUIName() {
return "com.kingdee.eas.fdc.schedule.client.FDCScheduleTaskPropertiesNewUI";
}

@Override
public void actionExport_actionPerformed(ActionEvent arg0) throws Exception {
super.actionExport_actionPerformed(arg0);
}

@Override
protected String getEditUIName() {
return null;
}

@Override
public EntityViewInfo getMainQuery() {
// TODO Auto-generated method stub
return super.getMainQuery();
}

}

/**
* output package name
*/
package com.kingdee.eas.fdc.schedule.client;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.derby.impl.sql.compile.SetSchemaNode;
import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.swing.event.DataChangeEvent;
import com.kingdee.bos.ctrl.swing.event.SelectorEvent;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
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.ui.face.ItemAction;
import com.kingdee.eas.base.commonquery.client.CustomerParams;
import com.kingdee.eas.base.core.util.EmptyUtil;
import com.kingdee.eas.basedata.person.PersonFactory;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.fdc.basedata.CurProjectFactory;
import com.kingdee.eas.fdc.basedata.CurProjectInfo;
import com.kingdee.eas.fdc.basedata.ICurProject;
import com.kingdee.eas.fdc.schedule.FDCScheduleCollection;
import com.kingdee.eas.fdc.schedule.FDCScheduleFactory;
import com.kingdee.eas.fdc.schedule.FDCScheduleInfo;
import com.kingdee.eas.fdc.schedule.FDCScheduleTaskCollection;
import com.kingdee.eas.fdc.schedule.FDCScheduleTaskFactory;
import com.kingdee.eas.fdc.schedule.FDCScheduleTaskInfo;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.client.ListUI;

/**
* output class name
*/
public class ProjectExcuteStaticFilterUI extends
AbstractProjectExcuteStaticFilterUI {
private static final Logger logger = CoreUIObject
.getLogger(ProjectExcuteStaticFilterUI.class);
protected ItemAction actionListOnLoad;
protected ListUI listUI;

/**
* output class constructor
*/
public ProjectExcuteStaticFilterUI() throws Exception {
super();
}

public ProjectExcuteStaticFilterUI(ListUI listUI, ItemAction itemAction) throws Exception
{
super();
this.listUI = listUI;
this.actionListOnLoad = itemAction;
}

@Override
public void onLoad() throws Exception {
super.onLoad();
prmtProject.setEditFormat("$name$");
prmtProject.setDisplayFormat("$name$");
kDPlantBeginDate.setValue(null);
kDPlantEndDate.setValue(null);
kDActualBeginDate.setValue(null);
kDActualEndDate.setValue(null);
Object[] objs = (Object[]) prmtProject.getData();
if(objs.length<=1 && objs[0] == null){
prmtTask.setEnabled(false);
}
}

@Override
public void setCustomerParams(CustomerParams cp) {
if (cp == null)
return;
Object obj = cp.getCustomerParam("projectIds");
if (obj != null && obj.toString().trim().length()>0) {
String[] projectIds = obj.toString().split(",");
Object [] projectS = new Object[projectIds.length];
ICurProject icurProject = null;
try {
icurProject = CurProjectFactory.getRemoteInstance();

for (int i = 0; i < projectIds.length; i++) {
String projectID = projectIds[i].toString().substring(1,projectIds[i].toString().length()-1);
projectS[i] = icurProject.getCurProjectInfo(new ObjectUuidPK(projectID));
}
} catch (BOSException e) {
e.printStackTrace();
} catch (EASBizException e) {
e.printStackTrace();
}
prmtProject.setValue(projectS);
}

obj = cp.getCustomerParam("taskID");
if (obj != null ) {
try {
prmtTask.setValue(FDCScheduleTaskFactory.getRemoteInstance().getFDCScheduleTaskInfo(new ObjectUuidPK(obj.toString())));
} catch (EASBizException e) {
e.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
}
}

obj = cp.getCustomerParam("personID");
if (obj != null ) {
try {
prmtResponsiblePerson.setValue(PersonFactory.getRemoteInstance().getPersonInfo(new ObjectUuidPK(obj.toString())));
} catch (EASBizException e) {
e.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
}
}

obj = cp.getCustomerParam("plantBeginDate");
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
if (obj != null) {
Date plantBeginDate = null;
try {
plantBeginDate =  formatDate.parse(obj.toString());
} catch (ParseException e) {
e.printStackTrace();
}
kDPlantBeginDate.setValue(plantBeginDate);

}else{
kDPlantBeginDate.setValue(null);
}

obj = cp.getCustomerParam("plantEndDate");
if (obj != null) {
Date plantEndDate = null;
try {
plantEndDate = formatDate.parse(obj.toString());
} catch (ParseException e) {
e.printStackTrace();
}
kDPlantEndDate.setValue(plantEndDate);
}else{
kDPlantEndDate.setValue(null);
}

obj = cp.getCustomerParam("actualBeginDate");
if (obj != null) {
Date actualBeginDate = null;
try {
actualBeginDate = formatDate.parse(obj.toString());
} catch (ParseException e) {
e.printStackTrace();
}
kDActualBeginDate.setValue(actualBeginDate);
}else{
kDActualBeginDate.setValue(null);
}

obj = cp.getCustomerParam("actualBeginDate");
if (obj != null) {
Date actualEndDate = null;
try {
actualEndDate= formatDate.parse(obj.toString());
} catch (ParseException e) {
e.printStackTrace();
}
kDActualEndDate.setValue(actualEndDate);
}else{
kDActualEndDate.setValue(null);
}

super.setCustomerParams(cp);
}

@Override
public CustomerParams getCustomerParams() {
CustomerParams params = new CustomerParams();
if (prmtProject.getValue() != null) {
if (prmtProject.getData() instanceof Object[]) {
Object[] objs = (Object[]) prmtProject.getData();
if (objs.length >= 0) {
if (objs[0] != null) {
StringBuffer projectIds = new StringBuffer();
CurProjectInfo curProjectInfo = null;
for (Object obj : objs) {
if (obj instanceof CurProjectInfo) {
curProjectInfo = (CurProjectInfo) obj;
projectIds.append(
"'" + curProjectInfo.getId().toString()
+ "'").append(",");
}
}
params.addCustomerParam("projectIds", projectIds
.toString());
}
}
}
}
if (prmtTask.getValue() != null) {
params.addCustomerParam("taskID", ((CoreBaseInfo) prmtTask
.getValue()).getId().toString());
}
if (prmtResponsiblePerson.getValue() != null) {
params.addCustomerParam("personID",
((CoreBaseInfo) prmtResponsiblePerson.getValue()).getId()
.toString());
}
if (kDPlantBeginDate.getValue() != null) {
params.addCustomerParam("plantBeginDate", kDPlantBeginDate
.getText());
}
if (kDPlantEndDate.getValue() != null) {
params.addCustomerParam("plantEndDate", kDPlantEndDate.getText());
}
if (kDActualBeginDate.getValue() != null) {
params.addCustomerParam("actualBeginDate", kDActualBeginDate
.getText());
}
if (kDActualEndDate.getValue() != null) {
params.addCustomerParam("actualEndDate", kDActualEndDate.getText());
}
return params;
}

/**
* output storeFields method
*/
public void storeFields() {
super.storeFields();
}

@Override
protected void prmtTask_willShow(SelectorEvent e) throws Exception {
super.prmtTask_willShow(e);

}

@Override
protected void prmtResponsiblePerson_willShow(SelectorEvent e)
throws Exception {
super.prmtResponsiblePerson_willShow(e);
// 如果项目与任务都为空刚全部显示
if (EmptyUtil.isEmpty(prmtTask.getValue())) {
if (prmtProject.getData() instanceof Object[]) {
Object[] objs = (Object[]) prmtProject.getData();
if (objs.length >= 0) {
if (objs[0] == null) {
return;
}
}
}
}
// 取得可供选择的责任人
Set<String> personIds = getPersonIds();
EntityViewInfo viewInfo = new EntityViewInfo();
FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(
new FilterItemInfo("id", personIds, CompareType.INCLUDE));
viewInfo.setFilter(filterInfo);
prmtResponsiblePerson.setEntityViewInfo(viewInfo);
prmtResponsiblePerson.getQueryAgent().resetRuntimeEntityView();
}

private Set<String> getPersonIds() throws BOSException, EASBizException {
Set<String> personIds = new HashSet<String>();
// 如果任务不为空,责任人则只能选择任务对应的责任人
if (!EmptyUtil.isEmpty(prmtTask.getValue())) {
if (prmtTask.getData() instanceof FDCScheduleTaskInfo) {
FDCScheduleTaskInfo fdcScheduleTaskInfo = (FDCScheduleTaskInfo) prmtTask
.getData();
fdcScheduleTaskInfo = FDCScheduleTaskFactory
.getRemoteInstance().getFDCScheduleTaskInfo(
"where id='" + fdcScheduleTaskInfo.getId()
+ "'");
if (fdcScheduleTaskInfo.getAdminPerson() != null) {
personIds.add(fdcScheduleTaskInfo.getAdminPerson().getId()
.toString());
}
}
} else {
// 如果任务为空,责任人刚是所选择项目下所有任务责任人的集合
if (!EmptyUtil.isEmpty(prmtProject.getValue())) {
if (prmtProject.getData() instanceof Object[]) {
Object[] objs = (Object[]) prmtProject.getData();
if (objs.length >= 0) {
if (objs[0] != null) {
Set<String> projectIds = new HashSet<String>();
CurProjectInfo curProjectInfo = null;
for (Object obj : objs) {
if (obj instanceof CurProjectInfo) {
curProjectInfo = (CurProjectInfo) obj;
projectIds.add(curProjectInfo.getId()
.toString());
}
}
EntityViewInfo viewInfo = new EntityViewInfo();
FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(
new FilterItemInfo("project.id",
projectIds, CompareType.INCLUDE));
viewInfo.setFilter(filterInfo);
FDCScheduleCollection fdcCollection = FDCScheduleFactory
.getRemoteInstance()
.getFDCScheduleCollection(viewInfo);
for (int i = 0, size = fdcCollection.size(); i < size; i++) {
FDCScheduleInfo scheduleInfo = fdcCollection
.get(i);
if (scheduleInfo.getAdminPerson() != null) {
personIds.add(scheduleInfo.getAdminPerson()
.getId().toString());
}
EntityViewInfo viewInfoTask = new EntityViewInfo();
FilterInfo filterInfoTask = new FilterInfo();
filterInfoTask.getFilterItems().add(
new FilterItemInfo("schedule.id",
scheduleInfo.getId(),
CompareType.EQUALS));
viewInfoTask.setFilter(filterInfoTask);
FDCScheduleTaskCollection taskCollection = FDCScheduleTaskFactory
.getRemoteInstance()
.getFDCScheduleTaskCollection(
viewInfoTask);
for (int j = 0, taskSize = taskCollection
.size(); j < taskSize; j++) {
if (taskCollection.get(j).getAdminPerson() != null) {
personIds.add(taskCollection.get(j)
.getAdminPerson().getId()
.toString());
}
}
}
}
}
}
}
}
return personIds;
}

@Override
protected void prmtProject_dataChanged(DataChangeEvent e) throws Exception {
super.prmtProject_dataChanged(e);
if (!EmptyUtil.isEmpty(prmtProject.getValue())) {
if (prmtProject.getData() instanceof Object[]) {
Object[] objs = (Object[]) prmtProject.getData();
Set<String> projectIds = new HashSet<String>();
CurProjectInfo curProjectInfo = null;

for (Object obj : objs) {
if (obj instanceof CurProjectInfo) {
curProjectInfo = (CurProjectInfo) obj;
projectIds.add(curProjectInfo.getId().toString());
}
}

prmtTask.setEnabled(true);
EntityViewInfo view = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("schedule.isLatestVer","1"));
filter.getFilterItems().add(new FilterItemInfo("project.id",projectIds,CompareType.INCLUDE));
view.setFilter(filter );
prmtTask.setEntityViewInfo(view );

Set<String> personIds = new HashSet<String>();
PersonInfo personInfo = (PersonInfo) prmtResponsiblePerson
.getData();
EntityViewInfo viewInfo = new EntityViewInfo();
FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(
new FilterItemInfo("project.id", projectIds,
CompareType.INCLUDE));
viewInfo.setFilter(filterInfo);
FDCScheduleCollection fdcCollection = FDCScheduleFactory
.getRemoteInstance().getFDCScheduleCollection(viewInfo);
int size = fdcCollection.size();
if (size <= 0) {
prmtResponsiblePerson.setValue(null);
}
// 如果责任人为项目下任何一个任务的责任人则不把责任人设为空
if (!EmptyUtil.isEmpty(prmtResponsiblePerson.getValue())) {
if (prmtResponsiblePerson.getData() instanceof PersonInfo) {
for (int i = 0; i < size; i++) {
FDCScheduleInfo scheduleInfo = fdcCollection.get(i);
personIds.add(scheduleInfo.getAdminPerson().getId()
.toString());
EntityViewInfo viewInfoTask = new EntityViewInfo();
FilterInfo filterInfoTask = new FilterInfo();
filterInfoTask.getFilterItems().add(
new FilterItemInfo("schedule.id",
scheduleInfo.getId(),
CompareType.EQUALS));
viewInfoTask.setFilter(filterInfoTask);
FDCScheduleTaskCollection taskCollection = FDCScheduleTaskFactory
.getRemoteInstance()
.getFDCScheduleTaskCollection(viewInfoTask);
for (int j = 0, taskSize = taskCollection.size(); j < taskSize; j++) {
personIds.add(taskCollection.get(j)
.getAdminPerson().getId().toString());
}
if (!personIds.contains(personInfo.getId()
.toString())) {
prmtResponsiblePerson.setValue(null);
}
}
}

}

// 如果任务为项目下的任务则不设为空
if (!EmptyUtil.isEmpty(prmtTask.getValue())) {
if (prmtTask.getData() instanceof FDCScheduleTaskInfo) {
FDCScheduleTaskInfo fdcScheduleTaskInfo = (FDCScheduleTaskInfo) prmtTask
.getData();
fdcScheduleTaskInfo = FDCScheduleTaskFactory
.getRemoteInstance().getFDCScheduleTaskInfo(
"where id='"
+ fdcScheduleTaskInfo.getId()
+ "'");

FDCScheduleInfo fdcScheduleInfo = fdcScheduleTaskInfo
.getSchedule();
fdcScheduleInfo = FDCScheduleFactory
.getRemoteInstance().getFDCScheduleInfo(
"where id='" + fdcScheduleInfo.getId()
+ "'");
if (!projectIds.contains(fdcScheduleInfo.getProject()
.getId().toString())) {
prmtTask.setValue(null);
}
}
}
}
} else {
prmtTask.setValue(null);
prmtTask.setEnabled(false);
prmtResponsiblePerson.setValue(null);
}
}

@Override
protected void prmtTask_dataChanged(DataChangeEvent e) throws Exception {
super.prmtTask_dataChanged(e);
// 选择任务后自动为项目赋值,为责任人赋值
if (!EmptyUtil.isEmpty(prmtTask.getValue())) {
if (prmtTask.getData() instanceof FDCScheduleTaskInfo) {
FDCScheduleTaskInfo fdcScheduleTaskInfo = (FDCScheduleTaskInfo) prmtTask
.getData();
fdcScheduleTaskInfo = FDCScheduleTaskFactory
.getRemoteInstance().getFDCScheduleTaskInfo(
"where id='" + fdcScheduleTaskInfo.getId()
+ "'");

FDCScheduleInfo fdcScheduleInfo = fdcScheduleTaskInfo
.getSchedule();
if (fdcScheduleInfo != null) {
fdcScheduleInfo = FDCScheduleFactory.getRemoteInstance()
.getFDCScheduleInfo(
"where id='" + fdcScheduleInfo.getId()
+ "'");
CurProjectInfo curProjectInfo = null;
if (fdcScheduleInfo.getProject() != null) {
curProjectInfo = CurProjectFactory.getRemoteInstance()
.getCurProjectInfo(
"where id='"
+ fdcScheduleInfo.getProject()
.getId() + "'");
prmtProject.setValue(curProjectInfo);
}
}
PersonInfo personInfo = fdcScheduleTaskInfo.getAdminPerson();
if (personInfo != null) {
EntityViewInfo viewInfo = new EntityViewInfo();
FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(
new FilterItemInfo("id", personInfo.getId(),
CompareType.EQUALS));
viewInfo.setFilter(filterInfo);
personInfo = PersonFactory.getRemoteInstance()
.getPersonCollection(viewInfo).get(0);
prmtResponsiblePerson.setValue(personInfo);
}
}
}
prmtResponsiblePerson.setValue(null);
}

public void clear() {
super.clear();
this.prmtProject.setValue(null);
this.prmtTask.setValue(null);
this.prmtResponsiblePerson.setValue(null);
this.kDPlantBeginDate.setValue(null);
this.kDPlantEndDate.setValue(null);
this.kDActualBeginDate.setValue(null);
this.kDActualEndDate.setValue(null);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: