yonge 5 年之前
父节点
当前提交
a145f85990
共有 1 个文件被更改,包括 7 次插入107 次删除
  1. 7 107
      mec-util/src/main/java/com/ym/mec/util/excel/POIUtil.java

+ 7 - 107
mec-util/src/main/java/com/ym/mec/util/excel/POIUtil.java

@@ -6,8 +6,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -17,30 +15,21 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.beanutils.NestedNullException;
 import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.ssl.SSLContextBuilder;
-import org.apache.http.ssl.TrustStrategy;
-import org.apache.http.util.EntityUtils;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
 import org.apache.poi.hssf.usermodel.HSSFFont;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
@@ -539,95 +528,6 @@ public class POIUtil {
 		return result;
 	}
 
-	public static void main(String[] args) {
-		File file = new File("e:/reward.xlsx");
-		String sheetName = "reward";
-		Map<String, List<Map<String, Object>>> map = null;
-		try {
-			map = POIUtil.importExcel(file, 1);
-		} catch (IOException e) {
-			e.printStackTrace();
-			return;
-		}
-		if (map != null) {
-			// Map<String, Object> loginParam = new HashMap<String, Object>();
-
-			SSLContextBuilder builder = new SSLContextBuilder();
-			try {
-				builder.loadTrustMaterial(null, new TrustStrategy() {
-
-					@Override
-					public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
-						return true;
-					}
-				});
-			} catch (Exception e) {
-				e.printStackTrace();
-				return;
-			}
-
-			HttpPost httpPost = null;
-			CloseableHttpClient httpClient = null;
-			try {
-				SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
-				httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).setDefaultCookieStore(new BasicCookieStore()).build();
-				// 登陆
-				httpPost = new HttpPost("https://ehjinrong.com/manage/admin/login.do?userName=sadmin&password=Hello@ehjr&captcha=411049");
-
-				HttpResponse httpResponse = httpClient.execute(httpPost);
-				HttpEntity httpEntity = httpResponse.getEntity();
-				String str = EntityUtils.toString(httpEntity);
-				System.out.println("--------" + str);
-				EntityUtils.consume(httpEntity);
-
-				// 发放奖励
-				for (Map<String, Object> row : map.get(sheetName)) {
-					try {
-						Long arg0 = Long.parseLong(row.get("user_id_").toString());
-						double arg1 = Double.parseDouble(row.get("reward").toString());
-						//String arg2 = row.get("tender_id_").toString();
-
-						Map<String, Object> parameterMap = new HashMap<String, Object>();
-						parameterMap.put("userId", arg0);
-						parameterMap.put("amount", arg1);
-						parameterMap.put("memo", "结清");
-
-						List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
-						if (parameterMap != null) {
-							for (Entry<String, Object> entry : parameterMap.entrySet()) {
-								String name = entry.getKey();
-								String value = ConvertUtils.convert(entry.getValue());
-								if (StringUtils.isNotEmpty(name)) {
-									nameValuePairs.add(new BasicNameValuePair(name, value));
-								}
-							}
-						}
-						httpPost = new HttpPost("https://ehjinrong.com/manage/sysAccount/fundAllocate.do");
-						httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
-						httpResponse = httpClient.execute(httpPost);
-						httpEntity = httpResponse.getEntity();
-						EntityUtils.toString(httpEntity);
-						EntityUtils.consume(httpEntity);
-
-						System.out.println("  userId:" + arg0 + "  reward:" + arg1);
-					} catch (Exception e) {
-						e.printStackTrace();
-					}
-				}
-			} catch (Exception e) {
-				e.printStackTrace();
-			} finally {
-				httpPost.releaseConnection();
-				try {
-					httpClient.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-
-		}
-	}
-
 	/**
 	 * 创建excel文档
 	 *