package com.trunko.invoke;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.codehaus.jackson.map.ObjectMapper; import com.trunko.webservice.ZdxmProService; import com.trunko.webservice.ZdxmProServiceService; public class Test { public static void main(String[] args) { ZdxmProServiceService zs = new ZdxmProServiceService(); ZdxmProService zp = zs.getZdxmProServicePort(); String xmlist =zp.getXmlist("在建","2016","8","zd_shx"); JSONArray ja = JSONArray.fromObject(xmlist); for (int i = 0; i < ja.size(); i++) { JSONObject jo = ja.getJSONObject(i); System.out.println(jo.get("mc")); } // String slist = zp.getZdxmlist("","","zd_lcx"); //获取重点项目集合 // JSONObject jb = JSONObject.fromObject(slist); //取查询参数params,是个json数组 // JSONArray jsons = jb.getJSONArray(slist); // System.out.println(list.size()); // for (int i = 0; i < list.size(); i++) { // System.out.println(list.get(i).getMc()); // // } // //获取重点项目详情 // ProZdxm p = zp.getZdxmById(1772); // System.out.println(p.getMc()); //获取月报列表 // List<ProZdxm> list = zp.getZdyblist("zd_lcx","在建",2016); // System.out.println(list.size()); // for (int i = 0; i < list.size(); i++) { // System.out.println(list.get(i).getMc()); // // } //获取当前项目各个月的月报 // List<ProZdxmYb> list =zp.getYblblist(1772); // for (int i = 0; i < list.size(); i++) { // System.out.println(list.get(i).getDwzjhj()); // // } //获取月报详情 // String str = zp.getYbDetail(1772); // JSONObject jo = JSONObject.fromObject(str); // ProZdxmYb pb = (ProZdxmYb) JSONToObj(jo.getString("zdxmyb").toString(),ProZdxmYb.class); // ProZdxm pz = (ProZdxm) JSONToObj(jo.getString("zdxm").toString(),ProZdxm.class); // System.out.println(pz.getMc()); // System.out.println(pb.getBywc()); //获取跳转添加月报数据 // String str=zp.toAddYb("1944"); // JSONObject jo = JSONObject.fromObject(str); // ProZdxmYb pb = (ProZdxmYb) JSONToObj(jo.getString("zdxmyb").toString(),ProZdxm.class); // System.out.println(pz.getMc()); // System.out.println(pb.getMessage()); //添加月报 // String str= zp.addYb("1772","500","800","700","2000","300","400","1000","1200","进展可以","5","33","工作计划和","情况厉害","规模宏大","未上报"); // System.out.println(str); //获取月报编辑 // String str = zp.toEditYb("1772"); // JSONObject jo = JSONObject.fromObject(str); // ProZdxmYb pb = (ProZdxmYb) JSONToObj(jo.getString("zdxmyb").toString(),ProZdxm.class); // System.out.println(pz.getMc()); //编辑月报 //添加月报 // String str= zp.editYb("1772","已上报"); // System.out.println(str); // String str = zp.saveUp(21017); // System.out.println(str); } public static<T> Object JSONToObj(String jsonStr,Class<T> obj) { T t = null; try { ObjectMapper objectMapper = new ObjectMapper(); t = objectMapper.readValue(jsonStr,obj); } catch (Exception e) { e.printStackTrace(); } return t; } } 原文链接:https://www.f2er.com/json/289212.html