コード例 #1
0
  /**
   * 查询所有的物质档案信息
   *
   * @return
   */
  public ArrayList FindAllMaterialRecordInfromation() {
    ArrayList list = new ArrayList(); // 创建list
    Query q = em.createQuery("select p from wzMaterialRecord p order by p.id desc"); // 建立带有参数的查询
    List result = q.getResultList(); // 返回结果
    if (!result.isEmpty()) {
      Iterator ite = result.iterator(); // 建立迭代器
      // 遍历结果并将数据存入list中
      while (ite.hasNext()) {
        wzMaterialRecord mate = (wzMaterialRecord) ite.next();
        if (mate != null) {
          if (mate.getDeptSysCode().getSysCode() != 0) {
            list.add(mate.getDeptSysCode().getSysCode());
          } else {
            list.add("");
          }
          if (mate.getDeptSysCode().getSysName() != null) {
            list.add(mate.getDeptSysCode().getSysName());
          } else {
            list.add("");
          }
          if (mate.getMaterialCode() != null) {
            list.add(mate.getMaterialCode());
          } else {
            list.add("");
          }
          if (mate.getMaterialConfig() != null) {
            list.add(mate.getMaterialConfig());
          } else {
            list.add("");
          }
          if (mate.getMaterialName() != null) {
            list.add(mate.getMaterialName());
          } else {
            list.add("");
          }
          if (mate.getMaterialUnit() != null && mate.getMaterialUnit().getUnitNo() != 0) {
            list.add(mate.getMaterialUnit().getUnitNo());
          } else {
            list.add("");
          }
          if (mate.getMaterialUnit() != null && mate.getMaterialUnit().getUnitName() != null) {
            list.add(mate.getMaterialUnit().getUnitName());
          } else {
            list.add("");
          }

          if (mate.getMaterialTwoType() != null && mate.getMaterialTwoType().getTwoType() != 0) {
            list.add(mate.getMaterialTwoType().getTwoType());
          } else if (mate.getMaterialOneType() != null
              && mate.getMaterialOneType().getOneType() != 0) {
            list.add(mate.getMaterialOneType().getOneType());
          } else {
            list.add("");
          }

          if (mate.getMaterialTwoType() != null
              && mate.getMaterialTwoType().getTwoTypeName() != null) {
            list.add(mate.getMaterialTwoType().getTwoTypeName());
          } else if (mate.getMaterialOneType() != null
              && mate.getMaterialOneType().getOneTypeName() != null) {
            list.add(mate.getMaterialOneType().getOneTypeName());
          } else {
            list.add("");
          }

          if (mate.getMaterialProp() != 0) {
            list.add(mate.getMaterialProp());
          } else {
            list.add("");
          }
          if (mate.getAbcType() != 0) {
            list.add(mate.getAbcType());
          } else {
            list.add("");
          }
          if (mate.getPriceAddRate() != 0.0f) {
            list.add(mate.getPriceAddRate());
          } else {
            list.add("");
          }
          if (mate.getVelocity() != 0.0f) {
            list.add(mate.getVelocity());
          } else {
            list.add("");
          }
          if (mate.getChargeCode() != 0L) {
            list.add(mate.getChargeCode());
          } else {
            list.add("");
          }
          if (mate.getStopMark() != -1) {
            list.add(mate.getStopMark());
          } else {
            list.add("");
          }
          if (mate.getPyCode() != null) {
            list.add(mate.getPyCode());
          } else {
            list.add("");
          }
          if (mate.getDCode() != null) {
            list.add(mate.getDCode());
          } else {
            list.add("");
          }
        }
      }
      return list; // 返回list

    } else {
      return null;
    }
  }