Browse Source

处理因对方字段缺失导致同步异常

master
xyiege 3 years ago
parent
commit
51ecf7afc6
  1. 13
      src/main/java/cn/chjyj/szwh/utils/ApiGoodsUtils.java

13
src/main/java/cn/chjyj/szwh/utils/ApiGoodsUtils.java

@ -5,6 +5,8 @@ import cn.chjyj.szwh.bean.GoodsDetail;
import cn.chjyj.szwh.bean.GoodsSource;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
@ -15,6 +17,7 @@ import java.util.Date;
* 处理api数据转为bean
*/
public class ApiGoodsUtils {
private static Log log = LogFactory.getLog(ApiGoodsUtils.class);
/**
* 从json字符串中抽取对象
@ -164,12 +167,20 @@ public class ApiGoodsUtils {
goodsDetail.setDataJson(nodejson.toJSONString());
goodsDetail.setSourceJson(json.toJSONString());
String sdate= json.getString("releaseTime");
//如果时间为空
if(StringUtils.isNotEmpty(sdate)) {
try {
Date createTime = sdf.parse(sdate);
goodsDetail.setCreatetime(createTime);
goodsDetail.setUpdatetime(createTime);
}catch (Exception ex){
} catch (Exception ex) {
//do nothing
log.error("商品详情createtime错误:" + ex.getStackTrace().toString());
}
}else {
Date now =new Date();
goodsDetail.setCreatetime(now);
goodsDetail.setUpdatetime(now);
}
//其他状态
goodsDetail.setIsDeleted(0);

Loading…
Cancel
Save