Commit 09729c59c2a3daf57a96f36167a65cc5d9ec0d33

Authored by 王彬
1 parent 58e01837
Exists in master

update some func

@@ -22,12 +22,11 @@ dependencies { @@ -22,12 +22,11 @@ dependencies {
22 compile( 22 compile(
23 "org.apache.poi:poi:3.16", 23 "org.apache.poi:poi:3.16",
24 "org.apache.poi:poi-excelant:3.16", 24 "org.apache.poi:poi-excelant:3.16",
25 - "log4j:log4j:1.2.17",  
26 - "commons-logging:commons-logging:1.2",  
27 "ch.ethz.ganymed:ganymed-ssh2:build210", 25 "ch.ethz.ganymed:ganymed-ssh2:build210",
28 "org.apache.velocity:velocity:1.6.4", 26 "org.apache.velocity:velocity:1.6.4",
29 "com.squareup.okhttp3:okhttp:3.14.1", 27 "com.squareup.okhttp3:okhttp:3.14.1",
30 - "com.belerweb:pinyin4j:2.5.1" 28 + "com.belerweb:pinyin4j:2.5.1",
  29 + "org.slf4j:slf4j-api:1.7.28"
31 ) 30 )
32 } 31 }
33 32
@@ -55,7 +54,7 @@ uploadArchives { @@ -55,7 +54,7 @@ uploadArchives {
55 authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) 54 authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
56 } 55 }
57 pom.project { 56 pom.project {
58 - version '1.0.5' 57 + version '1.1.2'
59 artifactId ARTIFACT_Id 58 artifactId ARTIFACT_Id
60 groupId GROUP_ID 59 groupId GROUP_ID
61 packaging TYPE 60 packaging TYPE
src/main/java/com/taover/util/UtilExcel.java
@@ -10,8 +10,6 @@ import java.util.HashMap; @@ -10,8 +10,6 @@ import java.util.HashMap;
10 import java.util.List; 10 import java.util.List;
11 import java.util.Map; 11 import java.util.Map;
12 12
13 -import org.apache.commons.logging.Log;  
14 -import org.apache.commons.logging.LogFactory;  
15 import org.apache.poi.hssf.usermodel.HSSFCell; 13 import org.apache.poi.hssf.usermodel.HSSFCell;
16 import org.apache.poi.hssf.usermodel.HSSFWorkbook; 14 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
17 import org.apache.poi.hssf.util.HSSFColor; 15 import org.apache.poi.hssf.util.HSSFColor;
@@ -68,16 +66,8 @@ public class UtilExcel { @@ -68,16 +66,8 @@ public class UtilExcel {
68 * @param data 66 * @param data
69 * @param path 67 * @param path
70 */ 68 */
71 - public static File saveExcelFromListString(String sheetName, List<String[]> data, String path){  
72 - Log log = LogFactory.getLog(UtilExcel.class);  
73 - Workbook wb = null;  
74 - try {  
75 - wb = UtilExcel.getWorkbook(path, false);  
76 - } catch (Exception e1) {  
77 - e1.printStackTrace();  
78 - log.error(e1.getStackTrace().toString()+"保存excel文件失败,失败原因不能获取Workbook对象!msg="+e1.getMessage());  
79 - return null;  
80 - } 69 + public static File saveExcelFromListString(String sheetName, List<String[]> data, String path) throws Exception{
  70 + Workbook wb = UtilExcel.getWorkbook(path, false);
81 //创建Excel工作簿对象 71 //创建Excel工作簿对象
82 Sheet sheet = wb.createSheet(sheetName);//创建Excel工作表对象 72 Sheet sheet = wb.createSheet(sheetName);//创建Excel工作表对象
83 for(int i=0; i<data.size(); ++i){ 73 for(int i=0; i<data.size(); ++i){
@@ -124,16 +114,8 @@ public class UtilExcel { @@ -124,16 +114,8 @@ public class UtilExcel {
124 * @param data 114 * @param data
125 * @param path 115 * @param path
126 */ 116 */
127 - public static void saveExcel(String sheetName, List<List<Object>> data, String path){  
128 - Log log =LogFactory.getLog(UtilExcel.class);  
129 - Workbook wb = null;  
130 - try {  
131 - wb = UtilExcel.getWorkbook(path, false);  
132 - } catch (Exception e1) {  
133 - e1.printStackTrace();  
134 - log.error(e1.getStackTrace().toString()+"保存excel文件失败,失败原因不能获取Workbook对象!msg="+e1.getMessage());  
135 - return;  
136 - } 117 + public static void saveExcel(String sheetName, List<List<Object>> data, String path) throws Exception{
  118 + Workbook wb = UtilExcel.getWorkbook(path, false);
137 //创建Excel工作簿对象 119 //创建Excel工作簿对象
138 Sheet sheet = wb.createSheet(sheetName);//创建Excel工作表对象 120 Sheet sheet = wb.createSheet(sheetName);//创建Excel工作表对象
139 for(int i=0; i<data.size(); ++i){ 121 for(int i=0; i<data.size(); ++i){
@@ -183,16 +165,8 @@ public class UtilExcel { @@ -183,16 +165,8 @@ public class UtilExcel {
183 * @param data 165 * @param data
184 * @param path 166 * @param path
185 */ 167 */
186 - public static void saveExcel(String sheetName, List<List<Object>> data, String path, List<Short> backColorList){  
187 - Log log =LogFactory.getLog(UtilExcel.class);  
188 - Workbook wb = null;  
189 - try {  
190 - wb = UtilExcel.getWorkbook(path, false);  
191 - } catch (Exception e1) {  
192 - e1.printStackTrace();  
193 - log.error(e1.getStackTrace().toString()+"保存excel文件失败,失败原因不能获取Workbook对象!msg="+e1.getMessage());  
194 - return;  
195 - } 168 + public static void saveExcel(String sheetName, List<List<Object>> data, String path, List<Short> backColorList) throws Exception{
  169 + Workbook wb = UtilExcel.getWorkbook(path, false);
196 Map<Short, CellStyle> cellStyleMap = new HashMap<Short, CellStyle>(); 170 Map<Short, CellStyle> cellStyleMap = new HashMap<Short, CellStyle>();
197 Sheet sheet = wb.createSheet(sheetName);//创建Excel工作表对象 171 Sheet sheet = wb.createSheet(sheetName);//创建Excel工作表对象
198 for(int i=0; i<data.size(); ++i){ 172 for(int i=0; i<data.size(); ++i){
@@ -250,27 +224,53 @@ public class UtilExcel { @@ -250,27 +224,53 @@ public class UtilExcel {
250 } 224 }
251 225
252 /** 226 /**
253 - * 读取excel表 227 + * 读取excel表--当前激活的工作表
254 * @param path 228 * @param path
255 */ 229 */
256 - public static List<List<Object>> readExcel(String filepath){ 230 + public static List<List<Object>> readExcel(String filepath) throws Exception{
257 File file = new File(filepath); 231 File file = new File(filepath);
258 List<List<Object>> result = new ArrayList<List<Object>>(); 232 List<List<Object>> result = new ArrayList<List<Object>>();
259 if(!file.exists()){ 233 if(!file.exists()){
260 return result; 234 return result;
261 } 235 }
262 - Log log = LogFactory.getLog(UtilExcel.class);  
263 - Workbook wb = null;  
264 - try {  
265 - wb = UtilExcel.getWorkbook(filepath, true);  
266 - } catch (Exception e1) {  
267 - e1.printStackTrace();  
268 - log.error(e1.getStackTrace().toString()+"保存excel文件失败,失败原因不能获取Workbook对象!msg="+e1.getMessage());  
269 - return new ArrayList<List<Object>>(); 236 + Workbook wb = UtilExcel.getWorkbook(filepath, true);
  237 + return readExcelBySheetIndex(filepath, wb.getActiveSheetIndex());
  238 + }
  239 +
  240 + /**
  241 + * 读取excel表--所有工作表
  242 + * @param path
  243 + */
  244 + public static List<List<Object>> readExcelAllSheet(String filepath) throws Exception{
  245 + File file = new File(filepath);
  246 + List<List<Object>> result = new ArrayList<List<Object>>();
  247 + if(!file.exists()){
  248 + return result;
  249 + }
  250 + Workbook wb = UtilExcel.getWorkbook(filepath, true);
  251 + int sheetNumber = wb.getNumberOfSheets();
  252 +
  253 + for(int sheetIndex=0; sheetIndex<sheetNumber; ++sheetIndex){
  254 + result.addAll(readExcelBySheetIndex(filepath, sheetIndex));
  255 + }
  256 +
  257 + return result;
  258 + }
  259 +
  260 + /**
  261 + * 读取excel表--当前激活的工作表
  262 + * @param path
  263 + */
  264 + public static List<List<Object>> readExcelBySheetIndex(String filepath, int sheetIndex) throws Exception{
  265 + File file = new File(filepath);
  266 + List<List<Object>> result = new ArrayList<List<Object>>();
  267 + if(!file.exists()){
  268 + return result;
270 } 269 }
  270 + Workbook wb = UtilExcel.getWorkbook(filepath, true);
271 //创建Excel工作簿对象 271 //创建Excel工作簿对象
272 DecimalFormat df = new DecimalFormat("0"); 272 DecimalFormat df = new DecimalFormat("0");
273 - Sheet sheet = wb.getSheetAt(wb.getActiveSheetIndex()); 273 + Sheet sheet = wb.getSheetAt(sheetIndex);
274 int start = sheet.getFirstRowNum(); 274 int start = sheet.getFirstRowNum();
275 int end = sheet.getLastRowNum(); 275 int end = sheet.getLastRowNum();
276 if(end > UtilExcel.maxExcelRowNum){ 276 if(end > UtilExcel.maxExcelRowNum){
@@ -309,7 +309,13 @@ public class UtilExcel { @@ -309,7 +309,13 @@ public class UtilExcel {
309 309
310 public static void main(String args[]){ 310 public static void main(String args[]){
311 String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; 311 String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx";
312 - List<List<Object>> data = UtilExcel.readExcel(filepath); 312 + List<List<Object>> data = null;
  313 + try {
  314 + data = UtilExcel.readExcel(filepath);
  315 + } catch (Exception e) {
  316 + // TODO Auto-generated catch block
  317 + e.printStackTrace();
  318 + }
313 List<Short> styleList = new ArrayList<Short>(); 319 List<Short> styleList = new ArrayList<Short>();
314 for(int i=0; i<data.size(); ++i){ 320 for(int i=0; i<data.size(); ++i){
315 if(i == 1)styleList.add(Short.valueOf(HSSFColor.RED.index)); 321 if(i == 1)styleList.add(Short.valueOf(HSSFColor.RED.index));
@@ -319,6 +325,11 @@ public class UtilExcel { @@ -319,6 +325,11 @@ public class UtilExcel {
319 } 325 }
320 System.out.println(""); 326 System.out.println("");
321 } 327 }
322 - UtilExcel.saveExcel("测试", data, "D:\\12345.xlsx", styleList); 328 + try {
  329 + UtilExcel.saveExcel("测试", data, "D:\\12345.xlsx", styleList);
  330 + } catch (Exception e) {
  331 + // TODO Auto-generated catch block
  332 + e.printStackTrace();
  333 + }
323 } 334 }
324 } 335 }
src/main/java/com/taover/util/UtilLog.java
@@ -5,12 +5,12 @@ import java.io.StringWriter; @@ -5,12 +5,12 @@ import java.io.StringWriter;
5 import java.util.HashMap; 5 import java.util.HashMap;
6 import java.util.Map; 6 import java.util.Map;
7 7
8 -import org.apache.commons.logging.Log;  
9 -import org.apache.commons.logging.LogFactory; 8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
10 10
11 11
12 public class UtilLog { 12 public class UtilLog {
13 - private static Map<String, Log> logByClassName = new HashMap<String, Log>(); 13 + private static Map<String, Logger> logByClassName = new HashMap<String, Logger>();
14 14
15 /** 15 /**
16 * 输出日志文本 16 * 输出日志文本
@@ -19,9 +19,9 @@ public class UtilLog { @@ -19,9 +19,9 @@ public class UtilLog {
19 */ 19 */
20 public static void infoForMessage(String message, Class infoClass){ 20 public static void infoForMessage(String message, Class infoClass){
21 String className = infoClass.getName(); 21 String className = infoClass.getName();
22 - Log log = logByClassName.get(infoClass.getName()); 22 + Logger log = logByClassName.get(infoClass.getName());
23 if(log == null){ 23 if(log == null){
24 - log = LogFactory.getLog(infoClass); 24 + log = LoggerFactory.getLogger(infoClass);
25 if(log == null){ 25 if(log == null){
26 return; 26 return;
27 } 27 }
@@ -49,9 +49,9 @@ public class UtilLog { @@ -49,9 +49,9 @@ public class UtilLog {
49 */ 49 */
50 public static void errorForMessage(String message, Class infoClass){ 50 public static void errorForMessage(String message, Class infoClass){
51 String className = infoClass.getName(); 51 String className = infoClass.getName();
52 - Log log = logByClassName.get(infoClass.getName()); 52 + Logger log = logByClassName.get(infoClass.getName());
53 if(log == null){ 53 if(log == null){
54 - log = LogFactory.getLog(infoClass); 54 + log = LoggerFactory.getLogger(infoClass);
55 if(log == null){ 55 if(log == null){
56 return; 56 return;
57 } 57 }
src/main/java/com/taover/util/UtilObject.java
@@ -298,6 +298,32 @@ public class UtilObject { @@ -298,6 +298,32 @@ public class UtilObject {
298 return result; 298 return result;
299 } 299 }
300 300
  301 + public static <E> E mapToObject(Map<String, Object> dataMap, Class<E> beanClass) throws Exception{
  302 + if(beanClass == null){
  303 + return null;
  304 + }
  305 + E result = beanClass.newInstance();
  306 + Iterator<String> keyIter = dataMap.keySet().iterator();
  307 + while(keyIter.hasNext()){
  308 + String keyName = keyIter.next();
  309 + String camelName = UtilString.camelName(keyName);
  310 + Object keyValue = dataMap.get(keyName);
  311 +
  312 + if(keyValue == null){
  313 + continue;
  314 + }
  315 +
  316 + try {
  317 + Field keyField = beanClass.getDeclaredField(camelName);
  318 + keyField.setAccessible(true);
  319 + keyField.set(result, keyValue);
  320 + } catch (Exception e) {
  321 + e.printStackTrace();
  322 + }
  323 + }
  324 + return result;
  325 + }
  326 +
301 public static void main(String args[]){ 327 public static void main(String args[]){
302 328
303 class Temp2{ 329 class Temp2{
src/main/java/com/taover/util/UtilProperties.java
@@ -8,12 +8,7 @@ import java.io.PrintWriter; @@ -8,12 +8,7 @@ import java.io.PrintWriter;
8 import java.io.StringWriter; 8 import java.io.StringWriter;
9 import java.util.Properties; 9 import java.util.Properties;
10 10
11 -import org.apache.commons.logging.Log;  
12 -import org.apache.commons.logging.LogFactory;  
13 -  
14 public class UtilProperties { 11 public class UtilProperties {
15 - Log log = LogFactory.getLog(this.getClass());  
16 -  
17 public static String getPropertiesContent(String fileName){ 12 public static String getPropertiesContent(String fileName){
18 InputStream inStream = UtilProperties.class.getClassLoader().getResourceAsStream("/conf/"+fileName); 13 InputStream inStream = UtilProperties.class.getClassLoader().getResourceAsStream("/conf/"+fileName);
19 try { 14 try {
src/main/java/com/taover/util/UtilTemplate.java
1 package com.taover.util; 1 package com.taover.util;
2 2
3 -import java.io.PrintWriter;  
4 import java.io.StringWriter; 3 import java.io.StringWriter;
5 import java.util.Iterator; 4 import java.util.Iterator;
6 import java.util.Map; 5 import java.util.Map;
7 import java.util.Properties; 6 import java.util.Properties;
8 import java.util.Set; 7 import java.util.Set;
9 8
10 -import org.apache.commons.logging.Log;  
11 -import org.apache.commons.logging.LogFactory;  
12 import org.apache.velocity.Template; 9 import org.apache.velocity.Template;
13 import org.apache.velocity.VelocityContext; 10 import org.apache.velocity.VelocityContext;
14 import org.apache.velocity.app.VelocityEngine; 11 import org.apache.velocity.app.VelocityEngine;
@@ -21,7 +18,7 @@ public class UtilTemplate { @@ -21,7 +18,7 @@ public class UtilTemplate {
21 * @param data 18 * @param data
22 * @return 19 * @return
23 */ 20 */
24 - public static String renderTemplateClass(String templateClassPath, Map<String, Object> data){ 21 + public static String renderTemplateClass(String templateClassPath, Map<String, Object> data) throws Exception{
25 //初始化 22 //初始化
26 VelocityEngine ve = new VelocityEngine(); 23 VelocityEngine ve = new VelocityEngine();
27 Properties p = new Properties(); 24 Properties p = new Properties();
@@ -32,14 +29,7 @@ public class UtilTemplate { @@ -32,14 +29,7 @@ public class UtilTemplate {
32 p.put(VelocityEngine.OUTPUT_ENCODING, "UTF-8"); 29 p.put(VelocityEngine.OUTPUT_ENCODING, "UTF-8");
33 p.put(VelocityEngine.ENCODING_DEFAULT, "UTF-8"); 30 p.put(VelocityEngine.ENCODING_DEFAULT, "UTF-8");
34 p.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); 31 p.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
35 - try {  
36 - ve.init(p);  
37 - } catch (Exception e) {  
38 - StringWriter sw = new StringWriter();  
39 - e.printStackTrace(new PrintWriter(sw, true));  
40 - Log log = LogFactory.getLog(UtilTemplate.class);  
41 - log.error(sw.toString());  
42 - } 32 + ve.init(p);
43 //取得VelocityContext对象 33 //取得VelocityContext对象
44 VelocityContext context = new VelocityContext(); 34 VelocityContext context = new VelocityContext();
45 //向context中放入要在模板中用到的数据对象 35 //向context中放入要在模板中用到的数据对象
@@ -57,16 +47,9 @@ public class UtilTemplate { @@ -57,16 +47,9 @@ public class UtilTemplate {
57 } 47 }
58 Template template; 48 Template template;
59 StringWriter sw = new StringWriter(); 49 StringWriter sw = new StringWriter();
60 - try {  
61 - template = ve.getTemplate(templateClassPath, "UTF-8");  
62 - //合并输出  
63 - template.merge( context, sw);  
64 - } catch (Exception e) {  
65 - StringWriter swE = new StringWriter();  
66 - e.printStackTrace(new PrintWriter(swE, true));  
67 - Log log = LogFactory.getLog(UtilTemplate.class);  
68 - log.error(sw.toString());  
69 - } 50 + template = ve.getTemplate(templateClassPath, "UTF-8");
  51 + //合并输出
  52 + template.merge( context, sw);
70 return sw.toString(); 53 return sw.toString();
71 } 54 }
72 } 55 }
src/test/java/TempExcel.java 0 → 100644
@@ -0,0 +1,218 @@ @@ -0,0 +1,218 @@
  1 +import java.util.ArrayList;
  2 +import java.util.HashMap;
  3 +import java.util.Iterator;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import com.taover.util.UtilExcel;
  8 +
  9 +public class TempExcel {
  10 + public static void main(String[] args){
  11 + dealExcel();
  12 + }
  13 +
  14 + public static final String SEPARATE_CONSIGNEE_MOBILE = "__";
  15 + public static final int EXCEL_TIANMAO_CONSIGNEE_INDEX = 14;
  16 + public static final int EXCEL_TIANMAO_MOBILE_INDEX = 18;
  17 + public static final int EXCEL_TIANMAO_ORDERDATE_INDEX = 20;
  18 + public static final int EXCEL_TIANMAO_GOODSNUMBER_INDEX = 26;
  19 + public static final int EXCEL_JD_CONSIGNEE_INDEX = 14;
  20 + public static final int EXCEL_JD_MOBILE_INDEX = 16;
  21 + public static final int EXCEL_JD_ORDERDATE_INDEX = 24;
  22 + public static final int EXCEL_JD_GOODSNUMBER_INDEX = 3;
  23 +
  24 + public static void dealExcel(){
  25 + try {
  26 + List<List<Object>> tianmaoData = UtilExcel.readExcel("D:\\tempexcel\\tianmao.xlsx");
  27 + List<List<Object>> jdData = UtilExcel.readExcel("D:\\tempexcel\\jd.xls");
  28 + tianmaoData.remove(0);
  29 + jdData.remove(0);
  30 +
  31 + //按下单人及下单手机号分类
  32 + Map<String, List<List<Object>>> separateData = new HashMap<String, List<List<Object>>>();
  33 + for(int i=0; i<tianmaoData.size(); ++i){
  34 + List<Object> tempData = tianmaoData.get(i);
  35 + injectMap(separateData, getNameAndMobileByTianmao(tempData), tempData);
  36 + }
  37 + for(int i=0; i<jdData.size(); ++i){
  38 + List<Object> tempData = jdData.get(i);
  39 + injectMap(separateData, getNameAndMobileByJd(tempData), tempData);
  40 + }
  41 +
  42 + //分析下单分类
  43 + List<SeparateAnalysisInfo> analysisData = new ArrayList<SeparateAnalysisInfo>();
  44 + Iterator<String> keyIter = separateData.keySet().iterator();
  45 + while(keyIter.hasNext()){
  46 + String keyName = keyIter.next();
  47 + List<List<Object>> keyData = separateData.get(keyName);
  48 + if(keyData.size() <= 1){
  49 + continue;
  50 + }
  51 +
  52 + String[] keyNameSep = keyName.split(TempExcel.SEPARATE_CONSIGNEE_MOBILE);
  53 + if(keyNameSep.length == 4){
  54 + SeparateAnalysisInfo anaInfo = new SeparateAnalysisInfo(keyNameSep[0], keyNameSep[1], keyData, Integer.valueOf(keyNameSep[2]), Integer.valueOf(keyNameSep[3]));
  55 + if(anaInfo.getDescList().size() > 1){
  56 + analysisData.add(anaInfo);
  57 + }
  58 + }
  59 + }
  60 +
  61 + //打印信息,保存信息
  62 + List<List<Object>> resultInfo = new ArrayList<List<Object>>();
  63 + List<Object> blankRow = new ArrayList<Object>();
  64 + for(int i=0; i<analysisData.size(); ++i){
  65 + SeparateAnalysisInfo item = analysisData.get(i);
  66 +
  67 + //添加空白间距行
  68 + resultInfo.add(blankRow);
  69 + resultInfo.add(blankRow);
  70 +
  71 + //用户信息列
  72 + List<Object> userInfo = new ArrayList<Object>();
  73 + userInfo.add("收货人:"+item.getConsignee());
  74 + userInfo.add("电话号:"+item.getMobile());
  75 + resultInfo.add(userInfo);
  76 +
  77 + //下单信息列
  78 + List<Object> descInfo = new ArrayList<Object>();
  79 + descInfo.add("下单简述");
  80 + for(int j=0; j<item.getDescList().size(); ++j){
  81 + descInfo.add(item.getDescList().get(j));
  82 + }
  83 + resultInfo.add(descInfo);
  84 +
  85 + //订单详情
  86 + resultInfo.addAll(item.getOrderData());
  87 + }
  88 + UtilExcel.saveExcel("处理结果", resultInfo, "D:\\tempexcel\\resultinfo.xlsx");
  89 + } catch (Exception e) {
  90 + e.printStackTrace();
  91 + }
  92 + }
  93 +
  94 + public static void injectMap(Map<String, List<List<Object>>> separateData, String keyName, List<Object> keyValue){
  95 + if(separateData.containsKey(keyName)){
  96 + separateData.get(keyName).add(keyValue);
  97 + }else{
  98 + List<List<Object>> tempData = new ArrayList<List<Object>>();
  99 + tempData.add(keyValue);
  100 + separateData.put(keyName, tempData);
  101 + }
  102 + }
  103 +
  104 + public static String getNameAndMobileByTianmao(List<Object> data){
  105 + String name = data.get(EXCEL_TIANMAO_CONSIGNEE_INDEX).toString();
  106 + String mobile = data.get(EXCEL_TIANMAO_MOBILE_INDEX).toString();
  107 + return name+SEPARATE_CONSIGNEE_MOBILE+mobile+SEPARATE_CONSIGNEE_MOBILE+EXCEL_TIANMAO_ORDERDATE_INDEX+SEPARATE_CONSIGNEE_MOBILE+EXCEL_TIANMAO_GOODSNUMBER_INDEX;
  108 + }
  109 +
  110 + public static String getNameAndMobileByJd(List<Object> data){
  111 + String name = data.get(EXCEL_JD_CONSIGNEE_INDEX).toString();
  112 + String mobile = data.get(EXCEL_JD_MOBILE_INDEX).toString();
  113 + return name+SEPARATE_CONSIGNEE_MOBILE+mobile+SEPARATE_CONSIGNEE_MOBILE+EXCEL_TIANMAO_ORDERDATE_INDEX+SEPARATE_CONSIGNEE_MOBILE+EXCEL_TIANMAO_GOODSNUMBER_INDEX;
  114 + }
  115 +}
  116 +
  117 +class SeparateAnalysisInfo{
  118 + private String consignee;
  119 + private String mobile;
  120 + private List<String> descList;
  121 + private List<List<Object>> orderData;
  122 +
  123 + public SeparateAnalysisInfo(String consignee, String mobile, List<List<Object>> data, int excelOrderDateIndex, int excelGoodsNumberIndex){
  124 + this.consignee = consignee;
  125 + this.mobile = mobile;
  126 + this.orderData = data;
  127 +
  128 + for(int i=0; i<data.size(); ++i){
  129 + List<Object> dataItem = data.get(i);
  130 + if(dataItem.get(excelOrderDateIndex) == null){
  131 + System.out.println("没有下单日期信息:"+this.consignee+"__"+this.mobile);
  132 + continue;
  133 + }
  134 + if(dataItem.get(excelGoodsNumberIndex) == null){
  135 + System.out.println("没有商品数量信息:"+this.consignee+"__"+this.mobile);
  136 + continue;
  137 + }
  138 +
  139 + String orderDate = dataItem.get(excelOrderDateIndex).toString();
  140 + if(orderDate.contains("-")){
  141 + orderDate = orderDate.substring(0, 10);
  142 + }else{
  143 + String[] dateInfo = orderDate.split(" ");
  144 + if(dateInfo.length > 0){
  145 + orderDate = dateInfo[0].replace("/", "-");
  146 + }
  147 + }
  148 + String goodsNumber = dataItem.get(excelGoodsNumberIndex).toString();
  149 + this.addDescListItem(orderDate, goodsNumber);
  150 + }
  151 + }
  152 +
  153 + public String getConsignee() {
  154 + return consignee;
  155 + }
  156 + public void setConsignee(String consignee) {
  157 + this.consignee = consignee;
  158 + }
  159 + public String getMobile() {
  160 + return mobile;
  161 + }
  162 + public void setMobile(String mobile) {
  163 + this.mobile = mobile;
  164 + }
  165 + public List<String> getDescList() {
  166 + return descList;
  167 + }
  168 + public void setDescList(List<String> descList) {
  169 + this.descList = descList;
  170 + }
  171 +
  172 + public void addDescListItem(String orderDate, String goodsNumber){
  173 + if(this.descList == null){
  174 + this.descList = new ArrayList<String>();
  175 + }
  176 + String separateStr = "__";
  177 +
  178 + //检查是否有重复日期的情况
  179 + boolean existsDate = false;
  180 + for(int i=0; i<this.descList.size(); ++i){
  181 + String tempDesc = this.descList.get(i);
  182 + if(tempDesc.startsWith(orderDate)){
  183 + existsDate = true;
  184 + String[] tempData = tempDesc.split(separateStr);
  185 + if(tempData.length > 1){
  186 + String[] tempDataGoods = tempData[1].split("件");
  187 + if(tempDataGoods.length > 0){
  188 + try{
  189 + int totalNumber = Integer.valueOf(tempDataGoods[0]).intValue()+Integer.valueOf(goodsNumber).intValue();
  190 + this.descList.set(i, orderDate+separateStr+totalNumber+"件");
  191 + }catch(Exception e){
  192 + e.printStackTrace();
  193 + }
  194 + }
  195 + }
  196 +
  197 + break;
  198 + }
  199 + }
  200 + if(!existsDate){
  201 + this.descList.add(orderDate+separateStr+goodsNumber+"件");
  202 + }
  203 + }
  204 +
  205 + public List<List<Object>> getOrderData() {
  206 + return orderData;
  207 + }
  208 + public void setOrderData(List<List<Object>> orderData) {
  209 + this.orderData = orderData;
  210 + }
  211 +
  212 + public void addOrderDataItem(List<Object> orderData){
  213 + if(this.orderData == null){
  214 + this.orderData = new ArrayList<List<Object>>();
  215 + }
  216 + this.orderData.add(orderData);
  217 + }
  218 +}