示例#1
0
  /** 查看项目列定义 */
  public String queryXshlfxLcL() {

    // 增加报表子分类的条件
    ReportDefineColumnCond condColumn = new ReportDefineColumnCond();

    // 从缓存当中取选择的项目
    PropertyUnitCond cond = new PropertyUnitCond();
    cond = (PropertyUnitCond) request.getSession().getAttribute("cond");

    if (cond == null) {
      return "suc";
    }

    CompanyProjectCond conds = new CompanyProjectCond();
    conds.setProjectIds(cond.getSearchCompanyProjectIds());

    List<CompanyProject> project = companyProjectServices.findCompanyProjectByCond(conds);

    condColumn.setReportName(ContReportName.XSHLFX_LC);
    if (cond.getSearchCompanyProjectIds().size() > 1) {
      int companyId = DescUtils.getCompanyIdByProjectId(cond.getSearchCompanyProjectIds().get(0));
      condColumn.setCompanyId(String.valueOf(companyId));
      condColumn.setProjectId("");
    } else if (cond.getSearchCompanyProjectIds().size() == 1) {
      int companyId = DescUtils.getCompanyIdByProjectId(cond.getSearchCompanyProjectIds().get(0));
      condColumn.setProjectId(String.valueOf(cond.getSearchCompanyProjectIds().get(0)));
    } else {
      return "suc"; // 没有选择项目或者公司,直接不查询数据库输出
    }
    List<Map> listReportDefineColumn =
        reportDefineColumnServices.findReportDefineColumnAndType(condColumn);

    // 步骤1:进行List的定义,直接对应于html页面的Table
    ArrayList<ReportShowTR> trList = new ArrayList();

    for (int i = 0; i < project.size(); i++) {
      CompanyProject pro = project.get(i);

      for (int j = 0; j < listReportDefineColumn.size(); j++) {

        if (listReportDefineColumn.get(j).get("projectId") == null) continue;

        if (pro.getId()
            == Integer.parseInt(listReportDefineColumn.get(j).get("projectId").toString())) {
          ReportShowTR showTR = new ReportShowTR();
          ReportShowTD td1 = new ReportShowTD();
          td1.setXyValueText(pro.getProjectName());
          showTR.addTD(td1);

          ReportShowTD td2 = new ReportShowTD();
          if (!listReportDefineColumn.get(j).get("companyId").toString().equals("0")) {
            td2.setXyValueText("项目定义列");
          } else {
            td2.setXyValueText("公司定义列");
          }
          showTR.addTD(td2);

          ReportShowTD td4 = new ReportShowTD();
          td4.setXyValueText(listReportDefineColumn.get(j).get("typeName").toString());
          showTR.addTD(td4);

          ReportShowTD td3 = new ReportShowTD();
          td3.setXyValueText(listReportDefineColumn.get(j).get("showName").toString());
          showTR.addTD(td3);

          trList.add(showTR);
        }
      }
    }

    String str = ReportShowUtils.getTrsByListTR(trList);
    ActionContext.getContext().getValueStack().set("showTable", str);
    return "suc";
  }
