|
|
@ -1,9 +1,12 @@
|
|
|
|
package au.com.royalpay.payment.manage.apps.core.impls;
|
|
|
|
package au.com.royalpay.payment.manage.apps.core.impls;
|
|
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
@ -11,9 +14,10 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Created by wangning on 05/01/2018.
|
|
|
|
* Created by wangning on 05/01/2018.
|
|
|
@ -26,6 +30,9 @@ public class CustomerImpressionImplTest {
|
|
|
|
private CustomerImpressionService customerImpression;
|
|
|
|
private CustomerImpressionService customerImpression;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClientMapper clientMapper;
|
|
|
|
private ClientMapper clientMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ThreadPoolExecutor generatePool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void generate() throws Exception {
|
|
|
|
public void generate() throws Exception {
|
|
|
|
customerImpression.generate(9);
|
|
|
|
customerImpression.generate(9);
|
|
|
@ -34,9 +41,28 @@ public class CustomerImpressionImplTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void generateAll(){
|
|
|
|
public void generateAll(){
|
|
|
|
List<JSONObject> clients = clientMapper.listValidClient();
|
|
|
|
List<JSONObject> clients = clientMapper.listValidClient();
|
|
|
|
clients.forEach(p -> {
|
|
|
|
List<List<JSONObject>> splitList = new ArrayList<>();
|
|
|
|
customerImpression.generate(p.getIntValue("client_id"));
|
|
|
|
for (int i = 0; i < clients.size(); i+=200) {
|
|
|
|
});
|
|
|
|
if(i+200>clients.size()){
|
|
|
|
|
|
|
|
splitList.add(clients.subList(i,clients.size()));
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
splitList.add(clients.subList(i,i+200));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (List<JSONObject> splitClients : splitList) {
|
|
|
|
|
|
|
|
Runnable task = () -> splitClients.forEach((p)->{
|
|
|
|
|
|
|
|
System.out.println("当前执行到"+p.getIntValue("client_id"));
|
|
|
|
|
|
|
|
customerImpression.generate(p.getIntValue("client_id"));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
generatePool.execute(task);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
generatePool.shutdown();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
generatePool.awaitTermination(5, TimeUnit.HOURS);
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|