5 changed files with 124 additions and 6 deletions
@ -0,0 +1,67 @@ |
|||||
|
package cn.chjyj.szwh.utils; |
||||
|
|
||||
|
import cn.chjyj.szwh.bean.GoodsSource; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 处理api数据,转为bean |
||||
|
*/ |
||||
|
public class ApiGoodsUtisl { |
||||
|
/** |
||||
|
* 从json字符串中抽取对象 |
||||
|
* @param innerJson |
||||
|
* @param islicode |
||||
|
* @return |
||||
|
*/ |
||||
|
public static GoodsSource jsonToGoodsSource(JSONObject innerJson,String islicode){ |
||||
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
|
GoodsSource goodsSource = new GoodsSource(); |
||||
|
goodsSource.setServicecode(innerJson.getString("'serviceCode'")); |
||||
|
goodsSource.setLinkcode(innerJson.getString("linkCode")); |
||||
|
// 发布 id
|
||||
|
String pubid = innerJson.getString("publisherId"); |
||||
|
goodsSource.setPublisherid(Integer.valueOf(pubid)); |
||||
|
goodsSource.setRegistrant(innerJson.getString("register")); |
||||
|
goodsSource.setResolutionUrl(innerJson.getString("resolutionUrl")); |
||||
|
goodsSource.setSourceType(innerJson.getString("sourceType")); |
||||
|
goodsSource.setSourceNameType(innerJson.getString("sourceNameType")); |
||||
|
goodsSource.setSourceName(innerJson.getString("sourceName")); |
||||
|
//
|
||||
|
goodsSource.setSourceidentify(innerJson.getString("sourceIdentify")); |
||||
|
goodsSource.setSourceFragment(innerJson.getString("sourceFragment")); |
||||
|
goodsSource.setTargetName(innerJson.getString("targetName")); |
||||
|
goodsSource.setTargetNameType(innerJson.getString("targetNameType")); |
||||
|
goodsSource.setTargetidentify(innerJson.getString("targetIdentify")); |
||||
|
//
|
||||
|
goodsSource.setTargetFragment(innerJson.getString("targetFragment")); |
||||
|
goodsSource.setTargetformat(innerJson.getString("targetFormat")); |
||||
|
// 存放了json字符串
|
||||
|
goodsSource.setSourceData(innerJson.getString("sourceData")); |
||||
|
goodsSource.setTargetData(innerJson.getString("targetData")); |
||||
|
//
|
||||
|
goodsSource.setMetadataxml(innerJson.getString("metadataXml")); |
||||
|
goodsSource.setCancellationReason(innerJson.getString("cancellationReason")); |
||||
|
// 字符串转为日期时间格式
|
||||
|
String aldate =innerJson.getString("allocationDate"); |
||||
|
try { |
||||
|
Date ndate = sdf.parse(aldate); |
||||
|
goodsSource.setAllocationtime(ndate); |
||||
|
}catch (Exception ex){ |
||||
|
// do nothing
|
||||
|
} |
||||
|
goodsSource.setSourceType(innerJson.getString("dataType")); |
||||
|
try{ |
||||
|
String cldate = innerJson.getString("cancellationDate"); |
||||
|
Date cndate =sdf.parse(cldate); |
||||
|
goodsSource.setCancellationtime(cndate); |
||||
|
}catch (Exception ex){ |
||||
|
//do nothing
|
||||
|
} |
||||
|
// 产品主键
|
||||
|
goodsSource.setGoodsIsliCode(islicode); |
||||
|
return goodsSource; |
||||
|
} |
||||
|
} |
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue