qryBeanStr="{"kpi_code":"11010111001","kpiDims":[{"dim_id":"1005","dim_name":"按订购可选包流量分层","kpiDimValues":[{"level_id":"102","level_description":"可选包流量=50MB"},{"level_id":"103","level_description":"可选包流量=70MB"},{"level_id":"104","level_description":"可选包流量=150MB"},{"level_id":"105","level_description":"可选包流量=500MB"}]},{"dim_id":"1004","dim_name":"按订购基本包流量分层","kpiDimValues":[{"level_id":"101","level_description":"基本包流量<30MB"},{"level_id":"102","level_description":"基本包流量=30MB"},{"level_id":"103","level_description":"基本包流量=50MB"}]},{"dim_id":"1009","dim_name":"WLAN使用时长分层","kpiDimValues":[{"level_id":"101","level_description":"0<WLAN时长<=15小时"}]}]}"
baseBeanStr="{"chunk_id":"310002","kpi_type":"99","kpi_code":"11010111001","sum_month":"201308","area_id":0,"area_name":"福建","region_type":"1"}"
java代码
KpiAnalysisQryBean qryBean = new KpiAnalysisQryBean(); BaseReqBean baseReqBean = new BaseReqBean(); String qryBeanStr = request.getParameter("qryBean"); String baseBeanStr = request.getParameter("baseBean"); JSONObject qryBeanJson = JSONObject.fromObject(qryBeanStr); JSONObject baseReqBeanJson = JSONObject.fromObject(baseBeanStr); BeanUtils.copyProperties(qryBean, qryBeanJson); BeanUtils.copyProperties(baseReqBean, baseReqBeanJson); qryBean.setKpiDims((List<KpiDim>)JSONArray.toList((JSONArray)qryBeanJson.get("kpiDims"), KpiDim.class)); for(int i=0; i<qryBean.getKpiDims().size(); i++){ qryBean.getKpiDims().get(i).setKpiDimValues((List<KpiDimValue>)JSONArray.toList(((JSONArray)(((JSONArray)qryBeanJson.get("kpiDims")).getJSONObject(i).get("kpiDimValues"))), KpiDimValue.class)); }bean 对象
public class KpiAnalysisQryBean { private String kpi_code = null; private String dim_id = null; private String level_id = null; private List<KpiDim> kpiDims = null; public String getKpi_code() { return kpi_code; } public void setKpi_code(String kpi_code) { this.kpi_code = kpi_code; } public List<KpiDim> getKpiDims() { return kpiDims; } public void setKpiDims(List<KpiDim> kpiDims) { this.kpiDims = kpiDims; } public String getDim_id() { return dim_id; } public void setDim_id(String dim_id) { this.dim_id = dim_id; } public String getLevel_id() { return level_id; } public void setLevel_id(String level_id) { this.level_id = level_id; } }
public class KpiDim { private String dim_id = null; //维度编码 private String dim_name = null; //维度名称 private String use_cnt = null; //使用频率 private List<KpiDimValue> kpiDimValues = null; public String getDim_id() { return dim_id; } public void setDim_id(String dim_id) { this.dim_id = dim_id; } public String getDim_name() { return dim_name; } public void setDim_name(String dim_name) { this.dim_name = dim_name; } public List<KpiDimValue> getKpiDimValues() { return kpiDimValues; } public void setKpiDimValues(List<KpiDimValue> kpiDimValues) { this.kpiDimValues = kpiDimValues; } public String getUse_cnt() { return use_cnt; } public void setUse_cnt(String use_cnt) { this.use_cnt = use_cnt; } }
public class KpiDimValue { private String level_id = null; //层级 private String level_description = null; //层级描述 public String getLevel_id() { return level_id; } public void setLevel_id(String level_id) { this.level_id = level_id; } public String getLevel_description() { return level_description; } public void setLevel_description(String level_description) { this.level_description = level_description; } }