xiatian 2 лет назад
Родитель
Сommit
edccefaa9c

+ 54 - 0
src/main/java/cn/com/qmth/importpaper/ClearProp.java

@@ -0,0 +1,54 @@
+package cn.com.qmth.importpaper;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.google.common.collect.Maps;
+
+import okhttp3.Response;
+
+public class ClearProp {
+
+	private static Logger logger = LogManager.getLogger(ClearProp.class);
+	private static String batch = "230517";
+	private final static String host="https://192.168.10.240/";
+
+	private final static String rootOrgId = "17286";
+
+	private final static String key = "U_C_17286_605350";
+
+	private final static String token = "03fd149ea5314afdb75c352ab055d1d8";
+
+	public static void main(String[] args) {
+		logger.debug("**********************开始");
+		clear();
+		logger.debug("**********************结束");
+	}
+
+
+	private static void clear() {
+		Map<String, String> params = Maps.newHashMap();
+		params.put("rootOrgId", rootOrgId);
+		params.put("batch", batch);
+		Map<String, String> headers = Maps.newHashMap();
+		headers.put("key", key);
+		headers.put("token", token);
+		Response resp = null;
+		try {
+//			OKHttpUtil.initOkHttpClient();
+			resp = OKHttpUtil.call(HttpMethod.POST, host+"/api/ecs_ques/importYunkaiProp/clear", headers, params);
+			if (resp.code() != 200) {
+				throw new RuntimeException("body:" + resp.body().string());
+			}
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		} finally {
+			IOUtils.closeQuietly(resp);
+		}
+	}
+
+}

+ 73 - 0
src/main/java/cn/com/qmth/importpaper/ConsumerDto.java

