|
@@ -1,5 +1,7 @@
|
|
|
package com.gree.mall.manager.logic;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
@@ -7,7 +9,9 @@ import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.nacos.common.util.UuidUtils;
|
|
|
import com.aliyuncs.utils.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.gree.mall.manager.bean.policy.ItfGreeSynDownloadRecBean;
|
|
@@ -65,8 +69,6 @@ public class SyncOrderInfoLogic {
|
|
|
private String v3TokenUrl;
|
|
|
@Value("${gree.V3.client.secert}")
|
|
|
private String v3ClientSecert;
|
|
|
- @Value("${gree.url}")
|
|
|
- private String apiUrlFeedBack;
|
|
|
|
|
|
@Autowired
|
|
|
ItfGreeSynRuleService itfGreeSynRuleService;
|
|
@@ -74,7 +76,7 @@ public class SyncOrderInfoLogic {
|
|
|
@Autowired
|
|
|
ItfGreeSynDownloadRecService itfGreeSynDownloadRecService;
|
|
|
|
|
|
- @Value("${gree.url}")
|
|
|
+ @Value("${gree.four.url}")
|
|
|
private String greeUrl;
|
|
|
|
|
|
@Autowired
|
|
@@ -88,18 +90,24 @@ public class SyncOrderInfoLogic {
|
|
|
|
|
|
String accessToken = this.getAccessTokenV3();
|
|
|
|
|
|
+ log.info(greeUrl+ Constant.gree.GET_UPDATE_ORDERS+"/"+Constant.gree.GUANGZHOUXIAOSI+"/"+time);
|
|
|
|
|
|
- String body = HttpRequest.get(greeUrl+ Constant.gree.GET_UPDATE_ORDERS+"/"+Constant.gree.GUANGZHOUXIAOSI+"/"+time)
|
|
|
- .header("authorization","Bearer " + accessToken)
|
|
|
- .execute().body();
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+
|
|
|
+ Map<String, String> heard = new HashMap<>();
|
|
|
+ heard.put("authorization","Bearer " + accessToken);
|
|
|
+
|
|
|
+ String body = HttpUtils.requestGet(greeUrl+ Constant.gree.GET_UPDATE_ORDERS+"/"+Constant.gree.GUANGZHOUXIAOSI+"/"+time, params,heard);
|
|
|
|
|
|
Map<String,Object> bodyMap = JSON.parseObject(body);
|
|
|
|
|
|
log.info("【工单同步数据内容】:"+bodyMap.get("data").toString());
|
|
|
|
|
|
- JSONArray jsonArray = JSONUtil.parseArray(JSON.parseObject(bodyMap.get("data").toString()));
|
|
|
+ String s = bodyMap.get("data").toString();
|
|
|
|
|
|
|
|
|
+ JSONArray jsonArray = JSONUtil.parseArray(s);
|
|
|
+
|
|
|
List<ItfGreeSynDownloadRecBean> itfGreeSynDownloadRecBeans = JSONUtil.toList(jsonArray, ItfGreeSynDownloadRecBean.class);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(itfGreeSynDownloadRecBeans))
|
|
@@ -108,11 +116,27 @@ public class SyncOrderInfoLogic {
|
|
|
List<ItfGreeSynDownloadRec> itfGreeSynDownloadRecs = new ArrayList<>();
|
|
|
|
|
|
Date date = new Date();
|
|
|
+ String batch = IdWorker.getIdStr();
|
|
|
|
|
|
for (ItfGreeSynDownloadRecBean itfGreeSynDownloadRecBean : itfGreeSynDownloadRecBeans) {
|
|
|
ItfGreeSynDownloadRec itfGreeSynDownloadRec = new ItfGreeSynDownloadRec();
|
|
|
+ itfGreeSynDownloadRec.setSynReqTime(date);
|
|
|
+ itfGreeSynDownloadRec.setGreeStatSynStatus(0);
|
|
|
+ itfGreeSynDownloadRec.setSalesWebsitNumber(itfGreeSynRule.getSalesWebsitNumber());
|
|
|
+ itfGreeSynDownloadRec.setDownloadBatchNo(batch);
|
|
|
+ itfGreeSynDownloadRec.setWorkOrderId(itfGreeSynDownloadRecBean.getWorkOrderId());
|
|
|
+ itfGreeSynDownloadRec.setUpdatedTimestamp(DateUtil.date(Convert.toLong(itfGreeSynDownloadRecBean.getUpdatedTimestamp())));
|
|
|
+ itfGreeSynDownloadRec.setOrderNode(itfGreeSynDownloadRecBean.getOrderNode());
|
|
|
+ itfGreeSynDownloadRec.setRegionOutletsNo(itfGreeSynDownloadRecBean.getRegionOutletsNo());
|
|
|
+ itfGreeSynDownloadRec.setRegionOutletsName(itfGreeSynDownloadRecBean.getRegionOutletsName());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ itfGreeSynDownloadRecs.add(itfGreeSynDownloadRec);
|
|
|
}
|
|
|
|
|
|
+ itfGreeSynDownloadRecService.saveBatch(itfGreeSynDownloadRecs);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -138,12 +162,10 @@ public class SyncOrderInfoLogic {
|
|
|
String s = HttpUtils.requestXwww(v3TokenUrl, forms);
|
|
|
//String s = HttpUtils.requestPostForm(tokenUrl, map, null);
|
|
|
log.info("【获取总部token】response:{}",s);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
- String accessToken = jsonObject.getString("access_token");
|
|
|
- if(StringUtils.isNotEmpty(accessToken)) {
|
|
|
- redisUtil.set(Constant.RedisPrefix.TOKEN_GREE_V3, accessToken, 2 * 60 * 60);
|
|
|
- }
|
|
|
- return accessToken;
|
|
|
+ Map<String,Object> bodyMap = JSON.parseObject(s);
|
|
|
+ Map<String,Object> map = JSON.parseObject(bodyMap.get("data").toString());
|
|
|
+
|
|
|
+ return (String) map.get("access_token");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -175,5 +197,63 @@ public class SyncOrderInfoLogic {
|
|
|
}
|
|
|
|
|
|
public void syncFo() {
|
|
|
+
|
|
|
+ ItfGreeSynRule itfGreeSynRule = itfGreeSynRuleService.lambdaQuery().eq(ItfGreeSynRule::getSalesWebsitNumber, Constant.gree.FOSHANXIAOSI)
|
|
|
+ .one();
|
|
|
+
|
|
|
+ Long time = itfGreeSynRule.getLastSynTime().getTime()/1000;
|
|
|
+
|
|
|
+ String accessToken = this.getAccessTokenV3();
|
|
|
+
|
|
|
+
|
|
|
+ String body = HttpRequest.get(greeUrl+ Constant.gree.GET_UPDATE_ORDERS+"/"+Constant.gree.GUANGZHOUXIAOSI+"/"+time)
|
|
|
+ .header("authorization","Bearer " + accessToken)
|
|
|
+ .execute().body();
|
|
|
+
|
|
|
+
|
|
|
+ Map<String,Object> bodyMap = JSON.parseObject(body);
|
|
|
+
|
|
|
+ log.info("【工单同步数据内容】:"+bodyMap.get("data").toString());
|
|
|
+
|
|
|
+ JSONArray jsonArray = JSONUtil.parseArray(JSON.parseObject(bodyMap.get("data").toString()));
|
|
|
+
|
|
|
+
|
|
|
+ List<ItfGreeSynDownloadRecBean> itfGreeSynDownloadRecBeans = JSONUtil.toList(jsonArray, ItfGreeSynDownloadRecBean.class);
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(itfGreeSynDownloadRecBeans))
|
|
|
+ return;
|
|
|
+
|
|
|
+ List<ItfGreeSynDownloadRec> itfGreeSynDownloadRecs = new ArrayList<>();
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ String batch = IdWorker.getIdStr();
|
|
|
+
|
|
|
+ for (ItfGreeSynDownloadRecBean itfGreeSynDownloadRecBean : itfGreeSynDownloadRecBeans) {
|
|
|
+ ItfGreeSynDownloadRec itfGreeSynDownloadRec = new ItfGreeSynDownloadRec();
|
|
|
+ itfGreeSynDownloadRec.setSynReqTime(date);
|
|
|
+ itfGreeSynDownloadRec.setGreeStatSynStatus(0);
|
|
|
+ itfGreeSynDownloadRec.setSalesWebsitNumber(itfGreeSynRule.getSalesWebsitNumber());
|
|
|
+ itfGreeSynDownloadRec.setDownloadBatchNo(batch);
|
|
|
+ itfGreeSynDownloadRec.setWorkOrderId(itfGreeSynDownloadRecBean.getWorkOrderId());
|
|
|
+ itfGreeSynDownloadRec.setOrderNode(itfGreeSynDownloadRecBean.getOrderNode());
|
|
|
+ itfGreeSynDownloadRec.setRegionOutletsNo(itfGreeSynDownloadRecBean.getRegionOutletsNo());
|
|
|
+ itfGreeSynDownloadRec.setRegionOutletsName(itfGreeSynDownloadRecBean.getRegionOutletsName());
|
|
|
+
|
|
|
+ itfGreeSynDownloadRecs.add(itfGreeSynDownloadRec);
|
|
|
+ }
|
|
|
+
|
|
|
+ itfGreeSynDownloadRecService.saveBatch(itfGreeSynDownloadRecs);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void syncDetail() {
|
|
|
+
|
|
|
+ List<ItfGreeSynDownloadRec> itfGreeSynDownloadRecs = itfGreeSynDownloadRecService.lambdaQuery()
|
|
|
+ .eq(ItfGreeSynDownloadRec::getGreeStatSynStatus, 0).last("limit 10").list();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|