示例#2
0
  /** 报表的组装 */
  public String runReport() {
    request.getSession().setAttribute("cond", propertyUnitCond);
    List<PropertyUnit> listUnit = propertyUnitServices.findPropertyUnit(propertyUnitCond);
    List<Confirm> listConfirm = confirmServices.findConfirm(null);
    List<Contract> listContract = contractServices.findContractPage(new ContractCond());

    // 增加报表子分类的条件
    ReportDefineColumnCond condColumn = new ReportDefineColumnCond();

    CompanyProjectCond conds = new CompanyProjectCond();
    conds.setProjectIds(propertyUnitCond.getSearchCompanyProjectIds());
    List<CompanyProject> project = companyProjectServices.findCompanyProjectByCond(conds);

    condColumn.setReportName(ContReportName.XSHLFX_LC);
    if (propertyUnitCond.getSearchCompanyProjectIds().size() > 1) {
      int companyId =
          DescUtils.getCompanyIdByProjectId(propertyUnitCond.getSearchCompanyProjectIds().get(0));
      condColumn.setCompanyId(String.valueOf(companyId));
      condColumn.setProjectId(CommonUtils.NORMAL);
    } else if (propertyUnitCond.getSearchCompanyProjectIds().size() == 1) {
      int companyId =
          DescUtils.getCompanyIdByProjectId(propertyUnitCond.getSearchCompanyProjectIds().get(0));
      condColumn.setProjectId(String.valueOf(companyId));
    } else {
      return "suc"; // 没有选择项目或者公司,直接不查询数据库输出
    }
    List<ReportDefineColumn> listReportDefineColumn =
        reportDefineColumnServices.findReportDefineColumnForY(condColumn);
    if (listReportDefineColumn.size() == 0
        && propertyUnitCond.getSearchCompanyProjectIds().size() == 1) {
      // 如果该项目没有设定报表列,则查找所属公司的设定
      int companyId =
          DescUtils.getCompanyIdByProjectId(propertyUnitCond.getSearchCompanyProjectIds().get(0));
      condColumn.setCompanyId(String.valueOf(companyId));
      condColumn.setProjectId(CommonUtils.NORMAL);
      listReportDefineColumn = reportDefineColumnServices.findReportDefineColumnForY(condColumn);
    }

    // 重新初始化listUnit
    ReportShowUtils.initListPropertyUnit_Confirm(listUnit, listConfirm);
    ReportShowUtils.initListPropertyUnit_Contract(listUnit, listContract);

    // 步骤1:进行List的定义,直接对应于html页面的Table
    ArrayList<ReportShowTR> trList = new ArrayList();

    // 形成表格(表格的结构以及td算法)
    // 总货量_总套数
    // 列出Y轴循环
    for (int j = 0; j < listReportDefineColumn.size(); j++) {
      ReportDefineColumn xColumn = listReportDefineColumn.get(j);
      // 按此方式,进行推广,进行一个list的定义
      ReportShowTR showTR = new ReportShowTR(xColumn.getTypeName());
      showTR.setXyMethodSql(xColumn.getMethodSql()); // 整行的判断是否符合条件

      ReportShowTD td1 = new ReportShowTD(xColumn.getTypeName());
      td1.setyTypeName(xColumn.getTypeName());
      showTR.addTD(td1);
      showTR.addTD(new ReportShowTD(xColumn.getShowName()));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总货量_总套数"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总货量_总面积"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总货量_总金额"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总货量_均价"));

      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出货量_总套数"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出货量_总面积"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出货量_总金额"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出货量_均价"));

      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总剩余货量_总套数"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总剩余货量_总面积"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总剩余货量_总金额"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总剩余货量_均价"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "总剩余货量_余货比例", "%1$,.0f%%"));

      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "认购情况_成交套数"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "认购情况_成交面积"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "认购情况_成交金额"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "认购情况_均价"));

      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "已签约情况_签约套数"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "已签约情况_签约面积"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "已签约情况_签约金额"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "已签约情况_均价"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "已签约情况_签约率", "%1$,.0f%%"));

      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "未签约情况_未签约套数"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "未签约情况_未签约面积"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "未签约情况_未签约金额"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "未签约情况_均价"));

      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出剩余货量_总量"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出剩余货量_面积"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出剩余货量_金额"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出剩余货量_均价"));
      showTR.addTD(ReportShowUtils.initShowTD(xColumn, "推出剩余货量_剩余率", "%1$,.0f%%"));

      // UNIT_ROOM_TYPE_FLOOR_NUM_COUNT

      trList.add(showTR);
    }

    // 根据数据对td进行填充
    for (int i = 0; i < listUnit.size(); i++) {
      PropertyUnit unit = listUnit.get(i);

      for (int j = 0; j < trList.size(); j++) {
        // 判断unit是否符合行的条件
        List<ReportColumnCond> listCond =
            ReportShowUtils.getListReportColumnCond_AND(trList.get(j).getXyMethodSql());

        // 目前这里写的比较固定,与method_sql的个数顺序一致
        if (listCond.size() == 2) {
          ReportColumnCond condRoomType = listCond.get(0);
          ReportColumnCond condFloorNum = listCond.get(1);

          if (ReportShowUtils.checkCond(
                  condRoomType,
                  ContReportTableColumn.ROOM_TYPE,
                  ContReportColumnMethod.EQ,
                  unit.getRoomType()) // 类型条件
              || ReportShowUtils.checkCond(
                  condFloorNum,
                  ContReportTableColumn.FLOOR_NUM,
                  String.valueOf(unit.getFloorNum()))) { // 楼层条件
            // 符合条件
            for (int k = 0; k < trList.get(j).getTdsCount(); k++) {
              computeTdByUnit(trList.get(j).getTD(k), unit);
            }
          }
        }
      }
    }

    ReportShowUtils.autoAddSumTRToListReportShow(trList); // 分组累计

    ReportShowUtils.autoAddAllSumTRToListReportShow(trList); // 总累计

    // 未签约情况
    ReportShowUtils.autoComputeListReportShow(trList, 24, 15, 19, EnumReportOperator.SUBTRACT);
    ReportShowUtils.autoComputeListReportShow(trList, 25, 16, 20, EnumReportOperator.SUBTRACT);
    ReportShowUtils.autoComputeListReportShow(trList, 26, 17, 21, EnumReportOperator.SUBTRACT);
    ReportShowUtils.autoComputeListReportShow(trList, 27, 26, 25, EnumReportOperator.DIVIDE);

    // 推出剩余货量
    ReportShowUtils.autoComputeListReportShow(trList, 28, 6, 15, EnumReportOperator.SUBTRACT);
    ReportShowUtils.autoComputeListReportShow(trList, 29, 7, 16, EnumReportOperator.SUBTRACT);
    ReportShowUtils.autoComputeListReportShow(trList, 30, 8, 17, EnumReportOperator.SUBTRACT);
    ReportShowUtils.autoComputeListReportShow(trList, 31, 30, 29, EnumReportOperator.DIVIDE);
    // ReportShowUtils.autoComputeListReportShow(trList,32,28,6,EnumReportOperator.DIVIDE);

    // 均价计算
    ReportShowUtils.autoComputeListReportShow(trList, 5, 4, 3, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 9, 8, 7, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 13, 12, 11, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 18, 17, 16, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 22, 20, 19, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 27, 26, 25, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 31, 30, 29, EnumReportOperator.DIVIDE);

    ReportShowUtils.autoComputeListReportShow(trList, 14, 10, 2, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 23, 19, 2, EnumReportOperator.DIVIDE);
    ReportShowUtils.autoComputeListReportShow(trList, 32, 28, 2, EnumReportOperator.DIVIDE);

    // String str = ReportShowUtils.getTrsOnlyTdIndexByListTR(trList);		//用于测试td的序号
    String str = ReportShowUtils.getTrsByListTR(trList); // getTrsByListTR

    setShowTrs(str); // 设置输出
    request.getSession().setAttribute("showTrs", showTrs);
    request.getSession().setAttribute("trList", trList);

    // 饼图
    chartSeriesData_DP = ReportShowUtils.getChartSeriesDataByType("叠拼", trList, 1, 2);
    chartSeriesData_GC = ReportShowUtils.getChartSeriesDataByType("高层", trList, 1, 2);
    chartSeriesData_GY = ReportShowUtils.getChartSeriesDataByType("公寓", trList, 1, 2);

    return "suc";
  }