@@ -0,0 +1,73 @@
+package cn.com.qmth.importpaper;
+
+public class ConsumerDto {
+	private Course course;
+	private String sourceDir;
+	private String host;
+
+	private String rootOrgId;
+
+	private String key;
+
+	private String token;
+
+	public Course getCourse() {
+		return course;
+	}
+
+	public void setCourse(Course course) {
+		this.course = course;
+	}
+
+	public String getSourceDir() {
+		return sourceDir;
+	}
+
+	public void setSourceDir(String sourceDir) {
+		this.sourceDir = sourceDir;
+	}
+
+	public String getHost() {
+		return host;
+	}
+
+	public void setHost(String host) {
+		this.host = host;
+	}
+
+	public String getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(String rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public String getKey() {
+		return key;
+	}
+
+	public void setKey(String key) {
+		this.key = key;
+	}
+
+	public String getToken() {
+		return token;
+	}
+
+	public void setToken(String token) {
+		this.token = token;
+	}
+
+	public ConsumerDto(Course course, String sourceDir, String host, String rootOrgId, String key, String token) {
+		super();
+		this.course = course;
+		this.sourceDir = sourceDir;
+		this.host = host;
+		this.rootOrgId = rootOrgId;
+		this.key = key;
+		this.token = token;
+	}
+	
+	
+}

+ 29 - 141
src/main/java/cn/com/qmth/importpaper/ImportPaperByCourse.java

@@ -1,163 +1,51 @@
 package cn.com.qmth.importpaper;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.xssf.usermodel.XSSFRow;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import okhttp3.Response;
 
 public class ImportPaperByCourse {
 
 	private static Logger logger = LogManager.getLogger(ImportPaperByCourse.class);
-	
-	private static String paperSuff="(211)";
-
-	private static String sourceDir = "e:\\quesDir";
-//	private static String sourceDir = "e:\\courseDir";
-//	private static String sourceDir = "D:\\2020ddimport\\ques\\excelDir";
-
-	private static String sourceQuesDir = sourceDir + "\\quesDir\\";
-
-//	private final static String url = "https://ecs-test.ea100.com.cn/api/ecs_ques/importDdCollegePaper";
-	private final static String url = "https://www.exam-cloud.cn/api/ecs_ques/importDdCollegePaper";
-//	private final static String url = "https://org0.qmth.com.cn/api/ecs_ques/importDdCollegePaper";
+	private final static String sourceDir = "d:/yunkai/";
 
-	private final static String rootOrgId = "1627";
+//	private static String host = "https://192.168.10.240/";
+//	private static String rootOrgId = "17286";
+//	private static String key = "U_C_17286_605350";
+//	private static String token = "03fd149ea5314afdb75c352ab055d1d8";
 	
-//	private final static String rootOrgId = "0";
+	private static String host = "http://localhost:8008";
+	private static String rootOrgId = "149";
+	private static String key = "U_C_149_170";
+	private static String token = "4b8b8bbab1b04084a7c19ca1fcf98243";
 	
-	private final static String key = "U_C_1627_545839";
-
-	private final static String token = "4aa4703852a544f4b1eb23c854419057";
+	private static AtomicInteger count=new AtomicInteger(0);
 
 	public static void main(String[] args) {
-		logger.debug("**********************导入开始");
-		Date start = new Date();
-		int errnum = 0;
-		StringBuilder sb = new StringBuilder();
-		
-		int num = 0;
-		String fname = null;
-		File dir = new File(sourceDir);
-		for (File f : dir.listFiles()) {
-			fname = f.getName();
-			if (!f.isDirectory() && fname.endsWith(".xlsx")) {
-				num++;
-				Date n = new Date();
-				try {
-					importCoursePaper(f);
-					Date et = new Date();
-					logger.debug("导入成功(" + num + "):" + fname + " 耗时:" + (et.getTime() - n.getTime()));
-				} catch (Exception e) {
-					errnum++;
-					sb.append(fname).append(",");
-					Date et = new Date();
-					logger.error(
-							"导入失败(" + num + "):" + fname + " 耗时:" + (et.getTime() - n.getTime()) + " " + e.getMessage(),
-							e);
-				}
-			}
-		}
-
-//        try {
-//            importCoursePaper(new File("D:\\2020ddimport\\ques\\excelDir\\F29020021.xlsx"));
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-
-		Date end = new Date();
-		logger.debug("**********************导入结束  耗时:" + (end.getTime() - start.getTime()));
-
-		logger.debug("**********************导入出错数:" + errnum);
-		logger.debug("**********************导入出错课程:" + sb.toString());
-	}
-
-	private static void importCoursePaper(File file) throws Exception {
-		File zfile = new File(sourceDir + "\\" + (file.getName().substring(0, file.getName().lastIndexOf(".")))+ ".zip");
-		try {
-			if (zfile.exists()) {
-				zfile.delete();
-			}
-			createZip(file, zfile);
-			submitZip(zfile);
-		} catch(NoPaperException e) {
-			logger.debug("忽略:" + e.getDesc() );
-		} finally {
-			if (zfile.exists()) {
-				zfile.delete();
-			}
-		}
-	}
-
-	private static void createZip(File file, File zfile) throws InvalidFormatException, IOException{
-
-		XSSFWorkbook wb = null;
+		logger.debug("导入开始");
+		Date start=new Date();
 		try {
-			wb = new XSSFWorkbook(file);
-			int num = wb.getNumberOfSheets();
-			if (num == 1) {
-				throw new NoPaperException("1000","没有试卷信息:" + file.getName());
-			}
-			Set<String> ques = new HashSet<String>();
-			for (int i = 1; i < num; i++) {
-				XSSFSheet sheet = wb.getSheetAt(i);
-				int rows = sheet.getLastRowNum();
-				for (int j = 1; j <= rows; j++) {
-					XSSFRow row = sheet.getRow(j);
-					ques.add(row.getCell(0).getStringCellValue());
-				}
-			}
-			List<File> files = new ArrayList<File>();
-			for (String s : ques) {
-				File f = new File(sourceQuesDir + s + ".txt");
-				files.add(f);
-			}
-			files.add(file);
-			FileUtil.doZip(files, zfile);
-		} finally {
-			if (wb != null) {
-				wb.close();
-			}
+			Map<String,Object> param=new HashMap<>();
+			param.put("sourceDir", sourceDir);
+			param.put("host", host);
+			param.put("rootOrgId", rootOrgId);
+			param.put("key", key);
+			param.put("token", token);
+			MyProducer pro=new MyProducer();
+			pro.startDispose(MyConsumer.class, 8, param);
+		} catch (Exception e) {
+			logger.error(e.getCause(), e);
 		}
+		Date end=new Date();
+		logger.debug("导入结束,耗时:"+((end.getTime()-start.getTime())/1000));
 	}
 
-	private static void submitZip(File zfile) throws Exception {
-		Map<String, String> params = Maps.newHashMap();
-		params.put("rootOrgId", rootOrgId);
-		params.put("courseCode", zfile.getName().split("\\.")[0]);
-		if(paperSuff!=null) {
-			params.put("suff", paperSuff);
-		}
-		Map<String, String> headers = Maps.newHashMap();
-		headers.put("key", key);
-		headers.put("token", token);
-		List<FormFilePart> fileList = Lists.newArrayList();
-		fileList.add(new FormFilePart("dataFile", zfile.getName(), zfile));
-		Response resp = null;
-		try {
-			OKHttpUtil.initOkHttpClient();
-			resp = OKHttpUtil.call(HttpMethod.POST, url, headers, params, fileList);
-			if (resp.code() != 200) {
-				throw new Exception(zfile.getName() + ":body:" + resp.body().string());
-			}
-		} finally {
-			IOUtils.closeQuietly(resp);
-		}
+	public static void  addDisposeCount() {
+		count.addAndGet(1);
+		logger.debug("处理了"+count);
 	}
 }

+ 10 - 36
src/main/java/cn/com/qmth/importpaper/ImportPropByCourse.java

@@ -22,21 +22,16 @@ import okhttp3.Response;
 public class ImportPropByCourse {
 
 	private static Logger logger = LogManager.getLogger(ImportPropByCourse.class);
-	private static String batch = "230517";
-	private static String sourceDir = "d:/yunkai/";
-
-	private final static String url = "http://localhost:8008/api/ecs_ques/importYunkaiProp";
-	private final static String clearurl = "http://localhost:8008/api/ecs_ques/importYunkaiProp/clear";
-
-	private final static String rootOrgId = "149";
+	private final static String sourceDir = "d:/yunkai/";
 
-	private final static String key = "U_C_149_170";
-
-	private final static String token = "a599299bea744990aca83c7e0140086c";
+	private static String batch = "230517";
+	private static String host = "https://192.168.10.240/";
+	private static String rootOrgId = "17286";
+	private static String key = "U_C_17286_605350";
+	private static String token = "03fd149ea5314afdb75c352ab055d1d8";
 
 	public static void main(String[] args) {
 		logger.debug("**********************导入开始");
-		clear();
 		Date start = new Date();
 		int errnum = 0;
 		StringBuilder sb = new StringBuilder();
@@ -57,8 +52,8 @@ public class ImportPropByCourse {
 				errnum++;
 				sb.append(file.getName()).append(",");
 				Date et = new Date();
-				logger.error(
-						"导入失败(" + num + "):" + file.getName() + " 耗时:" + (et.getTime() - n.getTime()) + " " + e.getMessage(), e);
+				logger.error("导入失败(" + num + "):" + file.getName() + " 耗时:" + (et.getTime() - n.getTime()) + " "
+						+ e.getMessage(), e);
 			}
 		}
 
@@ -100,27 +95,6 @@ public class ImportPropByCourse {
 		return list;
 	}
 
-	private static void clear() {
-		Map<String, String> params = Maps.newHashMap();
-		params.put("rootOrgId", rootOrgId);
-		params.put("batch", batch);
-		Map<String, String> headers = Maps.newHashMap();
-		headers.put("key", key);
-		headers.put("token", token);
-		Response resp = null;
-		try {
-			OKHttpUtil.initOkHttpClient();
-			resp = OKHttpUtil.call(HttpMethod.POST, clearurl, headers, params);
-			if (resp.code() != 200) {
-				throw new RuntimeException("body:" + resp.body().string());
-			}
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		} finally {
-			IOUtils.closeQuietly(resp);
-		}
-	}
-
 	private static void submit(Course c, File zfile) throws Exception {
 		Map<String, String> params = Maps.newHashMap();
 		params.put("rootOrgId", rootOrgId);
@@ -133,8 +107,8 @@ public class ImportPropByCourse {
 		fileList.add(new FormFilePart("dataFile", zfile.getName(), zfile));
 		Response resp = null;
 		try {
-			OKHttpUtil.initOkHttpClient();
-			resp = OKHttpUtil.call(HttpMethod.POST, url, headers, params, fileList);
+//			OKHttpUtil.initOkHttpClient();
+			resp = OKHttpUtil.call(HttpMethod.POST, host + "/api/ecs_ques/importYunkaiProp", headers, params, fileList);
 			if (resp.code() != 200) {
 				throw new Exception(zfile.getName() + ":body:" + resp.body().string());
 			}

+ 90 - 0
src/main/java/cn/com/qmth/importpaper/MyConsumer.java

@@ -0,0 +1,90 @@
+package cn.com.qmth.importpaper;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import cn.com.qmth.multithread.Consumer;
+import okhttp3.Response;
+
+public class MyConsumer extends Consumer<ConsumerDto> {
+	private static Logger logger = LogManager.getLogger(MyConsumer.class);
+	@Override
+	public void consume(ConsumerDto dto) {
+		importCoursePaper(dto);
+		ImportPaperByCourse.addDisposeCount();
+	}
+	private  void importCoursePaper(ConsumerDto dto){
+		File file = new File(dto.getSourceDir() + "paper/" + dto.getCourse().getId() + "/");
+		if(!file.exists()) {
+			return;
+		}
+		File zfile = new File(dto.getSourceDir()+"paper/"+dto.getCourse().getId()+ ".zip");
+		try {
+			List<File> files = new ArrayList<>();
+			getPaperFile(file, files);
+			if(files.size()==0) {
+				throw new NoPaperException("1000","没有试卷信息:" + file.getName());
+			}
+			if (zfile.exists()) {
+				zfile.delete();
+			}
+			FileUtil.doZip(file, zfile);
+			submitZip(dto,zfile);
+		} catch (NoPaperException e1) {
+			logger.debug("忽略:" + e1.getDesc() );
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		} finally {
+			if (zfile.exists()) {
+				zfile.delete();
+			}
+		}
+	}
+
+	private  void getPaperFile(File file, List<File> ret) {
+		if (file.isFile()) {
+			if (file.getName().endsWith(".json")) {
+				ret.add(file);
+			}
+			return;
+		} else {
+			for (File paperDir : file.listFiles()) {
+				getPaperFile(paperDir, ret);
+			}
+		}
+
+	}
+	private  void submitZip(ConsumerDto dto,File zfile) {
+		Map<String, String> params = Maps.newHashMap();
+		params.put("rootOrgId", dto.getRootOrgId());
+		params.put("courseCode",dto.getCourse().getCode());
+		Map<String, String> headers = Maps.newHashMap();
+		headers.put("key", dto.getKey());
+		headers.put("token", dto.getToken());
+		List<FormFilePart> fileList = Lists.newArrayList();
+		fileList.add(new FormFilePart("dataFile", zfile.getName(), zfile));
+		Response resp = null;
+		try {
+//			OKHttpUtil.initOkHttpClient();
+			resp = OKHttpUtil.call(HttpMethod.POST, dto.getHost()+"/api/ecs_ques/importYunkaiPaper", headers, params, fileList);
+			if (resp.code() != 200) {
+				throw new Exception(zfile.getName() + ":body:" + resp.body().string());
+			}else {
+				logger.debug("成功处理:" + zfile.getName() );
+			}
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		} finally {
+			IOUtils.closeQuietly(resp);
+		}
+	}
+}

+ 74 - 0
src/main/java/cn/com/qmth/importpaper/MyProducer.java

@@ -0,0 +1,74 @@
+package cn.com.qmth.importpaper;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import cn.com.qmth.multithread.Producer;
+
+
+public class MyProducer extends Producer {
+	private static Logger logger = LogManager.getLogger(MyProducer.class);
+	private static String dir = "d:/yunkai/";
+
+	@Override
+	protected void produce(Map<String, Object> param) throws Exception {
+		logger.info("***************************任务生产开始");
+		String sourceDir=param.get("sourceDir").toString();
+		String host=param.get("host").toString();
+		String rootOrgId=param.get("rootOrgId").toString();
+		String key=param.get("key").toString();
+		String token=param.get("token").toString();
+		List<Course> cs = readSubject();
+		if (CollectionUtils.isEmpty(cs)) {
+			logger.debug("无数据导入");
+			return;
+		} else {
+			logger.debug(cs.size() + "个课程");
+		}
+		for (Course c : cs) {
+			offer(new ConsumerDto(c, sourceDir, host, rootOrgId, key, token));
+		}
+		logger.info("***************************任务生产结束");
+	}
+	
+	
+	private  List<Course> readSubject() {
+		List<Course> list = new ArrayList<>();
+		XSSFWorkbook wb = null;
+		try {
+			wb = new XSSFWorkbook(dir + "subject.xlsx");
+			XSSFSheet sheet = wb.getSheetAt(0);
+			int rows = sheet.getLastRowNum();
+			for (int i = 1; i <= rows; i++) {
+				Course c = new Course();
+				XSSFRow row = sheet.getRow(i);
+				String id = row.getCell(0).getStringCellValue().trim();
+				String name = row.getCell(1).getStringCellValue().trim();
+				String code = row.getCell(2).getStringCellValue().trim();
+				c.setId(Long.valueOf(id));
+				c.setCode(code);
+				c.setName(name);
+				list.add(c);
+			}
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		} finally {
+			if (wb != null) {
+				try {
+					wb.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+		return list;
+	}
+}

+ 19 - 32
src/main/java/cn/com/qmth/importpaper/OKHttpUtil.java

@@ -6,9 +6,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLSession;
-
 import org.apache.commons.collections4.CollectionUtils;
 
 import okhttp3.FormBody;
@@ -23,13 +20,12 @@ import okhttp3.Response;
 /**
  * OKHttp
  *
- * @author 
+ * @author
  * @date 2018年9月6日
- * @Copyright (c) 2018-2020  [QQ:522080330] All Rights Reserved.
+ * @Copyright (c) 2018-2020 [QQ:522080330] All Rights Reserved.
  */
 public class OKHttpUtil {
 
-
 	public static final class MediaTypes {
 
 		public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
@@ -38,9 +34,9 @@ public class OKHttpUtil {
 	/**
 	 * 请求体构建器
 	 *
-	 * @author 
+	 * @author
 	 * @date 2019年4月10日
-	 * @Copyright (c) 2018-2020  [QQ:522080330] All Rights Reserved.
+	 * @Copyright (c) 2018-2020 [QQ:522080330] All Rights Reserved.
 	 */
 	public static interface RequestBodyBuilder {
 		RequestBody build();
@@ -49,9 +45,9 @@ public class OKHttpUtil {
 	/**
 	 * json请求体构建器
 	 *
-	 * @author 
+	 * @author
 	 * @date 2019年4月10日
-	 * @Copyright (c) 2018-2020  [QQ:522080330] All Rights Reserved.
+	 * @Copyright (c) 2018-2020 [QQ:522080330] All Rights Reserved.
 	 */
 	public static final class JsonBodyBuilder implements RequestBodyBuilder {
 
@@ -75,15 +71,11 @@ public class OKHttpUtil {
 
 	private static OkHttpClient okHttpClient;
 
-	public static void initOkHttpClient() {
-		okHttpClient = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS)
-				.readTimeout(800, TimeUnit.SECONDS).writeTimeout(800, TimeUnit.SECONDS).hostnameVerifier(new HostnameVerifier() {
-					
-					@Override
-					public boolean verify(String hostname, SSLSession session) {
-						return true;
-					}
-				}).build();
+	static {
+		okHttpClient = new OkHttpClient.Builder()
+				.sslSocketFactory(SSLSocketClient.getSSLSocketFactory(), SSLSocketClient.getX509TrustManager())
+				.hostnameVerifier(SSLSocketClient.getHostnameVerifier()).readTimeout(800, TimeUnit.SECONDS)
+				.writeTimeout(800, TimeUnit.SECONDS).build();
 	}
 
 	public static OkHttpClient getOkHttpClient() {
@@ -93,22 +85,21 @@ public class OKHttpUtil {
 	/**
 	 * 发送请求 (带json请求体)
 	 *
-	 * @author 
+	 * @author
 	 * @param httpMethod
 	 * @param url
 	 * @param headers
 	 * @param jsonBody
 	 * @return
 	 */
-	public static Response call(HttpMethod httpMethod, String url, Map<String, String> headers,
-			String jsonBody) {
+	public static Response call(HttpMethod httpMethod, String url, Map<String, String> headers, String jsonBody) {
 		return call(httpMethod, url, headers, new JsonBodyBuilder(jsonBody));
 	}
 
 	/**
 	 * 发送请求 (带请求体)
 	 *
-	 * @author 
+	 * @author
 	 * @param httpMethod
 	 * @param url
 	 * @param headers
@@ -118,7 +109,6 @@ public class OKHttpUtil {
 	public static Response call(HttpMethod httpMethod, String url, Map<String, String> headers,
 			RequestBodyBuilder requestBodyBuilder) {
 
-
 		Builder builder = null;
 		if (httpMethod.equals(HttpMethod.POST)) {
 			builder = new Request.Builder().url(url).post(requestBodyBuilder.build());
@@ -148,7 +138,7 @@ public class OKHttpUtil {
 	/**
 	 * 发送请求
 	 *
-	 * @author 
+	 * @author
 	 * @param httpMethod
 	 * @param url
 	 * @return
@@ -160,7 +150,7 @@ public class OKHttpUtil {
 	/**
 	 * 发送请求
 	 *
-	 * @author 
+	 * @author
 	 * @param httpMethod
 	 * @param url
 	 * @param headers
@@ -168,7 +158,6 @@ public class OKHttpUtil {
 	 */
 	public static Response call(HttpMethod httpMethod, String url, Map<String, String> headers) {
 
-
 		Builder builder = null;
 		if (httpMethod.equals(HttpMethod.GET)) {
 			builder = new Request.Builder().url(url);
@@ -200,7 +189,7 @@ public class OKHttpUtil {
 	/**
 	 * 发送请求 (表单)
 	 *
-	 * @author 
+	 * @author
 	 * @param httpMethod
 	 * @param url
 	 * @param headers
@@ -247,7 +236,7 @@ public class OKHttpUtil {
 	/**
 	 * 发送请求 (包含文件表单)
 	 *
-	 * @author 
+	 * @author
 	 * @param httpMethod
 	 * @param url
 	 * @param headers
@@ -258,7 +247,6 @@ public class OKHttpUtil {
 	public static Response call(HttpMethod httpMethod, String url, Map<String, String> headers,
 			Map<String, String> params, List<FormFilePart> formFilePartList) {
 
-
 		okhttp3.MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder()
 				.setType(MultipartBody.ALTERNATIVE);
 
@@ -272,8 +260,7 @@ public class OKHttpUtil {
 			MediaType type = MediaType.parse("application/octet-stream");
 			for (FormFilePart part : formFilePartList) {
 				RequestBody fileBody = RequestBody.create(type, part.getFile());
-				multipartBodyBuilder.addFormDataPart(part.getParamName(), part.getFilename(),
-						fileBody);
+				multipartBodyBuilder.addFormDataPart(part.getParamName(), part.getFilename(), fileBody);
 			}
 		}
 

+ 64 - 0
src/main/java/cn/com/qmth/importpaper/SSLSocketClient.java

@@ -0,0 +1,64 @@
+package cn.com.qmth.importpaper;
+
+import javax.net.ssl.*;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+
+
+public class SSLSocketClient {
+
+    //获取这个SSLSocketFactory
+    public static SSLSocketFactory getSSLSocketFactory() {
+        try {
+            SSLContext sslContext = SSLContext.getInstance("SSL");
+            sslContext.init(null, getTrustManager(), new SecureRandom());
+            return sslContext.getSocketFactory();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    //获取TrustManager
+    private static TrustManager[] getTrustManager() {
+        return new TrustManager[]{
+                new X509TrustManager() {
+                    @Override
+                    public void checkClientTrusted(X509Certificate[] chain, String authType) {
+                    }
+
+                    @Override
+                    public void checkServerTrusted(X509Certificate[] chain, String authType) {
+                    }
+
+                    @Override
+                    public X509Certificate[] getAcceptedIssuers() {
+                        return new X509Certificate[]{};
+                    }
+                }
+        };
+    }
+
+    //获取HostnameVerifier
+    public static HostnameVerifier getHostnameVerifier() {
+        return (s, sslSession) -> true;
+    }
+
+    public static X509TrustManager getX509TrustManager() {
+        X509TrustManager trustManager = null;
+        try {
+            TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+            trustManagerFactory.init((KeyStore) null);
+            TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
+            if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
+                throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers));
+            }
+            trustManager = (X509TrustManager) trustManagers[0];
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return trustManager;
+    }
+}

+ 0 - 2
src/main/java/cn/com/qmth/multithread/Basket.java

@@ -7,8 +7,6 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.log4j.Logger;
 
-import cn.com.qmth.importpaper.FileUtil;
-
 
 
 public  class  Basket {

+ 1 - 5
src/main/java/cn/com/qmth/multithread/Consumer.java

@@ -1,7 +1,5 @@
 package cn.com.qmth.multithread;
 
-import java.io.File;
-
 import org.apache.log4j.Logger;
 import org.apache.logging.log4j.ThreadContext;
 
@@ -31,7 +29,7 @@ public abstract class Consumer<T>  extends Thread{
 				}
 				@SuppressWarnings("unchecked")
 				T t=(T)o;
-				logger.info("*******************Consumer:"+Thread.currentThread().getId()+" consume");
+//				logger.info("*******************Consumer:"+Thread.currentThread().getId()+" consume");
 				//消费数据实现
 				consume(t);
 			}
@@ -57,6 +55,4 @@ public abstract class Consumer<T>  extends Thread{
 	public void setTraceId(String traceId) {
 		this.traceId = traceId;
 	}
-	public abstract void disposeOnEnd(File re,File unre);
-	
 }

+ 1 - 1
src/main/java/cn/com/qmth/multithread/Producer.java

@@ -21,7 +21,7 @@ public abstract class Producer {
 	 */
 	private Class<? extends Consumer<?>> consumer;
 	
-	public List<Consumer> consumers=new ArrayList<Consumer>();
+	public List<Consumer<?>> consumers=new ArrayList<>();
 	/**
 	 * 	处理开始方法
 	 * @param consumer 消费线程class