![在此处输入图片说明] [2]我使用eclipse Birt报告构建的应用程序是apache ofbiz。我想以表格格式报告一些信息,并希望以pdf格式获取输出,这是我的目的。我发布的是从源中获取数据的类..
public static void getReport(HttpServletRequest request, HttpServletResponse response){
Delegator delegator = (Delegator) request.getAttribute("delegator");
String reportType = request.getParameter("reportType");
String compId = request.getParameter("companyId");
List empTaskLists = FastList.newInstance();
//check employee position
try {
//use Company Id from global context
List<GenericValue> partyList = EntityUtil.filterByDate(delegator.findByAnd("PartyRelationshipAndDetail", UtilMisc.toMap("partyIdFrom", compId)));
//child
for( GenericValue party : partyList) {
GenericValue partyInfo=delegator.findByPrimaryKey("PartyAndPerson", UtilMisc.toMap("partyId", party.get("PartyId")) );
String partyName = partyInfo.get("firstName") +" "+partyInfo.get("lastName");
List<GenericValue> taskList = delegator.findList("WorkEffortAndPartyAssign", EntityCondition.makeCondition(UtilMisc.toMap("partyId", party.get("partyId"), "currentStatusId", "PTS_CREATED" , "statusId", "PAS_ASSIGNED")), null, null, null, false);
for( GenericValue task : taskList) {
Map taskMap = FastMap.newInstance();
String taskName=task.getString("workEffortName");
taskMap.put("empId", party.get("partyId"));
taskMap.put("empName", partyName);
taskMap.put("taskName", taskName);
taskMap.put("start", task.get("estimatedStartDate"));
taskMap.put("end", task.get("estimatedCompletionDate"));
empTaskLists.add(taskMap);
}
}
} catch (Exception e) {
e.printStackTrace();
}
这个类负责将数据填充到birt.And在Birt我有一个空的数据集。我发布了open和fetch脚本
打开脚本
var compId= "DemoScrumCompany";
emptaskList = FastList.newInstance();
partyList = delegator.findList("PartyRelationshipAndDetail", EntityCondition.makeCondition(UtilMisc.toList("partyIdFrom",compId)),null, null, null, false);
//child
for( party in partyList) {
partyName = PartyHelper.getPartyName(party, true);
var conds = FastList.newInstance();
conds.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, party.get("partyId")));
conds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PTS_CREATED"));
conds.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PAS_ASSIGNED"));
taskList = delegator.findList("WorkEffortAndPartyAssign", EntityCondition.makeCondition(conds), null, null, null, false);
for( task in taskList) {
taskMap = FastMap.newInstance();
taskName=task.get("workEffortName");
//taskName="Task1";
taskMap.put("empId", party.get("partyId"));
taskMap.put("empName", partyName);
taskMap.put("taskName", taskName);
taskMap.put("start", task.get("estimatedStartDate"));
taskMap.put("end", task.get("estimatedCompletionDate"));
//taskMap.put("empId", "EMp01");
//taskMap.put("empName", "EMP1");
//taskMap.put("taskName", taskName);
//taskMap.put("start", "2014-05-21");
//taskMap.put("end", "2014-05-31");
emptaskList.add(taskMap);
}
}
totalRow = 0;
countOfRow = 0;
if (emptaskList.size()> 0 ) {
totalRow = emptaskList.size();
}
获取脚本
if (countOfRow < emptaskList.size()-1) {
var emptaskMap =emptaskList.get(countOfRow);
row["employeeId"] = emptaskMap.get("employeeId");
row["employeeName"] = emptaskMap.get("employeeName");
row["taskName"] =emptaskMap.get("taskName");
row["startDate"] = emptaskMap.get("startDate");
row["endDate"] = emptaskMap.get("endDate");
countOfRow++;
return true;
}
return false;
这些我已经完成了数据。它足够了????。我还有一个数据集,我已经附在图片中。我需要用数据填充数据集