|
@@ -0,0 +1,88 @@
|
|
|
+package com.zswl.cloud.springBtach.server.core.publish;
|
|
|
+
|
|
|
+import com.github.microservice.productcenter.client.model.LocationModel;
|
|
|
+import com.github.microservice.productcenter.client.model.ProductPushModel;
|
|
|
+import com.github.microservice.productcenter.client.model.ProductTriggerTaskModel;
|
|
|
+import com.github.microservice.productcenter.client.model.RegionModel;
|
|
|
+import com.github.microservice.productcenter.client.publish.ProductPublish;
|
|
|
+import com.github.microservice.productcenter.client.service.ProductPushService;
|
|
|
+import com.github.microservice.productcenter.client.stream.ProductCenterStream;
|
|
|
+import com.github.microservice.productcenter.client.type.ProductType;
|
|
|
+import com.github.microservice.productcenter.client.type.RegionType;
|
|
|
+import com.zswl.cloud.springBatch.client.model.dfy.Ticket.request.ScenicListRequest;
|
|
|
+import com.zswl.cloud.springBatch.client.model.dfy.Ticket.response.ScenicListResponse;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.dfy.TicketApi;
|
|
|
+import com.zswl.cloud.springBtach.server.core.dao.XiaoJuStoreDao;
|
|
|
+import com.zswl.cloud.springBtach.server.core.domain.XiaoJuStore;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class PetrolStationPublish implements ProductPublish {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ XiaoJuStoreDao xiaoJuStoreDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductCenterStream productCenterStream;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String regionCode() {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Collection<RegionType> regionType() {
|
|
|
+ return Set.of(RegionType.City);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Collection<ProductType> productTypes() {
|
|
|
+ return Set.of(
|
|
|
+ ProductType.PetrolStation
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void trigger(ProductPushService updateService, ProductTriggerTaskModel productTriggerTask) {
|
|
|
+
|
|
|
+
|
|
|
+ RegionModel region = productTriggerTask.getRegion();
|
|
|
+ String name = region.getName();
|
|
|
+
|
|
|
+ xiaoJuStoreDao.findByCityNameContains(name).forEach(it -> {
|
|
|
+ try {
|
|
|
+ LocationModel locationModel = new LocationModel();
|
|
|
+ locationModel.setLongitude(it.getLon());
|
|
|
+ locationModel.setLatitude(it.getLat());
|
|
|
+ productCenterStream.send(List.of(
|
|
|
+ ProductPushModel.builder()
|
|
|
+ .regionCode(productTriggerTask.getRegion().getCode())
|
|
|
+ .pid(it.getStoreId())
|
|
|
+ .productType(ProductType.PetrolStation)
|
|
|
+ .cover(it.getPicList().stream().toArray(String[]::new))
|
|
|
+ .title(it.getStoreName())
|
|
|
+ .address(it.getAddress())
|
|
|
+ .meta(Map.of("store", it))
|
|
|
+ .locationPoint(locationModel)
|
|
|
+ .build()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|