Ejemplo n.º 1
0
 public String[] buldingbean2StringArray(BuldingBean bean) {
   String[] strings = new String[4];
   strings[0] = bean.getId();
   strings[1] = Double.toString(bean.getArea());
   strings[2] = Double.toString(bean.getBaseElectric());
   strings[3] = Double.toString(bean.getAirElectric());
   return strings;
 }
Ejemplo n.º 2
0
 public BuldingBean stringArray2BuildBean(String[] strings) {
   BuldingBean tmpBean = new BuldingBean();
   tmpBean.setId(strings[0]);
   tmpBean.setArea(Double.parseDouble(strings[1]));
   tmpBean.setBaseElectric(Double.parseDouble(strings[2]));
   tmpBean.setAirElectric(Double.parseDouble(strings[3]));
   return tmpBean;
 }
Ejemplo n.º 3
0
  public svm_node[] buildingBean2SvmNode(BuldingBean buldingBean) {
    // TODO Auto-generated method stub
    svm_node p0 = new svm_node();
    p0.index = 0;
    p0.value = buldingBean.getBaseElectric();

    svm_node p1 = new svm_node();
    p1.index = 1;
    p1.value = buldingBean.getAirElectric();

    svm_node[] p = {p0, p1};
    return p;
  }
Ejemplo n.º 4
0
  public List<BuldingBean> stringArrays2BuildBeans(List<String[]> list) {
    List<BuldingBean> beans = new ArrayList<BuldingBean>();

    for (int i = 0; i < list.size(); i++) {
      BuldingBean tmpBean = new BuldingBean();
      String[] tmpValues = list.get(i);
      tmpBean.setId(tmpValues[0]);
      tmpBean.setArea(Double.parseDouble(tmpValues[1]));
      tmpBean.setBaseElectric(Double.parseDouble(tmpValues[2]));
      tmpBean.setAirElectric(Double.parseDouble(tmpValues[3]));
      beans.add(tmpBean);
    }

    return beans;
  }
Ejemplo n.º 5
0
  public List<BuldingBean> generateSamples(
      List<BuldingBean> buldingBeans, List<AreaBean> areaBeans) {
    // TODO Auto-generated method stub
    List<BuldingBean> samples = new ArrayList<BuldingBean>();

    Map<String, Double> map = new HashMap<String, Double>();
    for (int i = 0; i < areaBeans.size(); i++) {
      map.put(areaBeans.get(i).getObjectId(), areaBeans.get(i).getArea());
    }
    Set<String> keySet = map.keySet();

    BuldingBean tmp = null;
    String tmpKey = null;
    for (int i = 0; i < buldingBeans.size(); i++) {
      tmp = buldingBeans.get(i);
      tmpKey = tmp.getId();
      if (!keySet.contains(tmpKey)) {
        continue;
      }
      tmp.setArea(map.get(tmpKey));
      samples.add(tmp);
    }
    return samples;
  }
Ejemplo n.º 6
0
 public double getBuldingArea(BuldingBean buldingBean) {
   // TODO Auto-generated method stub
   return buldingBean.getArea();
 }
Ejemplo n.º 7
0
  // 将一个合同账号的12和与用电量转化为基本用电量和空调用电量
  @SuppressWarnings("finally")
  private BuldingBean OTSBillEnergyConvert2BuldingBean(
      List<OTSBillEnergyConvert> billEnergyConverts) {
    BuldingBean bean = new BuldingBean();
    try {
      // 检查合同账号是否包含完整的12个月数据
      if (billEnergyConverts.size() < 12) {
        bean = null;
        throw new SvmModelAction()
        .new SvmException("合同账号: " + billEnergyConverts.get(0).getObjectId() + "含有数据少于12个月份!!");
      }
      double baseElec = 0;
      double airElec = 0;
      OTSBillEnergyConvert tmp = null;

      // 计算基本用电量的月份索引
      ArrayList<Integer> baseMonth = new ArrayList<Integer>();
      baseMonth.add(3);
      baseMonth.add(4);
      baseMonth.add(11);
      baseMonth.add(12);
      // 计算空调用电量的月份索引
      ArrayList<Integer> airMonth = new ArrayList<Integer>();
      airMonth.add(6);
      airMonth.add(7);
      airMonth.add(8);
      airMonth.add(9);

      // 计算基本用电量和空调用电两,空调用电量为减去基本用电量
      for (int i = 0; i < billEnergyConverts.size(); i++) {
        tmp = billEnergyConverts.get(i);

        // 判断一合同账号12个月份中的数据是全部否完整
        if (tmp.getIsComplete() == 1) {
          bean = null;
          throw new SvmModelAction()
          .new SvmException(
              "合同账号: " + tmp.getObjectId() + " " + tmp.getYear() + '年' + tmp.getMonth() + "月数据不完整");
        }

        //				System.out.println(tmp.getMonth());
        if (baseMonth.contains(tmp.getMonth().intValue())) {
          baseElec = baseElec + tmp.getMeasure();
        }
        if (airMonth.contains(tmp.getMonth().intValue())) {
          airElec = airElec + tmp.getMeasure();
        }
      }

      // 将数值注入到目标BuldingBean中
      bean.setId(billEnergyConverts.get(0).getObjectId());
      bean.setBaseElectric(baseElec);
      bean.setAirElectric(airElec - baseElec);
      bean.setArea(0);
    } catch (SvmException e) {
      // TODO: handle exception
      e.printStackTrace();
    } finally {
      return bean;
    }
  }