[Y] 商户地理位置定时任务

master
taylor.dang 6 years ago
parent 2ebe5a2eb7
commit ee0854002e

@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -31,10 +30,18 @@ import java.util.concurrent.TimeUnit;
@Service @Service
public class MerchantLocationServiceImpl implements MerchantLocationService { 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<Runnable>());
private Set<Integer> failureSet = new ConcurrentSet<>();
@Resource @Resource
private ClientLocationsMapper clientLocationsMapper; private ClientLocationsMapper clientLocationsMapper;
@Resource @Resource
private ClientManager clientManager; private ClientManager clientManager;
@ -45,22 +52,12 @@ public class MerchantLocationServiceImpl implements MerchantLocationService {
return clientLocationsMapper.getAllMerchantsLocations(params); 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<Runnable>());
private Set<Integer> failureSet = new ConcurrentSet<>();
@Resource @Resource
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Override @Override
public void initClientLocations() throws InterruptedException { public void initClientLocations() throws InterruptedException {
List<Map<String, Object>> 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<Map<String, Object>> 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(); final int totalLen = clients.size();
logger.info("total length:" + totalLen); logger.info("total length:" + totalLen);
for (int i = 0; i < totalLen; i++) { for (int i = 0; i < totalLen; i++) {

@ -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();
}
});
}
}
Loading…
Cancel
Save