|
|
|
@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
@ -23,8 +24,12 @@ import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
import org.springframework.data.redis.core.BoundListOperations;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
@ -54,9 +59,9 @@ import cn.yixblog.platform.http.HttpRequestResult;
|
|
|
|
|
/**
|
|
|
|
|
* Created by wangning on 05/01/2018.
|
|
|
|
|
*/
|
|
|
|
|
// @SpringBootTest
|
|
|
|
|
// @ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
|
|
|
|
|
// @RunWith(SpringRunner.class)
|
|
|
|
|
@SpringBootTest
|
|
|
|
|
@ActiveProfiles({ "proxy", "alipay", "wechat", "jd", "bestpay" })
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
|
|
|
public class CustomerImpressionImplTest {
|
|
|
|
|
@Resource
|
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
@ -133,8 +138,8 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
pastTotal = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Date tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(),"YYYYMM"),(-i+1));
|
|
|
|
|
String pastKey = String.valueOf(tmp.getYear()+1900)+ String.valueOf(tmp.getMonth());
|
|
|
|
|
Date tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYYMM"), (-i + 1));
|
|
|
|
|
String pastKey = String.valueOf(tmp.getYear() + 1900) + String.valueOf(tmp.getMonth());
|
|
|
|
|
|
|
|
|
|
if (p.getValue().containsKey(String.valueOf(pastKey))) {
|
|
|
|
|
BigDecimal pastAvgtmp = BigDecimal.valueOf(Double.parseDouble(p.getValue().get(String.valueOf(pastKey))));
|
|
|
|
@ -145,9 +150,9 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
|
|
|
|
|
if (i == 3) {
|
|
|
|
|
try {
|
|
|
|
|
BigDecimal pastAvg = pastTotal.divide(BigDecimal.valueOf(3L),5,BigDecimal.ROUND_HALF_DOWN);
|
|
|
|
|
BigDecimal pastAvg = pastTotal.divide(BigDecimal.valueOf(3L), 5, BigDecimal.ROUND_HALF_DOWN);
|
|
|
|
|
if (pastAvg.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
if (insAvg.divide(pastAvg,5,BigDecimal.ROUND_HALF_DOWN).intValue()>3) {
|
|
|
|
|
if (insAvg.divide(pastAvg, 5, BigDecimal.ROUND_HALF_DOWN).intValue() > 3) {
|
|
|
|
|
clients.add(p.getKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -163,8 +168,7 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clients.forEach(p->{
|
|
|
|
|
clients.forEach(p -> {
|
|
|
|
|
System.out.println(p);
|
|
|
|
|
});
|
|
|
|
|
System.out.println(clients.size());
|
|
|
|
@ -198,8 +202,6 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
|
String orders = cell.getStringCellValue().trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cell = row.getCell(1);
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
|
String dateStr = cell.getStringCellValue();
|
|
|
|
@ -218,15 +220,14 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
}
|
|
|
|
|
Set<String> clients = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, LinkedHashMap<String, String>> p : result.entrySet()) {
|
|
|
|
|
int count = 1;
|
|
|
|
|
for (Map.Entry<String, String> o : p.getValue().entrySet()) {
|
|
|
|
|
count+=1;
|
|
|
|
|
count += 1;
|
|
|
|
|
for (int i = 1; i < 4; i++) {
|
|
|
|
|
if(p.getValue().size()<4 && count==p.getValue().size()){
|
|
|
|
|
if (p.getValue().size() < 4 && count == p.getValue().size()) {
|
|
|
|
|
try {
|
|
|
|
|
if(DateUtils.addMonths(DateUtils.parseDate(o.getKey(),"YYYYMM"),3).compareTo(new Date())<0){
|
|
|
|
|
if (DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYYMM"), 3).compareTo(new Date()) < 0) {
|
|
|
|
|
clients.add(p.getKey());
|
|
|
|
|
}
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
@ -235,12 +236,12 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
|
|
|
|
|
Date tmp = null;
|
|
|
|
|
try {
|
|
|
|
|
tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(),"YYYYMM"),i);
|
|
|
|
|
String pastKey = String.valueOf(tmp.getYear()+1900)+ String.valueOf(tmp.getMonth());
|
|
|
|
|
tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYYMM"), i);
|
|
|
|
|
String pastKey = String.valueOf(tmp.getYear() + 1900) + String.valueOf(tmp.getMonth());
|
|
|
|
|
if (p.getValue().containsKey(String.valueOf(pastKey))) {
|
|
|
|
|
i = 10;
|
|
|
|
|
}else {
|
|
|
|
|
if(i==3 && (Integer.valueOf(o.getValue())>99)){
|
|
|
|
|
} else {
|
|
|
|
|
if (i == 3 && (Integer.valueOf(o.getValue()) > 99)) {
|
|
|
|
|
clients.add(p.getKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -255,7 +256,6 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(clients.size());
|
|
|
|
|
System.out.println(clients.size());
|
|
|
|
|
System.out.println(clients.size());
|
|
|
|
@ -264,14 +264,127 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
System.out.println(clients.size());
|
|
|
|
|
System.out.println(clients.size());
|
|
|
|
|
|
|
|
|
|
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
|
|
|
|
|
// workbook.write(out);
|
|
|
|
|
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
|
|
|
|
|
// workbook.write(out);
|
|
|
|
|
workbook.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void excel3() {
|
|
|
|
|
|
|
|
|
|
List<JSONObject> clients = clientMapper.listValidClient();
|
|
|
|
|
Map<String,JSONObject> clientMap = new HashMap<>();
|
|
|
|
|
clients.parallelStream().forEach(p->{
|
|
|
|
|
clientMap.put(p.getString("client_id"),p);
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/e4.xlsx")));
|
|
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
Iterator<Row> rowIterator = sheet.rowIterator();
|
|
|
|
|
Row row = null;
|
|
|
|
|
Cell cell = null;
|
|
|
|
|
Map<String, LinkedHashMap<String, String>> result = new HashMap<>();
|
|
|
|
|
while (rowIterator.hasNext()) {
|
|
|
|
|
row = rowIterator.next();
|
|
|
|
|
cell = row.getCell(0);
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
|
String orderCounts = cell.getStringCellValue().trim();
|
|
|
|
|
|
|
|
|
|
cell = row.getCell(1);
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
|
String clientId = cell.getStringCellValue().trim();
|
|
|
|
|
|
|
|
|
|
cell = row.getCell(2);
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
|
String dateStr = cell.getStringCellValue().trim();
|
|
|
|
|
|
|
|
|
|
if (result.containsKey(clientId)) {
|
|
|
|
|
result.get(clientId).put(dateStr, orderCounts);
|
|
|
|
|
} else {
|
|
|
|
|
LinkedHashMap<String, String> ele = new LinkedHashMap<>();
|
|
|
|
|
ele.put(dateStr, orderCounts);
|
|
|
|
|
result.put(clientId, ele);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Set<String> resultClients = new HashSet<>();
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
for (Map.Entry<String, LinkedHashMap<String, String>> p : result.entrySet()) {
|
|
|
|
|
JSONObject tmpClient = clientMap.get(p.getKey());
|
|
|
|
|
if(tmpClient==null){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(DateUtils.addMonths(tmpClient.getDate("create_time"), 7).compareTo(now)>-1){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(p.getKey().equals("1239")){
|
|
|
|
|
for (Map.Entry<String, String> stringStringEntry : p.getValue().entrySet()) {
|
|
|
|
|
System.out.println(stringStringEntry.getKey()+":"+stringStringEntry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, String> o : p.getValue().entrySet()) {
|
|
|
|
|
LinkedHashMap<String,String> resultEle = p.getValue();
|
|
|
|
|
int compareCount = 0;
|
|
|
|
|
for (int i = 1; i < 7; i++) {
|
|
|
|
|
compareCount+=1;
|
|
|
|
|
if(DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYY-MM"), 7).compareTo(now)>-1){
|
|
|
|
|
i=10;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Date compareDate = DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYY-MM"), i);
|
|
|
|
|
String compareKey = DateFormatUtils.format(compareDate,"YYYY-MM");
|
|
|
|
|
if(resultEle.containsValue(compareKey)){
|
|
|
|
|
i=10;
|
|
|
|
|
}
|
|
|
|
|
if(compareCount==6){
|
|
|
|
|
if(p.getKey().equals("1239")){
|
|
|
|
|
System.out.println(compareKey);
|
|
|
|
|
System.out.println(resultEle.containsValue(compareKey));
|
|
|
|
|
}
|
|
|
|
|
resultClients.add(p.getKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(resultClients.size());
|
|
|
|
|
|
|
|
|
|
if(resultClients.contains("1")){
|
|
|
|
|
System.out.println("1 Exist");
|
|
|
|
|
}
|
|
|
|
|
if(resultClients.contains("7")){
|
|
|
|
|
System.out.println("7 Exist");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(resultClients.contains("15")){
|
|
|
|
|
System.out.println("15 Exist");
|
|
|
|
|
}
|
|
|
|
|
if(resultClients.contains("1239")){
|
|
|
|
|
System.out.println("1239 Exist======================");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(resultClients.contains("2274")){
|
|
|
|
|
System.out.println("2274 Exist======================");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(resultClients.contains("2392")){
|
|
|
|
|
System.out.println("2392 Exist======================");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
|
|
|
|
|
// workbook.write(out);
|
|
|
|
|
workbook.close();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void sendSimpleMessage() throws Exception {
|
|
|
|
|
String url = "https://api.mailgun.net/v3/dev.showcodes.com/messages?from=postmaster@mail.royalpay.com.au&to=164851225@qq.com,1029811920@qq.com&subject=啊是记录&text=暗杀苏&v:my-custom-data={\"key\":\"value\"}";
|
|
|
|
@ -531,4 +644,5 @@ public class CustomerImpressionImplTest {
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|