|
|
|
@ -18,6 +18,7 @@ import org.apache.commons.logging.LogFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
@ -154,4 +155,68 @@ public class GoodsSourceServiceImpl implements GoodsSourceService { |
|
|
|
retmap.put("gather_arr",gatherList); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* add new GoodsSource |
|
|
|
* @param res 传递过来的json字符串 |
|
|
|
* @param islicode 商品编码 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int insertGoodsSource(String res, String islicode) { |
|
|
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
// 抽取出现对应数据
|
|
|
|
JSONArray jarr = JSONObject.parseArray(res); |
|
|
|
for(int i=0;i<jarr.size();i++){ |
|
|
|
JSONObject innerJson = (JSONObject) jarr.get(i); |
|
|
|
// 转为对象
|
|
|
|
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); |
|
|
|
// 执行插入
|
|
|
|
goodsSourceMapper.add(goodsSource); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|