Commit b7723c8d9718e86258eb99c5b4ea42e9336c49e0
1 parent
bd4fb9d4
Exists in
master
1.ignore
Showing
13 changed files
with
979 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,56 @@ |
1 | +buildscript { | |
2 | + repositories { | |
3 | + mavenCentral() | |
4 | + | |
5 | + } | |
6 | + dependencies { | |
7 | + classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE") | |
8 | + } | |
9 | +} | |
10 | + | |
11 | +apply plugin: 'java' | |
12 | +apply plugin: 'eclipse' | |
13 | +apply plugin: 'application' | |
14 | +apply plugin: 'org.springframework.boot' | |
15 | +apply plugin: 'io.spring.dependency-management' | |
16 | + | |
17 | +group = 'com.taover.bazhuayun.analysis' | |
18 | +mainClassName = 'com.taover.bazhuayun.analysis.StartUp' | |
19 | +sourceCompatibility = 1.8 | |
20 | + | |
21 | +repositories { | |
22 | + maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' } | |
23 | + jcenter() | |
24 | + maven{ url 'http://repository.sonatype.org/content/groups/public/' } | |
25 | + maven{ url 'https://repository.jboss.org/nexus/content/groups/public/' } | |
26 | + maven{ url 'http://nexus.taover.com:9001/repository/maven-releases/' } | |
27 | + | |
28 | +} | |
29 | + | |
30 | +dependencies { | |
31 | + compile( | |
32 | + "com.thoughtworks.xstream:xstream:1.4.12", | |
33 | + "org.springframework.boot:spring-boot-starter", | |
34 | + "org.springframework.boot:spring-boot-starter-web", | |
35 | + "org.springframework.boot:spring-boot-starter-jetty", | |
36 | + "org.springframework.boot:spring-boot-starter-data-jpa", | |
37 | + "org.springframework.boot:spring-boot-starter-mail", | |
38 | + | |
39 | + "mysql:mysql-connector-java", | |
40 | + | |
41 | + "com.hankcs:hanlp:portable-1.7.5", | |
42 | + | |
43 | + "com.aliyun.oss:aliyun-sdk-oss:2.0.7", | |
44 | + "com.alibaba:fastjson:1.2.72", | |
45 | + "com.alibaba:druid-spring-boot-starter:1.1.10", | |
46 | + | |
47 | + "com.xuxueli:xxl-job-core:2.1.0", | |
48 | + "com.taover:com-taover-repository:2.1.22", | |
49 | + "com.taover:com-taover-easyexcel:2.2.14", | |
50 | + "com.taover:com-taover-util:1.1.112", | |
51 | + "cn.hutool:hutool-all:5.2.4", | |
52 | + "com.taover:com-taover-codegenerate:1.2.11", | |
53 | + "com.auth0:java-jwt:3.4.0", | |
54 | + "io.jsonwebtoken:jjwt:0.6.0" | |
55 | + ) | |
56 | +} | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +/* | |
2 | + * This file was generated by the Gradle 'init' task. | |
3 | + * | |
4 | + * The settings file is used to specify which projects to include in your build. | |
5 | + * | |
6 | + * Detailed information about configuring a multi-project build in Gradle can be found | |
7 | + * in the user guide at https://docs.gradle.org/4.5.1/userguide/multi_project_builds.html | |
8 | + */ | |
9 | + | |
10 | +rootProject.name = '8zyun-data-analysis' | ... | ... |
src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsDataFileParser.java
0 โ 100644
... | ... | @@ -0,0 +1,68 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.io.File; | |
4 | +import java.util.ArrayList; | |
5 | +import java.util.Collections; | |
6 | +import java.util.HashSet; | |
7 | +import java.util.Iterator; | |
8 | +import java.util.List; | |
9 | +import java.util.Set; | |
10 | + | |
11 | +import com.taover.bazhuayun.analysis.util.ExcelUtil; | |
12 | + | |
13 | +public class GoodsDataFileParser { | |
14 | + private String fileNameIgnorePreffix; | |
15 | + private StringBuffer logStrBuffer = new StringBuffer(); | |
16 | + private Set<GoodsInfoRow> rowSet = new HashSet<GoodsInfoRow>(); | |
17 | + | |
18 | + private String[] goodsNamePatternArr; | |
19 | + private String[] goodsSkuNameParrternArr; | |
20 | + private GroupInfoExcelData groupInfoData; | |
21 | + | |
22 | + public GoodsDataFileParser(String[] goodsNamePatternArr, String[] goodsSkuNameParrternArr, GroupInfoExcelData groupInfoData) { | |
23 | + this.goodsNamePatternArr = goodsNamePatternArr; | |
24 | + this.goodsSkuNameParrternArr = goodsSkuNameParrternArr; | |
25 | + this.groupInfoData = groupInfoData; | |
26 | + } | |
27 | + | |
28 | + public void setFileNameIgnorePreffix(String preffix) { | |
29 | + this.fileNameIgnorePreffix = preffix; | |
30 | + } | |
31 | + | |
32 | + public void parse(GroupInfoExcelData groupInfoData, File[] listFiles) throws Exception { | |
33 | + for(int i=0; i<listFiles.length; ++i) { | |
34 | + File item = listFiles[i]; | |
35 | + | |
36 | + //่ทๅๅไปถ็ป/ๅไปถไบบ | |
37 | + String fileName = item.getName().replaceFirst(this.fileNameIgnorePreffix, ""); | |
38 | + GroupInfoExcelDataRow groupInfo = this.groupInfoData.findByFileName(fileName); | |
39 | + | |
40 | + //่ฏปๅExcelๆไปถ | |
41 | + List<List<Object>> data = ExcelUtil.readExcelSheet(item, false); | |
42 | + if(data.isEmpty()) { | |
43 | + continue; | |
44 | + } | |
45 | + | |
46 | + //ๅๅ ฅset | |
47 | + GoodsInfoExcelDataHeader header = new GoodsInfoExcelDataHeader(this.goodsNamePatternArr, this.goodsSkuNameParrternArr, data.get(0)); | |
48 | + for(int j=1; j<data.size(); ++j) { | |
49 | + this.rowSet.add(new GoodsInfoRow(groupInfo, header, data.get(j))); | |
50 | + } | |
51 | + } | |
52 | + } | |
53 | + | |
54 | + public List<GoodsInfoRow> getResult() { | |
55 | + List<GoodsInfoRow> data = new ArrayList<GoodsInfoRow>(); | |
56 | + Iterator<GoodsInfoRow> rowIter = this.rowSet.iterator(); | |
57 | + while(rowIter.hasNext()) { | |
58 | + data.add(rowIter.next()); | |
59 | + } | |
60 | + Collections.sort(data); | |
61 | + return data; | |
62 | + } | |
63 | + | |
64 | + public String getLogString() { | |
65 | + return logStrBuffer.toString(); | |
66 | + } | |
67 | + | |
68 | +} | ... | ... |
src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsInfoExcelDataHeader.java
0 โ 100644
... | ... | @@ -0,0 +1,40 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import com.taover.bazhuayun.analysis.util.StringTool; | |
6 | + | |
7 | +public class GoodsInfoExcelDataHeader { | |
8 | + private Integer goodsNameIndex; | |
9 | + private Integer goodsSkuNameIndex; | |
10 | + | |
11 | + public GoodsInfoExcelDataHeader(String[] goodsNamePattern, String[] goodsSkuNamePattern, List<Object> data) { | |
12 | + for(int i=0; i<data.size(); ++i) { | |
13 | + Object item = data.get(i); | |
14 | + if(item == null) { | |
15 | + continue; | |
16 | + } | |
17 | + if(StringTool.getStartWithStringIndex(item.toString(), goodsNamePattern) != -1) { | |
18 | + this.goodsNameIndex = i; | |
19 | + continue; | |
20 | + } | |
21 | + if(StringTool.getStartWithStringIndex(item.toString(), goodsSkuNamePattern) != -1) { | |
22 | + this.goodsSkuNameIndex = i; | |
23 | + continue; | |
24 | + } | |
25 | + } | |
26 | + } | |
27 | + | |
28 | + public Integer getGoodsNameIndex() { | |
29 | + return goodsNameIndex; | |
30 | + } | |
31 | + public void setGoodsNameIndex(Integer goodsNameIndex) { | |
32 | + this.goodsNameIndex = goodsNameIndex; | |
33 | + } | |
34 | + public Integer getGoodsSkuNameIndex() { | |
35 | + return goodsSkuNameIndex; | |
36 | + } | |
37 | + public void setGoodsSkuNameIndex(Integer goodsSkuNameIndex) { | |
38 | + this.goodsSkuNameIndex = goodsSkuNameIndex; | |
39 | + } | |
40 | +} | ... | ... |
src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsInfoRow.java
0 โ 100644
... | ... | @@ -0,0 +1,160 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +public class GoodsInfoRow implements Comparable<GoodsInfoRow>{ | |
6 | + private String originGoodsName; | |
7 | + private String commonGoodsName; | |
8 | + private String groupNickname; | |
9 | + private String originGoodsSkuName; | |
10 | + private String commonGoodsSkuName; | |
11 | + private String senderNickname; | |
12 | + | |
13 | + public GoodsInfoRow(GroupInfoExcelDataRow groupInfo, GoodsInfoExcelDataHeader header, List<Object> data) { | |
14 | + if(groupInfo != null) { | |
15 | + this.groupNickname = groupInfo.getGroupName(); | |
16 | + this.senderNickname = groupInfo.getSendNickname(); | |
17 | + }else { | |
18 | + this.groupNickname = ""; | |
19 | + this.senderNickname = ""; | |
20 | + } | |
21 | + this.originGoodsName = this.getEmptyStrWhenNull(data, header.getGoodsNameIndex()); | |
22 | + this.originGoodsSkuName = this.getEmptyStrWhenNull(data, header.getGoodsSkuNameIndex()); | |
23 | + } | |
24 | + | |
25 | + private String getEmptyStrWhenNull(List<Object> data, Integer goodsNameIndex) { | |
26 | + if(goodsNameIndex == null) { | |
27 | + return ""; | |
28 | + } | |
29 | + if(data.size() > goodsNameIndex) { | |
30 | + Object temp = data.get(goodsNameIndex); | |
31 | + if(temp == null) { | |
32 | + return ""; | |
33 | + }else { | |
34 | + return temp.toString(); | |
35 | + } | |
36 | + }else { | |
37 | + return ""; | |
38 | + } | |
39 | + } | |
40 | + | |
41 | + public String getOriginGoodsName() { | |
42 | + return originGoodsName; | |
43 | + } | |
44 | + public void setOriginGoodsName(String originGoodsName) { | |
45 | + this.originGoodsName = originGoodsName; | |
46 | + } | |
47 | + public String getCommonGoodsName() { | |
48 | + return commonGoodsName; | |
49 | + } | |
50 | + public void setCommonGoodsName(String commonGoodsName) { | |
51 | + this.commonGoodsName = commonGoodsName; | |
52 | + } | |
53 | + public String getGroupNickname() { | |
54 | + return groupNickname; | |
55 | + } | |
56 | + public void setGroupNickname(String groupName) { | |
57 | + this.groupNickname = groupName; | |
58 | + } | |
59 | + public String getOriginGoodsSkuName() { | |
60 | + return originGoodsSkuName; | |
61 | + } | |
62 | + public void setOriginGoodsSkuName(String originGoodsSkuName) { | |
63 | + this.originGoodsSkuName = originGoodsSkuName; | |
64 | + } | |
65 | + public String getCommonGoodsSkuName() { | |
66 | + return commonGoodsSkuName; | |
67 | + } | |
68 | + public void setCommonGooodsSkuName(String commonSkuName) { | |
69 | + this.commonGoodsSkuName = commonSkuName; | |
70 | + } | |
71 | + public String getSenderNickname() { | |
72 | + return senderNickname; | |
73 | + } | |
74 | + public void setSenderNickname(String senderNickname) { | |
75 | + this.senderNickname = senderNickname; | |
76 | + } | |
77 | + @Override | |
78 | + public int hashCode() { | |
79 | + final int prime = 31; | |
80 | + int result = 1; | |
81 | + result = prime * result + ((groupNickname == null) ? 0 : groupNickname.hashCode()); | |
82 | + result = prime * result + ((originGoodsName == null) ? 0 : originGoodsName.hashCode()); | |
83 | + result = prime * result + ((originGoodsSkuName == null) ? 0 : originGoodsSkuName.hashCode()); | |
84 | + return result; | |
85 | + } | |
86 | + | |
87 | + @Override | |
88 | + public boolean equals(Object obj) { | |
89 | + if (this == obj) | |
90 | + return true; | |
91 | + if (obj == null) | |
92 | + return false; | |
93 | + if (getClass() != obj.getClass()) | |
94 | + return false; | |
95 | + GoodsInfoRow other = (GoodsInfoRow) obj; | |
96 | + if (groupNickname == null) { | |
97 | + if (other.groupNickname != null) | |
98 | + return false; | |
99 | + } else if (!groupNickname.equals(other.groupNickname)) | |
100 | + return false; | |
101 | + if (originGoodsName == null) { | |
102 | + if (other.originGoodsName != null) | |
103 | + return false; | |
104 | + } else if (!originGoodsName.equals(other.originGoodsName)) | |
105 | + return false; | |
106 | + if (originGoodsSkuName == null) { | |
107 | + if (other.originGoodsSkuName != null) | |
108 | + return false; | |
109 | + } else if (!originGoodsSkuName.equals(other.originGoodsSkuName)) | |
110 | + return false; | |
111 | + return true; | |
112 | + } | |
113 | + | |
114 | + @Override | |
115 | + public int compareTo(GoodsInfoRow o) { | |
116 | + if(o == null) { | |
117 | + return 1; | |
118 | + } | |
119 | + if(this.equals(o)) { | |
120 | + return 0; | |
121 | + }else { | |
122 | + return this.calcDistince(o); | |
123 | + } | |
124 | + } | |
125 | + | |
126 | + private int calcDistince(GoodsInfoRow o) { | |
127 | + int groupDistince; | |
128 | + if(this.groupNickname == null && o.groupNickname == null) { | |
129 | + groupDistince = 0; | |
130 | + }else if(this.groupNickname == null){ | |
131 | + groupDistince = 0 - o.groupNickname.hashCode(); | |
132 | + }else if(o.groupNickname == null) { | |
133 | + groupDistince = this.groupNickname.hashCode(); | |
134 | + }else { | |
135 | + groupDistince = this.groupNickname.hashCode()-o.groupNickname.hashCode(); | |
136 | + } | |
137 | + int goodsNameDistince; | |
138 | + if(this.originGoodsName == null && o.originGoodsName == null) { | |
139 | + goodsNameDistince = 0; | |
140 | + }else if(this.originGoodsName == null){ | |
141 | + goodsNameDistince = 0 - o.originGoodsName.hashCode(); | |
142 | + }else if(o.originGoodsName == null) { | |
143 | + goodsNameDistince = this.originGoodsName.hashCode(); | |
144 | + }else { | |
145 | + goodsNameDistince = this.originGoodsName.hashCode()-o.originGoodsName.hashCode(); | |
146 | + } | |
147 | + int goodsSkuNameDistince; | |
148 | + if(this.originGoodsSkuName == null && o.originGoodsSkuName == null) { | |
149 | + goodsSkuNameDistince = 0; | |
150 | + }else if(this.originGoodsSkuName == null){ | |
151 | + goodsSkuNameDistince = 0 - o.originGoodsSkuName.hashCode(); | |
152 | + }else if(o.originGoodsSkuName == null) { | |
153 | + goodsSkuNameDistince = this.originGoodsSkuName.hashCode(); | |
154 | + }else { | |
155 | + goodsSkuNameDistince = this.originGoodsSkuName.hashCode()-o.originGoodsSkuName.hashCode(); | |
156 | + } | |
157 | + | |
158 | + return (int)(1.0*groupDistince/Integer.MAX_VALUE*1000)+(int)(1.0*goodsNameDistince/Integer.MAX_VALUE*100)+(int)(1.0*goodsSkuNameDistince/Integer.MAX_VALUE*10); | |
159 | + } | |
160 | +} | ... | ... |
src/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelData.java
0 โ 100644
... | ... | @@ -0,0 +1,40 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.io.File; | |
4 | +import java.util.ArrayList; | |
5 | +import java.util.List; | |
6 | + | |
7 | +import com.taover.bazhuayun.analysis.util.ExcelUtil; | |
8 | + | |
9 | +public class GroupInfoExcelData { | |
10 | + private GroupInfoExcelDataHeader header; | |
11 | + private List<GroupInfoExcelDataRow> rowList = new ArrayList<GroupInfoExcelDataRow>(); | |
12 | + | |
13 | + public void load(String groupInfoFilePath) throws Exception { | |
14 | + if(groupInfoFilePath == null) { | |
15 | + throw new Exception("groupInfoFilePath is null"); | |
16 | + } | |
17 | + File groupInfoFile = new File(groupInfoFilePath); | |
18 | + if(!groupInfoFile.exists()) { | |
19 | + throw new Exception("groupinfofile not exists"); | |
20 | + } | |
21 | + | |
22 | + List<List<Object>> data = ExcelUtil.readExcelSheet(groupInfoFile, false); | |
23 | + if(data.size() > 0) { | |
24 | + header = new GroupInfoExcelDataHeader(data.get(0)); | |
25 | + } | |
26 | + for(int i=1; i<data.size(); ++i) { | |
27 | + this.rowList.add(new GroupInfoExcelDataRow(this.header, data.get(i))); | |
28 | + } | |
29 | + } | |
30 | + | |
31 | + public GroupInfoExcelDataRow findByFileName(String fileName) { | |
32 | + for(GroupInfoExcelDataRow item: rowList) { | |
33 | + if(item.getFilePath().contains(fileName)) { | |
34 | + return item; | |
35 | + } | |
36 | + } | |
37 | + return null; | |
38 | + } | |
39 | + | |
40 | +} | ... | ... |
src/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelDataHeader.java
0 โ 100644
... | ... | @@ -0,0 +1,72 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +public class GroupInfoExcelDataHeader { | |
6 | + public static final String HEADER_GROUP_NAME = "็พคๅ็งฐ"; | |
7 | + public static final String HEADER_ROOW_WXID = "room_wxid"; | |
8 | + public static final String HEADER_FILE_PATH = "ๆไปถ่ทฏๅพ"; | |
9 | + public static final String HEADER_SENDER_NICKNAME = "ๅ้ไบบๆต็งฐ"; | |
10 | + | |
11 | + private Integer groupNameIndex; | |
12 | + private Integer roowWxidIndex; | |
13 | + private Integer fielPathIndex; | |
14 | + private Integer senderNicknameIndex; | |
15 | + | |
16 | + public GroupInfoExcelDataHeader(List<Object> data) { | |
17 | + for(int i=0; i<data.size(); ++i) { | |
18 | + Object item = data.get(i); | |
19 | + if(item == null) { | |
20 | + continue; | |
21 | + } | |
22 | + if(HEADER_GROUP_NAME.equals(item.toString())) { | |
23 | + this.groupNameIndex = i; | |
24 | + continue; | |
25 | + } | |
26 | + if(HEADER_FILE_PATH.equals(item.toString())) { | |
27 | + this.fielPathIndex = i; | |
28 | + continue; | |
29 | + } | |
30 | + if(HEADER_ROOW_WXID.equals(item.toString())) { | |
31 | + this.roowWxidIndex = i; | |
32 | + continue; | |
33 | + } | |
34 | + if(HEADER_SENDER_NICKNAME.equals(item.toString())) { | |
35 | + this.senderNicknameIndex = i; | |
36 | + continue; | |
37 | + } | |
38 | + } | |
39 | + } | |
40 | + | |
41 | + | |
42 | + public Integer getSenderNicknameIndex() { | |
43 | + return senderNicknameIndex; | |
44 | + } | |
45 | + | |
46 | + | |
47 | + public void setSenderNicknameIndex(Integer senderNicknameIndex) { | |
48 | + this.senderNicknameIndex = senderNicknameIndex; | |
49 | + } | |
50 | + | |
51 | + | |
52 | + public Integer getGroupNameIndex() { | |
53 | + return groupNameIndex; | |
54 | + } | |
55 | + public void setGroupNameIndex(Integer groupNameIndex) { | |
56 | + this.groupNameIndex = groupNameIndex; | |
57 | + } | |
58 | + public Integer getRoowWxidIndex() { | |
59 | + return roowWxidIndex; | |
60 | + } | |
61 | + public void setRoowWxidIndex(Integer roowWxidIndex) { | |
62 | + this.roowWxidIndex = roowWxidIndex; | |
63 | + } | |
64 | + public Integer getFielPathIndex() { | |
65 | + return fielPathIndex; | |
66 | + } | |
67 | + public void setFielPathIndex(Integer fielPathIndex) { | |
68 | + this.fielPathIndex = fielPathIndex; | |
69 | + } | |
70 | + | |
71 | + | |
72 | +} | ... | ... |
src/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelDataRow.java
0 โ 100644
... | ... | @@ -0,0 +1,67 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +public class GroupInfoExcelDataRow { | |
6 | + private String groupName; | |
7 | + private String roowWxid; | |
8 | + private String filePath; | |
9 | + private String sendNickname; | |
10 | + | |
11 | + public GroupInfoExcelDataRow(GroupInfoExcelDataHeader header, List<Object> data) { | |
12 | + if(header.getFielPathIndex() != null && data.size() > header.getFielPathIndex()) { | |
13 | + this.filePath = data.get(header.getFielPathIndex()) == null ? "" : data.get(header.getFielPathIndex()).toString(); | |
14 | + } | |
15 | + if(header.getRoowWxidIndex() != null && data.size() > header.getRoowWxidIndex()) { | |
16 | + this.roowWxid = data.get(header.getRoowWxidIndex()) == null ? "" : data.get(header.getRoowWxidIndex()).toString(); | |
17 | + } | |
18 | + if(header.getGroupNameIndex() != null && data.size() > header.getGroupNameIndex()) { | |
19 | + this.groupName = data.get(header.getGroupNameIndex()) == null ? "" : data.get(header.getGroupNameIndex()).toString(); | |
20 | + } | |
21 | + if(header.getSenderNicknameIndex() != null && data.size() > header.getSenderNicknameIndex()) { | |
22 | + this.sendNickname = data.get(header.getSenderNicknameIndex()) == null ? "" : data.get(header.getSenderNicknameIndex()).toString(); | |
23 | + } | |
24 | + if(this.filePath == null) { | |
25 | + this.filePath = ""; | |
26 | + } | |
27 | + if(this.roowWxid == null) { | |
28 | + this.roowWxid = ""; | |
29 | + } | |
30 | + if(this.groupName == null) { | |
31 | + this.groupName = ""; | |
32 | + } | |
33 | + if(this.sendNickname == null) { | |
34 | + this.sendNickname = ""; | |
35 | + } | |
36 | + } | |
37 | + | |
38 | + | |
39 | + public String getSendNickname() { | |
40 | + return sendNickname; | |
41 | + } | |
42 | + | |
43 | + | |
44 | + public void setSendNickname(String sendNickname) { | |
45 | + this.sendNickname = sendNickname; | |
46 | + } | |
47 | + | |
48 | + | |
49 | + public String getGroupName() { | |
50 | + return groupName; | |
51 | + } | |
52 | + public void setGroupName(String groupName) { | |
53 | + this.groupName = groupName; | |
54 | + } | |
55 | + public String getRoowWxid() { | |
56 | + return roowWxid; | |
57 | + } | |
58 | + public void setRoowWxid(String roowWxid) { | |
59 | + this.roowWxid = roowWxid; | |
60 | + } | |
61 | + public String getFilePath() { | |
62 | + return filePath; | |
63 | + } | |
64 | + public void setFilePath(String filePath) { | |
65 | + this.filePath = filePath; | |
66 | + } | |
67 | +} | ... | ... |
src/com/taover/bazhuayun/analysis/script/goodscollect/Main.java
0 โ 100644
... | ... | @@ -0,0 +1,73 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.io.File; | |
4 | +import java.util.ArrayList; | |
5 | +import java.util.List; | |
6 | + | |
7 | +import cn.hutool.core.io.FileUtil; | |
8 | +import cn.hutool.core.util.CharsetUtil; | |
9 | +import cn.hutool.poi.excel.ExcelUtil; | |
10 | + | |
11 | +public class Main { | |
12 | + public static void main(String[] args) { | |
13 | + try { | |
14 | + analysisGoodsName(); | |
15 | + } catch (Exception e) { | |
16 | + // TODO Auto-generated catch block | |
17 | + e.printStackTrace(); | |
18 | + } | |
19 | + } | |
20 | + | |
21 | + public static void analysisGoodsName() throws Exception { | |
22 | + String[] goodsNamePatternArr = new String[]{"ๅๅๅ็งฐ","ๅๅๆ ้ข","่ดงๅๅ็งฐ","ๅๅๅ็งฐ","ๅๅไฟกๆฏ","ๅๅ","ๅๅๅๅท","ๅๅๅ","ๅๅ็ฎ็งฐ"}; | |
23 | + String[] goodsSkuNameParrternArr = new String[]{"ๅๅ่งๆ ผๅ","่งๆ ผ","ๅๅ่งๆ ผ","่งๆ ผๅ็งฐ","ๅๅๅๅท"}; | |
24 | + String groupInfoFilePath = "C:\\Users\\86136\\Desktop\\ๆ็ฉบๅฎถๆฐๆฎๅๆ\\groupinfo.xls"; | |
25 | + String goodsDataFileDirPath = "C:\\Users\\86136\\Desktop\\ๆ็ฉบๅฎถๆฐๆฎๅๆ\\data"; | |
26 | + String logFilePath = "C:\\Users\\86136\\Desktop\\ๆ็ฉบๅฎถๆฐๆฎๅๆ\\dealinfo.log"; | |
27 | + String resultDataFilePath = "C:\\Users\\86136\\Desktop\\ๆ็ฉบๅฎถๆฐๆฎๅๆ\\result.xls"; | |
28 | + | |
29 | + //ๅ ่ฝฝๅบ็กๆฐๆฎ๏ผๆไปถๆฅๆบ | |
30 | + GroupInfoExcelData groupInfoData = new GroupInfoExcelData(); | |
31 | + groupInfoData.load(groupInfoFilePath); | |
32 | + | |
33 | + //่ฏปๅๆไปถๅ่กจ๏ผไบค็ฑ่งฃๆๅจๅค็ | |
34 | + GoodsDataFileParser parser = new GoodsDataFileParser(goodsNamePatternArr, goodsSkuNameParrternArr, groupInfoData); | |
35 | + parser.setFileNameIgnorePreffix("ใๅผๅธธ็ฉๆตไฟกๆฏใ-"); | |
36 | + parser.parse(groupInfoData, new File(goodsDataFileDirPath).listFiles()); | |
37 | + | |
38 | + //็ปๆๅๅ ฅ็ปๆๆไปถ | |
39 | + ExcelUtil.getWriter(new File(resultDataFilePath)).write(transListBeanTo2List(parser.getResult())).flush(); | |
40 | + | |
41 | + //ๆง่กไฟกๆฏๅๅ ฅๆฅๅฟๆไปถ | |
42 | + FileUtil.writeString(parser.getLogString(), logFilePath, CharsetUtil.CHARSET_UTF_8); | |
43 | + } | |
44 | + | |
45 | + private static List<List<Object>> transListBeanTo2List(List<GoodsInfoRow> result) { | |
46 | + List<List<Object>> data = new ArrayList<List<Object>>(); | |
47 | + | |
48 | + //ๅ ๅ ฅHEADER | |
49 | + List<Object> header = new ArrayList<Object>(); | |
50 | + header.add("ๅ่กจๅ็งฐ"); | |
51 | + header.add("ๅๅๅ็งฐ"); | |
52 | + header.add("ๅ่กจ่งๆ ผ"); | |
53 | + header.add("่ช้่งๆ ผ"); | |
54 | + header.add("ไปๅบ็พคๅ็งฐ"); | |
55 | + header.add("ๅๆไปถ็ไบบ"); | |
56 | + data.add(header); | |
57 | + | |
58 | + //ๅ ๅ ฅBODY | |
59 | + for(int i=1; i<result.size(); ++i) { | |
60 | + GoodsInfoRow row = result.get(i); | |
61 | + List<Object> item = new ArrayList<Object>(); | |
62 | + item.add(row.getOriginGoodsName()); | |
63 | + item.add(row.getCommonGoodsName()); | |
64 | + item.add(row.getOriginGoodsSkuName()); | |
65 | + item.add(row.getCommonGoodsSkuName()); | |
66 | + item.add(row.getGroupNickname()); | |
67 | + item.add(row.getSenderNickname()); | |
68 | + data.add(item); | |
69 | + } | |
70 | + | |
71 | + return data; | |
72 | + } | |
73 | +} | ... | ... |
... | ... | @@ -0,0 +1,146 @@ |
1 | +package com.taover.bazhuayun.analysis.util; | |
2 | + | |
3 | +import java.io.File; | |
4 | +import java.util.ArrayList; | |
5 | +import java.util.Collections; | |
6 | +import java.util.HashMap; | |
7 | +import java.util.List; | |
8 | +import java.util.Map; | |
9 | +import java.util.Map.Entry; | |
10 | + | |
11 | +import com.taover.easyexcel.EasyExcel; | |
12 | + | |
13 | +import cn.hutool.core.text.csv.CsvRow; | |
14 | +import cn.hutool.core.text.csv.CsvUtil; | |
15 | +import cn.hutool.core.util.CharsetUtil; | |
16 | + | |
17 | +public class ExcelUtil { | |
18 | + private final static String CSV =".csv"; //csv | |
19 | + | |
20 | + private static boolean endWithCsv(String fileName) { | |
21 | + int dotIndex = fileName.lastIndexOf("."); | |
22 | + if(dotIndex < 0) { | |
23 | + return false; | |
24 | + } | |
25 | + String filteTypeLower = fileName.substring(dotIndex).trim().toLowerCase(); | |
26 | + if(CSV.equals(filteTypeLower)){ | |
27 | + return true; | |
28 | + } | |
29 | + return false; | |
30 | + } | |
31 | + | |
32 | + private static void checkFile(File dataFile) throws Exception{ | |
33 | + if(dataFile == null) { | |
34 | + throw new Exception("ๆชไผ ๅ ฅๆไปถๅผ็จ"); | |
35 | + } | |
36 | + if(!dataFile.exists()) { | |
37 | + throw new Exception("ๆไปถไธๅญๅจ["+dataFile.getAbsolutePath()+"]"); | |
38 | + } | |
39 | + } | |
40 | + | |
41 | + private static List<List<Object>> transCsvRowToList(List<CsvRow> rowData){ | |
42 | + List<List<Object>> data = new ArrayList<List<Object>>(); | |
43 | + if(rowData == null) { | |
44 | + return data; | |
45 | + } | |
46 | + for(CsvRow item: rowData) { | |
47 | + List<Object> itemData = new ArrayList<Object>(); | |
48 | + for(String cell: item.getRawList()) { | |
49 | + itemData.add(cell); | |
50 | + } | |
51 | + data.add(itemData); | |
52 | + } | |
53 | + return data; | |
54 | + } | |
55 | + | |
56 | + public static List<List<Object>> readExcelSheetAllForList(File dataFile, boolean readHiddenRow) throws Exception{ | |
57 | + checkFile(dataFile); | |
58 | + if(endWithCsv(dataFile.getName())) { | |
59 | + return transCsvRowToList(CsvUtil.getReader().read(dataFile, CharsetUtil.CHARSET_GBK).getRows()); | |
60 | + }else { | |
61 | + return transListMapTo2List(EasyExcel.read(dataFile).readHiddenRow(readHiddenRow).headRowNumber(0).doReadAllSync()); | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + public static Map<String, List<List<Object>>> readExcelSheetAllForMap(File dataFile, boolean readHiddenRow) throws Exception{ | |
66 | + checkFile(dataFile); | |
67 | + if(endWithCsv(dataFile.getName())) { | |
68 | + return Collections.singletonMap("0", transCsvRowToList(CsvUtil.getReader().read(dataFile, CharsetUtil.CHARSET_GBK).getRows())); | |
69 | + }else { | |
70 | + return transMapListMapToMap2List(EasyExcel.read(dataFile).readHiddenRow(readHiddenRow).headRowNumber(0).doReadAllSyncForMap()); | |
71 | + } | |
72 | + } | |
73 | + | |
74 | + private static Map<String, List<List<Object>>> transMapListMapToMap2List(Map<Integer, List<Map<Integer, Object>>> doReadAllSyncForMap) { | |
75 | + Map<String, List<List<Object>>> data = new HashMap<String, List<List<Object>>>(); | |
76 | + if(doReadAllSyncForMap == null) { | |
77 | + return data; | |
78 | + } | |
79 | + for(Entry<Integer, List<Map<Integer, Object>>> item: doReadAllSyncForMap.entrySet()) { | |
80 | + List<List<Object>> itemData = new ArrayList<List<Object>>(); | |
81 | + for(Map<Integer, Object> cellData: item.getValue()) { | |
82 | + itemData.add(transMapToList(cellData)); | |
83 | + } | |
84 | + data.put(item.getKey().toString(), itemData); | |
85 | + } | |
86 | + return data; | |
87 | + } | |
88 | + | |
89 | + private static List<List<Object>> transListMapTo2List(List<Object> listMapData) { | |
90 | + List<List<Object>> data = new ArrayList<List<Object>>(); | |
91 | + if(listMapData == null) { | |
92 | + return data; | |
93 | + } | |
94 | + for(Object item: listMapData) { | |
95 | + data.add(transMapToList((Map<Integer, Object>) item)); | |
96 | + } | |
97 | + return data; | |
98 | + } | |
99 | + | |
100 | + private static List<Object> transMapToList(Map<Integer, Object> cellData) { | |
101 | + List<Object> data = new ArrayList<Object>((int)(cellData.size()*1.5)); | |
102 | + if(cellData == null || cellData.isEmpty()) { | |
103 | + return data; | |
104 | + } | |
105 | + | |
106 | + //่ทๅๆๅคง็ดขๅผ | |
107 | + int maxIndex = 0; | |
108 | + for(Entry<Integer, Object> item: cellData.entrySet()) { | |
109 | + if(item.getKey() > maxIndex && item.getValue()!=null && !"".equals(item.getValue())) { | |
110 | + maxIndex = item.getKey(); | |
111 | + } | |
112 | + } | |
113 | + | |
114 | + //่ฎพ็ฝฎๅ ็ด ๅนถๅกซๅ ฅ็ฉบไธฒ | |
115 | + fillBlankToList(data, maxIndex+1); | |
116 | + | |
117 | + //็ฝฎๅ ฅๅ ็ด | |
118 | + int dataSize = data.size(); | |
119 | + for(Entry<Integer, Object> item: cellData.entrySet()) { | |
120 | + if(item.getKey() >= dataSize) { | |
121 | + continue; | |
122 | + } | |
123 | + if(item.getValue() == null) { | |
124 | + data.set(item.getKey(), ""); | |
125 | + }else { | |
126 | + data.set(item.getKey(), item.getValue()); | |
127 | + } | |
128 | + } | |
129 | + return data; | |
130 | + } | |
131 | + | |
132 | + private static void fillBlankToList(List<Object> data, int blankNumber) { | |
133 | + for(int i=0; i<blankNumber; ++i) { | |
134 | + data.add(""); | |
135 | + } | |
136 | + } | |
137 | + | |
138 | + public static List<List<Object>> readExcelSheet(File dataFile, boolean readHiddenRow) throws Exception{ | |
139 | + checkFile(dataFile); | |
140 | + if(endWithCsv(dataFile.getName())) { | |
141 | + return transCsvRowToList(CsvUtil.getReader().read(dataFile, CharsetUtil.CHARSET_GBK).getRows()); | |
142 | + }else { | |
143 | + return transListMapTo2List(EasyExcel.read(dataFile).readHiddenRow(readHiddenRow).headRowNumber(0).doReadSelectedSync()); | |
144 | + } | |
145 | + } | |
146 | +} | ... | ... |
src/com/taover/bazhuayun/analysis/util/StringTool.java
0 โ 100644
... | ... | @@ -0,0 +1,193 @@ |
1 | +package com.taover.bazhuayun.analysis.util; | |
2 | + | |
3 | +import java.lang.reflect.Field; | |
4 | +import java.util.ArrayList; | |
5 | +import java.util.Arrays; | |
6 | +import java.util.List; | |
7 | + | |
8 | +import org.apache.commons.lang.StringUtils; | |
9 | + | |
10 | +import com.taover.util.UtilString; | |
11 | + | |
12 | + | |
13 | +public class StringTool { | |
14 | + public static String sortSplitStr(String cutTime, String splitStr, boolean isRemoveSame) { | |
15 | + if(cutTime == null || cutTime.isEmpty()) { | |
16 | + return cutTime; | |
17 | + } | |
18 | + String[] cutTimeArr = cutTime.split(splitStr); | |
19 | + List<String> data = new ArrayList<String>(cutTimeArr.length); | |
20 | + for(String item: cutTimeArr) { | |
21 | + int insertIndex = -1; | |
22 | + boolean isSame = false; | |
23 | + for(int i=0; i<data.size(); ++i) { | |
24 | + if(item.compareTo(data.get(i)) < 0){ | |
25 | + insertIndex = i; | |
26 | + }else if(item.compareTo(data.get(i)) == 0){ | |
27 | + insertIndex = i; | |
28 | + isSame = true; | |
29 | + } | |
30 | + } | |
31 | + if(isSame && isRemoveSame) { | |
32 | + continue; | |
33 | + } | |
34 | + if(insertIndex == -1) { | |
35 | + data.add(item); | |
36 | + }else if(insertIndex >= 0){ | |
37 | + data.add(insertIndex, item); | |
38 | + } | |
39 | + } | |
40 | + return StringUtils.join(data, ","); | |
41 | + } | |
42 | + | |
43 | + public static String getOrTruncStr(String data, int allowLen) { | |
44 | + if(data == null) { | |
45 | + return ""; | |
46 | + } | |
47 | + byte[] dataByte = data.getBytes(); | |
48 | + if(dataByte.length > allowLen) { | |
49 | + return new String(dataByte, 0, allowLen); | |
50 | + }else { | |
51 | + return data; | |
52 | + } | |
53 | + } | |
54 | + | |
55 | + public static List<String> splitByStringArr(String source, String[] patterns) { | |
56 | + List<String> result = new ArrayList<String>(); | |
57 | + if(source == null) { | |
58 | + return result; | |
59 | + } | |
60 | + if(patterns == null || patterns.length == 0) { | |
61 | + result.add(source); | |
62 | + return result; | |
63 | + } | |
64 | + String patternStr = StringUtils.join(patterns); | |
65 | + int subSourceStartIndex = 0; | |
66 | + for(int i=0; i<source.length(); ++i) { | |
67 | + String item = source.substring(i, i+1); | |
68 | + if(patternStr.contains(item)) { | |
69 | + if(i > subSourceStartIndex) { | |
70 | + result.add(source.substring(subSourceStartIndex, i)); | |
71 | + } | |
72 | + subSourceStartIndex = i+1; | |
73 | + } | |
74 | + } | |
75 | + if(subSourceStartIndex < source.length()) { | |
76 | + result.add(source.substring(subSourceStartIndex, source.length())); | |
77 | + } | |
78 | + return result; | |
79 | + } | |
80 | + | |
81 | + public static List<String> removeSuffixSplitOrder(List<String> data) { | |
82 | + List<String> result = new ArrayList<String>(); | |
83 | + if(data == null || data.isEmpty()) { | |
84 | + return result; | |
85 | + } | |
86 | + for(String item: data) { | |
87 | + item = item.trim(); | |
88 | + if(item.contains("-") && item.startsWith("W20")) { | |
89 | + String tempSubStr = item.substring(0, item.indexOf("-")); | |
90 | + if(StringUtils.isNotBlank(tempSubStr)) { | |
91 | + result.add(tempSubStr.trim()); | |
92 | + } | |
93 | + }else { | |
94 | + result.add(item); | |
95 | + } | |
96 | + } | |
97 | + return result; | |
98 | + } | |
99 | + | |
100 | + public static void trimObject(Object targetObj) { | |
101 | + Field[] tField = targetObj.getClass().getDeclaredFields(); | |
102 | + for(int i=0; i<tField.length; ++i) { | |
103 | + Field item = tField[i]; | |
104 | + item.setAccessible(true); | |
105 | + if("String".equals(item.getType().getSimpleName())) { | |
106 | + try { | |
107 | + Object data = item.get(targetObj); | |
108 | + if(data == null) { | |
109 | + continue; | |
110 | + } | |
111 | + item.set(targetObj, UtilString.trimByRegexS(data.toString())); | |
112 | + } catch (Exception e) { | |
113 | + e.printStackTrace(); | |
114 | + } | |
115 | + } | |
116 | + } | |
117 | + } | |
118 | + | |
119 | + public static List<String> replaceAll(List<String> data, String pattern, String target){ | |
120 | + List<String> result = new ArrayList<String>(); | |
121 | + if(data == null || data.isEmpty()) { | |
122 | + return result; | |
123 | + } | |
124 | + for(String item: data) { | |
125 | + result.add(item.replaceAll(pattern, target)); | |
126 | + } | |
127 | + return result; | |
128 | + } | |
129 | + | |
130 | + public static int getStartWithStringIndex(String pattern, String compares[]){ | |
131 | + //ๅๆฐๆฃ้ช | |
132 | + if(pattern==null || compares==null){ | |
133 | + return -1; | |
134 | + } | |
135 | + | |
136 | + //ๅพช็ฏ้ๅcompares | |
137 | + for(int i=0; i<compares.length; ++i){ | |
138 | + if(compares[i].startsWith(pattern)){ | |
139 | + return i; | |
140 | + } | |
141 | + } | |
142 | + return -1; | |
143 | + } | |
144 | + | |
145 | + public static int getStartWithStringIndex(String pattern, List<String> compares){ | |
146 | + //ๅๆฐๆฃ้ช | |
147 | + if(pattern==null || compares==null){ | |
148 | + return -1; | |
149 | + } | |
150 | + | |
151 | + //ๅพช็ฏ้ๅcompares | |
152 | + for(int i=0; i<compares.size(); ++i){ | |
153 | + if(compares.get(i).startsWith(pattern)){ | |
154 | + return i; | |
155 | + } | |
156 | + } | |
157 | + return -1; | |
158 | + } | |
159 | + | |
160 | + public static void main(String args[]) { | |
161 | + //String source = ";SF1 SF2; SF3๏ผSF4,SF5;"; | |
162 | + //System.out.println(splitByStringArr(source, new String[] {";๏ผ ,"})); | |
163 | + | |
164 | +// User u1 = new User(null, 12, null); | |
165 | +// trimObject(u1); | |
166 | +// System.out.println(u1.toString()); | |
167 | +// User u2 = new User(" d s ", 12, null); | |
168 | +// trimObject(u2); | |
169 | +// System.out.println(u2.toString()); | |
170 | +// User u3 = new User("* 3223 ", 12, null); | |
171 | +// trimObject(u3); | |
172 | +// System.out.println(u3.toString()); | |
173 | + | |
174 | + //System.out.println(StringUtils.join(StringTool.splitByStringArr("asdfasdf\nsdfsdf", ColumnDataBean.SPLIT_INFO_CHAR_ARR), "<->")); | |
175 | + System.out.println(replaceAll(Arrays.asList("asdf๏ผasdfasdf"), "[;๏ผ]", " ")); | |
176 | + } | |
177 | +} | |
178 | + | |
179 | +class User{ | |
180 | + private String name = "2323"; | |
181 | + private int age = 1; | |
182 | + private List<User> data; | |
183 | + public User(String name, int age, List<User> data) { | |
184 | + super(); | |
185 | + this.name = name; | |
186 | + this.age = age; | |
187 | + this.data = data; | |
188 | + } | |
189 | + @Override | |
190 | + public String toString() { | |
191 | + return "User [name=" + name + ", age=" + age + ", data=" + data + "]"; | |
192 | + } | |
193 | +} | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +package com.taover.bazhuayun.analysis.web; | |
2 | + | |
3 | +import org.apache.catalina.connector.Connector; | |
4 | +import org.springframework.boot.SpringApplication; | |
5 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
6 | +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | |
7 | +import org.springframework.boot.web.servlet.server.ServletWebServerFactory; | |
8 | +import org.springframework.context.ConfigurableApplicationContext; | |
9 | +import org.springframework.context.annotation.Bean; | |
10 | +import org.springframework.context.annotation.EnableAspectJAutoProxy; | |
11 | +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; | |
12 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |
13 | +import org.springframework.web.util.UrlPathHelper; | |
14 | + | |
15 | +@SpringBootApplication | |
16 | +@EnableAspectJAutoProxy(exposeProxy=true, proxyTargetClass=true) | |
17 | +public class StartUp implements WebMvcConfigurer { | |
18 | + public static ConfigurableApplicationContext context; | |
19 | + | |
20 | + public static void main(String[] args) { | |
21 | + System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true"); | |
22 | + StartUp.context = SpringApplication.run(StartUp.class, args); | |
23 | + } | |
24 | + | |
25 | + @Override | |
26 | + public void configurePathMatch(PathMatchConfigurer configurer) { | |
27 | + UrlPathHelper urlPathHelper = new UrlPathHelper(); | |
28 | + urlPathHelper.setUrlDecode(false); | |
29 | + configurer.setUrlPathHelper(urlPathHelper); | |
30 | + } | |
31 | + | |
32 | + @Bean | |
33 | + public ServletWebServerFactory servletContainer() { | |
34 | + TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); | |
35 | + tomcat.addAdditionalTomcatConnectors(createStandardConnector()); | |
36 | + return tomcat; | |
37 | + } | |
38 | + | |
39 | + private Connector createStandardConnector() { | |
40 | + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); | |
41 | + connector.setPort(0); | |
42 | + return connector; | |
43 | + } | |
44 | +} | |
0 | 45 | \ No newline at end of file | ... | ... |