예제 #1
0
  private ArrayList queryCondition(SaleDetailForm form) {
    ArrayList paramList = new ArrayList();
    where = " where pa.delFlag=0 and sif.stockStatus = 'A' and sif.stuffNo=pa.stuffNo";
    if (form != null) {

      if (form.getSaleNo() != null && !form.getSaleNo().equals("")) {
        where = where + " and pa.saleNo like :saleNo";
        QueryParameter param = new QueryParameter();
        param.setName("saleNo");
        param.setValue(form.getSaleNo());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }

      if (form.getStuffNo() != null && !form.getStuffNo().equals("")) {
        where = where + " and pa.stuffNo like :stuffNo ";
        QueryParameter param = new QueryParameter();
        param.setName("stuffNo");
        param.setValue(form.getStuffNo());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
      if (form.getSkuCode() != null && !form.getSkuCode().equals("")) {
        where = where + " and pa.skuCode like :skuCode ";
        QueryParameter param = new QueryParameter();
        param.setName("skuCode");
        param.setValue(form.getSkuCode());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
      if (form.getModelCode() != null && !form.getModelCode().equals("")) {
        where = where + " and pa.modelCode like :modelCode ";
        QueryParameter param = new QueryParameter();
        param.setName("modelCode");
        param.setValue(form.getModelCode());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
      if (form.getModelSerialNo() != null && !form.getModelSerialNo().equals("")) {
        where = where + " and pa.modelSerialNo like :modelSerialNo ";
        QueryParameter param = new QueryParameter();
        param.setName("modelSerialNo");
        param.setValue(form.getModelSerialNo());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }

      if (form.getCreateBy() != null && form.getCreateBy() != 0) {
        where = where + " and pa.createBy = :createBy";
        QueryParameter param = new QueryParameter();
        param.setName("createBy");
        param.setValue(form.getCreateBy());
        param.setHbType(Hibernate.LONG);
        paramList.add(param);
      }

      if (form.getPartStatus() != null && !form.getPartStatus().equals("")) {
        where = where + " and pa.partStatus = :partStatus";
        QueryParameter param = new QueryParameter();
        param.setName("partStatus");
        param.setValue(form.getPartStatus());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
      if (form.getInDate1() != null && !form.getInDate1().equals("")) {
        where += " and pa.createDate >= :inDate1";
        QueryParameter param = new QueryParameter();
        param.setName("inDate1");
        param.setValue(Operate.toDate(form.getInDate1()));
        param.setHbType(Hibernate.DATE);
        paramList.add(param);
      }
      if (form.getInDate2() != null && !form.getInDate2().equals("")) {
        where += " and pa.createDate < :inDate2";
        QueryParameter param = new QueryParameter();
        param.setName("inDate2");
        param.setValue(Operate.getNextDate(form.getInDate2()));
        param.setHbType(Hibernate.DATE);
        paramList.add(param);
      }
    }
    return paramList;
  }
예제 #2
0
  private ArrayList queryCondition(StockInfoForm form) {
    ArrayList paramList = new ArrayList();
    where = " where 1=1 ";
    try {

      if (form != null) {
        if (form.getOrganizationCode() != null && form.getOrganizationCode().longValue() != 0) {
          where = where + " and pa.organizationCode = :organizationCode";
          QueryParameter param = new QueryParameter();
          param.setName("organizationCode");
          param.setValue(form.getOrganizationCode());
          param.setHbType(Hibernate.LONG);
          paramList.add(param);
        }
        if (form.getStockCode() != null && !form.getStockCode().equals("")) {
          where = where + " and pa.stockCode = :stockCode";
          QueryParameter param = new QueryParameter();
          param.setName("stockCode");
          param.setValue(form.getStockCode());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }
        if (form.getBinCode() != null && !form.getBinCode().equals("")) {
          where = where + " and pa.binCode = :binCode";
          QueryParameter param = new QueryParameter();
          param.setName("binCode");
          param.setValue(form.getBinCode());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }
        if (form.getStockType() != null && !form.getStockType().equals("")) {
          where = where + " and pa.stockType = :stockType";
          QueryParameter param = new QueryParameter();
          param.setName("stockType");
          param.setValue(form.getStockType());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }

        if (form.getSkuType() != null && !form.getSkuType().equals("")) {
          where = where + " and pa.skuType = :skuType";
          QueryParameter param = new QueryParameter();
          param.setName("skuType");
          param.setValue(form.getSkuType());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }
        if (form.getSkuCode() != null && !form.getSkuCode().equals("")) {
          where = where + " and pa.skuCode = :skuCode";
          QueryParameter param = new QueryParameter();
          param.setName("skuCode");
          param.setValue(form.getSkuCode());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }
        if (form.getSkuNum() != null && form.getSkuNum().longValue() != 0) {
          where = where + " and pa.skuNum = :skuNum";
          QueryParameter param = new QueryParameter();
          param.setName("skuNum");
          param.setValue(form.getSkuNum());
          param.setHbType(Hibernate.INTEGER);
          paramList.add(param);
        }

        if (form.getSnNo() != null && !form.getSnNo().equals("")) {
          where = where + " and pa.snNo = :snNo";
          QueryParameter param = new QueryParameter();
          param.setName("snNo");
          param.setValue(form.getSnNo());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }
        if (form.getLotNo() != null && !form.getLotNo().equals("")) {
          where = where + " and pa.lotNo = :lotNo";
          QueryParameter param = new QueryParameter();
          param.setName("lotNo");
          param.setValue(form.getLotNo());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }
        if (form.getFlowNo() != null && !form.getFlowNo().toString().equals("0")) {
          // System.out.println("getFlowNo------------"+form.getFlowNo());
          where = where + " and pa.flowNo = :flowNo";
          QueryParameter param = new QueryParameter();
          param.setName("flowNo");
          param.setValue(form.getFlowNo());
          param.setHbType(Hibernate.LONG);
          paramList.add(param);
        }
        /*
        if (form.getRealCost() != null && form.getRealCost().doubleValue()!=-1) {
        	where = where + " and pa.realCost = :realCost";
        	QueryParameter param = new QueryParameter();
        	param.setName("realCost");
        	param.setValue(form.getRealCost());
        	param.setHbType(Hibernate.DOUBLE);
        	paramList.add(param);
        }
        */
        if (form.getRealCost3() != null && !form.getRealCost3().equals("")) {
          where = where + " and pa.realCost = :realCost";
          QueryParameter param = new QueryParameter();
          param.setName("realCost");
          param.setValue(new Double(form.getRealCost3()));
          param.setHbType(Hibernate.DOUBLE);
          paramList.add(param);
        }

        if (form.getOwner() != null && !form.getOwner().equals("")) {
          where = where + " and pa.owner = :owner";
          QueryParameter param = new QueryParameter();
          param.setName("owner");
          param.setValue(form.getOwner());
          param.setHbType(Hibernate.STRING);
          paramList.add(param);
        }
        if (form.getStockStatus() != null && !form.getStockStatus().equals("")) {
          if ("adjust".equals(form.getStockStatus())) {
            // 可用库存和差错处理
            where = where + " and pa.stockStatus in ('A','B')";
          } else {
            where = where + " and pa.stockStatus = :stockStatus";
            QueryParameter param = new QueryParameter();
            param.setName("stockStatus");
            param.setValue(form.getStockStatus());
            param.setHbType(Hibernate.STRING);
            paramList.add(param);
          }
        }
        if (form.getBinType() != null && !form.getBinType().equals("")) {
          where =
              where
                  + " and pa.binType = (select distinct(sb.binType) from TsStationBinForm as sb,TsStoreInfoForm as si "
                  + "where si.storeId=sb.storeId and si.storeCode=pa.stockCode and sb.binCode=pa.binCode "
                  + "and sb.organizationCode=pa.organizationCode and sb.binType='"
                  + form.getBinType()
                  + "'))";
        }
        if (form.getRequestId() != null && !form.getRequestId().toString().equals("0")) {
          where = where + " and pa.requestId = :requestId";
          QueryParameter param = new QueryParameter();
          param.setName("requestId");
          param.setValue(form.getRequestId());
          param.setHbType(Hibernate.LONG);
          paramList.add(param);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return paramList;
  }
예제 #3
0
  /**
   * Generate HQL sentence for querying results quantity
   *
   * @param aform ActionForm
   * @return AdvQueryString
   */
  protected AdvQueryString generateCountQuery(ActionForm aform) {
    TsRepairLevelForm form = (TsRepairLevelForm) aform;
    AdvQueryString countQuery = new AdvQueryString();
    ArrayList paramList = new ArrayList();
    String queryString = "select count(pa) from TsRepairLevelForm as pa  ";
    String where = " where 1=1 ";
    if (form != null) {
      if (form.getMethodCode() != null && !form.getMethodCode().equals("")) {
        where = where + " and (pa.methodCode like :methodCode ";
        QueryParameter param = new QueryParameter();
        param.setName("methodCode");
        param.setValue(form.getMethodCode());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.methodCode like :methodCodeUPCASE";
        param = new QueryParameter();
        param.setName("methodCodeUPCASE");
        param.setValue("%" + form.getMethodCode().toUpperCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.methodCode like :methodCodeLOWERCASE";
        param = new QueryParameter();
        param.setName("methodCodeLOWERCASE");
        param.setValue("%" + form.getMethodCode().toLowerCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
        where += ")";
      }
      if (form.getPartCode() != null && !form.getPartCode().equals("")) {
        where = where + " and (pa.partCode like :partCode ";
        QueryParameter param = new QueryParameter();
        param.setName("partCode");
        param.setValue(form.getPartCode());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.partCode like :partCodeUPCASE";
        param = new QueryParameter();
        param.setName("partCodeUPCASE");
        param.setValue("%" + form.getPartCode().toUpperCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.partCode like :partCodeLOWERCASE";
        param = new QueryParameter();
        param.setName("partCodeLOWERCASE");
        param.setValue("%" + form.getPartCode().toLowerCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
        where += ")";
      }
      if (form.getBizGroupName() != null && !form.getBizGroupName().equals("")) {
        where = where + " and (pa.bizGroupName like :bizGroupName";
        QueryParameter param = new QueryParameter();
        param.setName("bizGroupName");
        param.setValue(form.getBizGroupName());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.bizGroupName like :bizGroupNameUPCASE";
        param = new QueryParameter();
        param.setName("bizGroupNameUPCASE");
        param.setValue("%" + form.getBizGroupName().toUpperCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.bizGroupName like :bizGroupNameLOWERCASE";
        param = new QueryParameter();
        param.setName("bizGroupNameLOWERCASE");
        param.setValue("%" + form.getBizGroupName().toLowerCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
        where += ")";
      }
      if (form.getRepairType() != null
          && !form.getRepairType().equals("N")
          && !form.getRepairType().equals("")) {
        where = where + " and (pa.repairType = :repairType)";
        QueryParameter param = new QueryParameter();
        param.setName("repairType");
        param.setValue(form.getRepairType());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
      if (form.getRepairProperites() != null
          && !form.getRepairProperites().equals("N")
          && !form.getRepairProperites().equals("")) {
        where = where + " and (pa.repairProperites = :repairProperites)";
        QueryParameter param = new QueryParameter();
        param.setName("repairProperites");
        param.setValue(form.getRepairProperites());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
      if (form.getRepairLevel() != null
          && form.getRepairLevel().longValue() != 0
          && !form.getRepairLevel().equals("")) {
        where = where + " and (pa.repairLevel = :repairLevel) ";
        QueryParameter param = new QueryParameter();
        param.setName("repairLevel");
        param.setValue(form.getRepairLevel());
        param.setHbType(Hibernate.LONG);
        paramList.add(param);
      }
      if (form.getModelCode() != null && !form.getModelCode().equals("")) {
        where = where + " and (pa.modelCode like :modelCode ";
        QueryParameter param = new QueryParameter();
        param.setName("modelCode");
        param.setValue(form.getModelCode());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.modelCode like :modelCodeUPCASE";
        param = new QueryParameter();
        param.setName("modelCodeUPCASE");
        param.setValue("%" + form.getModelCode().toUpperCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);

        where = where + " or pa.modelCode like :modelCodeLOWERCASE";
        param = new QueryParameter();
        param.setName("modelCodeLOWERCASE");
        param.setValue("%" + form.getModelCode().toLowerCase() + "%");
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
        where += ")";
      }
      if (form.getMajorCat() != null && !"".equals(form.getMajorCat())) {
        where = where + " and (pa.majorCat like :majorCat) ";
        QueryParameter param = new QueryParameter();
        param.setName("majorCat");
        param.setValue(form.getMajorCat());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
      if (form.getMinorCat() != null && !"".equals(form.getMinorCat())) {
        where = where + " and (pa.minorCat like :minorCat) ";
        QueryParameter param = new QueryParameter();
        param.setName("minorCat");
        param.setValue(form.getMinorCat());
        param.setHbType(Hibernate.STRING);
        paramList.add(param);
      }
    }
    queryString = queryString + where;

    countQuery.setQueryString(queryString);
    countQuery.setParameters(paramList);

    return countQuery;
  }