|
|
|
@ -1,8 +1,8 @@ |
|
|
|
package cn.chjyj.szwh; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.utils.RequestUtils; |
|
|
|
import cn.chjyj.szwh.utils.SignUtils; |
|
|
|
import cn.chjyj.szwh.utils.SzwhApiUtils; |
|
|
|
import cn.chjyj.szwh.bean.GoodsDetail; |
|
|
|
import cn.chjyj.szwh.bean.GoodsSource; |
|
|
|
import cn.chjyj.szwh.utils.*; |
|
|
|
import com.alibaba.fastjson2.JSONArray; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import org.junit.Test; |
|
|
|
@ -86,4 +86,45 @@ public class ApiTest { |
|
|
|
System.out.println(calendar.get(1)); |
|
|
|
System.out.println(calendar.get(2)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新和入库操作 |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
public void insertGoods(){ |
|
|
|
String url ="http://localhost:90/as.json"; |
|
|
|
String host = ProperUtils.getSzwhProp("ENTRUST_URL"); |
|
|
|
//创建签名
|
|
|
|
String sign = SignUtils.createSign("entrust"); |
|
|
|
// 请求头
|
|
|
|
Map<String, Object> hmap = new HashMap(); |
|
|
|
hmap.put("entrust_token", sign); |
|
|
|
JSONObject sdjson = RequestUtils.GetData(url,hmap,false); |
|
|
|
// String nsdstr = sdjson.getString("sourceData");
|
|
|
|
// sdjson有数组
|
|
|
|
JSONArray jarr = sdjson.getJSONArray("data"); |
|
|
|
for(int i=0;i<jarr.size();i++){ |
|
|
|
JSONObject innerJobj = (JSONObject) jarr.get(i); |
|
|
|
//getJSONObject("sourceData");
|
|
|
|
String nsdstr = innerJobj.getString("sourceData"); |
|
|
|
JSONObject nsdjson = JSONObject.parseObject(nsdstr); |
|
|
|
// 从sourcedata节点中提取商品唯一编号
|
|
|
|
String goodsId = nsdjson.getString("identifier"); |
|
|
|
//详情
|
|
|
|
String gdurl = host + "/consign/exchange/v1/selectEntrustDetails"; |
|
|
|
String gdetailUrl = gdurl + "/" + goodsId; |
|
|
|
JSONObject gdJson = RequestUtils.GetData(gdetailUrl, hmap,true); |
|
|
|
JSONObject gditem = gdJson.getJSONObject("data"); |
|
|
|
//goods source
|
|
|
|
if(gditem!=null) { |
|
|
|
GoodsSource goodsSource = ApiGoodsUtils.jsonToGoodsSource(gditem, goodsId); |
|
|
|
System.out.println(goodsSource.getLinkcode()); |
|
|
|
} |
|
|
|
// 商品详情
|
|
|
|
GoodsDetail goodsDetail = ApiGoodsUtils.jsonToGoodsDetail(nsdjson, sdjson); |
|
|
|
System.out.println(goodsDetail.getGoodsName()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|