|
@@ -1,20 +1,31 @@
|
|
|
package com.zswl.cloud.springBtach.server.core.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.auth.client.content.ResultContent;
|
|
|
import com.github.microservice.auth.client.content.ResultState;
|
|
|
+import com.zswl.cloud.shop.client.dto.life.TripartiteShopDto;
|
|
|
+import com.zswl.cloud.shop.client.service.ShopService;
|
|
|
import com.zswl.cloud.springBatch.client.model.dfy.Ticket.request.*;
|
|
|
import com.zswl.cloud.springBatch.client.model.dfy.Ticket.response.*;
|
|
|
import com.zswl.cloud.springBatch.client.service.DfyTicketService;
|
|
|
import com.zswl.cloud.springBtach.server.core.api.dfy.TicketApi;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
|
+@Log4j2
|
|
|
public class DfyTicketServiceImpl implements DfyTicketService {
|
|
|
|
|
|
@Autowired
|
|
|
TicketApi ticketApi;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ShopService shopService;
|
|
|
+
|
|
|
|
|
|
public ResultContent<ScenicListResponse> scenicList(ScenicListRequest scenicListRequest) {
|
|
|
return ResultContent.buildContent(ticketApi.scenicList(scenicListRequest));
|
|
@@ -82,26 +93,55 @@ public class DfyTicketServiceImpl implements DfyTicketService {
|
|
|
|
|
|
int pageNo = 1;
|
|
|
int pageSize = 10;
|
|
|
- ScenicListRequest scenicListRequest = new ScenicListRequest();
|
|
|
- scenicListRequest.setPage(pageNo);
|
|
|
- scenicListRequest.setPageSize(pageSize);
|
|
|
-
|
|
|
- ScenicListResponse scenicListResponse = ticketApi.scenicList(scenicListRequest);
|
|
|
- Integer totalCount = scenicListResponse.getData().getTotalCount();
|
|
|
-
|
|
|
- while (true){
|
|
|
-
|
|
|
- for (ScenicListResponse.rows row : scenicListResponse.getData().getRows()) {
|
|
|
-
|
|
|
- String scenicId = row.getScenicId();
|
|
|
- String scenicName = row.getScenicName();
|
|
|
- String newPicUrl = row.getNewPicUrl();
|
|
|
- String address = row.getAddress();
|
|
|
-
|
|
|
|
|
|
+ try {
|
|
|
+
|
|
|
+ while (true) {
|
|
|
+ ScenicListRequest scenicListRequest = new ScenicListRequest();
|
|
|
+ scenicListRequest.setPage(pageNo);
|
|
|
+ scenicListRequest.setPageSize(pageSize);
|
|
|
+
|
|
|
+ ScenicListResponse scenicListResponse = ticketApi.scenicList(scenicListRequest);
|
|
|
+ if (scenicListResponse.getData().getRows().size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (ScenicListResponse.rows row : scenicListResponse.getData().getRows()) {
|
|
|
+ ScenicDetailResponse scenicDetailResponse = ticketApi.scenicDetail(new ScenicDetailRequest(row.getScenicId()));
|
|
|
+ ScenicDetailResponse.Datas data = scenicDetailResponse.getData();
|
|
|
+
|
|
|
+ String glocation = row.getGlocation();
|
|
|
+ if (ObjectUtil.isEmpty(glocation)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ String[] split = glocation.split(",");
|
|
|
+
|
|
|
+ TripartiteShopDto tripartiteShopDto = new TripartiteShopDto();
|
|
|
+ tripartiteShopDto.setKey("门票");
|
|
|
+ tripartiteShopDto.setTripartiteId(row.getScenicId());
|
|
|
+ tripartiteShopDto.setShopName(row.getScenicName());
|
|
|
+ tripartiteShopDto.setShopMenuId("1");
|
|
|
+ tripartiteShopDto.setProvince(ObjectUtil.isEmpty(data.getProvinceName()) ? data.getCityName() : data.getProvinceName());
|
|
|
+ tripartiteShopDto.setCity(data.getCityName());
|
|
|
+ tripartiteShopDto.setAddress(row.getAddress());
|
|
|
+ tripartiteShopDto.setMapLon(split[1]);
|
|
|
+ tripartiteShopDto.setMapLat(split[0]);
|
|
|
+ tripartiteShopDto.setLogoPath(row.getNewPicUrl());
|
|
|
+ tripartiteShopDto.setDetailImg(data.getDefaultPic());
|
|
|
+ tripartiteShopDto.setTripartiteJson(JSONUtil.toJsonStr(data));
|
|
|
+
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent resultContent = shopService.tripartiteShop(tripartiteShopDto);
|
|
|
+ log.info("景区创建店铺响应:{}", JSONUtil.toJsonStr(resultContent));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ pageNo++;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("pageNo:{};pageSize:{}", pageNo, pageSize);
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|