master
wangning 7 years ago
parent 2228a0cc45
commit 8c78a671cf

@ -1,24 +1,39 @@
package au.com.royalpay.payment.manage.apps.core.impls;
import javax.annotation.Resource;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import com.alibaba.fastjson.JSONObject;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.Cell;
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 com.alibaba.fastjson.JSONObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import javax.annotation.Resource;
/**
* Created by wangning on 05/01/2018.
*/
@SpringBootTest
@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
@ActiveProfiles({ "proxy", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class)
public class CustomerImpressionImplTest {
@Resource
@ -26,14 +41,89 @@ public class CustomerImpressionImplTest {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private ClientMapper clientMapper;
// @Test
// public void redisQueue() {
// BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
// JSONObject order = orderMapper.find("00009201711300930013961422");
// for (int i = 0; i < 10000; i++) {
// ops.rightPush(order.toJSONString());
//
// }
// }
@Test
public void redisQueue() {
BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
JSONObject order = orderMapper.find("00009201711300930013961422");
for (int i = 0; i < 10000; i++) {
ops.rightPush(order.toJSONString());
public void excel() {
try {
List<JSONObject> asd = orderMapper.tmop();
Map<String,JSONObject> map = new HashMap<>();
asd.forEach(p->{
map.put(p.getString("sub_merchant_id"),p);
});
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/qwe.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(1);
if(cell==null){
continue;
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
JSONObject tmpOBJ = map.get(cell.getStringCellValue());
if(tmpOBJ==null){
continue;
}
row.createCell(4).setCellValue(tmpOBJ.getString("cc"));
row.createCell(5).setCellValue(tmpOBJ.getString("maxct"));
}
//
//
// if (!"Australia".equals(row.getCell(1).getStringCellValue())) {
// continue;
// }
// cell = row.getCell(0);
// cell.setCellType(HSSFCell.CELL_TYPE_STRING);
//
// JSONObject client = clientMapper.clientInfoBySubMerchantId(cell.getStringCellValue());
// if(client==null){
// continue;
// }
// row.createCell(4).setCellValue(client.getString("bd_user_name"));
// row.createCell(5).setCellValue(client.getString("client_moniker"));
// row.createCell(6).setCellValue(client.getString("short_name"));
// }
//
// XSSFSheet sheet3 = workbook.getSheetAt(3);
// Iterator<Row> rowIterator3 = sheet3.rowIterator();
// while (rowIterator3.hasNext()) {
// row = rowIterator3.next();
// if (!"Australia".equals(row.getCell(1).getStringCellValue())) {
// continue;
// }
// cell = row.getCell(0);
// cell.setCellType(HSSFCell.CELL_TYPE_STRING);
// JSONObject client = clientMapper.clientInfoBySubMerchantId(cell.getStringCellValue());
// if(client==null){
// continue;
// }
// row.createCell(4).setCellValue(client.getString("bd_user_name"));
// row.createCell(5).setCellValue(client.getString("client_moniker"));
// row.createCell(6).setCellValue(client.getString("short_name"));
// }
OutputStream out = new FileOutputStream("/Users/wangning/Desktop/订单fin.xlsx");
workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save