日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

NC集成旺店通使用JSONObject获取数据

發(fā)布時間:2024/5/14 javascript 61 豆豆
生活随笔 收集整理的這篇文章主要介紹了 NC集成旺店通使用JSONObject获取数据 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

NC使用JSONObject獲取數(shù)據(jù)
小例子測試,非正式環(huán)境系統(tǒng)

  • 需要引入com.alibaba.fastjson.JSONObject.jar或net.sf.json.JSONObject.jar
  • net.sf.json.JSONObject轉(zhuǎn)換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);//單表方式//獲取整個json(data)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");......//封裝VOUserVO 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) {// TODO 自動生成的 catch 塊e.printStackTrace();}/*多表方式*///獲取整個json(data)SONObject json=JSONObject.fromObject(request.getParameter("data"));//獲取表頭數(shù)據(jù)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>();/*** 獲取表頭頁面數(shù)據(jù)*/// 審批人 // String user_code_q = map.get("user_code_q");String user_code_q= map.get("user_code_q").toString();// 已協(xié)同生成銷售訂單String bcooptoso = map.get("bcooptoso").toString();// 直運采購String bdirect = map.get("bdirect").toString();...../*** 獲取子表頁面數(shù)據(jù)* 循環(huán)遍歷json,獲取數(shù)據(jù)* 表體可能會有多條數(shù)據(jù)成為數(shù)組,轉(zhuǎn)換時需要使用JSONArray* */Map<JSONObject,JSONObject> body = null;for (int i = 0; i < bodyjson.size(); i++) {body = bodyjson.getJSONObject(i);}// 到貨關(guān)閉String barriveclose = body.get(" barriveclose").toString();// 借入轉(zhuǎn)采購String bborrowpur = body.get("bborrowpur").toString();....//利用主子表的VO類把主表/子表VO進行set 插入數(shù)據(jù)list.add(itemVO);orderVO.setParent(headerVO);orderVO.setChildrenVO(list.toArray(new OrderItemVO[list.size()]));//執(zhí)行持久化操作PFBusiAction PFBusiAction = new PFBusiAction();try {PFBusiAction.processAction("WRITE", "4R", null, orderVO, null, null);} catch (Exception e) {e.printStackTrace();}//通過api返回獲取數(shù)據(jù),//例子以旺店通為例WdtClient client = new WdtClient(sid,appkey,appsecret,baseUrl);//查詢數(shù)據(jù)部需要傳入時間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");// client.execute("api", 傳入的參數(shù));String response1 = client.execute("vip_stat_sales_by_spec_shop_warehouse_query.php", params);//轉(zhuǎn)換成JSONJSONObject json = JSONObject.parseObject(response1);根據(jù)返回數(shù)據(jù)格式獲取數(shù)據(jù)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>();//根據(jù)下標獲取Map<String, Object> map = listjosn.getJSONObject(i);//行標識String rec_id = map.get("rec_id").toString();//發(fā)貨日期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("銷售訂單匯總數(shù)據(jù)保存成功"+spec_no);} catch (Exception e) {e.printStackTrace();Logger.info("銷售訂單匯總數(shù)據(jù)保存失敗異常 "+e);}}}}

    總結(jié)

    以上是生活随笔為你收集整理的NC集成旺店通使用JSONObject获取数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。