From ee0854002e0af22dd353da6fce12fc44cdcee6db Mon Sep 17 00:00:00 2001 From: "taylor.dang" Date: Tue, 18 Sep 2018 11:12:05 +0800 Subject: [PATCH] =?UTF-8?q?[Y]=20=E5=95=86=E6=88=B7=E5=9C=B0=E7=90=86?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MerchantLocationServiceImpl.java | 23 ++++++------ .../manage/task/initClientLocationTask.java | 35 +++++++++++++++++++ 2 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/MerchantLocationServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/MerchantLocationServiceImpl.java index 24ca4aad1..8ddac5def 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/MerchantLocationServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/MerchantLocationServiceImpl.java @@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.util.UriComponentsBuilder; import javax.annotation.Resource; -import java.io.IOException; import java.net.URISyntaxException; import java.util.Date; import java.util.List; @@ -31,10 +30,18 @@ import java.util.concurrent.TimeUnit; @Service public class MerchantLocationServiceImpl implements MerchantLocationService { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private static final String GOOGLE_MAPS_API = "https://maps.googleapis.com/maps/api/geocode/json"; + + private static final String GOOGLE_API_KEY = "AIzaSyDUu6qXRV-j24rSdbPOMfVdTN1-2OfC2o8"; + + private ThreadPoolExecutor pool = new ThreadPoolExecutor(5, 100, 5, TimeUnit.SECONDS, new LinkedBlockingQueue()); + + private Set failureSet = new ConcurrentSet<>(); @Resource private ClientLocationsMapper clientLocationsMapper; - @Resource private ClientManager clientManager; @@ -45,22 +52,12 @@ public class MerchantLocationServiceImpl implements MerchantLocationService { return clientLocationsMapper.getAllMerchantsLocations(params); } - private Logger logger = LoggerFactory.getLogger(getClass()); - - private static final String GOOGLE_MAPS_API = "https://maps.googleapis.com/maps/api/geocode/json"; - - // private static final String GOOGLE_API_KEY = "AIzaSyBbt7XV5PdXqB2aZeVFAZIzOTO0W6gn_YY"; - private static final String GOOGLE_API_KEY = "AIzaSyDUu6qXRV-j24rSdbPOMfVdTN1-2OfC2o8"; - - private ThreadPoolExecutor pool = new ThreadPoolExecutor(5, 100, 5, TimeUnit.SECONDS, new LinkedBlockingQueue()); - private Set failureSet = new ConcurrentSet<>(); - @Resource private JdbcTemplate jdbcTemplate; @Override public void initClientLocations() throws InterruptedException { - List> clients = jdbcTemplate.queryForList("select client_id, CONCAT(IFNULL(address,''),' ',IFNULL(suburb,''),' ',IFNULL(state,''),' ',IFNULL(country,'')) as 'address' from royalpay_production.sys_clients where client_id not in (select client_id from royalpay_production.sys_clients_locations) AND client_moniker in ('CUEC','SEA8','SEA0','SEA2','SEA7','HUNT','HLSY','RIMO','TONY','SUCS','SUEM','SUSO','NEW2','NEW1','NEW3','SABO','TSRE','AQSY','JUSC','YMKP','ETAS','EASW','MEET','TDBR','DOUB','NOON','H2GR','LKST','ASON','JSMS','HIDA','DAFR','XANY','VEJE','LUTI','CNHJ','EHPL','YIFA','MRMA','NGMT','BJKC','FORU','CHED','GSAP','ASQI','OMPL','XAMC','HMJC','MGPL','6PHD','MTCS','AIND','KOTN','FDWK','NHKP','GFIT','GHCA','OGPL','RTCB','HOTT','MCRE','YBDW','WPX1','SFPT','WPXM','HOFT','AUID','SUBX','GBTK','PERA','TDCS','DUMP','QJF2','LBWD','HUGG','YINI','CALA','XHJJ','BLUS','SSSS','HEND')"); + List> clients = jdbcTemplate.queryForList("select client_id, CONCAT(IFNULL(address,''),' ',IFNULL(suburb,''),' ',IFNULL(state,''),' ',IFNULL(country,'')) as 'address' from royalpay_production.sys_clients where client_id not in (select client_id from royalpay_production.sys_clients_locations) "); final int totalLen = clients.size(); logger.info("total length:" + totalLen); for (int i = 0; i < totalLen; i++) { diff --git a/src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java b/src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java new file mode 100644 index 000000000..f7b23547c --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java @@ -0,0 +1,35 @@ +package au.com.royalpay.payment.manage.task; + +import au.com.royalpay.payment.manage.dev.core.MerchantLocationService; +import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * Created by wangning on 2018/1/2. + */ +@Component +@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") +public class initClientLocationTask { + @Resource + private MerchantLocationService merchantLocationService; + @Resource + private SynchronizedScheduler synchronizedScheduler; + + @Scheduled(cron = "0 0 5 * * *") + public void checkBillOrderCheck() { + synchronizedScheduler.executeProcess("manage_task:initClientLocation", 120_000, () -> { + try { + merchantLocationService.initClientLocations(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + + } +}