コード例 #1
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;
 }
コード例 #2
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;
  }
コード例 #3
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;
    }
  }