生活随笔
收集整理的這篇文章主要介紹了
NC集成旺店通使用JSONObject获取数据
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
NC使用JSONObject獲取數據
小例子測試,非正式環境系統
需要引入com.alibaba.fastjson.JSONObject.jar或net.sf.json.JSONObject.jarnet.sf.json.JSONObject轉換JSON方式JSONObject json=JSONObject.fromObject(request.getParameter("data"));com.alibaba.fastjson.JSONObject 方式 JSONObject.parseObject(response1);
public class Demo {public static void main(String
[] args
) {IVOPersistence ivop
= NCLocator
.getInstance().lookup(IVOPersistence
.class);JSONObject json
=JSONObject
.fromObject(request
.getParameter("data"));Map
<String, Object> map
=json
;String token
= map
.get("token").toString();String abledate
= map
.get("abledate").toString();Integer base_doc_type
= (Integer
) map
.get("base_doc_type");......UserVO userVO
= new UserVO();userVO
.setAbledate(new UFDate(abledate
));userVO
.setBase_doc_type(base_doc_type
);userVO
.setContentlang(contentlang
);....try {ivop
.insertVO(userVO
);} catch (BusinessException e
) {e
.printStackTrace();}SONObject json
=JSONObject
.fromObject(request
.getParameter("data"));JSONObject head
= json
.getJSONObject("head");Map
<JSONObject, JSONObject> map
=head
;JSONArray bodyjson
=json
.getJSONArray("body");OrderVO orderVO
= new OrderVO();OrderHeaderVO headerVO
= new OrderHeaderVO();OrderItemVO itemVO
= new OrderItemVO();ArrayList
<OrderItemVO> list
= new ArrayList<OrderItemVO>();
String user_code_q
= map
.get("user_code_q").toString();String bcooptoso
= map
.get("bcooptoso").toString();String bdirect
= map
.get("bdirect").toString();.....Map
<JSONObject,JSONObject> body
= null
;for (int i
= 0; i
< bodyjson
.size(); i
++) {body
= bodyjson
.getJSONObject(i
);}String barriveclose
= body
.get(" barriveclose").toString();String bborrowpur
= body
.get("bborrowpur").toString();....list
.add(itemVO
);orderVO
.setParent(headerVO
);orderVO
.setChildrenVO(list
.toArray(new OrderItemVO[list
.size()]));PFBusiAction PFBusiAction
= new PFBusiAction();try {PFBusiAction
.processAction("WRITE", "4R", null
, orderVO
, null
, null
);} catch (Exception e
) {e
.printStackTrace();}WdtClient client
= new WdtClient(sid
,appkey
,appsecret
,baseUrl
);Map
<String, String> params
= new HashMap<String, String>();Calendar cal
=Calendar
.getInstance();cal
.add(Calendar
.DATE
,-1);Date d
=cal
.getTime();SimpleDateFormat sp
=new SimpleDateFormat("yyyy-MM-dd");String ZUOTIAN
=sp
.format(d
);params
.put("consign_date","2020-10-25");String response1
= client
.execute("vip_stat_sales_by_spec_shop_warehouse_query.php", params
);JSONObject json
= JSONObject
.parseObject(response1
);JSONObject json2
= json
.getJSONObject("content");JSONArray listjosn
= json2
.getJSONArray("spec_list");for (int i
= 0; i
< listjosn
.size(); i
++) {saleVo
= new SaleOrderVO ();saleHVo
= new SaleOrderHVO();saleBVo
= new SaleOrderBVO ();list
= new ArrayList<SaleOrderBVO>();Map
<String, Object> map
= listjosn
.getJSONObject(i
);String rec_id
= map
.get("rec_id").toString();String consign_date
= map
.get("consign_date").toString();String sales_date
= map
.get("sales_date").toString();String order_type
= map
.get("order_type").toString(); try {PFBusiAction
.processAction("WRITE", "30", w
, saleVo
, null
, null
);Logger
.info("銷售訂單匯總數據保存成功"+spec_no
);} catch (Exception e
) {e
.printStackTrace();Logger
.info("銷售訂單匯總數據保存失敗異常 "+e
);}}}}
總結
以上是生活随笔為你收集整理的NC集成旺店通使用JSONObject获取数据的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。